/* Builder B — landing + authoring. Builds on base.css tokens. */

[hidden] {
  display: none !important;
}

/* ---------- shared ---------- */
.sub {
  margin: 4px 0 0;
  font-size: 15px;
}
.head {
  margin-bottom: 2px;
}
.err {
  color: var(--danger);
  font-size: 14px;
  margin: 2px 0 0;
  text-align: center;
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.btn-secondary:active {
  transform: scale(0.98);
}

/* ---------- landing ---------- */
body.landing::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(40% 30% at 20% 15%, rgba(74, 222, 128, 0.1), transparent 70%),
    radial-gradient(45% 35% at 85% 28%, rgba(74, 222, 128, 0.06), transparent 70%),
    radial-gradient(55% 40% at 60% 92%, rgba(74, 222, 128, 0.09), transparent 70%);
}

.hero {
  min-height: calc(100dvh - 2 * var(--pad));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px 0;
}
.brand {
  font-size: clamp(54px, 22vw, 84px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .brand {
    background: linear-gradient(155deg, var(--text) 20%, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
}
.tagline {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0;
}
.hero-cta {
  max-width: 360px;
  width: 100%;
  margin: 4px auto 0;
}
/* Full-bleed hero band. Negative margins break out of .stack's padding so it
   reaches the page edges; the image's own bottom edge already fades to the app
   background, so it melts into the page rather than sitting as a rectangle.
   object-fit: cover keeps the 2:1 source from letterboxing at any width. */
.hero-img {
  display: block;
  width: calc(100% + 2 * var(--pad));
  height: 200px;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 4px;
  object-fit: cover;
}

/* Outlined accent, matching the native landing screen: reads as the second
   choice without reading as fine print the way .btn-ghost does. */
.btn-find {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-size: 17px;
}
.btn-find:active {
  transform: scale(0.98);
}
.find-note {
  max-width: 360px;
  margin: 10px auto 0;
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
}
.find-note a {
  color: var(--accent);
}
.steps {
  display: grid;
  /* auto-fit rather than a fixed count: the step list went from three to four
     when Draw was added, and a hardcoded repeat(3) left the fourth card alone
     on its own row. This wraps 4->2x2 on a phone and 1x4 on a wide screen. */
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.step {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}
.step .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
}
.step .t {
  font-weight: 700;
  font-size: 14px;
  margin-top: 8px;
}
.step .d {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.3;
}

/* ---------- create ---------- */
#compose,
#share {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* scene picker: choose the backdrop deliberately (replaced the shuffle button) */
.scene-pick {
  display: flex;
  align-items: center;
  gap: 10px;
}
.scene-pick label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.scene-pick select {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

/* play-mode segmented control */
.mode-pick {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mode-pick .mp-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.mode-row {
  display: flex;
  flex: 1;
  gap: 4px;
}
.mode-row button {
  flex: 1;
  padding: 11px 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.mode-row button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.scene-wrap {
  position: relative;
  width: min(100%, calc(50vh * var(--ar, 0.75)));
  aspect-ratio: var(--ar, 0.75);
  margin: 2px auto 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  cursor: crosshair;
  touch-action: none; /* custom pinch/pan; browser must not hijack the gesture */
  user-select: none;
  -webkit-user-select: none;
}
/* Zoom/pan viewport: scene image + figure + pulse scale together so the drawing
   overlay stays pinned over the photo. transform-origin 0 0 keeps the pan math
   simple (see setZoom in create.js). The HUD (timer/hint/cursor/zoom buttons)
   lives OUTSIDE this layer, so it never scales. */
.zoom-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.zoom-ctrl {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  z-index: 4;
}
.zoom-ctrl button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zoom-ctrl button:active {
  transform: scale(0.94);
}
.scene-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
/* colored figure: a 200x300 canvas masked to the current pose silhouette,
   centered on the placement point, sized as a fraction of scene width */
.figure {
  position: absolute;
  left: calc(var(--tx, 0.5) * 100%);
  top: calc(var(--ty, 0.5) * 100%);
  width: calc(var(--fw, 0.15) * 100%);
  aspect-ratio: 200 / 300;
  transform: translate(-50%, -50%);
}
.figure canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-mask: var(--pose) center / 100% 100% no-repeat;
  mask: var(--pose) center / 100% 100% no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.fig-img {
  position: absolute;
  left: calc(var(--tx, 0.5) * 100%);
  top: calc(var(--ty, 0.5) * 100%);
  width: calc(var(--fw, 0.15) * 100%);
  aspect-ratio: 200 / 300;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
/* countdown pill for a timed draw (top-center of the scene) */
.draw-timer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 54px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  pointer-events: none;
  z-index: 4;
}
.draw-timer.urgent {
  color: var(--danger);
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}
.pulse {
  position: absolute;
  left: calc(var(--tx, 0.5) * 100%);
  top: calc(var(--ty, 0.5) * 100%);
  width: calc(var(--size, 0.12) * 100%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.pulse.go {
  animation: pulse 0.5s ease-out;
}
@keyframes pulse {
  from {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.4);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.9);
  }
}

/* ---------- pose picker ---------- */
.pose-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.pose-row button {
  flex: 0 0 auto;
  width: 46px;
  height: 58px;
  padding: 7px 6px 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.pose-row button.is-on {
  border-color: var(--accent);
}
.pose-row .thumb {
  width: 22px;
  flex: 1;
  -webkit-mask: var(--pose) center / contain no-repeat;
  mask: var(--pose) center / contain no-repeat;
  background: var(--text);
}
.pose-row .lbl {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
}

/* ---------- coloring tools ---------- */
.tools {
  display: flex;
  gap: 4px;
}
.tools button {
  flex: 1;
  padding: 11px 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  border: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.tools button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}
.tools button.pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tools button.pick svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}
/* current color chip: always-visible active swatch at the head of the row */
.cur {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--text);
  box-shadow: inset 0 0 0 2px var(--bg);
}
/* brush size slider */
.brush-size {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 16px;
}
.bs-dot {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
}
.bs-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--surface);
  outline: none;
}
.bs-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg);
}
.bs-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--bg);
}

/* brush-size preview ring that follows the pointer over the figure */
.brush-cursor {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  z-index: 3;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.55), inset 0 0 0 1.5px rgba(0, 0, 0, 0.35);
}
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.palette button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.palette button.is-on {
  border-color: var(--text);
  box-shadow: inset 0 0 0 2px var(--bg);
}

/* ---------- share ---------- */
.preview-wrap {
  position: relative;
  width: min(100%, calc(32vh * var(--ar, 0.75)));
  aspect-ratio: var(--ar, 0.75);
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.link-box {
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  padding: 14px 16px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Consent toggle on the share step. A real checkbox styled as a switch rather
   than a div with a click handler, so it keeps keyboard focus, the space bar,
   and the label association for free. */
.opt-in {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
}
.opt-in-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.opt-in-title { font-size: 15px; font-weight: 700; }
.opt-in-body { font-size: 13px; line-height: 1.4; color: var(--text-dim); }
.opt-in-switch {
  appearance: none;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: #2b3340;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.opt-in-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.opt-in-switch:checked { background: var(--accent); }
.opt-in-switch:checked::after { transform: translateX(20px); }
.opt-in-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
