/* ═══════════════════════════════════════════════════════════════════════
   Afrah.ly Studio — the guided, Arabic-first, phone-first invitation wizard.
   Constrained customization (the builder decision): the user confirms and
   swaps within safe choices, never a blank canvas. RTL-first.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --violet: #5d2f9e;
  --violet-deep: #43217a;
  --violet-heading: #472a78;
  --lavender: #b9a3d8;
  --lilac-wash: #efe9f6;
  --gold: #b39250;
  --gold-bright: #e6cf9a;
  --ink: #2f2937;
  --ink-soft: #6b6377;
  --line: #e7e0f0;
  --ok: #4f8a54;
  --card: #ffffff;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(67, 33, 122, 0.10);
  --font-ui: "Tajawal", "Amiri", system-ui, sans-serif;
  --font-display: "Aref Ruqaa", "Amiri", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% 0%, #f7f2fb 0%, #efe9f6 45%, #e9e3f2 100%) fixed;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

.studio-top {
  text-align: center;
  padding: 22px 16px 8px;
}
.brand {
  font-family: var(--font-display);
  font-size: 34px;
  color: var(--violet-deep);
  line-height: 1;
}
.brand-sub {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* progress dots */
.progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 0 4px;
}
.progress .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #d8cdea; transition: all .25s ease;
}
.progress .dot.active { background: var(--violet); transform: scale(1.25); }
.progress .dot.done { background: var(--gold); }

/* step container */
.steps {
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 16px 120px;
}
.step { display: none; animation: rise .3s ease both; }
.step.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.step h2 {
  font-family: var(--font-display);
  color: var(--violet-heading);
  font-size: 24px;
  margin: 6px 0 2px;
}
.step .hint { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 18px; }

/* fields */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-weight: 700; font-size: 14px;
  margin-bottom: 7px; color: var(--violet-deep);
}
.field .sub { font-weight: 400; color: var(--ink-soft); font-size: 12.5px; }
input[type="text"], input[type="tel"], input[type="email"],
input[type="date"], input[type="time"], input[type="url"] {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 16px; /* >=16px avoids iOS zoom */
  padding: 14px 15px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(93, 47, 158, 0.12);
}
input::placeholder { color: #b3aac2; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* collapsible optional block */
details.optional { margin-top: 4px; }
details.optional > summary {
  cursor: pointer; color: var(--violet); font-size: 13.5px;
  list-style: none; padding: 6px 0; user-select: none;
}
details.optional > summary::-webkit-details-marker { display: none; }
details.optional > summary::before { content: "＋ "; }
details.optional[open] > summary::before { content: "－ "; }

/* occasion tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all .18s ease;
}
.tile .emoji { font-size: 30px; display: block; margin-bottom: 8px; }
.tile .ticon { width: 36px; height: 36px; display: block; margin: 0 auto 10px; color: var(--violet); }
.tile.selected .ticon { color: var(--violet-deep); }
.tile .name { font-weight: 700; color: var(--violet-deep); font-size: 16px; }
.tile.selected { border-color: var(--violet); background: var(--lilac-wash); box-shadow: var(--shadow); }
.tile.disabled { opacity: .5; cursor: not-allowed; }
.tile .soon {
  position: absolute; top: 8px; inset-inline-end: 8px;
  font-size: 10px; background: var(--gold-bright); color: #6b551d;
  padding: 2px 7px; border-radius: 20px; font-weight: 700;
}

/* palette swatches */
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch {
  width: 62px; text-align: center; cursor: pointer;
  font-size: 11.5px; color: var(--ink-soft);
}
.swatch .chip {
  height: 46px; border-radius: 12px; margin-bottom: 6px;
  border: 2.5px solid transparent; transition: all .15s ease;
}
.swatch.selected .chip { border-color: var(--violet); transform: scale(1.04); }
.swatch.disabled { opacity: .45; cursor: not-allowed; }

/* toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 14px; background: var(--card);
}
.toggle-row .t-label { font-size: 14px; font-weight: 700; color: var(--violet-deep); }
.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d8cdea; border-radius: 20px;
  transition: .2s; cursor: pointer;
}
.switch .track::before {
  content: ""; position: absolute; height: 22px; width: 22px;
  inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .track { background: var(--violet); }
.switch input:checked + .track::before { transform: translateX(-22px); }

/* footer nav */
.studio-nav {
  position: fixed; inset-inline: 0; bottom: 0;
  display: flex; gap: 12px; justify-content: space-between;
  max-width: 520px; margin: 0 auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, #efe9f6 70%, rgba(239,233,246,0));
}
.btn {
  font-family: var(--font-ui); font-size: 16px; font-weight: 700;
  padding: 15px 20px; border-radius: 14px; border: none; cursor: pointer;
  transition: transform .1s ease, filter .15s ease; flex: 1;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--violet); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { background: #c9bfe0; box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--violet); border: 1.5px solid var(--line); flex: 0 0 auto; }
.btn-ghost[hidden] { display: none; }

/* review / preview */
.preview-frame {
  width: 100%; aspect-ratio: 9 / 16; max-height: 62vh;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #000; overflow: hidden; box-shadow: var(--shadow);
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.review-row { display: flex; gap: 10px; margin-top: 14px; }
.review-row .btn { font-size: 15px; padding: 13px; }

.result {
  margin-top: 16px; padding: 16px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
}
.result.ok { border-color: #bfe0c2; }
.result h3 { margin: 0 0 8px; color: var(--ok); font-family: var(--font-display); }
.link-box {
  display: flex; gap: 8px; margin-top: 10px;
}
.link-box input { direction: ltr; text-align: left; font-size: 13px; padding: 11px; }
.copy-btn { flex: 0 0 auto; padding: 11px 14px; font-size: 14px; }
.mini { font-size: 12px; color: var(--ink-soft); margin-top: 8px; }

.err { color: #b03a3a; font-size: 12.5px; margin-top: 6px; min-height: 1em; }
.upload-btn { display: block; cursor: pointer; font-family: var(--font-ui); font-size: 15px; font-weight: 700; color: var(--violet); background: var(--card); border: 1.5px dashed var(--violet); border-radius: 14px; padding: 14px 18px; text-align: center; }

/* accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tile:focus-visible, .swatch:focus-visible, .btn:focus-visible, .upload-btn:focus-within, h2:focus-visible { outline: 3px solid rgba(93, 47, 158, 0.45); outline-offset: 2px; }
h2:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  .step { animation: none; }
  .switch .track, .switch .track::before, .btn, .tile, .swatch .chip { transition: none; }
  html { scroll-behavior: auto; }
}

/* ── design & customization step ── */
details.adv { border: 1px solid var(--line); background: var(--card); margin-top: 4px; }
details.adv summary { cursor: pointer; padding: 14px 16px; font-weight: 700; color: var(--violet-deep); font-size: 14.5px; list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: "+"; color: var(--gold); margin-inline-end: 8px; font-weight: 700; }
details.adv[open] summary::before { content: "−"; }
details.adv > .field, details.adv > .mini { padding: 0 16px; }
details.adv > .mini { padding-bottom: 14px; }
#flowTiles .swatch .chip { border: 1px solid var(--line); }
