/* ============================================================
   HATCH — Monarch / Highland Cyberpunk theme
   Loaded only when HATCH_THEME=cyberpunk. Built for a Raspberry Pi 2
   (CPU-rendered Chromium): static art, no blur/backdrop-filter/canvas,
   the only animation is the emblem's stepped wing flutter.
   ============================================================ */

:root {
  --bg:           #0e0818;
  --bg-2:         #171027;
  --bg-3:         #1f1636;
  --bg-4:         #291d45;
  --border:       #3a2a5e;
  --border-bright:#6a4bb0;

  --text:         #f6eef9;
  --text-muted:   #b9a8d6;
  --text-dim:     #6f5f92;

  --accent:       #ff8a1f;          /* monarch orange */
  --accent-glow:  rgba(255,138,31,0.28);
  --accent-dim:   #a35410;

  --neon-cyan:    #2be6ff;
  --neon-pink:    #ff2e93;
  --fur:          #c4541e;
  --horn:         #efe0bd;

  --rainstorm:    #0e0818;
  --ng:           #171027;
  --ng-dark:      #3a2a5e;
  --surface-text: #f6eef9;
  --surface-muted:#b9a8d6;
  --page-text:    #f6eef9;
  --page-muted:   #b9a8d6;
  --kid-color:    #ff8a1f;
  --shadow:       0 4px 24px rgba(0,0,0,0.55);
  --shadow-sm:    0 2px 10px rgba(0,0,0,0.4);
  --radius:       6px;
  --radius-sm:    4px;
}

/* ── Background: ink violet, one orange dawn, magenta-tinted grid, grid floor ── */
body.theme-cyber {
  background:
    radial-gradient(900px 360px at 50% -60px, rgba(255,138,31,0.20), transparent 70%),
    var(--bg);
}
.theme-cyber::before {
  background-image:
    linear-gradient(rgba(255,46,147,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,46,147,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}
.theme-cyber::after {           /* static perspective grid floor (one SVG, painted once) */
  content: '';
  position: fixed; left: 0; right: 0; bottom: 0; height: 42vh;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1080 640' preserveAspectRatio='none'%3E%3Cdefs%3E%3ClinearGradient id='f' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ff2e93' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23ff2e93' stop-opacity='.55'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg stroke='url(%23f)' stroke-width='1.6' fill='none'%3E%3Cpath d='M0 0H1080M0 40H1080M0 100H1080M0 180H1080M0 290H1080M0 440H1080M0 640H1080'/%3E%3Cpath d='M540 0L-1400 640M540 0L-820 640M540 0L-420 640M540 0L-150 640M540 0L120 640M540 0L330 640M540 0L540 640M540 0L750 640M540 0L960 640M540 0L1230 640M540 0L1500 640M540 0L1900 640M540 0L2480 640'/%3E%3C/g%3E%3C/svg%3E") center bottom / 100% 100% no-repeat;
  pointer-events: none;
  z-index: -2;
  opacity: .55;
}

/* ── Header: emblem + chromatic wordmark ── */
.theme-cyber .hatch-header { padding: 8px 4px 10px; border-bottom-color: var(--border-bright); }
.theme-cyber .hatch-header::after {
  width: 220px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--neon-pink), var(--accent), var(--neon-cyan), transparent);
}
.theme-cyber .header-brand { flex-direction: row; align-items: center; gap: 18px; }
.theme-cyber .header-title-wrap { align-items: flex-start; }
.theme-cyber .header-title {
  font-family: "Chakra Petch", "Nunito", sans-serif;
  font-size: 3.4rem; font-weight: 700; letter-spacing: 10px;
  color: var(--text);
  text-shadow: 3px 0 0 rgba(255,46,147,0.65), -3px 0 0 rgba(43,230,255,0.55), 0 0 22px rgba(255,138,31,0.55);
}
.theme-cyber .header-slogan { color: var(--neon-cyan); letter-spacing: 0.16em; }
.emblem { width: 210px; height: auto; flex: none; display: block; }
.emblem .wing-anim { transform-origin: 120px 80px; }
.emblem .wing-l { animation: wingFlap 2.4s steps(1, end) infinite; }
.emblem .wing-r { animation: wingFlap 2.4s steps(1, end) infinite; }
@keyframes wingFlap {
  0%   { transform: scaleX(1); }
  25%  { transform: scaleX(0.92); }
  50%  { transform: scaleX(0.82); }
  75%  { transform: scaleX(0.92); }
}

/* ── Chamfered panels (top-right + bottom-left corner cut), thin neon edge ── */
.theme-cyber .kid-card,
.theme-cyber .sidebar-card,
.theme-cyber .cal-card,
.theme-cyber .super-chore-card,
.theme-cyber .weather-block,
.theme-cyber .report-card {
  border-radius: 4px;
  border-color: var(--border-bright);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.theme-cyber .kid-card { background: var(--bg-2); box-shadow: none; }
.theme-cyber .kid-card:hover { box-shadow: none; }
.theme-cyber .kid-name { font-family: "Chakra Petch", "Nunito", sans-serif; font-weight: 700; letter-spacing: 0.04em; }
.theme-cyber .sidebar-card-title,
.theme-cyber .cal-month-label,
.theme-cyber .weather-block-title { font-family: "Chakra Petch", "Nunito", sans-serif; letter-spacing: 0.06em; }

/* ── Tabs ── */
.theme-cyber .tab-btn {
  font-family: "Chakra Petch", "Nunito", sans-serif; font-weight: 600; letter-spacing: 0.04em;
  border-radius: 3px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.theme-cyber .tab-btn.active { border-color: var(--accent); color: var(--accent); background: var(--bg-3); }

/* ── Chores: neon rail in each kid's colour ── */
.theme-cyber .chore-item { border-radius: 3px; border-left: 3px solid var(--kid-color); }
.theme-cyber .kid-score-badge { border-radius: 3px; }

/* ── Super chores: keep the gold, drop the infinite shimmer (Pi budget) ── */
.theme-cyber .super-chore-card::before,
.theme-cyber .super-chore-card::after { animation: none; }

/* ── Header buttons ── */
.theme-cyber .header-admin-btn { border-radius: 3px; border-color: var(--border-bright); color: var(--neon-cyan); }
.theme-cyber .header-admin-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Outlets page ── */
.theme-cyber .op {
  --bg: #0e0818; --panel: #171027; --panel-edge: #6a4bb0; --lamp: #ff9a2e; --lamp-deep: #7a3d00;
  --off: #8b78b0; --text: #f6eef9; --muted: #b9a8d6; --warn: #ff5c8a;
}
.theme-cyber .op-title { font-family: "Chakra Petch", "Nunito", sans-serif; color: var(--accent); letter-spacing: 0.06em; }
.theme-cyber .plate { border-radius: 4px; box-shadow: none;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px)); }
.theme-cyber .plate-name { font-family: "Chakra Petch", "Nunito", sans-serif; letter-spacing: 0.05em; }
.theme-cyber .row { border-radius: 3px; }
.theme-cyber .row[data-state="on"] { box-shadow: none; border-color: var(--accent); }

@media (max-width: 720px) {
  .emblem { width: 110px; }
  .theme-cyber .header-title { font-size: 2.2rem; letter-spacing: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .emblem .wing-l, .emblem .wing-r { animation: none; }
}

/* ── Chore tokens: a chrysalis that hatches into a monarch (sprite, 5 frames) ──
   Frames: 0 chrysalis, 1 crack, 2 split, 3 emerging, 4 monarch. Plays once, on tap. */
.theme-cyber .chore-check {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 0; background-color: transparent;
  background-image: url("../img/hatch-sprite.svg");
  background-size: 500% 100%; background-repeat: no-repeat; background-position: 0 0;
  font-size: 0; color: transparent; transition: none;
}
.theme-cyber .chore-item.chore-done .chore-check { background-position: 100% 0; }
.theme-cyber .chore-check.hatching { animation: chrysalisHatch 0.75s steps(1, end) forwards; }
@keyframes chrysalisHatch {
  0%   { background-position: 25% 0; }
  20%  { background-position: 50% 0; }
  45%  { background-position: 75% 0; }
  70%, 100% { background-position: 100% 0; }
}
.theme-cyber .chore-item { min-height: 52px; gap: 10px; }
.theme-cyber .chore-item.chore-done { opacity: .62; }
.theme-cyber .chore-item.chore-done .chore-title { text-decoration: line-through; text-decoration-color: var(--kid-color); }
@media (prefers-reduced-motion: reduce) { .theme-cyber .chore-check.hatching { animation: none; } }
.theme-cyber .chore-item.chore-done { border-left: 3px solid var(--kid-color); }

/* ══ Scene: strolling highland cow + drifting monarchs (behind content) ══ */
.theme-cyber .op { background: transparent; }
.scene { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }

.cow-stroll {
  position: absolute; bottom: 3vh; right: -420px; width: 390px; height: 247px; opacity: .92;
  background: url("../img/cow-walk.svg") 0 0 / 200% 100% no-repeat;
  animation: cowStep 0.9s steps(1, end) infinite, cowWalk 130s steps(650, end) infinite;
}
@keyframes cowStep { 0% { background-position: 0 0; } 50% { background-position: 100% 0; } }
@keyframes cowWalk { from { transform: translateX(0); } to { transform: translateX(calc(-100vw - 840px)); } }

.mb {
  position: absolute; width: 48px; height: 48px; opacity: 0;
  background: url("../img/monarch-fly.svg") 0 0 / 300% 100% no-repeat;
  animation: mbFlap 0.8s steps(1, end) infinite, mbDrift var(--dur, 80s) steps(420, end) infinite;
  animation-delay: 0s, var(--delay, 0s);
}
@keyframes mbFlap { 0% { background-position: 0 0; } 25% { background-position: 50% 0; } 50% { background-position: 100% 0; } 75% { background-position: 50% 0; } }
@keyframes mbDrift {
  0%   { transform: translate(0, 0) rotate(var(--r, 0deg)); opacity: 0; }
  6%   { opacity: .9; }
  25%  { transform: translate(calc(var(--dx) * .25), calc(var(--dy) * .25 - 5vh)) rotate(var(--r, 0deg)); }
  50%  { transform: translate(calc(var(--dx) * .5),  calc(var(--dy) * .5 + 4vh))  rotate(var(--r, 0deg)); }
  75%  { transform: translate(calc(var(--dx) * .75), calc(var(--dy) * .75 - 4vh)) rotate(var(--r, 0deg)); }
  94%  { opacity: .9; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r, 0deg)); opacity: 0; }
}
.mb1 { left: 4vw;  top: 82vh; --dx: 70vw;  --dy: -55vh; --r: 50deg;   --dur: 75s;  --delay: 0s; }
.mb2 { left: 92vw; top: 70vh; --dx: -75vw; --dy: -45vh; --r: -55deg;  --dur: 90s;  --delay: -20s; }
.mb3 { left: 30vw; top: 95vh; --dx: 30vw;  --dy: -80vh; --r: 20deg;   --dur: 65s;  --delay: -40s; }
.mb4 { left: 96vw; top: 30vh; --dx: -85vw; --dy: 40vh;  --r: -120deg; --dur: 100s; --delay: -55s; }
.mb5 { left: 10vw; top: 40vh; --dx: 80vw;  --dy: 20vh;  --r: 100deg;  --dur: 85s;  --delay: -10s; }

/* ══ Header cow: visor scanner, flicker, ear twitch ══ */
.emblem .scan { animation: visorScan 3.4s steps(9, end) infinite alternate; }
@keyframes visorScan { from { transform: translateX(0); } to { transform: translateX(34px); } }
.emblem .visor { animation: visorFlicker 8s steps(1, end) infinite; }
@keyframes visorFlicker { 0%, 93% { opacity: 1; } 94% { opacity: .4; } 95% { opacity: 1; } 96% { opacity: .4; } 97%, 100% { opacity: 1; } }
.emblem .ear-l { transform-origin: 86px 74px; animation: earL 7s steps(1, end) infinite; }
.emblem .ear-r { transform-origin: 154px 74px; animation: earR 7s steps(1, end) infinite; animation-delay: 3.4s; }
@keyframes earL { 0%, 90% { transform: rotate(0); } 92% { transform: rotate(-16deg); } 94% { transform: rotate(5deg); } 96%, 100% { transform: rotate(0); } }
@keyframes earR { 0%, 90% { transform: rotate(0); } 92% { transform: rotate(16deg); } 94% { transform: rotate(-5deg); } 96%, 100% { transform: rotate(0); } }

/* ══ Chore-complete celebration: cow pops up and moos, monarchs flutter up ══ */
.cow-pop {
  position: absolute; left: 50%; bottom: 0; width: 252px; height: 174px; margin-left: -126px;
  background: url("../img/cow-moo.svg") 0 0 / 200% 100% no-repeat;
  animation: cowRise 1.7s steps(1, end) forwards, cowMoo 0.5s steps(1, end) 4 0.5s;
}
@keyframes cowRise {
  0% { transform: translateY(105%); } 8% { transform: translateY(65%); } 16% { transform: translateY(30%); } 24%, 80% { transform: translateY(0); }
  88% { transform: translateY(45%); } 100% { transform: translateY(105%); }
}
@keyframes cowMoo { 0% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.cow-bubble {
  position: absolute; left: 66%; top: -34px; white-space: nowrap;
  font-family: "Chakra Petch", "Nunito", sans-serif; font-weight: 700; font-size: 2.4rem; letter-spacing: 0.08em;
  color: var(--accent); text-shadow: 3px 0 0 rgba(255,46,147,0.7), -3px 0 0 rgba(43,230,255,0.6);
  opacity: 0; animation: bubbleIn 1.7s steps(1, end) forwards;
}
@keyframes bubbleIn { 0%, 27% { opacity: 0; } 28%, 78% { opacity: 1; } 80%, 100% { opacity: 0; } }
.mb-burst {
  position: absolute; bottom: 18vh; width: 34px; height: 34px; opacity: 0;
  background: url("../img/monarch-fly.svg") 0 0 / 300% 100% no-repeat;
  animation: mbFlap 0.6s steps(1, end) infinite, mbBurst 1.6s steps(14, end) forwards;
}
@keyframes mbBurst {
  0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: .95; }
  85% { opacity: .95; } 100% { transform: translate(var(--bx, 0), -55vh); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cow-stroll, .mb, .cow-pop, .cow-bubble, .mb-burst,
  .emblem .scan, .emblem .visor, .emblem .ear { animation: none; }
  .mb { opacity: .5; }
}
