/* Ashenda in Black — UI styles.
   The UI chrome deliberately echoes the campaign artwork: near-black
   ground, warm bone type, hairline rules. All color lives in variables.

   Layout contract:
   - Desktop (>940px): two columns; preview sticky in the left column.
   - Mobile (<=940px): the preview becomes a compact sticky stage at the
     top (the live preview stays visible while controls scroll beneath),
     and the download group sticks to the bottom of the scroll. */

:root {
  --bg: #0b0b0a;
  --panel: #141310;
  --line: #2a2721;
  --ink: #e9e4d7;
  --muted: #a59d8a;
  --accent: #cdc5b4;
  --accent-ink: #14120e;
  --danger: #c98a7a;
  --radius: 10px;
  --stage-h: min(46vh, 420px);
}

@supports (height: 1dvh) {
  :root { --stage-h: min(46dvh, 420px); }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- header ---------- */

.site-header {
  text-align: center;
  padding: 40px 16px 28px;
  border-bottom: 1px solid var(--line);
}

.header-candle {
  width: 26px;
  height: 42px;
  color: var(--accent);
  display: inline-block;
}

.site-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: 34px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 10px 0 4px;
  color: var(--accent);
}

.site-tagline {
  font-family: "Cormorant Garamond", serif;
  font-size: 17px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.privacy-badge {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  margin: 0;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 380px;
  gap: 28px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  align-items: start;
}

/* ---------- preview ---------- */

.preview-col { position: sticky; top: 16px; }

.preview-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 340px;
}

.preview-wrap.drag-over { outline: 2px dashed var(--accent); outline-offset: -8px; }

#preview {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  touch-action: none;          /* we handle drag panning + pinch zoom ourselves */
  cursor: grab;
}

#preview.is-panning { cursor: grabbing; }

.preview-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: var(--panel);
  cursor: pointer;
}

.empty-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 26px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

.empty-hint { color: var(--muted); margin: 0; }
.empty-fineprint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

/* Status lives INSIDE the stage so it is always visible, even when the
   preview is the only thing on a phone screen. */
.status-line {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  background: rgba(10, 10, 9, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  pointer-events: none;
}

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  color: var(--ink);
  font-size: 12.5px;
  white-space: nowrap;
  background: rgba(10, 10, 9, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  pointer-events: none;
  transition: opacity 0.4s;
}

.drag-hint.is-fading { opacity: 0; }

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

.controls-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

/* Before a photo exists there is nothing to control; the groups wait,
   visibly asleep, instead of pretending to work. */
.needs-photo.is-idle { opacity: 0.5; }

.group-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

/* segmented controls */

.seg { display: flex; gap: 6px; flex-wrap: wrap; }

.seg-btn {
  appearance: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn:hover:not(:disabled) { border-color: var(--accent); }

.seg-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* buttons */

.btn {
  appearance: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 9px 18px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) { background: rgba(205, 197, 180, 0.12); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) { background: #ddd5c2; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-wide { width: 100%; }

/* sliders */

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--ink);
  margin: 8px 0 4px;
}

.slider-label output { color: var(--muted); font-size: 12.5px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  background: transparent;
}

input[type="range"]:disabled { opacity: 0.4; }

/* ---------- footer & misc ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 16px 34px;
}

.site-footer p { max-width: 640px; margin: 0 auto; }

.noscript-note { text-align: center; color: var(--danger); padding: 20px; }

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

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

/* ---------- mobile: compact sticky stage ---------- */

@media (max-width: 940px) {
  .site-header { padding: 18px 14px 14px; }
  .header-candle { width: 18px; height: 30px; }
  .site-title { font-size: 22px; margin: 6px 0 2px; }
  .site-tagline { font-size: 12.5px; margin-bottom: 10px; }
  .privacy-badge { font-size: 11.5px; padding: 3px 12px; }

  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 12px 12px 40px;
  }

  /* The stage: short, sticky, always in view while controls scroll. */
  .preview-col {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bg);
    padding: 8px 0;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55);
  }

  .preview-wrap {
    height: var(--stage-h);
    min-height: 0;
  }

  #preview { max-height: 100%; }

  .empty-title { font-size: 20px; }
  .preview-empty { gap: 8px; padding: 16px; }
  .empty-fineprint { margin-top: 4px; }

  /* Keep the way out always reachable. */
  .download-group {
    position: sticky;
    bottom: 10px;
    z-index: 20;
    box-shadow: 0 -8px 18px rgba(0, 0, 0, 0.45), 0 8px 18px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- touch ergonomics ---------- */

@media (pointer: coarse) {
  .seg-btn { min-height: 44px; padding: 9px 16px; }
  .btn { min-height: 44px; }

  input[type="range"] { height: 32px; }

  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }
}

/* The hidden attribute must always win. The browser's own
   [hidden]{display:none} is UA-level CSS, which ANY author display rule
   (like .preview-empty{display:flex}) silently overrides — that exact
   cascade bug shipped on 2026-08-09 and left the empty-state overlay
   covering the loaded photo. Enforced by tools/check_site.py. */
[hidden] { display: none !important; }
