/* face.css — alternative face look: round eye dots + animated mouth.
   Reuses state-keyframes.css for the eye / overlay / light animations
   and adds face-keyframes.css for the per-state mouth movement.
   Layout mirrors states.css so the gallery feels identical. */

:root {
  --spd: 1;                       /* global duration multiplier (face.js) */
  --g0: #fffefb;                  /* bright highlight / core (warm white) */
  --g1: #fff1d6;
  --g2: #ffdca6;
  --g3: #f3c587;
  --glow: 255, 224, 184;          /* outer bloom (rgb) — used by light feedback */
  --ish: 96, 58, 14;              /* dark ink for notepad lines */
  --acc: #ffd9a0;                 /* UI accent */
  --bg: #0a0d10;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(120% 120% at 50% 0%, #14181d 0%, #0a0d10 55%, #06080a 100%);
  color: #e7edf2;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Top bar / controls ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 18px;
  padding: 14px 22px;
  background: rgba(10, 13, 16, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1c2228;
}
.topbar h1 {
  font-size: 15px; font-weight: 650; margin: 0; letter-spacing: .2px;
  display: flex; align-items: center; gap: 9px;
}
.topbar h1 .dot-ico { width: 9px; height: 9px; border-radius: 50%; background: var(--acc); }
.alt-link {
  color: #aeb8c2; text-decoration: none; font-size: 12px;
  padding: 6px 12px; border: 1px solid #2a323a; border-radius: 9px;
}
.alt-link:hover { color: #fff; border-color: var(--acc); }
.ctrl { display: flex; align-items: center; gap: 8px; }
.ctrl label { color: #9aa6b1; font-size: 12px; white-space: nowrap; }
.ctrl input[type=range] { width: 150px; accent-color: var(--acc); }
.val { font-variant-numeric: tabular-nums; color: var(--acc); min-width: 52px; font-size: 12px; }
.btn {
  background: #161c22; color: #cdd6df; border: 1px solid #2a323a; border-radius: 9px;
  padding: 7px 14px; font-size: 12px; cursor: pointer;
}
.btn:hover { border-color: var(--acc); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- Power switch ---------- */
.power { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.power input { position: absolute; opacity: 0; width: 0; height: 0; }
.power .track {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: #2a323a; border: 1px solid #3a444e; transition: background .18s, border-color .18s;
}
.power .knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #cdd6df; transition: transform .18s, background .18s;
}
.power input:checked + .track { background: var(--acc); border-color: var(--acc); }
.power input:checked + .track .knob { transform: translateX(16px); background: #221604; }
.power .plabel { color: #9aa6b1; font-size: 12px; min-width: 22px; }
.power input:checked ~ .plabel { color: var(--acc); }

/* ---------- Lifecycle flow simulation ---------- */
.flow-btn.on { background: var(--acc); color: #221604; font-weight: 650; border-color: var(--acc); }
.hey-btn.on { background: #d97757; color: #1a0f0a; font-weight: 650; border-color: #d97757; }
.hey-btn.on::before { content: ""; }
.flowbar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 10px; padding: 7px 16px;
  background: #10171c; border: 1px solid rgba(var(--glow), .25); border-radius: 999px;
}
.flowbar[hidden] { display: none; }
.flowbar .phase { color: var(--acc); font-size: 13px; font-weight: 600; }
.flowbar .dotpulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--acc); flex: none;
  animation: fpulse 1.4s ease-in-out infinite;
}
@keyframes fpulse { 0%,100% { opacity: .4; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }

/* ---------- Layout: thumbnails flank the big visualization in the centre ---------- */
main { display: flex; flex-direction: row; align-items: flex-start; justify-content: center;
  gap: 26px; padding: 22px 22px 60px; max-width: 1400px; margin: 0 auto; }
/* fixed width = the stage, so long per-state descriptions wrap inside it instead of
   widening the centre column and shoving the side rails outward */
.featured { flex: 0 0 480px; width: 480px; display: flex; flex-direction: column; align-items: center;
  gap: 14px; position: sticky; top: 80px; }
.featured-meta { text-align: center; max-width: 480px; }
.featured-meta .fname { font-size: 16px; font-weight: 650; }
.featured-meta .finfo { margin: 16px auto 0; width: fit-content;
  display: flex; flex-direction: column; gap: 9px; text-align: left; }
.featured-meta .firow { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #9aa6b1; }
.featured-meta .firow b { color: #cdd6df; font-weight: 650; min-width: 46px; }
.featured-meta .firow .ic { width: 17px; height: 17px; flex: none; display: inline-flex; }
.featured-meta .firow .ic svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.featured-meta .firow.light .ic { color: var(--acc); }
.featured-meta .firow.sound .ic { color: #ffce7a; }
.featured-meta .firow.silent { color: #69727b; }
.featured-meta .firow.silent .ic { color: #69727b; }

.grid {
  flex: 0 0 auto;
  display: grid; gap: 9px; align-content: start;
  grid-template-columns: repeat(2, 114px);   /* a narrow 2-col column of thumbnails per side */
}
.grid-side { position: sticky; top: 80px; }
.sechead {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  font-size: 12px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase;
  color: #8b97a2;
  display: flex; align-items: center;
}
.card {
  align-self: start;                 /* don't stretch to the row's tallest card — keeps it compact */
  background: #0e1216; border: 1px solid #1c2228; border-radius: 13px;
  padding: 8px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #34404a; transform: translateY(-2px); }
.card.active { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), 0 10px 30px rgba(var(--glow), .12); }
.card .cname { font-weight: 600; margin-top: 7px; font-size: 12px; line-height: 1.2; }
.card .cmeta { color: #8b97a2; font-size: 10px; margin-top: 1px; }

.thumb { position: relative; width: 96px; height: 96px; overflow: visible; border-radius: 11px; }
.thumb .stage { position: absolute; top: 0; left: 0; transform-origin: top left; transform: scale(0.2); }

/* ---------- The 480x480 round stage — FLAT (no 3D shading) ----------
   A uniform dark disc; the eyes + mouth sit in front. No sphere gradient, no
   top sheen, no specular highlight, no volume shadows. The only glow is the
   functional ambient light-feedback ring (lume) — not a 3D highlight. */
.stage {
  position: relative;
  width: 480px; height: 480px;
  display: flex; align-items: center; justify-content: center;
  background: #0c1318;                /* flat — single uniform fill */
  overflow: hidden;
  --lumeRGB: var(--glow);             /* default warm light (unchanged) */
  --lumeLevel: 0;
  box-shadow: 0 0 44px 6px rgba(var(--lumeRGB), var(--lumeLevel));  /* ambient light feedback only */
}
.stage.round { border-radius: 50%; }

/* ---------- The face: round eyes + smile mouth ----------
   - .face groups eyes + mouth so they sit together (eyes on top, mouth below)
   - .eyes / .eye / .dot mirror the states.html structure so state-keyframes.css
     animations (blink, drift, breath, wink, ...) apply unchanged
   - .mouth has two shapes: a smile arc (default) + an oval "open mouth"
     (used by face-keyframes.css to make the mouth move per state) */
.face {
  display: flex; flex-direction: column; align-items: center; gap: 36px;
  position: relative; z-index: 1;
  /* the face sits dead-centre by default; face.js lifts it (inline `top`) only for
     listening and tweens it back to centre fluidly via the Web Animations API */
  top: 0;
  /* fade the whole face in/out for a fluid hand-off to the clock (and back) */
  opacity: 1;
  transition: opacity 380ms ease;
}

.eyes {
  display: flex; align-items: center; gap: 86px;
  transform-origin: center center;
}
.eye {
  width: 60px; height: 60px;
  transform-origin: center center;
}
.dot {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--g0);
  transform-origin: center center;
  will-change: transform, opacity;
}

.mouth {
  position: relative; width: 220px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  transform-origin: center center;
}
.mouth .smile {
  width: 100%; height: 100%; display: block;
  overflow: visible;                 /* never clip the mouth arc (e.g. the wide thinking arc) */
  transform-origin: center center;
}
.mouth .smile path {
  fill: none; stroke: var(--g0); stroke-width: 16;
  stroke-linecap: round; stroke-linejoin: round;
}
.mouth .open {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 64px; border-radius: 50%;
  background: var(--g0);
  transform: translate(-50%, -50%) scaleY(.4);
  transform-origin: center center;
  opacity: 0;
}

/* ---------- Clock overlay (A4_clock) — crossfades in over the fading face ---------- */
.clock {
  display: flex; opacity: 0; pointer-events: none;
  transition: opacity 380ms ease;
  position: absolute; inset: 0; z-index: 2;
  align-items: center; justify-content: center; gap: 8px;
  color: var(--g0);
}
.clock b {
  display: inline-block;
  font: 800 104px/1 ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Quicksand", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  transform: scaleY(1.5) scaleX(0.92);
  transform-origin: center center;
}
.clock .cl { opacity: 1; transform: scaleY(1.18); }

/* ---------- Listening overlay: notepad + writing hand (B2_listening) ---------- */
.notes {
  display: none;
  position: absolute; left: 50%; margin-left: -61px; bottom: 36px; z-index: 2;
  width: 122px; height: 104px;
}
.notes .pad {
  position: absolute; inset: 0; border-radius: 13px; z-index: 2;
  background: #eaf6f3;
}
.notes .ring {
  position: absolute; right: -6px; width: 16px; height: 7px; border-radius: 4px;
  background: var(--g2);
}
.notes .ring.r1 { top: 15px; } .notes .ring.r2 { top: 39px; }
.notes .ring.r3 { top: 63px; } .notes .ring.r4 { top: 84px; }
/* the written lines — no hand; they draw themselves in from the bottom up */
.notes .ln {
  position: absolute; left: 16px; height: 5px; border-radius: 3px;
  background: rgba(var(--ish), .22);
  transform-origin: left center;
}
.notes .ln.l1 { top: 22px; width: 60%; }
.notes .ln.l2 { top: 40px; width: 70%; }
.notes .ln.l3 { top: 58px; width: 52%; }
.notes .ln.l4 { top: 76px; width: 46%; }
/* the pen — writes each line then steps up (penWrite in state-keyframes.css) */
.notes .pen {
  position: absolute; z-index: 3;          /* above the pad (z 2) */
  left: 12px; top: 26px; width: 6px; height: 50px;
  border-radius: 3px; background: #241f1b;
  transform-origin: bottom center;
}
.notes .pen::after {                        /* nib at the bottom = writing tip */
  content: ""; position: absolute; left: 0; bottom: -5px; width: 5px; height: 6px;
  background: #241f1b; border-radius: 0 0 3px 3px;
}

/* ---------- Confirm check overlay (C1_confirm) ---------- */
.check {
  display: none;
  position: absolute; inset: 0; z-index: 2;
  align-items: center; justify-content: center;
}
.check svg { width: 210px; height: 210px; overflow: visible; }
.check path {
  fill: none; stroke: var(--g0); stroke-width: 15;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 80; stroke-dashoffset: 80;
}

/* ---------- Reminder bell overlay (D1_reminder) ---------- */
.bell {
  display: none;
  position: absolute; inset: 0; z-index: 2;
  align-items: center; justify-content: center;
}
.bell svg {
  width: 156px; height: 156px;
  transform-origin: 50% 16%;
}
.bell svg path { fill: var(--g0); }

/* ---------- Ambient light feedback (same as states.css) ---------- */
@property --lumeLevel {
  syntax: "<number>"; initial-value: 0; inherits: false;
}
/* only the formerly-blue light changes: listening / wake word now use a warm neutral
   Claude-logo orange instead of the cool blue (all other states keep their light) */
.st-B2_listening, .st-D2_wakeword { --lumeRGB: 217, 119, 87; }

.stage .eyes, .stage .eye, .stage .dot,
.stage .mouth, .stage .smile, .stage .open {
  animation-fill-mode: both;
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .stage .eyes, .stage .eye, .stage .dot,
  .stage .mouth, .stage .smile, .stage .open,
  .stage .notes, .stage .notes * { animation: none !important; }
  .st-E4_wink .eye.right .dot { transform: scaleY(.07); }
}
