/* ============================================================
   Operative Path — Training Terminal
   First Light noir: cold dark glass, thin lines of light,
   champagne gold reserved for moments that matter.
   Mirrors OperativePath/DesignSystem/Theme.swift.
   ============================================================ */

:root {
  --bg:          #04070B;
  --bg-elevated: #08131F;
  --card:        #0A141F;
  --card-hi:     #101E2C;
  --signal:      #E9EEF4;
  --brass:       #C3A96A;
  --brass-hi:    #DCC488;
  --red:         #B3382E;
  --danger:      #A31D1D;
  --steel:       #8C99A7;
  --muted:       #66707C;
  --ok:          #5F8468;
  --stroke:      rgba(233, 238, 244, 0.10);
  --stroke-hi:   rgba(233, 238, 244, 0.38);
  --radius:      4px;
  --radius-sm:   2px;
  --font-display: "Rajdhani", "Arial Narrow", sans-serif;
  --font-mono:   "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--signal);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* First-light glow + faint scanlines over near-black glass */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(195, 169, 106, 0.07), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(8, 19, 31, 0.9), transparent 70%),
    repeating-linear-gradient(0deg, rgba(233, 238, 244, 0.012) 0 1px, transparent 1px 3px),
    var(--bg);
}

a { color: var(--brass); text-decoration: none; }
a:hover { color: var(--brass-hi); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ---------- Top bar / nav ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--stroke);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--signal);
  white-space: nowrap;
}
.brand em { color: var(--brass); font-style: normal; }

.topnav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.topnav a {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--steel);
  padding: 4px 0;
}
.topnav a:hover { color: var(--signal); }
.topnav a[aria-current="page"] {
  color: var(--brass);
  border-bottom: 1px solid var(--brass);
}

/* ---------- Classified bar ---------- */

.classified-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(179, 56, 46, 0.55);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin-bottom: 20px;
  background:
    repeating-linear-gradient(-45deg,
      rgba(179, 56, 46, 0.16) 0 6px, transparent 6px 14px);
}
.classified-bar span {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--red);
  text-transform: uppercase;
  flex: 1;
  text-align: center;
}
.classified-bar::before,
.classified-bar::after {
  content: "";
  width: 7px; height: 7px;
  border: 1px solid rgba(179, 56, 46, 0.7);
  transform: rotate(45deg);
  flex: none;
}

/* ---------- Dossier card ---------- */

.card {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--steel);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--brass);
  transform: rotate(45deg);
  flex: none;
}
.card-title.red::before { background: var(--red); }

/* ---------- Type helpers ---------- */

.stamp {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brass);
}
.stamp.muted  { color: var(--muted); }
.stamp.red    { color: var(--red); }
.stamp.signal { color: var(--signal); }

.serial {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.big-number {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  color: #14100a;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent;
  color: var(--brass);
}
.btn.ghost:hover { background: rgba(195, 169, 106, 0.08); filter: none; }
.btn:disabled {
  border-color: var(--stroke);
  background: var(--card);
  color: var(--muted);
  cursor: default;
}

.small-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  background: none;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
}
.small-btn:disabled { color: var(--muted); cursor: default; }

/* ---------- Status board (shared by games) ---------- */

.status-board {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.status-board .left  { display: flex; flex-direction: column; gap: 3px; }
.status-board .right { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.status-line {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.status-line.watch  { color: var(--brass-hi); }
.status-line.act    { color: var(--signal); }
.status-line.danger { color: var(--red); font-weight: 700; }
.record-gap {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--brass-hi);
}

/* ---------- Signal Recall grid ---------- */

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 380px;
  margin: 24px auto;
}
.signal-tile {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
}
.signal-tile:disabled { cursor: default; }
.signal-grid.armed .signal-tile { border-color: var(--stroke-hi); }
.signal-tile.lit {
  background: linear-gradient(135deg, var(--brass-hi), var(--brass));
  border-color: rgba(220, 196, 136, 0.9);
  box-shadow: 0 0 22px rgba(195, 169, 106, 0.55);
  transform: scale(1.04);
}
.signal-tile.missed {
  background: linear-gradient(180deg, rgba(179, 56, 46, 0.45), rgba(179, 56, 46, 0.3));
  border-color: var(--red);
}

/* ---------- Kim's Game ---------- */

.kim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kim-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: var(--card-hi);
}
.kim-item .glyph {
  font-size: 26px;
  line-height: 1;
  filter: grayscale(1) brightness(1.5) contrast(0.9);
}
.kim-item .label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--steel);
  white-space: nowrap;
}
button.kim-item { cursor: pointer; background: var(--card); border-color: rgba(233,238,244,0.18); }
button.kim-item:disabled { cursor: default; }
button.kim-item.correct {
  border-color: var(--brass);
  box-shadow: 0 0 14px rgba(195, 169, 106, 0.4);
}
button.kim-item.correct .glyph { filter: grayscale(0.2) brightness(1.2); }
button.kim-item.wrong { border-color: var(--red); }

.lives {
  display: flex;
  gap: 5px;
}
.lives i {
  width: 9px; height: 9px;
  background: var(--brass);
  transform: rotate(45deg);
}
.lives i.spent { background: transparent; border: 1px solid var(--muted); }

.countdown {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--brass-hi);
  border: 1px solid var(--stroke-hi);
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Codebreaker ---------- */

.cipher-board {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-family: var(--font-mono);
}
.cipher-word { display: flex; gap: 3px; }
.cipher-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 17px;
  cursor: pointer;
  user-select: none;
}
.cipher-cell .guess {
  font-size: 15px;
  font-weight: 700;
  color: rgba(233, 238, 244, 0.85);
  min-height: 20px;
}
.cipher-cell.assigned .guess { color: var(--brass); }
.cipher-cell.locked  .guess { color: var(--ok); }
.cipher-cell .code {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.cipher-cell .bar {
  width: 14px; height: 1px;
  background: var(--stroke-hi);
}
.cipher-cell.selected .code { color: var(--brass-hi); }
.cipher-cell.selected .bar  { background: var(--brass); height: 2px; }
.cipher-cell.punct { cursor: default; }
.cipher-cell.punct .guess { color: var(--steel); }

.freq-strip {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.freq-item {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  padding: 0;
}
.freq-item .sym   { font-size: 14px; font-weight: 700; color: var(--signal); }
.freq-item.selected .sym { color: var(--brass-hi); }
.freq-item .count { font-size: 9px; color: var(--muted); }

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.keyboard .row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1;
  max-width: 52px;
  min-height: 38px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--signal);
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.key:disabled { color: var(--muted); cursor: default; }
.key.used { color: rgba(102, 112, 124, 0.5); }
.key.wide { max-width: 64px; color: var(--red); }

.hint-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* ---------- Overlay (game over / decrypted) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 7, 0.92);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.overlay-box {
  text-align: center;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.seal {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--brass);
  border: 2px solid var(--brass);
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  transform: rotate(-6deg);
  animation: stamp-slam 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.seal.red { color: var(--red); border-color: var(--red); }
.seal.ok  { color: var(--ok);  border-color: var(--ok); }
@keyframes stamp-slam {
  0%   { transform: rotate(-6deg) scale(2.2); opacity: 0; }
  60%  { transform: rotate(-6deg) scale(0.96); opacity: 1; }
  100% { transform: rotate(-6deg) scale(1); }
}

.overlay-score {
  font-family: var(--font-display);
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  color: var(--signal);
  font-variant-numeric: tabular-nums;
}
.overlay-quote {
  font-size: 17px;
  font-style: italic;
  color: var(--signal);
  line-height: 1.55;
}
.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 240px;
}

/* ---------- Index: game roster ---------- */

.hero {
  text-align: center;
  padding: 28px 0 8px;
}
.hero h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
}
.hero h1 em { color: var(--brass); font-style: normal; }
.hero p.sub {
  color: var(--steel);
  max-width: 520px;
  margin: 12px auto 0;
  font-size: 16px;
}

.roster { margin-top: 24px; }
a.op-card {
  display: block;
  color: inherit;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.op-card:hover {
  border-color: rgba(195, 169, 106, 0.5);
  transform: translateY(-1px);
}
.op-card .op-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.op-card h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.op-card .op-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--red);
  border: 1px solid rgba(179, 56, 46, 0.5);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.op-card p { color: var(--steel); font-size: 14px; }
.op-card .op-cta {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--brass);
}

/* ---------- Intel section (SEO copy) ---------- */

.intel {
  margin-top: 40px;
  border-top: 1px solid var(--stroke);
  padding-top: 24px;
}
.intel h2, .intel h3 {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 22px 0 8px;
  font-family: var(--font-mono);
  font-weight: 700;
}
.intel p, .intel li {
  color: var(--steel);
  font-size: 15px;
  line-height: 1.65;
}
.intel ul, .intel ol { padding-left: 22px; margin: 8px 0; }
.intel strong { color: var(--signal); font-weight: 600; }

/* ---------- App promo / footer ---------- */

.app-promo {
  margin-top: 36px;
  border: 1px solid rgba(195, 169, 106, 0.35);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  background:
    radial-gradient(80% 120% at 50% 0%, rgba(195, 169, 106, 0.08), transparent 70%),
    var(--card);
}
.app-promo h2 {
  font-size: 19px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.app-promo p {
  color: var(--steel);
  font-size: 14px;
  max-width: 460px;
  margin: 8px auto 14px;
}
.app-promo .stamp { display: block; margin-bottom: 10px; }

footer {
  margin-top: 40px;
  border-top: 1px solid var(--stroke);
  padding: 18px 0 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
footer .serial { text-align: left; }
footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
footer nav a {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}
footer nav a:hover { color: var(--steel); }

/* ---------- Decrypt-in animation for headings ---------- */

.decrypt { display: inline-block; }

/* ---------- Wide game layout ----------
   Game pages use .wrap.wide: a broader column with larger play elements,
   so the boards feel like instruments, not thumbnails. */

.wrap.wide { max-width: 860px; }

@media (min-width: 760px) {
  .wide .signal-grid { max-width: 560px; gap: 14px; }

  .wide .kim-grid { gap: 12px; }
  .wide .kim-item { padding: 18px 8px; gap: 10px; }
  .wide .kim-item .glyph { font-size: 42px; }
  .wide .kim-item .label { font-size: 11px; }
  .wide .countdown { width: 48px; height: 48px; font-size: 16px; }

  .wide .cipher-board { gap: 14px 20px; }
  .wide .cipher-cell { min-width: 22px; }
  .wide .cipher-cell .guess { font-size: 20px; min-height: 26px; }
  .wide .cipher-cell .code { font-size: 10px; }
  .wide .cipher-cell .bar { width: 18px; }
  .wide .freq-item .sym { font-size: 18px; }
  .wide .freq-item .count { font-size: 11px; }
  .wide .key { max-width: 66px; min-height: 46px; font-size: 16px; }
  .wide .key.wide { max-width: 84px; }

  .wide .big-number { font-size: 32px; }
  .wide .card { padding: 20px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 26px; }
  .overlay-score { font-size: 42px; }
  .key { min-height: 42px; }
}
