/* ============================================
   Teaching AI — pixel world, GitS palette
   Stage is authored at 1280x720 and scaled
   ============================================ */

@font-face {
  font-family: 'Press Start 2P';
  src: url('../fonts/PressStart2P.woff2') format('woff2');
  font-display: block;
}
@font-face {
  font-family: 'VT323';
  src: url('../fonts/VT323.woff2') format('woff2');
  font-display: block;
}

:root {
  --ink: #d9fff4;
  --dim: #7fb5aa;
  --teal: #3de0c8;
  --teal-deep: #0d3b3a;
  --magenta: #ff4fa0;
  --amber: #ffb347;
  --violet: #a58cff;
  --panel: rgba(3, 14, 18, 0.88);
  --panel-edge: rgba(61, 224, 200, 0.75);
  --ghosts: #6ff3ff;
  --shells: #ffb347;
  --puppets: #ff4fa0;
  --coda: #a58cff;
}

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

html, body {
  width: 100%; height: 100%;
  background: #020406;
  overflow: hidden;
  color: var(--ink);
  font-family: 'VT323', monospace;
}

#stage {
  position: absolute;
  width: 1280px; height: 720px;
  transform-origin: 0 0;
  background: #000;
}

/* ---------- viewport ---------- */

#viewport {
  position: absolute; left: 0; top: 0;
  width: 1280px; height: 560px;
  overflow: hidden;
  cursor: pointer;
}

#world {
  position: absolute; inset: 0;
  width: 1280px; height: 560px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.16) 2px 4px);
  mix-blend-mode: multiply;
  z-index: 5;
}

/* ---------- HUD ---------- */

#hud {
  position: absolute; left: 0; top: 0; right: 0; height: 34px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0.55));
  border-bottom: 2px solid rgba(61,224,200,0.35);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px; letter-spacing: 1px;
  z-index: 20;
  cursor: default;
}
#hud-left { display: flex; gap: 10px; align-items: center; color: var(--teal); min-width: 330px; }
#hud-mark { color: var(--magenta); animation: pulse 2.4s infinite; }
#hud-section { white-space: nowrap; }
#hud-sections { display: flex; gap: 6px; }
#hud-sections button {
  font-family: 'Press Start 2P', monospace; font-size: 8px;
  background: transparent; color: var(--dim);
  border: 1px solid rgba(127,181,170,0.35); padding: 5px 7px; cursor: pointer;
}
#hud-sections button.active { color: #001; background: var(--teal); border-color: var(--teal); }
#hud-sections button:hover { border-color: var(--teal); color: var(--ink); }
#hud-sections button.active:hover { color: #001; }
#hud-right { display: flex; gap: 12px; align-items: center; min-width: 330px; justify-content: flex-end; }
#hud-counter { color: var(--dim); }
#hud-construction {
  color: #141014; background: repeating-linear-gradient(45deg, #f2c230 0 8px, #ffd95a 8px 16px);
  padding: 5px 8px; font-size: 8px; animation: blink 1.6s steps(2) infinite;
}

/* ---------- content panels ---------- */

#content { position: absolute; inset: 34px 0 0 0; z-index: 10; pointer-events: none; }
#content > * { pointer-events: auto; }

.panel {
  position: absolute;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.8), 0 0 24px rgba(61,224,200,0.18), inset 0 0 40px rgba(61,224,200,0.05);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  padding: 20px 26px 18px;
  cursor: default;
  animation: materialize 0.45s steps(9) both;
}
.panel.out { animation: dematerialize 0.18s steps(4) both; }

.tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px; letter-spacing: 1px;
  color: var(--magenta);
  margin-bottom: 12px;
  display: flex; justify-content: space-between; gap: 12px;
}
.tag .right { color: var(--dim); }

.panel h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 19px; line-height: 1.45;
  color: var(--teal);
  margin-bottom: 14px;
  text-shadow: 0 0 10px rgba(61,224,200,0.35);
}
.panel p, .panel li { font-size: 27px; line-height: 1.12; color: var(--ink); }
.panel p + p { margin-top: 10px; }
.panel em { color: var(--amber); font-style: normal; }
.panel strong { color: var(--teal); font-weight: normal; }
.panel a { color: var(--ghosts); }
.panel .small { font-size: 22px; color: var(--dim); }

/* title */
.panel.title { text-align: left; padding: 30px 34px; }
.panel.title .kicker { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--magenta); letter-spacing: 2px; }
.panel.title h1 {
  font-family: 'Press Start 2P', monospace; font-size: 30px; line-height: 1.4;
  color: var(--ink); margin: 18px 0 12px;
  text-shadow: 2px 2px 0 #3a0f2a, 0 0 18px rgba(255,79,160,0.4);
}
.panel.title .sub { font-size: 30px; color: var(--teal); }
.panel.title .byline { margin-top: 18px; font-size: 25px; color: var(--dim); line-height: 1.15; }
.panel.title .byline strong { color: var(--ink); }
.panel.title .start {
  margin-top: 18px; font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--amber);
  animation: blink 1.2s steps(2) infinite;
}

/* quote */
.panel.quote blockquote { font-size: 33px; line-height: 1.12; color: var(--ink); }
.panel.quote blockquote::before { content: '\201C'; color: var(--magenta); margin-right: 4px; }
.panel.quote blockquote::after { content: '\201D'; color: var(--magenta); margin-left: 2px; }
.panel.quote cite { display: block; margin-top: 14px; font-style: normal; font-size: 22px; color: var(--dim); }
.panel.quote .note { margin-top: 12px; }

/* list */
.panel ul { list-style: none; }
.panel ul li { position: relative; padding-left: 24px; margin: 6px 0; }
.panel ul li::before { content: '\25B8'; position: absolute; left: 2px; color: var(--teal); }
.panel ol { list-style: none; counter-reset: n; }
.panel ol li { counter-increment: n; position: relative; padding-left: 44px; margin: 7px 0; }
.panel ol li::before {
  content: counter(n, decimal-leading-zero); position: absolute; left: 0; top: 3px;
  font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--magenta);
}

/* stat grid */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; }
.stat { border-left: 3px solid var(--teal); padding: 4px 0 4px 12px; }
.stat .k { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--magenta); letter-spacing: 1px; margin-bottom: 6px; }
.stat .v { font-size: 26px; line-height: 1.08; }
.stat.flag { border-left-color: var(--amber); }
.stat.flag .v { color: var(--amber); }

/* unit cards */
.cards { display: grid; gap: 12px; }
.card { border: 2px solid; padding: 12px 14px; background: rgba(0,0,0,0.35); }
.card .name { font-family: 'Press Start 2P', monospace; font-size: 12px; margin-bottom: 4px; }
.card .weeks { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--dim); margin-bottom: 8px; }
.card p { font-size: 23px; line-height: 1.08; }
.card.ghosts { border-color: var(--ghosts); } .card.ghosts .name { color: var(--ghosts); }
.card.shells { border-color: var(--shells); } .card.shells .name { color: var(--shells); }
.card.puppets { border-color: var(--puppets); } .card.puppets .name { color: var(--puppets); }
.card.coda { border-color: var(--coda); } .card.coda .name { color: var(--coda); }

/* week table */
table.weeks { width: 100%; border-collapse: collapse; font-size: 21px; }
table.weeks th {
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--magenta);
  text-align: left; padding: 0 6px 6px; border-bottom: 1px solid rgba(61,224,200,0.4);
}
table.weeks td { padding: 2px 6px; line-height: 1.02; vertical-align: top; border-bottom: 1px solid rgba(61,224,200,0.1); }
table.weeks td.wk { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--dim); padding-top: 6px; white-space: nowrap; }
table.weeks td.unit { width: 6px; padding: 0; }
table.weeks tr.ghosts td.unit { background: var(--ghosts); }
table.weeks tr.shells td.unit { background: var(--shells); }
table.weeks tr.puppets td.unit { background: var(--puppets); }
table.weeks tr.coda td.unit { background: var(--coda); }
table.weeks td.tool { color: var(--dim); }

/* compare */
.compare { display: grid; grid-template-columns: 170px 1fr 1fr; gap: 0; font-size: 22px; }
.compare > div { padding: 5px 8px; border-bottom: 1px solid rgba(61,224,200,0.12); line-height: 1.04; }
.compare .h { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--magenta); border-bottom: 1px solid rgba(61,224,200,0.45); padding-bottom: 8px; }
.compare .k { font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--dim); padding-top: 9px; }
.compare .old { color: var(--dim); }
.compare .new { color: var(--ink); }
.compare .new::before { content: '\25B8 '; color: var(--teal); }

/* grade bar */
.gradebar { display: flex; height: 64px; margin: 8px 0 16px; border: 2px solid rgba(61,224,200,0.5); }
.gradebar div {
  display: flex; flex-direction: column; justify-content: center; padding: 0 10px;
  font-family: 'Press Start 2P', monospace; font-size: 9px; color: #031012; overflow: hidden; white-space: nowrap;
}
.gradebar div b { font-size: 16px; }
.gradebar .a { background: var(--violet); }
.gradebar .b { background: repeating-linear-gradient(90deg, var(--teal) 0 calc(100%/13 - 2px), #0a2a28 calc(100%/13 - 2px) calc(100%/13)); }
.gradebar .c { background: var(--amber); }
.gradebar.old { height: 26px; opacity: 0.7; margin-top: 0; }
.gradebar.old div { font-size: 8px; }

/* lineage strip */
.lineage { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; align-items: center; }
.lineage .who { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--magenta); }
.lineage .chain { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 22px; }
.lineage .chain span { border: 1px solid rgba(61,224,200,0.45); padding: 1px 8px; background: rgba(0,0,0,0.4); }
.lineage .chain span.gone { text-decoration: line-through; color: var(--dim); border-style: dashed; }
.lineage .chain span.now { border-color: var(--amber); color: var(--amber); }
.lineage .chain i { color: var(--dim); font-style: normal; }

/* media: image and embed */
.panel.media { padding: 0; display: flex; flex-direction: column; }
.panel.media .bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 16px; background: rgba(61,224,200,0.12); border-bottom: 2px solid rgba(61,224,200,0.5);
  font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--teal);
}
.panel.media .bar .live { color: var(--magenta); animation: blink 1.4s steps(2) infinite; }
.panel.media .bar a { color: var(--amber); text-decoration: none; }
.panel.media .screen { flex: 1; position: relative; background: #000; overflow: hidden; }
.panel.media .screen img, .panel.media .screen video { width: 100%; height: 100%; object-fit: contain; display: block; background: #050809; }
.panel.media .screen iframe { position: absolute; left: 0; top: 0; border: 0; background: #fff; transform-origin: 0 0; }
.panel.media .caption { padding: 8px 16px 10px; font-size: 21px; color: var(--dim); line-height: 1.05; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; height: 100%; }

/* student voices */
.voices { display: grid; gap: 14px; }
.voice { border-left: 3px solid var(--magenta); padding: 2px 0 2px 14px; }
.voice blockquote { font-size: 25px; line-height: 1.08; color: var(--ink); }
.voice blockquote::before { content: '\201C'; color: var(--magenta); }
.voice blockquote::after { content: '\201D'; color: var(--magenta); }
.voice figcaption { margin-top: 4px; font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--dim); letter-spacing: 1px; }

/* placeholder */
.panel.placeholder { border-style: dashed; text-align: center; }
.panel.placeholder .glyph { font-family: 'Press Start 2P', monospace; font-size: 42px; color: var(--amber); margin: 10px 0 18px; animation: blink 1.8s steps(2) infinite; }

/* ---------- dialogue ---------- */

#dialogue {
  position: absolute; left: 0; top: 560px; width: 1280px; height: 160px;
  background: linear-gradient(to bottom, #04090b, #010304);
  border-top: 3px solid var(--teal);
  box-shadow: inset 0 8px 20px rgba(61,224,200,0.08);
  display: grid; grid-template-columns: 150px 1fr 90px; align-items: start;
  padding: 16px 20px;
}
#speaker {
  font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--magenta);
  padding-top: 8px; letter-spacing: 1px;
}
#dialogue-text { font-size: 29px; line-height: 1.08; color: var(--ink); min-height: 120px; }
#dialogue-text a { color: var(--teal); text-decoration: underline; text-underline-offset: 4px; }
#dialogue-text a:hover { color: var(--magenta); }
#dialogue-text.typing::after { content: '\2588'; color: var(--teal); animation: blink 0.6s steps(2) infinite; margin-left: 2px; }
#dialogue-controls { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
#dialogue-controls button {
  font-size: 14px; width: 36px; height: 32px; cursor: pointer;
  background: transparent; color: var(--teal); border: 2px solid rgba(61,224,200,0.5);
}
#dialogue-controls button:hover { background: var(--teal); color: #001; }

/* ---------- transitions ---------- */

#fx { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#fx.fade { animation: fxfade 0.7s steps(8) both; background: #000; }
#fx.glitch { animation: fxglitch 0.55s steps(6) both; }
#fx.dive { animation: fxdive 0.9s steps(12) both; }

@keyframes fxfade { 0%, 100% { opacity: 0; } 45%, 55% { opacity: 1; } }
@keyframes fxglitch {
  0% { background: transparent; }
  20% { background: repeating-linear-gradient(to bottom, rgba(255,79,160,0.5) 0 6px, transparent 6px 22px, rgba(61,224,200,0.5) 22px 26px, transparent 26px 48px); transform: translateX(-10px); }
  40% { background: #000; transform: translateX(8px); }
  60% { background: repeating-linear-gradient(to bottom, rgba(61,224,200,0.45) 0 4px, transparent 4px 30px); transform: translateX(-4px); }
  100% { background: transparent; transform: none; }
}
@keyframes fxdive {
  0% { background: transparent; }
  30% { background: radial-gradient(circle at 50% 55%, rgba(61,255,138,0.0) 0 10%, rgba(1,8,4,0.95) 40%); }
  55% { background: repeating-linear-gradient(to right, #031a0d 0 6px, #0b4a2c 6px 8px), #031a0d; }
  100% { background: transparent; }
}
@keyframes materialize {
  0% { opacity: 0; clip-path: polygon(0 0, 100% 0, 100% 0, 0 0); filter: brightness(2.2) hue-rotate(40deg); }
  60% { opacity: 1; filter: brightness(1.4); }
  100% { opacity: 1; filter: none; }
}
@keyframes dematerialize { to { opacity: 0; transform: translateX(6px); filter: brightness(2); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes pulse { 50% { opacity: 0.4; } }

#focus-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: #001;
  background: var(--amber); padding: 6px 10px; z-index: 25; pointer-events: none;
}

.hidden { display: none !important; }

#debug {
  position: absolute; right: 8px; bottom: 168px; z-index: 40;
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--amber);
  background: rgba(0,0,0,0.8); padding: 6px 8px;
}

@media (prefers-reduced-motion: reduce) {
  .panel, #fx.fade, #fx.glitch, #fx.dive { animation-duration: 0.01s !important; }
  #hud-construction, .panel.title .start, #hud-mark { animation: none; }
}
