/* CRYPTEXT viewer: a 1980s CRT in a dark room. Teletext colours are the 8 pure Level 1 colours. */
:root {
  --c-black: #000; --c-red: #ff2a1f; --c-green: #19ff3c; --c-yellow: #fff22a;
  --c-blue: #2b4bff; --c-magenta: #ff2bff; --c-cyan: #2bffff; --c-white: #f4f4f4;
  --room: #07060a; --plastic: #26221f; --plastic-hi: #3b352f; --ink: #d9d4cc; --muted: #8d867c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--room); color: var(--ink); font-family: "VT323", ui-monospace, monospace; }
body { min-height: 100vh;
  background: radial-gradient(1200px 700px at 35% 30%, #1a1420 0%, #0b0910 45%, var(--room) 100%); }
a { color: #7fe7ff; }
button { font-family: inherit; }

.room, .room * { --cell-w: calc(var(--screen-w) / 40); --cell-h: calc(var(--screen-w) / 40 * 1.32); }
.room { --screen-w: min(92vw, 760px); display: grid; grid-template-columns: auto 230px; grid-template-areas: "tv remote" "panel panel";
  gap: 22px 26px; justify-content: center; align-items: start; padding: 28px 16px 40px; }
.tv { grid-area: tv; }
.remote { grid-area: remote; }
.panel { grid-area: panel; max-width: calc(var(--screen-w) + 256px); width: 100%; justify-self: center; }

/* ---------- television ---------- */
.bezel { position: relative; padding: 34px 34px 64px; border-radius: 34px;
  background: linear-gradient(160deg, var(--plastic-hi), var(--plastic) 40%, #191613);
  box-shadow: 0 40px 80px rgba(0,0,0,.7), inset 0 2px 0 rgba(255,255,255,.08), inset 0 -3px 0 rgba(0,0,0,.6); }
.bezel::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px); }
.badge { position: absolute; left: 40px; bottom: 22px; letter-spacing: .25em; font-size: 18px; color: #b9ae9f; }
.badge span { color: var(--muted); font-size: 14px; margin-left: 10px; }
.led { position: absolute; right: 44px; bottom: 28px; width: 10px; height: 10px; border-radius: 50%; background: #ff3b2f;
  box-shadow: 0 0 10px #ff3b2f, 0 0 20px rgba(255,59,47,.6); }

.screen { position: relative; width: var(--screen-w); height: calc(var(--cell-h) * 25 + 32px); padding: 16px 0; overflow: hidden;
  background: #000; border-radius: 28px / 34px;
  box-shadow: inset 0 0 60px rgba(0,0,0,.95), inset 0 0 6px rgba(120,160,255,.15), 0 0 0 6px #0b0a09; }
.glass { position: relative; width: var(--screen-w); margin: 0 auto; filter: saturate(1.15);
  animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 50% { filter: saturate(1.15) brightness(1.04); } }

.grid { display: grid; grid-template-columns: repeat(40, var(--cell-w)); grid-auto-rows: var(--cell-h);
  font-size: calc(var(--cell-h) * 1.08); line-height: var(--cell-h); }
.cell { position: relative; width: var(--cell-w); height: var(--cell-h); text-align: center; white-space: pre; overflow: visible;
  text-shadow: 0 0 calc(var(--cell-w) * .35) currentColor; }
.cell.t { transform: scaleX(1.45); }
.cell.dh { transform: scaleY(2); transform-origin: top; z-index: 1; }
.cell.t.dh { transform: scale(1.45, 2); transform-origin: top; }
.row-hidden { visibility: hidden; }
.flash { animation: flash 1s steps(1) infinite; }
@keyframes flash { 50% { color: transparent; text-shadow: none; } }
.flash .m i.on { animation: flashm 1s steps(1) infinite; }
@keyframes flashm { 50% { background: transparent; box-shadow: none; } }
.screen:not(.revealed) .conceal, .ghost:not(.revealed) .conceal { color: transparent !important; text-shadow: none !important; }
.screen:not(.revealed) .conceal .m i.on { background: transparent !important; box-shadow: none !important; }

/* colours */
.f-black { color: var(--c-black); } .f-red { color: var(--c-red); } .f-green { color: var(--c-green); } .f-yellow { color: var(--c-yellow); }
.f-blue { color: var(--c-blue); } .f-magenta { color: var(--c-magenta); } .f-cyan { color: var(--c-cyan); } .f-white { color: var(--c-white); }
.b-red { background: var(--c-red); } .b-green { background: var(--c-green); } .b-yellow { background: var(--c-yellow); }
.b-blue { background: var(--c-blue); } .b-magenta { background: var(--c-magenta); } .b-cyan { background: var(--c-cyan); } .b-white { background: var(--c-white); }

/* mosaic sextants: 2x3 blocks in the cell's foreground colour */
.m { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; }
.m i { display: block; }
.m i.on { background: currentColor; box-shadow: 0 0 calc(var(--cell-w) * .3) currentColor; }

/* CRT layers */
.scan { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.42) 0 1px, transparent 1px 3px); }
.band { position: absolute; left: 0; right: 0; height: 18%; top: -20%; pointer-events: none; opacity: .07;
  background: linear-gradient(transparent, #fff, transparent); animation: roll 7s linear infinite; }
@keyframes roll { to { top: 110%; } }
.vignette { position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.55) 88%, rgba(0,0,0,.9) 100%); }
.poweron { position: absolute; inset: 0; background: #000; pointer-events: none; opacity: 0; }
.poweron.on { animation: power 1.1s ease-out forwards; }
@keyframes power {
  0% { opacity: 1; background: linear-gradient(transparent 49.6%, #fff 49.6% 50.4%, transparent 50.4%), #000; }
  35% { opacity: 1; background: linear-gradient(transparent 30%, rgba(255,255,255,.6) 30% 70%, transparent 70%), #000; }
  100% { opacity: 0; background: #000; }
}
.screen.searching .grid > .cell:nth-child(n+41) { opacity: .85; }

/* page 666 haunting */
.ghost { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.screen.haunt .glass { filter: hue-rotate(70deg) saturate(1.4); animation: haunt 3.2s infinite; }
.screen.haunt .ghost { opacity: .28; transform: translate(6px, 2px); filter: blur(1px); animation: drift 4s ease-in-out infinite; }
@keyframes haunt { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .4; } 94% { opacity: 1; } 96% { opacity: .2; transform: translateX(-3px); } 97% { opacity: 1; transform: none; } }
@keyframes drift { 50% { transform: translate(-5px, 3px); } }

/* ---------- remote ---------- */
.remote { position: relative; padding: 22px 18px 18px; border-radius: 26px 26px 40px 40px;
  background: linear-gradient(180deg, #2c2b2e, #18171a); box-shadow: 0 30px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); }
.ir { width: 34px; height: 8px; margin: 0 auto 14px; border-radius: 4px; background: #3a0d12; box-shadow: inset 0 0 4px #000; }
.entry { text-align: center; font-size: 34px; color: var(--c-yellow); background: #050505; border-radius: 8px; padding: 2px 0 0; margin-bottom: 14px;
  letter-spacing: .12em; text-shadow: 0 0 10px rgba(255,242,42,.6); box-shadow: inset 0 0 8px #000; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.remote button { height: 44px; border: 0; border-radius: 12px; cursor: pointer; font-size: 26px; color: #e9e4dc;
  background: linear-gradient(180deg, #45434a, #2f2e33); box-shadow: 0 3px 0 #0e0d10, inset 0 1px 0 rgba(255,255,255,.1); }
.remote button:active { transform: translateY(2px); box-shadow: 0 1px 0 #0e0d10; }
.remote button:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 2px; }
.fastext { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.remote .fx { height: 26px; border-radius: 13px; }
.fx.red { background: #d01d16; } .fx.green { background: #14b52c; } .fx.yellow { background: #e6d81d; } .fx.cyan { background: #1fc9c9; }
.row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.remote .row3 button { font-size: 22px; }
.remote .evil { background: linear-gradient(180deg, #8d1010, #4a0606); color: #ffd6d6; text-shadow: 0 0 8px #ff2a1f; }
.hint { font-size: 17px; color: var(--muted); margin: 14px 2px 0; line-height: 1.15; }

/* ---------- panel ---------- */
.panel { background: #121015; border: 1px solid #241f28; border-radius: 16px; padding: 14px 18px 12px; font-size: 20px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { background: #1d1a21; color: var(--ink); border: 1px solid #2c2731; border-radius: 9px; padding: 4px 12px; font-size: 20px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--c-cyan); color: #000; border-color: var(--c-cyan); }
.tabbody p { margin: 10px 0 6px; }
pre { margin: 6px 0; padding: 10px 12px; background: #050505; border-radius: 8px; color: var(--c-green); font-family: "VT323", monospace; font-size: 20px;
  white-space: pre-wrap; word-break: break-all; }
code { color: var(--c-yellow); }
.copy { display: inline-block; margin-top: 4px; background: #1d1a21; color: var(--ink); border: 1px solid #2c2731; border-radius: 9px; padding: 4px 12px;
  font-size: 20px; cursor: pointer; text-decoration: none; }
.src { color: var(--muted); font-size: 18px; margin: 12px 0 0; }

@media (max-width: 1060px) {
  .room { grid-template-columns: 1fr; grid-template-areas: "tv" "remote" "panel"; --screen-w: min(calc(100vw - 32px - 40px), 760px); }
  .bezel { padding: 20px 20px 52px; border-radius: 26px; }
  .remote { width: min(100%, 360px); justify-self: center; }
  .panel { max-width: calc(var(--screen-w) + 40px); }
}
@media (prefers-reduced-motion: reduce) {
  .band, .glass, .flash, .flash .m i.on, .screen.haunt .glass, .screen.haunt .ghost, .poweron.on { animation: none !important; }
}
