/* ============================================================
   AFIYAH INFINITY — BASE STYLES
   Mobile-first. Apple-inspired: one primary action per screen,
   generous spacing, high contrast, breathing cards. (KB §2.3)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,500&family=Playfair+Display:wght@500;600;700&family=Manrope:wght@400;500;600;700;800&family=Amiri:wght@400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background var(--ease-slow), color var(--ease-slow);
  overflow-x: hidden;
}

img, svg { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
h3 { font-size: clamp(1.15rem, 3vw, 1.4rem); }

p { margin: 0 0 var(--space-3); color: var(--muted); }

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-2);
  display: block;
}

.arabic {
  font-family: var(--font-arabic);
  direction: rtl;
}

/* ---- Layout shell ---- */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-shell--wide {
  max-width: 1180px;
}

.screen {
  flex: 1;
  padding: var(--space-5) var(--space-5) calc(var(--space-8) + 72px);
}

.screen--no-nav {
  padding-bottom: var(--space-7);
}

.screen--centered {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
}

/* ---- Containers & cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

[data-theme="ivory_fajr"] .card {
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.card--soft {
  background: var(--surface-soft);
  backdrop-filter: blur(12px);
}

.card--gold-edge {
  border: 1px solid rgba(201, 154, 69, 0.28);
  box-shadow: var(--shadow-gold-glow);
}

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-6); }

.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  padding: 15px 24px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform var(--ease-fast), box-shadow var(--ease-fast), opacity var(--ease-fast), background var(--ease-fast);
  min-height: 48px;
  width: 100%;
  letter-spacing: 0.01em;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--antique-gold));
  color: #1A1204;
  box-shadow: var(--shadow-gold-glow);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(201,154,69,0.4), 0 10px 34px rgba(201,154,69,0.22); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
}
[data-theme="ivory_fajr"] .btn-secondary { border-color: rgba(0,0,0,0.15); }
.btn-secondary:hover { border-color: var(--gold); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  width: auto;
  padding: 8px 4px;
  min-height: auto;
  font-weight: 600;
}
.btn-ghost:hover { color: var(--gold); }

.btn-sm { padding: 10px 16px; min-height: 38px; font-size: 0.85rem; width: auto; }
.btn-icon { width: 44px; padding: 0; flex-shrink: 0; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text);
  min-height: 48px;
  transition: border var(--ease-fast), background var(--ease-fast);
}
[data-theme="ivory_fajr"] .field input,
[data-theme="ivory_fajr"] .field select,
[data-theme="ivory_fajr"] .field textarea {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.14);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(201,154,69,0.06);
}
.field textarea { min-height: 96px; resize: vertical; }
.field-hint { font-size: 0.75rem; color: var(--muted); }
.field-error { font-size: 0.78rem; color: var(--danger); font-weight: 600; }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
  margin-top: 1px;
  position: relative;
  cursor: pointer;
  background: rgba(255,255,255,0.03);
}
[data-theme="ivory_fajr"] .checkbox-row input[type="checkbox"] { border-color: rgba(0,0,0,0.2); }
.checkbox-row input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}
.checkbox-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 5px; height: 10px;
  border: solid #1A1204;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox-row span { font-size: 0.9rem; color: var(--text); }
.checkbox-row .required-mark { color: var(--gold); font-weight: 700; }

/* ---- Badges / pills ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-gold { background: rgba(201,154,69,0.15); color: var(--gold); }
.badge-success { background: rgba(78,154,115,0.16); color: var(--success); }
.badge-warning { background: rgba(214,154,58,0.16); color: var(--warning); }
.badge-danger { background: rgba(201,92,92,0.16); color: var(--danger); }
.badge-info { background: rgba(108,147,184,0.16); color: var(--info); }
.badge-muted { background: rgba(255,255,255,0.08); color: var(--muted); }

/* ---- Icons ---- */
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.icon-sm { width: 17px; height: 17px; }
.icon-lg { width: 32px; height: 32px; }

/* ---- Progress ring / bar ---- */
.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
[data-theme="ivory_fajr"] .progress-bar { background: rgba(0,0,0,0.08); }
.progress-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--antique-gold));
  transition: width var(--ease-slow);
}

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(201,154,69,0.3); border-radius: 3px; }

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.divider { height: 1px; background: rgba(255,255,255,0.08); border: none; margin: var(--space-4) 0; }
[data-theme="ivory_fajr"] .divider { background: rgba(0,0,0,0.08); }
.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;
}

.fade-in { animation: fadeIn var(--ease-slow) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (min-width: 640px) {
  .app-shell:not(.app-shell--wide) { border-inline: 1px solid rgba(255,255,255,0.06); }
}
