/* Framepick — cutting-room contact sheet. Tokens mirror docs/DESIGN.md exactly. */

:root {
  --bg: #efe9dd;
  --surface-1: #f7f3ea;
  --surface-2: #e4dccb;
  --ink: #211d17;
  --muted: #6f6656;
  --line: #d3c9b4;
  --accent: #d63e26;
  --accent-ink: #a8321d;
  --support: #2f4a53;
  --success: #3f7d55;
  --danger: #b23a2a;

  --radius-ctl: 4px;
  --radius-card: 8px;

  --shadow-card: 0 1px 0 #ffffffcc inset, 0 2px 8px rgba(33, 29, 23, 0.1),
    0 12px 32px rgba(33, 29, 23, 0.08);

  --font-display: Fraunces, "Times New Roman", serif;
  --font-ui: Inter, system-ui, -apple-system, sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--bg);
  /* Paper treatment: a warm vignette + a faint fibrous grain so it never reads as a flat fill. */
  background-image: radial-gradient(
      120% 90% at 50% -10%,
      rgba(255, 252, 245, 0.9),
      rgba(239, 233, 221, 0) 55%
    ),
    radial-gradient(100% 120% at 100% 110%, rgba(47, 74, 83, 0.06), rgba(239, 233, 221, 0) 60%);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px);
}

/* ---- Header / wordmark -------------------------------------------------- */

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gh-link {
  flex-shrink: 0;
  text-decoration: none;
  white-space: nowrap;
  align-self: center;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(31px, 6vw, 44px);
  letter-spacing: -0.01em;
  line-height: 1;
  margin: 0;
  position: relative;
}

.wordmark .dot {
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  font-size: 15px;
  max-width: 46ch;
}

/* ---- Layout ------------------------------------------------------------- */

.stage {
  display: grid;
  gap: clamp(16px, 3vw, 28px);
  grid-template-columns: 1fr;
  margin-top: 28px;
}

@media (min-width: 900px) {
  .stage.has-results {
    grid-template-columns: 300px 1fr;
    align-items: start;
  }
}

/* ---- Dropzone ----------------------------------------------------------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  min-height: 46vh;
  padding: 32px;
  background: var(--surface-1);
  border: 2px dashed var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: border-color 180ms var(--ease), background 180ms var(--ease),
    transform 180ms var(--ease);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #fbf7ee;
  transform: translateY(-2px);
}

.dropzone h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  margin: 0;
}

.dropzone p {
  color: var(--muted);
  margin: 0;
  max-width: 42ch;
}

/* ---- Buttons / controls ------------------------------------------------- */

.btn {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent-ink);
  border-radius: var(--radius-ctl);
  padding: 12px 20px;
  min-height: 44px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--accent-ink);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease),
    background 120ms var(--ease);
}

.btn:hover {
  /* Deepen on hover — a lighter vermilion would drop white text below WCAG AA. */
  background: #c9381f;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--accent-ink);
}

.btn:focus-visible,
.file-input:focus-visible + .btn {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn.ghost {
  color: var(--support);
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---- Notices ------------------------------------------------------------ */

.notice {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line);
  background: var(--surface-1);
  font-size: 14px;
}

.notice.warn {
  border-color: var(--danger);
  color: var(--danger);
  background: #f7ebe6;
}

.notice[hidden] {
  display: none;
}

.footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer a {
  color: var(--support);
}

/* ---- Stage layout (post-load) ------------------------------------------ */

.stage.has-results .dropzone {
  min-height: auto;
  padding: 20px;
  gap: 8px;
}

.stage.has-results .dropzone h2 {
  font-size: 19px;
}

.stage.has-results .dropzone .dropzone-glyph {
  width: 40px;
  height: 40px;
}

.dropzone-glyph {
  width: 64px;
  height: 64px;
  /* Sprocket-punched film cell — the brand glyph, drawn as an inline SVG (no binary asset). */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Crect width='48' height='48' rx='8' fill='%23d63e26'/%3E%3Crect x='14' y='6' width='20' height='36' rx='2' fill='%23f7f3ea'/%3E%3Cg fill='%23efe9dd'%3E%3Crect x='5' y='7' width='4' height='4' rx='1'/%3E%3Crect x='5' y='16' width='4' height='4' rx='1'/%3E%3Crect x='5' y='25' width='4' height='4' rx='1'/%3E%3Crect x='5' y='34' width='4' height='4' rx='1'/%3E%3Crect x='39' y='7' width='4' height='4' rx='1'/%3E%3Crect x='39' y='16' width='4' height='4' rx='1'/%3E%3Crect x='39' y='25' width='4' height='4' rx='1'/%3E%3Crect x='39' y='34' width='4' height='4' rx='1'/%3E%3C/g%3E%3C/svg%3E")
    center / contain no-repeat;
  filter: drop-shadow(0 6px 14px rgba(214, 62, 38, 0.28));
}

.dropzone-note {
  font-size: 13px;
  color: var(--support);
  font-weight: 600;
  word-break: break-word;
}
.dropzone-note[hidden] {
  display: none;
}

/* ---- Panels / controls -------------------------------------------------- */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.controls {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.controls[hidden] {
  display: none;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.field-head label {
  font-weight: 600;
  font-size: 14px;
}

.field-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent-ink);
  background: #f2d9d0;
  border-radius: var(--radius-ctl);
  padding: 1px 8px;
  font-size: 13px;
}

.field-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

/* ---- Range slider (fully themed, ≥44px target) -------------------------- */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  cursor: pointer;
}

.slider:focus-visible {
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(33, 29, 23, 0.28);
  transition: transform 120ms var(--ease), box-shadow 120ms var(--ease);
}
.slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(33, 29, 23, 0.28);
}

.slider:hover::-webkit-slider-thumb {
  transform: scale(1.08);
}
.slider:active::-webkit-slider-thumb {
  transform: scale(0.94);
}
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(214, 62, 38, 0.35);
}
.slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(214, 62, 38, 0.35);
}

/* ---- Stats readout ------------------------------------------------------ */

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  overflow: hidden;
}

.stat {
  background: var(--surface-1);
  padding: 12px 14px;
}

.stat dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.export-all:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.export-all:disabled:hover {
  background: var(--accent);
}

/* ---- Results / progress ------------------------------------------------- */

.results[hidden] {
  display: none;
}

.progress {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 20px;
  overflow: hidden;
}
.progress[hidden] {
  display: none;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.progress-label {
  font-weight: 600;
}
.progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
  font-weight: 600;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f0663f);
  transition: width 160ms var(--ease);
}

/* Vermilion scan line sweeping down while analysis runs. */
.progress-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.9;
  animation: scan 1.2s var(--ease) infinite;
}

@keyframes scan {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(120px);
  }
}

/* ---- Filmstrip contact sheet -------------------------------------------- */

.filmstrip {
  position: relative;
  background: var(--surface-2);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 30px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.filmstrip:empty {
  display: none;
}

/* Punched sprocket rails, top and bottom — the detail that sells "film". */
.filmstrip::before,
.filmstrip::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  height: 8px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--support) 0 8px,
    transparent 8px 22px
  );
  border-radius: 2px;
  opacity: 0.5;
}
.filmstrip::before {
  top: 12px;
}
.filmstrip::after {
  bottom: 12px;
}

.frame-cell {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 1px 0 #ffffff55 inset, 0 4px 12px rgba(33, 29, 23, 0.14);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}

.frame-cell:hover,
.frame-cell:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(33, 29, 23, 0.2);
}

.frame-cell canvas {
  display: block;
  width: 100%;
  height: auto;
}

.timecode {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(33, 29, 23, 0.72);
  padding: 2px 7px;
  border-radius: var(--radius-ctl);
  backdrop-filter: blur(2px);
}

.frame-dl {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-ctl);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 140ms var(--ease), transform 140ms var(--ease),
    background 140ms var(--ease);
}
.frame-cell:hover .frame-dl,
.frame-cell:focus-within .frame-dl,
.frame-dl:focus-visible {
  opacity: 1;
  transform: translateY(0);
}
.frame-dl:hover {
  background: var(--accent-ink);
}
.frame-dl:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -2px;
}

.results-empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 16px;
}
.results-empty[hidden] {
  display: none;
}

/* ---- Toast (export confirmation) ---------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--surface-1);
  padding: 12px 18px;
  border-radius: var(--radius-card);
  box-shadow: 0 8px 28px rgba(33, 29, 23, 0.32);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  z-index: 10;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast[hidden] {
  display: block;
}
.toast::before {
  content: "✓ ";
  color: var(--success);
}

/* ---- About / FAQ (below the fold, search-facing) ----------------------- */

.about {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  max-width: 68ch;
}

.about h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 31px;
  margin: 0 0 16px;
}

.about h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 32px 0 12px;
}

.about p {
  color: var(--ink);
  margin: 0 0 14px;
}

.steps {
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
}

.steps li {
  margin-bottom: 8px;
}

.faq {
  margin: 0;
}

.faq dt {
  font-weight: 600;
  margin-top: 16px;
}

.faq dd {
  margin: 6px 0 0;
  color: var(--muted);
}

.about code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--radius-ctl);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
