/* The live demo (/demo/) only: the TV drawn in CSS, the remote and the code.
   Loaded by that page alone (page.styles), so no other page downloads it.
   Uses the site's tokens from site.css (navy, blue, cyan, lamp, fonts). */

.demo-wrap {
  width: min(100% - 2 * var(--gutter), 92rem);
  margin-inline: auto;
}

.demo-head { padding-block: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 2vw, 1.5rem); }
.demo-head h1 { font-size: var(--step-3); max-width: 30ch; margin-bottom: 0.3em; }
.demo-head .lead { max-width: 80ch; margin-bottom: 0; font-size: var(--step-0); }

.demo { padding-bottom: clamp(2rem, 5vw, 4rem); }


/* ---------- Stage: the TV and the remote ---------- */

.demo-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  justify-items: center;
}
@media (min-width: 48rem) {
  .demo-stage { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: clamp(1rem, 2vw, 1.75rem); }
}

.demo-tv {
  margin: 0;
  width: 100%;
  /* Keep the whole TV in view on short screens. */
  max-width: calc((100vh - 8rem) * 16 / 9);
}

/* The set: a slim dark bezel with the logo's blue-to-cyan edge, like the hero TV. */
.demo-tv-set {
  position: relative;
  padding: clamp(6px, 1vw, 14px) clamp(6px, 1vw, 14px) 0;
  border-radius: clamp(12px, 1.6vw, 22px);
  background: linear-gradient(160deg, #18294a 0%, #0a1428 55%, #070f20 100%);
  box-shadow:
    0 0 0 clamp(2px, 0.3vw, 3px) var(--blue),
    0 0 0 clamp(3px, 0.45vw, 5px) color-mix(in oklch, var(--cyan) 70%, transparent),
    0 30px 60px -20px oklch(0.1 0.04 262 / 0.9),
    0 0 120px -30px color-mix(in oklch, var(--cyan) 35%, transparent);
}
.demo-tv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: clamp(4px, 0.6vw, 8px);
  background: #000;
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.06);
}
.demo-tv-screen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--navy);
}
.demo-tv-screen:focus-within { outline: 3px solid var(--lamp); outline-offset: 2px; }
.demo-noscript { position: absolute; inset: 0; display: grid; place-items: center; padding: 1.5rem; margin: 0; text-align: center; max-width: none; }
.demo-tv-chin {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(18px, 2.4vw, 32px);
}
.demo-tv-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(0.55rem, 0.9vw, 0.8rem);
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.demo-tv-led {
  position: absolute;
  right: 4%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 0 8px var(--lamp);
}
.demo-tv-stand {
  position: relative;
  width: 28%;
  height: clamp(14px, 2.2vw, 30px);
  margin: 0 auto;
  background: linear-gradient(#0d1a33, #08122a);
  clip-path: polygon(38% 0, 62% 0, 70% 100%, 30% 100%);
}
.demo-tv-stand::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  border-radius: 99px;
  background: #0f1d38;
}
.demo-tv figcaption {
  margin-top: 0.6rem;
  text-align: center;
  font-size: var(--step--1);
  color: var(--ink-3);
  max-width: none;
}

/* ---------- The remote ---------- */

.remote {
  --key: clamp(2.6rem, 9vw, 3.1rem);
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: 28px;
  background: linear-gradient(180deg, #1b2c4d, #0c1830);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.08), 0 18px 40px -16px oklch(0.08 0.04 262 / 0.9);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
@media (min-width: 48rem) {
  .remote { flex-direction: column; padding: 1.4rem 1rem 1.2rem; border-radius: 40px; gap: 1.1rem; }
}
.remote-ir { width: 10px; height: 10px; border-radius: 50%; background: #3a1d24; box-shadow: inset 0 0 0 2px #00000055; }
.remote-dpad {
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  grid-template-rows: repeat(3, var(--key));
  padding: 0.35rem;
  border-radius: 50%;
  background: #091327;
  box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.06);
}
.remote button {
  appearance: none;
  display: grid;
  place-items: center;
  border: 0;
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s, transform 0.12s;
}
/* Hover only where there is a real pointer: on a phone a tapped button would stay lit. */
@media (hover: hover) {
  .remote button:hover { background: oklch(1 0 0 / 0.07); }
}
.remote button.is-down, .remote button:active { transform: scale(0.94); background: color-mix(in oklch, var(--blue) 40%, transparent); }
.remote-up { grid-area: 1 / 2; }
.remote-left { grid-area: 2 / 1; }
.remote-ok {
  grid-area: 2 / 2;
  border-radius: 50% !important;
  background: var(--blue) !important;
  color: var(--navy) !important;
  font-family: var(--font-display) !important;
  font-weight: 800 !important;
  font-size: 0.95rem !important;
}
.remote-ok.is-down, .remote-ok:active { background: var(--cyan) !important; }
.remote-right { grid-area: 2 / 3; }
.remote-down { grid-area: 3 / 2; }
.remote-back {
  display: flex !important;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem !important;
  border-radius: 999px !important;
  background: oklch(1 0 0 / 0.08) !important;
  font-weight: 700 !important;
  font-size: var(--step--1) !important;
}
.remote-back.is-down, .remote-back:active { background: color-mix(in oklch, var(--blue) 40%, transparent) !important; }
.remote-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
@media (max-width: 47.99rem) {
  .remote-ir, .remote-brand { display: none; }
}
/* The color keys open the game's developer menu: only with ?dev=1 (page.js unhides them). */
.remote-colors { display: flex; gap: 0.45rem; }
.remote-colors[hidden], .demo-dev-note[hidden] { display: none; }
.remote-colors button {
  width: 1.9rem;
  height: 1.1rem;
  border-radius: 999px !important;
  box-shadow: inset 0 -2px 0 #00000055;
}
.remote-red { background: #e5484d !important; }
.remote-green { background: #30a46c !important; }
.remote-yellow { background: #f6c453 !important; }
.remote-blue { background: var(--blue) !important; }
.remote-colors button.is-down, .remote-colors button:active { filter: brightness(1.25); }

/* ---------- The code and the notes ---------- */

.demo-notes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}
@media (min-width: 64rem) {
  .demo-notes-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
}
.demo-notes h2 { font-size: var(--step-2); }
.demo-notes .ticks { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .remote button { transition: none; }
}
