/* TV Home — Hogwarts night theme ("Castle Home"). 10-foot UI, 1920x1080.
   Palette: deep navy night, candlelight gold #d4a437, parchment cream.
   Animations are transform/opacity only, and all respect
   prefers-reduced-motion — the Fire Stick is weak, so nothing heavy. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { background: #05070f; }
body {
  background: transparent;
  color: #f3ead3;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
/* Castle backdrop: fixed, slowly drifting (gentle camera move). */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: #05070f url("assets/castle-night.jpg") center 38% / cover no-repeat;
  transform: scale(1.06);
  animation: castleDrift 90s ease-in-out infinite alternate;
}
@keyframes castleDrift {
  from { transform: scale(1.06) translateX(-1.2%); }
  to   { transform: scale(1.06) translateX(1.2%); }
}
/* Readability veil: keeps white/gold text legible over the painting. */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5,7,15,.42) 0%, rgba(5,7,15,.18) 34%, rgba(5,7,15,.30) 68%, rgba(5,7,15,.62) 100%);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- Atmosphere: twinkling stars + drifting mist (CSS only) ---------- */
.fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
/* Stars: tiny radial-gradient dots, one layer gently breathing. */
.fx::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 8% 12%, rgba(255,255,255,.95), transparent 60%),
    radial-gradient(1.2px 1.2px at 22% 30%, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(1.8px 1.8px at 36% 8%, rgba(255,244,214,.9), transparent 60%),
    radial-gradient(1.2px 1.2px at 47% 22%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 6%, rgba(255,255,255,.85), transparent 60%),
    radial-gradient(1.1px 1.1px at 68% 18%, rgba(255,244,214,.75), transparent 60%),
    radial-gradient(1.7px 1.7px at 82% 10%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(1.2px 1.2px at 93% 26%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 15% 48%, rgba(255,255,255,.65), transparent 60%),
    radial-gradient(1.1px 1.1px at 30% 42%, rgba(255,244,214,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 76% 38%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 5% 62%, rgba(255,255,255,.55), transparent 60%);
  animation: starTwinkle 6s ease-in-out infinite alternate;
}
@keyframes starTwinkle {
  from { opacity: .45; }
  to   { opacity: .95; }
}
/* Mist: two soft banks drifting low over the lake. */
.fx::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 55% 16% at 22% 84%, rgba(178,198,228,.12), transparent 70%),
    radial-gradient(ellipse 48% 14% at 74% 88%, rgba(178,198,228,.10), transparent 70%);
  animation: mistDrift 55s ease-in-out infinite alternate;
}
@keyframes mistDrift {
  from { transform: translateX(-3%); }
  to   { transform: translateX(3%); }
}

/* ---------- Hedwig — the snowy owl that hops between tiles ---------- */
#hedwig {
  position: absolute; width: 84px; z-index: 3; pointer-events: none;
  left: 0; top: 0; opacity: 0;
  transition: left .38s cubic-bezier(.34, 1.45, .64, 1), top .38s cubic-bezier(.34, 1.45, .64, 1), opacity .3s ease;
  filter: drop-shadow(0 5px 9px rgba(0,0,0,.55));
}
#hedwig.on { opacity: 1; }
#hedwig .owl-hop { display: block; }
#hedwig.hop .owl-hop { animation: owlHop .38s ease; }
@keyframes owlHop {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-18px); }
  100% { transform: translateY(0); }
}
#hedwig svg { display: block; width: 100%; height: auto; transform-origin: 50% 92%;
  animation: owlPerch 3.4s ease-in-out infinite; }
@keyframes owlPerch {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg) translateY(-1px); }
}

/* ---------- Home ---------- */
.home { min-height: 100vh; padding: 40px 56px 28px; display: flex; flex-direction: column; position: relative; z-index: 1; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 40px; }
.clock {
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  font-size: 96px; font-weight: 700; line-height: 1; letter-spacing: -2px;
  color: #f6efdc; text-shadow: 0 2px 22px rgba(0,0,0,.75);
}
.date { font-size: 30px; color: #cfc4a4; margin-top: 10px; text-shadow: 0 2px 14px rgba(0,0,0,.7); }
.weather { text-align: right; min-width: 380px; text-shadow: 0 2px 14px rgba(0,0,0,.7); }
.wx-now { display: flex; align-items: baseline; justify-content: flex-end; gap: 14px; }
.wx-glyph { font-size: 56px; }
.wx-temp { font-size: 72px; font-weight: 700; line-height: 1; color: #f6efdc; }
.wx-sub { font-size: 24px; color: #cfc4a4; margin-top: 6px; }
.wx-days { display: flex; gap: 22px; justify-content: flex-end; margin-top: 14px; font-size: 21px; color: #cfc4a4; }
.wx-days span b { color: #f6efdc; }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 26px;
  margin-top: 44px;
  align-content: center;
}
/* Super-minimal tiles: dark glass, thin candlelight-gold frame, gold glyph. */
.tile {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  min-height: 210px; padding: 28px 30px; border-radius: 22px;
  background: rgba(13, 19, 34, .78); border: 2px solid rgba(212, 164, 55, .38);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
  cursor: pointer;
}
.tile-glyph { font-size: 54px; line-height: 1; margin-bottom: 16px; color: #d4a437; }
.tile-name {
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  font-size: 36px; font-weight: 700; line-height: 1.15; color: #f6efdc;
}
.tile-sub { font-size: 22px; color: #b8ad8d; margin-top: 8px; }
/* Visible focus: candlelight-gold ring + a soft flickering glow. */
.tile:focus, .tile:focus-visible, .tile.focused,
.pill:focus, .pill:focus-visible, .pill.focused,
.btn:focus, .btn:focus-visible, .btn.focused {
  outline: none;
  border-color: #d4a437;
  box-shadow: 0 0 0 5px rgba(212, 164, 55, .45), 0 0 34px rgba(212, 164, 55, .28);
  transform: scale(1.04);
  z-index: 2;
}
.tile:focus, .tile:focus-visible, .tile.focused {
  background: rgba(24, 30, 50, .88);
  animation: candleFlicker 2.6s ease-in-out infinite;
}
@keyframes candleFlicker {
  0%, 100% { box-shadow: 0 0 0 5px rgba(212, 164, 55, .45), 0 0 34px rgba(212, 164, 55, .30); }
  50%      { box-shadow: 0 0 0 5px rgba(212, 164, 55, .45), 0 0 22px rgba(212, 164, 55, .16); }
}
.hint { text-align: center; color: #9a8f6f; font-size: 20px; margin-top: 34px; text-shadow: 0 2px 10px rgba(0,0,0,.7); }

/* ---------- Shared sub-pages ---------- */
.page { min-height: 100vh; padding: 36px 56px 28px; display: flex; flex-direction: column; position: relative; z-index: 1; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.page-title {
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  font-size: 52px; font-weight: 700; color: #f6efdc; text-shadow: 0 2px 18px rgba(0,0,0,.75);
}
.back-link {
  display: inline-block; font-size: 26px; padding: 12px 26px; border-radius: 999px;
  background: rgba(13, 19, 34, .8); border: 2px solid rgba(212, 164, 55, .4); color: #f3ead3;
}
.btn {
  font-size: 28px; font-weight: 700; padding: 16px 34px; border-radius: 999px;
  background: #d4a437; color: #1a1408; border: 3px solid transparent; cursor: pointer;
}
.btn.ghost { background: rgba(13, 19, 34, .8); color: #f3ead3; border-color: rgba(212, 164, 55, .4); }
.pill {
  font-size: 26px; padding: 14px 26px; border-radius: 999px; cursor: pointer;
  background: rgba(13, 19, 34, .8); border: 2px solid rgba(212, 164, 55, .4); color: #f3ead3;
}
.pill[aria-pressed="true"] { background: #d4a437; color: #1a1408; border-color: #d4a437; }
.status-pill { font-size: 22px; padding: 10px 20px; border-radius: 999px; background: rgba(51, 61, 78, .85); color: #f3ead3; }
.status-pill.live { background: #14532d; }
.status-pill.offline { background: #7c2d12; }

/* ---------- Drawing board ---------- */
/* #drawPage gets a definite height (not just min-height): without it the
   <canvas> falls back to its intrinsic 2:1 aspect ratio and pushes the
   toolbar below the fold. */
#drawPage { height: 100vh; }
.board-wrap { flex: 1; display: flex; flex-direction: column; gap: 12px; margin-top: 14px; min-height: 0; }
#board {
  flex: 1; width: 100%; min-height: 320px;
  background: rgba(13, 18, 30, .88); border: 2px solid rgba(212, 164, 55, .4); border-radius: 18px;
  touch-action: none; cursor: crosshair;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.toolbar .swatch {
  width: 56px; height: 56px; border-radius: 50%; border: 4px solid transparent; cursor: pointer;
}
.toolbar .swatch[aria-pressed="true"] { border-color: #d4a437; transform: scale(1.12); }
.toolbar .spacer { flex: 1; }
.kiosk-hint { font-size: 24px; color: #cfc4a4; text-align: center; padding: 10px 0 2px; text-shadow: 0 2px 10px rgba(0,0,0,.7); }
.kiosk-hint b { color: #d4a437; }
body.kiosk .toolbar { display: none; }

/* ---------- Movie picker ---------- */
.pick-groups { display: flex; flex-direction: column; gap: 30px; margin-top: 30px; }
.pick-group h2 { font-size: 28px; color: #cfc4a4; margin-bottom: 14px; text-shadow: 0 2px 10px rgba(0,0,0,.7); }
.pick-row { display: flex; flex-wrap: wrap; gap: 14px; }
.pick-actions { display: flex; gap: 18px; margin-top: 36px; align-items: center; }
.result { margin-top: 36px; background: rgba(13, 19, 34, .82); border: 2px solid rgba(212, 164, 55, .45); border-radius: 22px; padding: 30px 34px; }
.result .r-label { font-size: 22px; color: #b8ad8d; text-transform: uppercase; letter-spacing: 2px; }
.result .r-title {
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  font-size: 56px; font-weight: 700; margin-top: 8px; color: #f6efdc;
}
.result .r-meta { font-size: 26px; color: #cfc4a4; margin-top: 10px; }
.result .r-why { font-size: 24px; margin-top: 14px; line-height: 1.5; }
.alts { display: flex; gap: 18px; margin-top: 26px; flex-wrap: wrap; }
.alt {
  flex: 1; min-width: 280px; background: rgba(10, 14, 26, .85); border: 2px solid rgba(212, 164, 55, .35);
  border-radius: 16px; padding: 20px 24px; cursor: pointer; text-align: left;
}
.alt .a-title { font-size: 28px; font-weight: 700; color: #f6efdc; }
.alt .a-meta { font-size: 21px; color: #b8ad8d; margin-top: 6px; }
.rules-note { margin-top: 14px; font-size: 20px; color: #9a8f6f; line-height: 1.5; max-width: 1100px; }
.error-note { margin-top: 20px; font-size: 22px; color: #f0a35e; }

@media (max-width: 1100px) {
  .home, .page { padding: 24px 28px 18px; }
  .clock { font-size: 64px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .tile { min-height: 170px; }
  .tile-name { font-size: 28px; }
  .weather { min-width: 0; }
  .wx-temp { font-size: 52px; }
  #hedwig { width: 60px; }
}
/* On shorter screens the draw page's explainer note hides so the toolbar
   (the part you actually tap) always fits without scrolling. */
@media (max-height: 1150px) {
  #drawPage .rules-note { display: none; }
}

/* ---------- Reduced motion: still image, no drift, twinkle, mist or hops ---------- */
@media (prefers-reduced-motion: reduce) {
  body::before, .fx::before, .fx::after, #hedwig svg, .tile:focus, .tile:focus-visible, .tile.focused {
    animation: none !important;
  }
  #hedwig { transition: none; }
}
