/* The whole page seen through the same tube as method.log: scan lines and a phosphor grille over
   the picture, text that glows and is not quite steady, a prompt above every chapter, panels that
   print on and glitch as they arrive. Loaded last; it restyles, it does not lay anything out.
   Titles stay in --sans, as the terminal's own title does; what is read is in --mono; figures in Chakra Petch. */

:root {
  --glow: 0 0 5px rgba(255, 120, 240, 0.55), 0 0 14px rgba(255, 47, 230, 0.25);
  --glow-soft: 0 0 4px rgba(255, 120, 240, 0.35), 0 0 12px rgba(255, 47, 230, 0.16);
  --phosphor: #ffe6fd;
}

/* ---------- the tube, over everything ---------- */

.fx-scan {
  opacity: 1;
  background:
    linear-gradient(to bottom, transparent 0, rgba(255, 190, 250, 0.035) 40%, rgba(255, 190, 250, 0.08) 50%, transparent 60%) 0 0 / 100% 34% no-repeat,
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(to right, rgba(255, 0, 80, 0.04) 0 1px, rgba(0, 255, 120, 0.028) 1px 2px, rgba(40, 80, 255, 0.04) 2px 3px);
  animation: crt-roll 7s linear infinite;
}

/* A tear across the picture when a chapter arrives: a few bright slices that jump and are gone. */
.fx-tear {
  opacity: 0;
  mix-blend-mode: screen;
  background:
    linear-gradient(to bottom, transparent 0 18%, rgba(255, 77, 234, 0.5) 18% 19.2%, transparent 19.2% 43%, rgba(120, 150, 255, 0.45) 43% 43.8%, transparent 43.8% 71%, rgba(255, 220, 252, 0.55) 71% 73%, transparent 73%),
    repeating-linear-gradient(to bottom, rgba(255, 190, 250, 0.1) 0 2px, transparent 2px 6px);
}

body.glitching .fx-tear {
  animation: tear 0.46s steps(1) both;
}

@keyframes tear {
  0% { opacity: 0.9; transform: translate(-14px, -6%); }
  14% { opacity: 0.5; transform: translate(22px, 9%); }
  28% { opacity: 0.85; transform: translate(-8px, 21%); }
  42% { opacity: 0.2; transform: translate(12px, -12%); }
  58% { opacity: 0.7; transform: translate(-20px, 4%); }
  74% { opacity: 0.3; transform: translate(6px, 30%); }
  100% { opacity: 0; transform: none; }
}

/* ---------- what is read: mono, lit ---------- */

.panel,
.room-copy,
.files,
.menu,
.hud-top,
.dots {
  text-shadow: var(--glow-soft);
}

.panel:not(.panel-hero) {
  animation: crt-flicker 4.3s steps(1) infinite;
}

/* What the terminal prints is in --mono: the command line, labels, keys, values. What a person reads as
   a sentence is in --sans and does not glow: sentences in spaced, glowing mono turned every panel into noise,
   and the figure lost its caption. */
.room-lede,
.menu .m-d,
.bar .bv,
.pair .v,
.tiles dt {
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

.read,
.stat-l,
.cap,
.note,
.bar span:not(.bv),
.pair span:not(.v) {
  font-family: var(--sans);
  letter-spacing: 0;
  text-shadow: none;
}

.stat-l {
  font-size: 16px;
  line-height: 1.35;
  color: #fff;
}

.read {
  max-width: 44ch;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
}

.cap,
.note {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.55);
}

/* The readout says what was picked, the figure, and what the figure counts, in that order. */
.readout [data-r='u'] {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: 14px;
  font-style: normal;
  color: rgba(255, 255, 255, 0.78);
}

html[data-m='d'] .readout span[data-r='k'] {
  font-size: 11px;
  color: #ffd6fb;
}

.room-lede {
  font-size: 15px;
  line-height: 1.65;
  color: var(--phosphor);
  text-shadow: var(--glow);
}

.stat,
.tiles dd,
.readout b,
.m-f,
.file-name {
  text-shadow: 0 0 6px rgba(255, 120, 240, 0.6), 0 0 22px rgba(255, 47, 230, 0.35);
}

.panel h2,
.room-copy h2 {
  --ts: var(--glow-soft);
}

.panel .stat,
.panel .duo {
  --ts: 0 0 6px rgba(255, 120, 240, 0.6), 0 0 22px rgba(255, 47, 230, 0.35);
}

/* The prompt above each chapter, as the terminal has above each entry. */
.cmd {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: rgba(255, 214, 251, 0.75);
  text-shadow: var(--glow);
}

.cmd .crt-cursor {
  width: 0.55em;
  height: 1em;
}

/* A dashed rule over the controls, as between the terminal's rows. */
html[data-m='d'] .panel .screen {
  padding-top: 14px;
  border-top: 1px dashed rgba(250, 189, 249, 0.3);
}

/* ---------- arriving: print on, then settle with a glitch ---------- */

.panel > * {
  transform: none;
}

.panel.is-on > * {
  animation: panel-print 0.42s steps(7) backwards;
}

.panel.is-on > :nth-child(2) { animation-delay: 0.08s; }
.panel.is-on > :nth-child(3) { animation-delay: 0.16s; }
.panel.is-on > :nth-child(4) { animation-delay: 0.24s; }
.panel.is-on > :nth-child(5) { animation-delay: 0.32s; }
.panel.is-on > :nth-child(6) { animation-delay: 0.4s; }
.panel.is-on > :nth-child(7) { animation-delay: 0.48s; }

@keyframes panel-print {
  from { clip-path: inset(-20px -60px 100% -60px); }
  to { clip-path: inset(-20px -60px -20px -60px); }
}

.panel.is-on > h2,
.panel.is-on > .stat,
.panel.is-on > .duo {
  animation: panel-print 0.42s steps(7) backwards, glitch-in 0.55s steps(1) 0.1s, glitch-idle 11s steps(1) 2.5s infinite;
}

.panel.is-on > .stat { animation-delay: 0.16s, 0.3s, 4s; }

@keyframes glitch-in {
  0% { transform: translateX(-9px) skewX(-10deg); text-shadow: -4px 0 #2b55ff, 4px 0 #ff2fe6; clip-path: inset(0 -60px 55% -60px); }
  16% { transform: translateX(7px) skewX(6deg); text-shadow: 4px 0 #2b55ff, -4px 0 #ff2fe6; clip-path: inset(40% -60px 0 -60px); }
  32% { transform: translateX(-3px); text-shadow: -2px 0 #2b55ff, 2px 0 #ff2fe6; clip-path: inset(-20px -60px 22% -60px); }
  48% { transform: translateX(4px) skewX(-3deg); text-shadow: 3px 0 #2b55ff, -3px 0 #ff2fe6; clip-path: inset(-20px -60px -20px -60px); }
  64% { transform: none; text-shadow: -1px 0 #2b55ff, 1px 0 #ff2fe6; }
  80%, 100% { transform: none; text-shadow: var(--ts); }
}

/* Now and then the signal slips for a frame or two. */
/* Every frame states the shadow: a frame that left it out would hold the split one before it. */
@keyframes glitch-idle {
  0%, 100% { transform: none; text-shadow: var(--ts); }
  1.2% { transform: translateX(-4px) skewX(-6deg); text-shadow: -3px 0 #2b55ff, 3px 0 #ff2fe6; }
  2% { transform: translateX(3px); text-shadow: 2px 0 #2b55ff, -2px 0 #ff2fe6; }
  2.8% { transform: none; text-shadow: var(--ts); }
  47% { transform: none; text-shadow: var(--ts); }
  47.6% { transform: translateX(2px) skewX(3deg); text-shadow: 2px 0 #2b55ff, -2px 0 #ff2fe6; }
  48.2% { transform: none; text-shadow: var(--ts); }
}

/* The same slip for the cover's title, which keeps its own light. */
@keyframes slip-idle {
  0%, 100% { transform: none; }
  1.2% { transform: translateX(-5px) skewX(-6deg); }
  2% { transform: translateX(4px); }
  2.8% { transform: none; }
  47% { transform: none; }
  47.6% { transform: translateX(3px) skewX(3deg); }
  48.2% { transform: none; }
}

/* The cover's title slips too. */
body[data-ch='0'].ready h1 {
  animation: slip-idle 9s steps(1) 3s infinite;
}

/* ---------- the index and the control room, same tube ---------- */

.m-head span:first-child::after,
.room-copy .cmd::after {
  content: none;
}

.menu li a:hover .m-n,
.menu li a:focus-visible .m-n {
  color: #14061c;
  background: #fabdf9;
  text-shadow: none;
  box-shadow: 0 0 14px rgba(255, 77, 234, 0.6);
}

.menu .m-n {
  padding: 2px 0;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.menu-open .menu ul {
  animation: crt-flicker 4.3s steps(1) infinite;
}

.menu-open .menu li a {
  animation: panel-print 0.36s steps(5) backwards;
}

.menu-open .menu li:nth-child(7n + 2) a { animation-delay: 0.04s; }
.menu-open .menu li:nth-child(7n + 3) a { animation-delay: 0.08s; }
.menu-open .menu li:nth-child(7n + 4) a { animation-delay: 0.12s; }
.menu-open .menu li:nth-child(7n + 5) a { animation-delay: 0.16s; }
.menu-open .menu li:nth-child(7n + 6) a { animation-delay: 0.2s; }
.menu-open .menu li:nth-child(7n) a { animation-delay: 0.24s; }

.file-way .file-tag,
.file-way .file-link {
  text-shadow: var(--glow);
}

.file-way:hover .file-tag,
.file-way:focus-visible .file-tag {
  align-self: flex-start;
  padding: 2px 6px;
  margin: -2px -6px;
  color: #14061c;
  background: #fabdf9;
  text-shadow: none;
}

.room-open .room-copy h2 {
  animation: glitch-in 0.55s steps(1) 0.25s, glitch-idle 11s steps(1) 3s infinite;
}

@media (max-aspect-ratio: 1/1) {
  .read {
    font-size: 13px;
    line-height: 1.55;
  }

  .cmd {
    margin-bottom: 8px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-scan,
  .fx-tear,
  .panel,
  .panel.is-on > *,
  .menu-open .menu ul,
  .menu-open .menu li a,
  .room-open .room-copy h2,
  body[data-ch='0'].ready h1 {
    animation: none !important;
  }
}
