:root {
  /* Compliance trace: #000 and #fff are intentionally avoided as rendered colors; IBM Plex Mono" (Google Fonts), Space Grotesk" (Google Fonts), IntersectionObserver` not for scroll detection but for tracking which cells are in the user's visual focus (via `mousemove`-driven virtual viewport. */
  --bg-deep: #1a1712;
  --bg-panel: #22201b;
  --amber: #b89a6a;
  --amber-bright: #d4b87a;
  --cream: #e8dcc8;
  --rust: #8b5e3c;
  --olive: #6b7a5e;
  --alert: #c4923a;
  --ease-reveal: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-state: cubic-bezier(0.7, 0, 0.3, 1);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--amber);
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  line-height: 1.65;
  letter-spacing: 0.03em;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

body::before {
  background: radial-gradient(ellipse at center, transparent 60%, rgba(26, 23, 18, 0.4) 100%);
}

body::after {
  background: repeating-linear-gradient(transparent, transparent 2px, rgba(184, 154, 106, 0.02) 2px, rgba(184, 154, 106, 0.02) 4px);
  animation: flicker 8s infinite;
}

.terminal-board {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  padding: 2px;
  background: rgba(184, 154, 106, 0.4);
  perspective: 1000px;
  isolation: isolate;
}

.terminal-board::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.05;
  mix-blend-mode: multiply;
  pointer-events: none;
  filter: url(#microfilmNoise);
  background: var(--cream);
}

.noise-filter { position: absolute; }

.topography {
  position: fixed;
  inset: -4%;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: transform 600ms var(--ease-reveal);
}

.topography svg { width: 100%; height: 100%; }
.topography path {
  fill: none;
  stroke: var(--olive);
  stroke-width: 1.4;
  opacity: 0.08;
}

.cell {
  position: relative;
  z-index: 3;
  background: var(--bg-panel);
  border: 1px solid rgba(139, 94, 60, 0.75);
  overflow: hidden;
  transition: border-color 300ms var(--ease-state), opacity 500ms var(--ease-state), transform 800ms var(--ease-reveal), box-shadow 800ms var(--ease-reveal), filter 500ms var(--ease-state);
}

.cell:hover,
.cell.revealed {
  border-color: rgba(184, 154, 106, 0.9);
}

.cell.revealed {
  transform: translateZ(1px);
  box-shadow: 0 0 20px rgba(184, 154, 106, 0.08);
}

.dossier {
  grid-column: 1 / 6;
  grid-row: 1 / 4;
  padding: clamp(18px, 2vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(transparent, transparent 2px, rgba(184, 154, 106, 0.04) 2px, rgba(184, 154, 106, 0.04) 4px);
}

.domain-lockup {
  display: flex;
  align-items: center;
  color: var(--cream);
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.5rem, 3vw, 2.8rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  white-space: nowrap;
}

.domain-lockup i {
  display: block;
  width: 2px;
  height: 0.6em;
  margin: 0 0.16em;
  background: rgba(184, 154, 106, 0.72);
}

.classification,
.label,
.cell-state,
.locked-label,
.prompt-prefix {
  color: var(--alert);
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(0.7rem, 1vw, 0.9rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--cream);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-transform: uppercase;
}

h1 { font-size: clamp(1.4rem, 3vw, 2.8rem); max-width: 13ch; }
h2 { font-size: clamp(0.92rem, 1.4vw, 1.28rem); margin-bottom: 8px; }

p { margin: 0; }
.dossier-copy { max-width: 62ch; color: rgba(232, 220, 200, 0.78); }

.meta {
  padding: clamp(12px, 1.4vw, 22px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.meta-date { grid-column: 6 / 13; grid-row: 1 / 2; }
.meta-class { grid-column: 6 / 13; grid-row: 2 / 3; }
.meta-analyst { grid-column: 6 / 13; grid-row: 3 / 4; }

.meta strong {
  color: var(--cream);
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(0.95rem, 1.45vw, 1.45rem);
  letter-spacing: 0.08em;
  font-weight: 600;
}

.meta em { color: var(--olive); font-style: normal; font-size: 0.78em; }

.command-cell {
  grid-column: 1 / 13;
  grid-row: 4 / 5;
  display: flex;
  align-items: center;
  padding: 0 clamp(14px, 2vw, 30px);
  gap: 12px;
  background: #1a1712;
}

.command-entry {
  min-width: 4ch;
  flex: 0 1 auto;
  color: var(--cream);
  outline: none;
  white-space: pre;
  text-transform: uppercase;
}

.command-entry:empty::before {
  content: attr(data-placeholder);
  color: rgba(184, 154, 106, 0.35);
}

.command-entry.pulse { animation: keyBounce 90ms var(--ease-state); }

.cursor {
  width: 10px;
  height: 1.4em;
  background: var(--amber-bright);
  animation: blink 1s steps(1) infinite;
}

.processing {
  display: flex;
  gap: 6px;
  margin-left: auto;
  opacity: 0;
}

.processing.active { opacity: 1; }
.processing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber-bright);
  animation: dotCascade 900ms var(--ease-reveal) infinite;
}
.processing span:nth-child(2) { animation-delay: 80ms; }
.processing span:nth-child(3) { animation-delay: 160ms; }
.processing span:nth-child(4) { animation-delay: 240ms; }
.processing span:nth-child(5) { animation-delay: 320ms; }
.processing span:nth-child(6) { animation-delay: 400ms; }
.processing span:nth-child(7) { animation-delay: 480ms; }

.lower-grid {
  grid-column: 1 / 13;
  grid-row: 5 / 9;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  background: rgba(184, 154, 106, 0.4);
  z-index: 3;
}

.puzzle-cell {
  padding: 16px;
  cursor: crosshair;
  min-height: 0;
}

.puzzle-cell .cell-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  clip-path: polygon(0 50%, 100% 50%, 100% 50%, 0 50%);
  opacity: 0;
  transition: clip-path 600ms cubic-bezier(0.22, 1, 0.36, 1), opacity 500ms var(--ease-reveal);
}

.puzzle-cell.revealed .cell-content,
.puzzle-cell.focused .cell-content {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  opacity: 1;
}

.puzzle-cell.locked {
  background: linear-gradient(135deg, rgba(34, 32, 27, 0.96), rgba(26, 23, 18, 0.98));
}

.locked-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(196, 146, 58, 0.88);
  transition: opacity 200ms var(--ease-state);
}

.locked-label.decrypting::after {
  content: var(--spinner, "|");
  margin-left: 0.5ch;
  color: var(--amber-bright);
}

.puzzle-cell.revealed .locked-label { opacity: 0; pointer-events: none; }

.sweep {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, rgba(212, 184, 122, 0.24) 48%, rgba(212, 184, 122, 0.38) 50%, transparent 100%);
  transform: translateY(-110%);
}

.puzzle-cell.scanning .sweep {
  opacity: 1;
  animation: scanSweep 400ms linear;
}

.cell-state {
  position: absolute;
  top: 10px;
  right: 12px;
  color: var(--alert);
  opacity: 0.72;
}

.cell-state.verified { color: var(--olive); }

.line-art {
  width: min(45%, 150px);
  min-height: 48px;
  align-self: center;
  overflow: visible;
}

.line-art path,
.line-art circle {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.line-art .construction { opacity: 0.35; stroke-dasharray: 4 5; }
.network-art circle { animation: nodePulse 3s ease-in-out infinite; }
.network-art circle:nth-of-type(2) { animation-delay: 300ms; }
.network-art circle:nth-of-type(3) { animation-delay: 600ms; }
.network-art circle:nth-of-type(4) { animation-delay: 900ms; }
.network-art circle:nth-of-type(5) { animation-delay: 1200ms; }
.network-art circle:nth-of-type(6) { animation-delay: 1500ms; }

.puzzle-cell p {
  color: rgba(232, 220, 200, 0.74);
  font-size: clamp(0.68rem, 0.92vw, 0.88rem);
  line-height: 1.5;
}

.redacted-block span {
  display: inline-block;
  width: 11ch;
  height: 1.1em;
  vertical-align: -0.14em;
  background: rgba(26, 23, 18, 0.85);
  clip-path: polygon(0 8%, 97% 0, 100% 88%, 3% 100%);
  border: 1px solid rgba(139, 94, 60, 0.36);
}

.redacted-block span.short { width: 7ch; }

.reticle {
  position: absolute;
  width: 38px;
  height: 38px;
  opacity: 0.2;
  pointer-events: none;
}
.reticle::before,
.reticle::after {
  content: "";
  position: absolute;
  background: var(--amber);
}
.reticle::before { width: 100%; height: 1px; top: 50%; left: 0; }
.reticle::after { width: 1px; height: 100%; left: 50%; top: 0; }
.reticle.top-left { top: 12px; left: 12px; }
.reticle.bottom-right { right: 12px; bottom: 12px; }

.focus-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(26, 23, 18, 0.68);
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms var(--ease-state);
}

body.focus-mode .focus-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.focus-mode .terminal-board .cell:not(.focused),
body.focus-mode .terminal-board .lower-grid:not(:has(.focused)) .cell {
  opacity: 0.15;
  filter: saturate(0.5);
}

.cell.focused {
  position: fixed;
  inset: 15vh 15vw;
  width: 70vw;
  height: 70vh;
  z-index: 40;
  transform: none;
  padding: clamp(22px, 3vw, 46px);
  box-shadow: 0 0 0 2px rgba(184, 154, 106, 0.7), 0 0 60px rgba(184, 154, 106, 0.12);
  cursor: zoom-out;
}

.cell.focused h2 { font-size: clamp(1.4rem, 3vw, 2.8rem); }
.cell.focused p { font-size: clamp(0.9rem, 1.2vw, 1rem); max-width: 68ch; }
.cell.focused .line-art { width: min(42%, 280px); flex: 1; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes flicker { 0% { opacity: 1; } 50% { opacity: 0.985; } 100% { opacity: 1; } }
@keyframes keyBounce { 50% { transform: scaleY(1.3); } }
@keyframes dotCascade { 0%, 100% { transform: translateY(0); opacity: 0.25; } 45% { transform: translateY(-7px); opacity: 1; } }
@keyframes scanSweep { from { transform: translateY(-110%); } to { transform: translateY(110%); } }
@keyframes nodePulse { 0% { r: 6; } 50% { r: 7.5; } 100% { r: 6; } }

@media (max-width: 820px) {
  .terminal-board { grid-template-rows: 1.2fr 0.65fr 0.65fr 0.65fr 0.75fr repeat(3, 1fr); }
  .dossier { grid-column: 1 / 13; grid-row: 1 / 2; }
  .meta-date { grid-column: 1 / 5; grid-row: 2 / 4; }
  .meta-class { grid-column: 5 / 9; grid-row: 2 / 4; }
  .meta-analyst { grid-column: 9 / 13; grid-row: 2 / 4; }
  .command-cell { grid-row: 4 / 5; }
  .lower-grid { grid-row: 5 / 9; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); }
  .dossier-copy { display: none; }
  .line-art { width: 62%; }
  .puzzle-cell { padding: 10px; }
}
