/* Regent's Park | Time for laps? Phone first; colours from the Figma "Tokens" collection. */

:root {
    --green-900: #015c1f;
    --page: #f2f4ef;
    --card: #ffffff;
    --border: #dde3d8;
    --text: #172017;
    --muted: #566055;
    --on-dark: #ffffff;

    --go: #17703a;
    --go-tint: #e3f2e7;
    --maybe: #f2b705;
    --maybe-stripe: #b98a00; /* darker, so the stripe shows on white (3:1) */
    --maybe-ink: #2e2300;
    --maybe-tint: #fff4d1;
    --notnow: #b42318;
    --notnow-tint: #fde7e4;
    --dark: #2c3440;
    --dark-tint: #e7eaef;
    --now-tint: #edf3ea; /* background of the current hour in the timeline */
    --sun: #b87300; /* the sunrise/sunset line's icon: the sun icon's amber */

    --radius-lg: 20px;
    --radius: 14px;
    --gap: 16px;

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

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}

p,
h1,
h2,
h3,
ol,
dl,
dd {
    margin: 0;
}

a {
    color: inherit;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px;
}

.nowrap {
    white-space: nowrap;
}

/* ---------- Header, banner, status ---------- */

.site-header {
    background: var(--green-900);
    color: var(--on-dark);
}

/* Phones: the mark, the name with the update time under it, the units button on the
   right. From 480px wide everything fits on one line, the time beside the button. */
.site-header__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "mark name units"
        "mark updated units";
    align-items: center;
    column-gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* The "RP?" mark: drawn at 84×88, shown 32px tall. Decorative: the site name follows it. */
.site-mark {
    grid-area: mark;
    display: block;
    width: auto;
    height: 32px;
}

.site-name {
    grid-area: name;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}

.site-name__tagline {
    font-weight: 500;
    color: rgb(255 255 255 / 85%);
}

/* A quiet divider: fainter than the words either side. */
.site-name__pipe {
    color: rgb(255 255 255 / 50%);
}

.updated {
    grid-area: updated;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
}

@media (max-width: 359px) {
    .site-name {
        font-size: 16px;
    }
}

/* Below 340px the tagline would run into the units button: just "Regent's Park". */
@media (max-width: 339px) {
    .site-name__tagline {
        display: none;
    }
}

@media (min-width: 480px) {
    .site-header__inner {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas: "mark name updated units";
    }
}

/* The units button: a gear, 44px to tap, but no taller than the line it sits on.
   The hover backgrounds are for a mouse only: a phone keeps :hover on the last
   thing tapped, which left the gear looking open after it was closed. */
.units {
    grid-area: units;
    position: relative;
}

.units__button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -6px -12px -6px 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--on-dark);
    cursor: pointer;
}

.units__button[aria-expanded="true"] {
    background: rgb(255 255 255 / 18%);
}

@media (hover: hover) {
    .units__button:hover {
        background: rgb(255 255 255 / 18%);
    }

    .units__choice:hover {
        background: var(--border);
    }
}

.units__button:focus-visible {
    outline-color: var(--on-dark);
    outline-offset: -2px;
}

.units__icon {
    width: 22px;
    height: 22px;
}

/* The panel: under the button, right-aligned with it, just wide enough for its rows. */
.units__panel {
    position: absolute;
    top: calc(100% + 16px);
    right: -4px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: max-content;
    min-width: 256px;
    padding: 14px 16px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgb(23 32 23 / 18%), 0 2px 6px rgb(23 32 23 / 8%);
}

.units__panel[hidden] {
    display: none;
}

.units__heading {
    font-weight: 700;
}

.units__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
}

.units__label {
    font-weight: 500;
}

/* Two choices of the same width in every row, so the three rows line up. */
.units__choices {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.units__choice {
    width: 56px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}


.units__choice[aria-pressed="true"] {
    background: var(--green-900);
    color: var(--on-dark);
}

.banner {
    background: var(--dark);
    color: var(--on-dark);
    font-size: 13px;
    font-weight: 600;
}

.banner .wrap {
    padding-top: 8px;
    padding-bottom: 8px;
}

.status-bar {
    background: var(--dark-tint);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

.status-bar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.link-button {
    min-height: 44px;
    min-width: 44px;
    padding: 0 4px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.button {
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 10px;
    background: var(--green-900);
    color: var(--on-dark);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: #024a1a;
}

.link-button:hover,
.site-footer a:hover {
    text-decoration-thickness: 2px;
}

/* ---------- Layout ---------- */

/* main.wrap, not main: .wrap's "padding: 0 16px" would otherwise wipe the top
   and bottom padding, and the answer card would touch the header on phones. */
main.wrap {
    display: grid;
    gap: var(--gap);
    padding-top: var(--gap);
    padding-bottom: 24px;
}

.col {
    display: grid;
    gap: var(--gap);
    align-content: start;
    min-width: 0;
}

@media (min-width: 960px) {
    main.is-ready {
        grid-template-columns: minmax(320px, 440px) 1fr;
        gap: 32px;
        padding-top: 32px;
    }

    .col--answer {
        position: sticky;
        top: 16px;
    }
}

/* ---------- Loading and errors ---------- */

.loading {
    padding: 24px 20px;
    border-radius: var(--radius-lg);
    background: var(--dark-tint);
}

.loading__title {
    font-size: 20px;
    font-weight: 700;
}

.loading__sub {
    margin-top: 6px;
    color: var(--muted);
}

.error {
    display: grid;
    gap: 12px;
    padding: 20px;
    border: 2px solid var(--notnow);
    border-radius: var(--radius-lg);
    background: var(--card);
}

.error__title {
    font-size: 20px;
    font-weight: 700;
}

.error__detail {
    color: var(--muted);
}

.error .button {
    justify-self: start;
}

.noscript {
    padding-top: 16px;
}

/* ---------- Answer card ---------- */

.answer {
    display: grid;
    gap: 8px;
    padding: 20px 20px 16px;
    border-radius: var(--radius-lg);
    color: var(--on-dark);
}

.answer--go {
    background: var(--go);
}

.answer--maybe {
    background: var(--maybe);
    color: var(--maybe-ink);
}

.answer--notnow {
    background: var(--notnow);
}

.answer__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.answer__icon {
    width: 40px;
    height: 40px;
    flex: none;
}

.answer__word {
    font-size: 44px;
    font-weight: 800;
    line-height: 1.1;
}

.answer__reason {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
}

/* Night (outside riding hours): slate, so red only ever means weather. */
.answer--night {
    background: var(--dark);
}

/* The window: a white panel with the time large, so "when" is the second thing read. */
.when {
    display: grid;
    gap: 2px;
    margin-top: 4px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
}

.when__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.when__value {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.when__sub {
    color: var(--muted);
    font-weight: 500;
}

/* The next 12 hours: one block per hour in the timeline's colours, every third labelled. */
.strip {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.strip__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.strip__bar,
.strip__ticks {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 3px;
    padding: 0;
    list-style: none;
}

.strip__h {
    height: 14px;
    border-radius: 3px;
}

.strip__h--go { background: var(--go); }
.strip__h--maybe { background: var(--maybe-stripe); }
.strip__h--notnow { background: var(--notnow); }
.strip__h--night { background: var(--dark); }

.strip__ticks {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.strip__ticks span {
    white-space: nowrap;
}

/* ---------- Condition tiles ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tile {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

.tile__label,
.tile__sub {
    font-size: 13px;
    color: var(--muted);
}

/* The wind's arrow: 16px, sitting on the text's middle. */
.tile__arrow {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: -3px;
}

.tile__label {
    font-weight: 600;
}

.tile__value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
}

/* Today's sunrise and sunset: two halves, each an icon, a label and the time in bold. */
.sun {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    line-height: 20px;
}

@media (max-width: 359px) {
    .sun {
        gap: 12px;
    }
}

.sun__item {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
}

.sun__icon {
    width: 18px;
    height: 18px;
    flex: none;
    margin-right: 2px; /* 8px from the icon, 6px between the label and the time */
    color: var(--muted);
}

.sun__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.sun__time {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- Timeline ---------- */

.col--timeline {
    gap: 8px;
}

.day-heading {
    margin-top: 12px;
    font-size: 15px;
    font-weight: 700;
}

.col--timeline .day-heading:first-of-type {
    margin-top: 0;
}

.hours {
    container-type: inline-size; /* the facts columns adapt to the list's width */
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    overflow: hidden;
}

.hour {
    --stripe: var(--border);
    position: relative;
    padding: 8px 12px 8px 20px;
}

/* The state stripe: a short rounded bar inset from the row's edges, so it
   never collides with the list's rounded corners or the dividers between rows. */
.hour::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    inset-inline-start: 8px;
    width: 4px;
    border-radius: 2px;
    background: var(--stripe);
}

.hours > li + li {
    border-top: 1px solid var(--border);
}

.hour--go {
    --stripe: var(--go);
}

.hour--maybe {
    --stripe: var(--maybe-stripe);
}

.hour--notnow {
    --stripe: var(--notnow);
}

.hour--night {
    --stripe: var(--dark);
    background: var(--dark-tint);
}

/* The current hour: a soft tint, not a border. */
.hour.is-now {
    background: var(--now-tint);
}

/* A dark hour (inside riding hours): its time sits in a slate chip that fits the
   figures ("6:00" as well as "20:00"). The padding is cancelled by the negative
   margin, so the figures stay exactly where they are on other rows. An
   inline-block, because Safari clips a plain inline's background at the start
   of the line, which left the chip with no padding on the left. Its own line is
   tighter than the row's (18px, not 21px), so the chip is 22px tall, not 25px;
   the row's line keeps its height, so nothing else moves. */
.hour.is-dark .hour__clock {
    display: inline-block;
    line-height: 18px;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 6px;
    background: var(--dark);
    color: var(--on-dark);
}

/* Sunrise and sunset: a thin line after the hour they fall in. */
.sun-line {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px 3px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.sun-line__icon {
    width: 14px;
    height: 14px;
    flex: none;
    color: var(--sun);
}

.hour__top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hour__time {
    flex: none;
    min-width: 2.9em; /* "13:00": so the state shapes line up down the list */
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hour__temp {
    flex: none;
    min-width: 3ch;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The facts: road, rain, wind in three fixed columns, so each lines up down the
   list. The first two are as wide as their longest usual value ("Road damp",
   "Rain 0.1 mm"). Where the list is too narrow for "Wind 18 mph, gusts 38" on
   the same line (under about 375px screens), wind moves to a line of its own. */
.hour__facts {
    display: grid;
    grid-template-columns: 5.5em 6em minmax(0, 1fr);
    column-gap: 8px;
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.hour__fact {
    white-space: nowrap;
}

@container (max-width: 339px) {
    .hour__facts {
        grid-template-columns: 5.5em minmax(0, 1fr);
    }

    .hour__fact:last-child {
        grid-column: 1 / -1;
    }
}

/* The state label: a filled circle (Go, Not Now) or triangle (Maybe) with the symbol inside, then the word. */
.state {
    display: flex;
    flex: 1;
    min-width: 0;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
}

.state__dot {
    width: 16px;
    height: 16px;
    flex: none;
}

.state--go { --disc: var(--go); --mark: var(--on-dark); }
.state--maybe { --disc: var(--maybe); --mark: var(--maybe-ink); }
.state--notnow { --disc: var(--notnow); --mark: var(--on-dark); }

.state__disc { fill: var(--disc); stroke: var(--disc); }
.state__mark { stroke: var(--mark); }

/* Weather icons: coloured line icons (Lucide), no tile behind them. */
.hour__icon {
    display: block;
    width: 24px;
    height: 24px;
    flex: none;
}

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

.site-footer {
    padding: 8px 0 32px;
    font-size: 13px;
    color: var(--muted);
}
