/* ============================================
   Agentic AI as Cultural Technology
   Pixel library world, edutainment palette:
   panels are catalog cards, the HUD is a
   chunky menu bar, the dialogue sits on a
   brick wall. 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: #2a1a2e;
  --soft: #6a5a72;
  --paper: #fffaf0;
  --rule: rgba(47, 111, 208, 0.16);
  --red: #d8343a;
  --blue: #2f6fd0;
  --blue-deep: #1f4c9a;
  --yellow: #ffd23f;
  --green: #3aa655;
  --purple: #7b4fc9;
  --orange: #f28c28;
  --pink: #e2577a;
  --teal: #1fa3a3;
  --shadow: rgba(42, 26, 46, 0.55);
}

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

html, body {
  width: 100%; height: 100%;
  background: #1d1426;
  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 3px, rgba(0,0,0,0.07) 3px 4px);
  z-index: 5;
}

/* ---------- HUD: a chunky menu bar ---------- */

#hud {
  position: absolute; left: 0; top: 0; right: 0; height: 34px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: var(--blue);
  border-bottom: 3px solid var(--ink);
  box-shadow: inset 0 -3px 0 var(--blue-deep), inset 0 2px 0 #5a92e8;
  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(--yellow); min-width: 360px; text-shadow: 2px 2px 0 var(--ink); }
#hud-mark {
  width: 12px; height: 16px; position: relative; display: inline-block;
  background:
    linear-gradient(var(--paper), var(--paper)) 1px 0 / 3px 9px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 7px 0 / 3px 9px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 0 8px / 11px 8px no-repeat;
  animation: twitch 3s steps(1) 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: var(--yellow); color: var(--ink);
  border: 2px solid var(--ink); padding: 5px 7px; cursor: pointer;
  box-shadow: inset -2px -2px 0 #c99a10, inset 2px 2px 0 #fff2a8;
}
#hud-sections button.active { color: var(--paper); background: var(--red); box-shadow: inset -2px -2px 0 #8a1f24, inset 2px 2px 0 #f07a7e; }
#hud-sections button:hover { transform: translateY(-1px); }
#hud-right { display: flex; gap: 12px; align-items: center; min-width: 140px; justify-content: flex-end; }
#hud-counter { color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }

/* ---------- content panels: catalog cards ---------- */

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

.panel {
  position: absolute;
  background:
    linear-gradient(var(--red), var(--red)) 0 46px / 100% 2px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 32px, var(--rule) 32px 34px),
    var(--paper);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: 8px 8px 0 var(--shadow);
  padding: 16px 26px 22px;
  cursor: default;
  animation: popin 0.42s steps(7) both;
}
.panel:not(.media)::after {
  /* the catalog card's rod hole */
  content: ''; position: absolute; left: 50%; bottom: 7px; width: 14px; height: 14px; margin-left: -7px;
  border-radius: 50%; background: rgba(42, 26, 46, 0.12); border: 2px solid rgba(42, 26, 46, 0.25);
}
.panel[data-i="1"] { animation-delay: 0.12s; }
.panel[data-i="2"] { animation-delay: 0.24s; }
.panel.out { animation: popout 0.18s steps(4) both; }

.tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px; letter-spacing: 1px;
  color: var(--red);
  height: 26px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.tag .right { color: var(--soft); text-align: right; }

.panel h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px; line-height: 1.45;
  color: var(--blue);
  margin-bottom: 12px;
}
.panel p, .panel li { font-size: 28px; line-height: 1.12; color: var(--ink); }
.panel p + p { margin-top: 10px; }
.panel em { color: var(--red); font-style: italic; }
.panel strong { color: var(--blue-deep); }
.panel a { color: var(--blue); }
.panel .small { font-size: 23px; color: var(--soft); }

/* title */
.panel.title {
  padding: 28px 34px 34px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 32px, var(--rule) 32px 34px),
    var(--paper);
}
.panel.title .kicker {
  display: inline-block; font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--ink);
  background: var(--yellow); border: 3px solid var(--ink); padding: 8px 12px; letter-spacing: 2px;
}
.panel.title h1 {
  font-family: 'Press Start 2P', monospace; font-size: 34px; line-height: 1.35;
  color: var(--red); margin: 20px 0 12px;
  text-shadow: 3px 3px 0 var(--ink);
}
.panel.title .sub { font-size: 34px; color: var(--blue); }
.panel.title .byline { margin-top: 18px; font-size: 26px; color: var(--soft); line-height: 1.15; }
.panel.title .byline strong { color: var(--ink); }
.panel.title .start {
  margin-top: 20px; font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--green);
  animation: blink 1.2s steps(2) infinite;
}

/* quote */
.panel.quote blockquote { font-size: 34px; line-height: 1.1; color: var(--ink); }
.panel.quote blockquote::before { content: '\201C'; color: var(--red); margin-right: 4px; }
.panel.quote blockquote::after { content: '\201D'; color: var(--red); margin-left: 2px; }
.panel.quote cite { display: block; margin-top: 14px; font-style: normal; font-size: 23px; color: var(--soft); }
.panel.quote .note { margin-top: 14px; padding-top: 10px; border-top: 2px dashed rgba(42, 26, 46, 0.2); }

/* statement: an unquoted claim set large */
.panel p.statement { font-size: 35px; line-height: 1.1; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2px dashed rgba(42, 26, 46, 0.2); }

.panel p.statement.solo { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }

/* list */
.panel ul { list-style: none; }
.panel ul li { position: relative; padding-left: 26px; margin: 6px 0; }
.panel ul li::before { content: '\25B8'; position: absolute; left: 2px; color: var(--red); }

/* cards */
.cards { display: grid; gap: 14px; }
.card { border: 3px solid var(--ink); border-radius: 6px; padding: 10px 14px 12px; background: #fff; box-shadow: 4px 4px 0 rgba(42, 26, 46, 0.25); }
.card .name { font-family: 'Press Start 2P', monospace; font-size: 12px; margin-bottom: 6px; }
.card .ask { font-size: 23px; color: var(--soft); margin-bottom: 4px; }
.card p { font-size: 25px; line-height: 1.06; }
.card.red { border-top: 10px solid var(--red); } .card.red .name { color: var(--red); }
.card.blue { border-top: 10px solid var(--blue); } .card.blue .name { color: var(--blue); }
.card.green { border-top: 10px solid var(--green); } .card.green .name { color: var(--green); }
.card.purple { border-top: 10px solid var(--purple); } .card.purple .name { color: var(--purple); }

/* stacked layers */
.stack { display: grid; gap: 8px; }
.layer {
  display: grid; grid-template-columns: 190px 1fr; align-items: center; gap: 16px;
  border: 3px solid var(--ink); border-radius: 6px; padding: 10px 14px; background: #fff;
}
.layer .name { font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--paper); padding: 10px; text-align: center; border: 2px solid var(--ink); }
.layer p { font-size: 26px; line-height: 1.06; }
.layer.harness { margin: 0; } .layer.harness .name { background: var(--green); }
.layer.reasoning { margin: 0 34px; } .layer.reasoning .name { background: var(--purple); }
.layer.model { margin: 0 68px; } .layer.model .name { background: var(--blue); }

/* game menu: press a number to play a game */
.panel.menu { background: #120c1a; color: var(--paper); border-color: var(--ink); }
.panel.menu::after { display: none; }
.menu-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.menu-head .ears {
  width: 24px; height: 34px; display: inline-block;
  background:
    linear-gradient(var(--paper), var(--paper)) 3px 0 / 6px 20px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 15px 0 / 6px 20px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 5px 3px / 2px 14px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 17px 3px / 2px 14px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 0 18px / 24px 16px no-repeat;
  animation: twitch 2.4s steps(1) infinite;
}
.panel.menu h2 { color: var(--paper); font-size: 22px; margin: 0; }
.menu-sub { text-align: center; font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--yellow); margin: 12px 0 18px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.game { border: 4px solid var(--teal); padding: 12px 14px 16px; cursor: pointer; transition: transform 0.1s steps(2); }
.game.red { border-color: var(--red); } .game.yellow { border-color: var(--yellow); } .game.green { border-color: var(--green); }
.game .num { font-family: 'Press Start 2P', monospace; font-size: 30px; color: var(--paper); }
.game .gname { font-family: 'Press Start 2P', monospace; font-size: 13px; line-height: 1.5; margin: 8px 0 10px; color: var(--yellow); }
.game p { font-size: 25px; line-height: 1.06; color: #e8e0f0; }
.game:hover { transform: translateY(-2px); }
.game.chosen { background: rgba(255, 210, 63, 0.14); animation: chosen 0.5s steps(2) 3; }
.menu-foot { margin-top: 16px; text-align: center; font-size: 24px; color: #c8bcd8; }
.menu-foot a { color: var(--yellow); }

/* media: image, video and embed */
.panel.media { padding: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); }
.panel.media .bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 14px; background: var(--blue); border-bottom: 3px solid var(--ink);
  font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--yellow); line-height: 1.4;
  text-shadow: 1px 1px 0 var(--ink);
}
.panel.media .bar .live { color: #ff8a8e; animation: blink 1.4s steps(2) infinite; }
.panel.media .bar a { color: var(--paper); text-decoration: none; white-space: nowrap; }
.panel.media .screen { flex: 1; position: relative; background: #fff; overflow: hidden; }
.panel.media .screen img, .panel.media .screen video { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.panel.media .screen video { background: #120c1a; }
.panel.media .screen.pixel img { image-rendering: pixelated; background: #120c1a; }
.panel.media .screen iframe { position: absolute; left: 0; top: 0; border: 0; background: #fff; transform-origin: 0 0; }
.panel.media .caption { padding: 8px 14px 10px; font-size: 22px; color: var(--ink); line-height: 1.05; border-top: 3px solid var(--ink); background: var(--paper); }

/* ---------- dialogue: a cream box on a brick wall ---------- */

#dialogue {
  position: absolute; left: 0; top: 560px; width: 1280px; height: 160px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 18px, #7a1f22 18px 20px),
    repeating-linear-gradient(to right, transparent 0 38px, #7a1f22 38px 40px) 0 0 / 100% 20px,
    repeating-linear-gradient(to right, transparent 0 18px, #7a1f22 18px 20px, transparent 20px 40px) 0 20px / 100% 20px,
    #b8383a;
  border-top: 4px solid var(--ink);
  display: grid; grid-template-columns: 130px 1fr 96px; align-items: stretch; gap: 10px;
  padding: 12px 14px;
}
#speaker {
  align-self: start;
  font-family: 'Press Start 2P', monospace; font-size: 10px; color: var(--ink);
  background: var(--yellow); border: 3px solid var(--ink); padding: 8px 6px; text-align: center;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.35);
}
#dialogue-text {
  font-size: 28px; line-height: 1.05; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 6px;
  padding: 6px 14px; box-shadow: 4px 4px 0 rgba(0,0,0,0.35);
  overflow: hidden;
}
#dialogue-text a { color: var(--blue); text-decoration: underline; text-underline-offset: 4px; }
#dialogue-text a:hover { color: var(--red); }
#dialogue-text.typing::after { content: '\2588'; color: var(--blue); animation: blink 0.6s steps(2) infinite; margin-left: 2px; }
#dialogue-controls { display: flex; gap: 8px; justify-content: flex-end; align-items: start; }
#dialogue-controls button {
  font-size: 14px; width: 40px; height: 36px; cursor: pointer;
  background: var(--yellow); color: var(--ink); border: 3px solid var(--ink);
  box-shadow: inset -3px -3px 0 #c99a10, 3px 3px 0 rgba(0,0,0,0.35);
}
#dialogue-controls button:hover { background: #fff2a8; }

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

@property --r { syntax: '<length>'; inherits: false; initial-value: 1400px; }

#fx { position: absolute; inset: 0; z-index: 30; pointer-events: none; --cx: 160px; --cy: 440px; }
/* a cartoon iris: closes on the rabbit, opens on the next room */
#fx.iris {
  background: radial-gradient(circle at var(--cx) var(--cy), transparent var(--r), #120c1a calc(var(--r) + 1px));
  animation: iris 0.84s steps(14) both;
}
#fx.wipe { animation: wipe 0.84s steps(10) both; }

@keyframes iris { 0% { --r: 1400px; } 46%, 54% { --r: 0px; } 100% { --r: 1400px; } }
@keyframes wipe {
  0% { background: transparent; }
  25% { background: repeating-linear-gradient(90deg, var(--red) 0 80px, var(--yellow) 80px 160px, var(--blue) 160px 240px, var(--green) 240px 320px); transform: translateX(-60%); }
  50% { background: repeating-linear-gradient(90deg, var(--red) 0 80px, var(--yellow) 80px 160px, var(--blue) 160px 240px, var(--green) 240px 320px); transform: none; }
  75% { background: repeating-linear-gradient(90deg, var(--red) 0 80px, var(--yellow) 80px 160px, var(--blue) 160px 240px, var(--green) 240px 320px); transform: translateX(60%); }
  100% { background: transparent; }
}
@keyframes popin {
  0% { opacity: 0; transform: translateY(18px) scale(0.92); }
  60% { opacity: 1; transform: translateY(-4px) scale(1.01); }
  100% { opacity: 1; transform: none; }
}
@keyframes popout { to { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes twitch { 0%, 90% { transform: none; } 92% { transform: translateY(-2px); } 96% { transform: none; } }
@keyframes chosen { 50% { border-color: var(--paper); } }

#focus-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--ink);
  background: var(--yellow); border: 2px solid var(--ink); 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(--yellow);
  background: rgba(0,0,0,0.8); padding: 6px 8px;
}

/* ?still: no animation, for screenshots and PDF export */
.still *, .still *::before, .still *::after { animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .panel, #fx.iris, #fx.wipe { animation-duration: 0.01s !important; }
  .panel.title .start, #hud-mark, .menu-head .ears { animation: none; }
}
