/* "Your card deck" — the full-screen editor at /video-deck and the same
   panel as a modal from the Make-a-video column (plans/card-deck-2 S3).

   Deliberately the SAME surface language as the clip-trim overlay in
   broll.css: elevated panel on a dimmed page, radii from tokens.css
   (6/10/12), warm paper behind, violet primary. A second modal idiom on
   one machine would read as a second app.

   The one new shape here is the deck itself: a wrapping grid of fixed-
   geometry cards, because a deck IS its order and its order is what you
   rearrange. Media is CONTAINED inside the card (never cropped to it):
   the card's proportions belong to the deck, the photo's belong to the
   photo, and letterboxing is the only honest way to keep both. */

.deck-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;          /* over the views, under toasts (1500) — as the trim modal */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.deck-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  animation: deck-editor-fade 160ms ease-out;
}

/* align-items is set EXPLICITLY, not left to the default, because the panel
   used to carry the container's own class (`deck-editor-overlay`) as its
   mode modifier and inherited that rule's `align-items: center` — which
   shrink-wrapped every row to its content and squeezed the card grid down
   to a single column. The mode class is now `deck-editor-mode-*`; this line
   is the second lock on the same door. */
.deck-editor-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.deck-editor-panel:focus {
  outline: none;          /* it takes focus on open; the ring would be noise */
}

.deck-editor-overlay .deck-editor-panel {
  width: min(1100px, 100%);
  max-height: 100%;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  animation: deck-editor-rise 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Full-screen mode fills the content area rather than floating in it: the
   deck is the whole job on this route, not an aside to something else. */
.deck-editor-mode-screen {
  flex: 1;
  min-height: calc(100vh - 140px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

@keyframes deck-editor-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes deck-editor-rise {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Reduced motion: appear, do not move. */
.deck-editor-no-motion .deck-editor-backdrop,
.deck-editor-no-motion .deck-editor-panel {
  animation: none;
}

.deck-editor-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.deck-editor-title-text {
  margin: 0;
  font-size: 1.05em;
}

.deck-editor-title-sub {
  margin: 0;
}

.deck-editor-notice,
.deck-editor-problem {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
}

.deck-editor-problem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.deck-editor-error {
  margin: 0;
  color: var(--text);
}

.deck-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 8px;
}

/* One number for the whole deck, sitting beside "+ Add files". Pushed to
   the right on a wide panel, wrapping under the button on a narrow one. */
.deck-equal {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.deck-equal-label {
  white-space: nowrap;
}

.deck-equal-tick {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.deck-equal-secs {
  width: 96px;
}

.deck-gather {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.deck-gather-q {
  font-weight: 600;
}

.deck-gather-name {
  flex: 1 1 220px;
  min-width: 160px;
}

/* The scrolling box. Only this scrolls — the title and the buttons stay
   put, so the deck can be as long as it likes without the Make-the-video
   button walking off the bottom of the screen. */
.deck-grid-host {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 8px;
  list-style: none;
}

.deck-grid-dragging {
  cursor: grabbing;
}

/* ---- The sheet ---------------------------------------------------------
   The deck reads as a card-sorting SHEET: every cell in the grid — filled
   or empty, card or drop target — is the same dashed rounded frame, so
   dragging a card is visibly moving it between slots that already exist
   rather than into empty air. One shape, three states: a card in it, a
   place to drop one, an invitation to add one. */
.deck-cell,
.deck-tile,
.deck-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  min-height: 132px;
}

.deck-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-color: color-mix(in srgb, var(--text-muted) 34%, transparent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  touch-action: none;      /* the drag is ours, not the scroller's */
  user-select: none;
}

/* Untimed is a state, not an error: the card is fine, it just can't be
   rendered yet, and the footer says so in words. Now that every cell is
   dashed, the mark is COLOUR and a faint wash — a dashed edge no longer
   distinguishes anything. */
.deck-tile-untimed {
  border-color: var(--sunny-ink);
  background: color-mix(in srgb, var(--sunny-ink) 7%, var(--bg-elevated));
}

/* The empty cells: grey, quiet, and the same frame as everything else. */
.deck-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  list-style: none;
}

.deck-cell-blank {
  opacity: 0.5;
}

/* The circled +. Grey by owner's ruling: adding files is the ordinary next
   move here, not the loud one. */
.deck-cell-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid color-mix(in srgb, var(--text-muted) 45%, transparent);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 120ms ease-out, color 120ms ease-out, background 120ms ease-out;
}

.deck-cell-add:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg-sunken);
}

.deck-cell-add:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.deck-cell-plus {
  font-size: 1.5rem;
  line-height: 1;
}

.deck-cell-hint {
  margin: 0;
  padding: 0 6px;
  color: var(--text-muted);
  font-size: 0.8em;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .deck-cell-add { transition: none; }
}

.deck-tile-dragging {
  opacity: 0.35;
}

.deck-tile-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.deck-tile-img {
  width: 100%;
  height: 100%;
  object-fit: contain;     /* contained, never cropped — see the header note */
}

.deck-tile-thumb-blank {
  font-size: 1.6em;
  opacity: 0.5;
}

.deck-tile-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.deck-tile-index {
  flex: none;
  min-width: 20px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 0.8em;
  text-align: center;
}

.deck-tile-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9em;
}

.deck-tile-seconds {
  width: 100%;
}

/* A measured suggestion sits in the placeholder, greyed and labelled — it
   is never typed into the box, because a number in a box is
   indistinguishable from a number he chose. */
.deck-tile-seconds::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.deck-tile-actions {
  display: flex;
  gap: 4px;
}

.deck-tile-actions .btn {
  flex: 1;
  padding: 2px 4px;
}

.deck-tile-remove {
  flex: 2;
}

/* Where the card will land: a dashed rounded rectangle sitting in the
   grid's own flow, so it occupies the actual destination rather than
   hinting at it from the side. */
.deck-drop {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* The tile under the pointer. Body-level and pointer-events:none so it can
   never become a drop target for its own drag. */
.deck-ghost {
  position: fixed;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  font-size: 0.85em;
  text-align: center;
  pointer-events: none;
  opacity: 0.9;
  transform: rotate(-2deg);   /* a card lifted off the pile */
  transition: transform 120ms ease-out;
}

.deck-ghost.deck-no-motion {
  transform: none;
  transition: none;
}

.deck-editor-empty {
  margin: 12px 0 0;
}

.deck-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.deck-editor-reason {
  margin: 0;
  flex: 1 1 240px;
}

.deck-editor-buttons {
  display: flex;
  gap: 8px;
}

.deck-narrate-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-top: 10px;
}

.deck-narrate-checkbox {
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--primary);
}

/* ---- Style, fly-in, speed, destinations (photo-pile wave, S6) -----------

   Four rows of chips between the toolbar and the deck itself, each one a
   label on the left and its choices on the right so the eye reads down a
   single column of questions. Chips are the b-roll screen's output chips
   to the pixel (pill, sunken when off, violet when on) — the owner has
   already learnt that shape means "tap to choose", and a second chip
   language on one machine would be a second app. */

.deck-style {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.deck-style-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.deck-style-row[hidden] {
  display: none;          /* hidden is hidden even under a flex parent */
}

.deck-style-legend {
  flex: none;
  min-width: 148px;
  padding-top: 3px;
  font-size: 0.9em;
  color: var(--text-muted);
}

.deck-style-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.deck-chip {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85em;
  cursor: pointer;
}

.deck-chip:hover {
  border-color: var(--primary);
}

.deck-chip[disabled],
.deck-style-radio:disabled + .deck-chip {
  opacity: 0.55;
  cursor: default;
}

/* The radio itself does the work — keyboard, arrow keys, screen readers —
   and the label wears the look. Hidden by clipping, never by
   display:none, which would take it out of the tab order with it. */
.deck-style-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.deck-style-radio:checked + .deck-chip,
.deck-dest-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.deck-style-radio:focus-visible + .deck-chip,
.deck-dest-chip:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* "Where it's going" folds away: it is the tallest block in the editor and
   the deck is what the owner came here to look at. A real <details>, so the
   keyboard and the screen reader need nothing from us; block display
   because .deck-style-row's flex row is for the chip rows, not for a
   disclosure. */
.deck-dest-row {
  display: block;
}

.deck-dest-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  list-style: none;      /* the default marker, replaced by our own below */
  cursor: pointer;
}

.deck-dest-summary::-webkit-details-marker {
  display: none;
}

.deck-dest-summary::after {
  content: "▸";
  color: var(--text-muted);
  font-size: 0.8em;
  transition: transform 120ms ease-out;
}

.deck-dest-row[open] > .deck-dest-summary::after {
  transform: rotate(90deg);
}

.deck-dest-summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.deck-dest-summary .deck-style-legend {
  min-width: 0;
  padding-top: 0;
  color: var(--text);
}

.deck-dest-body {
  flex: 1 1 320px;
  min-width: 220px;
  padding-top: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .deck-dest-summary::after { transition: none; }
}

.deck-dest-hint {
  margin: 2px 0 6px;
}

.deck-dest-group-label {
  margin: 8px 0 4px;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-muted);
}

.deck-dest-groups > .deck-dest-group-label:first-child {
  margin-top: 0;
}
