/* ============================================================
   YUSIQO — broadcast teletext
   One face. One 40-cell lattice. The broadcast eight.
   Font: Departure Mono (SIL OFL 1.1) · advance 0.63636em/cell
   ============================================================ */

@font-face {
  font-family: "Departure Mono";
  src: url("../fonts/DepartureMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* geometry — measured from the font, not guessed */
  --ratio: 0.63636;                 /* advance / em, Departure Mono */
  --cols: 40;
  --rowh: 1.18;                     /* rows sit just over the 4:3 cell so the
                                       Turkish İ-dot and ş-cedilla never collide;
                                       measured worst case keeps a 1px gap */
  --gut: 10px;                      /* the frame's margin, tightened on phones so
                                       the 40-cell row keeps as much size as possible */

  /* base size: JS refines this to an integer-friendly step; this is the no-JS floor */
  --fs: clamp(11px, calc((100vw - (2 * var(--gut))) / 25.4544), 22px);

  /* the broadcast eight, at full strength — there is nothing else */
  --black:   #000000;
  --red:     #ff0000;
  --green:   #00ff00;
  --yellow:  #ffff00;
  --blue:    #0000ff;
  --magenta: #ff00ff;
  --cyan:    #00ffff;
  --white:   #ffffff;

  /* roles */
  --ground: var(--black);
  --ink: var(--white);
  --head: var(--yellow);
  --live: var(--cyan);
  --alert: var(--red);
  --ok: var(--green);
  --bar: var(--blue);
}

* { box-sizing: border-box; }

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: var(--gut) 0 calc(var(--gut) * 2);
  background: var(--ground);
  color: var(--ink);
  font-family: "Departure Mono", ui-monospace, "Courier New", monospace;
  font-size: var(--fs);
  line-height: var(--rowh);
  font-variant-ligatures: none;
  font-kerning: none;
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

/* ---------- browser surfaces carry the design ---------- */

::selection { background: var(--cyan); color: var(--black); text-shadow: none; }

body { caret-color: var(--live); }

:focus-visible {
  outline: calc(var(--rowh) * 1em / 8) solid var(--live);
  outline-offset: 2px;
}

html { scrollbar-color: var(--cyan) var(--black); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--cyan); border: 2px solid var(--black); }
::-webkit-scrollbar-thumb:hover { background: var(--white); }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- language: one voice at a time ---------- */

html[data-lang="tr"] .en,
html[data-lang="en"] .tr { display: none; }

.skip {
  position: absolute; top: 0; left: 0; z-index: 9;
  width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
  clip-path: inset(50%);
  background: var(--yellow); color: var(--black); text-decoration: none;
}
.skip:focus {
  width: auto; height: auto; clip-path: none;
  padding: 0.2em 1ch;
}

/* ---------- the frame ---------- */

.tv {
  width: 40ch;
  max-width: calc(100% - (2 * var(--gut)));
  margin-inline: auto;
}

/* ---------- header strip ---------- */

.hdr {
  position: sticky; top: 0; z-index: 5;
  background: var(--black);
}

.hdr-line {
  display: flex; align-items: baseline; gap: 1ch;
  margin: 0;
  background: var(--bar);
  color: var(--white);
  padding: 0.18em 1ch;
  white-space: nowrap;
  overflow: hidden;
}

.svc { color: var(--white); flex: 0 0 auto; }
.langs { display: flex; align-items: baseline; gap: 0; flex: 1 1 auto; }
.pgnum { color: var(--white); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.clock { color: var(--white); flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.pgnum.is-tick { animation: tick 320ms steps(1, end) 1; }

.lang {
  font: inherit; color: var(--white); background: none; border: 0;
  padding: 0; cursor: pointer;
}
.lang[aria-pressed="true"] { background: var(--white); color: var(--bar); }
.lang:hover { text-decoration: underline; text-underline-offset: 2px; }
.lang-sep { color: var(--white); }

.chips {
  display: flex; gap: 1ch; flex-wrap: wrap;
  margin: 0; padding: 0.45em 1ch 0;
}
.chip { color: var(--live); text-decoration: none; }
.chip:hover, .chip:focus-visible { background: var(--live); color: var(--black); }
.chip.is-here { background: var(--white); color: var(--black); }

.keyline {
  margin: calc(var(--rowh) * 0.3em) 0 0;
  background: var(--magenta); color: var(--black);
  padding: 0 1ch; min-height: calc(var(--rowh) * 1em);
  visibility: hidden;
}
.keyline.is-on { visibility: visible; }

/* ---------- pages ---------- */

.pages { display: block; }

.page {
  padding: 1.3em 0 2.4em;
  scroll-margin-top: 4em;
  border-top: 1px solid var(--blue);
}
.page:first-child { border-top: 0; }

.page p { margin: 0 0 calc(var(--rowh) * 0.9em); }

.body { color: var(--ink); }
.body.strong { color: var(--head); }
.body.dim { color: var(--magenta); }

.note, .cap {
  color: var(--live);
  font-size: inherit;
  margin: 0 0 calc(var(--rowh) * 1.2em);
}

/* ---------- headline: teletext double size ---------- */

.dh {
  margin: 0 0 calc(var(--rowh) * 1.1em);
  font-weight: 400;
  font-size: calc(var(--fs) * 2);
  line-height: var(--rowh);
  color: var(--head);
  letter-spacing: 0;
}

.dh-l { display: block; white-space: nowrap; }
.dh-2 { color: var(--white); }

.lede { color: var(--ink); }

/* ---------- index menu ---------- */

.menu {
  display: grid;
  gap: 0;
  margin: calc(var(--rowh) * 1.1em) 0 0;
}

.mrow {
  display: grid;
  grid-template-columns: 4ch 10ch 1fr;
  align-items: baseline;
  color: var(--ink);
  text-decoration: none;
  padding: calc(var(--rowh) * 0.12em) 0;
  border-bottom: 1px solid var(--live);
}
.mrow:last-child { border-bottom: 0; }
.mrow .mn { color: var(--head); }
.mrow .ml { color: var(--ink); }
.mrow .md { color: var(--live); }

.mrow:hover, .mrow:focus-visible { background: var(--white); }
.mrow:hover .mn, .mrow:hover .ml, .mrow:hover .md,
.mrow:focus-visible .mn, .mrow:focus-visible .ml, .mrow:focus-visible .md { color: var(--black); }
.mrow:hover { text-decoration: none; }

/* ---------- the one loud row ---------- */

.cta-row {
  display: grid;
  grid-template-columns: 4ch 2ch 1fr;
  align-items: baseline;
  margin: calc(var(--rowh) * 1em) 0 0;
  padding: calc(var(--rowh) * 0.22em) 0;
  background: var(--head);
  color: var(--black);
  text-decoration: none;
}
.cta-row .cta-n, .cta-row .cta-l { color: var(--black); }
.cta-row .cta-x { color: var(--alert); }
.cta-row:hover, .cta-row:focus-visible { background: var(--white); }
.cta-row:hover .cta-x { color: var(--alert); }

.hint { color: var(--live); margin-top: calc(var(--rowh) * 1.2em); }

/* ---------- section headers ---------- */

.ph {
  margin: 0 0 calc(var(--rowh) * 1.6em);
  font-weight: 400;
  font-size: var(--fs);
  line-height: calc(var(--rowh) * 2.4);
  color: var(--head);
  transform: scaleY(2);
  transform-origin: left top;
}

.ph-n {
  background: var(--bar); color: var(--white);
  padding: 0 0.5ch; margin-right: 1ch;
}

/* ---------- ladder (sixel-built, JS) ---------- */

.ladder-wrap { margin: 0 0 calc(var(--rowh) * 1.6em); }

.ladder {
  display: grid;
  grid-auto-rows: calc(var(--rowh) * 1em);
  gap: 0;
  width: max-content;
  margin-bottom: calc(var(--rowh) * 0.4em);
}
.ladder i { display: block; background: transparent; }
.ladder i.on { background: var(--live); }
.ladder i.top { background: var(--head); }

.ladder-keys {
  display: flex; gap: 0; list-style: none;
  margin: 0 0 calc(var(--rowh) * 0.4em); padding: 0;
  color: var(--live);
}
.ladder-keys li { width: 3ch; }

.levels { margin: 0 0 calc(var(--rowh) * 1.2em); }
.levels dt { color: var(--head); }
.levels dd { margin: 0 0 calc(var(--rowh) * 0.8em); color: var(--ink); }

/* ---------- boxed panels, the magazine's own device ---------- */

.panel {
  border: 1px solid var(--bar);
  padding: 0.7em 1ch 0.9em;
  margin: 0 0 calc(var(--rowh) * 1.5em);
}
.panel-head { color: var(--head); margin: 0 0 calc(var(--rowh) * 0.6em); }
.panel-strong { border-color: var(--head); }

/* ---------- facts ---------- */

.facts {
  list-style: none; margin: 0 0 calc(var(--rowh) * 1.2em); padding: 0;
  color: var(--ink);
}
.panel .facts { margin-bottom: 0; }
.facts li::before { content: "· "; color: var(--live); }

/* ---------- speaking practice: the sample carousel ---------- */

.sub-shell {
  border: 1px solid var(--bar);
  padding: 1em 1ch 1.2em;
  margin: 0 0 calc(var(--rowh) * 1.4em);
}

.sub-line {
  display: flex; align-items: baseline; gap: 1ch;
  margin: 0 0 calc(var(--rowh) * 0.9em);
}
.sub-label { background: var(--alert); color: var(--black); padding: 0.18em 1ch; }
.sub-ind { color: var(--live); flex: 1 1 auto; font-variant-numeric: tabular-nums; }

.hold {
  font: inherit; color: var(--black); background: var(--live);
  border: 0; padding: 0 1ch; cursor: pointer;
}
.hold[aria-pressed="true"] { background: var(--alert); color: var(--black); }
.hold:hover { background: var(--white); color: var(--black); }

.mosaic {
  display: grid; margin-bottom: calc(var(--rowh) * 0.8em);
  color: var(--live);
}
.mosaic i { display: block; }
.mosaic i.on { background: currentColor; }

.dlg { margin: 0 0 calc(var(--rowh) * 0.8em); }
.dl {
  display: grid; grid-template-columns: 7ch 1fr;
  margin: 0 0 calc(var(--rowh) * 0.55em);
}
.sp { color: var(--head); }
.tx { color: var(--ink); }
.cue { color: var(--live); }

.caret { color: var(--live); animation: blink 1.06s steps(1, end) infinite; }

.reveal {
  font: inherit; color: var(--black); background: var(--alert);
  border: 0; padding: 0.12em 1ch; cursor: pointer;
}
.reveal:hover, .reveal:focus-visible { background: var(--white); color: var(--black); }
.reveal[aria-expanded="true"] { background: var(--green); color: var(--black); }

.rev {
  margin: 1em 0 0;
  border-top: 1px solid var(--blue);
  padding-top: 0.9em;
}
.rev .line { margin: 0 0 calc(var(--rowh) * 0.2em); color: var(--ink); }
.rev[hidden] { display: none; }
.rev .hit { color: var(--alert); }
.rev .fix { color: var(--ok); }

.rev.is-wiping .line { animation: wipe 260ms steps(6, end) both; }
.rev.is-wiping .line:nth-child(2) { animation-delay: 40ms; }
.rev.is-wiping .line:nth-child(3) { animation-delay: 80ms; }
.rev.is-wiping .line:nth-child(4) { animation-delay: 120ms; }
.rev.is-wiping .line:nth-child(5) { animation-delay: 160ms; }
.rev.is-wiping .line:nth-child(6) { animation-delay: 200ms; }
.rev.is-wiping .line:nth-child(7) { animation-delay: 240ms; }

/* ---------- page nav ---------- */

.pnav {
  display: flex; justify-content: space-between; gap: 2ch;
  margin-top: calc(var(--rowh) * 1.4em);
}
.pnav a { color: var(--live); text-decoration: none; }
.pnav a:hover, .pnav a:focus-visible {
  background: var(--live); color: var(--black);
}

/* ---------- signup ---------- */

.join { margin: calc(var(--rowh) * 1.2em) 0 0; }
.panel .join { margin-top: 0; }

.field-label { display: block; color: var(--head); margin-bottom: calc(var(--rowh) * 0.3em); }

.field {
  display: block;
  font: inherit;
  width: 100%;
  margin: 0 0 calc(var(--rowh) * 0.8em);
  padding: 0 1ch;
  color: var(--white);
  background: var(--black);
  border: 1px solid var(--live);
  border-radius: 0;
}
.field::placeholder { color: var(--live); opacity: 1; }
.field:focus-visible { outline-offset: 0; border-color: var(--white); }
.field[aria-invalid="true"] { border-color: var(--alert); }

.submit {
  font: inherit; color: var(--black); background: var(--head);
  border: 0; padding: 0 1ch; cursor: pointer;
}
.submit:hover, .submit:focus-visible { background: var(--white); }
.submit[disabled] { background: var(--magenta); color: var(--black); cursor: progress; }

.msg { margin: calc(var(--rowh) * 0.9em) 0 0; color: var(--ok); }
.msg.is-bad { color: var(--alert); }
.msg:empty { display: none; }

.fine { color: var(--live); margin-top: calc(var(--rowh) * 1.6em); }

/* ---------- footer ---------- */

.ftr { margin-top: calc(var(--rowh) * 2em); }

.ftr-line {
  display: flex; justify-content: space-between; gap: 1ch;
  margin: 0; padding: 0.18em 1ch;
  background: var(--bar); color: var(--white);
  white-space: nowrap;
}
.ftr-c { color: var(--white); }
.ftr-r { color: var(--white); }

/* ---------- motion ---------- */

@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

@keyframes tick {
  0% { color: var(--head); }
  30% { color: var(--black); }
  60% { color: var(--head); }
  100% { color: var(--white); }
}

@keyframes wipe {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes arrive {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.page:first-child .dh-l { animation: arrive 420ms steps(9, end) both; }
.page:first-child .dh-2 { animation-delay: 90ms; }

.sub { display: block; }
.sub[hidden] { display: none; }
.sub.is-in { animation: wipe 300ms steps(8, end) both; }

@media (max-width: 460px) {
  :root { --gut: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .pgnum.is-tick { animation: none; }
  .rev.is-wiping .line, .sub.is-in, .page:first-child .dh-l { animation: none; }
  html { scroll-behavior: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
