/* Markets of War — Deal desk, Ledger, Chronicle, Settings, Regions and War Cards panels (playtest revisions).
   New classes are prefixed .gp-; overrides are scoped under the panels' own root classes. Linked after game.css. */

/* ---------- shared: legibility (E5) ---------- */
.gp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:is(.g-desk, .g-ledger, .g-chron, .g-settings, .g-regions, .g-hand, .g-pledges) :focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
:is(.g-desk, .g-ledger, .g-chron, .g-settings, .g-regions, .g-hand) .g-small { opacity: 1; color: var(--ink-soft); font-size: max(.88rem, 13px); }
:is(.g-desk, .g-ledger, .g-chron, .g-settings, .g-regions, .g-hand) .g-empty { opacity: 1; color: var(--ink-soft); }
:is(.g-desk, .g-ledger, .g-settings, .g-regions) .g-num small,
:is(.g-desk, .g-ledger) .g-letter header small,
.g-ledger .g-ltable th small { color: var(--ink-faint); font-size: max(.82rem, 12px); }
.g-ledger .g-ftable thead th { color: var(--ink-soft); font-size: max(.78rem, 12px); }
.g-ledger .g-ftable tbody th { font-weight: 400; font-family: var(--font-num); }
:is(.g-desk, .g-settings) .g-seg-opt small { opacity: 1; color: inherit; }
:is(.g-desk, .g-ledger, .g-settings, .g-hand) .btn[aria-disabled="true"] { opacity: 1; filter: none; color: var(--ink-soft); background: repeating-linear-gradient(135deg, rgba(122,95,53,.10) 0 6px, rgba(122,95,53,.22) 6px 12px); border: 1px dashed var(--ink-faint); box-shadow: none; }
:is(.g-desk, .g-ledger, .g-settings, .g-hand) .btn--primary[aria-disabled="true"]::before { content: "⊘"; font-family: var(--font-num); margin-right: .2em; }
.g-count { min-width: 20px; height: 20px; font-size: 12px; }
.gp-kbd, .gp-keys kbd { display: inline-block; min-width: 1.6em; padding: 0 .4em; border: 1px solid var(--ink-faint); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,250,235,.7); color: var(--ink); font: 600 max(.85rem, 12px) var(--font-num); text-align: center; line-height: 1.5; }
.gp-tick { font-family: var(--font-num); font-weight: 700; }

/* gains and losses carry a sign and stay ≥ 4.5:1 on parchment */
.g-ledger .g-lneg td { color: #7b2d26; }
.g-ledger .gp-gain td, .gp-gain-txt { color: #2b5e36; }
.gp-short { color: #7b2d26; font-weight: 600; }
.panel .g-warn { color: var(--oxblood); }

/* ---------- tabs: pinned row, conventional selected state ---------- */
.g-root .g-drawer.g-drawer--deals .g-drawer-body, .g-root .g-drawer.g-drawer--chronicle .g-drawer-body { padding-top: 0; }
.gp-desk > .gp-tabs { position: sticky; top: 0; z-index: 2; margin: 0 -20px 10px; padding: 8px 14px 0; background: var(--parchment) url("/assets/img/parchment.webp") center / 512px; box-shadow: 0 6px 8px -6px rgba(60,40,10,.35); flex-wrap: wrap; overflow: visible; }
.gp-chron > .gp-tabs { padding-top: 8px; flex-wrap: wrap; overflow: visible; }
.gp-tabs .g-tab { font-size: max(.9rem, 13px); padding: 6px 7px; letter-spacing: .03em; color: var(--ink-soft); }
.gp-tabs .g-tab[aria-selected="true"] { color: var(--ink); font-weight: 600; background: rgba(255,250,235,.85); border-color: var(--brass-lo); box-shadow: inset 0 3px 0 var(--oxblood); }
.gp-tabs .g-tab[aria-selected="false"]:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.g-root.g-compact .gp-desk > .gp-tabs { margin: 0 -12px 8px; padding: 6px 6px 0; gap: 0; }
.g-root.g-compact .gp-tabs .g-tab { padding: 6px 5px; font-size: max(.84rem, 13px); letter-spacing: .02em; }
.g-root.g-compact .gp-tabs .g-count { margin-left: 3px; }

/* segmented radios: selected = filled + check mark; unselected = plain paper */
:is(.g-desk, .g-settings) .g-seg-opt[aria-checked="true"] { color: var(--ink); }
:is(.g-desk, .g-settings) .g-seg-opt[aria-checked="false"] { background: rgba(255,250,235,.75); }

/* War Aid purpose radios: draw the circle ourselves (the dark colour scheme painted unchecked ones filled) */
.gp-radio input[type="radio"] { appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 0; border-radius: 50%; border: 2px solid var(--ink-soft); background: #fffaf0; display: grid; place-items: center; cursor: pointer; }
.gp-radio input[type="radio"]::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--oxblood); transform: scale(0); transition: transform .12s; }
.gp-radio input[type="radio"]:checked { border-color: var(--oxblood); }
.gp-radio input[type="radio"]:checked::before { transform: scale(1); }
.gp-radio input[type="radio"]:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.gp-radio.is-on { background: rgba(255,250,235,.85); box-shadow: inset 0 0 0 1px var(--brass-lo); }

/* checkboxes in Settings */
.gp-check { align-items: flex-start; padding: 4px 0; }
.gp-check input { margin-top: 3px; flex: none; }
.gp-check > span { display: grid; gap: 1px; }
.gp-hint { color: var(--ink-faint); font-size: max(.84rem, 12px); line-height: 1.3; }
.gp-check.is-disabled { color: var(--ink-soft); }
.gp-check.is-disabled > span::after { content: "(unavailable)"; font-size: 12px; color: var(--ink-faint); }

/* ---------- player picker with money facts (D1) ---------- */
.gp-ppick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.gp-ppick-opt { justify-content: flex-start; text-align: left; border-radius: 10px; padding: 5px 10px 5px 6px; min-height: 48px; }
.gp-ppick-opt[aria-checked="true"] { background: #fffaf0; }
.gp-ppick-txt { display: grid; gap: 1px; min-width: 0; }
.gp-ppick-name { font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.gp-ai { font: 400 12px var(--font-body); color: var(--ink-faint); }
.gp-facts { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.3; }
.gp-why { display: block; font-size: 12.5px; line-height: 1.3; color: #7b2d26; }
.gp-why::before { content: "⊘ "; }
.gp-ppick-opt.is-blocked { background: repeating-linear-gradient(135deg, rgba(122,95,53,.06) 0 6px, rgba(122,95,53,.16) 6px 12px); border-style: dashed; cursor: not-allowed; }
.gp-ppick-opt.is-blocked .gp-ppick-name { color: var(--ink-soft); }
.gp-ppick-opt[aria-disabled="true"]:not(.is-blocked) { opacity: .75; cursor: default; }
.gp-afford { margin-top: 0; }
.gp-hint-line { padding: 6px 10px; border: 1px dashed var(--brass-lo); border-radius: 6px; background: rgba(255,250,235,.45); }

/* ---------- letters ---------- */
.gp-letter.is-counter { border-style: double; border-width: 3px; }
.gp-letter .gp-why { margin: 0 0 6px; }
.g-wax.is-blocked { filter: grayscale(.9); opacity: .7; cursor: not-allowed; }
.gp-counter-note { border-left-color: var(--navy); }
.gp-sent { border-left-color: #2b5e36; }
.gp-replies { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gp-reply { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: rgba(255,250,235,.45); border: 1px solid rgba(122,95,53,.3); }
.gp-reply p { margin: 0; overflow-wrap: anywhere; }
.gp-reply > div { min-width: 0; flex: 1; }
.gp-reply-head { font-size: 13px; }
.gp-reply-tag { display: inline-block; padding: 0 8px; border-radius: 10px; border: 1px solid currentColor; font: 600 12px var(--font-num); text-transform: lowercase; color: var(--ink-soft); }
.gp-reply-tag--declined, .gp-reply-tag--stalled { color: #7b2d26; }
.gp-reply-tag--countered { color: var(--navy); }
.gp-quote { margin: 6px 0 0; padding: 4px 10px; border-left: 3px solid var(--c, var(--brass)); font-style: italic; background: rgba(255,250,235,.5); }
.gp-quote footer { font-style: normal; font-size: 12.5px; color: var(--ink-soft); }

/* toasts never cover the deal desk's form on phones: the desk shows letters and replies inline */
.g-root.g-compact:has(.g-drawer--deals) .g-toasts { display: none; }

/* ---------- Ledger ---------- */
.gp-recv { margin-bottom: 4px; }

/* ---------- Chronicle (C7) ---------- */
.gp-chron .g-chron-item > span, .gp-chat span { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.gp-chat span { white-space: pre-wrap; }
.gp-setup-head { font-weight: 600; font-family: var(--font-display); font-size: .9rem; letter-spacing: .02em; }
.gp-chron .g-chron-list:focus-visible { outline-offset: -3px; }

/* ---------- Settings ---------- */
.gp-help { align-items: center; }
.gp-wide { flex-basis: 100%; margin: 4px 0 0; }
.gp-danger-zone { margin-top: 10px; padding: 12px; border: 1px solid rgba(123,45,38,.45); border-radius: 8px; background: rgba(123,45,38,.06); }
.gp-danger-zone h3 { margin-bottom: 8px; }
.gp-danger-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.gp-danger-row .g-small { margin: 0; }
.gp-confirm { padding: 8px 10px; border-radius: 6px; background: rgba(255,250,235,.7); border: 1px solid var(--oxblood); }

/* ---------- Regions: rivals' cards ---------- */
.gp-rivals { margin-top: 12px; border-top: 1px solid rgba(122,95,53,.3); }
.gp-rival-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gp-rival-list li { display: flex; gap: 8px; align-items: flex-start; font-size: .95rem; }
.gp-intel { display: grid; gap: 1px; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }
.gp-threat.is-hot { color: #7b2d26; font-weight: 600; }

/* ---------- Glossary terms ---------- */
.gp-term { position: relative; display: inline; }
.gp-term-btn { display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: help; text-decoration: underline dotted; text-decoration-thickness: 1.5px; text-underline-offset: 3px; min-height: 0; }
.gp-term-pop { position: absolute; z-index: 40; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); width: max-content; max-width: min(300px, 80vw); padding: 8px 10px; border-radius: 6px;
  background: var(--ink); color: var(--parchment-hi); border: 1px solid var(--brass); box-shadow: var(--shadow); font: 400 14px/1.4 var(--font-body); font-style: normal; text-align: left; white-space: normal; }
.gp-term-pop b { color: var(--brass-hi); }
@media (max-width: 560px) { .gp-term-pop { position: fixed; left: 12px; right: 12px; bottom: auto; top: 30%; transform: none; max-width: none; width: auto; } }

/* ---------- modal overlay (keyboard shortcuts) ---------- */
.gp-modal-back { position: fixed; inset: 0; z-index: calc(var(--z-tutorial) + 1); display: grid; place-items: center; padding: 16px; background: rgba(10,6,3,.7); animation: fade-in .15s both; }
.gp-modal { width: min(760px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 16px 20px; }
.gp-modal:focus { outline: none; }
.gp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(122,95,53,.4); margin-bottom: 8px; }
.gp-modal-head h2 { margin: 0; font-size: 1.3rem; color: var(--ink); }
.gp-x { width: 44px; height: 44px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink); border-radius: 6px; }
.gp-x:focus-visible { outline: 3px solid var(--navy); }
.gp-small { font-size: 14px; color: var(--ink-soft); margin: 6px 0; }
.gp-keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 24px; }
.gp-keys h3 { font-size: 1rem; color: var(--oxblood); margin: 10px 0 4px; }
.gp-keys dl { margin: 0; display: grid; gap: 4px; }
.gp-key-row { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 10px; align-items: baseline; padding: 3px 0; border-bottom: 1px dotted rgba(122,95,53,.3); }
.gp-key-row dt { white-space: nowrap; }
.gp-key-row dd { margin: 0; font-size: 15px; }
.gp-glossary { display: grid; gap: 8px; margin: 0; }
.gp-glossary dt { font-weight: 600; }
.gp-glossary dd { margin: 0 0 0 1em; }

/* short landscape phones: one scrolling tab row so the pinned row stays small */
.g-root.g-compact.g-landscape .gp-desk > .gp-tabs, .g-root.g-compact.g-landscape .gp-chron > .gp-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.g-root.g-compact.g-landscape .gp-tabs .g-tab { min-height: 36px; }

/* ---------- opening roll: waiting for every player (no countdown) ---------- */
.g-or-wait { display: grid; justify-items: center; gap: 6px; margin-top: 10px; text-align: center; }
.g-or-wait p { margin: 0; font-style: italic; color: var(--ink-soft); }
.g-or-ready { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.g-or-ready li { padding: 2px 10px; border-radius: 12px; border: 1px dashed var(--ink-faint); font-size: 14px; color: var(--ink-soft); }
.g-or-ready li.is-ready { border-style: solid; border-color: #2b5e36; color: #2b5e36; font-weight: 600; }
.g-or-ready small { font-weight: 400; color: var(--ink-faint); }
.gp-suggest { padding: 6px 10px; border-left: 3px solid var(--navy); background: rgba(255,250,235,.6); }

/* ---------- declarations of war ---------- */
.gp-war-back { z-index: calc(var(--z-modal) + 5); }
.gp-war { width: min(480px, 100%); border: 2px solid var(--oxblood); }
.gp-war h2 { color: var(--oxblood); margin: 0 0 8px; font-size: 1.3rem; }
.gp-war p { margin: 0 0 12px; font-size: 1.05rem; color: var(--ink); }
.gp-war-acts { display: flex; flex-wrap: wrap; gap: 10px; }
.gp-war-acts .btn { min-height: 48px; flex: 1 1 140px; }
.gp-war-clock { margin: 12px 0 0 !important; font-size: 14px !important; color: var(--ink-soft) !important; display: grid; gap: 4px; }
.gp-war-bar { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--oxblood) calc(var(--p) * 100%), rgba(122,95,53,.2) 0); }
.gp-warnote { align-self: stretch; display: grid; gap: 4px; padding: 8px 12px; border-radius: 8px; background: var(--parchment); color: var(--ink); border: 2px solid var(--oxblood); box-shadow: var(--shadow); font-size: 15px; }
.gp-warnote p { margin: 0; }
.gp-warnote-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.gp-warnote-row p { flex: 1 1 220px; }
.gp-warnote-acts { display: flex; gap: 6px; align-items: center; }
.gp-warnote .gp-x { width: 36px; height: 36px; font-size: 22px; }

/* ---------- players who step away: decider popup, waiting indicator, menu actions ---------- */
.gp-away-back { z-index: calc(var(--z-modal) + 4); }
.gp-away { width: min(500px, 100%); border: 2px solid var(--brass-lo); }
.gp-away h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--ink); }
.gp-away > p { margin: 0 0 10px; color: var(--ink); font-size: 1.02rem; }
.gp-away-opts { display: grid; gap: 8px; margin-bottom: 10px; }
.gp-away-opt { display: grid; gap: 2px; text-align: left; padding: 10px 12px; min-height: 56px; border-radius: 8px; cursor: pointer; color: var(--ink);
  background: rgba(255,250,235,.55); border: 1px solid rgba(122,95,53,.45); }
.gp-away-opt b { font-size: 1.05rem; }
.gp-away-opt small { font-size: .9rem; color: var(--ink-soft); line-height: 1.25; }
.gp-away-opt.is-on { background: rgba(255,250,235,.95); border-color: var(--oxblood); box-shadow: inset 4px 0 0 var(--oxblood); }
.gp-away-remember { margin: 0 0 10px; }
.gp-away-acts { display: flex; gap: 10px; }
.gp-away-acts .btn { flex: 1 1 auto; min-height: 48px; }
.gp-away-later { margin: 8px 0 0; }
/* phones: the popup is a bottom sheet over the board */
.gp-away-back.is-sheet { place-items: end stretch; padding: 0; }
.gp-away-back.is-sheet .gp-away { width: 100%; max-height: 82dvh; border-radius: 16px 16px 0 0; border-width: 2px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); animation: rise-in .2s var(--ease, ease) both; }
.g-root.g-landscape .gp-away-back.is-sheet .gp-away { width: min(560px, 100%); margin: 0 auto; }

.gp-awaynote {
  position: absolute; z-index: var(--z-hud); left: 50%; top: calc(var(--g-top-h) + 24px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; max-width: min(560px, calc(100% - 2 * var(--g-rail-w) - 24px)); padding: 5px 14px; border-radius: 16px;
  font-size: .98rem; line-height: 1.25; color: var(--parchment-hi); background: rgba(28,19,13,.9); border: 1px solid rgba(176,141,87,.7); box-shadow: var(--shadow);
  pointer-events: none;
}
.gp-awaynote b { color: #fff3d6; }
.gp-awaynote-slow { opacity: .8; font-style: italic; }
.gp-awaynote-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px rgba(201,162,39,.8); animation: gp-away-pulse 2s ease-in-out infinite; }
@keyframes gp-away-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .gp-awaynote-dot { animation: none; } }
/* compact layouts: a slim band attached under the top strip; toasts move below it */
.g-root.g-compact .gp-awaynote { left: 0; right: 0; top: var(--g-top-h); transform: none; max-width: none; border-radius: 0; border-width: 0 0 1px; padding: 4px 10px; font-size: .84rem; justify-content: center; box-shadow: none; }
.g-root.g-compact.g-landscape .gp-awaynote { right: var(--g-colw, 0px); }
.g-root.g-compact.has-awaynote .g-toasts, .g-root.g-compact.has-awaynote .g-ticker { top: calc(var(--g-top-h) + 34px); }

.g-badge--waiting { background: #5a4a1e; border-color: #b39a4d; color: #fbefc8; }
.g-mini-dots .d-away.is-waiting { background: var(--warn); }
.gp-awayacts { display: grid; gap: 6px; margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: rgba(255,250,235,.55); border: 1px solid rgba(122,95,53,.4); }
.gp-awayacts p { margin: 0; }
.gp-awayacts-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gp-table-sec .awaypick { margin-bottom: 6px; }

/* ---------- table modules: market, goods ---------- */
.gp-good { position: relative; display: inline-grid; place-items: center; vertical-align: -.3em; border-radius: 50%; background: rgba(122,95,53,.18); flex: none; }
.gp-good img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.gp-good i { font: 700 10px var(--font-num); font-style: normal; color: var(--ink-soft); }
.gp-good img:not([style*="none"]) + i { visibility: hidden; }
.gp-market .g-sec h3 { margin-top: 4px; }
.gp-mtable { width: 100%; border-collapse: collapse; font-size: .95rem; }
.gp-mtable th, .gp-mtable td { padding: 4px 6px; border-bottom: 1px solid rgba(122,95,53,.25); text-align: right; white-space: nowrap; }
.gp-mtable th:first-child, .gp-mtable td:first-child { text-align: left; }
.gp-mtable thead th { font: max(.78rem, 12px) var(--font-caps); letter-spacing: .05em; color: var(--ink-soft); }
.gp-mrow { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.gp-mtable tr.is-open > * { background: rgba(255,250,235,.7); }
.gp-mtrade td { text-align: left !important; white-space: normal !important; }
.gp-trade { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 0; }
.gp-trend { color: var(--ink-soft); }
.gp-trend.is-up { color: #2b5e36; }
.gp-trend.is-down { color: #7b2d26; }
.gp-spark { vertical-align: middle; }
.gp-spark.is-empty { display: inline-block; width: 56px; }
.gp-produce { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; font-size: .95rem; }
.gp-scroll-x { overflow-x: auto; }
.gp-mtable--rivals th, .gp-mtable--rivals td { text-align: center; }
.gp-offnote { font-style: italic; }

/* rulebook: module status marks (codex) */
.codex-status { display: inline-block; margin: 0 0 8px; padding: 2px 10px; border-radius: 12px; font-size: 14px; border: 1px solid currentColor; }
.codex-status.is-on { color: #2b5e36; }
.codex-status.is-off { color: #7b2d26; border-style: dashed; }
