/* The studio: a film as a sequence of decisions you can change.
 *
 * The pipeline already thinks in stages, so the page does too — one panel per
 * stage, in the order they run, each showing what that stage decided and
 * letting you rewrite it and run it again. Nothing here is read-only unless
 * the machine owns it.
 */

.studio { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }

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

/* -- stage rail --------------------------------------------------------- */

.rail { position: sticky; top: 84px; align-self: start; }
@media (max-width: 900px) {
  .rail { position: static; }
  .rail ol { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
}

.rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.rail a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
  transition: background var(--fast), color var(--fast);
}
.rail a:hover { background: var(--surface-2); color: var(--text); }
.rail a[aria-current="true"] { background: var(--surface-2); color: var(--text); font-weight: 560; }

.pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line-strong); flex: none;
}
.pip.done    { background: var(--good); }
.pip.active  { background: var(--warn); animation: pulse 1.4s infinite; }
.pip.failed  { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }

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

.panel {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  margin-bottom: 18px;
  overflow: hidden;
  scroll-margin-top: 84px;
}

.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
.panel-head .count { color: var(--text-faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.panel-body { padding: 16px; }

.row { display: grid; gap: 6px; margin-bottom: 14px; }
.row:last-child { margin-bottom: 0; }
.row label {
  font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
}

input[type="text"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color var(--fast), background var(--fast);
}
textarea { line-height: 1.5; min-height: 72px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  background: var(--bg-raised);
}
.dirty input, .dirty textarea { border-color: var(--warn); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.sbtn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 560;
  cursor: pointer;
  transition: background var(--fast), border-color var(--fast), opacity var(--fast);
}
.sbtn:hover:not(:disabled) { background: var(--line); border-color: var(--text-faint); }
.sbtn:disabled { opacity: .45; cursor: not-allowed; }
.sbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sbtn.primary:hover:not(:disabled) { filter: brightness(1.1); }
.sbtn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

.hint { color: var(--text-faint); font-size: 12.5px; margin: 8px 0 0; }
.saved { color: var(--good); font-size: 13px; }

/* -- cast / settings ---------------------------------------------------- */

.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }

.person { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--bg-raised); }
.person figure { margin: 0; aspect-ratio: 1 / 1; background: var(--bg-sunken); position: relative; }
.person figure img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person .fields { padding: 12px; display: grid; gap: 10px; }
.pitch {
  position: absolute; right: 8px; bottom: 8px;
  padding: 3px 8px; border-radius: var(--r-sm);
  background: rgb(10 11 14 / .74); backdrop-filter: blur(6px);
  color: #fff; font: 600 12px var(--mono);
}

/* -- shots -------------------------------------------------------------- */

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }

.shot {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg-raised);
  transition: border-color var(--fast);
}
.shot.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.shot figure { margin: 0; aspect-ratio: 1344/768; background: var(--bg-sunken); position: relative; cursor: pointer; }
.shot figure img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .n {
  position: absolute; left: 7px; top: 7px;
  min-width: 22px; height: 22px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: rgb(10 11 14 / .78); backdrop-filter: blur(6px);
  color: #fff; font: 600 12px/1 var(--mono);
}
.shot .act {
  position: absolute; right: 7px; top: 7px;
  padding: 2px 7px; border-radius: var(--r-sm);
  background: rgb(10 11 14 / .7); backdrop-filter: blur(6px);
  color: #cfd6e4; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase;
}
.shot .meta2 { padding: 9px 10px; display: grid; gap: 4px; }
.shot .beat { font-size: 13px; font-weight: 580; }
.shot .line { font-size: 12.5px; color: var(--text-dim); font-style: italic; }
.shot .secs { font: 600 11.5px var(--mono); color: var(--text-faint); }

.shot-edit { padding: 0 10px 10px; display: none; gap: 8px; }
.shot.open .shot-edit { display: grid; }

/* -- animatic ----------------------------------------------------------- */

.animatic {
  display: grid; gap: 12px;
}
.animatic video {
  width: 100%;
  border-radius: var(--r);
  background: #000;
  display: block;
  aspect-ratio: 1344/768;
}
.animatic .idle {
  aspect-ratio: 1344/768;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  display: grid; place-items: center;
  color: var(--text-faint);
  text-align: center;
  padding: 20px;
}

.toolbar {
  position: sticky; bottom: 0;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  margin: 0 -24px -72px;
  padding-left: 24px; padding-right: 24px;
  z-index: 20;
}

/* -- shot viewer ---------------------------------------------------------
 * The grid is for reading a film; this is for judging a frame. It gets the
 * whole window because the defects that matter -- whether the ring is
 * jewellery or an animal, whether two shots hold the same face -- are simply
 * not visible at 480px.
 */

body.viewing { overflow: hidden; }

.viewer {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg-sunken) 92%, transparent);
  backdrop-filter: blur(14px);
  display: grid; place-items: center;
  padding: 28px;
}

.viewer-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 22px;
  width: 100%; max-width: 1680px;
  max-height: calc(100vh - 56px);
}

.viewer-stage {
  position: relative;
  display: grid; place-items: center;
  min-width: 0; min-height: 0;
}

.viewer-img {
  max-width: 100%; max-height: calc(100vh - 56px);
  object-fit: contain;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  background: var(--bg-sunken);
}

.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 76px;
  display: grid; place-items: center;
  font-size: 30px; line-height: 1;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  transition: background .12s ease, opacity .12s ease;
}
.viewer-nav:hover:not(:disabled) { background: var(--surface); }
.viewer-nav:disabled { opacity: .25; cursor: default; }
.viewer-nav.prev { left: 8px; }
.viewer-nav.next { right: 8px; }

.viewer-close {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px;
  font-size: 26px; line-height: 1;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
}
.viewer-close:hover { color: var(--text); background: var(--surface); }

.viewer-side {
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
}

.viewer-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
                color: var(--text-faint); }
.viewer-beat  { font-size: 19px; font-weight: 600; color: var(--text); }
.viewer-line  { font-style: italic; color: var(--text-dim); }
.viewer-instruction {
  font-size: 13px; line-height: 1.55; color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  max-height: 190px; overflow-y: auto;
}

.viewer-note {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 10px 12px;
  font: inherit; font-size: 13px; line-height: 1.5;
  resize: vertical;
}
.viewer-note:focus { outline: none; border-color: var(--accent); }

.viewer-well {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  padding: 12px;
  min-height: 92px;
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.viewer-well.over { border-color: var(--accent); background: var(--accent-soft); }
.viewer-well-hint {
  font-size: 12px; line-height: 1.5; color: var(--text-faint);
  margin: auto; text-align: center;
}

.viewer-refs { display: contents; }
.viewer-ref { position: relative; width: 92px; height: 92px; }
.viewer-ref img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.viewer-ref-x {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 15px; line-height: 1;
  color: var(--text);
  background: var(--bad);
  border: none; border-radius: var(--r-pill);
  cursor: pointer;
}

.viewer-go { align-self: flex-start; }
.viewer-status { font-size: 12px; color: var(--text-dim); min-height: 16px; }

@media (max-width: 1100px) {
  .viewer-shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .viewer-side  { max-height: 42vh; }
  .viewer-img   { max-height: 52vh; }
}
