/*
 * Beat photo-to-character: Greenroom, one image becoming a talking character, replayed from
 * the record of one build (web/landing/sections/photo-to-character.html). Linked in the page
 * head by lib/landing.ts while the beat is enabled; the shells' sheets it builds on
 * (DemoFrame, ProgressLedger, CharacterSurface) are linked by the page itself, once each
 * and before every section sheet, so nothing is imported here. Every class starts with the
 * beat id and every rule is scoped by [data-beat]; the tokens are web/landing.css's.
 *
 * Layout: the copy over the frame. In a frame of 640 px or more the character becoming
 * stands on the left (the image and the stage in one 2:3 box, the name, tagline, chips and
 * the source note under it) and the build graph runs on the right: twelve rows, each with
 * its state, timer, a bar of its run on the record's length and (Show log) its last line,
 * then the skips and the replay note. Narrow: the character on top, the graph under it,
 * nothing wider than the frame. Names in the serif, the tagline in the sans, every stage
 * name, state, time, chip and log line in the mono.
 */

/* ── The copy, as a header ─────────────────────────────────────────────── */

@media (min-width: 1024px) {
  .use-case[data-beat="photo-to-character"] .use-case-copy {
    display: grid;
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    grid-template-areas: "eyebrow eyebrow" "title body";
    column-gap: clamp(28px, 4vw, 56px);
    align-items: end;
    margin: 0 0 clamp(24px, 4vh, 36px);
  }
  .use-case[data-beat="photo-to-character"] .use-case-eyebrow { grid-area: eyebrow; }
  .use-case[data-beat="photo-to-character"] .use-case-title { grid-area: title; margin: 0; }
  .use-case[data-beat="photo-to-character"] .use-case-body { grid-area: body; padding-bottom: 6px; }
}

@media (max-width: 1023px) {
  .use-case[data-beat="photo-to-character"] .use-case-copy { margin: 0 0 24px; }
}

/* ── The frame: the character on the left, the graph on the right ──────── */

@container demo-frame (min-width: 640px) {
  [data-beat="photo-to-character"] .demo-frame-body {
    grid-template-columns: minmax(240px, 5fr) minmax(0, 7fr);
    grid-template-areas: "stage main";
    align-items: start;
    gap: 22px;
  }
}

/* ── The character becoming ────────────────────────────────────────────── */

[data-beat="photo-to-character"] .photo-to-character-becoming {
  display: grid;
  gap: 12px;
  justify-items: center;
  margin: 0;
  min-width: 0;
}

/* The image and the stage share one box of the image's own shape (400 x 600), so the
   face box is plain percentages of it and the stage replaces the image in place. */
[data-beat="photo-to-character"] .photo-to-character-canvas {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #0e0b14; /* the app's stage colour, as CharacterSurface.css has it */
  box-shadow: 0 0 0 1px var(--line);
}

@container demo-frame (max-width: 639px) {
  [data-beat="photo-to-character"] .photo-to-character-canvas { width: min(100%, 260px); }
}

[data-beat="photo-to-character"] .photo-to-character-source {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

[data-beat="photo-to-character"] .photo-to-character-source[hidden],
[data-beat="photo-to-character"] .photo-to-character-scan[hidden],
[data-beat="photo-to-character"] .photo-to-character-face[hidden],
[data-beat="photo-to-character"] .photo-to-character-stage[hidden],
[data-beat="photo-to-character"] .photo-to-character-chips[hidden] { display: none; }

/* Assess looking at the image: one violet line sweeping down it. */
[data-beat="photo-to-character"] .photo-to-character-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 0 46%, color-mix(in srgb, var(--accent) 55%, transparent) 50%, transparent 54% 100%);
  background-size: 100% 220%;
  animation: photo-to-character-scan 1.8s linear infinite;
  pointer-events: none;
}

@keyframes photo-to-character-scan {
  from { background-position: 0 100%; }
  to { background-position: 0 0; }
}

/* The verdict's face box, locking on from wide. */
[data-beat="photo-to-character"] .photo-to-character-face {
  position: absolute;
  left: calc(var(--fx, 0) * 100%);
  top: calc(var(--fy, 0) * 100%);
  width: calc(var(--fw, 0) * 100%);
  height: calc(var(--fh, 0) * 100%);
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 60%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
  animation: photo-to-character-lock .7s cubic-bezier(.2, .8, .2, 1) both;
  pointer-events: none;
}

@keyframes photo-to-character-lock {
  from { transform: scale(2.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* The stage fills the same box; the surface sets its aspect ratio from the character. */
[data-beat="photo-to-character"] .photo-to-character-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  border-radius: 0;
  box-shadow: none;
}

[data-beat="photo-to-character"] .photo-to-character-caption {
  display: grid;
  gap: 4px;
  width: min(100%, 340px);
  min-width: 0;
  text-align: center;
}

[data-beat="photo-to-character"] .photo-to-character-name {
  margin: 0;
  min-height: 1.3em;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.3;
}

[data-beat="photo-to-character"] .photo-to-character-tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

[data-beat="photo-to-character"] .photo-to-character-tagline:empty { display: none; }

[data-beat="photo-to-character"] .photo-to-character-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 0;
}

[data-beat="photo-to-character"] .photo-to-character-chip {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

[data-beat="photo-to-character"] .photo-to-character-source-note {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── The build graph ───────────────────────────────────────────────────── */

[data-beat="photo-to-character"] .photo-to-character-graph { gap: 10px; }

[data-beat="photo-to-character"] .photo-to-character-clock {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* Before a replay starts the clock is empty, and so is its line. */
[data-beat="photo-to-character"] .photo-to-character-clock:has(.progress-ledger-clock:empty) { visibility: hidden; }
[data-beat="photo-to-character"] .photo-to-character-clock .progress-ledger-clock { color: var(--text); }

[data-beat="photo-to-character"] .photo-to-character-stages > .progress-ledger-stage {
  grid-template-areas:
    "mark label state elapsed"
    ". bar bar bar"
    ". line line line";
  row-gap: 5px;
  padding: 7px 0;
}

[data-beat="photo-to-character"] .photo-to-character-stages > .progress-ledger-stage:not(:last-child)::before {
  top: calc(7px + var(--ledger-mark) + 4px);
}

[data-beat="photo-to-character"] .photo-to-character-stages .progress-ledger-label {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}

/* A stage's run on the record's whole length: where it started, how long it ran. */
[data-beat="photo-to-character"] .photo-to-character-bar {
  grid-area: bar;
  display: block;
  height: 4px;
  min-width: 0;
  border-radius: 2px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
  overflow: hidden;
}

[data-beat="photo-to-character"] .photo-to-character-bar > i {
  display: block;
  height: 100%;
  margin-left: calc(var(--from, 0) * 100%);
  width: calc(var(--span, 0) * 100%);
  min-width: 0;
  border-radius: 2px;
  background: var(--muted);
}

[data-beat="photo-to-character"] .progress-ledger-stage[data-state="running"] .photo-to-character-bar > i { background: var(--accent); }
[data-beat="photo-to-character"] .progress-ledger-stage[data-state="done"] .photo-to-character-bar > i { background: color-mix(in srgb, var(--accent) 55%, var(--muted)); }
[data-beat="photo-to-character"] .progress-ledger-stage:not([data-state]) .photo-to-character-bar > i { width: 0; }

/* Show log: each stage's last line, the running ones in the text colour. */
[data-beat="photo-to-character"] .photo-to-character-graph:not([data-log]) .progress-ledger-line { display: none; }
[data-beat="photo-to-character"] .progress-ledger-stage[data-state="running"] .progress-ledger-line { color: var(--text); }

[data-beat="photo-to-character"] .photo-to-character-note {
  margin: 2px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── The toolbar: Build your own, a plain link, keeps to the end of the row ── */

/* The intro's provenance beside its button, in the source note's register. */
[data-beat="photo-to-character"] .photo-to-character-intro-note {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 300px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

[data-beat="photo-to-character"] .photo-to-character-intro-note[hidden] { display: none; }

[data-beat="photo-to-character"] .photo-to-character-mine { margin-left: auto; }

@container demo-frame (max-width: 479px) {
  [data-beat="photo-to-character"] .photo-to-character-mine { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  [data-beat="photo-to-character"] .photo-to-character-scan {
    animation: none;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
  }
  [data-beat="photo-to-character"] .photo-to-character-face { animation: none; }
}
