/* Cliptica — Caption Studio (js/ui/caption-studio.js) + the shared "Style"
   section on /new, where ONE live preview serves both the caption picker and
   the framing list.

   Layout: a sticky 9:16 preview on the left, the choices on the right —
   caption styles as a gallery (they are visual, a list would hide them),
   framing as the existing option list. Stacks on phones with the preview on
   top so a tap on a style is answered on screen. */

/* The caption faces the presets actually use — same files the editor and the
   renderer load (captions/font_registry.py). Anton comes from Google Fonts in
   new.html's <head>. */
@font-face{font-family:'Komika Axis';src:url('/fonts/KOMIKAX_.ttf') format('truetype');font-display:swap}
@font-face{font-family:'Montserrat Black';src:url('/fonts/montserrat-v31-latin-900.ttf') format('truetype');font-weight:900;font-display:swap}
@font-face{font-family:'Montserrat ExtraBold';src:url('/fonts/montserrat-v31-latin-800.ttf') format('truetype');font-weight:800;font-display:swap}
@font-face{font-family:'Poppins ExtraBold';src:url('/fonts/poppins-v24-latin-800.ttf') format('truetype');font-weight:800;font-display:swap}
@font-face{font-family:'Bebas Neue';src:url('/fonts/BebasNeue-Regular.ttf') format('truetype');font-display:swap}
/* Headline faces (modules/headline_choice.AUTO_HEADLINE_FONTS). Anton is also
   declared here for /project, which does not load it from Google Fonts. */
@font-face{font-family:'Anton';src:url('/fonts/Anton-Regular.ttf') format('truetype');font-display:swap}
@font-face{font-family:'Archivo Black';src:url('/fonts/ArchivoBlack-Regular.ttf') format('truetype');font-display:swap}
@font-face{font-family:'Lilita One';src:url('/fonts/LilitaOne-Regular.ttf') format('truetype');font-display:swap}

/* ── Section ─────────────────────────────────────────────────────────────── */
.look {
  display: grid; gap: 20px; margin-top: 16px;
  grid-template-columns: 200px minmax(0, 1fr);
  align-items: start;
}
.look-hero { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 9px; }
.look-hero .fr-stage { box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 18px 40px -22px rgba(0,0,0,.8); }
[data-theme="light"] .look-hero .fr-stage { box-shadow: inset 0 0 0 1px rgba(24,24,27,.16), 0 18px 36px -24px rgba(24,24,27,.45); }
.look-cap { display: flex; flex-direction: column; gap: 3px; padding: 0 2px; min-height: 44px; }
.look-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.35; }
.look-desc { font-size: 11px; line-height: 1.45; color: var(--muted); }
.look-spec {
  font-size: 10px; font-weight: 500; letter-spacing: .03em; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px; padding: 0 2px;
}
.look-main { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.look-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.look-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.look-aside { font-size: 11px; color: var(--muted); }
/* Hover is a desktop affordance; a phone gets the instruction that works there. */
.look-aside-touch { display: none; }
@media (hover: none) { .look-aside-hover { display: none; } .look-aside-touch { display: inline; } }

/* No preview column of its own inside the shared section. */
.fr-studio.fr-studio-nohero { grid-template-columns: minmax(0, 1fr); margin-top: 0; }

@media (max-width: 600px) {
  .look { grid-template-columns: 1fr; gap: 16px; }
  .look-hero { position: static; width: 184px; justify-self: center; }
  .look-cap { text-align: center; min-height: 0; }
}

/* ── Caption gallery ─────────────────────────────────────────────────────── */
.cs-picker { display: flex; flex-direction: column; gap: 12px; }
.cs-picker.is-loading .cs-grid { min-height: 230px; }
.cs-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}
@media (max-width: 380px) { .cs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.cs-tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 0; border: 0; background: none; color: inherit; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.cs-tile[hidden] { display: none; }
.cs-tile-stage {
  position: relative; display: block; width: 100%; aspect-ratio: 4 / 3;
  border-radius: 10px; overflow: hidden; background: #111114;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: box-shadow 160ms var(--snap), transform 160ms var(--snap);
}
.cs-tile-canvas { display: block; width: 100%; height: 100%; }
.cs-tile:hover .cs-tile-stage { box-shadow: inset 0 0 0 1px var(--border2); transform: translateY(-1px); }
.cs-tile:active .cs-tile-stage { transform: scale(.98); }
.cs-tile:focus-visible { outline: none; }
.cs-tile:focus-visible .cs-tile-stage { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
/* Selected: a solid accent ring + a check — a control state, not decoration. */
.cs-tile.is-on .cs-tile-stage { box-shadow: inset 0 0 0 2px var(--accent); }
.cs-tile.is-on:focus-visible .cs-tile-stage { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

.cs-tile-check {
  position: absolute; top: 6px; right: 6px; width: 18px; height: 18px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: #FFF7F2;
  transform: scale(.4); opacity: 0;
  transition: transform 180ms var(--snap), opacity 140ms var(--snap);
}
.cs-tile-check svg { width: 11px; height: 11px; }
.cs-tile.is-on .cs-tile-check { transform: scale(1); opacity: 1; }

.cs-tile-badge {
  position: absolute; top: 6px; left: 6px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 5px; border-radius: 999px;
  background: rgba(11,11,13,.72); color: #FFB08F;
  border: 1px solid rgba(232,73,15,.55);
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.cs-tile-badge svg { width: 10px; height: 10px; color: var(--accent); }

.cs-tile-name {
  font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 140ms var(--snap);
}
.cs-tile:hover .cs-tile-name { color: var(--text); }
.cs-tile.is-on .cs-tile-name { color: var(--text); font-weight: 600; }

.cs-more {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border2); background: var(--s2); color: var(--text);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background 130ms var(--snap), border-color 130ms var(--snap);
}
.cs-more[hidden] { display: none; }
.cs-more:hover { background: var(--s3); }
.cs-more svg { width: 14px; height: 14px; transition: transform 200ms var(--snap); }
.cs-more.is-open svg { transform: rotate(180deg); }

/* ── Emoji / glow / position ─────────────────────────────────────────────── */
.cs-opts {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 16px; padding-top: 12px; border-top: 1px solid var(--border);
}
.cs-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 7px 13px 7px 11px; border-radius: 999px;
  border: 1px solid var(--border2); background: var(--s2); color: var(--muted);
  font-size: 12.5px; font-weight: 500; cursor: pointer; touch-action: manipulation;
  transition: background 140ms var(--snap), border-color 140ms var(--snap), color 140ms var(--snap);
}
.cs-pill svg { width: 15px; height: 15px; }
.cs-pill:hover { color: var(--text); border-color: var(--border2); background: var(--s3); }
.cs-pill.is-on {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, var(--s2));
}
.cs-pill.is-on svg { color: var(--accent2); }

.cs-pos { display: flex; align-items: center; gap: 10px; }
.cs-pos-label { font-size: 12px; color: var(--muted); }
.cs-seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--s2); border: 1px solid var(--border);
}
.cs-seg-btn {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 30px; padding: 5px 10px; border: 0; border-radius: 7px;
  background: none; color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer; touch-action: manipulation;
  transition: background 140ms var(--snap), color 140ms var(--snap);
}
.cs-seg-btn svg { width: 14px; height: 14px; }
.cs-seg-btn:hover:not(:disabled) { color: var(--text); }
.cs-seg-btn.is-on { background: var(--s3); color: var(--text); box-shadow: 0 1px 0 rgba(0,0,0,.25), inset 0 0 0 1px var(--border2); }
.cs-seg-btn.is-on svg { color: var(--accent2); }
.cs-seg-btn:disabled { cursor: not-allowed; }
.cs-pos.is-off .cs-seg { opacity: .45; }

.cs-note[hidden] { display: none; }
.cs-note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

@media (max-width: 600px) {
  .cs-opts { flex-direction: column; align-items: stretch; }
  .cs-toggles .cs-pill { flex: 1; justify-content: center; }
  .cs-pos { justify-content: space-between; }
}

/* ── Headline picker (js/ui/headline-studio.js) ────────────────────────────
   Reuses the caption tiles' look; the tiles show the TOP of a 9:16 frame,
   which is where the headline lives. */
.hs-picker { display: flex; flex-direction: column; gap: 12px; }
.hs-layouts { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hs-tile-stage { aspect-ratio: 16 / 10; }

.hs-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
/* Top-aligned with the first row of chips (34px tall) when the row wraps. */
.hs-row-label { flex: 0 0 64px; font-size: 12px; line-height: 34px; color: var(--muted); }
.hs-fonts { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.hs-font {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border2); background: var(--s2); color: var(--muted);
  font-size: 12.5px; cursor: pointer; touch-action: manipulation;
  transition: background 140ms var(--snap), border-color 140ms var(--snap), color 140ms var(--snap);
}
.hs-font svg { width: 13px; height: 13px; color: var(--accent2); }
.hs-font-face { font-size: 14px; line-height: 1; letter-spacing: .01em; }
.hs-font:hover { color: var(--text); background: var(--s3); }
.hs-font.is-on {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, var(--s2));
}
.hs-font:focus-visible, .hs-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hs-swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.hs-swatch {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer; touch-action: manipulation;
}
.hs-swatch-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
  transition: transform 140ms var(--snap), box-shadow 140ms var(--snap);
}
.hs-swatch:hover .hs-swatch-dot { transform: scale(1.1); }
.hs-swatch.is-on .hs-swatch-dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--sw); }

@media (max-width: 600px) {
  .hs-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .hs-row-label { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-tile-stage, .cs-tile-check, .cs-more svg, .cs-pill, .cs-seg-btn,
  .hs-font, .hs-swatch-dot { transition: none; }
}
