/* ESPER: the page is the machine. A big, worn, adapted piece of 80s hardware (all CSS, no film assets). */
:root {
  --room: #07090b;
  --case: #3a4036;
  --case-dark: #262b24;
  --case-edge: #545c4e;
  --metal: #b9bdb3;
  --crt: #cfe6ff;
  --crt-glow: rgba(70, 150, 255, 0.75);
  --amber: #ffb347;
  --amber-glow: rgba(255, 150, 40, 0.7);
  --alert: #ff5a5a;
  --dim: #8d9a86;
  --font: "VT323", ui-monospace, Menlo, monospace;
  --label: "Share Tech Mono", ui-monospace, Menlo, monospace;
  /* grime: SVG noise, generated inline */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #151b22, var(--room) 65%);
  color: var(--crt);
  font-family: var(--font);
  font-size: 20px;
  padding: 16px;
}

/* ---------- the case ---------- */
.machine {
  position: relative;
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 30px 22px;
  border-radius: 18px;
  background:
    var(--noise),
    linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.035) 41%, transparent 43%),  /* scratch */
    linear-gradient(28deg, transparent 70%, rgba(0, 0, 0, 0.12) 71%, transparent 73%),          /* scratch */
    radial-gradient(ellipse at 20% 110%, rgba(20, 16, 8, 0.55), transparent 55%),              /* hand wear */
    linear-gradient(180deg, var(--case-edge), var(--case) 6%, var(--case) 88%, var(--case-dark));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -4px 0 rgba(0, 0, 0, 0.45),
    0 30px 60px rgba(0, 0, 0, 0.7),
    0 0 0 2px #1a1d18;
}

.screw {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d8dbd2, #6d7266 60%, #34382f);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}
.screw::after { content: ""; position: absolute; inset: 6px 2px; background: #2c3028; transform: rotate(35deg); }
.screw.tl { top: 10px; left: 10px; } .screw.tr { top: 10px; right: 10px; }
.screw.bl { bottom: 10px; left: 10px; } .screw.br { bottom: 10px; right: 10px; }

/* ---------- top: brand plate + photo cartridge ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.plate {
  padding: 8px 20px 6px;
  border-radius: 4px;
  background: linear-gradient(180deg, #d4d7cf, #9da196 55%, #c3c6bd);
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 #6b6f65, 0 2px 3px rgba(0, 0, 0, 0.6);
  color: #2b2f28;
}
.plate h1 {
  margin: 0;
  font-family: var(--label);
  font-size: 34px;
  letter-spacing: 0.45em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 -1px 0 rgba(0, 0, 0, 0.35);  /* engraved */
}
.plate p { margin: 0; font-family: var(--label); font-size: 12px; letter-spacing: 0.18em; }
.plate b { color: #7a1f1f; }

.cartridge { display: flex; gap: 8px; align-items: center; }

/* Tool switcher next to the brand plate: ESPER / V-K, with a label on hover */
.tools { display: flex; gap: 10px; margin-right: auto; }
.key.tool { position: relative; padding: 10px 16px 12px; font-size: 14px; }
.key.tool.active {
  background: linear-gradient(180deg, #ffd08a, #e6a24a);
  box-shadow: 0 5px 0 #9a6420, 0 7px 8px rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 170, 60, 0.45), inset 0 1px 0 #fff3dd;
}
.key.tool::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 4px;
  font: 18px var(--font);
  letter-spacing: 0.05em;
  color: var(--amber);
  background: #0d0904;
  box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.5), 0 6px 14px rgba(0, 0, 0, 0.7);
  text-shadow: 0 0 6px var(--amber-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.key.tool:hover::after, .key.tool:focus-visible::after { opacity: 1; }
.cartridge select {
  font: 22px var(--font);
  color: var(--amber);
  background: #111410;
  border: 2px solid #1b1e19;
  border-radius: 4px;
  padding: 4px 10px;
  box-shadow: inset 0 2px 6px #000;
  text-shadow: 0 0 6px var(--amber-glow);
}

/* ---------- deck: monitor + side panel ---------- */
.deck { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 20px; }
.deck > * { min-width: 0; }  /* the 1200 px canvas must be allowed to shrink */

.bay {
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1f231d, #2b3027);
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.08);
}

.screen {
  position: relative;
  border-radius: 26px / 22px;  /* CRT tube corners */
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 3px #0c0e0b, 0 0 25px rgba(60, 130, 255, 0.25);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  transition: filter 0.6s;
}
/* Blue-grey monochrome of the scanned photo; "mejorar" reveals the real colour */
canvas.tinted { filter: grayscale(0.8) sepia(0.35) hue-rotate(170deg) saturate(1.6) contrast(1.08) brightness(0.95); }

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.24) 0 1px, transparent 1px 3px);
  animation: flicker 4s infinite steps(1);
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 0.9; } 48% { opacity: 1; } }

.glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 30% 12%, rgba(255, 255, 255, 0.10), transparent 40%),  /* reflection */
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);    /* bulge vignette */
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8);
}

/* ---------- LCD readout: amber digits over ghost segments ---------- */
.lcd {
  margin-top: 14px;
  padding: 8px 14px;
  border-radius: 6px;
  background: linear-gradient(180deg, #120c05, #1c1307);
  box-shadow: inset 0 2px 8px #000, 0 1px 0 rgba(255, 255, 255, 0.06);
}
.lcd-line { position: relative; font-size: clamp(15px, 2.4vw, 30px); letter-spacing: 0.06em; white-space: pre; overflow: hidden; }
.lcd-line .ghost { position: absolute; inset: 0; color: rgba(255, 179, 71, 0.08); }
.lcd-line .lit { position: relative; color: var(--amber); text-shadow: 0 0 8px var(--amber-glow); }

.detection {
  min-height: 1.3em;
  margin: 4px 0 0;
  font-size: 24px;
  color: #ffd0c8;
  text-shadow: 0 0 10px rgba(255, 60, 60, 0.85);
}
.detection.on::before { content: "\25B6  "; color: var(--alert); }

/* ---------- side panel: vents, LEDs, cryogenic gauge ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #30352d, #252922);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  font-family: var(--label);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--metal);
}

.vents {
  height: 56px;
  border-radius: 4px;
  background: repeating-linear-gradient(to bottom, #0b0d0a 0 5px, #3d4339 5px 9px);
  box-shadow: inset 0 1px 3px #000;
}

.leds { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.leds li { display: flex; align-items: center; gap: 10px; }

.led {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #1a1d18;
  box-shadow: inset 0 1px 2px #000, 0 0 0 2px #121410;
}
.led.green.on { background: #5dff7a; box-shadow: 0 0 10px #3cff5f, 0 0 0 2px #121410; }
.led.amber.on { background: #ffb347; box-shadow: 0 0 10px #ff9b1a, 0 0 0 2px #121410; }
.led.blue.on { background: #7fc4ff; box-shadow: 0 0 10px #3f9dff, 0 0 0 2px #121410; }
.led.blink { animation: blink 0.5s infinite steps(1); }
@keyframes blink { 50% { opacity: 0.25; } }

.cryo { text-align: center; }
.gauge {
  position: relative;
  width: 34px;
  height: 120px;
  margin: 0 auto 8px;
  border-radius: 17px;
  background: #0d1014;
  box-shadow: inset 0 2px 6px #000, 0 0 0 3px #1a1d18;
  overflow: hidden;
}
#cryo-level {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(180deg, #d9f1ff, #3f9dff);
  box-shadow: 0 0 14px #3f9dff;
  transition: height 1.2s ease, background 1.2s;
}
#cryo-level.hot { height: 78%; background: linear-gradient(180deg, #ffe0b0, #ff8a2b); box-shadow: 0 0 14px #ff8a2b; }
#cryo-temp { margin: 0; font-family: var(--font); font-size: 26px; color: #9fd2ff; text-shadow: 0 0 8px #3f9dff; }
.cryo .label { margin: 4px 0 0; font-size: 10px; line-height: 1.5; color: var(--dim); }

/* ---------- printer slot and hard copy ---------- */
.slot {
  position: relative;
  height: 14px;
  margin: 18px 12% 0;
  border-radius: 7px;
  background: #050605;
  box-shadow: inset 0 3px 6px #000, 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 2;
}
.printout {
  position: absolute;
  top: 7px;
  left: 50%;
  width: min(460px, 90%);
  transform: translate(-50%, -100%);
  clip-path: inset(100% 0 0 0);
  pointer-events: none;
}
.printout.printing {
  animation: feed 2.4s steps(24) forwards;
  pointer-events: auto;
}
.printout img { display: block; width: 100%; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.7); cursor: pointer; }
@keyframes feed {
  from { transform: translate(-50%, -100%); clip-path: inset(100% 0 0 0); }
  to { transform: translate(-50%, 0); clip-path: inset(0 0 0 0); }
}

/* ---------- mechanical keys ---------- */
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 22px; }

.key {
  font: 13px var(--label);
  letter-spacing: 0.15em;
  color: #2a2d27;
  padding: 12px 16px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: linear-gradient(180deg, #e6e2d3, #c9c3ae);  /* old putty keycaps */
  box-shadow: 0 5px 0 #8c8672, 0 7px 8px rgba(0, 0, 0, 0.55), inset 0 1px 0 #fff;
  transition: transform 0.05s, box-shadow 0.05s;
}
.key:active, .key.pressed { transform: translateY(4px); box-shadow: 0 1px 0 #8c8672, 0 2px 3px rgba(0, 0, 0, 0.6), inset 0 1px 0 #fff; }
.key.small { padding: 8px 12px 10px; font-size: 12px; }
.key.voice { background: linear-gradient(180deg, #d9a09a, #b8746c); box-shadow: 0 5px 0 #7c4640, 0 7px 8px rgba(0, 0, 0, 0.55), inset 0 1px 0 #ffd9d4; }
.key.voice.on { background: linear-gradient(180deg, #ff8a80, #e0473c); color: #fff; }

/* ---------- terminal line ---------- */
.terminal {
  margin-top: 22px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #0b0e0c;
  box-shadow: inset 0 2px 8px #000;
}
.prompt { display: flex; align-items: center; gap: 8px; font-size: 26px; text-shadow: 0 0 8px var(--crt-glow); }
.prompt input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--crt);
  background: transparent;
  border: none;
  border-bottom: 1px solid #22303f;
  outline: none;
  caret-color: var(--crt);
}
.prompt input::placeholder { color: #3a4b5e; }
.status { margin: 6px 0 0; min-height: 1.2em; color: #8fa2b5; overflow-wrap: anywhere; }
.status.error { color: var(--alert); }
.place { color: #9cc4ff; }
.help { margin: 10px 0 0; color: #4f6152; font-size: 18px; }
.help b { color: var(--dim); font-weight: normal; }

/* ---------- small screens: same machine, simplified ---------- */
@media (max-width: 760px) {
  body { padding: 8px; }
  .machine { padding: 18px 12px 14px; border-radius: 12px; }
  .screw { display: none; }
  .deck { grid-template-columns: 1fr; }
  .panel { flex-direction: row; flex-wrap: wrap; justify-content: space-around; align-items: center; }
  .panel .vents, .gauge, .cryo .label { display: none; }
  .leds { grid-auto-flow: column; }
  .lcd-line { font-size: clamp(13px, 4.2vw, 20px); letter-spacing: 0.02em; }
  .detection { font-size: 19px; }
  .plate h1 { font-size: 26px; }
  .key { padding: 10px 11px 12px; font-size: 11px; }
}

/* ---------- Voight-Kampff (vk.html) ---------- */
.vk .plate h1 { letter-spacing: 0.6em; }
a.key { text-decoration: none; display: inline-block; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.consent {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 12%;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 22, 0.94), rgba(0, 0, 0, 0.98));
  z-index: 3;
}
.consent[hidden] { display: none; }
.consent h2 { margin: 0 0 10px; font-weight: normal; font-size: 34px; letter-spacing: 0.12em; text-shadow: 0 0 10px var(--crt-glow); }
.consent p { margin: 0; font-size: 22px; color: #b8cde2; }
.consent p b { color: var(--crt); font-weight: normal; }
.consent .small { font-size: 18px; color: #7890a8; }
.consent .key { margin-top: 18px; }
.key:disabled { opacity: 0.45; cursor: default; transform: none; }

/* Bellows: a breathing accordion, faster when the subject blinks a lot */
.bellows { display: grid; gap: 3px; padding: 6px 10px; }
.bellows span {
  height: 9px;
  border-radius: 3px;
  background: linear-gradient(180deg, #4a4f45, #1b1e19);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: breathe var(--breath, 4s) ease-in-out infinite;
}
.bellows span:nth-child(2) { animation-delay: 0.08s; } .bellows span:nth-child(3) { animation-delay: 0.16s; }
.bellows span:nth-child(4) { animation-delay: 0.24s; } .bellows span:nth-child(5) { animation-delay: 0.32s; }
.bellows span:nth-child(6) { animation-delay: 0.4s; }
@keyframes breathe { 0%, 100% { transform: scaleX(0.7); } 50% { transform: scaleX(1); } }

.trace { width: 100%; height: auto; border-radius: 4px; box-shadow: inset 0 2px 6px #000, 0 0 0 2px #1a1d18; }
.panel > .label { margin: 0; text-align: center; font-size: 10px; color: var(--dim); }

/* Second monitor inside the screen: the whole face, with the tracked mesh and the zoomed area */
.subject {
  position: absolute;
  right: 3%;
  bottom: 4%;
  width: 27%;
  border: 2px solid rgba(255, 179, 71, 0.7);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 150, 40, 0.35), 0 4px 12px rgba(0, 0, 0, 0.8);
  background: #000;
  z-index: 1;
}
.subject canvas { display: block; width: 100%; height: auto; }
.subject span {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 18px;
  color: var(--amber);
  text-shadow: 0 0 6px var(--amber-glow);
}
.vk .detection { min-height: 2.6em; }  /* room for a two-line question */
.stamp-human { color: #7dffa0; } .stamp-replicant { color: var(--alert); }
.opt-in {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 640px;
  margin-top: 12px;
  text-align: left;
  font-size: 19px;
  color: #b8cde2;
  cursor: pointer;
}
.opt-in input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--amber); flex: none; }

/* ---------- floating voice button (ESPER) ---------- */
.voice-fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 14px 16px;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  font: 15px var(--label);
  letter-spacing: 0.14em;
  color: #2a2d27;
  background: linear-gradient(180deg, #e6e2d3, #c9c3ae);
  box-shadow: 0 5px 0 #8c8672, 0 10px 22px rgba(0, 0, 0, 0.6), inset 0 1px 0 #fff;
  transition: transform 0.05s, background 0.2s;
}
.voice-fab:active { transform: translateY(4px); box-shadow: 0 1px 0 #8c8672, 0 4px 10px rgba(0, 0, 0, 0.6); }
.voice-fab svg { width: 26px; height: 26px; fill: none; stroke: #a3201c; stroke-width: 2; stroke-linecap: round; }
.voice-fab svg rect { fill: #a3201c; stroke: none; }
.voice-fab.on {
  color: #fff;
  background: radial-gradient(circle at 30% 30%, #ff7b70, #c62a20 70%);
  box-shadow: 0 5px 0 #7c1c16, 0 0 26px rgba(255, 70, 50, 0.65), inset 0 1px 0 #ffc2bb;
}
.voice-fab.on svg { stroke: #fff; }
.voice-fab.on svg rect { fill: #fff; }
.voice-fab.on::before {  /* "on air" ring */
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  border: 2px solid rgba(255, 90, 80, 0.8);
  animation: on-air 1.6s ease-out infinite;
  pointer-events: none;
}
.voice-fab.hearing::before { animation-duration: 0.6s; }
@keyframes on-air { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.25); } }

.voice-hint {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 76px);
  z-index: 50;
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 22px;
  color: var(--amber);
  background: #0d0904;
  box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.6), 0 8px 20px rgba(0, 0, 0, 0.7);
  text-shadow: 0 0 6px var(--amber-glow);
  animation: bob 1.8s ease-in-out infinite;
}
.voice-hint::after {  /* arrow pointing at the button */
  content: "";
  position: absolute;
  right: 42px;
  bottom: -8px;
  border: 8px solid transparent;
  border-bottom: none;
  border-top-color: #0d0904;
}
.voice-hint b { color: #ffe3b8; font-weight: normal; }
@keyframes bob { 50% { transform: translateY(-5px); } }

body.esper { padding-bottom: 110px; }  /* room below the machine: the floating button never covers text */

@media (max-width: 760px) {
  .voice-fab { padding: 12px 16px 12px 12px; font-size: 13px; }
}

/* V-K on phones: the consent text does not fit inside the 16:10 "TV", so while it is shown the
   screen grows with the text instead of cutting it (the camera views are hidden until accepted). */
@media (max-width: 760px) {
  .screen:has(> .consent:not([hidden])) > :not(.consent) { display: none; }
  .consent { position: relative; inset: auto; padding: 22px 16px; gap: 8px; }
  .consent h2 { font-size: 26px; margin-bottom: 4px; }
  .consent p { font-size: 18px; }
  .consent .small { font-size: 16px; }
  .opt-in { font-size: 16px; }
  .consent .key { width: 100%; margin-top: 14px; }
  .vk .bellows { width: 100%; }
  .vk .trace { max-height: 90px; object-fit: fill; }
}
