/* ==========================================================================
   PANDAI — Design System
   WCAG 2.1 AA compliant: contrast >= 4.5:1, visible focus, reduced motion
   ========================================================================== */

/* ---------- Custom properties ---------- */
:root {
  --navy: #14264e;
  --navy-dark: #0d1a38;
  --navy-light: #23407f;
  --gold: #c9a44c;        /* decorative only (borders, icons on dark) */
  --gold-text: #755a14;   /* 4.5:1+ on ivory, for text accents */
  --ivory: #fbf8f1;
  --cream: #f4eede;
  --white: #ffffff;
  --ink: #1c2333;         /* body text: 13+:1 on ivory */
  --ink-soft: #45506b;    /* secondary text: 7+:1 on ivory */
  --error: #a4262c;
  --success: #1e6641;
  --focus: #1a55c4;

  --font-scale: 1;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-head: "Playfair Display", Georgia, serif;
  --font-ar-body: "Noto Naskh Arabic", "Source Sans 3", serif;
  --font-ar-head: "Amiri", "Playfair Display", serif;

  --radius: 14px;
  --shadow: 0 4px 24px rgba(13, 26, 56, 0.1);
  --maxw: 72rem;
}

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

body {
  margin: 0;
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(1.0625rem * var(--font-scale));
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

[lang="ar"] body,
body[lang="ar"] {
  font-family: var(--font-ar-body);
}

html[lang="ar"] body {
  font-family: var(--font-ar-body);
  line-height: 1.9;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--navy);
  line-height: 1.25;
  margin: 0 0 0.5em;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4 {
  font-family: var(--font-ar-head);
}

h1 { font-size: calc(2.4rem * var(--font-scale)); }
h2 { font-size: calc(1.9rem * var(--font-scale)); }
h3 { font-size: calc(1.35rem * var(--font-scale)); }

p { margin: 0 0 1em; }

a {
  color: var(--navy-light);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover { color: var(--navy-dark); }

ul, ol { padding-inline-start: 1.4em; }

/* ---------- Focus visibility (WCAG 2.4.7) ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.btn:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ---------- Skip link (WCAG 2.4.1) ---------- */
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  z-index: 200;
  background: var(--navy);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 600;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ---------- Layout helpers ---------- */
.container {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.section {
  padding-block: 3.5rem;
}

.section--alt {
  background: var(--cream);
}

.section--navy {
  background: var(--navy);
  color: var(--white);
}

.section--navy h2,
.section--navy h3 {
  color: var(--white);
}

.section--navy a {
  color: #cfe0ff;
}

.section-head {
  max-width: 46rem;
  margin-bottom: 2.25rem;
}

.kicker {
  display: inline-block;
  font-size: calc(0.85rem * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 0.6rem;
}

.section--navy .kicker {
  color: var(--gold);
}

.lead {
  font-size: calc(1.2rem * var(--font-scale));
  color: var(--ink-soft);
}

.section--navy .lead {
  color: #d8e0f2;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid #e5ddc8;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4.5rem;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--navy);
  font-weight: 700;
}

.brand svg,
.brand img {
  height: 2.4rem;
  width: auto;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-head);
  font-size: calc(1.4rem * var(--font-scale));
  line-height: 1;
}

.brand-tag {
  display: block;
  font-family: var(--font-body);
  font-size: calc(0.7rem * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--gold-text);
  margin-top: 0.25rem;
}

.main-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.main-nav a {
  display: block;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
  color: var(--navy);
  font-weight: 600;
  border-radius: 8px;
  font-size: calc(0.98rem * var(--font-scale));
}

.main-nav a:hover {
  background: var(--cream);
}

.main-nav a[aria-current="page"] {
  background: var(--navy);
  color: var(--white);
}

.nav-toggle {
  display: none;
  background: var(--navy);
  color: var(--white);
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Language switcher */
.lang-switch {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.lang-switch a,
.lang-switch span {
  display: block;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  font-size: calc(0.88rem * var(--font-scale));
  font-weight: 700;
  text-decoration: none;
  color: var(--navy);
  border: 1.5px solid transparent;
}

.lang-switch a:hover {
  border-color: var(--gold);
}

.lang-switch [aria-current="true"] {
  background: var(--navy);
  color: var(--white);
}

@media (max-width: 61rem) {
  .nav-toggle { display: inline-block; }

  .main-nav {
    display: none;
    width: 100%;
  }

  .main-nav.is-open { display: block; }

  .main-nav ul {
    flex-direction: column;
    padding-block: 0.75rem;
  }

  .header-inner { flex-wrap: wrap; }
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(ellipse at 85% 15%, rgba(201, 164, 76, 0.22), transparent 55%),
    linear-gradient(160deg, var(--navy-dark), var(--navy) 60%, var(--navy-light));
  color: var(--white);
  padding-block: 5rem 6rem;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -6rem;
  top: -6rem;
  width: 26rem;
  height: 26rem;
  border: 2px solid rgba(201, 164, 76, 0.35);
  border-radius: 50%;
  pointer-events: none;
}

.hero h1 {
  color: var(--white);
  max-width: 21ch;
  font-size: calc(clamp(2.1rem, 5vw, 3.3rem) * var(--font-scale));
}

.hero .kicker {
  color: var(--gold);
}

.hero-lead {
  max-width: 54ch;
  font-size: calc(1.2rem * var(--font-scale));
  color: #dbe3f5;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: calc(1.02rem * var(--font-scale));
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn--gold {
  background: var(--gold);
  color: var(--navy-dark);
}

.btn--gold:hover {
  background: #d9b765;
  color: var(--navy-dark);
}

.btn--outline {
  border-color: var(--white);
  color: var(--white);
  background: transparent;
}

.btn--outline:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
}

.btn--navy {
  background: var(--navy);
  color: var(--white);
}

.btn--navy:hover {
  background: var(--navy-light);
  color: var(--white);
}

/* ---------- Cards ---------- */
.grid {
  display: grid;
  gap: 1.4rem;
}

.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(13.5rem, 100%), 1fr)); }

.card {
  background: var(--white);
  border: 1px solid #e8e1cd;
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0.2rem;
}

.card--plain {
  border-top-color: #e8e1cd;
}

.card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
  margin-bottom: 0.8rem;
  font-size: calc(1rem * var(--font-scale));
}

/* Values strip */
.values-strip {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
}

.value-item {
  text-align: center;
  padding: 1.4rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 164, 76, 0.4);
  border-radius: var(--radius);
}

.value-item h3 {
  color: var(--gold);
  font-size: calc(1.15rem * var(--font-scale));
}

.value-item p {
  color: #d8e0f2;
  font-size: calc(0.95rem * var(--font-scale));
  margin: 0;
}

/* ---------- News / event cards ---------- */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid #e8e1cd;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.post-card img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
}

.post-card-body {
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.post-card time,
.post-meta {
  color: var(--ink-soft);
  font-size: calc(0.9rem * var(--font-scale));
}

.post-card h3 a {
  color: var(--navy);
  text-decoration: none;
}

.post-card h3 a:hover {
  text-decoration: underline;
}

.event-row {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
  background: var(--white);
  border: 1px solid #e8e1cd;
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
}

.event-date {
  flex-shrink: 0;
  text-align: center;
  background: var(--navy);
  color: var(--white);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  min-width: 4.6rem;
}

.event-date .d {
  display: block;
  font-size: calc(1.5rem * var(--font-scale));
  font-weight: 700;
  line-height: 1.1;
}

.event-date .m {
  display: block;
  font-size: calc(0.82rem * var(--font-scale));
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Gallery ---------- */
.album-grid {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr));
}

.album-card a {
  text-decoration: none;
}

.gallery-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
}

.gallery-grid img {
  border-radius: 10px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
}

/* ---------- Forms (WCAG 3.3) ---------- */
.form-grid {
  display: grid;
  gap: 1.1rem;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--navy);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid #b9b09a;
  border-radius: 10px;
  font: inherit;
  background: var(--white);
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.required-note {
  color: var(--ink-soft);
  font-size: calc(0.92rem * var(--font-scale));
}

.req {
  color: var(--error);
  font-weight: 700;
}

/* ---------- Donate ---------- */
.bank-box {
  background: var(--white);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.bank-box dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  margin: 0 0 1.4rem;
}

.bank-box dt {
  font-weight: 700;
  color: var(--ink-soft);
}

.bank-box dd {
  margin: 0;
  font-weight: 600;
}

.bank-account {
  font-size: calc(1.55rem * var(--font-scale));
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.04em;
}

/* ---------- Contact ---------- */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.1rem;
}

.contact-list strong {
  display: block;
  color: var(--navy);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy-dark);
  color: #d8e0f2;
  padding-block: 3rem 1.5rem;
  margin-top: 4rem;
}

.site-footer h2 {
  color: var(--white);
  font-size: calc(1.15rem * var(--font-scale));
  font-family: var(--font-body);
  font-weight: 700;
}

.site-footer a {
  color: #cfe0ff;
}

.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(201, 164, 76, 0.35);
}

.footer-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.footer-bottom {
  padding-top: 1.4rem;
  font-size: calc(0.9rem * var(--font-scale));
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: space-between;
}

/* ---------- Accessibility widget ---------- */
.a11y-fab {
  position: fixed;
  inset-inline-end: 1.1rem;
  bottom: 1.1rem;
  z-index: 300;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--navy);
  color: var(--white);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-fab svg {
  width: 1.9rem;
  height: 1.9rem;
}

.a11y-panel {
  position: fixed;
  inset-inline-end: 1.1rem;
  bottom: 5.2rem;
  z-index: 300;
  width: min(21rem, calc(100vw - 2.2rem));
  max-height: min(70vh, 34rem);
  overflow: auto;
  background: var(--white);
  border: 2px solid var(--navy);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  padding: 1.1rem;
}

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

.a11y-panel h2 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  margin: 0 0 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.a11y-close {
  background: none;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--navy);
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
}

.a11y-group {
  display: grid;
  gap: 0.5rem;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.a11y-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.65rem 0.8rem;
  border: 2px solid #cbc2a8;
  border-radius: 10px;
  background: var(--white);
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: start;
}

.a11y-toggle[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}

.a11y-size {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.a11y-size button {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 8px;
  border: 2px solid #cbc2a8;
  background: var(--white);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}

.a11y-reset {
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.65rem;
  border-radius: 10px;
  border: 2px solid var(--error);
  color: var(--error);
  background: var(--white);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- A11y modes (body classes) ---------- */
body.a11y-contrast {
  --ivory: #ffffff;
  --cream: #ffffff;
  --ink: #000000;
  --ink-soft: #1a1a1a;
  --navy: #001040;
  --navy-light: #001a66;
  --gold-text: #4d3a00;
}

body.a11y-contrast .card,
body.a11y-contrast .post-card,
body.a11y-contrast .event-row {
  border-color: #000;
}

body.a11y-dyslexia,
body.a11y-dyslexia h1,
body.a11y-dyslexia h2,
body.a11y-dyslexia h3,
body.a11y-dyslexia h4,
body.a11y-dyslexia .brand-name {
  font-family: "Atkinson Hyperlegible", Verdana, sans-serif !important;
}

body.a11y-links a {
  background: #ffe9a8;
  color: #001040 !important;
  text-decoration: underline !important;
  outline: 2px solid #001040;
}

body.a11y-spacing {
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
}

body.a11y-spacing p,
body.a11y-spacing li {
  line-height: 2.1;
  margin-bottom: 1.4em;
}

body.a11y-motion *,
body.a11y-motion *::before,
body.a11y-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

#a11y-ruler {
  position: fixed;
  left: 0;
  right: 0;
  height: 3.2rem;
  pointer-events: none;
  z-index: 290;
  background: rgba(201, 164, 76, 0.28);
  border-top: 3px solid var(--gold-text);
  border-bottom: 3px solid var(--gold-text);
  display: none;
}

body.a11y-ruler #a11y-ruler {
  display: block;
}

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

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }

.mt-2 { margin-top: 2rem; }

.cta-band {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--navy);
  border-radius: var(--radius);
  color: var(--white);
}

.cta-band h2 { color: var(--white); }
.cta-band p { color: #d8e0f2; max-width: 50ch; margin-inline: auto; }

@media print {
  .site-header, .site-footer, .a11y-fab, .a11y-panel, .hero-ctas { display: none; }
}
