/* Meydn Web (1A) — visual identity from web/index.html + web/legal/legal.css */

:root {
  --bg: #0c0c0a;
  --bg-elevated: #131210;
  --ink: #f3ede2;
  --ink-dim: #a8a094;
  --ink-quiet: #6b665c;
  --accent: #c9a66b;
  --rule: rgba(243, 237, 226, 0.08);
  --rule-strong: rgba(243, 237, 226, 0.18);
  --err: #ff8080;
  --warn: #f4c150;

  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;

  --sidebar-w: 320px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* film grain (marketing-page surfaces only — toggled by body class) */
body.grain::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* — typography vocabulary, matching web/index.html — */

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.015em;
}

.logo {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.eyebrow-rule {
  display: flex;
  align-items: center;
  gap: 12px;
}
.eyebrow-rule::before {
  content: '';
  width: 32px;
  height: 1px;
  background: var(--ink-dim);
}

.muted { color: var(--ink-dim); }
.quiet { color: var(--ink-quiet); }
.small { font-size: 13px; }

/* — pill button — matches nav-cta on the marketing site — */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  padding: 10px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.2, 0, 0.2, 1);
  font-weight: 400;
}
.pill:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.pill:disabled {
  opacity: 0.5;
  cursor: default;
}
.pill:disabled:hover {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.pill.pill-accent {
  border-color: var(--accent);
  color: var(--accent);
}
.pill.pill-accent:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.pill-ghost {
  background: transparent;
  color: var(--ink-dim);
  border: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s ease;
}
.pill-ghost:hover { color: var(--ink); }

/* — empty state — */

.empty-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 24px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(12,12,10,0.85) 0%, rgba(12,12,10,0) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.empty-state {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 120px 40px 80px;
}

.empty-eyebrow {
  margin-bottom: -8px;
}

.empty-headline {
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 84px);
  line-height: 1.0;
  letter-spacing: -0.025em;
  font-weight: 400;
  color: var(--ink);
  text-align: center;
  max-width: 18ch;
}
.empty-headline em {
  font-style: italic;
}

.empty-sub {
  font-family: var(--sans);
  font-size: clamp(15px, 1.3vw, 17px);
  color: var(--ink-dim);
  text-align: center;
  max-width: 52ch;
  margin-top: -16px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 520px;
  max-width: 90vw;
  height: 220px;
  border: 1px dashed var(--rule-strong);
  background: rgba(243, 237, 226, 0.02);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 240ms cubic-bezier(0.2,0,0.2,1), background 240ms ease;
  position: relative;
}
.drop-zone::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid transparent;
  border-radius: 2px;
  pointer-events: none;
  transition: border-color 240ms ease;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(201, 166, 107, 0.05);
}
.drop-zone:hover::before, .drop-zone.drag-over::before {
  border-color: rgba(201, 166, 107, 0.2);
}
.drop-zone-main {
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  color: var(--ink);
}
.drop-zone-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-quiet);
}

/* Detecting state: GeoCalib inference takes ~5s in production. The tiny
   bottom-of-screen status pill is easy to miss across that wait, so we
   morph the drop zone itself into the activity indicator — same visual
   location the user just interacted with. */
.drop-zone.detecting {
  cursor: default;
  border-color: var(--accent);
  background: rgba(201, 166, 107, 0.05);
  overflow: hidden;
}
.drop-zone.detecting::before {
  border-color: rgba(201, 166, 107, 0.25);
}
.drop-zone.detecting .drop-zone-sub {
  color: var(--accent);
  animation: meydn-pulse 1.4s ease-in-out infinite;
}
.drop-zone.detecting::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: meydn-scan 1.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes meydn-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1.0; }
}
@keyframes meydn-scan {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(370%); }
}

/* — workspace — */

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  height: calc(100vh - 67px);
}

.canvas-wrap {
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
#preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  cursor: grab;
  /* No CSS transition — the JS compare-animation drives the transform
     directly per frame via applyViewportZoom, lerped by compareStrength.
     A CSS transition here would fight that loop and produce the
     "collapse to the side and back" stutter. */
}
#preview-canvas:active { cursor: grabbing; }

/* Reveal overlay — vanishing-point construction + corner readouts shown
   on first load while the raw image is on screen. Positioned absolute
   like the canvas; their CSS transform is set imperatively in lockstep
   with #preview-canvas's transform so the overlay tracks the viewport
   zoom. Default opacity 0 so they're invisible until the reveal
   sequence fades them in. */
#reveal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease-out;
}
#reveal-overlay .reveal-ray {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.25;
  /* Non-scaling-stroke keeps lines at 1.25 CSS pixels regardless of the
     canvas's CSS transform, so they don't get thick when the viewport
     zooms in. */
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
}
#reveal-overlay .reveal-vp {
  fill: var(--accent);
  opacity: 0.85;
}
#reveal-readouts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease-out;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.reveal-readout {
  position: absolute;
  padding: 6px 10px;
  white-space: pre;
}
.reveal-readout.reveal-tl { top: 16px; left: 20px; }
.reveal-readout.reveal-tr { top: 16px; right: 20px; text-align: right; }
.reveal-readout.reveal-bl { bottom: 16px; left: 20px; }
.reveal-readout.reveal-br { bottom: 16px; right: 20px; text-align: right; }

.reveal-on #reveal-overlay,
.reveal-on #reveal-readouts { opacity: 1; }

/* Lines-only mode used by the click-hold compare gesture: rays show,
   readouts do not — the readouts are a "look at this measurement"
   beat that belongs only to the initial reveal. */
.reveal-lines #reveal-overlay { opacity: 1; }

.sidebar {
  background: var(--bg-elevated);
  border-left: 1px solid var(--rule);
  padding: 28px 24px;
  overflow-y: auto;
}

.sidebar-group {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}
.sidebar-group:last-child { border-bottom: none; }

.sidebar-group h3 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin-bottom: 14px;
}
.sidebar-group h3::before {
  content: '§ ';
  opacity: 0.5;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
}
.radio-row input[type=radio],
.radio-row input[type=checkbox] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.radio-row label {
  cursor: pointer;
  user-select: none;
}

.slider-row {
  display: grid;
  grid-template-columns: 56px 1fr 58px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}
.slider-row label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.slider-row input[type=range] {
  accent-color: var(--accent);
  width: 100%;
}
.slider-row .value {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  color: var(--ink);
}

.advanced-disclosure {
  /* same border treatment as sidebar-group */
}
.advanced-disclosure summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  margin-bottom: 14px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease;
}
.advanced-disclosure summary::before {
  content: '§ ';
  opacity: 0.5;
}
.advanced-disclosure summary::after {
  content: '+';
  margin-left: auto;
  font-size: 14px;
  opacity: 0.6;
}
.advanced-disclosure[open] summary::after { content: '−'; }
.advanced-disclosure summary:hover { color: var(--ink-dim); }
.advanced-disclosure summary::-webkit-details-marker { display: none; }

/* Advanced controls parked for v1 (spec 2026-06-01). Markup + JS wiring kept
   intact so this is a one-line revert. */
#advanced { display: none; }

.sidebar-button {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}
.sidebar-button:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.meta-grid {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
  margin-top: -2px;
}
.meta-grid dt {
  color: var(--ink-quiet);
  letter-spacing: 0.04em;
}
.meta-grid dd {
  color: var(--ink-dim);
}

.callout {
  background: rgba(244, 193, 80, 0.06);
  border: 1px solid rgba(244, 193, 80, 0.28);
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 3px;
  color: var(--warn);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
}

.banner {
  background: rgba(201, 166, 107, 0.06);
  border: 1px solid var(--rule);
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 3px;
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 13px;
}
.banner.err {
  background: rgba(255, 128, 128, 0.06);
  border-color: rgba(255, 128, 128, 0.3);
  color: var(--err);
}

#status:not(:empty) {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
}
#status .banner {
  background: var(--bg-elevated);
  border: 1px solid var(--rule-strong);
  padding: 14px 22px;
  margin: 0;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* — unsupported / not-supported page — */

.unsupported {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  text-align: center;
  padding: 120px 40px 80px;
}
.unsupported h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 400;
  letter-spacing: -0.02em;
  max-width: 18ch;
}
.unsupported p {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink-dim);
  max-width: 50ch;
}

.cta-app-store {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: var(--bg);
  padding: 16px 32px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.4s cubic-bezier(0.2, 0, 0.2, 1);
  border: 1px solid var(--ink);
}
.cta-app-store:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* Model-initializing loader. Fills the canvas (opaque --bg) so the image is
   hidden until the model is ready, then fades out as the image fades in.
   Shown/hidden by toggling .is-on (opacity), not display, so it can cross-fade. */
#preparing {
  position: absolute; inset: 0; z-index: 6; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
  opacity: 0; pointer-events: none;
  transition: opacity 350ms ease;
}
#preparing.is-on { opacity: 1; }
.preparing-label { font-family: var(--serif); font-size: 22px; color: var(--ink); }
.preparing-track {
  width: 240px; height: 3px; background: var(--rule);
  border-radius: 2px; overflow: hidden;
}
.preparing-fill { height: 100%; width: 0%; background: var(--accent); transition: width .15s linear; }
.preparing-pct { font-family: var(--mono); font-size: 12px; color: var(--ink-quiet); min-height: 1em; }
/* Cached model: no real byte progress, so slide an indeterminate sliver. */
#preparing.indeterminate .preparing-fill {
  width: 38%; transition: none;
  animation: meydn-indet 1.1s ease-in-out infinite;
}
@keyframes meydn-indet {
  0%   { margin-left: -38%; }
  100% { margin-left: 100%; }
}

/* Analyzing progress bar — over the faded-in image (metaball shimmer behind).
   The fill width is driven per-frame from JS (fast→slow easing), so no width
   transition here. Shown/hidden via .is-on opacity. */
#analyzing {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 34px 54px;
  /* Soft scrim so the indicator stays legible centered over any image content
     (the metaball already dims the photo; this is insurance over bright skies). */
  background: radial-gradient(62% 62% at 50% 50%, rgba(12, 12, 10, 0.55), rgba(12, 12, 10, 0) 72%);
  opacity: 0; pointer-events: none;
  transition: opacity 350ms ease;
}
#analyzing.is-on { opacity: 1; }
.analyzing-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}
.analyzing-track {
  width: 240px; height: 3px; background: rgba(0, 0, 0, 0.4);
  border-radius: 2px; overflow: hidden; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
.analyzing-fill { height: 100%; width: 0%; background: var(--accent); }
