/* ------------------------------------------------------------------
   W8Q

   Design brief: this gets read one-handed, outdoors, in bright sun, on
   a connection that barely works, by someone who wants one number.
   So: park signage vernacular. Big tabular numerals, a solid status
   bar down the left of every row, high contrast, no decorative
   gradients or shadows to wash out in daylight. One bold element -
   the dark board at the top of a park page - and everything else
   deliberately quiet.
   ------------------------------------------------------------------ */

:root {
    --paper:   #ECEEEC;
    --surface: #FFFFFF;
    --ink:     #16222B;
    --muted:   #5B6B72;
    --line:    #D5DAD8;
    --accent:  #0D5A6B;

    --open:    #12784A;
    --closed:  #A32A1E;
    --service: #8A5A00;
    --unknown: #5B6B72;

    --radius:  6px;
    --gutter:  16px;
    --row-min: 56px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper:   #0E1519;
        --surface: #17222A;
        --ink:     #E8EDEF;
        --muted:   #93A5AD;
        --line:    #26343D;
        --accent:  #4FB3C6;

        --open:    #35B36F;
        --closed:  #E06255;
        --service: #D19A2E;
        --unknown: #93A5AD;
    }
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    /* Room for the iPhone home indicator when installed to the home screen */
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent); }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* ---------------- header ---------------- */

.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top, 0px);
}

.appbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}

.brand {
    font-weight: 800;
    font-size: 19px;
    letter-spacing: -0.02em;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand img { height: 22px; width: auto; display: block; }

.brand-sub {
    font-weight: 400;
    font-size: 13px;
    color: var(--muted);
}

.appbar-spacer { flex: 1; }

.langpick {
    display: flex;
    align-items: center;
    gap: 2px;
}

.langpick a {
    display: block;
    padding: 8px 7px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--muted);
    border-radius: 4px;
    text-transform: lowercase;
}

.langpick a[aria-current="true"] {
    color: var(--surface);
    background: var(--accent);
}

/* ---------------- the board ----------------
   The one loud element on the page. Reads like the summary sign at a
   park entrance, which is exactly what it is. */

.board {
    background: #16222B;
    color: #F2F6F7;
    border-radius: var(--radius);
    margin: var(--gutter) 0;
    padding: 16px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 20px;
    align-items: baseline;
}

.board-figure {
    grid-row: 1 / span 2;
    font-size: 56px;
    font-weight: 800;
    line-height: 0.9;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.board-figure span {
    font-size: 17px;
    font-weight: 600;
    margin-left: 4px;
    letter-spacing: 0;
}

.board-label {
    font-size: 14px;
    color: #9FB3BB;
    align-self: end;
}

.board-meta {
    font-size: 14px;
    color: #C9D8DD;
}

.board-meta b {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.board-hours {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.14);
    font-size: 14px;
    color: #C9D8DD;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.board.is-closed { background: #3A1E1A; }

/* crowd meter: five blocks, filled proportionally */
.crowd {
    display: inline-flex;
    gap: 3px;
    vertical-align: -1px;
    margin-left: 6px;
}
.crowd i {
    width: 9px;
    height: 12px;
    border-radius: 1px;
    background: rgba(255,255,255,0.22);
    display: block;
}
.crowd i.on { background: #F2C14E; }

/* ---------------- controls ---------------- */

.controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.search {
    flex: 1 1 180px;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px; /* 16px stops iOS zooming the page on focus */
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.search::placeholder { color: var(--muted); }

.sorts {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.sorts button {
    min-height: 44px;
    padding: 0 13px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    background: none;
    border: 0;
    border-left: 1px solid var(--line);
    cursor: pointer;
}

.sorts button:first-child { border-left: 0; }

.sorts button[aria-pressed="true"] {
    background: var(--accent);
    color: #fff;
}

/* ---------------- ride rows ---------------- */

.rides {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.ride {
    display: flex;
    align-items: stretch;
    min-height: var(--row-min);
    border-top: 1px solid var(--line);
}

.rides > .ride:first-child,
.rides > details > .ride:first-child { border-top: 0; }

.ride-bar {
    width: 5px;
    flex: 0 0 5px;
    background: var(--unknown);
}

.ride[data-status="opened"]      .ride-bar { background: var(--open); }
.ride[data-status="closed"]      .ride-bar { background: var(--closed); }
.ride[data-status="maintenance"] .ride-bar { background: var(--service); }

.ride-fav {
    flex: 0 0 44px;
    border: 0;
    background: none;
    color: var(--line);
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
    padding: 0;
}

.ride-fav[aria-pressed="true"] { color: var(--accent); }

.ride-body {
    flex: 1;
    min-width: 0;
    padding: 9px 4px 9px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ride-name {
    font-weight: 600;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ride-note {
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ride-note .spark { display: block; }

.ride-wait {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 14px 0 8px;
    font-variant-numeric: tabular-nums;
}

.ride-wait b {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.ride-wait span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.ride[data-status="closed"] .ride-name,
.ride[data-status="maintenance"] .ride-name { color: var(--muted); font-weight: 500; }

.ride-status {
    padding: 0 14px 0 8px;
    align-self: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

/* the whole row opens the detail panel */
.ride-open {
    display: contents;
}

.ride button.ride-body {
    text-align: left;
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    cursor: pointer;
}

/* ---------------- closed section ---------------- */

details.closed-group {
    border-top: 1px solid var(--line);
}

details.closed-group > summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    background: var(--surface);
}

details.closed-group > summary::-webkit-details-marker { display: none; }

details.closed-group > summary::before {
    content: "";
    width: 0;
    height: 0;
    margin-right: 10px;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.15s ease;
}

details.closed-group[open] > summary::before { transform: rotate(90deg); }

/* ---------------- park picker ---------------- */

.country {
    margin: 22px 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.parks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
}

.park {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.25;
}

.park:active { background: var(--paper); }

.park-fav {
    margin-left: auto;
    padding-left: 8px;
    color: var(--accent);
}

/* ---------------- detail panel ---------------- */

dialog::backdrop { background: rgba(10, 18, 22, 0.55); }

.sheet {
    border: 0;
    border-radius: var(--radius);
    padding: 0;
    width: min(520px, calc(100vw - 24px));
    background: var(--surface);
    color: var(--ink);
}

.sheet-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px 8px;
}

.sheet-head h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.25;
    flex: 1;
}

.sheet-close {
    border: 0;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.sheet-body { padding: 0 16px 16px; }

.sheet-body p { margin: 8px 0; font-size: 14px; color: var(--muted); }

.chart {
    width: 100%;
    height: 128px;
    display: block;
    margin: 8px 0 4px;
}

/* ---------------- notices, footer ---------------- */

.notice {
    margin: 12px 0;
    padding: 10px 12px;
    border-left: 4px solid var(--service);
    background: var(--surface);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 14px;
}

.notice.error { border-left-color: var(--closed); }

.freshness {
    margin: 10px 2px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--open);
    flex: 0 0 auto;
}

.dot.stale { background: var(--service); }

.foot {
    margin: 28px 0 8px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.foot a { color: var(--muted); }

.empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media (min-width: 560px) {
    .board-figure { font-size: 68px; }
    .ride-wait b { font-size: 30px; }
}
