/* Realada — video studio (/studio).
   Loaded only by studio.html. Everything general lives in styles.css; this is
   the working surface: a drop target, a photo grid, and a preview that stays put
   while you change what it is showing. */

/* Two columns once there is room, with the preview pinned so a reorder ten tiles
   down is still visible. Below 940px they stack and the preview sits under the
   grid, which is the reading order anyway on a phone. */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 26px;
  align-items: start;
  padding-bottom: 60px;
}

.studio-side {
  position: sticky;
  top: 18px;
}

@media (max-width: 940px) {
  .studio { grid-template-columns: 1fr; }
  .studio-side { position: static; }
}

.studio h2 { font-size: 20px; margin: 0 0 4px; }

.studio section + section { margin-top: 26px; }

/* ---- Browser gate ---------------------------------------------------------
   Not an error page: arranging and previewing work fine without WebCodecs, and
   only the export needs it. The banner says which half is unavailable. */
.gate {
  border: 1px solid var(--gold);
  background: #fdf6ec;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 24px;
  font-size: 14.5px;
}

.gate strong { display: block; margin-bottom: 3px; }

/* ---- What the plan allows -------------------------------------------------- */
/* Deliberately quieter than .gate: that one reports a browser that cannot
   export, which is a dead end. This one is a statement of what you get, so it
   sits under the lede as information rather than as a warning. */
.plan-strip {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 14.5px;
}
.plan-strip.free { border-left-color: var(--gold); }
.plan-strip.pro { border-left-color: #2e7d5b; }
.plan-strip a { font-weight: 600; }

/* The end-card fields stay usable while locked — what you type is remembered
   for when you do sign in — so this reads as a note, not as a disabled state. */
.lock {
  border-left: 3px solid var(--gold);
  background: #fdf6ec;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  margin: 0 0 14px;
}

/* ---- Drop target ---------------------------------------------------------- */
.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 40px 24px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.drop.over {
  border-color: var(--gold);
  background: #fdf8f1;
}

.drop p { margin: 0 0 8px; }
.drop p:last-child { margin-bottom: 0; }

/* Once photos are in, the drop box hides and the whole page takes drops. This
   is what says so while files are being dragged over it. */
body.files-over::after {
  content: "Drop to add photos";
  position: fixed;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  border: 3px dashed var(--gold);
  border-radius: var(--radius);
  background: rgba(253, 248, 241, .88);
  color: var(--navy);
  font-size: 20px;
  font-weight: 700;
  pointer-events: none; /* the drop must land on the page beneath, not on this */
}

/* ---- Photo grid ----------------------------------------------------------- */
.grid-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.grid-head .spacer { margin-left: auto; }

.sgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  cursor: grab;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

.tile.dragging { opacity: .4; }

/* Past the free cap. Dimmed and desaturated rather than hidden, and still fully
   draggable, so reordering one INTO the reel is the obvious move. */
.tile.out img { opacity: .32; filter: grayscale(1); }
.tile.out .pos { background: var(--border); color: var(--muted); }

/* The photo currently on screen in the preview — the same idea as the
   extension's panel: it ties the frame being watched to the tile whose badges
   would change it. */
.tile.live { outline: 3px solid var(--gold); outline-offset: -3px; }

.tile.bad {
  display: grid;
  place-items: center;
  padding: 10px;
  aspect-ratio: 4 / 3;
  font-size: 11.5px;
  color: var(--danger);
  text-align: center;
  background: #fdf1f0;
  cursor: default;
}

.tile .pos {
  position: absolute;
  left: 5px;
  bottom: 5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(4, 24, 44, .82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
}

/* ---- Selection, the inspector and the timeline ----------------------------- */
/*
   These three replaced the badges that used to sit on the photographs. The tile
   now does one job — show the photo and where it falls in the reel — and the
   editing moved somewhere with room to explain itself.
*/

/* The selected photo(s). Navy, and drawn inside the tile so a selected photo
   does not jump against its neighbours. */
.tile.sel { outline: 3px solid var(--navy); outline-offset: -3px; }
.tile:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

/* "This photo differs from what Realada would have chosen." One dot, in the
   corner, absent by default — which is the state most photos are in. */
.tile .dot {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .6);
}

/* ---- inspector ---- */
.insp {
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.insp h3 { margin: 0 0 2px; font-size: 15px; }
.insp-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.insp-row { margin-bottom: 14px; }
.insp-row > label {
  display: block;
  margin-bottom: 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1;
  padding: 8px 4px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--panel-alt); }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
/* A selection whose photos disagree about this setting. Striped rather than
   blank, because blank reads as "Auto" — which is itself one of the answers. */
.seg button.mixed {
  background: repeating-linear-gradient(135deg, var(--panel-alt) 0 5px, var(--panel) 5px 10px);
}
/* Fixed height so the panel doesn't jump as the description changes under the
   pointer — the whole point is that reading it costs nothing. */
.insp-says { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); min-height: 2.6em; }
.insp-remove { width: 100%; color: var(--danger); border-color: var(--danger); }
.insp-remove:hover { background: var(--danger); color: #fff; }

/* ---- timeline ---- */
.tl-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 8px; }
.tl-head h2 { margin: 0; }
.tl-head .spacer { flex: 1; }

.strip {
  position: relative;
  height: 92px;
  padding: 0;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Visible, not hidden: the playhead's grab handle sits above the strip's top
     edge, and clipping it leaves a 2px line as the only target. Every clip is
     inset 6px and positioned as a percentage, so nothing else can escape. */
  overflow: visible;
  touch-action: none; /* or a touch drag scrolls the page instead of scrubbing */
}
/* Every segment sits at its true start for its true duration, so clips overlap
   by one fade at each junction. That overlap is the crossfade. */
.strip .clip {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  cursor: pointer;
}
.strip .clip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip .clip.card {
  display: grid;
  place-items: center;
  background: var(--navy);
  border-color: var(--navy);
}
.clip-card {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .82);
}
.strip .clip .secs {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(4, 24, 44, .82);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.6;
}
.strip .clip.sel { outline: 3px solid var(--navy); outline-offset: -3px; z-index: 2; }
/* The clip under the playhead — gold, so "watching" and "editing" stay legibly
   different states. */
.strip .clip.live { outline: 3px solid var(--gold); outline-offset: -3px; z-index: 3; }

/* The trim handle appears on hover or on the selected clip. Showing it on all of
   them at rest would put the badges back, one shape further along. */
.strip .clip .grip {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity .12s;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, .95));
}
.strip .clip:hover .grip, .strip .clip.sel .grip { opacity: 1; }
.strip .clip .grip::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 22px;
  border-radius: 2px;
  background: #fff;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--navy);
  cursor: ew-resize;
  z-index: 6;
  touch-action: none;
}
.playhead span {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 0 2px var(--panel-alt);
}

.scrub-hint { margin-left: auto; }

@media (max-width: 720px) {
  /* Thin clips are unusable as touch targets; the strip stays a readable picture
     of the pacing, and trimming happens through the inspector's Length row. */
  .strip { height: 68px; }
  .strip .clip .grip { display: none; }
}

/* ---- Settings ------------------------------------------------------------- */
.row-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.studio select,
.studio input[type=number] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.studio details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0 18px;
  margin-top: 14px;
}

.studio details[open] { padding-bottom: 18px; }

.studio summary {
  cursor: pointer;
  padding: 15px 0;
  font-weight: 600;
  font-size: 14.5px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 14px;
  margin: 0;
}

/* ---- Preview -------------------------------------------------------------- */
.preview-card { padding: 14px; }

.stage {
  display: grid;
  place-items: center;
  background: #0a1526;
  border-radius: 10px;
  padding: 8px;
}

/* Both maxima with auto sizes, so the canvas keeps its own aspect whichever
   constraint binds first. */
.stage canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 52vh;
  border-radius: 4px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.play {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.play:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* The scrubber and its marker bar moved to the timeline strip above. */

.clock {
  flex: 0 0 auto;
  min-width: 78px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Render --------------------------------------------------------------- */
.bar-progress {
  position: relative;
  height: 22px;
  border-radius: 11px;
  background: var(--panel-alt);
  overflow: hidden;
  margin: 12px 0;
  border: 1px solid var(--border);
}

.bar-progress > div {
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #d4a05c, var(--gold));
  transition: width .2s linear;
}

.bar-progress > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* A 9:16 result is 640px tall at the column's full width, which pushes the
   download button and the "nothing was uploaded" line below the fold on a
   laptop. Cap it and centre it: the point of this player is to confirm the reel,
   not to be the reel's final home. */
.result video {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 44vh;
  margin: 0 auto 10px;
  border-radius: 10px;
  background: #0a1526;
}

/* ---- Caption track ---------------------------------------------------------
   One row per clip, numbered to match the badge on the tile. The value is what
   the video will actually say: a suggestion until it is typed over, empty if
   that clip should say nothing. */

.captions {
  display: grid;
  gap: 6px;
  margin: 12px 0 6px;
}

.cap-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.cap-n {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.cap-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

/* ---- End-card brand -------------------------------------------------------- */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-logo img {
  height: 44px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--navy);
  padding: 4px 7px;
}

/* ---- Play all / Play clip ------------------------------------------------------ */
/* Together under the preview. Navy when the reel plays, gold when a clip loops — the
   same gold as the loop band on the timeline. */
.transport { flex-wrap: wrap; row-gap: 6px; }
.transport .clock { margin-left: auto; }
.pv-btn { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--navy); font: inherit; font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; cursor: pointer; }
.pv-btn:hover { border-color: var(--navy); }
.pv-btn[aria-pressed="true"] { border-color: var(--navy); background: var(--navy); color: #fff; }
.pv-btn.clip[aria-pressed="true"] { border-color: var(--gold); background: var(--gold); color: #1c1305; }
.pv-btn:disabled { opacity: .5; cursor: default; }

/* The stretch "Play clip" is looping, along the strip's top edge above the clips. */
.strip .tl-loop {
  position: absolute;
  top: 1px;
  height: 4px;
  border-radius: 2px;
  background: var(--gold);
  pointer-events: none;
  z-index: 4;
}

/* ---- Focus point ------------------------------------------------------------- */
/* The photo with the frame's crop over it: solid gold where the clip ends (and
   everything outside that dimmed), dashed where it starts, a dot on the focus. */
.focus-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.focus-head label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.focus-auto { padding: 0; border: 0; background: none; color: var(--navy); font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: underline; cursor: pointer; }
.focus-stage { position: relative; overflow: hidden; border-radius: 8px; background: #0a1526; line-height: 0; cursor: crosshair; }
.focus-stage.whole { cursor: default; }
.focus-stage img { display: block; width: 100%; height: auto; }
.focus-crop { position: absolute; box-sizing: border-box; border: 2px dashed rgba(255, 255, 255, .85); pointer-events: none; }
.focus-crop.end { border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(4, 24, 44, .38); }
.focus-dot { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid #fff; border-radius: 50%; background: var(--gold); box-shadow: 0 1px 5px rgba(0, 0, 0, .45); pointer-events: none; }
