/*
  NAVIG shared UI layer. Loaded by every app page via templates/_nv/head.html (last in <head>).
  One accent, one radius, one type family, light + dark. Matches the homepage (index.css).

  Contract for page CSS:
    - Use the --nv-* tokens instead of hard-coded colours, radii and fonts.
    - Opt a page into the base look with <body class="nv">.
    - Shared chrome: templates/_nv/bar.html (top bar), templates/_nv/foot.html (content pages only).
    - Full-viewport apps (maps): use height: calc(100dvh - var(--nv-bar-h)) under the bar.
*/

@font-face {
    font-family: "Geist";
    src: url("/static/fonts/geist-vf.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Geist Mono";
    src: url("/static/fonts/geist-mono-vf.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --nv-font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --nv-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --nv-ease: cubic-bezier(0.16, 1, 0.3, 1);

    --nv-r: 6px;          /* the one corner radius */
    --nv-bar-h: 56px;
    --nv-wrap: 1180px;
    --nv-gut: clamp(16px, 4vw, 32px);

    --nv-accent: #e9b83a;       /* transit yellow, the only accent */
    --nv-accent-ink: #17150e;   /* text on a filled accent */

    --nv-bg: #ecedee;
    --nv-surface: #f6f6f7;
    --nv-raised: #ffffff;       /* popovers, modals, sheets */
    --nv-ink: #121316;
    --nv-muted: #555a62;
    --nv-line: rgba(18, 19, 22, 0.14);
    --nv-shadow: 0 24px 48px -24px rgba(28, 36, 56, 0.4);

    /* status colours: semantic only (good / warn / bad / info), never decoration */
    --nv-ok: #1f8a4c;
    --nv-warn: #b7791f;
    --nv-bad: #c53030;
    --nv-info: #2b6cb0;
    color-scheme: light;
}

/* ---------- Opt-in page base ---------- */

body.nv {
    margin: 0;
    background: var(--nv-bg);
    color: var(--nv-ink);
    font-family: var(--nv-font);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.nv-wrap {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--nv-wrap);
    margin-inline: auto;
    padding-inline: var(--nv-gut);
}

.nv-icon { width: 1em; height: 1em; fill: currentColor; flex: none; }

.nv-skip {
    position: fixed;
    left: 16px; top: -64px;
    z-index: 10000;
    padding: 10px 16px;
    background: var(--nv-ink);
    color: var(--nv-bg);
    border-radius: var(--nv-r);
    font: 500 0.9375rem var(--nv-font);
    text-decoration: none;
    transition: top 0.2s var(--nv-ease);
}
.nv-skip:focus { top: 12px; }

.nv :focus-visible,
.nv-bar :focus-visible,
.nv-foot :focus-visible {
    outline: 2px solid var(--nv-ink);
    outline-offset: 2px;
    border-radius: var(--nv-r);
}

/* ---------- App bar ---------- */

.nv-bar {
    position: sticky;
    top: 0;
    z-index: 2000;               /* above Leaflet panes (max 1000) and controls */
    height: var(--nv-bar-h);
    background: color-mix(in srgb, var(--nv-bg) 88%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--nv-line);
    font-family: var(--nv-font);
    font-size: 0.9375rem;
    line-height: 1.2;
    color: var(--nv-ink);
}
.nv-bar--static { position: relative; }

.nv-bar *, .nv-foot * { box-sizing: border-box; }
.nv-bar a, .nv-foot a { color: inherit; text-decoration: none; }

.nv-bar-in {
    height: 100%;
    max-width: var(--nv-wrap);
    margin-inline: auto;
    padding-inline: var(--nv-gut);
    display: flex;
    align-items: center;
    gap: 14px;
}

.nv-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 650;
    font-size: 1.0625rem;
    letter-spacing: -0.02em;
}
.nv-brand img { width: 26px; height: 26px; border-radius: var(--nv-r); }

.nv-crumb {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--nv-muted);
    font-weight: 500;
}
.nv-crumb-sep { margin-right: 10px; opacity: 0.5; }

.nv-links {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}
.nv-links > a,
.nv-apps-btn {
    padding: 8px 12px;
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--nv-muted);
    cursor: pointer;
    border-radius: var(--nv-r);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}
.nv-links > a:hover,
.nv-apps-btn:hover,
.nv-apps-btn[aria-expanded="true"] { color: var(--nv-ink); background: var(--nv-surface); }
.nv-apps-btn .nv-icon { transition: transform 0.35s var(--nv-ease); }
.nv-apps-btn[aria-expanded="true"] .nv-icon { transform: rotate(180deg); }

.nv-apps { position: relative; }
.nv-apps-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: min(680px, calc(100vw - 32px));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 20px;
    background: var(--nv-raised);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    box-shadow: var(--nv-shadow);
    transform-origin: 85% 0;
}
.nv-apps-panel[hidden] { display: none; }
.nv-apps-panel.is-open { animation: nv-pop 0.35s var(--nv-ease); }
.nv-apps-col { display: grid; align-content: start; gap: 2px; }
.nv-apps-col h2 {
    margin: 0 0 6px;
    font: 500 0.6875rem var(--nv-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nv-muted);
}
.nv-apps-col a {
    padding: 6px 0;
    color: var(--nv-ink);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.25s var(--nv-ease), color 0.2s;
}
.nv-apps-col a:hover { transform: translateX(3px); }
.nv-apps-col a .nv-icon { color: var(--nv-muted); }

@keyframes nv-pop {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.nv-tools { display: flex; align-items: center; gap: 8px; }
.nv-links + .nv-tools { margin-left: 0; }

.nv-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    padding: 0;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    background: transparent;
    color: var(--nv-ink);
    font-size: 1.125rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s var(--nv-ease);
}
.nv-icon-btn:hover { background: var(--nv-surface); }
.nv-icon-btn:active { transform: scale(0.94); }

.nv-menu { display: none; }
.nv-menu .nv-i-close { display: none; }
.nv-menu[aria-expanded="true"] .nv-i-close { display: block; }
.nv-menu[aria-expanded="true"] .nv-i-open { display: none; }

@media (max-width: 760px) {
    .nv-menu { display: inline-grid; }
    .nv-bar-in { gap: 10px; }
    .nv-links + .nv-tools { margin-left: auto; }
    .nv-links {
        position: absolute;
        left: 0; right: 0; top: 100%;
        margin: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px var(--nv-gut) 16px;
        background: var(--nv-bg);
        border-bottom: 1px solid var(--nv-line);
        max-height: calc(100dvh - var(--nv-bar-h));
        overflow-y: auto;
    }
    .nv-links.is-open { display: flex; }
    .nv-links > a, .nv-apps-btn { padding: 14px 4px; border-bottom: 1px solid var(--nv-line); border-radius: 0; width: 100%; justify-content: space-between; }
    .nv-apps { position: static; }
    .nv-apps-panel { position: static; width: auto; grid-template-columns: 1fr 1fr; margin-top: 8px; box-shadow: none; }
}

/* ---------- Footer (content pages) ---------- */

.nv-foot {
    margin-top: 80px;
    border-top: 1px solid var(--nv-line);
    font-family: var(--nv-font);
    font-size: 0.875rem;
    color: var(--nv-muted);
    background: var(--nv-bg);
}
.nv-foot-in {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
    padding-block: 28px;
}
.nv-foot .nv-brand { color: var(--nv-ink); font-size: 1rem; }
.nv-foot-links { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.nv-foot-links a, .nv-foot-note a { transition: color 0.2s; }
.nv-foot-links a:hover { color: var(--nv-ink); }
.nv-foot-note { margin: 0; }
.nv-foot-note a { color: var(--nv-ink); text-decoration: underline; text-decoration-color: var(--nv-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ---------- Primitives (opt in with the nv- classes) ---------- */

.nv-h1 { font: 700 clamp(2rem, 4.5vw, 3.25rem)/1.05 var(--nv-font); letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
.nv-h2 { font: 650 clamp(1.375rem, 2.4vw, 1.75rem)/1.15 var(--nv-font); letter-spacing: -0.025em; margin: 0; }
.nv-lede { color: var(--nv-muted); font-size: 1.0625rem; max-width: 62ch; margin: 0; }
.nv-mono { font-family: var(--nv-mono); }
.nv-label { font: 500 0.75rem var(--nv-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--nv-muted); }

.nv-card {
    background: var(--nv-surface);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    padding: 20px;
}

.nv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid var(--nv-ink);
    border-radius: var(--nv-r);
    background: var(--nv-ink);
    color: var(--nv-bg);
    font: 500 0.9375rem var(--nv-font);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s var(--nv-ease), background 0.2s, color 0.2s, border-color 0.2s;
}
.nv-btn:hover { transform: translateY(-1px); }
.nv-btn:active { transform: scale(0.97); }
.nv-btn--ghost { background: transparent; color: var(--nv-ink); border-color: var(--nv-line); }
.nv-btn--ghost:hover { background: var(--nv-surface); }
.nv-btn--accent { background: var(--nv-accent); border-color: var(--nv-accent); color: var(--nv-accent-ink); }
.nv-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.nv-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    background: var(--nv-surface);
    color: var(--nv-ink);
    font: 400 1rem var(--nv-font);   /* 16px prevents iOS zoom */
    transition: border-color 0.2s, box-shadow 0.2s;
}
.nv-input::placeholder { color: var(--nv-muted); }
.nv-input:focus { outline: none; border-color: var(--nv-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--nv-accent) 45%, transparent); }

.nv-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    background: transparent;
    color: var(--nv-ink);
    font: 500 0.875rem var(--nv-font);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s var(--nv-ease);
}
.nv-chip:hover { background: var(--nv-surface); }
.nv-chip:active { transform: scale(0.96); }
.nv-chip[aria-pressed="true"],
.nv-chip.is-active { background: var(--nv-ink); border-color: var(--nv-ink); color: var(--nv-bg); }

.nv-tag {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r);
    font: 500 0.75rem var(--nv-mono);
    color: var(--nv-muted);
}

.nv-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.nv-table th { text-align: left; font: 500 0.75rem var(--nv-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--nv-muted); padding: 10px 12px; border-bottom: 1px solid var(--nv-line); }
.nv-table td { padding: 12px; border-bottom: 1px solid var(--nv-line); }
.nv-table tbody tr { transition: background 0.2s; }
.nv-table tbody tr:hover { background: var(--nv-surface); }

/* Long-form text (blog, privacy) */
.nv-prose { max-width: 70ch; font-size: 1.0625rem; line-height: 1.7; }
.nv-prose h2 { font: 650 1.5rem/1.2 var(--nv-font); letter-spacing: -0.02em; margin: 2.2em 0 0.6em; }
.nv-prose h3 { font: 650 1.2rem/1.25 var(--nv-font); margin: 1.8em 0 0.5em; }
.nv-prose a { text-decoration: underline; text-decoration-color: var(--nv-accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.nv-prose code { font-family: var(--nv-mono); font-size: 0.9em; background: var(--nv-surface); border: 1px solid var(--nv-line); border-radius: var(--nv-r); padding: 1px 6px; }
.nv-prose pre { background: var(--nv-surface); border: 1px solid var(--nv-line); border-radius: var(--nv-r); padding: 16px; overflow-x: auto; }
.nv-prose pre code { background: none; border: 0; padding: 0; }
.nv-prose img { border-radius: var(--nv-r); }
.nv-prose blockquote { margin: 1.5em 0; padding-left: 18px; border-left: 3px solid var(--nv-accent); color: var(--nv-muted); }

/* ---------- Maps: Leaflet themed by the same tokens (opt in with class nv-map on the map element's ancestor, or body.nv) ---------- */

.nv .leaflet-container { font-family: var(--nv-font); background: var(--nv-surface); }
.nv .leaflet-popup-content-wrapper,
.nv .leaflet-popup-tip {
    background: var(--nv-raised);
    color: var(--nv-ink);
    border-radius: var(--nv-r);
    box-shadow: var(--nv-shadow);
}
.nv .leaflet-popup-content { font-size: 0.9375rem; line-height: 1.45; }
.nv .leaflet-popup-close-button { color: var(--nv-muted) !important; }
.nv .leaflet-bar { border: 1px solid var(--nv-line); border-radius: var(--nv-r); box-shadow: none; overflow: hidden; }
.nv .leaflet-bar a,
.nv .leaflet-bar a:hover {
    background: var(--nv-raised);
    color: var(--nv-ink);
    border-bottom-color: var(--nv-line);
}
.nv .leaflet-bar a:hover { background: var(--nv-surface); }
.nv .leaflet-control-attribution { background: color-mix(in srgb, var(--nv-bg) 80%, transparent) !important; color: var(--nv-muted); font-size: 0.6875rem; }
.nv .leaflet-control-attribution a { color: var(--nv-ink); }
@media (prefers-reduced-motion: reduce) {
    .nv-bar *, .nv-foot *, .nv-btn, .nv-chip { transition: none !important; animation: none !important; }
}


/* ---------- Shared map controls ---------- */
.nv .leaflet-bar a { width: 36px; height: 36px; line-height: 36px; font-size: 1.125rem; }
.nv .leaflet-bottom.leaflet-right { margin-bottom: 4px; }
.nv .nv-locate { margin-right: 12px; }
.nv .nv-locate .nv-locate-btn, .nv .nv-locate .nv-locate-btn:hover { display: grid; place-items: center; width: 48px; height: 48px; line-height: 48px; background: var(--nv-accent); color: var(--nv-accent-ink); }
.nv .nv-locate-btn svg { width: 24px; height: 24px; }
/* Phone More stack sits at the bottom-right too: lift the locate control above it */
body.nv-fab .leaflet-bottom.leaflet-right { margin-bottom: 76px; }
/* Pages with a bottom sheet (.panel): keep the control above it while it is open */
@media (max-width: 768px) { body.nv:has(.panel:not(.hidden)) .leaflet-bottom.leaflet-right { bottom: var(--panel-h, 46dvh); } }
.nv .nv-locate-btn.is-busy svg { animation: nv-pulse 0.9s ease-in-out infinite; }
.nv .nv-locate .nv-locate-btn.is-on { background: var(--nv-info); color: #fff; }
.nv .nv-locate .nv-locate-btn.is-error { background: var(--nv-bad); color: #fff; }
@keyframes nv-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .nv .nv-locate-btn.is-busy svg { animation: none; opacity: 0.5; } }
@media (pointer: coarse) { .nv .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; } }
/* Phones: icon-only brand, the page name carries the context */
@media (max-width: 600px) {
    .nv-bar .nv-brand .nv-word { display: none; }
    .nv-bar .nv-brand { gap: 0; }
    .nv-bar .nv-brand img { width: 28px; height: 28px; }
    .nv-crumb-sep { display: none; }
    .nv-bar .nv-crumb { font-weight: 600; color: var(--nv-ink); }
}

/* ---------- Touch: 44px hit areas for small text links ---------- */
@media (pointer: coarse) {
    .nv-brand { min-height: 44px; }
    .nv-foot-links a, .nv-foot-note a { display: inline-flex; align-items: center; min-height: 44px; }
    .nv-foot-links { gap: 0 16px; }
    .nv-apps-col a { min-height: 44px; }
    .nv-prose a, .nv-label a { padding-block: 4px; }
}

/* ---------- Phone declutter: fewer chrome elements around the map ---------- */
@media (max-width: 600px) {
  /* Pinch-zoom is native; the +/- stack only adds noise on touch screens. */
  .leaflet-touch .leaflet-control-zoom { display: none; }
  /* Sheet tab strips: one quiet row, scrollable, no badges or group boxes. */
  .panel .panel-tabs { gap: 0; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; padding-right: 8px; }
  .panel .ptab-group { gap: 0; background: none; border: 0; flex: 0 0 auto; }
  .panel .ptab { min-width: 0; padding: 0.45rem 0.8rem; flex: 0 0 auto; white-space: nowrap; scroll-snap-align: start; }
  .panel .ptab-tag { display: none; }
  .panel .panel-header { padding-inline: 4px; gap: 0; }
}

/* ---------- Shared popup + pin vocabulary (each page keeps its own content and colours) ---------- */
/* Popup: flat raised card, hairline border, no tip, same type scale and close target. */
.nv .leaflet-popup-content-wrapper { border: 1px solid var(--nv-line); border-radius: var(--nv-r); box-shadow: 0 8px 24px -12px rgba(28, 36, 56, 0.35); padding: 0; overflow: hidden; }
.nv .leaflet-popup-tip-container { display: none; }
.nv .leaflet-popup { margin-bottom: 14px; }
.nv .leaflet-popup-content { margin: 12px 14px; font-size: 0.875rem; line-height: 1.45; }
.nv .leaflet-popup-content h1, .nv .leaflet-popup-content h2, .nv .leaflet-popup-content h3, .nv .leaflet-popup-content h4 { margin: 0 0 6px; font-size: 1rem; line-height: 1.25; font-weight: 700; color: var(--nv-ink); }
.nv .leaflet-popup-content a { color: var(--nv-ink); text-underline-offset: 3px; }
.nv .leaflet-container a.leaflet-popup-close-button { top: 4px; right: 4px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font: 400 20px/1 var(--nv-font); color: var(--nv-muted); border-radius: var(--nv-r); }
.nv .leaflet-container a.leaflet-popup-close-button:hover { background: var(--nv-surface); color: var(--nv-ink); }
.nv .leaflet-popup-content h1:first-child, .nv .leaflet-popup-content h2:first-child, .nv .leaflet-popup-content h3:first-child, .nv .leaflet-popup-content h4:first-child { padding-right: 28px; }
/* Popup actions: one primary button look. Use .nv-pop-btn in new markup. */
.nv-pop-btn, .nv .stn-popup-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-radius: var(--nv-r); background: var(--nv-accent); color: var(--nv-accent-ink); font: 700 0.8125rem/1 var(--nv-font); text-decoration: none; cursor: pointer; transition: transform .18s var(--nv-ease), background .18s var(--nv-ease); }
.nv-pop-btn:active, .nv .stn-popup-btn:active { transform: scale(.97); }
/* Pins: icon pins are a 6px tile, point pins and clusters are discs; both share the same rim. */
.nv .incident-marker, .nv .faulty-light-marker, .nv .emoji-icon { background: var(--nv-raised); border: 1px solid var(--nv-line); box-shadow: 0 1px 3px rgba(28, 36, 56, 0.3); }
.nv .faulty-light-marker { border-radius: var(--nv-r); }
.nv .pin, .nv .bike-cluster, .nv .ev-cluster { border: 2px solid var(--nv-raised); box-shadow: 0 1px 3px rgba(28, 36, 56, 0.4); }
.nv .bike-cluster, .nv .ev-cluster { color: var(--nv-accent-ink); }
/* "You are here" dot: same blue everywhere (matches the My location control). */
.nv .pin.you, .nv .user-location-icon { color: #2f6fed; }
.nv .pin.you { background: #2f6fed; border-color: #fff; }
@media (pointer: coarse) { .nv .leaflet-container a.leaflet-popup-close-button { width: 40px; height: 40px; } }
.nv .bike-info-body .details { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.nv .bike-info-body .details span + span::before { content: ""; display: inline-block; width: 3px; height: 3px; margin-right: 12px; border-radius: 50%; background: var(--nv-muted); vertical-align: middle; }

/* Phone "More" stack (built by navig-map.js): shortcuts hide behind one button. */
.nv-more { display: none; }
@media (max-width: 600px) {
    body.nv-fab .nv-more { position: fixed; z-index: 1200; right: 12px; bottom: 24px; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--nv-line); border-radius: var(--nv-r); background: var(--nv-raised); color: var(--nv-ink); cursor: pointer; }
    body.nv-fab.nv-fab-open .nv-more { background: var(--nv-accent); color: var(--nv-accent-ink); }
    body.nv-fab .nv-fab-item { display: none !important; }
    body.nv-fab.nv-fab-open .nv-fab-item { display: flex !important; position: fixed !important; z-index: 1200; top: auto !important; left: auto !important; right: 12px !important; bottom: calc(24px + 52px * (var(--nv-fab-i) + 1)) !important; width: 44px; height: 44px; margin: 0; }
    body.nv-fab #map-legend { bottom: 80px; }
}
@media (max-width: 600px) { body.nv-fab .location-button { top: calc(var(--nv-bar-h) + 64px) !important; } }
