/* RookWild shared design tokens and base styles (web + mobile). */
:root {
    --rookwild-accent: #d94f1e;
    --rookwild-accent-dark: #a93a13;
    --rookwild-ink: #1b2127;
    --rookwild-muted: #5c6570;
    --rookwild-border: #d9dde3;
    --rookwild-surface: #ffffff;
    --rookwild-background: #f4f5f7;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --rookwild-ink: #e8ebee;
        --rookwild-muted: #9aa4af;
        --rookwild-border: #343b43;
        --rookwild-surface: #1c2126;
        --rookwild-background: #111418;
        color-scheme: dark;
    }
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--rookwild-background);
    color: var(--rookwild-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

*, *::before, *::after { box-sizing: border-box; }

/* An action as an icon (edit, delete, take out, add), the same everywhere (18 October): a quiet square, big enough for
   a gloved thumb. A two-tap one (ConfirmButton) widens to say what it does, in red, on the first tap. */
.rw-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--rookwild-muted);
    font: inherit;
    font-weight: 700;
    white-space: nowrap;
}

.rw-icon:disabled {
    opacity: 0.4;
}

.rw-icon.confirm {
    padding: 0 12px;
    background: #b42318;
    color: #ffffff;
}

.rw-icon.accent {
    color: var(--rookwild-accent);
}

/* A part of a full screen (ScreenLayout), its heading the same everywhere (18 October: headings must stand out, and
   alike on every screen): the accent colour, small capitals, underlined. Wins over a screen's own h3. */
.rw-screen .rw-screen-body h3 {
    margin: 4px 0 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid color-mix(in srgb, var(--rookwild-accent) 35%, transparent);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rookwild-accent);
}

/* More below (20 October, owner: when something must scroll, make it plain). Every panel that can scroll shows a thin
   orange scroll bar, and while there's more below its bottom edge fades out, gone once at the end. The fade is a
   scroll-driven animation: where the panel doesn't scroll, or the browser can't, nothing shows. */
.rookwild-sheet,
.rw-screen-body,
.find-sheet,
.group-sheet,
.rookwild-tour,
.sos-full,
.rookwild-ride-controls .choices {
    scrollbar-width: thin;
    scrollbar-color: var(--rookwild-accent, #d94f1e) transparent;
}

.rookwild-sheet,
.find-sheet,
.group-sheet,
.rookwild-ride-controls .choices {
    --rw-cue-bg: var(--rookwild-surface, #ffffff);
}

.rw-screen-body,
.rookwild-tour,
.sos-full {
    --rw-cue-bg: var(--rookwild-background, #f4f5f7);
}

@supports (animation-timeline: scroll()) {
    .rookwild-sheet::after,
    .rw-screen-body::after,
    .find-sheet::after,
    .group-sheet::after,
    .rookwild-tour::after,
    .rookwild-ride-controls .choices::after {
        content: "";
        position: sticky;
        bottom: 0;
        display: block;
        flex: none;
        height: 36px;
        margin-top: -36px;
        background: linear-gradient(to bottom, transparent, var(--rw-cue-bg));
        pointer-events: none;
        opacity: 0;
        animation: rw-more-below linear both;
        animation-timeline: scroll(self);
    }
}

@keyframes rw-more-below {
    0%, 92% { opacity: 1; }
    100% { opacity: 0; }
}

/* The Route menu open (21 October, owner: it opened under the map's buttons). It sits inside the guidance pane or the
   route card, whose own stacking level is low, so the menu's level can't lift it past the map's buttons and the ride
   panel; while it's open, the pane or card itself goes over them (still under full screens and sheets). "body" gives it
   the weight to win over the components' own z-index, loaded after this. */
body .rookwild-guidance-pane:has(.route-choices),
body .rookwild-route-guidance:has(.route-choices) {
    z-index: 12;
}

/* A card over the map, compressed (owner, 24 October: the cards took "a massive part of the real estate"; "all the
   information shown is needed, it just needs compressing"), the same on Explore and the riding map, designed for a
   360 x 640 phone. Size budget there, upright, for a section's or route's card: at most about 40% of the height and
   never scrolling. Padding 18 + heading 40 + facts (a row or two of chips) 48 + notes about 30 + profile 48 + actions 44
   + gaps 30 = about 258 px. Held to 44% of the screen's height: past that the notes give way first (cut to what fits,
   all of them in full in Details) and nothing scrolls. Sideways, and on a big screen, it is a panel down the side as
   before. "body" and the second class give these the weight to win over the cards' own styles, loaded after this. */
body .rookwild-sheet.rw-map-card:not(.full),
body .find-sheet.compact.rw-map-card {
    gap: 6px;
    padding: 8px 12px 10px;
}

@media (orientation: portrait) and (max-width: 739px) {
    body .rookwild-sheet.rw-map-card:not(.full),
    body .find-sheet.compact.rw-map-card {
        max-height: 44vh;
        max-height: 44dvh;
        overflow: hidden;
        padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    }

    body .rw-map-card > * {
        flex-shrink: 0;
    }

    body .rw-map-card > .rw-card-note {
        flex-shrink: 1;
        min-height: 0;
    }
}

/* A route's card (owner, 30 October): more rows than other cards, so at most about half the screen upright, scrolling
   what doesn't fit with Ride this route pinned at its foot; ⌄ folds it to its name alone, for more of the map. */
@media (orientation: portrait) and (max-width: 739px) {
    body .rookwild-sheet.rw-map-card.route-card:not(.full) {
        max-height: 52vh;
        max-height: 52dvh;
        overflow-y: auto;
    }
}

body .rookwild-sheet.route-card.folded:not(.full) {
    padding-bottom: 8px;
}

/* A card's notes (what the map's data says, where from, who graded it, its notes): small, two lines at most; the rest
   in Details, where they are in full. */
body .rw-map-card .rw-card-note {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.3;
}

/* A hazard on a card: its warning in full, what it means in two lines (all of it in Details). */
body .rw-map-card .rookwild-hazard span {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

/* A TRO along a route, as a note on a card: its warning, then what it means, read on in one run. */
body .rw-map-card .rookwild-tro-on-route strong::after {
    content: " ";
}

/* A line of packs opened with +N: all of it, in place. */
body .rw-map-card .rw-card-note.rw-all {
    display: block;
}

/* A card's actions, on the card and at the top of its Details: one row of compact buttons, the main one widest, still a
   gloved thumb's height. Never a second row (it would be cut off on a card that does not scroll): three fit across 336 px
   ("Ride this route", "Navigate me here", "Details"); narrower still, a word is cut short with … instead. */
body :is(.rookwild-sheet, .find-sheet) .rw-card-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}

body :is(.rookwild-sheet, .find-sheet) .rw-card-actions > button {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0 8px;
    overflow: hidden;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

body :is(.rookwild-sheet, .find-sheet) .rw-card-actions > button.primary {
    flex: 2 1 auto;
}

/* Waiting for the network (BusyNote, owner, 16 November): a thin bar moving at once, then "Slow connection" after a few
   seconds. A button busy with it (rw-working) shows a small spinner before its words and stays off. */
.rw-busy {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}

.rw-busy-bar {
    position: relative;
    display: block;
    height: 3px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--rookwild-border);
}

.rw-busy-bar::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    border-radius: 2px;
    background: var(--rookwild-accent);
    animation: rw-busy-slide 1.1s ease-in-out infinite;
}

@keyframes rw-busy-slide {
    to { left: 100%; }
}

.rw-busy-text {
    color: var(--rookwild-muted);
    font-size: 0.95rem;
}

.rw-busy-text.rw-slow {
    color: var(--rookwild-ink);
    font-weight: 600;
}

button.rw-working::before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.5em;
    vertical-align: -0.15em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: rw-spin 0.8s linear infinite;
}

@keyframes rw-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .rw-busy-bar::after, button.rw-working::before { animation-duration: 3s; }
}

/* A network action that failed (RetryNote): the note, and Retry beside it. */
.rw-retry {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 8px 0;
}

.rw-retry > span {
    flex: 1 1 12em;
    line-height: 1.4;
}

.rw-retry .retry {
    min-height: 44px;
    padding: 0 18px;
    border: 2px solid var(--rookwild-accent);
    border-radius: 12px;
    background: transparent;
    color: var(--rookwild-accent);
    font: inherit;
    font-weight: 700;
}

.rw-retry .retry:disabled {
    opacity: 0.6;
}
