/* face_rec/docs/css/demo.css */

html { height: 100%; }
body { min-height: 100vh; }

[hidden] { display: none !important; }

/* Substate visibility — data-state on <body> reveals matching atelier block */
.atelier > [data-show-state] { display: none; }
body[data-state="pre-camera"] .atelier > [data-show-state="pre-camera"],
body[data-state="loading"]    .atelier > [data-show-state="pre-camera"],
body[data-state="reading"]    .atelier > [data-show-state="reading"],
body[data-state="live"]       .atelier > [data-show-state="live"],
body[data-state="error"]      .atelier > [data-show-state="error"] { display: block; }

/* Loading veil over the stage frame */
.stage__veil { opacity: 0; pointer-events: none; transition: opacity 250ms ease; }
body[data-state="loading"] .stage__veil { opacity: 1; }
body[data-state="error"]   .stage__veil { opacity: 1; }

/* Stage layers — placeholder visible only pre-camera, video from loading onward */
.stage__placeholder { opacity: 1; }
.stage__video       { opacity: 0; }
.stage__canvas      { opacity: 0; display: none; }
body[data-state="loading"] .stage__placeholder,
body[data-state="reading"] .stage__placeholder,
body[data-state="live"]    .stage__placeholder { opacity: 0; }
body[data-state="loading"] .stage__video,
body[data-state="reading"] .stage__video,
body[data-state="live"]    .stage__video { opacity: 1; }

/* ── Body / page ─────────────────────────────────────────────────────── */
.demo-body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── Nav (cream zone) ────────────────────────────────────────────────── */
.demo-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.demo-nav__logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.demo-nav__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--purple);
}
.demo-nav__back {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: color 0.2s;
}
.demo-nav__back:hover { color: var(--text); }

/* ── Two-column grid ─────────────────────────────────────────────────── */
.demo-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.63fr) minmax(0, 1fr);   /* ~62/38 */
  gap: 0;
  background: var(--bg);
  min-height: 0;
}

/* ── Stage (left) — the cinematic frame ──────────────────────────────── */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 60px 60px 60px;
  background: var(--bg);
}
.stage__frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 5;
  border-radius: 18px;
  border: 1px solid oklch(60% 0.14 35 / 0.22);
  box-shadow: 0 24px 64px oklch(22% 0.04 60 / 0.12);
  overflow: hidden;
  background: oklch(20% 0.012 50);   /* coal — the only coal on the page */
}
.stage__placeholder,
.stage__video,
.stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1);
}
.stage__placeholder { object-fit: cover; }
.stage__video       { object-fit: cover; transform: scaleX(-1); }
.stage__canvas      { object-fit: cover; pointer-events: none; transform: scaleX(-1); }

/* Veil — text overlay (loading, no-face, error) */
.stage__veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(20% 0.012 50 / 0.72);
  z-index: 2;
}
.stage__veil-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: oklch(94% 0.014 75);
}
.stage__veil-text[hidden] { display: none; }

/* ── Atelier panel (right) ───────────────────────────────────────────── */
.atelier {
  padding: 60px 60px 60px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 520px;
}
.atelier__eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.atelier__eyebrow--accent { color: var(--purple-strong); }
.atelier__eyebrow--muted  { color: var(--text-3); letter-spacing: 0.10em; font-size: 12px; margin-bottom: 8px; }

/* Pre-camera intro */
.atelier__intro-h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 4.4vw, 56px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0 0 24px 0;
}
.atelier__intro-body {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-2);
  max-width: 42ch;
  margin-bottom: 36px;
}
.atelier__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 14px 28px;
  border-radius: 8px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.atelier__cta:hover { opacity: 0.88; transform: translateY(-1px); }
.atelier__permission-note {
  font-size: 13px;
  color: var(--purple-strong);
  margin-top: 12px;
  max-width: 38ch;
  line-height: 1.5;
}

/* Reading state */
.reading-line {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.reading-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
}
.reading-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--purple-strong);
  opacity: 0.3;
  animation: dot-breathe 1.4s ease-in-out infinite;
}
.reading-dots span:nth-child(2) { animation-delay: 0.18s; }
.reading-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot-breathe {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 1.0; transform: translateY(-2px); }
}

/* Live state — result shape */
.result__shape {
  font-family: var(--font-display);
  font-size: clamp(40px, 5.2vw, 64px);
  font-weight: 500;
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 28px 0;
}
.result__shape em {
  font-style: italic;
  font-weight: 500;
  color: var(--purple-strong);
  transition: color 250ms ease;
}
.result__shape.low-confidence em { color: var(--text-3); }

/* Stylist card */
.stylist-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px 18px;
  margin-bottom: 14px;
}
.stylist-card__note {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 18px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 14px 0;
}
.stylist-card__confidence {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.stylist-card__confidence span {
  color: var(--purple-strong);
  font-weight: 600;
}

/* Re-read link */
.reread-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-bottom: 32px;
  transition: color 0.2s;
}
.reread-link:hover { color: var(--purple-strong); }

/* Rec grid 2x2 — polaroid cards, typography only */
.recs-eyebrow { margin-top: 0; }
.rec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  --tilt: 0deg;
  transform: rotate(var(--tilt));
  transition:
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 200ms ease,
    box-shadow 200ms ease;
}
.rec-card:nth-child(1) { --tilt: -2deg; }
.rec-card:nth-child(2) { --tilt:  3deg; }
.rec-card:nth-child(3) { --tilt:  2deg; }
.rec-card:nth-child(4) { --tilt: -3deg; }

.rec-card:hover {
  transform: rotate(var(--tilt)) translateY(-3px);
  box-shadow: 0 12px 28px oklch(22% 0.04 60 / 0.10);
}
.rec-card.is-active {
  border-color: var(--purple-strong);
  background: var(--purple-dim);
  transform: rotate(var(--tilt)) scale(1.02) translateY(-2px);
}
.rec-card__kind {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--purple-strong);
  display: block;
  margin-bottom: 6px;
}
.rec-card__name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}
.rec-card__why {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-2);
  margin: 0;
}

/* Error state */
.error-message {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 24px 0;
}

/* ── Card entry animation (live state) ───────────────────────────────── */
body[data-state="live"] .stylist-card     { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 0ms; }
body[data-state="live"] .reread-link      { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 150ms; }
body[data-state="live"] .recs-eyebrow     { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 300ms; }
body[data-state="live"] .rec-grid .rec-card:nth-child(1) { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 450ms; }
body[data-state="live"] .rec-grid .rec-card:nth-child(2) { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 600ms; }
body[data-state="live"] .rec-grid .rec-card:nth-child(3) { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 750ms; }
body[data-state="live"] .rec-grid .rec-card:nth-child(4) { animation: card-in 550ms cubic-bezier(0.34, 1.56, 0.64, 1) both; animation-delay: 900ms; }

@keyframes card-in {
  from { opacity: 0; transform: rotate(var(--tilt, 0deg)) translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: rotate(var(--tilt, 0deg)) translateY(0)    scale(1); }
}

/* Save-your-fit secondary CTA */
.save-fit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding: 12px 22px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.save-fit:hover {
  background: var(--purple-dim);
  border-color: var(--purple-strong);
  color: var(--purple-strong);
  transform: translateY(-1px);
}
.save-fit:disabled {
  cursor: default;
  opacity: 0.7;
  transform: none;
}
.save-fit svg { flex-shrink: 0; }

/* Canvas reveal when accessory engaged */
body[data-accessory-active="true"] .stage__canvas { display: block; animation: canvas-in 250ms ease both; }
@keyframes canvas-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Focus states ────────────────────────────────────────────────────── */
a:focus, button:focus { outline: none; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 3px;
  border-radius: 4px;
}
.atelier__cta:focus-visible { outline-offset: 4px; border-radius: 8px; }

/* ── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reading-dots span { animation: none; opacity: 0.7; }
}

/* ── Responsive (≤960px) ─────────────────────────────────────────────── */
@media (max-width: 960px) {
  .demo-nav { padding: 18px 28px; }
  .demo-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .stage   { padding: 28px 28px 0; }
  .stage__frame { max-width: 480px; }
  .atelier { padding: 28px 28px 56px; max-width: none; }
  .result__shape  { font-size: clamp(36px, 8vw, 52px); }
  .atelier__intro-h1 { font-size: clamp(32px, 7vw, 44px); }
  .reread-link { padding: 8px 0; }   /* taller tap target */
}
