/* Self-hosted brand typeface: KMR Waldenburg. Regular weight (the
   "Halbschmal" / semi-condensed cut) drives all menu/UI text; the bold
   "Fett" cut is used only for the CRISP logo below. Self-hosting means
   this now needs the sibling fonts/ folder deployed alongside index.html. */
@font-face {
  font-family: "KMR Waldenburg";
  src: url("fonts/KMR-Waldenburg-Halbschmal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "KMR Waldenburg";
  src: url("fonts/KMR-Waldenburg-Fett.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0a0a0a;
  --paper: #eeece6;
  --panel: #ffffff;
  --line: rgba(10, 10, 10, 0.1);
  --accent: #0a0a0a;
  --accent-contrast: #ffffff;
  --mono: "SF Mono", "Roboto Mono", Consolas, monospace;
  --face: "KMR Waldenburg", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --tracking: 0.005em;
  --w: 420; /* fine, light body weight — the rest of the UI leans thin so
               the bold logo (see .brand h1) stands out by contrast */

  /* type scale: small, fixed sizes now that the panel is a floating
     overlay rather than a proportionally-sized sidebar — no more vw
     dependence, so it stays legible at any viewport width without a
     breakpoint-driven rewrite. */
  --fs-heading: 10.5px; /* section labels */
  --fs-btn: 12px;       /* buttons, controls */
  --fs-note: 10.5px;    /* explanatory texts */

  /* Width of the left-edge control dock — referenced by .panel itself
     and by .brand/.siteCredit so their overlay text doesn't sit under
     the (semi-transparent, but still readable-text-carrying) dock. */
  --panelW: min(240px, 82vw);

  /* Native form controls (select, range, checkbox, color) should stay
     light-themed even when the OS/browser is set to dark mode — the rest
     of the UI is a fixed light design, and letting native chrome switch
     to dark independently (as Chrome/Safari do by default) looks broken
     and inconsistent. */
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* The app is a fixed full-screen canvas with floating overlays, not a
     scrolling page — overflow:hidden avoids a stray scrollbar from
     sub-pixel rounding and stops the mobile-Safari bounce from revealing
     blank space at the edges. The one internal scroller is
     .panelScroll, which is unaffected by this. */
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--face);
  font-weight: var(--w);
  letter-spacing: var(--tracking);
  color: var(--ink);
  background: var(--paper);
}

.hidden {
  display: none;
}

/* ---------- Stage (full-screen canvas) ---------- */

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  overflow: hidden;
}

.stage.interactive canvas {
  cursor: crosshair;
  touch-action: none;
}

.stage-hint {
  position: absolute;
  pointer-events: none;
  font-family: var(--face);
  font-size: var(--fs-note);
  font-weight: var(--w);
  letter-spacing: var(--tracking);
  text-transform: none;
  color: var(--ink);
  text-align: center;
  transition: opacity 0.4s ease;
}

.stage-hint.hidden {
  opacity: 0;
}

canvas {
  /* Full-bleed, unframed look — the canvas is the whole screen now, not
     a card floating in a padded stage, so the old drop shadow (meant to
     lift a smaller canvas off the page) is gone. No max-width/max-height
     constraint here on purpose: fitCanvasToStage() already computes the
     exact display size for the current format (landscape always fills
     the full width, portrait always fills the full height), and letting
     CSS re-clamp that size could squish the canvas out of its aspect
     ratio on an unusually shaped viewport instead of simply letting the
     .stage's overflow:hidden crop the centered overflow. */
}

/* ---------- Brand dock (top of the left menu) ---------- */

.brandDock {
  flex: 0 0 auto;
  padding: 16px 12px 6px;
  /* Lets the h1 below size itself as a fraction of this element's own
     width (via cqw units) rather than the viewport's — so "CRISP.CLUB"
     always fills one line exactly, at any panel width (desktop or the
     narrower mobile dock), with no separate breakpoint math needed. */
  container-type: inline-size;
}

.brandDock h1 {
  margin: 0;
  font-weight: 800; /* the KMR Waldenburg "Fett" cut, in deliberate
                        contrast to the fine weight used everywhere else
                        in the UI */
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
  font-size: 15cqw;
}

/* Fallback for browsers without container query units: a fixed size
   that comfortably fits "CRISP.CLUB" within the panel's own min-width. */
@supports not (font-size: 1cqw) {
  .brandDock h1 {
    font-size: 26px;
  }
}

/* ---------- Info dock (tagline + credit, bottom-right of window) ---------- */

.infoDock {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(320px, calc(100vw - var(--panelW) - 48px));
  text-align: right;
  /* Purely informational, and it sits over the canvas — clicks/taps
     should fall through to painting underneath rather than being
     swallowed by this overlay. */
  pointer-events: none;
}

.infoDock .tagline {
  font-size: clamp(12px, 1.4vw, 14px);
  font-weight: 380;
  text-transform: none;
  line-height: 1.5;
  color: rgba(10, 10, 10, 0.6);
  margin: 0 0 8px;
}

.infoDock .siteCredit {
  display: inline-block;
  font-family: var(--face);
  font-size: 10px;
  font-weight: var(--w);
  letter-spacing: var(--tracking);
  color: var(--ink);
  opacity: 0.45;
  text-decoration: none;
  pointer-events: auto;
}

.infoDock .siteCredit:hover {
  opacity: 0.85;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Control dock (left edge, Photoshop/Paint-style) ---------- */

.panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  width: var(--panelW);
  /* Fully opaque white — no blur/see-through canvas behind the menu. */
  background: #ffffff;
  border-right: 1px solid rgba(10, 10, 10, 0.1);
  border-radius: 0; /* square edges throughout the dock */
  box-shadow: 4px 0 30px rgba(20, 20, 20, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Mode switcher: a plain, square-edged tab row */
.modeToggle {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px;
  flex: 0 0 auto;
}

.modeToggle .btn {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #000000;
  padding: 8px 8px;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
}

.modeToggle .btn.active {
  background: rgba(10, 10, 10, 0.06);
  border-color: rgba(10, 10, 10, 0.14);
  color: #000000;
}

.panelScroll {
  padding: 0 12px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.panelScroll::-webkit-scrollbar {
  width: 5px;
}

.panelScroll::-webkit-scrollbar-thumb {
  background: rgba(10, 10, 10, 0.16);
  border-radius: 0;
}

/* Accordion sections — native <details>/<summary>, so opening/closing
   needs no JS: keeps the dock short enough to not cover the canvas. */
.group {
  margin-bottom: 1px;
  border: 1px solid rgba(10, 10, 10, 0.08);
  border-radius: 0;
}

.group + .group {
  border-top: none;
}

.group.hidden {
  display: none;
}

.group summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  transition: background 0.15s ease;
}

.group summary:hover {
  background: rgba(10, 10, 10, 0.05);
}

.group summary::-webkit-details-marker {
  display: none;
}

.group summary::after {
  content: "+";
  font-size: 12px;
  font-weight: 500;
  color: #000000;
  transition: transform 0.15s ease;
}

.group[open] summary::after {
  content: "−";
}

.group h2 {
  font-size: var(--fs-heading);
  font-weight: 620;
  text-transform: none;
  letter-spacing: 0.01em;
  color: #000000;
  margin: 0;
}

.groupBody {
  padding: 4px 10px 12px;
}

.hint {
  font-size: var(--fs-note);
  font-weight: 400;
  text-transform: none;
  color: #000000;
  margin: -3px 0 9px;
  line-height: 1.5;
}

.field {
  display: block;
  margin-bottom: 11px;
}

.field:last-child {
  margin-bottom: 0;
}

.field span {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  color: var(--ink);
  margin-bottom: 6px;
}

.field b {
  font-family: var(--face);
  font-weight: 500;
  color: var(--ink);
}

select {
  width: 100%;
  font-family: var(--face);
  font-size: var(--fs-btn);
  font-weight: var(--w);
  letter-spacing: var(--tracking);
  text-transform: none;
  color: #000000;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 9px;
  cursor: pointer;
}

select:hover {
  border-color: rgba(10, 10, 10, 0.3);
}

/* Fine, understated sliders */
input[type="range"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(10, 10, 10, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(10, 10, 10, 0.5);
}

/* Firefox does not apply `background` on the plain <input type="range">
   to its native track the way Chrome/Safari do — without an explicit
   ::-moz-range-track rule it falls back to its own grey groove, ignoring
   our styling entirely and looking inconsistent with other browsers. */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  border: none;
}

/* ---------- Swatches ---------- */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.swatch {
  position: relative;
  width: 20px;
  height: 20px;
}

.swatch input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  background: none;
}

.swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatch input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0; }

.swatch .remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: 1.5px solid #fff;
  font-size: 8px;
  line-height: 12px;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

.bulkPaste {
  margin-top: 10px;
}

.bulkPaste summary {
  font-size: var(--fs-note);
  font-weight: 400;
  color: #000000;
  cursor: pointer;
}

.bulkPaste summary:hover {
  color: #000000;
}

.bulkPaste textarea {
  width: 100%;
  margin-top: 8px;
  font-family: var(--face);
  font-size: var(--fs-note);
  font-weight: 400;
  color: #000000;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 8px;
  resize: vertical;
  box-sizing: border-box;
}

.bulkPaste textarea:focus {
  outline: none;
  border-color: rgba(10, 10, 10, 0.35);
}

/* ---------- Buttons (iOS-style) ---------- */

.btn {
  font-family: var(--face);
  font-size: var(--fs-btn);
  font-weight: 500;
  letter-spacing: var(--tracking);
  text-transform: uppercase;
  text-align: center;
  padding: 9px 12px;
  border-radius: 0;
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-outline {
  background: rgba(10, 10, 10, 0.04);
  border-color: rgba(10, 10, 10, 0.16);
  color: #000000;
}

.btn-outline:hover {
  background: rgba(10, 10, 10, 0.08);
  border-color: rgba(10, 10, 10, 0.28);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  margin-bottom: 8px;
  box-shadow: 0 2px 10px rgba(10, 10, 10, 0.18);
}

.btn-primary:hover {
  opacity: 0.88;
}

/* Buttons that sit several-in-a-row (shape presets, fill mode, etc.) —
   a flex row with a gap, so each button's width is just "share of the
   row" rather than a formula tied to a sidebar width that no longer
   exists. */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-row .btn {
  width: auto;
  flex: 1 1 calc(50% - 3px);
  border-radius: 0;
}

.preset-row .btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.shapePreviewWrap {
  position: relative;
  width: 40px;
  height: 40px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  background-image:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}

.shapePreviewWrap.hidden {
  display: none;
}

.shapePreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
  box-sizing: border-box;
}

.shapePreviewWrap .remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: 1.5px solid #fff;
  font-size: 9px;
  line-height: 13px;
  text-align: center;
  padding: 0;
  cursor: pointer;
}

.checkbox input:disabled + span {
  color: rgba(10, 10, 10, 0.3);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 450;
  text-transform: none;
  color: var(--ink);
  cursor: pointer;
}

.checkbox input {
  width: 13px;
  height: 13px;
  accent-color: var(--accent);
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row input[type="color"] {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
}

.value {
  font-family: var(--face);
  font-size: 11px;
  font-weight: 450;
  color: var(--ink);
}

.actions {
  margin-top: 4px;
}

.footnote {
  font-size: var(--fs-note);
  font-weight: 400;
  text-transform: none;
  color: #000000;
  text-align: center;
  margin: 12px 0 0;
}

/* ---------- Lead-capture modal (SVG export gate) ---------- */

.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modalOverlay.hidden {
  display: none;
}

.modalBox {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 24px 70px rgba(20, 22, 26, 0.3);
}

.modalBox h3 {
  font-size: 15px;
  font-weight: 700;
  text-transform: none;
  color: var(--ink);
  margin: 0 0 10px;
}

.modalBox .hint {
  margin: 0 0 16px;
}

.leadInput {
  width: 100%;
  font-family: var(--face);
  font-size: var(--fs-btn);
  font-weight: var(--w);
  letter-spacing: var(--tracking);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7em 0.7em;
}

.leadInput:focus {
  outline: none;
  border-color: rgba(10, 10, 10, 0.35);
}

.leadError {
  color: #c12026;
  text-align: left;
  margin: 8px 0 0;
}

.leadError.hidden {
  display: none;
}

/* Small screens: the dock stays docked to the left edge (no breakpoint-
   driven restructuring needed any more) and the brandDock heading scales
   itself via container query units, so only the info dock in the bottom
   corner needs trimming to stay comfortable on a narrow phone. */
@media (max-width: 480px) {
  :root {
    --panelW: min(190px, 66vw);
  }
  .infoDock {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    max-width: min(260px, calc(100vw - var(--panelW) - 32px));
  }
  .infoDock .tagline {
    font-size: 11px;
  }
  .infoDock .siteCredit {
    font-size: 9px;
  }
}
