/*
 * theme.css — Photo Stitch's design-system values.
 *
 * The brief: a small, precise video tool, like a camera's record screen
 * crossed with Linear's settings panels. Cool neutrals so the photos carry
 * the colour, one "record" red for the action that makes the video, and a
 * film-strip dark for the frames in the reel. Unbounded for the display
 * lines (wide, like a title card), DM Sans for reading, DM Mono for
 * timecodes. Buttons are pills; cards are soft-cornered.
 *
 * Own tokens (both modes): --x-film is the film-strip ground around each
 * frame, --x-film-ink the text and icons on it, --x-film-hole its sprocket
 * holes.
 */

:root {
  --canvas: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --border: #dcdfe7;
  --border-strong: #b4b9c6;
  --ink: #141726;
  --muted: #5a6074;
  --accent: #d63826;
  --accent-hover: #bb2f1f;
  --accent-ink: #ffffff;
  --accent-text: #b5301f;
  --accent-strong: #962515;
  --accent-soft: #fde7e3;
  --accent-border: #f2b2a8;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #dfefe4;
  --success-strong: #126b33;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #f8ead9;
  --warning-strong: #8f4207;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #f8e1e1;
  --danger-strong: #a11818;
  --chart-1: #d63826;
  --chart-2: #3b5bdb;
  --chart-3: #0b7a62;
  --chart-4: #a15c07;
  --chart-5: #7a3fb0;
  --chart-6: #4a5568;

  --x-film: #151821;
  --x-film-ink: #f1f2f6;
  --x-film-hole: #3a3f4f;

  --font-display: "Unbounded Variable", ui-sans-serif, system-ui, sans-serif;
  --font-body: "DM Sans Variable", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "DM Sans Variable", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.03em;
  --eyebrow-tracking: 0.08em;

  --radius-btn: 999px;
  --radius-card: 1.25rem;
  --radius-input: 0.75rem;
  --shadow-card: 0 1px 2px rgba(20, 23, 38, 0.05), 0 12px 32px -18px rgba(20, 23, 38, 0.22);
  --shadow-raised: 0 18px 48px -16px rgba(20, 23, 38, 0.3);
  --shadow-btn: none;
  --btn-weight: 600;
}

html[data-theme="dark"] {
  --canvas: #0c0e15;
  --surface: #151823;
  --surface-2: #1d2130;
  --border: #272c3d;
  --border-strong: #3d4459;
  --ink: #eef0f6;
  --muted: #9ba2b6;
  --accent: #ff6b57;
  --accent-hover: #ff8371;
  --accent-ink: #1b0703;
  --accent-text: #ff8a78;
  --accent-strong: #ffb4a8;
  --accent-soft: #35160f;
  --accent-border: #6a2a1f;
  --success: #22a35a;
  --success-ink: #04140a;
  --success-soft: #11291b;
  --success-strong: #6fd39a;
  --warning: #d9822b;
  --warning-ink: #1a0d02;
  --warning-soft: #2f2112;
  --warning-strong: #f2b26b;
  --danger: #e5484d;
  --danger-ink: #1a0405;
  --danger-soft: #36161a;
  --danger-strong: #ff9b9e;
  --chart-1: #ff6b57;
  --chart-2: #7c95ff;
  --chart-3: #3cc9a5;
  --chart-4: #e0a43c;
  --chart-5: #b98af0;
  --chart-6: #9aa3b8;

  --x-film: #05060a;
  --x-film-ink: #eef0f6;
  --x-film-hole: #2b3041;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-raised: 0 20px 50px -16px rgba(0, 0, 0, 0.75);
}

/*
 * app.css — what no primitive covers in Photo Stitch: the ground, the brand
 * mark, the drop zone, the reel's film-strip frames, the segmented choices,
 * the sliders and the finished video. Tokens only; black and white appear
 * only as depth (shadows and scrims).
 */

/* ---- Ground ---------------------------------------------------------------- */
.page-glow {
  background:
    radial-gradient(56rem 26rem at 12% -8%, color-mix(in srgb, var(--accent-soft) 85%, transparent), transparent 70%),
    var(--canvas);
  min-height: 100vh;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.625rem;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand-mark .icon { width: 1.05rem; height: 1.05rem; }

/* ---- Drop zone (the empty reel) --------------------------------------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 3.5rem 1.5rem;
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: calc(var(--radius-card) - 0.25rem);
  background: var(--surface-2);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.dropzone-art {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.reel.is-dragover .dropzone { border-color: var(--accent); background: var(--accent-soft); }
.reel.is-dragover .strip { outline: 2px dashed var(--accent); outline-offset: 0.5rem; border-radius: 0.75rem; }

/* ---- The reel: one film-strip frame per photo -------------------------------- */
.frame { position: relative; display: flex; min-width: 0; flex-direction: column; gap: 0.5rem; }
.frame.is-new { animation: frame-in 300ms var(--ease-out) both; }
@keyframes frame-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.frame.is-dragging { opacity: 0.4; }

.frame-film {
  position: relative;
  padding: 0.875rem 0.375rem;
  border-radius: 0.75rem;
  background: var(--x-film);
  cursor: grab;
}
.frame-film:active { cursor: grabbing; }
/* Sprocket holes along the top and bottom edge. */
.frame-film::before,
.frame-film::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  right: 0.5rem;
  height: 0.3rem;
  border-radius: 1px;
  background-image: repeating-linear-gradient(90deg, var(--x-film-hole) 0 0.45rem, transparent 0.45rem 0.8rem);
}
.frame-film::before { top: 0.3rem; }
.frame-film::after { bottom: 0.3rem; }

.frame.drop-before .frame-film { box-shadow: -5px 0 0 0 var(--accent); }
.frame.drop-after .frame-film { box-shadow: 5px 0 0 0 var(--accent); }

/* The picture, in the shape and fit the video will use. */
.frame-pic {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 0.25rem;
  background: var(--x-film);
}
.strip[data-shape="portrait"] .frame-pic { aspect-ratio: 9 / 16; }
.strip[data-shape="square"] .frame-pic { aspect-ratio: 1 / 1; }
.frame-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.frame-pic .frame-bg { display: none; object-fit: cover; filter: blur(10px) brightness(0.75); transform: scale(1.15); }
.strip[data-fit="fill"] .frame-pic .frame-main { object-fit: cover; }
.strip[data-fit="blur"] .frame-pic .frame-bg { display: block; }

.frame-no {
  position: absolute;
  top: 1.25rem;
  left: 0.875rem;
  padding: 0.125rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--x-film) 78%, transparent);
  color: var(--x-film-ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.2rem;
}

.frame-tools {
  position: absolute;
  top: 1.25rem;
  right: 0.875rem;
  display: flex;
  gap: 0.125rem;
  padding: 0.125rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--x-film) 78%, transparent);
  transition: opacity 150ms var(--ease);
}
@media (hover: hover) {
  .frame-tools { opacity: 0; }
  .frame:hover .frame-tools, .frame:focus-within .frame-tools { opacity: 1; }
}
.frame-btn {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  color: var(--x-film-ink);
  transition: background-color 120ms var(--ease);
}
.frame-btn .icon { width: 0.95rem; height: 0.95rem; }
.frame-btn:hover { background: color-mix(in srgb, var(--x-film-ink) 20%, transparent); }
.frame-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.frame-btn:disabled { opacity: 0.35; pointer-events: none; }

.frame-first {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  height: 2rem;
  padding-inline: 0.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ---- Segmented choices -------------------------------------------------------- */
.seg {
  display: grid;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius-input);
  background: var(--surface-2);
}
.seg-opt { position: relative; display: block; min-width: 0; cursor: pointer; }
.seg-opt input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.seg-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.5rem 0.25rem;
  border-radius: calc(var(--radius-input) - 0.25rem);
  font-size: 0.8125rem;
  text-align: center;
  color: var(--muted);
  transition: background-color 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.seg-sub { font-size: 0.6875rem; opacity: 0.85; }
.seg-opt:hover .seg-box { color: var(--ink); }
.seg-opt input:checked + .seg-box {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
}
.seg-opt input:focus-visible + .seg-box { box-shadow: var(--ring); }

.ratio { display: inline-block; flex-shrink: 0; border: 1.5px solid currentColor; border-radius: 2px; }
.ratio-landscape { width: 1rem; height: 0.6rem; }
.ratio-portrait { width: 0.6rem; height: 1rem; }
.ratio-square { width: 0.8rem; height: 0.8rem; }

/* ---- Sliders ------------------------------------------------------------------ */
.range { width: 100%; height: 1.5rem; cursor: pointer; accent-color: var(--accent); }

/* ---- Render stage and result ---------------------------------------------------- */
.error-log {
  max-height: 12rem;
  margin-top: 0.5rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
}

.result { animation: frame-in 360ms var(--ease-out) both; }
.result-video {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin-inline: auto;
  border-radius: 0.75rem;
  background: var(--x-film);
}
