/* ============================================================
   شمس حلب - Shams Halab
   Usability layer: wizard, presets, explanations, steppers, toast
   Logical properties only — this stylesheet must stay RTL-safe.
   ============================================================ */

/* ── Wizard shell ─────────────────────────── */
.wizard {
  position: relative;
}

.wizard-progress-track {
  height: 6px;
  background: var(--muted);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-5);
}

.wizard-progress {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, var(--solar-orange), var(--solar-amber));
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.wizard-rail {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
}

.wizard-rail::-webkit-scrollbar {
  display: none;
}

.wizard-dot {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--hit);
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-arabic);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.wizard-dot-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  font-weight: 700;
  flex: 0 0 auto;
}

.wizard-dot.is-active {
  border-color: var(--primary);
  background: var(--card);
  color: var(--foreground);
}

.wizard-dot.is-active .wizard-dot-num {
  background: var(--primary);
  color: var(--primary-foreground);
}

.wizard-dot.is-done {
  border-color: var(--success);
  color: var(--foreground);
}

.wizard-dot.is-done .wizard-dot-num {
  background: var(--success);
  color: var(--success-foreground);
}

.wizard-panel[hidden] {
  display: none;
}

.wizard-panel-title {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.wizard-panel-hint {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.wizard-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.wizard-error[hidden] {
  display: none;
}

.wizard-bar {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.wizard-bar .btn {
  flex: 1;
}

.wizard-bar [data-wizard-back][hidden],
.wizard-bar [data-wizard-next][hidden] {
  display: none;
}

/* ── Presets ──────────────────────────────── */
.preset-block {
  margin-bottom: var(--space-6);
}

.preset-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--muted-foreground);
  margin-bottom: var(--space-3);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.preset-chip {
  min-height: var(--hit);
  padding: var(--space-2) var(--space-5);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-arabic);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.preset-chip:hover {
  border-color: var(--primary);
}

.preset-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

/* ── Explain trigger + bottom sheet ───────── */
/* A real tap target, not a decorative superscript: 44px here, 48px on touch.
   Vertically aligned to the label text it belongs to. */
/* A 44px filled circle next to a 15px label made the label 44px tall, so a
   field that had an explain button sat lower than the field beside it and
   the whole two-column form went out of alignment. The circle draws at the
   size of the text it belongs to; the tap target is a 44px ::after that
   overhangs it invisibly, so the finger target is unchanged. */
.explain-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-inline-start: var(--space-1);
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--muted);
  color: var(--muted-foreground);
  font-family: var(--font-arabic);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.explain-btn::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 44px;
  height: 44px;
  transform: translate(50%, -50%);
}

.explain-btn:hover {
  border-color: var(--primary);
  background: var(--card);
  color: var(--primary);
}

@media (max-width: 768px) {
  .explain-btn { transition: none; }
  .explain-btn::after { width: 48px; height: 48px; }
}

.sh-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(28, 25, 23, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.sh-sheet.is-open {
  opacity: 1;
  visibility: visible;
}

.sh-sheet-card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-5) var(--space-6) var(--space-6);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform var(--transition-base);
}

.sh-sheet.is-open .sh-sheet-card {
  transform: translateY(0);
}

.sh-sheet-grip {
  width: 44px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border);
  margin: 0 auto var(--space-5);
}

.sh-sheet-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-3);
}

.sh-sheet-body {
  color: var(--muted-foreground);
  font-size: var(--text-base);
  line-height: 1.8;
  margin: 0 0 var(--space-6);
}

.sh-no-scroll {
  overflow: hidden;
}

@media (min-width: 769px) {
  .sh-sheet {
    align-items: center;
  }
  .sh-sheet-card {
    border-radius: var(--radius-lg);
  }
  .sh-sheet-grip {
    display: none;
  }
}

/* ── Toast ────────────────────────────────── */
.sh-toast {
  position: fixed;
  inset-block-end: var(--space-6);
  inset-inline: var(--space-6);
  margin-inline: auto;
  max-width: 360px;
  z-index: 300;
  background: var(--solar-dark);
  color: #FFFFFF;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.sh-toast.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ── Number stepper ─────────────────────────
   Minus, value and plus used to be three separate bordered boxes with gaps
   between them, which read as three controls rather than one field you can
   nudge. They share a border now, and only the value carries the fill. */
.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card);
}

.stepper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.stepper .form-input {
  flex: 1 1 auto;
  /* The value is the point of the control; the buttons yield to it. */
  min-width: 4ch;
  text-align: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  /* 16px minimum stops iOS from zooming the page on focus */
  font-size: max(16px, var(--text-base));
}

.stepper .form-input:focus,
.stepper .form-input:focus-visible { outline: none; box-shadow: none; }

.stepper-btn {
  flex: 0 1 var(--hit);
  min-width: 48px;
  min-height: var(--hit);
  border: 0;
  border-radius: 0;
  background: var(--muted);
  color: var(--foreground);
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-arabic);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.stepper-btn:hover {
  background: var(--border);
  color: var(--primary);
}

.stepper-btn:active {
  background: var(--border);
}

/* ── Mobile ───────────────────────────────── */
@media (max-width: 768px) {
  .wizard-bar {
    position: sticky;
    inset-block-end: 0;
    background: var(--card);
    padding: var(--space-4) 0 calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    margin-inline: calc(var(--space-6) * -1);
    padding-inline: var(--space-6);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
    z-index: 50;
  }

  .wizard-dot-label {
    display: none;
  }

  .wizard-dot {
    flex: 0 0 auto;
    min-width: 48px;
    justify-content: center;
    padding: var(--space-2);
  }

  /* Frequently tapped controls: no transitions on touch devices */
  .preset-chip,
  .stepper-btn,
  .wizard-dot {
    transition: none;
  }
}

/* ── Print ────────────────────────────────── */
@media print {
  .wizard-rail,
  .wizard-progress-track,
  .wizard-bar,
  .preset-block,
  .explain-btn,
  .sh-toast,
  .sh-sheet {
    display: none !important;
  }

  /* Print only the step that asked to be printed (the results), never the
     input steps — printing hidden steps would produce a nonsense document. */
  .wizard-panel {
    display: none !important;
  }

  .wizard-panel[data-print="keep"] {
    display: block !important;
  }
}
