/* Palette and glass panels mirror public/avatar-demo.css so the demo looks like the real panel. */
:root {
  color-scheme: light;
  --bg: #fbf4e6;
  --panel: rgba(255, 255, 255, 0.58);
  --line: rgba(79, 91, 108, 0.22);
  --text: #18202b;
  --muted: #5f6b7d;
  --accent: #0f8f78;
  --accent-ink: #0d5f51;
  --accent-2: #d97706;
  --surface: rgba(255, 252, 245, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 12%, rgba(15, 143, 120, 0.2), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(217, 119, 6, 0.2), transparent 24%),
    linear-gradient(135deg, #fffaf0 0%, var(--bg) 46%, #eef7f4 100%);
  background-attachment: fixed;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 88px; /* bottom room for the Wise Piece badge */
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  border: 1px solid rgba(15, 143, 120, 0.3);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--accent-ink);
  background: rgba(15, 143, 120, 0.08);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 4.6vw, 56px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  max-width: 640px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

/* demo-builder rule 6: the language switch stays pinned top-right while scrolling */
.topbar {
  padding-right: 64px;
}

.lang-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 100;
  flex: none;
  box-shadow: 0 6px 18px rgba(22, 50, 59, 0.12);
  min-width: 52px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  /* near-opaque: it floats over content while scrolling */
  background: rgba(255, 252, 245, 0.96);
  backdrop-filter: blur(18px) saturate(1.25);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.lang-toggle:hover,
.lang-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent-ink);
  outline: none;
}

.step-title {
  margin: 0 0 12px;
  font-size: 18px;
}

/* ---------- scene picker ---------- */

.scene-picker {
  margin-bottom: 20px;
}

.scene-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.scene-tag {
  display: inline-block;
  margin-bottom: 4px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #1d1102;
  background: rgba(217, 119, 6, 0.22);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
  line-height: 1.5;
}

.scene-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.3);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.scene-card:hover {
  transform: translateY(-1px);
}

.scene-card[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 143, 120, 0.25), 0 14px 34px rgba(80, 66, 36, 0.12);
}

.scene-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scene-card img {
  width: 96px;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  object-fit: cover;
  object-position: 50% 25%;
}

.scene-card strong {
  display: block;
  font-size: 16px;
}

.scene-card span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

/* ---------- panels ---------- */

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(80, 66, 36, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(24px) saturate(1.35);
  padding: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
}

.section-head span {
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.section-head strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.section-head.compact {
  margin-bottom: 12px;
}

/* ---------- inputs ---------- */

/* Compact on purpose: the output stage already shows the same photo large. */
.source-figure {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 0 0 18px;
}

.source-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  background: #efe6d4;
}

.source-figure figcaption {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-figure figcaption span {
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.ai-tag {
  font-style: normal;
  color: var(--accent-2);
}

.field {
  margin-bottom: 16px;
}

.field-label {
  margin: 0 0 8px;
  font-weight: 850;
}

.script-box {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--surface-strong);
  line-height: 1.6;
}

.translation {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.translation:empty {
  display: none;
}

.form-section {
  margin: 0 0 16px;
  border: 1px solid rgba(15, 143, 120, 0.2);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.54), rgba(255, 250, 240, 0.28));
}

.voice-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}

.speed {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
}

.speed input {
  width: 100%;
  accent-color: var(--accent);
}

output {
  color: var(--accent-ink);
  font-weight: 900;
}

small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.motion {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--surface);
}

.motion summary {
  font-weight: 850;
  cursor: pointer;
}

.motion p {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

button {
  font: inherit;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  color: #1d1102;
  background: var(--accent-2);
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(217, 119, 6, 0.28);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.ghost-button {
  min-height: 44px;
  border: 1px solid rgba(15, 143, 120, 0.3);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--accent-ink);
  background: rgba(15, 143, 120, 0.1);
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}

.full-note {
  margin-top: 10px;
  text-align: center;
}

/* ---------- output stage ---------- */

.video-review {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1b2430;
}

.stage-still,
.video-review video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-review video {
  display: none;
  object-fit: contain;
  background: #0e141b;
}

.video-review[data-state="done"] video {
  display: block;
}

.video-review[data-state="done"] .stage-still {
  display: none;
}

.video-review[data-state="running"] .stage-still {
  filter: saturate(0.7) brightness(0.72);
}

.stage-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: 4px;
  padding: 40px 18px 16px;
  color: #fff;
  background: linear-gradient(transparent, rgba(10, 16, 22, 0.82));
}

.stage-overlay strong {
  font-size: 19px;
}

.stage-overlay span {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.video-review[data-state="done"] .stage-overlay {
  display: none;
}

.stage-cta {
  justify-self: start;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  color: #1d1102;
  background: var(--accent-2);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.video-review[data-state="running"] .stage-cta {
  display: none;
}

/* scanning sweep while the replay runs */
.video-review[data-state="running"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(15, 143, 120, 0.32) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: sweep 1.6s linear infinite;
  pointer-events: none;
}

@keyframes sweep {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.wave {
  display: none;
  gap: 4px;
  align-items: end;
  height: 22px;
  margin-top: 6px;
}

.video-review[data-voice="on"] .wave {
  display: flex;
}

.wave i {
  width: 4px;
  border-radius: 2px;
  background: #5eead4;
  animation: bar 0.9s ease-in-out infinite;
}

.wave i:nth-child(2n) { animation-delay: -0.3s; }
.wave i:nth-child(3n) { animation-delay: -0.6s; }

@keyframes bar {
  0%, 100% { height: 5px; }
  50% { height: 22px; }
}

/* "before" inset shown next to the finished video */
.before-inset {
  position: absolute;
  top: 10px;
  left: 10px;
  display: none;
  width: 26%;
  aspect-ratio: 16 / 9;
  border: 2px solid #fff;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.video-review[data-state="done"] .before-inset {
  display: block;
}

/* ---------- pipeline + status ---------- */

.pipeline {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.pipeline li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
  font-weight: 800;
  font-size: 14px;
}

.pipeline li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(79, 91, 108, 0.12);
  font-size: 12px;
}

.pipeline li .label {
  flex: 1;
  min-width: 0;
}

.pipeline li .t {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pipeline li.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(15, 143, 120, 0.12);
}

.pipeline li.done {
  color: var(--text);
}

.pipeline li.done::before {
  content: "✓";
  color: #fff;
  background: var(--accent);
}

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
  font-size: 14px;
}

.status-strip strong {
  flex: none;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- report ---------- */

.report {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
}

.report[hidden] {
  display: none;
}

.report h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.report dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0 0 14px;
}

.report dl div {
  min-width: 0;
}

.report dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 800;
}

.report-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.download-link {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  color: #04110d;
  background: var(--accent);
  text-decoration: none;
  font-weight: 900;
}

.prerender-note {
  margin-top: 12px;
}

/* ---------- how it works ---------- */

.how {
  margin-top: 28px;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-grid li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel);
  backdrop-filter: blur(20px);
}

.how-grid strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-ink);
}

.how-grid span {
  color: var(--muted);
  line-height: 1.6;
}

.foot {
  margin-top: 26px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  /* output first on narrow screens: the talking video is the payoff */
  .output-panel {
    order: -1;
  }
}

@media (max-width: 720px) {
  .how-grid {
    grid-template-columns: 1fr;
  }

  /* compact 2x2 tiles keep the output stage near the first screen */
  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .scene-tag {
    font-size: 10px;
  }

  .scene-card {
    grid-template-columns: 1fr;
    gap: 6px;
    align-content: start;
    padding: 6px;
  }

  .scene-card img {
    width: 100%;
  }

  .scene-card strong {
    font-size: 13px;
    line-height: 1.3;
  }

  .scene-card span {
    display: none;
  }

  /* a 16:9 stage is ~190px tall on phones: keep the face visible */
  .stage-overlay {
    padding: 22px 12px 10px;
  }

  .stage-overlay strong {
    font-size: 15px;
  }

  .video-review[data-state="idle"] .stage-overlay span {
    display: none;
  }

  .stage-cta {
    min-height: 38px;
    margin-top: 4px;
    padding: 0 16px;
    font-size: 14px;
  }

  .before-inset {
    width: 30%;
    top: 6px;
    left: 6px;
  }

  .source-figure {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .panel {
    padding: 16px;
  }

  .voice-row,
  .report-actions {
    grid-template-columns: 1fr;
  }

  .lead {
    font-size: 15px;
  }
}
