/* 看片台 — a photographer's light table.
   Quiet UI; the one loud thing is the red grease-pencil mark. */

:root {
  --table: #e7ecf0;
  --lit: #fafbfc;
  --ink: #1c2631;
  --ink-2: #5b6775;
  --rule: #c5ced8;
  --marker: #c4122f;
  --focus: #1f6feb;

  --sans: "Noto Sans TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", system-ui, sans-serif;
  --hand: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius-sm: 6px;

  color-scheme: light dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --table: #171c22;
    --lit: #222931;
    --ink: #e4e9ee;
    --ink-2: #98a4b1;
    --rule: #38414c;
    --marker: #ff5a70;
    --focus: #6aa7ff;
  }
}

*, *::before, *::after { box-sizing: inherit; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--table);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2 { margin: 0; font-weight: 700; }

button, input, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--ink-2); margin: 0; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--s5) var(--s5) var(--s4);
}

.brand { display: flex; align-items: center; gap: var(--s3); }
.brand h1 { font-size: 22px; letter-spacing: 0.08em; }

/* a 35mm frame with sprocket holes */
.brand-mark {
  width: 28px; height: 22px;
  border-radius: 3px;
  background:
    radial-gradient(circle, var(--table) 1.3px, transparent 1.6px) 0 1px / 5px 4px repeat-x,
    radial-gradient(circle, var(--table) 1.3px, transparent 1.6px) 0 17px / 5px 4px repeat-x,
    var(--ink);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 6px 3px;
  background: var(--lit);
  border-radius: 1px;
}

.link-button {
  background: none; border: 0; padding: var(--s2) 0;
  color: var(--ink-2); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-button:hover { color: var(--ink); }

/* ------------------------------------------------------------ buttons */

.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0 var(--s5);
  border-radius: var(--radius-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.primary { background: var(--ink); color: var(--lit); border: 1px solid var(--ink); }
.primary:hover { filter: brightness(1.15); }
.secondary { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.secondary:hover { border-color: var(--ink-2); }
.primary:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }

/* --------------------------------------------------------------- gate */

.gate { display: grid; place-items: center; padding: var(--s7) var(--s5); }
.gate-form {
  width: min(400px, 100%);
  display: grid; gap: var(--s4);
  background: var(--lit);
  padding: var(--s6);
  border-radius: var(--radius-sm);
}
.gate-form h2 { font-size: 20px; }
.gate-form p { margin: 0; color: var(--ink-2); font-size: 15px; }

.field input, .field textarea {
  width: 100%;
  padding: var(--s3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--lit);
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--ink-2); outline: none; }
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.form-error { margin: 0; color: var(--marker); font-weight: 500; }

/* -------------------------------------------------------------- bench */

.bench {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--s5) var(--s7);
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
  gap: var(--s6);
  align-items: start;
}

@media (max-width: 860px) {
  .bench { grid-template-columns: 1fr; gap: var(--s5); padding: 0 var(--s4) var(--s6); }
  .topbar { padding: var(--s4); }
}

/* The lit panel. The photo is the only thing on it. */
.plate { position: sticky; top: var(--s4); display: grid; gap: var(--s4); }
@media (max-width: 860px) { .plate { position: static; } }

.stage {
  background: var(--lit);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px var(--rule), 0 0 60px 0 color-mix(in srgb, var(--lit) 70%, transparent);
  min-height: min(62vh, 620px);
  display: grid;
  place-items: center;
  padding: var(--s6);
  position: relative;
}
@media (max-width: 860px) { .stage { min-height: 300px; padding: var(--s4); } }

.dropzone {
  width: 100%; height: 100%;
  min-height: inherit;
  display: grid; place-content: center; gap: var(--s2);
  text-align: center;
  border: 1.5px dashed var(--rule);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: var(--s5);
}
.stage.is-dragging .dropzone { border-color: var(--marker); }
.dropzone-title { font-size: 20px; font-weight: 500; }
.dropzone-sub { color: var(--ink-2); font-size: 15px; }

.slide { margin: 0; display: grid; justify-items: center; gap: var(--s3); width: 100%; }
.slide img, .slide video {
  display: block;
  max-width: 100%;
  max-height: min(56vh, 560px);
  object-fit: contain;
  border: 6px solid #fff;
  box-shadow: 0 1px 2px rgba(28, 38, 49, 0.25);
  /* checkerboard so transparent PNGs read as transparent */
  background: repeating-conic-gradient(#e9edf1 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}

/* grease-pencil note under the slide */
.annotation {
  font-family: var(--hand);
  color: var(--marker);
  font-size: 22px;
  line-height: 1.3;
  min-height: 1.3em;
  transform: rotate(-1.5deg);
}

.meter { display: grid; gap: var(--s2); }
.meter-bar { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.meter-bar span {
  display: block; height: 100%; width: 0;
  background: var(--marker);
  transition: width 0.4s ease;
}
.meter.is-indeterminate .meter-bar span {
  width: 30%;
  animation: sweep 1.4s ease-in-out infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.meter-text { margin: 0; color: var(--ink-2); font-size: 15px; }

.result-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
#hold-compare { touch-action: none; }
#hold-compare.is-holding { border-color: var(--marker); color: var(--marker); }

/* -------------------------------------------------------------- steps */

.steps ol {
  list-style: none;
  margin: 0; padding: 0;
  counter-reset: step;
  display: grid;
}
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: var(--s3);
  row-gap: var(--s3);
  padding: var(--s5) 0;
  border-top: 1px solid var(--rule);
}
.step:first-child { border-top: 0; padding-top: 0; }
.step::before {
  content: counter(step);
  grid-row: 1;
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
.step h2 { font-size: 17px; grid-column: 2; }
.step > :not(h2) { grid-column: 2; }
.optional { margin-left: var(--s2); font-size: 14px; font-weight: 400; color: var(--ink-2); }

.file-row { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.file-name {
  color: var(--ink-2); font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tasks { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s1); }

.task {
  position: relative;
  display: block;
  padding: 16px var(--s6) 16px 40px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.task:hover { background: color-mix(in srgb, var(--lit) 60%, transparent); }
.task-body { display: grid; position: relative; z-index: 1; }
.task-label { font-weight: 500; }
.task-hint { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.task input:focus-visible ~ .task-body { outline: 2px solid var(--focus); outline-offset: 6px; border-radius: 2px; }

/* the grease-pencil circle */
.circle {
  position: absolute;
  inset: -2px -4px;
  width: calc(100% + 8px);
  height: calc(100% + 4px);
  fill: none;
  stroke: var(--marker);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  opacity: 0;
  pointer-events: none;
}
.task input:checked ~ .circle {
  opacity: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--marker); flex: none; }

.start { width: 100%; margin-top: var(--s4); min-height: 52px; font-size: 17px; }
#job-error { margin-top: var(--s4); }

@media (prefers-reduced-motion: reduce) {
  .task input:checked ~ .circle { transition: none; }
  .meter-bar span { transition: none; }
  .meter.is-indeterminate .meter-bar span { animation: none; width: 100%; opacity: 0.4; }
}
