/* Builder page. Tokens come from /lib/base.css. */

/* Base styles give buttons and panels a display value; hidden must still win. */
[hidden] { display: none !important; }

body {
  background-image: radial-gradient(ellipse at 50% 0%, rgba(230, 16, 13, 0.22), transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- header: shared .top rules live in /lib/base.css ---------- */

/* ---------- steps ---------- */
/* Cards line up with the top bar's 680px column; 16px gutters on small screens. */
.steps {
  max-width: calc(680px + 2 * var(--space-2));
  margin: 0 auto;
  padding: 0 var(--space-2) 80px;
}

.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: var(--space-3) var(--space-2);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  scroll-margin-top: 12px;
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Spacing inside a card, on the --space scale: 8px from a heading to its
   content, 16px between blocks, 24px before a sub-section (h3, Make another). */
.step h2 { margin: 0 0 calc(var(--space-1) - var(--space-2)); display: flex; align-items: center; justify-content: center; gap: var(--space-2); }
.step h3 { margin: var(--space-1) 0 0; }
.step h3 + .fine { margin-top: calc(var(--space-1) - var(--space-2)); }
/* A caption under its own control sits 8px away, like a heading. */
#offerNote, #createNote, .share + .fine, .share + .fine + .fine { margin-top: calc(var(--space-1) - var(--space-2)); }

.num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-hi), var(--accent) 50%, var(--accent-lo));
  color: var(--ink);
  font-size: 1.15rem;
}

.step.is-locked { opacity: 0.55; }
.step.is-locked .place,
.step.is-locked .publish { display: none; }
.step:not(.is-locked) .locked-note { display: none; }

.fine, .hint { color: var(--muted); font-size: 0.9rem; text-align: center; margin: 0; max-width: 46ch; }

.btn-small { font-size: 1rem; padding: 12px 16px; }

/* ---------- 1. formats ---------- */
#formatGroups { width: 100%; display: flex; flex-direction: column; gap: var(--space-2); }
.formats {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--space-1);
}
.formats legend {
  width: 100%;
  text-align: center;
  margin-bottom: var(--space-1);
  padding: 0;
  font: 600 0.9rem var(--font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.format {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.3s;
}
.format:has(input:checked) { border-color: var(--accent-lo); }
.format input { flex: none; }
.format-thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  max-height: 64px;
  border-radius: 6px;
  overflow: hidden;
}
.format-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.format-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.format-text strong { font-weight: 600; overflow-wrap: anywhere; }
.format-text span { color: var(--muted); font-size: 0.85rem; }

/* ---------- 2. photo ---------- */
.photo-sources { display: flex; gap: var(--space-1); width: 100%; max-width: 420px; justify-content: center; }
.photo-sources .btn { margin: 0; flex: 1; }

.picker { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.picker-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: var(--space-1);
}
.picker-item {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  aspect-ratio: 1;
  cursor: pointer;
}
.picker-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-item:hover { border-color: var(--accent); }
.picker-tag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(7, 7, 7, 0.85);
  font-size: 0.7rem;
  color: var(--accent-hi);
}

.offer { display: flex; align-items: center; gap: var(--space-1); cursor: pointer; text-align: left; }
.offer input { flex: none; }

/* ---------- 3. place ---------- */
.place { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }

.tabs {
  display: flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  font: 600 0.9rem/1 var(--font-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.4s, color 0.4s;
}
.tab[aria-selected="true"] { background: var(--brand); color: var(--text); }

.stage { position: relative; width: 100%; display: flex; justify-content: center; }
#preview {
  display: block;
  max-width: 100%;
  max-height: min(64vh, 620px);
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  touch-action: none;
  cursor: grab;
  background: #1a1515;
}
#preview.dragging { cursor: grabbing; }

.centering {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(7, 7, 7, 0.82);
  color: var(--text);
  font: 600 0.9rem var(--font-label);
  white-space: nowrap;
  pointer-events: none;
}

.adjust { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-1); }
.zoom {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font: 600 0.9rem var(--font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.zoom input { flex: 1; min-width: 0; accent-color: var(--brand); height: 32px; }

.quality {
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  background: #3a2a10;
  color: var(--accent-hi);
}
.quality.bad { background: #4a1010; color: #ffd2c8; }

/* ---------- 5. publish ---------- */
.publish { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
#again { margin-top: var(--space-1); }

.results {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: var(--space-2);
  align-items: stretch;
}
.result {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  min-width: 0;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.result img { width: 100%; height: clamp(150px, 40vw, 220px); object-fit: contain; border-radius: 6px; display: block; }
.result figcaption { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.3; }
.result figcaption strong { font-weight: 600; overflow-wrap: anywhere; }
.result figcaption span { color: var(--muted); font-size: 0.85rem; }
.result-actions { width: 100%; margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.share-pick { display: flex; align-items: center; gap: var(--space-1); white-space: nowrap; font-size: 0.85rem; color: var(--muted); cursor: pointer; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.save-all { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-1); }
.format-pick { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }

.share {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  width: 100%;
  max-width: 420px;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 104px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 600 1rem var(--font-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.3s, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.share-btn svg { width: 34px; height: 34px; color: var(--accent); }
.share-btn:hover { border-color: var(--accent); }
.share-btn:active { transform: scale(0.97); }

.send { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.members { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-2); max-width: 420px; }
.member { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 36px; cursor: pointer; }

.fail {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
  color: var(--bad);
}

/* Wide screens: same column as the top bar (680px), roomier cards. */
@media (min-width: 900px) {
  .step { padding: var(--space-4); }
}
.fine:empty { display: none; }
