/* Facet — field-book panel beside a graphite 3D viewport.
   One accent: survey flagging-tape pink, reserved for what is active, selected or primary. */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url("fonts/archivo-latin-wdth-normal.woff2") format("woff2-variations"), url("fonts/archivo-latin-wdth-normal.woff2") format("woff2");
}

:root {
  --paper: #e8ebe4;
  --paper-2: #dce0d7;
  --paper-3: #cfd4c9;
  --ink: #18201d;
  --ink-2: #4a5550;
  --ink-3: #6d7772;
  --graphite: #2b302e;
  --graphite-2: #353b38;
  --graphite-line: rgba(232, 235, 228, 0.14);
  --flag: #ff3d7f;
  --flag-ink: #18201d;
  --line: rgba(24, 32, 29, 0.14);
  --line-strong: rgba(24, 32, 29, 0.28);
  --ok: #2f7d5b;
  --warn: #9a5b00;
  --radius: 4px;
  --panel: 352px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  font-stretch: 100%;
  font-weight: 420;
  color: var(--ink);
  background: var(--graphite);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); text-decoration-color: var(--flag); }
:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }

.app {
  display: grid;
  grid-template-columns: var(--panel) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------------ field book */
.book {
  background: var(--paper);
  border-right: 1px solid #111614;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-3) transparent;
}
.brand { padding-bottom: 2px; }
.wordmark {
  margin: 0;
  font-size: 40px;
  line-height: 0.95;
  font-weight: 780;
  font-stretch: 125%;
  letter-spacing: -0.01em;
}
.lede {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  max-width: 30ch;
}

.stages { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-strong); }
.stage { border-bottom: 1px solid var(--line); padding: 12px 0 12px; }
.stage-head {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: baseline;
  gap: 8px;
}
.stage-n {
  font-stretch: 75%;
  font-weight: 650;
  font-size: 15px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.stage h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  font-stretch: 100%;
  letter-spacing: 0;
}
.stage-stat {
  font-stretch: 78%;
  font-weight: 560;
  font-size: 14px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stage-body { padding: 8px 0 0 30px; }
.stage[data-state="idle"] .stage-body .note { color: var(--ink-3); }
.stage[data-state="running"] .stage-n { color: var(--flag); }
.stage[data-state="done"] .stage-n::after { content: ""; }
.stage[data-state="done"] .stage-n { color: var(--ink); }
.stage[data-state="error"] .stage-stat { color: #b3123f; }
.stage[data-state="skipped"] { opacity: 0.55; }
.note { margin: 0; font-size: 13.5px; color: var(--ink-2); max-width: 36ch; }
.note b { font-weight: 640; color: var(--ink); }
.note.warn { color: var(--warn); }

.meter {
  height: 5px;
  background: var(--paper-3);
  border-radius: 3px;
  overflow: hidden;
  margin: 2px 0 8px;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: var(--flag);
  transition: width 0.25s ease-out;
}
.meter.indeterminate .meter-fill {
  width: 30%;
  animation: slide 1.1s ease-in-out infinite alternate;
}
@keyframes slide { from { transform: translateX(-10%); } to { transform: translateX(250%); } }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row-actions:empty { display: none; }

.tips { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.tips summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 560;
  list-style: none;
  width: fit-content;
}
.tips summary::-webkit-details-marker { display: none; }
.tips summary::before { content: "+"; display: inline-block; width: 1em; color: var(--ink-3); font-weight: 400; }
.tips[open] summary::before { content: "\2212"; }
.tips ul { margin: 6px 0 0; padding-left: 16px; }
.tips li { margin: 3px 0; max-width: 36ch; }

/* ------------------------------------------------------------------ controls */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  line-height: 1.2;
  color: var(--ink);
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--paper-2); border-color: var(--ink-2); }
.btn:disabled { opacity: 0.42; cursor: default; }
.btn-quiet { border-color: transparent; padding-left: 6px; padding-right: 6px; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.btn-quiet:hover:not(:disabled) { background: transparent; text-decoration-color: var(--flag); border-color: transparent; }
.btn-primary {
  background: var(--flag);
  border-color: var(--flag);
  color: var(--flag-ink);
  font-weight: 680;
  padding: 11px 16px;
  font-size: 15px;
}
.btn-primary:hover:not(:disabled) { background: #ff5a92; border-color: #ff5a92; }
.btn-primary:disabled { background: var(--paper-2); border-color: var(--line); color: var(--ink-3); opacity: 1; }
.btn-file { display: flex; justify-content: space-between; align-items: baseline; width: 100%; text-align: left; }
.btn em, .seg em { font-style: normal; font-stretch: 78%; font-weight: 520; color: var(--ink-3); margin-left: 6px; }
.btn-file:disabled em { color: inherit; }

.options { display: grid; gap: 12px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 5px; }
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 100%;
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: block;
  padding: 6px 11px;
  font-size: 14px;
  font-weight: 560;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--ink); color: var(--paper); }
.seg input:checked + span em { color: var(--paper-3); }
.seg input:focus-visible + span { outline: 2px solid var(--flag); outline-offset: -2px; }
.seg input:disabled + span { opacity: 0.4; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.checks legend { width: 100%; }
.checks label { display: inline-flex; gap: 7px; align-items: center; font-size: 14px; cursor: pointer; }
.checks input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }

.go {
  display: grid; gap: 6px;
  position: sticky; bottom: 0; z-index: 2;
  margin: 0 -22px; padding: 12px 22px 18px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.go .btn-primary { width: 100%; }

.exports h2 { margin: 0 0 8px; font-size: 16px; font-weight: 640; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.credits { margin-top: auto; padding-bottom: 18px; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.credits p { margin: 0; max-width: 40ch; }

/* ------------------------------------------------------------------ viewport */
.stage-view {
  position: relative;
  overflow: hidden;
  background: var(--graphite);
  color: var(--paper);
  min-height: 0;
}
.splat-layer, .three-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.splat-layer { visibility: hidden; }
.three-layer { touch-action: none; outline: none; }

.view-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  pointer-events: none;
}
.view-tools > * { pointer-events: auto; }
.seg-dark { border-color: var(--graphite-line); background: rgba(43, 48, 46, 0.72); backdrop-filter: blur(6px); }
.seg-dark span { border-right-color: var(--graphite-line); color: var(--paper); }
.seg-dark input:checked + span { background: var(--paper); color: var(--ink); }
.toggle-dark {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 560; cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius);
  border: 1px solid var(--graphite-line); background: rgba(43, 48, 46, 0.72);
}
.toggle-dark input { accent-color: var(--flag); margin: 0; }
.btn-dark {
  appearance: none; border: 1px solid var(--graphite-line); background: rgba(43, 48, 46, 0.72);
  color: var(--paper); border-radius: var(--radius); padding: 6px 10px; font-size: 14px; font-weight: 560; cursor: pointer;
}
.btn-dark:hover { border-color: rgba(232, 235, 228, 0.4); }
.btn-ghost-dark {
  appearance: none; border: 1px solid rgba(232, 235, 228, 0.35); background: transparent; color: var(--paper);
  border-radius: var(--radius); padding: 11px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-ghost-dark:hover { border-color: var(--paper); }

.empty {
  position: absolute;
  left: clamp(20px, 5vw, 64px);
  bottom: clamp(24px, 8vh, 88px);
  max-width: 560px;
  pointer-events: none;
}
.empty > * { pointer-events: auto; }
.stage-view.has-strip .empty { bottom: calc(96px + clamp(16px, 4vh, 40px)); }
.headline {
  margin: 0 0 14px;
  font-size: clamp(32px, 4.2vw, 54px);
  line-height: 1.02;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.015em;
  max-width: 15ch;
  text-wrap: balance;
}
.empty p { margin: 0 0 18px; color: rgba(232, 235, 228, 0.78); max-width: 52ch; font-size: 15.5px; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.fine { font-size: 13px !important; color: rgba(232, 235, 228, 0.55) !important; }
.fine.warn { color: #ffb4c9 !important; }

.dropzone {
  position: absolute; inset: 10px;
  border: 2px dashed var(--flag);
  border-radius: 8px;
  background: rgba(43, 48, 46, 0.6);
  display: grid; place-items: center;
  pointer-events: none;
  z-index: 5;
}
.dropzone p { font-size: 28px; font-weight: 680; font-stretch: 112%; }

.cam-tip {
  position: absolute; z-index: 4; pointer-events: none;
  background: var(--paper); color: var(--ink);
  font-size: 13px; font-weight: 560; padding: 3px 7px; border-radius: 3px;
  font-stretch: 85%;
  transform: translate(10px, -26px);
  white-space: nowrap;
}

.toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 28px));
  background: var(--paper); color: var(--ink);
  border-left: 4px solid var(--flag);
  padding: 10px 14px; border-radius: 3px;
  font-size: 14px; z-index: 6;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.toast b { font-weight: 650; }

/* film strip: photo order is the capture order the reconstruction uses */
.strip {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, rgba(28, 32, 30, 0.92), rgba(28, 32, 30, 0.72));
  border-top: 1px solid var(--graphite-line);
  padding: 8px 10px 10px;
  z-index: 3;
}
.strip-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: 6px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(232, 235, 228, 0.25) transparent;
  scroll-snap-type: x proximity;
}
.strip-list li { flex: 0 0 auto; scroll-snap-align: start; }
.frame {
  appearance: none; display: block; position: relative;
  padding: 0; border: 1px solid transparent; border-radius: 3px; cursor: pointer;
  background: var(--graphite-2);
  height: 64px; overflow: hidden;
}
.frame img { display: block; height: 100%; width: auto; opacity: 0.92; }
.frame .fno {
  position: absolute; left: 3px; top: 2px;
  font-size: 12px; font-weight: 640; font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.frame:hover { border-color: rgba(232, 235, 228, 0.5); }
.frame[aria-current="true"] { border-color: var(--flag); box-shadow: 0 0 0 1px var(--flag); }
.frame[data-flag="blurry"] .fno::after { content: " blurry"; color: #ffb4c9; }
.frame[data-flag="unplaced"] img { opacity: 0.35; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; min-height: 100dvh; }
  .stage-view { grid-row: 1; height: 58vh; position: sticky; top: 0; z-index: 2; }
  .book { grid-row: 2; border-right: 0; border-top: 1px solid #111614; overflow: visible; }
  .empty { left: 18px; right: 18px; bottom: 18px; }
  .headline { font-size: 30px; }
  .empty p { font-size: 14.5px; }
  .frame { height: 52px; }
}

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