/* =========================================================
   Afaq Al-Ibdaa — styles (mobile-first, WCAG 2.2 AA)
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --teal: #1f7a7a;
  --teal-dark: #155c5c;
  --teal-soft: #cfe7e3;
  --sand: #f6ead8;
  --sun: #f4b63f;
  --coral-text: #b4462c;     /* 5:1 on light backgrounds */
  --ink: #1e2a32;
  --ink-soft: #4a5a64;
  --bg: #fffdf9;
  --bg-tint: #f1f7f5;
  --card: #ffffff;
  --line: #e4ebe8;           /* decorative borders */
  --field-border: #6f7f88;   /* controls: ≥3:1 (WCAG 1.4.11) */
  --error: #a3260b;
  --focus-ring: #1e2a32;
  --focus-halo: #ffffff;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(30, 42, 50, .07);
  --font-ar: "Tajawal", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font-en: "Nunito", "Segoe UI", system-ui, sans-serif;
  --base-size: 112.5%;       /* relative: browser text-size settings still work */
  --line-height: 1.75;
  --quickbar-h: 0px;
  --header-h: 68px;
}

/* ---------- Display modes ---------- */
html.high-contrast {
  --teal: #003d3d; --teal-dark: #002626; --teal-soft: #ffffff;
  --sand: #ffffff; --coral-text: #8a1f08;
  --ink: #000; --ink-soft: #000; --bg: #fff; --bg-tint: #fff; --card: #fff;
  --line: #000; --field-border: #000; --focus-ring: #0040d0; --shadow: none;
}
html.high-contrast .card, html.high-contrast .contact-form, html.high-contrast .steps li,
html.high-contrast .checklist li, html.high-contrast .contact-tile, html.high-contrast .tile { border: 2px solid #000; }
html.high-contrast .section-quote, html.high-contrast .site-footer { background: #000; }
html.high-contrast .hero-art { display: none; }

html.spacing { --line-height: 2.1; }
html.spacing body { word-spacing: .16em; }
html.spacing p, html.spacing li, html.spacing dd { margin-bottom: 1.4em; }
html[lang="en"].spacing body { letter-spacing: .05em; }

html.links a:not(.btn):not(.contact-tile):not(.skip-link) {
  text-decoration: underline !important; text-decoration-thickness: 3px !important;
  background: #fff3c4; color: #000 !important; padding: 0 .15em; border-radius: 3px;
}
html.links .btn, html.links .contact-tile, html.links .quickbar a { outline: 3px dashed currentColor; outline-offset: 2px; }

html.easy { --line-height: 2; }
html.easy .hero-art, html.easy .section-quote { display: none; }
html.easy .pict { font-size: 2.6rem; }
html.easy .section-head p, html.easy .lead, html.easy .card p { font-size: 1.1em; color: var(--ink); }
html.easy .eyebrow { display: none; }

html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: var(--base-size);
  scroll-behavior: smooth;
  /* keep focused items/anchors clear of the sticky header and phone bar (WCAG 2.4.11) */
  scroll-padding-top: calc(var(--header-h) + 24px);
  scroll-padding-bottom: calc(var(--quickbar-h) + 24px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-ar);
  color: var(--ink);
  background: var(--bg);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: var(--quickbar-h);
}
html[lang="en"] body { font-family: var(--font-en); }
img, svg, video { max-width: 100%; display: block; }
a { color: var(--teal); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.75rem, 7vw, 3rem); font-weight: 800; }
h2 { font-size: clamp(1.45rem, 5vw, 2.15rem); font-weight: 800; }
h3 { font-size: 1.12rem; font-weight: 700; }
p { margin: 0 0 1em; }
button { font: inherit; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 7px var(--focus-halo);
  border-radius: 6px;
}
.site-footer :focus-visible, .section-quote :focus-visible, .quickbar :focus-visible {
  outline-color: #fff; box-shadow: 0 0 0 7px #1e2a32;
}
main:focus, [tabindex="-1"]:focus { outline: none; box-shadow: none; }

.container { width: min(1140px, 100% - 32px); margin-inline: auto; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; inset-inline-start: 12px; top: -100px; z-index: 200;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: .55em 1.5em;
  background: var(--teal); color: #fff; text-decoration: none; text-align: center;
  font-weight: 700; border: 2px solid var(--teal); border-radius: 999px;
  cursor: pointer; transition: background .2s, transform .2s; touch-action: manipulation;
}
.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--teal); }
.btn-ghost:hover { background: var(--teal-soft); color: var(--teal-dark); }
.btn-small { min-height: 44px; padding: .3em 1.1em; font-size: .92rem; }
.btn-block { display: flex; width: 100%; }
.btn-whatsapp { background: #17703c; border-color: #17703c; }
.btn-whatsapp:hover { background: #115a2f; border-color: #115a2f; }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); }
.btn[aria-pressed="true"]::before { content: "✓" / ""; }

.listen {
  display: inline-flex; align-items: center; gap: .4em; min-height: 44px; padding: .3em 1em;
  border: 2px solid var(--teal); border-radius: 999px; background: var(--card); color: var(--teal-dark);
  font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.listen:hover { background: var(--teal-soft); }
.listen[aria-pressed="true"] { background: var(--coral-text); border-color: var(--coral-text); color: #fff; }

/* Text currently being read aloud */
.reading { background: #fff3c4 !important; box-shadow: 0 0 0 6px #fff3c4; border-radius: 4px; color: #000 !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 8px; min-height: var(--header-h); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); margin-inline-end: auto; min-width: 0; padding-block: 6px; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 1.05rem; }
.brand-text small { color: var(--ink-soft); font-size: .72rem; }

.header-tools { display: flex; align-items: center; gap: 6px; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 4px 10px;
  background: var(--card); color: var(--ink); border: 2px solid var(--field-border); border-radius: 12px;
  font-weight: 700; font-size: .85rem; cursor: pointer; touch-action: manipulation;
}
.tool-btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.tool-btn svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.a11y-toggle[aria-expanded="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.bars { display: inline-grid; gap: 4px; }
.bars span { display: block; width: 20px; height: 2.5px; background: currentColor; border-radius: 2px; }
.nav-toggle[aria-expanded="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Phones: the accessibility button lives in the bottom bar instead */
.a11y-toggle { display: none; }

.site-nav { display: none; width: 100%; padding: 4px 0 16px; }
.site-nav.open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.site-nav a:not(.btn) {
  display: flex; align-items: center; min-height: 52px; padding: 0 12px;
  color: var(--ink); text-decoration: none; font-weight: 700; border-radius: 12px; font-size: 1.05rem;
}
.site-nav a:not(.btn):hover { background: var(--bg-tint); color: var(--teal-dark); }
.site-nav .btn { width: 100%; margin-top: 6px; }

/* ---------- Accessibility panel ---------- */
.a11y-panel {
  position: fixed; z-index: 70;
  inset-inline: 0; bottom: var(--quickbar-h);
  max-height: calc(100dvh - var(--quickbar-h) - 40px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); color: var(--ink);
  border-top: 3px solid var(--teal); border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  padding: 18px 16px 20px;
}
.a11y-panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { font-size: 1.3rem; margin: 0; }
.panel-close {
  min-height: 44px; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  background: var(--bg-tint); color: var(--ink); border: 2px solid var(--field-border); font-weight: 700;
}
.panel-intro { color: var(--ink-soft); margin: 8px 0 14px; font-size: .95rem; }
.size-control {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  background: var(--bg-tint); border-radius: 14px; padding: 10px; margin-bottom: 12px;
}
.size-label { grid-column: 1 / -1; font-weight: 700; }
.size-btn {
  min-height: 52px; border-radius: 12px; border: 2px solid var(--field-border); background: var(--card);
  color: var(--ink); font-weight: 800; cursor: pointer;
}
.size-btn:disabled { opacity: .45; cursor: not-allowed; }
.size-value { font-weight: 800; font-size: 1.1rem; min-width: 4ch; text-align: center; font-family: var(--font-en); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 92px; padding: 10px; border-radius: 16px; cursor: pointer; touch-action: manipulation;
  background: var(--card); color: var(--ink); border: 2px solid var(--field-border); font-weight: 700; text-align: center;
}
.tile-ico { font-size: 1.7rem; line-height: 1; }
.tile:hover { border-color: var(--teal); }
.tile[aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.tile[aria-pressed="true"]::after { content: "✓" / ""; font-weight: 800; }

/* ---------- Toast (visual feedback, for deaf users too) ---------- */
.toast {
  /* phones: top of screen, so it never covers the panel or the bottom bar */
  position: fixed; z-index: 90; inset-inline: 16px; top: calc(var(--header-h) + 10px);
  margin-inline: auto; max-width: 480px;
  background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 14px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); text-align: center;
  opacity: 0; visibility: hidden; transform: translateY(-10px); pointer-events: none;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: none; }

/* ---------- Hero ---------- */
.hero { padding: 28px 0 32px; background: linear-gradient(180deg, var(--bg) 0%, var(--bg-tint) 100%); }
.hero-inner { display: grid; gap: 24px; align-items: center; }
.hero-art { display: none; }
.eyebrow { color: var(--coral-text); font-weight: 800; margin-bottom: .35em; font-size: .92rem; }
html[lang="en"] .eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; }
.lead { font-size: 1.1rem; color: var(--ink-soft); max-width: 36em; }
.hero-actions { display: grid; gap: 10px; margin-top: 20px; }
.hero-actions .listen { justify-self: start; }
.stats {
  list-style: none; padding: 0; margin: 28px 0 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.stats li {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 6px;
}
.stats strong { font-size: 1.6rem; color: var(--teal); line-height: 1.15; font-family: var(--font-en); }
.stats span { color: var(--ink-soft); font-size: .85rem; line-height: 1.4; }

/* ---------- Sections ---------- */
.section { padding: 48px 0; }
.section-tint { background: var(--bg-tint); }
.section-head { max-width: 700px; margin: 0 auto 28px; text-align: center; }
.section-head p { color: var(--ink-soft); }
.section-head .listen, .section-side .listen { margin-bottom: 8px; }

.cards { display: grid; gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.card p { color: var(--ink-soft); margin: 0; }
.access-card p { margin-bottom: 18px; }
.pict { display: block; font-size: 2.1rem; line-height: 1; margin-bottom: 12px; }

.sign-video { margin: 28px auto 0; max-width: 760px; }
.sign-video video { width: 100%; border-radius: var(--radius); background: #000; }
.sign-video figcaption { text-align: center; color: var(--ink-soft); margin-top: 8px; }

.split { display: grid; gap: 28px; align-items: start; }

.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.checklist li {
  display: grid; grid-template-columns: 34px 1fr; column-gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.checklist li::before {
  content: "✓" / ""; grid-row: span 2; width: 32px; height: 32px; border-radius: 50%;
  background: var(--teal-soft); color: var(--teal-dark); font-weight: 800; display: grid; place-items: center;
}
.checklist span { color: var(--ink-soft); }

.section-quote { background: var(--teal); color: #fff; }
.quote { margin: 0 auto; max-width: 820px; text-align: center; }
.quote blockquote { margin: 0 0 14px; }
.quote blockquote p { font-size: clamp(1.2rem, 4.5vw, 1.65rem); font-weight: 700; line-height: 1.65; margin: 0; }
.quote figcaption { font-weight: 600; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); position: relative; }
.steps p { color: var(--ink-soft); margin: 0; }
.steps .pict { position: absolute; inset-inline-end: 20px; top: 20px; font-size: 1.8rem; }
.step-num {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--sun); color: var(--ink); font-weight: 800; font-size: 1.15rem; margin-bottom: 12px;
  font-family: var(--font-en);
}
html.high-contrast .step-num { background: #fff; border: 2px solid #000; }
.note { text-align: center; margin-top: 24px; color: var(--ink-soft); }

/* ---------- Contact ---------- */
.contact-actions { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 10px; }
.contact-tile {
  display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 10px 16px;
  background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  color: var(--ink); text-decoration: none; touch-action: manipulation;
}
.contact-tile:hover { border-color: var(--teal); }
.contact-tile .pict { margin: 0; font-size: 1.7rem; }
.contact-tile strong { display: block; }
.c-detail { display: block; color: var(--ink-soft); font-size: .9rem; }
html[dir="rtl"] .c-detail[dir="ltr"] { text-align: right; }
.info-list { margin: 0; display: grid; gap: 10px; }
.info-list dt { font-weight: 800; }
.info-list dd { margin: 0; color: var(--ink-soft); }

.contact-form { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.field { margin: 0 0 16px; }
.field label, .field legend { display: block; font-weight: 700; margin-bottom: 6px; }
fieldset.field { border: 0; padding: 0; min-width: 0; }
.field input:not([type="radio"]), .field select, .field textarea {
  width: 100%; font: inherit; font-size: max(1rem, 16px); /* ≥16px stops iPhone zooming in */
  color: var(--ink); background: var(--bg);
  border: 2px solid var(--field-border); border-radius: 12px; padding: 10px 14px; min-height: 52px;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--teal); }
.field [aria-invalid="true"] { border-color: var(--error) !important; border-width: 3px !important; }
.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice-row-3 { grid-template-columns: 1fr; }
.hp { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.book-points { margin-top: 20px; }
.phone-tile { margin-top: 12px; max-width: 420px; }
.btn:disabled { opacity: .6; cursor: progress; }
.choice {
  display: flex !important; align-items: center; gap: 8px; min-height: 52px; padding: 6px 12px; margin: 0 !important;
  border: 2px solid var(--field-border); border-radius: 12px; cursor: pointer; font-weight: 600 !important;
}
.choice input { width: 22px; height: 22px; accent-color: var(--teal); flex: none; margin: 0; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.req { color: var(--error); font-weight: 800; }
.form-hint, .field-hint { color: var(--ink-soft); font-size: .9rem; margin: 0 0 6px; }
.form-hint { margin-bottom: 16px; }
.field-error { color: var(--error); font-weight: 700; font-size: .92rem; margin: 6px 0 0; }
.field-error:empty { display: none; }
.field-error:not(:empty)::before { content: "⚠ " / ""; }
.form-status { margin: 12px 0 0; font-weight: 700; color: var(--teal-dark); min-height: 1.5em; }
.form-status.error { color: var(--error); }

.map-wrap { margin-top: 40px; }
.map-wrap iframe { width: 100%; height: 280px; border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.map-wrap p { margin-top: 10px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #fff; padding: 28px 0; }
.footer-inner { display: grid; gap: 8px; }
.footer-inner p { margin: 0; }
.muted { opacity: .85; }
.site-footer a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Phone quick-action bar ---------- */
.quickbar {
  position: fixed; z-index: 65; inset-inline: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--ink); padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0,0,0,.15);
}
.quickbar a, .quickbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 6px 2px; color: #fff; text-decoration: none; background: none; border: 0;
  font-weight: 700; font-size: .8rem; line-height: 1.2; cursor: pointer; touch-action: manipulation;
}
.quickbar .qi { font-size: 1.35rem; line-height: 1; }
.quickbar button[aria-expanded="true"] { background: var(--teal); }
html.high-contrast .quickbar { background: #000; }
:root { --quickbar-h: calc(64px + env(safe-area-inset-bottom)); }

/* =========================================================
   Larger screens
   ========================================================= */
@media (min-width: 600px) {
  .hero-actions { display: flex; flex-wrap: wrap; align-items: center; }
  .stats { gap: 16px; }
  .stats strong { font-size: 2rem; }
  .cards-3 { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .choice-row { grid-template-columns: repeat(4, auto); justify-content: start; }
  .choice-row-3 { grid-template-columns: repeat(3, auto); }
  .footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; }
  .a11y-statement { order: 3; flex-basis: 100%; }
  .a11y-toggle { display: inline-flex; }
}

@media (min-width: 900px) {
  :root { --header-h: 80px; --quickbar-h: 0px; }
  .quickbar { display: none; }
  .header-inner { flex-wrap: nowrap; gap: 18px; }
  .brand { margin-inline-end: 0; }
  .brand-mark { width: 46px; height: 46px; }
  .brand-text strong { font-size: 1.2rem; }
  .brand-text small { font-size: .78rem; }
  .nav-toggle { display: none; }
  .site-nav { display: block; width: auto; padding: 0; margin-inline-start: auto; }
  .site-nav ul { display: flex; align-items: center; gap: 4px; }
  .site-nav a:not(.btn) { min-height: 44px; font-size: 1rem; }
  .site-nav .btn { width: auto; margin: 0 0 0 0; margin-inline-start: 8px; }
  .header-tools { order: 3; }

  .a11y-panel {
    position: absolute; top: 100%; bottom: auto; inset-inline-start: auto; inset-inline-end: 16px;
    width: 400px; border-radius: 0 0 22px 22px; border-top: 0; border: 2px solid var(--teal);
    max-height: calc(100vh - var(--header-h) - 20px);
  }
  .toast { top: auto; bottom: 24px; }
  .hero { padding: 72px 0 56px; }
  .hero-inner { grid-template-columns: 1.15fr .85fr; gap: 40px; }
  .hero-art { display: block; }
  .hero-art svg { width: 100%; max-width: 420px; margin-inline: auto; }
  .section { padding: 88px 0; }
  .section-head { margin-bottom: 44px; }
  .cards-3 { grid-template-columns: repeat(3, 1fr); }
  .card, .contact-form { padding: 28px; }
  .steps { grid-template-columns: repeat(4, 1fr); }
  .split { grid-template-columns: 1fr 1fr; gap: 56px; }
  .map-wrap iframe { height: 340px; }
}

/* Very small phones: tighter header that scrolls away instead of covering content */
@media (max-width: 374px) {
  .brand-text small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .tool-btn { padding: 4px 8px; font-size: .8rem; }
}
/* Short screens, tiny phones or very high zoom: don't let a sticky header eat the page */
@media (max-height: 480px), (max-width: 340px) {
  .site-header { position: relative; }
  html { scroll-padding-top: 16px; }
}

@media print {
  .site-header, .quickbar, .a11y-panel, .listen, .toast, .skip-link { display: none !important; }
  body { padding: 0; }
}
