/* style.css was one 2,500-line file. It is now five, linked in this order from
   index.html, and the order is the cascade: a later file wins a tie.

     base      tokens, the page itself, rules every control shares
     layout    the shell: session sheet/rail, Collection, bottom bar
     overlays  the five tools and the one overlay rule they all join
     cards     the compendium grid, its cards and the detail panel
     map       Leaflet, pins and popups

   Split by owner, not by size: a rule lives with the component it styles, and
   that component's phone rules sit beside it rather than in a responsive
   section at the far end of another file. */

/* ONE BREAKPOINT SET.

   Phone is <= 780px, desktop is >= 781px. There used to be a second pair at
   899/900 that disagreed with the first, so a 850px window got the phone's
   sheet with the desktop's sidebar. Custom properties cannot appear inside a
   media query, so the numbers below are the record and every @media in these
   files repeats them literally; js/shell.js reads --bp-phone so script and CSS
   can never disagree about which layout is showing. */
:root {
    --bp-phone: 780px;
    --bp-desktop: 781px;

    --rail-w: 360px;
    /* The phone's bottom bar, and the sheet's three resting heights. Peek shows
       the handle, the title and the search box and nothing else. */
    --bar-h: calc(56px + env(safe-area-inset-bottom, 0px));
    --peek-h: 8.25rem;
    --half-h: 50dvh;
    --full-h: calc(100dvh - var(--bar-h) - 2.5rem);
    /* A thumb, not a mouse pointer. */
    --touch: 44px;

    /* One stacking order for the whole shell. The map is its own stacking
       context (z-index 1), so Leaflet's internal panes never meet these. */
    --z-map: 1;
    --z-dock: 1200;
    --z-collection: 1500;
    --z-bar: 1600;
    --z-overlay: 2000;

    /* The palette the panels already used, named once. */
    --ink: #e0d8c0;
    --ink-muted: #9a927f;
    --gold: #c8a951;
    --surface: #1a1a1a;
    --surface-2: #262626;
    --surface-3: #2f2a22;
    --line: #4a3f33;

    /* Native controls (selects, checkboxes, scrollbars, date pickers) draw
       dark to match. Without this the browser draws them white. */
    color-scheme: dark;
    accent-color: var(--gold);
}

/* =========================================
   1. CORE LAYOUT & TYPOGRAPHY
   ========================================= */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #111;
    color: #eee;
    font-family: 'Georgia', serif;
}

/* Every control starts from the same dark look. Without this, any button a
   component didn't style itself fell back to the browser's white, bevelled
   default. :where() keeps these at zero specificity, so any component rule
   still wins. */
:where(button) {
    font: inherit;
    font-size: 12px;
    line-height: 1.2;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
}
:where(button):hover { border-color: var(--gold); background: var(--surface-3); }
:where(button):disabled { opacity: .5; cursor: default; }
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]), select, textarea) {
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 5px 8px;
}
:where(input, select, textarea)::placeholder { color: var(--ink-muted); }
:where(button, input, select, textarea, summary, a):focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Buttons that read as text: a row you click, not a box you press. */
.btn-plain {
    padding: 0;
    color: inherit;
    background: none;
    border: 0;
    border-radius: 0;
}
.btn-plain:hover { background: none; color: #fff; }

/* Controls with no data behind them yet */
.control-disabled { opacity: 0.4; cursor: not-allowed !important; }
.checkbox-row label.control-disabled { cursor: not-allowed; }

/* A sortable column header is a <button> inside the <th>, so it is reachable
   by keyboard and announced as a control. It borrows every look from the th. */
.th-sort {
    all: inherit;
    display: inline;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    cursor: pointer;
}
.th-sort:focus-visible { outline: 2px solid #c8a951; outline-offset: 2px; }

/* Read by a screen reader, not drawn. */
.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Every list says why it is empty rather than leaving a blank. */
.list-empty { padding: 14px; color: #9a927f; font-size: 12px; line-height: 1.5; }

@media (max-width: 780px) {
    /* Touch targets: 44px tall for every free-standing control. :where() keeps
       this at zero specificity, so a component that sets its own size wins. */
    :where(button, select, summary,
           input:not([type="checkbox"], [type="radio"], [type="range"])) {
        min-height: var(--touch);
    }
    :where(input[type="checkbox"], input[type="radio"]) { width: 22px; height: 22px; }
}
