/* =========================================
   9. TABLE VIEW (the spreadsheet)
   ========================================= */
/* The table's button, panel shell and header are the SHARED ones - see
   .toolbox and the .overlay rule. */

.table-rollup {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    font-size: 12px;
    color: #9a927f;
}
.table-rollup b { color: #e0d8c0; font-size: 14px; }
.table-rollup .stat-warn b { color: #ff6b6b; }
.table-rollup .stat-gap b { color: #f1c40f; }
.table-rollup .rollup-shown { font-style: italic; }

.table-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
}
.table-filters input,
.table-filters select,
.table-filters button {
    background: #2f2f2f;
    color: #eee;
    border: 1px solid #555;
    padding: 5px 8px;
    font-family: inherit;
    font-size: 12px;
}
.table-filters input { min-width: 240px; }
.table-filters button { cursor: pointer; }
.table-filters button:hover { background: #8b0000; }

.table-scroll { flex: 1; overflow: auto; }

#compendium-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#compendium-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #2a2a2a;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #8b0000;
    white-space: nowrap;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
#compendium-table th.sortable { cursor: pointer; user-select: none; }
#compendium-table th.sortable:hover { background: #3a3a3a; }
#compendium-table th.sorted { color: #f1c40f; }
#compendium-table th[data-dir="asc"]::after  { content: ' ▲'; font-size: 9px; }
#compendium-table th[data-dir="desc"]::after { content: ' ▼'; font-size: 9px; }

#compendium-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #262626;
    vertical-align: top;
}
#compendium-table tbody tr:nth-child(even) { background: #1a1a1a; }
#compendium-table tbody tr:hover { background: #2b2419; }

#compendium-table tbody tr.row-missable td.col-name { color: #ff9b9b; }

.col-check { width: 52px; text-align: center; }
.col-check input { accent-color: #8b0000; cursor: pointer; width: 15px; height: 15px; }
.col-name { min-width: 200px; }
.col-cat { color: #9a927f; width: 90px; }
.col-chapter { width: 100px; white-space: nowrap; color: #c9c0a8; }
.col-missable { width: 90px; }
.col-pins { width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.col-pins.pins-zero { color: #f1c40f; }
.col-note { color: #9a927f; font-size: 12px; line-height: 1.4; min-width: 280px; }

/* Deliberately muted next to .missable-tag: a mission lock is a "not yet",
   not a "lost forever", and must not compete with the red. */
.lock-tag {
    background: #5d4037;
    color: #e0d6c8;
    font-size: 9px;
    padding: 1px 4px;
    letter-spacing: 0.5px;
    margin-left: 4px;
}

.missable-tag {
    background: #b71c1c;
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    letter-spacing: 0.5px;
}
/* ---- What's Nearby ----------------------------------------------------- */
/* Docked beside the map rather than over it, unlike the table: you need to see
   the point you dropped and the list at the same time. */

/* The deliberate exception to the full-screen rule. Every other tool answers a
   question about a LIST; this one answers "what is around this point", and
   covering the map would hide the very thing it is describing. So it stays a
   rail - but shares the header, the button and the z-index of the rest.
   2026-08-10: "hunt list and what's nearby ... have different sizing."
   On a phone there is no room beside the map, so it joins the full-screen
   rule there and a tapped row closes it and flies to the pin. */
@media (min-width: 781px) {
    #nearby-panel.overlay {
        inset: 0 0 0 auto;
        width: 340px;
        border-left: 2px solid #8b0000;
    }
}


.nearby-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #333;
    font-size: 12px;
}
.nearby-controls input[type="range"] { flex: 1; min-width: 0; }
#nearby-radius-value { min-width: 20px; text-align: right; color: #c8a951; }

.nearby-summary {
    margin: 0;
    padding: 8px 14px;
    font-size: 12px;
    color: #9a9a9a;
}

.nearby-results {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}
.nearby-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-bottom: 1px solid #242424;
    font-size: 12px;
    cursor: pointer;
}
.nearby-row:hover { background: #1e1e1e; }
.nearby-row:focus-visible { outline: 2px solid #c8a951; outline-offset: -2px; background: #1e1e1e; }

.nearby-done {
    background: none;
    border: 1px solid #4a4a4a;
    color: #6a6a6a;
    width: 20px;
    height: 20px;
    flex: none;
    cursor: pointer;
    line-height: 1;
}
.nearby-done:hover { border-color: #4caf50; color: #4caf50; }

/* Distance is the whole point of this list, so it gets the accent and a fixed
   column - the eye scans down it to decide what is worth the detour. */
.nearby-dist {
    color: #c8a951;
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex: none;
}
.nearby-name { flex: 1; }
.nearby-cat { color: #777; font-size: 10px; text-transform: uppercase; }
.nearby-empty { padding: 16px 14px; color: #777; font-size: 12px; line-height: 1.5; }

/* ONE rule for every full-screen tool. They used to be three separate rules at
   three different z-indexes (1100/1200/1300) with three different header
   styles, which is why they read as three unrelated kinds of thing. Any new
   overlay joins this list - #hunt-list was missing from it, which is the whole
   reason it rendered `position: static` behind the map and looked dead.
   So it is a class now, not a list of ids: every tool is a `.overlay` and is
   opened and closed by js/overlay.js through its `hidden` attribute. What's
   Nearby narrows itself to a rail on desktop; see its own rule. */
.overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
    background: #141414;
}
.overlay[hidden] { display: none; }
.overlay:focus { outline: none; }

/* The Tools menu: the five buttons and nothing else, so on desktop it is a
   small dialog rather than a full screen with a strip of buttons at the top. */
@media (min-width: 781px) {
    #tools-panel.overlay {
        inset: 12vh auto auto 50%;
        transform: translateX(-50%);
        width: min(560px, 92vw);
        border: 1px solid #5c4e40;
        box-shadow: 0 8px 30px rgba(0,0,0,.6);
    }
}
#tools-panel .toolbox { margin: 16px; }

/* Every tool's title bar, full-screen or not. One size, one border, one close
   button - three rules that disagreed on all three used to be what made these
   panels feel like different apps. */
.overlay-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    background: #1a1a1a;
    border-bottom: 2px solid #8b0000;
}
.overlay-header h2 {
    margin: 0;
    flex: none;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 2px;
    white-space: nowrap;
}
.overlay-header > button[aria-label^="Close"] {
    margin-left: auto;
    flex: none;
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
}
.overlay-header > button[aria-label^="Close"]:hover { color: #e0d8c0; }
.hc-progress { display: flex; gap: 18px; flex: 1; font-size: 12px; color: #9a927f; }
.hc-progress b { color: #e0d8c0; font-variant-numeric: tabular-nums; }
.hc-progress .hc-done b { color: #4caf50; }
.hc-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #9a927f; cursor: pointer; }
.hc-toggle input { accent-color: #8b0000; cursor: pointer; }

.hc-scroll { flex: 1; overflow: auto; }
.hc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.hc-table th, .hc-table td {
    padding: 5px 9px;
    text-align: left;
    border-bottom: 1px solid #242424;
    white-space: nowrap;
}
.hc-table thead th {
    position: sticky;
    top: 0;
    background: #1f1f1f;
    color: #c0b8a0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 1;
}
.hc-table th.sortable { cursor: pointer; user-select: none; }
.hc-table th.sortable:hover { color: #fff; }
.hc-table th.sorted { color: #c8a951; }
.hc-table th.sorted[data-dir="asc"]::after  { content: ' ▲'; font-size: 8px; }
.hc-table th.sorted[data-dir="desc"]::after { content: ' ▼'; font-size: 8px; }
.hc-table tbody tr:hover { background: #1e1e1e; }

.hc-check { width: 28px; }
.hc-check input { accent-color: #2e8b57; cursor: pointer; }
.hc-cost { font-variant-numeric: tabular-nums; color: #c0b8a0; }
.hc-stat { text-align: center; font-variant-numeric: tabular-nums; }
.hc-total { color: #c0b8a0; font-weight: bold; }

/* The best value in each stat column - the whole reason this view exists is
   answering "which is best" without reading every row. */
.hc-stat.is-best { color: #c8a951; background: rgba(200, 169, 81, 0.10); }

/* Gang horses are reference only, so they recede rather than compete. */
.hc-npc td { color: #6a6a6a; font-style: italic; }

/* ---- Hunt list ---------------------------------------------------------- */
/* Two panes: the goals on the left, narrow because a goal is one line, and the
   materials on the right in cards, because each one carries a tally, a list of
   what wants it, and several places to get it. */
.hl-body { flex: 1; display: flex; min-height: 0; }
/* min-width:0 on both panes: without it a flex child refuses to shrink below
   its content and the whole overlay grows a horizontal scrollbar instead of the
   cards reflowing. */
.hl-pane { overflow: auto; padding: 12px 16px; min-width: 0; }
.hl-pane h3 {
    margin: 0 0 8px;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #6a6250;
}
.hl-pane-recipes { width: 300px; flex: none; border-right: 1px solid #2a2a2a; background: #171717; }
.hl-pane-materials { flex: 1; }

.hl-recipe {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid #232323;
    font-size: 12px;
}
.hl-recipe-name { flex: 1; color: #c0b8a0; }
.hl-recipe.is-fav .hl-recipe-name { color: #e0d8c0; }
.hl-recipe-count { color: #6a6250; font-size: 10px; font-variant-numeric: tabular-nums; }
.hl-recipe.is-ready .hl-recipe-count { color: #a8c070; }
.hl-craft {
    background: #2a3418;
    border: 1px solid #4a5a30;
    color: #a8c070;
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 2px 6px;
    cursor: pointer;
}
.hl-craft:hover { background: #3a4a20; color: #d0e0a0; }

/* Drops the recipe off the hunt list. Deliberately quiet - it undoes a tick
   you made on purpose, and it sits next to CRAFT, which must stay the loud
   one. Touch-sized because the hunt list is a phone screen first. */
.hl-drop {
    background: none;
    border: 1px solid transparent;
    color: #6a6250;
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
}
.hl-drop:hover { border-color: #5a3030; color: #c08080; }

/* Cards rather than table rows: a requirement has a tally, a "for" list and
   several sources, and a five-column table made all three fight for one line. */
.hl-materials-grid { display: block; }
#hunt-materials {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 10px;
    align-items: start;
}
.hl-mat {
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    padding: 8px 10px;
}
.hl-mat.is-met { opacity: 0.55; border-color: #3a4a30; }
.hl-mat.is-fav { border-color: #6a5a28; }
/* A sub-recipe with nothing recorded. Says what is missing rather than showing
   a blank where six satchels should be. */
.hl-mat.is-gap { border-color: #4a3a20; background: #1e1a14; }
.hl-mat.is-gap .hl-mat-tally { color: #b08a50; }
.hl-gap-note { color: #6a6250; font-size: 10px; line-height: 1.5; }
.hl-mat-any { color: #4a453c; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }
/* A goal you didn't tick but can't skip - one of Legend of the East's six. */
.hl-prereq { display: block; color: #6a6250; font-size: 9px; letter-spacing: 0.5px; }
/* A prerequisite's box states a fact rather than offering a tick - you mark it
   crafted on its own card, not from the thing that needs it. */
.dp-part-box.is-static { cursor: default; }
.dp-prereqs { margin: 6px 0; }
.hl-mat-head { display: flex; align-items: baseline; gap: 8px; }
.hl-mat-label {
    flex: 1;
    color: #e0d8c0;
    font-size: 12px;
    text-transform: capitalize;
}
.hl-mat-tally { color: #8a7f6d; font-size: 12px; font-variant-numeric: tabular-nums; }
.hl-mat-tally.is-met { color: #a8c070; }
.hl-mat-for { color: #6a6250; font-size: 10px; margin: 2px 0 6px; }
.hl-mat-for .is-fav { color: #c8a951; }

.hl-sources { display: flex; flex-direction: column; gap: 3px; }
.hl-source {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}
.hl-source-name { flex: 1; min-width: 0; color: #c0b8a0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-spawns { color: #4a453c; font-size: 9px; white-space: nowrap; }

/* The +/- pair. 2026-08-10: "there should be a subtract button for
   whenever you actually find the thing." */
.hl-step { display: flex; align-items: center; gap: 4px; flex: none; }
.hl-step button {
    width: 18px;
    height: 18px;
    padding: 0;
    background: #262626;
    border: 1px solid #4a4a4a;
    color: #c0b8a0;
    font-family: inherit;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.hl-step button:hover:not(:disabled) { background: #4a3c2e; border-color: #c8a951; }
.hl-step button:disabled { opacity: 0.3; cursor: default; }
.hl-step b { min-width: 12px; text-align: center; color: #e0d8c0; font-variant-numeric: tabular-nums; }

.hl-empty { color: #6a6250; font-size: 11px; line-height: 1.6; grid-column: 1 / -1; }

/* =========================================
   INVENTORY PAGE (hunt list, second tab)
   ========================================= */
.hl-tabs { display: flex; gap: 4px; }
.hl-tabs button {
    background: #1e1e1e;
    border: 1px solid #2f2f2f;
    color: #8a8270;
    font-family: inherit;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 10px;
    cursor: pointer;
}
.hl-tabs button.is-on { background: #2e2418; border-color: #6a5a28; color: #e0d8c0; }

.hl-inv-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.hl-inv-bar input[type="search"] {
    flex: 1 1 220px;
    min-width: 0;
    background: #111;
    border: 1px solid #333;
    color: #ddd;
    font-family: inherit;
    padding: 6px 8px;
}
.hl-inv-count { color: #6a6250; font-size: 10px; letter-spacing: 1px; }

/* A dense two-column-ish list rather than cards: the inventory is something you
   scan for one name and type a number into, not something you read. */
#hunt-inv-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 2px 16px;
}
.hl-inv {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-bottom: 1px solid #202020;
    font-size: 12px;
    color: #7a7466;
}
.hl-inv.is-held { color: #c0b8a0; background: #1b1a16; }
.hl-inv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-inv-part { color: #5a5448; font-size: 10px; letter-spacing: 0.5px; }
.hl-inv-input {
    width: 3.5em;
    background: #111;
    border: 1px solid #333;
    color: #ddd;
    font-family: inherit;
    font-size: 12px;
    text-align: center;
    padding: 2px;
}

/* Phone: the two-pane hunt list is two half-panes of nothing. */
@media (max-width: 780px) {
    .hl-body { flex-direction: column; }
    .hl-pane-recipes { width: auto; flex: 0 0 auto; border-right: none; border-bottom: 1px solid #2a2a2a; }
    .hl-pane-materials { flex: 1 1 auto; }
}

/* `display: flex` on .hl-body outranks the [hidden] attribute's UA rule, so the
   two hunt-list pages rendered on top of each other. Same trap as any flex/grid
   container that also toggles `hidden`. */
.hl-body[hidden] { display: none; }
/* Header only - the inventory page has its own .hc-toggle ("Only what I have")
   inside .hl-inv-bar, which an unscoped selector would hide too. */
#hunt-list.is-inventory > .overlay-header .hc-toggle,
#hunt-list.is-inventory > .overlay-header #hunt-list-progress { display: none; }
/* .hl-pane carries no flex-grow (the hunt view's two panes size themselves),
   so the inventory's single pane shrank to its content and left most of a
   1600px overlay empty. */
.hl-inv-body .hl-pane { flex: 1; }

/* CHALLENGES
   Nine cards on an auto-fitting grid rather than a fixed column count: the
   card has a natural minimum (a rank name plus its tip is ~2 lines at 320px)
   and the screen decides how many fit. Per the project's rule, no px width is
   authored here beyond that one minimum. */
.ch-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
    align-content: start;
}

.ch-card {
    background: #1c1c1c;
    border: 1px solid #333;
    padding: 12px 14px;
}
.ch-card.is-finished { opacity: 0.6; }

.ch-card-head { display: flex; align-items: baseline; gap: 10px; }
.ch-card-head h3 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #e0d8c0;
}
.ch-count { font-size: 12px; color: #9a927f; font-variant-numeric: tabular-nums; }
.ch-expand {
    margin-left: auto;
    background: none;
    border: 1px solid #4a4a4a;
    color: #9a927f;
    font-family: inherit;
    font-size: 10px;
    padding: 2px 7px;
    cursor: pointer;
}
.ch-expand:hover { color: #e0d8c0; border-color: #6a6a6a; }

.ch-bar { height: 3px; background: #2b2b2b; margin: 8px 0 10px; }
.ch-bar i { display: block; height: 100%; background: #8b0000; }

.ch-rank { display: flex; gap: 9px; padding: 7px 0; border-top: 1px solid #2a2a2a; }
.ch-rank:first-of-type { border-top: none; }
.ch-rank.is-done { opacity: 0.45; }
/* The rank you're on, when the whole ladder is showing. Without it, an
   expanded card is ten equal rows and the answer to "what now" is gone. */
.ch-rank.is-current { background: #201c14; margin: 0 -14px; padding: 7px 14px; }
.ch-rank.is-locked .ch-rank-name { color: #8a8378; }

.ch-tick {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    background: #262626;
    border: 1px solid #555;
    color: #4caf50;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.ch-tick:hover { border-color: #8b0000; }

.ch-rank-main { min-width: 0; }
.ch-rank-name { font-size: 12px; color: #d8d0c0; }
.ch-rank-name b { color: #9a927f; font-weight: normal; }
.ch-tip { margin: 4px 0 0; font-size: 11px; line-height: 1.45; color: #9a927f; }

.ch-places { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ch-place {
    background: #2b2b2b;
    border: 1px solid #4a4a4a;
    color: #c9a24a;
    font-family: inherit;
    font-size: 10px;
    padding: 2px 6px;
    cursor: pointer;
}
.ch-place:hover { background: #3a3a3a; }
/* A place we hold no coordinates for. Same shape, deliberately not a button -
   there is nowhere to fly to, and a dead control is worse than a label. */
.ch-place-flat { color: #7d776c; cursor: default; border-style: dashed; }

.ch-locked { margin: 5px 0 0; font-size: 10px; color: #d9a825; }
.ch-finished { margin: 4px 0 0; font-size: 11px; color: #4caf50; }
.ch-empty { color: #9a927f; }

/* Sortable headers are buttons now (see .th-sort in base.css); the hover and
   the arrow stay on the th. */
.table-sentinel td { padding: 0; border: 0; height: 1px; }
.table-more { color: #9a927f; font-size: 11px; text-align: center; padding: 10px; }

/* PHONE: every tool is full screen (the .overlay rule already is) and every
   control in one is a thumb's width. */
@media (max-width: 780px) {
    .overlay-header { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
    .overlay-header > button[aria-label^="Close"] { order: 1; min-width: var(--touch); min-height: var(--touch); font-size: 20px; }
    /* Title and close share the first line; everything else wraps under. */
    .overlay-header > :not(h2, button[aria-label^="Close"]) { order: 2; }
    .overlay-header h2 { flex: 1 0 calc(100% - var(--touch) - 20px); }
    .hc-toggle { min-height: var(--touch); }
    .hl-tabs button { min-width: var(--touch); min-height: var(--touch); }
    .hl-step { gap: 6px; }
    .hl-step button { width: var(--touch); height: var(--touch); min-width: var(--touch); }
    .hl-drop { min-width: var(--touch); min-height: var(--touch); }
    .hl-craft { min-height: var(--touch); padding: 2px 10px; }
    .hl-inv-input { min-height: var(--touch); font-size: 16px; }
    .table-filters input { min-width: 0; width: 100%; }
    .table-filters input, .table-filters select, .table-filters button { min-height: var(--touch); font-size: 14px; }
    #compendium-table th, .hc-table thead th { height: var(--touch); }
    .col-check input, .hc-check input { width: 24px; height: 24px; }
    /* The whole cell takes the tap - see the cell handlers in tableView.js
       and horseCompare.js - so a 24px box still has a 44px target. */
    .col-check, .hc-check { cursor: pointer; min-width: var(--touch); }
    .th-sort { min-width: var(--touch); }
    .nearby-controls { flex-wrap: wrap; }
    .nearby-controls input[type="range"] { min-height: var(--touch); }
    .nearby-row { min-height: var(--touch); box-sizing: border-box; }
    .nearby-done { width: var(--touch); height: var(--touch); }
    .ch-tick { width: var(--touch); height: var(--touch); }
    .ch-expand, .ch-place { min-height: var(--touch); padding: 2px 10px; }
    .ch-body { grid-template-columns: 1fr; padding: 10px; }
}
