/* style.css - dark, neutral, responsive. No frameworks. */

:root {
  --bg: #0e1015;
  --surface: #151820;
  --surface-2: #1b1f29;
  --border: #272c38;
  --text: #e8ebf1;
  --muted: #8e97a8;
  --accent: #6fa8ff;
  --accent-2: #ffb454; /* selected camera */
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.muted { color: var(--muted); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 24px;
  background: rgba(14, 16, 21, 0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: 0.01em; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: linear-gradient(135deg, #2a6fe0 50%, #f2f5fa 50%); transform: rotate(45deg); }
.topbar nav { display: flex; gap: 22px; }
.topbar nav a { color: var(--muted); font-size: 0.92rem; }
.topbar nav a:hover { color: var(--text); }

/* --------------------------------------------------------------- hero */
.hero { max-width: 900px; margin: 0 auto; padding: 56px 24px 32px; text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 0.8rem; letter-spacing: 0.16em; text-transform: uppercase; }
.hero h1 { margin: 0 0 14px; font-size: clamp(2rem, 5vw, 3.3rem); line-height: 1.1; letter-spacing: -0.02em; }
.lede { margin: 0 auto; max-width: 640px; color: var(--muted); font-size: 1.08rem; }

/* ------------------------------------------------------------- viewer */
.viewer-section { width: 100%; }
.viewer-stage {
  position: relative; width: 100%;
  height: clamp(460px, 76vh, 860px);
  background: var(--bg);
  border-top: 1px solid var(--border);
  overflow: hidden;
  touch-action: none;
}
.viewer-stage canvas { display: block; outline: none; }

.photo-overlay {
  position: absolute; top: 0; left: 50%;
  height: 100%; width: auto; transform: translateX(-50%);
  opacity: 0.5; pointer-events: none;
  /* same vertical field of view as the viewer: photo height == canvas height */
}

.panel {
  position: absolute; z-index: 5;
  background: rgba(21, 24, 32, 0.86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}
.controls { top: 14px; left: 14px; width: 256px; }
.panel-toggle {
  width: 100%; text-align: left; padding: 9px 14px; background: none; color: var(--muted); border: 0;
  font: inherit; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.72rem; cursor: pointer;
}
.panel-toggle::after { content: "\2212"; float: right; }
.controls.collapsed .panel-toggle::after { content: "+"; }
.controls.collapsed .panel-body { display: none; }
.panel-body { padding: 2px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; }
.row .label { color: var(--muted); white-space: nowrap; }
.row.check { justify-content: flex-start; gap: 8px; cursor: pointer; }
.row.slider input { width: 120px; }
.row:has(.segmented) { flex-direction: column; align-items: stretch; gap: 6px; }

input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.segmented { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1; padding: 6px 4px; border: 0; white-space: nowrap; min-width: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font: inherit; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--text); }
/* four or more options (sparse / dense / mesh / textured): 2-column grid */
.segmented:has(> button:nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; }
.segmented button.active { background: var(--accent); color: #07101f; font-weight: 600; }
.segmented button.busy { opacity: 0.6; cursor: progress; }

.btn {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 0.82rem; white-space: nowrap; }

/* selected photo card */
.photo-card { top: 14px; right: 14px; width: 232px; padding: 10px; }
.photo-frame { position: relative; background: #000; border-radius: 8px; overflow: hidden; max-height: 300px; display: flex; justify-content: center; }
.photo-frame img { display: block; max-height: 300px; max-width: 100%; object-fit: contain; }
.photo-missing { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; color: var(--muted); }
.photo-card.no-img .photo-frame { min-height: 120px; }
.photo-card.no-img .photo-frame img { display: none; }
.photo-card.no-img .photo-missing { display: flex; }
.photo-card .close {
  position: absolute; top: 14px; right: 14px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.photo-meta { margin: 10px 2px 8px; display: flex; flex-direction: column; gap: 2px; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.photo-nav { display: flex; justify-content: space-between; }

.hover-tip {
  position: absolute; z-index: 6; pointer-events: none; padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.75); color: #fff; font: 0.75rem var(--mono);
}
.loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7;
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--radius);
  background: rgba(21, 24, 32, 0.9); border: 1px solid var(--border);
}
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  padding: 6px 14px; border-radius: 999px; background: rgba(21, 24, 32, 0.8); color: var(--muted);
  font-size: 0.78rem; white-space: nowrap; pointer-events: none;
}
.error-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8; max-width: min(560px, 90%);
  padding: 18px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid #6b3a3a; line-height: 1.7;
}

/* filmstrip */
.filmstrip-wrap { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 10px 0 12px; }
.filmstrip-head { display: flex; gap: 12px; align-items: baseline; padding: 0 16px 8px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.filmstrip-head .muted { text-transform: none; font-weight: 400; letter-spacing: 0; }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 6px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; outline: none; }
.thumb {
  position: relative; flex: 0 0 auto; height: 108px; aspect-ratio: 3 / 4; padding: 0; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; background: var(--surface-2); cursor: pointer; transition: transform 0.15s, border-color 0.15s;
}
.thumb:hover { transform: translateY(-2px); border-color: var(--muted); }
.thumb.selected { border-color: var(--accent-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.missing { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, #1f2430 8px, #1f2430 16px); }
.thumb-label {
  position: absolute; left: 4px; bottom: 4px; padding: 0 6px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font: 0.7rem var(--mono);
}

/* ------------------------------------------------------------ sections */
.section { padding: 72px 0; }
.section.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.01em; }
.section-lede { margin: 0 0 32px; color: var(--muted); max-width: 640px; }
#stats h2 { margin-bottom: 28px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile { padding: 20px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--accent); font-variant-numeric: tabular-nums; }
.tile-label { margin-top: 4px; color: var(--muted); font-size: 0.88rem; }

/* pipeline */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.step { display: flex; gap: 16px; padding: 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.step-num {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(111, 168, 255, 0.14); color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums;
}
.step h3 { margin: 4px 0 6px; font-size: 1.02rem; }
.step p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.fig { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: zoom-in; transition: transform 0.15s, border-color 0.15s; }
.fig:hover, .fig:focus-visible { transform: translateY(-3px); border-color: var(--accent); outline: none; }
.fig img { display: block; width: 100%; height: 240px; object-fit: contain; background: #0a0b0f; }
.fig figcaption { padding: 12px 16px 14px; color: var(--muted); font-size: 0.88rem; }

.footer { padding: 28px 0 40px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------ lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(5, 6, 9, 0.92); padding: 24px; }
.lightbox figure { margin: 0; max-width: min(1200px, 100%); text-align: center; }
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 8px; background: #000; }
.lightbox figcaption { margin-top: 12px; color: var(--muted); }
.lb-btn { position: absolute; border: 0; background: rgba(255, 255, 255, 0.08); color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 1.6rem; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, 0.2); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; top: 50%; }
.lb-next { right: 18px; top: 50%; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .topbar nav { gap: 14px; }
  .hero { padding-top: 36px; }
  .viewer-stage { height: clamp(420px, 72vh, 640px); }
  .controls { width: calc(100% - 28px); max-width: 300px; }
  .controls .panel-body { max-height: 46vh; overflow-y: auto; }
  .photo-card { top: auto; bottom: 44px; right: 14px; width: 170px; }
  .photo-frame, .photo-frame img { max-height: 160px; }
  .photo-meta .kv:nth-child(n+3) { display: none; }
  .viewer-hint { display: none; }
  .section { padding: 48px 0; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .brand span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
