/* ============================================================
   CountdownTimer.it — interfaccia builder
   Tema "mezzanotte": blu notte profondo + oro (fuochi/quadrante)
   ============================================================ */

:root {
  --ink: #0a0e1a;
  --ink-2: #0d1322;
  --panel: #121a2c;
  --panel-2: #17203a;
  --line: #253052;
  --text: #eaeef7;
  --muted: #97a0b8;
  --gold: #f5b841;
  --gold-ink: #221806;
  --violet: #6c5ce0;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(3, 6, 18, 0.55);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(108, 92, 224, 0.18), transparent 60%),
    radial-gradient(700px 420px at -10% 0%, rgba(245, 184, 65, 0.10), transparent 55%),
    var(--ink);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- top bar + hero ---------- */
.topbar {
  display: flex;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 40px);
}

.wordmark {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}
.wordmark span { color: var(--gold); }

.hero {
  text-align: center;
  padding: clamp(8px, 3vw, 28px) 20px clamp(18px, 3vw, 34px);
}
.hero h1 {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 4.6vw, 44px);
  line-height: 1.15;
  margin: 0 0 10px;
  text-wrap: balance;
}
.hero p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: clamp(14px, 1.8vw, 17px);
}

/* ---------- layout studio ---------- */
.studio {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: clamp(16px, 2.5vw, 32px);
  align-items: start;
  padding: 0 clamp(14px, 4vw, 40px) 60px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- pannello form ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(16px, 2.5vw, 26px);
  box-shadow: var(--shadow);
}

.group { padding: 6px 0 18px; }
.group + .group { border-top: 1px solid var(--line); padding-top: 18px; }

.group-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 7px;
}
.field-label em { color: var(--muted); font-style: normal; font-weight: 400; }
.field-label.spaced { margin-top: 16px; }

.field input[type="text"],
.field input[type="url"],
.field input[type="datetime-local"] {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.18);
}

.hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.hint b { color: var(--text); }

/* ---------- segmented ---------- */
.seg {
  display: flex;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
}
.seg-btn {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--gold); color: var(--gold-ink); }
.seg.small .seg-btn { padding: 6px 12px; font-size: 13px; }
.seg.small { flex: 0 0 auto; }

/* ---------- chips carattere ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--text);
  font-size: 15px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.chip:hover { border-color: var(--gold); }
.chip.is-active {
  border-color: var(--gold);
  background: rgba(245, 184, 65, 0.14);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.ff-bebas { font-family: 'Bebas Neue', sans-serif; letter-spacing: 0.04em; font-size: 17px; }
.ff-inter { font-family: 'Inter', sans-serif; }
.ff-playfair { font-family: 'Playfair Display', serif; }
.ff-mono { font-family: 'Space Mono', monospace; font-size: 13.5px; }
.ff-montserrat { font-family: 'Montserrat', sans-serif; }

/* ---------- colori ---------- */
.colors { display: flex; gap: 18px; margin-top: 16px; flex-wrap: wrap; }
.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
}
.color-field input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 38px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: none;
  padding: 0;
  cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
.color-field input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
.color-field.wide { padding: 4px 0; }

/* ---------- tabs sfondo ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel-2); color: var(--text); border-color: var(--gold); }

.bg-pane { display: none; }
.bg-pane.is-open { display: block; animation: paneIn 0.18s ease; }
@keyframes paneIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 52px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.25); }

/* ---------- upload ---------- */
.file-drop {
  display: block;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-drop:hover { border-color: var(--gold); background: rgba(245, 184, 65, 0.05); }
.file-drop input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-cta { display: block; font-weight: 700; color: var(--gold); margin-bottom: 4px; }

/* ---------- slider ---------- */
.slider-field { margin-top: 16px; }
.slider-field output { color: var(--gold); font-variant-numeric: tabular-nums; margin-left: 6px; }
input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--gold) 0 var(--fill, 44%), var(--line) var(--fill, 44%) 100%);
  outline: none;
  margin: 8px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--ink);
  cursor: pointer;
}
input[type="range"]:focus-visible { box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.25); }

/* ---------- opzioni ---------- */
.row-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.row-split .field-label { margin-bottom: 0; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  cursor: pointer;
  font-weight: 500;
  border-bottom: 1px dashed rgba(37, 48, 82, 0.6);
}
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  display: block;
  width: 44px; height: 25px;
  border-radius: 999px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  pointer-events: none;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 2.5px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}
.switch input:checked + i { background: rgba(245, 184, 65, 0.22); border-color: var(--gold); }
.switch input:checked + i::after { transform: translateX(19px); background: var(--gold); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.25); }

/* ---------- CTA ---------- */
.cta {
  width: 100%;
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: var(--gold-ink);
  font: inherit;
  font-weight: 800;
  font-size: 17px;
  padding: 15px 20px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(245, 184, 65, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.cta:hover { transform: translateY(-1px); filter: brightness(1.05); }
.cta:active { transform: none; }
.cta:disabled { opacity: 0.6; cursor: wait; transform: none; }

.fineprint {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 12px 0 0;
}
.fineprint b { color: var(--text); font-weight: 600; }

/* ---------- anteprima ---------- */
.preview-wrap { position: sticky; top: 16px; }

.browser {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.browser-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.dot.r { background: #ff5f57; }
.dot.y { background: #febc2e; }
.dot.g { background: #28c840; }
.urlbar {
  flex: 1;
  margin-left: 6px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.urlbar b { color: var(--gold); letter-spacing: 0.08em; }

.preview {
  position: relative;
  height: min(66vh, 620px);
  container-type: size;
  background: #0b0c12;
}

.preview-note {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 10px 0 0;
}

/* ---------- footer ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 26px 16px 40px;
  border-top: 1px solid var(--line);
}

/* ---------- dialog successo ---------- */
.done {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  max-width: min(460px, 92vw);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.done::backdrop { background: rgba(4, 6, 14, 0.7); backdrop-filter: blur(4px); }
.done-inner { padding: 30px 26px 24px; text-align: center; }
.done-emoji { font-size: 44px; line-height: 1; }
.done h2 {
  font-family: 'Unbounded', sans-serif;
  font-size: 20px;
  margin: 12px 0 18px;
}
.link-pill {
  display: block;
  background: var(--ink-2);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 16px;
}
.done-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.wa { background: #1faa53; border-color: #1faa53; color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { color: var(--text); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #2a1717;
  border: 1px solid #7a3a3a;
  color: #ffd9d9;
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: 92vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .studio { grid-template-columns: 1fr; }
  .preview-wrap { position: sticky; top: 8px; z-index: 20; order: -1; }
  .preview { height: min(42vh, 380px); }
  .preview-note { display: none; }
  .browser { border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
