/* =========================================================
 *  Vulture — vintage timetable / departure-board aesthetic.
 *
 *  The page is the chrome (cream paper, deep ink, editorial
 *  serif headings); the journey output is the act (pitch
 *  black with amber monospace, like a Solari split-flap board
 *  at a European train station).
 * ========================================================= */

:root {
    /* Paper-and-ink chrome */
    --paper:        #f1ebde;
    --paper-deep:   #ebe2d0;
    --ink:          #15110b;
    --rule:         rgba(21, 17, 11, 0.16);
    --rule-strong:  rgba(21, 17, 11, 0.5);
    --muted:        #5a4f3d;
    --muted-soft:   #8a7d68;

    /* Departure-board palette (used regardless of light/dark mode
       so the journey output always reads as a real board) */
    --board:        #08070a;
    --board-soft:   #14121a;
    --board-rule:   rgba(239, 179, 94, 0.20);
    --amber:        #f0b441;
    --amber-dim:    rgba(240, 180, 65, 0.55);
    --amber-bright: #ffce63;

    /* Single accent — railway-signage red, used sparingly */
    --rail:         #c2342b;

    /* Typography */
    --serif:  "Fraunces", "Georgia", "Times New Roman", serif;
    --sans:   "Bricolage Grotesque", -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:   "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper:        #14110a;
        --paper-deep:   #1c1810;
        --ink:          #ebe1cc;
        --rule:         rgba(235, 225, 204, 0.18);
        --rule-strong:  rgba(235, 225, 204, 0.55);
        --muted:        #8a7d68;
        --muted-soft:   #5a4f3d;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-feature-settings: "ss01", "cv11", "tnum";
    font-size: 16px;
    line-height: 1.55;
    /* Subtle paper grain — a tiny SVG noise turbulence at low opacity.
       Doesn't request a separate file; rendered by the browser. */
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.045 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--rule-strong);
    transition: color 120ms, border-color 120ms;
}
a:hover { color: var(--rail); border-bottom-color: var(--rail); }

::selection { background: var(--ink); color: var(--paper); }

/* Container ------------------------------------------------ */

header, main, footer {
    max-width: 980px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

header {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--rule);
    position: relative;
}

main {
    padding-top: 1rem;
    padding-bottom: 4rem;
}

/* Brand ---------------------------------------------------- */

.brand {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.brand h1 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 500;
    font-variation-settings: "opsz" 144, "SOFT" 30;
    font-size: clamp(3.5rem, 10vw, 7rem);
    line-height: 0.92;
    letter-spacing: -0.025em;
    color: var(--ink);
    animation: rise 700ms cubic-bezier(0.2, 0.8, 0.3, 1) 100ms both;
}

.brand h1 .word {
    display: inline-block;
}

.kicker {
    margin: 0.4rem 0 0;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--muted);
    animation: rise 700ms cubic-bezier(0.2, 0.8, 0.3, 1) 220ms both;
}

.lede {
    margin: 1.6rem 0 0;
    max-width: 62ch;
    font-family: var(--serif);
    font-variation-settings: "opsz" 24, "SOFT" 0;
    font-weight: 400;
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--ink);
    animation: rise 700ms cubic-bezier(0.2, 0.8, 0.3, 1) 320ms both;
}

.lede em {
    font-weight: 700;
    color: var(--rail);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(0.4em); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Feed banner --------------------------------------------- */

.feed-loader {
    margin-top: 1.5rem;
    margin-bottom: 2.5rem;
    padding: 1.3rem 1.5rem;
    background: var(--paper-deep);
    border: 1px solid var(--rule);
    border-radius: 0;  /* sharp corners throughout */
    position: relative;
}

.feed-loader::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--rail);
}

.feed-current {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem 1rem;
}

.feed-current .label {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--muted);
}

#feed-name {
    font-family: var(--serif);
    font-weight: 600;
    font-variation-settings: "opsz" 24, "SOFT" 0;
    font-size: 1.25rem;
    color: var(--ink);
}

.feed-current .muted {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.85rem;
    font-feature-settings: "tnum";
}

.feed-loader details {
    margin-top: 0.9rem;
    border-top: 1px solid var(--rule);
    padding-top: 0.9rem;
}

.feed-loader summary {
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
    user-select: none;
    list-style: none;
    transition: color 120ms;
}
.feed-loader summary::-webkit-details-marker { display: none; }
.feed-loader summary:hover { color: var(--rail); }
.feed-loader summary::before {
    content: "›";
    display: inline-block;
    margin-right: 0.55em;
    font-style: normal;
    transform: translateY(-1px);
    transition: transform 200ms;
}
.feed-loader details[open] summary::before { transform: rotate(90deg) translateX(-1px); }

.feed-progress {
    margin-top: 0.9rem;
    font-family: var(--mono);
    font-size: 0.8rem;
}

.feed-progress .bar {
    width: 100%;
    height: 4px;
    background: var(--rule);
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.feed-progress .fill {
    height: 100%;
    background: var(--rail);
    width: 0%;
    transition: width 120ms linear;
}

.feed-progress .status {
    color: var(--muted);
    font-feature-settings: "tnum";
}

.feed-progress.error .status { color: var(--rail); }

/* "Feed features" introspection panel: a definition list of the
 * counts vulture surfaces from `tt.features()`, plus an advisory
 * suggestions list. Styled to sit between the feed summary and the
 * feed loader without competing visually. */
.feed-features-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1.2rem;
    row-gap: 0.4rem;
    margin: 0.9rem 0 0;
    font-family: var(--sans);
    font-size: 0.85rem;
    line-height: 1.4;
}

.feed-features-grid dt {
    margin: 0;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.feed-features-grid dd {
    margin: 0;
    color: var(--ink);
    font-feature-settings: "tnum";
}

.feed-features-suggestions {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px dashed var(--rule);
}

.feed-features-suggestions .label {
    margin: 0 0 0.5rem;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--muted);
}

.feed-features-suggestions ul {
    margin: 0;
    padding-left: 1.1rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink);
}

.feed-features-suggestions li {
    margin: 0 0 0.4rem;
}

.cors-note {
    margin: 0.9rem 0 0;
    font-family: var(--sans);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--muted);
}

code {
    font-family: var(--mono);
    font-size: 0.85em;
    padding: 0.05em 0.3em;
    background: rgba(21, 17, 11, 0.06);
    border-radius: 0;
    color: var(--ink);
}

@media (prefers-color-scheme: dark) {
    code { background: rgba(235, 225, 204, 0.07); }
}

/* Demo panels --------------------------------------------- */

main { counter-reset: demo; }

.demo {
    counter-increment: demo;
    margin-bottom: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--rule);
    position: relative;
}

.demo h2 {
    font-family: var(--serif);
    font-weight: 500;
    font-variation-settings: "opsz" 96, "SOFT" 30;
    font-size: clamp(1.7rem, 3.5vw, 2.4rem);
    line-height: 1.05;
    margin: 0 0 0.6rem;
    color: var(--ink);
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
}

.demo h2::before {
    content: counter(demo, upper-roman) ".";
    font-family: var(--serif);
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 100;
    font-weight: 300;
    font-size: clamp(2rem, 5vw, 3rem);
    color: var(--rail);
    line-height: 1;
    letter-spacing: -0.02em;
}

.intro {
    margin: 0 0 1.4rem;
    max-width: 64ch;
    font-family: var(--serif);
    font-variation-settings: "opsz" 18, "SOFT" 0;
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.6;
}

.intro em { font-weight: 600; color: var(--ink); }

/* Forms --------------------------------------------------- */

form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.1rem 1.3rem;
    margin-bottom: 1.2rem;
    align-items: end;
}

form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--muted);
}

form label.narrow { max-width: 140px; }
form label:has(input[type="time"]),
form label:has(input[type="date"]) { max-width: 160px; }

input, select {
    font: inherit;
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--rule-strong);
    border-radius: 0;
    padding: 0.45rem 0.1rem;
    transition: border-color 120ms;
    width: 100%;
}

input[type="time"], input[type="date"] {
    font-family: var(--mono);
    font-feature-settings: "tnum";
    font-size: 0.95rem;
}

input[type="number"] {
    font-family: var(--mono);
    font-feature-settings: "tnum";
}

input:focus, select:focus {
    outline: 0;
    border-bottom-color: var(--rail);
}

input::placeholder { color: var(--muted-soft); font-style: italic; }

select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--ink) 50%),
        linear-gradient(135deg, var(--ink) 50%, transparent 50%);
    background-position:
        calc(100% - 14px) center,
        calc(100% - 9px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 1.5rem;
}

button {
    font: inherit;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    background: var(--ink);
    color: var(--paper);
    border: 0;
    border-radius: 0;
    padding: 0.85rem 1.4rem;
    cursor: pointer;
    transition: background 140ms, transform 140ms;
    grid-column: 1 / -1;
    justify-self: start;
}

@media (min-width: 600px) {
    button { grid-column: auto; }
}

button:hover {
    background: var(--rail);
    transform: translateY(-1px);
}
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Output panels ------------------------------------------- */

.output {
    margin-top: 1rem;
}

.output:empty { display: none; }

.output > p.intro {
    margin: 1rem 0;
    font-family: var(--sans);
    font-style: normal;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Empty state — sits in the chrome, not on the board. */
.empty {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    border: 1px dashed var(--rule-strong);
    color: var(--muted);
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.5;
}

.error {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    background: var(--rail);
    color: var(--paper);
    font-family: var(--sans);
    font-size: 0.9rem;
    border-radius: 0;
}

.timing {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--muted);
    margin-left: 0.4rem;
    font-feature-settings: "tnum";
}

/* =========================================================
 *  Departure board — for journey output and range tables.
 *  Always dark with amber mono regardless of page mode.
 * ========================================================= */

.journey {
    background: var(--board);
    color: var(--amber);
    font-family: var(--mono);
    font-feature-settings: "tnum";
    border: 0;
    border-radius: 0;
    margin: 0.9rem 0;
    padding: 1.2rem 1.4rem;
    position: relative;
    box-shadow: inset 0 0 0 1px var(--board-rule);
    animation: board-rise 320ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes board-rise {
    from { opacity: 0; transform: translateY(0.5em); }
    to { opacity: 1; transform: none; }
}

/* Subtle "scanline" texture, like a real LED/LCD board. */
.journey::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.18) 2px,
        rgba(0, 0, 0, 0.18) 3px
    );
    mix-blend-mode: multiply;
    opacity: 0.5;
}

.journey-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem 1.5rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px dashed var(--board-rule);
    position: relative;
    z-index: 1;
}

.journey-header .arrival {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: 0.04em;
    color: var(--amber-bright);
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(240, 180, 65, 0.4);
}

.journey-header .arrival::before {
    content: "ARR ";
    font-size: 0.7em;
    margin-right: 0.4em;
    color: var(--amber-dim);
    letter-spacing: 0.16em;
}

.journey-header .summary {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--amber-dim);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.legs {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 1;
}

.leg {
    display: grid;
    grid-template-columns: 5rem 1fr;
    column-gap: 1rem;
    padding: 0.7rem 0;
    border-top: 1px dashed var(--board-rule);
    font-size: 0.92rem;
}

.leg:first-child { border-top: 0; padding-top: 0.3rem; }

.leg .line-pill {
    align-self: start;
    padding: 0.18rem 0.5rem;
    border-radius: 0;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--board);
    background: var(--amber);
    text-align: center;
    /* Make sure the pill stays compact. */
    width: max-content;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leg .stops {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.15rem 1rem;
    align-items: baseline;
    font-family: var(--mono);
    color: var(--amber);
}

.leg .stops > span:nth-child(odd) {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.92rem;
}

.leg .stops .times {
    font-family: var(--mono);
    color: var(--amber-bright);
    font-feature-settings: "tnum";
    font-size: 0.92rem;
    margin-left: 0;
    letter-spacing: 0.04em;
    text-shadow: 0 0 6px rgba(240, 180, 65, 0.3);
    text-align: right;
}

.leg strong { font-weight: 600; }

/* Range query table — same board treatment ---------------- */

.range-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--board);
    color: var(--amber);
    font-family: var(--mono);
    font-feature-settings: "tnum";
    margin-top: 0.9rem;
    box-shadow: inset 0 0 0 1px var(--board-rule);
    animation: board-rise 320ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
    position: relative;
}

.range-table thead { background: var(--board-soft); }

.range-table th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--amber-dim);
    border-bottom: 1px solid var(--board-rule);
}

.range-table td {
    padding: 0.65rem 1rem;
    border-top: 1px dashed var(--board-rule);
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--amber);
}

.range-table tbody tr:hover {
    background: var(--board-soft);
    color: var(--amber-bright);
}

.range-table td:nth-child(1),
.range-table td:nth-child(2) {
    color: var(--amber-bright);
    font-weight: 600;
}

/* Walking comparison grid --------------------------------- */

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
    margin-top: 0.9rem;
}

@media (max-width: 720px) {
    .compare-grid { grid-template-columns: 1fr; }
}

.compare-grid > div h3 {
    margin: 0 0 0.4rem;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--muted);
}

.compare-grid > div h3 .timing { color: var(--muted-soft); }

/* Footer -------------------------------------------------- */

footer {
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.85rem;
    padding-top: 1.5rem;
    padding-bottom: 3rem;
}

footer p { margin: 0.4rem 0; }

footer .small {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--muted-soft);
    line-height: 1.6;
    max-width: 60ch;
}

/* === Map section ===========================================
   Sits between feed-loader and the demo panels. Header bar
   styled to echo the Solari journey-output boards (black +
   amber). Canvas is fixed-height so layout doesn't shift on
   data load. */

.map-section {
    margin: 1.5rem 0 2rem;
}

.map-header {
    background: #0a0c10;
    color: #f0b441;
    padding: 0.5rem 1rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 4px 4px 0 0;
    border: 1px solid #1c1e22;
    border-bottom: none;
}

.map-label {
    font-weight: 600;
}

.map-status {
    color: #d2d6de;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
}

.map-canvas {
    width: 100%;
    height: 480px;
    background: #14171c;
    border: 1px solid #1c1e22;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.map-attrib {
    font-size: 0.72rem;
    color: #6b6759;
    margin: 0.4rem 0 0;
    text-align: right;
}

.map-attrib a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* === Range table row interactivity ============================
   Rows in the departure-window Pareto table become clickable so
   the user can pick which option to render on the map. The
   active row picks up the demo's amber accent. */

.range-row {
    cursor: pointer;
}

.range-row:hover {
    background: rgba(240, 180, 65, 0.08);
}

.range-row.active {
    background: rgba(240, 180, 65, 0.15);
}

/* === Walking-panel before/after toggle =========================
   Appears in the map header only after the walking-footpaths
   panel runs a query. Toggle styling stays on-house with the
   demo's railway/Solari aesthetic — uppercase tracked button,
   amber on dark when "after", neutral when "before". */

.map-walking-toggle button {
    background: transparent;
    border: 1px solid #f0b441;
    color: #f0b441;
    font-family: inherit;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.7rem;
    border-radius: 2px;
    cursor: pointer;
}

.map-walking-toggle button[data-state="before"] {
    color: #d2d6de;
    border-color: #d2d6de;
}

.map-walking-toggle button:hover {
    background: rgba(240, 180, 65, 0.12);
}

/* === Stop popup ================================================
   Solari-styled tooltip on map dots. Idle stops show just the
   name; journey stops show arrival / departure times and routes
   for the current journey. */

.maplibregl-popup.stop-popup .maplibregl-popup-content {
    background: #0a0c10;
    color: #f1ebde;
    border: 1px solid #1c1e22;
    border-radius: 4px;
    padding: 0.7rem 0.9rem 0.6rem;
    font-family: "Bricolage Grotesque", system-ui, sans-serif;
    font-size: 0.78rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.maplibregl-popup.stop-popup .maplibregl-popup-tip {
    border-top-color: #0a0c10;
    border-bottom-color: #0a0c10;
}

.maplibregl-popup.stop-popup .maplibregl-popup-close-button {
    color: #d2d6de;
    font-size: 1rem;
    padding: 0 0.4rem;
}

.stop-popup-name {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    font-weight: 600;
    color: #f0b441;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.45rem;
}

.stop-popup-event {
    display: grid;
    grid-template-columns: 4rem 1fr;
    gap: 0.4rem;
    align-items: baseline;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.72rem;
    line-height: 1.45;
    margin-top: 0.18rem;
}

.stop-popup-event .label {
    color: #6b6759;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.66rem;
}

.stop-popup-event .time {
    color: #f0b441;
}

.stop-popup-event .route {
    color: #d2d6de;
}
