/* Animatic demo shell.
   The product is black line art on white, so the page is too: ink on paper,
   one accent, no gradients. */

:root {
  --ink: #14110f;
  --ink-soft: #4a423c;
  --ink-faint: #8b807a;
  --paper: #ffffff;
  --paper-warm: #faf8f5;
  --rule: #e3ddd6;
  --accent: #b2361f;      /* the one warm mark on the page */
  --accent-soft: #f6e9e5;
  --live: #1f6b4a;
  --live-soft: #e6f2eb;
  --radius: 3px;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  /* Lightness of the wordmark's rotating letters. A single knob because the
     three hues are fixed at 0/120/240 — only their legibility changes with
     the ground they sit on. */
  --wm-l: 45%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f2ede8;
    --ink-soft: #b8afa8;
    --ink-faint: #7d746d;
    --paper: #16130f;
    --paper-warm: #1e1a16;
    --rule: #322c26;
    --accent: #e0715a;
    --accent-soft: #2c1c17;
    --live: #63b98f;
    --live-soft: #16281f;
    --wm-l: 64%;
  }
}

:root[data-theme="dark"] {
  --ink: #f2ede8;
  --ink-soft: #b8afa8;
  --ink-faint: #7d746d;
  --paper: #16130f;
  --paper-warm: #1e1a16;
  --rule: #322c26;
  --accent: #e0715a;
  --accent-soft: #2c1c17;
  --live: #63b98f;
  --live-soft: #16281f;
  --wm-l: 64%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 24px; }

/* The masthead is the page's fixed edge: its 2px rule is the line everything
   scrolls under. It has to carry an opaque background of its own — a sticky
   element with a transparent ground shows the content sliding beneath it. */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  padding: 48px 0 28px;
  margin-bottom: 40px;
  transition: padding 180ms ease;
}
.masthead h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-wrap: balance;
  transition: font-size 180ms ease;
}

/* Pinned, the masthead at full height would hold about a third of a laptop
   viewport hostage. `.is-stuck` (set by app.js when the page scrolls past the
   top) trades the display size for the room the cut needs. */
.masthead.is-stuck { padding: 12px 0 10px; }
.masthead.is-stuck h1 { font-size: clamp(1.35rem, 3.4vw, 1.75rem); }
.masthead.is-stuck .sub { font-size: 0.92rem; }
.masthead.is-stuck .header-controls { margin-top: 8px; }

/* ---------- wordmark ----------
 *
 * "AI" is the constant; the seven letters after it each hold a resting hue of
 * red, green or blue and arrive there by one turn of the colour wheel on load.
 * `--h` has to be a registered property: a plain custom property is a string
 * as far as the animation engine is concerned, so it would jump from start to
 * end with nothing in between instead of sweeping. */
@property --h {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

.wordmark .wm-ai { color: var(--ink); }
.wordmark .wm-rot {
  color: hsl(var(--h) 78% var(--wm-l));
  animation: wm-sweep 900ms ease-out both;
}

/* One full turn, landing on the letter's resting hue. Staggering the delay is
   what makes the colour read as travelling across the word rather than seven
   letters changing at once. */
@keyframes wm-sweep {
  from { --h: calc(var(--h0) + 360deg); }
  to   { --h: var(--h0); }
}

.wordmark .wm-rot:nth-child(2) { --h0:   0deg; animation-delay:   0ms; }
.wordmark .wm-rot:nth-child(3) { --h0: 120deg; animation-delay:  60ms; }
.wordmark .wm-rot:nth-child(4) { --h0: 240deg; animation-delay: 120ms; }
.wordmark .wm-rot:nth-child(5) { --h0:   0deg; animation-delay: 180ms; }
.wordmark .wm-rot:nth-child(6) { --h0: 120deg; animation-delay: 240ms; }
.wordmark .wm-rot:nth-child(7) { --h0: 240deg; animation-delay: 300ms; }
.wordmark .wm-rot:nth-child(8) { --h0:   0deg; animation-delay: 360ms; }

/* The resting colours are the point; the sweep is decoration. Reduced motion
   gets the former without the latter. */
@media (prefers-reduced-motion: reduce) {
  .wordmark .wm-rot { animation: none; --h: var(--h0); }
  .masthead, .masthead h1 { transition: none; }
}

/* ---------- subtitle row ---------- */

.sub-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.sub { margin: 6px 0 0; color: var(--ink-soft); font-size: 1.05rem; }

/* Outranks `.btn` below on specificity, deliberately — this button sits on a
   line of running text and would shout at the display size the panels use. */
.sub-row .btn-restore {
  flex: none;
  font-size: 0.82rem;
  padding: 7px 14px;
  border-width: 1px;
  border-color: var(--rule);
  color: var(--ink-soft);
}
.sub-row .btn-restore:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* The script picker sits under the masthead rule rather than beside the title:
   which screenplay is showing is stated in the subtitle already, and this is
   the control that changes it. */
/* Any rule that sets `display` outranks the browser's own `[hidden]` rule and
   silently un-hides the element. This file sets `display` on several things
   the JS toggles with `hidden`, so state it once, here, for all of them. */
[hidden] { display: none !important; }

/* The picker and the three views share one line under the rule: which
   screenplay, and what you are doing to it. */
.header-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.script-picker {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.script-picker label {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.script-picker select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 10px;
  max-width: min(100%, 34rem);
}
.script-picker select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.script-picker option:disabled { color: var(--ink-faint); }

.panel {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 26px 28px 28px;
  margin-bottom: 28px;
  background: var(--paper-warm);
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.panel h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.lede { margin: 8px 0 20px; color: var(--ink-soft); max-width: 62ch; }

.tag {
  font: 600 0.68rem/1 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.tag-live { background: var(--live-soft); color: var(--live); }
.tag-cached { background: var(--accent-soft); color: var(--accent); }

.btn {
  font: 600 0.95rem var(--sans);
  padding: 11px 22px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }

.modes { display: grid; gap: 10px; margin-bottom: 20px; }
@media (min-width: 660px) { .modes { grid-template-columns: repeat(3, 1fr); } }
.mode {
  display: block;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  background: var(--paper);
  transition: border-color 0.12s;
}
.mode:has(input:checked) { border-color: var(--ink); border-width: 1.5px; }
.mode:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode-name { display: block; font-weight: 600; font-size: 0.95rem; }
.mode-note { display: block; color: var(--ink-faint); font-size: 0.82rem; margin-top: 2px; }

.progress { margin-top: 22px; }
.bar {
  height: 4px;
  background: var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease-out;
}
.progress-line {
  margin: 10px 0 0;
  font: 0.85rem/1.5 var(--mono);
  color: var(--ink-soft);
}
.events {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  font: 0.78rem/1.7 var(--mono);
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
  padding-top: 8px;
}
.events li { display: flex; gap: 10px; }
.events .who { color: var(--ink); min-width: 4.4em; }
.events .src-footage { color: var(--accent); font-weight: 600; }
.events .src-motion { color: var(--live); }

video {
  width: 100%;
  margin-top: 22px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #000;
  display: block;
}
.disclosure {
  margin: 10px 0 0;
  font-size: 0.84rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--accent);
  padding-left: 11px;
}

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 9px;
  max-height: 460px;
  overflow-y: auto;
  padding: 2px;
}
.shot {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  cursor: pointer;
  aspect-ratio: 16 / 9;
}
.shot img,
.shot video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* A take is one shot in the strip, the same size as the rest of them. The
   accent border is what marks it, not extra room. */
.shot.is-span {
  border-color: var(--accent);
  border-width: 2px;
}
.shot.is-over { border-color: var(--accent); border-width: 2px; }
.shot.state-footage { border-color: var(--accent); border-width: 2px; }
.shot.state-animatic_motion { border-color: var(--live); border-width: 2px; }
.shot-id {
  position: absolute;
  left: 0; bottom: 0;
  font: 600 0.66rem/1 var(--mono);
  background: var(--ink);
  color: var(--paper);
  padding: 3px 5px;
}
.shot-badge {
  position: absolute;
  right: 0; top: 0;
  font: 600 0.6rem/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 5px;
  color: var(--paper);
}
.state-footage .shot-badge { background: var(--accent); }
.state-animatic_motion .shot-badge { background: var(--live); }
.state-animatic_still .shot-badge { display: none; }

.out {
  margin-top: 18px;
  font: 0.82rem/1.7 var(--mono);
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 13px 15px;
  white-space: pre-wrap;
  max-height: 230px;
  overflow-y: auto;
}
.out.is-error { border-color: var(--accent); color: var(--accent); }

.foot {
  border-top: 1px solid var(--rule);
  padding: 22px 24px 48px;
  color: var(--ink-faint);
  font-size: 0.85rem;
}
.foot p { margin: 0; max-width: 62ch; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- steering: characters, editor, dailies ---- */

.rows { display: grid; gap: 7px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 11px 14px;
  background: var(--paper);
}
.note {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
  border-left: 2px solid var(--rule);
  padding-left: 11px;
}

.row-name { font-weight: 600; min-width: 9em; }
.row-meta { color: var(--ink-faint); font-size: 0.85rem; }
.row select, .row input[type="text"], .row input[type="number"] {
  font: 0.85rem var(--sans);
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
.btn-sm {
  font: 600 0.78rem var(--sans);
  padding: 6px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.btn-sm:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover:not(:disabled) { background: var(--accent); color: var(--paper); border-color: var(--accent); }

.editor { display: grid; gap: 14px; }
.editor .empty { color: var(--ink-faint); margin: 0; }
.editor-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.editor-head img {
  width: 380px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: block;
}
.editor-field { display: grid; gap: 7px; }
.editor-field label { font-weight: 600; font-size: 0.88rem; }
.editor-field .hint { color: var(--ink-faint); font-size: 0.82rem; margin: 0; }
.editor-field textarea {
  font: 0.9rem/1.5 var(--sans);
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
  min-height: 68px;
}
.editor-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.rewrite {
  margin: 0;
  font: 0.8rem/1.6 var(--mono);
  color: var(--ink-faint);
  border-left: 2px solid var(--accent);
  padding-left: 11px;
}

.daily-form {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}
.daily-form label { display: grid; gap: 5px; font-size: 0.85rem; font-weight: 600; }
.daily-form input[type="text"] {
  font: 0.9rem var(--mono);
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  width: 7em;
}
.daily-form .file input { font-size: 0.8rem; }
.shot.is-selected { outline: 2px solid var(--ink); outline-offset: 2px; }
.shot.state-animatic_edited { border-color: var(--ink); border-width: 2px; }
.state-animatic_edited .shot-badge { background: var(--ink); }
.shot.state-daily { border-color: var(--accent); border-width: 2px; }
.state-daily .shot-badge { background: var(--accent); }


/* ---------- the three views ----------
 *
 * Watching, changing, building. A person arrives to watch, which is why that
 * is the default and why the cut is the first thing under the rule — the page
 * used to open on a control panel with the film somewhere below the fold. */

.views {
  display: flex;
  gap: 2px;
  margin-left: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--paper);
}
.view-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  font: 600 0.82rem var(--sans);
  padding: 7px 13px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.view-tab:hover { color: var(--ink); }
.view-tab.is-current { background: var(--ink); color: var(--paper); }
.view-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.view-icon { font-size: 0.95rem; line-height: 1; }

/* Under about 30rem the labels cost more than they explain; the icons carry
   it, and each button keeps its accessible name from the hidden text. */
@media (max-width: 560px) {
  .view-name {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .view-tab { padding: 8px 11px; }
}

/* ---------- the cut, which is the point ---------- */

#player-wrap { margin-top: 4px; }
#player-wrap video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.rendering {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-warm);
  padding: 28px;
  text-align: center;
}
.rendering-title {
  margin: 0 0 18px;
  font: 600 1.05rem var(--sans);
  letter-spacing: 0.02em;
}
.rendering .bar { max-width: 420px; margin: 0 auto; }
.rendering .progress-line { text-align: center; }
.rendering .events { text-align: left; max-width: 420px; margin: 14px auto 0; }

/* Shown when the shots have moved past the rendered cut. */
.restale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.restale-note { margin: 0; color: var(--accent); font-size: 0.92rem; }

.btn-link {
  font: inherit;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* One sentence, once, when a render lands. The cut is already behind it. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 13px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.92rem var(--sans);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.22);
  animation: toast-in 220ms ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* A shot that moves plays where its still would have been — a frozen frame of
   a moving shot tells you nothing about whether the movement is right. */
.editor-head video {
  width: 480px;
  max-width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}


/* ---------- the changelist ----------
 *
 * Edits accumulate; the cut is built once, from the sum of them. The bar is
 * fixed because the decision it offers — throw these away, or cut them in —
 * has to be reachable from anywhere in a strip of fifty shots. */

.changes {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  padding: 14px 24px 16px;
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.08);
}
.changes-head {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.changes-count {
  margin: 0;
  font: 700 0.78rem/1 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.changes-actions { display: flex; gap: 10px; }
.changes-actions .btn { padding: 9px 18px; font-size: 0.88rem; }
.btn-quiet {
  border-color: var(--rule);
  color: var(--ink-soft);
}
.btn-quiet:hover:not(:disabled) {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.changes-list {
  max-width: 940px;
  margin: 10px auto 0;
  padding: 0 0 0 18px;
  max-height: 22vh;
  overflow-y: auto;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.changes-list li { margin: 2px 0; }

/* The bar sits over the page, so the last panel needs room to clear it. */
#view-edit:not([hidden]) { padding-bottom: 140px; }


/* What an upload is doing, while it does it. */
.upload-status {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* A shot with a clip on the way in. The strip redraws when it lands. */
.shot.is-uploading { opacity: 0.55; }
.shot.is-uploading::after {
  content: attr(data-progress);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 0.72rem var(--mono);
  background: rgb(0 0 0 / 0.55);
  color: #fff;
}


/* A pipeline step, reporting itself. */
.step { margin-top: 16px; }
.step-line {
  margin: 0 0 8px;
  font: 600 0.85rem var(--sans);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.step .events { max-height: 200px; }


/* ---------- asking ---------- */

.ask {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 26px 28px 22px;
  max-width: 520px;
  width: calc(100% - 48px);
}
.ask::backdrop { background: rgb(0 0 0 / 0.45); }
.ask h2 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ask p { margin: 0 0 18px; color: var(--ink-soft); }
.ask-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.ask-actions .btn { padding: 9px 18px; font-size: 0.88rem; }

/* The scene list. Scrolls rather than growing past the viewport on a
   screenplay with forty of them. */
.ask-body {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 10px;
}
.ask-scene {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  font-size: 0.92rem;
  cursor: pointer;
}
.ask-scene input { margin: 0; }
.ask-scene .row-meta { margin-left: auto; }
.ask-scene.is-all {
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
  margin-bottom: 4px;
}
