/* Brand palette — Leroy D. Simpson, Psy.D: Green, Pearl, Burgundy, Old Gold.
   (--brass names are kept for the old-gold accent so component styles stay unchanged.) */
:root {
  --green: #1f4a3b;
  --green-deep: #0f241c;
  --green-hi: #7fb99a;
  --pearl: #f2ede3;
  --burgundy: #6d1f2f;
  --burgundy-deep: #4a1420;
  --gold: #c5a253;
  --ink: #0a120f;
  --ink-2: #111b17;
  --glass: rgba(10, 20, 16, .66);
  --glass-strong: rgba(9, 17, 14, .88);
  --glass-line: rgba(242, 237, 227, .16);
  --text: #f2ede3;
  --muted: #c9c1b2;
  --faint: #938b7d;
  --brass: #c5a253;
  --brass-hi: #e3ca8a;
  --walnut: #4a1420;
  --focus: #e3ca8a;
  --ok: #7fb99a;
  --r: 14px;
  --r-sm: 9px;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
  --fs: 1rem;
  --ease: cubic-bezier(.22, .7, .2, 1);
  --t: 1;
  /* linear (reading) mode */
  --paper: #f5f1e8;
  --paper-2: #ebe5d8;
  --paper-ink: #1a1c18;
  --paper-muted: #545249;
  --paper-line: #d6cebd;
  --paper-accent: #6d1f2f;
  --paper-green: #1f4a3b;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1612; --paper-2: #14201b; --paper-ink: #f2ede3; --paper-muted: #bdb5a6; --paper-line: #2c3a33; --paper-accent: #e3ca8a; --paper-green: #7fb99a;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1612; --paper-2: #14201b; --paper-ink: #f2ede3; --paper-muted: #bdb5a6; --paper-line: #2c3a33; --paper-accent: #e3ca8a; --paper-green: #7fb99a;
}

/* Placeholder monogram: old-gold "LS" on burgundy */
.mono { display: inline-grid; place-items: center; flex: none; width: var(--s, 40px); height: var(--s, 40px); border-radius: 4px;
  background: linear-gradient(150deg, var(--burgundy), var(--burgundy-deep)); color: var(--gold);
  font: 500 calc(var(--s, 40px) * .44)/1 var(--serif); letter-spacing: .04em;
  box-shadow: inset 0 0 0 1px rgba(197, 162, 83, .55), inset 0 0 0 3px var(--burgundy-deep), inset 0 0 0 4px rgba(197, 162, 83, .35); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font: 400 var(--fs)/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body.large-text { --fs: 1.14rem; }
body.mode-linear { overflow: auto; background: var(--paper); color: var(--paper-ink); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.mode-linear :focus-visible { outline-color: var(--paper-accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.25em; height: 1.25em; flex: none; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--brass); color: #1a1208; padding: 10px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.skip-link:focus { top: 12px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px clamp(16px, 2.4vw, 28px);
  background: linear-gradient(180deg, rgba(8, 9, 10, .78), rgba(8, 9, 10, 0));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hud-left { display: flex; flex-direction: column; min-width: 0; }
.hud-brand { font: 600 .68rem/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brass); white-space: nowrap; }
.hud-loc { font: 400 1.05rem/1.3 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; margin-top: 4px; }
.hud-progress { display: flex; gap: 5px; align-items: center; margin-left: auto; }
.hud-progress button {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, .05); font: 600 .62rem/1 var(--sans); color: var(--muted); padding: 0;
  transition: background .3s, color .3s, transform .3s;
}
.hud-progress button.visited { background: rgba(197, 162, 83, .28); color: var(--brass-hi); border-color: rgba(197, 162, 83, .5); }
.hud-progress button.current { background: var(--brass); color: #2a0d14; transform: scale(1.15); }
.hud-progress .count { font-size: .75rem; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.hud-right { display: flex; gap: 6px; align-items: center; }
.hud-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--glass-line); background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: .82rem; white-space: nowrap;
}
.hud-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hud-btn:hover { border-color: rgba(197, 162, 83, .55); }
#btn-sound .snd-on { display: none; }
#btn-sound[aria-pressed="true"] .snd-on { display: inline; }
#btn-sound[aria-pressed="true"] .snd-off { display: none; }
.mode-toggle { display: inline-flex; border: 1px solid var(--glass-line); border-radius: 999px; background: var(--glass); backdrop-filter: blur(12px); padding: 3px; }
.mode-toggle button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.mode-toggle button[aria-pressed="true"] { background: var(--brass); color: #2a0d14; font-weight: 600; }
.mode-linear .hud { position: fixed; background: var(--paper-2); border-bottom: 1px solid var(--paper-line); color: var(--paper-ink); }
.mode-linear .hud-btn, .mode-linear .mode-toggle { background: var(--paper); border-color: var(--paper-line); color: var(--paper-ink); backdrop-filter: none; }
.mode-linear .hud-progress, .mode-linear #btn-map, .mode-linear #btn-sound, .mode-linear .hud-loc { display: none; }
.mode-linear .mode-toggle button { color: var(--paper-muted); }
.mode-linear .mode-toggle button[aria-pressed="true"] { background: var(--paper-accent); color: var(--paper); }
.mode-linear .hud-brand { color: var(--paper-accent); }

/* ---------- Dock ---------- */
.dock {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 6px; padding: 6px;
  border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}
.dock-btn { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; background: rgba(255, 255, 255, .06); font-size: .86rem; white-space: nowrap; }
.dock-btn:hover { background: rgba(255, 255, 255, .12); }
.dock-btn.primary { background: var(--brass); color: #2a0d14; font-weight: 600; }
.dock-btn.primary:hover { background: var(--brass-hi); }
.dock-btn.ghost { background: none; border-color: var(--glass-line); color: var(--muted); }
.dock-btn[disabled] { opacity: .35; cursor: default; }
.dock-now { min-width: 120px; text-align: center; font: 500 .8rem/1.2 var(--sans); letter-spacing: .06em; color: var(--muted); padding: 0 8px; }
.mode-linear .dock { display: none; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .06); font-size: .9rem; text-decoration: none; color: inherit; }
.btn:hover { border-color: rgba(197, 162, 83, .6); background: rgba(255, 255, 255, .1); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #2a0d14; font-weight: 600; }
.btn.primary:hover { background: var(--brass-hi); }
.btn.sm { min-height: 34px; padding: 0 13px; font-size: .8rem; }

/* ---------- Dialogs ---------- */
.dlg {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--glass-line); border-radius: 18px; background: #121416; color: var(--text);
  box-shadow: 0 40px 90px rgba(0, 0, 0, .55); overflow: auto;
}
.dlg::backdrop { background: rgba(4, 5, 6, .66); backdrop-filter: blur(4px); }
.dlg-sm { width: min(480px, calc(100vw - 32px)); }
.dlg-wide { width: min(1080px, calc(100vw - 32px)); }
.dlg-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; background: #121416; border-bottom: 1px solid var(--glass-line); z-index: 2; }
.dlg-head h2 { font-size: 1.45rem; }
.dlg > p, .dlg-actions { padding: 18px 22px; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 0; }
.x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--glass-line); background: none; font-size: 1.3rem; line-height: 1; }
.mode-linear .dlg, .mode-linear .dlg-head { background: var(--paper); color: var(--paper-ink); border-color: var(--paper-line); }

.settings { padding: 8px 22px 22px; display: grid; gap: 4px; }
.sw { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--glass-line); cursor: pointer; }
.sw input { grid-row: span 2; width: 20px; height: 20px; accent-color: var(--brass); margin-top: 2px; }
.sw span { font-weight: 600; }
.sw small { color: var(--muted); font-size: .82rem; }
.set-keys h3 { font: 600 .78rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brass); margin: 16px 0 8px; }
.set-keys ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: .88rem; color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .06); font: 600 .75rem/1.5 var(--sans); color: var(--text); text-align: center; }

/* ---------- Veil (room-to-room transition) ---------- */
.veil { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.door { position: absolute; top: 0; bottom: 0; width: 50.5%; background:
  linear-gradient(90deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0) 30%),
  linear-gradient(180deg, #17352a, #0b1a14); transform: translateX(var(--off)); transition: transform calc(.55s * var(--t)) var(--ease); }
.door::after { content: ""; position: absolute; top: 50%; width: 3px; height: 90px; margin-top: -45px; border-radius: 3px; background: var(--brass); box-shadow: 0 0 18px rgba(197, 162, 83, .6); }
.door-l { left: 0; --off: -101%; } .door-l::after { right: 18px; }
.door-r { right: 0; --off: 101%; } .door-r::after { left: 18px; }
.veil.closed .door { --off: 0%; }
.veil-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 86vw); text-align: center; opacity: 0; transition: opacity .25s; }
.veil.closed .veil-card { opacity: 1; transition-delay: .2s; }
.veil-card .k { font: 600 .72rem/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--brass); }
.veil-card h3 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 10px 0 8px; }
.veil-card p { color: var(--muted); font-size: .95rem; }
.veil.fade .door { display: none; }
.veil.fade { background: var(--ink); opacity: 0; transition: opacity .18s; }
.veil.fade.closed { opacity: 1; }

/* ---------- Caption ---------- */
.caption { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 35; padding: 6px 14px; border-radius: 8px; background: rgba(0, 0, 0, .78); color: #fff; font-size: .82rem; opacity: 0; transition: opacity .3s; pointer-events: none; }
.caption.show { opacity: 1; }

/* ---------- Motion preferences ---------- */
body.reduce-motion { --t: 0; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; }

/* ---------- Print (action plan) ---------- */
.print-only { display: none; }
@media print {
  body > *:not(#print-plan) { display: none !important; }
  body { overflow: visible; background: #fff; color: #000; }
  #print-plan { display: block; font: 11pt/1.5 Georgia, serif; color: #000; padding: 0 8mm; }
  #print-plan h1 { font-size: 20pt; margin-bottom: 6pt; }
  #print-plan h2 { font-size: 13pt; margin: 14pt 0 4pt; }
  #print-plan table { width: 100%; border-collapse: collapse; }
  #print-plan td, #print-plan th { border: 1px solid #999; padding: 5pt; text-align: left; vertical-align: top; }
}

/* ---------- Responsive HUD ---------- */
@media (max-width: 1100px) {
  .hud-btn span, .hud-progress .count { display: none; }
  .hud-btn { width: 38px; padding: 0; justify-content: center; }
}
@media (max-width: 820px) {
  .hud { flex-wrap: wrap; gap: 8px; }
  .hud-progress { order: 3; width: 100%; justify-content: center; margin: 0; gap: 3px; }
  .hud-progress button { width: 18px; height: 18px; font-size: 0; }
  .hud-right { margin-left: auto; }
  .mode-toggle button { padding: 6px 9px; font-size: .7rem; }
  .hud-loc { max-width: 52vw; }
  .dock { width: calc(100vw - 24px); justify-content: space-between; }
  .dock-btn { padding: 0 12px; font-size: .8rem; }
  #nav-lobby, #nav-exec, .dock-now { display: none; }
  #nav-prev, #nav-next { flex: 1; }
}
@media (max-width: 560px) {
  .hud-brand { display: none; }
  .m-hide { display: none; }
  .hud-left { width: 100%; }
  .hud-loc { max-width: 100%; }
  .hud-right { margin-left: 0; width: 100%; justify-content: space-between; }
}
