/* cablevision.app: the Backglass. Layout = Margot's locked comp (crew/margot-layout.md); type = Jan; motion = Mira.
   Dark only, on purpose: a backglass only exists lit, in a dark cabinet. */

@font-face {
  font-family: "DSEG14"; font-weight: 700; font-style: normal; font-display: block;
  src: url("/fonts/DSEG14Classic-Bold.a73df6e665.woff2") format("woff2");
}
@font-face {
  font-family: "DSEG7"; font-weight: 700; font-style: normal; font-display: block;
  src: url("/fonts/DSEG7Classic-Bold.ec2e7499bc.woff2") format("woff2");
}
@font-face {                                   /* Changa One by Eduardo Tunni, SIL OFL 1.1, served unmodified */
  font-family: "CTM Ribbon"; font-weight: 400; font-style: normal; font-display: block;
  src: url("/fonts/ChangaOne-Regular.7ac4d26a3a.ttf") format("truetype");
}

:root {
  color-scheme: dark;
  --bg: #000;                     /* must stay pure #000: matches the art's surround, hides the glass edge */
  --red: #ff2b1c; --green: #39ff5e; --amber: #ffad14;
  --unlit: #2a0705;
  --credit-hi: #a39e94; --credit: #8f8b82; --credit-lo: #7a766e;

  --art-ratio: 0.7474;            /* 1024 / 1370: the glass window; do not change */
  --gutter: clamp(16px, 4vw, 48px);
  --pad-top: clamp(12px, 3.5svh, 40px);
  --pad-bottom: max(clamp(12px, 2.5svh, 28px), env(safe-area-inset-bottom));
  --gap-prompt: clamp(8px, 1.5svh, 16px);    /* glass to prompt: tight, one machine */
  --gap-footer: clamp(16px, 3svh, 32px);     /* prompt to credit: clearly bigger */
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  background: var(--bg); color: var(--credit);
  height: 100svh; min-height: 480px;
  display: grid; grid-template-rows: minmax(220px, 1fr) auto;
  padding: var(--pad-top) var(--gutter) var(--pad-bottom);
  overflow-x: clip;
  font: 400 clamp(11px, .7rem + .15vw, 12px)/1.5 "Helvetica Neue", Arial, sans-serif;
}

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

/* the stage is a size container; spare height splits 2:3 above/below the unit */
.stage {
  container-type: size;
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: var(--gap-footer);
  min-width: 0;
}
.stage::before { content: ""; flex: 2 1 0; }
.stage::after  { content: ""; flex: 3 1 0; }

.unit {
  --prompt-size: clamp(15px, min(3.2svh, 5.8cqw), 30px);
  --prompt-block: calc(var(--prompt-size) + 24px + var(--gap-prompt));
  --glass-w: min(100cqw, (100cqh - var(--prompt-block)) * var(--art-ratio));
  display: flex; flex-direction: column; align-items: center; gap: var(--gap-prompt);
  flex: none;
}

.glass {
  position: relative; width: var(--glass-w); aspect-ratio: 1024 / 1370;
  overflow: hidden; cursor: pointer; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
.layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.lit { transition: opacity .25s linear; }              /* reduced-motion glass change: one 250 ms cross-fade */
.lit.out { opacity: 0; }
.lit.snap { transition: none; }
#bloom { filter: blur(calc(var(--glass-w) * .03)); opacity: .55; mix-blend-mode: screen; }

/* code-set displays (all text on the glass is set here, never in the art) */
#disp { overflow: visible; }
.disp { transition: opacity .15s linear; }
.disp.dark { opacity: 0; }
.disp.off { display: none; }
.seg { font-weight: 700; }
.ghost { opacity: .1; }
.r { fill: var(--red); }
.g { fill: var(--green); }
.a { fill: var(--amber); }
.lit-r { filter: drop-shadow(0 0 6px var(--red)); }
.lit-g { filter: drop-shadow(0 0 6px var(--green)); }
.lit-a { filter: drop-shadow(0 0 6px var(--amber)); }
.ribbon { font-family: "CTM Ribbon", sans-serif; fill: #13213d; }
.ribbon.shadow { fill: #A8551B; }

/* the prompt: the machine's ninth display, with ghost segments behind the lit ones */
.prompt {
  display: grid; place-items: center;
  min-height: 44px; min-width: 44px;
  font: 700 var(--prompt-size)/1 "DSEG14", monospace; letter-spacing: .08em; white-space: nowrap;
  text-transform: uppercase; text-decoration: none;
  color: var(--red); text-shadow: 0 0 .35em rgba(255, 43, 28, .55);
  background: none; border: 0; padding: 12px 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.prompt > .cells, .prompt > .vis { grid-area: 1 / 1; }
.prompt .gap { letter-spacing: calc(.616em + .08em); }      /* a space is a full blank cell, like the glass */
.prompt .d7 { font-family: "DSEG7", monospace; }            /* D and B lit as 7-seg d and b (see backglass.js) */
.prompt > .cells { opacity: .1; text-shadow: none; }        /* aria-hidden: never part of the button's name */
.prompt.off > .vis { color: var(--unlit); text-shadow: none; }
.prompt.dark > .vis { color: var(--unlit) !important; text-shadow: none !important; }   /* dark beat: power cut */
.prompt:focus { outline: none; }
.prompt:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }
.prompt[aria-disabled="true"] { cursor: default; }

footer { text-align: center; max-width: 60ch; justify-self: center; }
footer p + p { margin-top: 2px; }
.maker  { color: var(--credit-hi); text-transform: uppercase; letter-spacing: .14em; font-weight: 700; font-size: .92em; }
.slogan { color: var(--credit); }
.legal  { color: var(--credit-lo); }

/* the operator's attract switch (WCAG 2.2.2): holds every lamp steady for this viewer */
.switch {
  display: inline-flex; align-items: center; gap: .6em;
  min-height: 44px; padding: 0 12px; margin-top: 4px;
  font: 700 .92em/1 "Helvetica Neue", Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase;
  color: var(--credit-hi); background: none; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.switch .lamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--unlit); box-shadow: inset 0 0 0 1px #5a1a12;
}
.switch[aria-pressed="true"] .lamp { background: var(--amber); box-shadow: 0 0 6px rgba(255, 173, 20, .7); }
.switch:focus { outline: none; }
.switch:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.no-js .switch { display: none; }

@media (max-width: 479px) { .slogan span { display: block; } }

/* short landscape phones: let the page scroll a little rather than shrink the glass to a stamp */
@media (max-height: 500px) and (orientation: landscape) {
  body { height: auto; grid-template-rows: 420px auto; }
}

@media (prefers-reduced-motion: reduce) {
  .prompt.off > .vis { color: var(--red); text-shadow: 0 0 .35em rgba(255, 43, 28, .55); }
}
