/* THE SHELL - one navigation model at two sizes.

   Desktop (>= 781px): the session is a left rail, Collection is a right
   sidebar over the map, and the tools open as dialogs.

   Phone (<= 780px): the session is a bottom sheet with three resting heights
   (peek, half, full) above a four-button bar - Session, Collection, Tools,
   Nearby. Collection is a full-screen page above the bar; the tools are
   full-screen dialogs over everything. js/shell.js owns the behaviour. */

#map {
    position: absolute;
    inset: 0 0 0 var(--rail-w);
    z-index: var(--z-map);
}

#session-dock {
    position: fixed;
    z-index: var(--z-dock);
    top: 0;
    left: 0;
    width: var(--rail-w);
    height: 100vh;
    overflow: auto;
    box-sizing: border-box;
    color: #eee;
    background: #1a1a1a;
    border: 1px solid #5c4e40;
    box-shadow: 0 3px 14px rgba(0,0,0,.45);
    font-size: 13px;
}
/* The handle only means something on a sheet. */
.sheet-handle { display: none; }

.session-head { display: flex; align-items: start; gap: 5px; padding: 10px; border-bottom: 1px solid #4a3f33; }
.session-title { flex: 1; text-align: left; }
/* Rows you click read as text, not as boxes: the title folds the rail, a job
   name opens its list, a search hit or member flies the map to it. */
:is(.session-title, .session-job-name, .session-search-go, .session-members button) {
    padding: 0; color: inherit; background: none; border: 0; border-radius: 0;
}
:is(.session-job-name, .session-search-go, .session-members button):hover { color: #fff; background: none; }
.session-title:hover { background: none; }
.session-title:hover strong { color: var(--gold); }
.session-job-name { font-size: 13px; line-height: 1.35; }
.session-job-name::before { content: '▸ '; color: var(--ink-muted); }
.session-job.is-open .session-job-name::before { content: '▾ '; }
.session-search-go { padding: 7px 8px; }
#session-results li > button:not(.session-search-go) { margin: 5px 6px; align-self: center; }
.session-head strong { display: block; text-transform: uppercase; letter-spacing: 1px; }
.session-head span { color: #9a927f; font-size: 11px; }
#session-search { display: block; width: calc(100% - 20px); box-sizing: border-box; margin: 10px; padding: 8px 10px; }
#session-results { list-style: none; margin: 0 10px 10px; padding: 0; border: 1px solid #4a3f33; background: #202020; }
#session-results li { display: flex; align-items: stretch; border-bottom: 1px solid #393126; }
#session-results li:last-child { border: 0; }
.session-search-heading { padding: 6px 8px; color: #9a927f; text-transform: uppercase; letter-spacing: .7px; font-size: 10px; }
.session-search-go { min-width: 0; flex: 1; text-align: left; }
.session-search-go:focus-visible { outline: 2px solid #c8a951; outline-offset: -2px; }
.session-search-go span, .session-search-go small { display: block; }
.session-search-go small { color: #9a927f; margin-top: 2px; }
.session-search-empty { padding: 8px; color: #9a927f; }
#session-jobs { padding: 0 10px 10px; }
.session-empty { display: grid; gap: 7px; padding: 12px 0; color: #b8b0a2; }
.session-empty b { color: #eee; }
.session-empty div { display: flex; gap: 6px; }
.session-job { border-bottom: 1px solid #4a3f33; }
.session-job-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 6px; padding: 9px 0; }
.session-job-name { min-width: 0; text-align: left; }
.session-job-progress { color: #c8a951; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 11px; }
.session-job-map, .session-job-remove { padding: 3px 5px; font-size: 11px; }
.session-members { display: grid; gap: 3px; padding: 0 0 8px 8px; }
.session-members button { text-align: left; color: #b8b0a2; font-size: 12px; }
.session-members-empty { color: #9a927f; font-size: 12px; padding: 4px 0; }
.session-finished { margin-top: 8px; color: #9a927f; }
.session-help { margin-top: 14px; color: var(--ink-muted); font-size: 12px; line-height: 1.5; }
.session-help p { margin: 0 0 6px; }
.session-finished summary { cursor: pointer; padding: 7px 0; }
.session-members-more { color: #c8a951 !important; }
.app-status { margin: 0 10px 10px; padding: 7px 9px; font-size: 12px; color: #d8d0bf; background: #262626; border: 1px solid #4a3f33; }
.app-status.is-error, .app-status.load-error { color: #ffd2c8; background: #3a1d17; border-color: #8c3b2c; }
#load-status { color: #9a927f; text-align: center; font-size: 13px; padding: 20px 0; }
#load-status.load-error { color: #ff6b6b; }

/* "You have not backed up in a while." Amber, like the Safari warning: a
   caution about losing work, not an error. */
.backup-reminder { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: #e8c96b; border-color: #a3781c; background: #2d2510; }
.backup-reminder[hidden] { display: none; }
.backup-reminder span { flex: 1 1 12em; }

/* Collection: a right-hand sidebar over the map. */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-collection);
    display: none;
    width: min(var(--sidebar-width), calc(100vw - var(--rail-w)));
    overflow-y: auto;
    box-sizing: border-box;
    background-color: #1a1a1a;
    padding: 15px;
    border-left: 2px solid #b71c1c;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
}
body.collection-open #sidebar { display: block; }
.collection-head { display: flex; align-items: center; gap: 10px; margin: 0 0 15px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.collection-head .app-title { flex: 1; margin: 0; padding: 0; border: 0; text-align: left; display: flex; align-items: baseline; gap: 10px; }
.collection-head .global-progress { float: none; margin-left: auto; }
.collection-head + .global-progress-bar { margin: -16px 0 15px; }
.collection-close { width: 32px; height: 32px; padding: 0; font-size: 20px; line-height: 1; flex: none; }

/* The bottom bar is the phone's; desktop reaches the same four places from the
   rail's header. */
#bottom-bar { display: none; }

@media (min-width: 781px) {
    /* Collapsed, the rail folds to its header and gives the map its width back.
       Leaflet's zoom buttons move out from under the folded header. */
    body.session-collapsed #map { left: 0; }
    body.session-collapsed #session-dock { height: auto; }
    body.session-collapsed #session-search,
    body.session-collapsed #session-results,
    body.session-collapsed #session-jobs { display: none; }
    body.session-collapsed .leaflet-top.leaflet-left { left: var(--rail-w); }
}

@media (max-width: 780px) {
    #map { inset: 0 0 calc(var(--bar-h) + var(--peek-h)) 0; }

    #session-dock {
        top: auto;
        right: 0;
        bottom: var(--bar-h);
        left: 0;
        width: 100%;
        height: var(--peek-h);
        border-width: 1px 0 0;
        border-radius: 12px 12px 0 0;
        overflow: hidden;
        transition: height .2s ease;
        overscroll-behavior: contain;
    }
    body.sheet-half #session-dock { height: var(--half-h); overflow-y: auto; }
    body.sheet-full #session-dock { height: var(--full-h); overflow-y: auto; }
    /* Following a finger: no easing, or the sheet lags behind it. */
    #session-dock.is-dragging { transition: none; }

    .sheet-handle {
        display: block;
        position: sticky;
        top: 0;
        z-index: 1;
        width: 100%;
        height: 22px;
        min-height: 22px;
        padding: 0;
        margin: 0;
        border: 0;
        background: #1a1a1a;
        cursor: grab;
        touch-action: none;
    }
    .sheet-handle::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        margin: 0 auto;
        border-radius: 2px;
        background: #6a5f4d;
    }
    .sheet-handle:focus-visible::before { background: #c8a951; }
    /* The drag area is the whole header strip, not a 4px pill. */
    .session-head { position: sticky; top: 22px; z-index: 1; background: #1a1a1a; padding: 0 10px 6px; border-bottom: 0; touch-action: none; }
    .session-title { min-height: var(--touch); }
    /* The bar carries these on a phone. */
    .session-head > button:not(.session-title) { display: none; }
    #session-search { margin: 0 10px 10px; min-height: var(--touch); font-size: 16px; }
    .session-search-go { padding: 6px 8px; }
    .session-job-map, .session-job-remove { min-width: var(--touch); }
    .session-members button { min-height: var(--touch); }

    #sidebar {
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--bar-h);
        width: 100%;
        border: none;
        padding: 10px;
    }
    /* The bar's Session and Collection tabs both close it on a phone. */
    .collection-close { display: none; }

    #bottom-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: var(--z-bar);
        height: var(--bar-h);
        box-sizing: border-box;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #171310;
        border-top: 1px solid #3a2f1e;
    }
    #bottom-bar button {
        flex: 1;
        min-height: 56px;
        background: none;
        border: none;
        border-top: 2px solid transparent;
        color: #8a8270;
        font-family: inherit;
        font-size: 11px;
        letter-spacing: 1.2px;
        text-transform: uppercase;
        cursor: pointer;
    }
    #bottom-bar button[aria-current="page"] { color: #e0d8c0; border-top-color: #c8a951; }
    #bottom-bar button:focus-visible { outline: 2px solid #c8a951; outline-offset: -4px; }

}

/* The playthrough in one line. The number gives the fact, the sliver of gold
   below the title gives the dopamine - it only ever moves right. */
.global-progress-bar {
    height: 3px;
    background: #2a2419;
    margin: -6px 0 12px;
    overflow: hidden;
}
#global-progress-fill,
.tx-bar-fill {
    height: 100%;
    width: 0;
    background: #c8a951;
    transition: width 0.4s ease;
}

/* Every section header gets the same sliver the whole playthrough gets, so
   "how far into THE COMPENDIUM am I" reads the same way as "how far into the
   game am I". 2026-08-26: "each section should have a little gold bar." */
.tx-bar {
    height: 2px;
    background: #2a2419;
    overflow: hidden;
}

.global-progress {
    float: right;
    font-size: 12px;
    letter-spacing: 1px;
    color: #8a8270;
    font-variant-numeric: tabular-nums;
    align-self: baseline;
}

.app-title {
    font-size: 24px;
    text-align: center;
    margin: 0 0 15px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

/* =========================================
   4. GLOBAL CONTEXT HEADER (CHAPTER/TIME)
   ========================================= */
.global-context {
    background: #2a2a2a;
    padding: 10px;
    margin-bottom: 15px;
}

.context-row {
    display: flex;
    /* Wraps, and the chapter select keeps a real min-width: a long mission
       name used to squeeze it down to "C..." on a 360px sidebar, and the
       chapter is the heading this whole row exists to state. */
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    width: 100%;
}

.context-row select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 5px;
    font-size: 12px;
    /* Enough for "Chapter 1" and "Epilogue 1" without an ellipsis; the
       mission select takes the slack. */
    min-width: 5.5em;
    text-overflow: ellipsis; 
    white-space: nowrap;
    overflow: hidden;
}

/* Percentages became wrong once the row wrapped and gained a fourth control:
   they were shares of the whole row, not of the line the select ends up on.
   Flex bases instead, so the mission name takes whatever slack there is. */
#chapter-select { flex: 0 0 auto; }
#mission-select { flex: 1 1 8em; }
#time-select { flex: 0 1 6em; }

.checkbox-row {
    display: flex;
    flex-wrap: wrap; 
    gap: 8px 12px; 
    justify-content: center;
    font-size: 12px;
    color: #aaa;
}

/* `display: flex` below beats the browser's own [hidden] rule, so a control
   hidden for having no data behind it would still take up a row's worth of
   space with nothing in it. */
.checkbox-row label[hidden] { display: none; }

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap; 
}

.checkbox-row input[type="checkbox"] {
    accent-color: #8b0000;
    cursor: pointer;
}

/* Backup / restore */
.save-row { display: flex; gap: 6px; margin-top: 10px; }
.save-row button {
    flex: 1;
    padding: 6px;
    background: #333;
    color: #e0d8c0;
    border: 1px solid #5c4e40;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 1px;
    cursor: pointer;
}
.save-row button:hover { background: #4a3c2e; }

/* The bulk chip buttons carry no active state any more, and shouldn't: they
   are one-shot operations on the boxes below, and the boxes themselves are
   now the honest readout of what is on. A lit-up "Show All" would go on
   claiming everything was shown after you unticked something. Three buttons
   in a sidebar column need a smaller label than two did. */

.save-status { font-size: 11px; color: #2e8b57; min-height: 14px; margin-top: 4px; text-align: center; }
/* Sits directly above Backup and Restore, because it is only worth reading next
   to the buttons that answer it. Amber rather than red: this is a caution about
   a browser behaviour, not an error the player has caused. */
.save-warning {
    font-size: 11px;
    line-height: 1.35;
    color: #d8a657;
    margin: 10px 0 0;
    text-align: center;
}

.icon-credits {
    font-size: 10px;
    color: #6a6250;
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #2a2620;
}
.icon-credits a { color: #8a8168; }
.save-status.save-error { color: #ff6b6b; }

/* Chapter-transition warning. Scoped to the banner element: an unscoped
   .missable-alert once leaked this padding and margin onto compendium cards,
   which share the concept but not the shape. */
#missable-alert {
    background: #4a1010;
    border: 1px solid #b71c1c;
    border-left: 4px solid #b71c1c;
    padding: 10px 12px;
    margin-bottom: 15px;
    font-size: 12px;
}
#missable-alert[hidden] { display: none; }
#missable-alert strong { color: #ff9b9b; display: block; margin-bottom: 6px; }
#missable-alert ul { margin: 0 0 6px 0; padding-left: 18px; color: #e0d8c0; }
#missable-alert li { margin-bottom: 2px; }
#missable-alert em { color: #9a927f; display: block; margin-bottom: 6px; }
#missable-alert button {
    background: #b71c1c;
    color: #fff;
    border: none;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

/* The checklist version - amber, not red, and collapsed by default: this is
   "still gettable" information, not an alarm. See updateChapterMissables. */
.chapter-missable {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 15px;
    font-size: 12px;
}
.chapter-missable[hidden] { display: none; }
.chapter-missable summary {
    color: var(--gold);
    cursor: pointer;
    padding: 4px 0;
}
.chapter-missable ul {
    list-style: none;
    margin: 6px 0 2px 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}
.chapter-missable li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    color: #e0d8c0;
    border-top: 1px solid #333;
}
.chapter-missable li span { flex: 1; min-width: 0; }
.chapter-missable li:first-child { border-top: none; }
.chapter-missable button { padding: 3px 9px; font-size: 11px; flex-shrink: 0; }
.chapter-missable [data-track-compid] { color: #1a1a1a; background: var(--gold); border-color: var(--gold); }
.chapter-missable [data-track-compid]:hover { background: #d9bc66; }
.chapter-missable [data-track-compid]:disabled { color: var(--ink-muted); background: none; border-color: transparent; opacity: 1; }

/* =========================================
   5. PANEL TOGGLES
   =========================================
   Search mode is gone (2026-08-07). It never got past a placeholder, and
   everything it was going to be now exists elsewhere: the taxonomy has its own
   search box, and the table does the finer filtering it was meant to carry. */
/* The five cross-cutting tools, as one block. Before this they were three
   loose buttons here plus two buried inside their own subsections, and only one
   of the five had any styling at all - so TABLE VIEW was a full-width bar and
   WHAT'S NEARBY was a default browser button sitting next to it. */
.toolbox {
    margin-bottom: 15px;
    border: 1px solid #3a3228;
    background: #1c1a17;
}
.toolbox-name {
    padding: 6px 10px;
    color: #6a6250;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid #2a2620;
}
/* Flex-wrap rather than a grid: five buttons in a three-wide grid leaves an
   empty cell on the second row, which reads as a sixth tool that failed to
   load. Wrapping lets the last row's two stretch to fill instead. */
.toolbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1px;
    background: #2a2620;
}
.toolbox-grid button {
    flex: 1 1 140px;
    padding: 9px 8px;
    background: #262320;
    color: #c0b8a0;
    border: none;
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 1px;
    cursor: pointer;
}
.toolbox-grid button:hover { background: #3d3126; color: #e0d8c0; }

.view-section.hidden { display: none !important; }
.view-section.active { display: block; }

/* Support link, last thing in the sidebar. Quiet on purpose: it sits below the
   backup controls, states the deal in six words, and never covers the map the
   way the Buy Me a Coffee floating widget would. */
.support-note {
    margin: 1.1rem 0 0.4rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--line, #3a3226);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--muted, #9a8f7d);
    text-align: center;
}
.support-link {
    color: var(--accent, #c8a951);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.support-link:hover,
.support-link:focus-visible { border-bottom-color: currentColor; }

/* Phone sizes for the Collection's controls. Last in the file so they beat
   the rules above at equal specificity. */
@media (max-width: 780px) {
    .toolbox-grid button { flex: 1 1 45%; padding: 14px 6px; }
    .checkbox-row label { min-height: var(--touch); }
    .context-row select { font-size: 14px; }
    .save-row button { min-height: var(--touch); }
    .chapter-missable button { min-width: var(--touch); }
}

/* Dormant ad slots - js/ads.js, "ads" in site.config.json. The build writes
   each slot's fixed size inline and hides it unless ads are enabled, so the
   space is reserved before any ad code runs and nothing shifts. Self-contained
   so it can move with the sidebar markup. Phones get at most the one slot
   inside the Collection list: never the sheet, never the map. */
.ad-slot {
    box-sizing: border-box;
    max-width: 100%;
    margin: 1rem auto;
    overflow: hidden;
    contain: strict;
}
.ad-slot[hidden] { display: none; }
.ad-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 1px dashed var(--line, #3a3226);
    color: var(--muted, #9a8f7d);
    font-size: 0.75rem;
    text-align: center;
}
@media (max-width: 780px) {
    .ad-slot[data-ad-phone="false"] { display: none; }
}
