/* ============================================================
   Madrasah — Qur'an School
   ============================================================ */

:root {
  --bg: #ffffff;
  --panel: #f4f3ef;
  --ink: #1c1c1a;
  --ink-soft: #6b6b66;
  --ink-faint: #a7a7a1;
  --line: #ececea;
  --soft: #f1f0ec;
  --soft-hover: #e8e7e2;
  --dark: #1f1d1b;
  --green: #2f9e44;
  --radius: 26px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 20px 50px -30px rgba(0,0,0,.25);
  --ease: cubic-bezier(.22,.61,.36,1);
  --gap: 12px;
}

[data-theme="dark"] {
  --bg: #131211;
  --panel: #1c1b19;
  --ink: #f3f1ed;
  --ink-soft: #a3a099;
  --ink-faint: #6d6a63;
  --line: #2a2825;
  --soft: #232120;
  --soft-hover: #2c2a28;
  --dark: #f3f1ed;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 20px 50px -30px rgba(0,0,0,.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .5s var(--ease), color .5s var(--ease);
}

/* ===================== LAYOUT ===================== */
.app {
  display: grid;
  grid-template-columns: 50% 50%;
  min-height: 100vh;
  padding: var(--gap);
  gap: var(--gap);
}

/* ---- Left visual panel ---- */
.visual {
  position: sticky;
  top: var(--gap);
  height: calc(100vh - var(--gap) * 2);
  border-radius: var(--radius);
  overflow: hidden;
}
.visual-card { position: absolute; inset: 0; animation: fadeIn .6s var(--ease); }
.visual-card[hidden] { display: none; }

.brand {
  position: absolute;
  top: 22px; left: 26px;
  z-index: 5;
  font-family: "Dancing Script", cursive;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  text-shadow: 0 1px 12px rgba(0,0,0,.25);
}

/* ---- Right content panel ---- */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 4% 40px;
}

/* Mobile-only "best on desktop" note (hidden on desktop) */
.desktop-note { display: none; }

/* ===================== NAV ===================== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 0;
}
.nav-list {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0 auto;
}
.nav-list a {
  display: block;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.nav-list a:hover { color: var(--ink); }
.nav-list a.active {
  background: var(--soft);
  color: var(--ink);
}
/* Desktop: plain gold icon (original look) */
.theme-toggle {
  display: grid; place-items: center;
  border: none;
  background: transparent;
  color: #f0a000;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 999px;
  transition: background .25s, transform .4s var(--ease);
}
.theme-toggle:hover { background: var(--soft); transform: rotate(40deg); }
.theme-toggle .ti { font-size: 20px; line-height: 1; color: #f0a000; }
.theme-toggle .tl { display: none; }   /* label hidden on desktop */

/* ===================== PAGES ===================== */
.pages { flex: 1; display: flex; }
.page { width: 100%; }
.page[hidden] { display: none; }
.page:not([hidden]),
.page.is-active { display: flex; }

.page-inner {
  margin: auto 0;
  width: 100%;
  max-width: 620px;
  padding: 40px 0;
}
.home-inner { max-width: 640px; }

/* ===================== TYPOGRAPHY ===================== */
.display {
  font-size: clamp(38px, 4.4vw, 60px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin-bottom: 30px;
}
.display .muted { color: var(--ink-faint); }
.title {
  font-size: clamp(34px, 4vw, 50px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 22px;
}
.lead {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 18px;
  max-width: 560px;
}

/* ===================== HOME ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  padding: 6px 13px;
  border-radius: 999px;
  margin-bottom: 26px;
}
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.cta-row { display: flex; gap: 12px; margin-bottom: 64px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 24px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform .25s var(--ease), background .25s var(--ease), box-shadow .25s;
}
.btn:active { transform: scale(.97); }
.btn-dark { background: var(--dark); color: var(--bg); }
.btn-dark:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -10px rgba(0,0,0,.4); }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-soft:hover { background: var(--soft-hover); transform: translateY(-2px); }

.logo-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  align-items: center;
  opacity: .55;
}
.logo-cloud span {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: -.01em;
}

/* ===================== ABOUT ===================== */
.signature {
  display: block;
  margin-top: 26px;
  font-family: "Great Vibes", "Dancing Script", cursive;
  font-size: 48px;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
}

/* ===================== FEES ===================== */
.price-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--soft);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin: 30px 0 34px;
  max-width: 560px;
}
.price { display: flex; align-items: baseline; gap: 8px; }
.price-amount { font-size: 52px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.price-unit { font-size: 17px; font-weight: 500; color: var(--ink-soft); }
.price-note { font-size: 15px; color: var(--ink-soft); margin-top: 4px; }

/* ===================== CLASSES (subheads + schedule) ===================== */
.subhead {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  margin: 34px 0 12px;
}
.schedule {
  display: inline-block; margin-left: 8px;
  font-size: 13px; font-weight: 600; color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  padding: 3px 10px; border-radius: 999px; vertical-align: middle;
}

/* ===================== BLOG ===================== */
.page-blog .page-inner { margin: 0; max-width: 640px; }
.blog-inner { padding-top: 30px; }
.blog-grid { display: flex; flex-direction: column; gap: 40px; }
.blog-card .ph { margin-bottom: 16px; }
.cat {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; margin-bottom: 10px;
}
.cat-green { color: #2f9e44; background: #e7f6ec; }
.cat-blue { color: #2563eb; background: #e8eefc; }
[data-theme="dark"] .cat-green { background: #16301d; }
[data-theme="dark"] .cat-blue { background: #172138; }
.blog-card h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; letter-spacing: -.01em; }
.blog-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.6; max-width: 540px; }

/* ---- Location: building slideshow + map ---- */
.ph-building { height: 360px; border-radius: var(--radius-sm); margin: 22px 0 0; }
.map-embed {
  margin: 22px 0 18px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
}
.map-embed iframe { display: block; width: 100%; height: 340px; border: 0; }
.map-link { color: var(--green); font-weight: 600; text-decoration: none; }
.map-link:hover { text-decoration: underline; }

/* ===================== CONTACT (form) ===================== */
.form {
  display: grid; grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 20px 24px; margin-top: 30px; max-width: 600px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 15px; font-weight: 500; color: var(--ink); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 15px 16px; outline: none;
  transition: border-color .25s, box-shadow .25s;
  resize: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink-faint);
  box-shadow: 0 0 0 4px var(--soft);
}
.form-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 26px; max-width: 600px; gap: 16px; }
.resp { font-size: 13px; color: var(--ink-soft); }

/* ---- Child detail blocks ---- */
.child-list { display: flex; flex-direction: column; gap: 28px; }
.child-block { position: relative; }
.child-block + .child-block { padding-top: 28px; border-top: 1px solid var(--line); }
.child-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; letter-spacing: -.01em; }
.child-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 20px 24px; }
.child-remove {
  position: absolute; top: 0; right: 0;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  padding: 2px 6px; border-radius: 8px;
}
.child-block + .child-block .child-remove { top: 28px; }
.child-remove:hover { color: #c0392b; }
.btn-add {
  background: none; color: var(--ink);
  border: 1px dashed var(--ink-faint);
}
.btn-add:hover { background: var(--soft); }
@media (max-width: 560px) {
  .child-grid { grid-template-columns: 1fr; }
}
.form-status { max-width: 600px; margin-top: 16px; font-size: 14px; line-height: 1.5; }
.form-status.is-sending { color: var(--ink-soft); }
.form-status.is-success { color: #1a7f4b; }
.form-status.is-error { color: #c0392b; }
.privacy-check { align-items: flex-start; }
.check-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.field .check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 0;
  border-radius: 4px;
}
.check-label a,
.resp a {
  color: var(--green);
  font-weight: 600;
  text-decoration: none;
}
.check-label a:hover,
.resp a:hover { text-decoration: underline; }
button[disabled] { opacity: .6; cursor: not-allowed; }

/* ===================== IMAGE PLACEHOLDERS ===================== */
.ph {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: rgba(255,255,255,.92);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px),
    linear-gradient(150deg, #b9b69e, #8f9277 55%, #6f7256);
  overflow: hidden;
}
.ph-tall { height: 100%; }
.ph-wide { height: 230px; border-radius: var(--radius-sm); }
.ph.warm  { background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px), linear-gradient(150deg, #e8762f, #c2410c 70%); }
.ph.cool  { background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px), linear-gradient(150deg, #7fa3b3, #4d7689 70%); }
.ph.deep  { background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px), linear-gradient(150deg, #2f6b4f, #16402d 70%); }
.ph.ember { background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px), linear-gradient(150deg, #d98a5a, #9a3b1f 70%); }
.ph-tag {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(0,0,0,.28); backdrop-filter: blur(4px);
}

/* ---- Image slideshow (cross-fade) ---- */
.slideshow { padding: 0; background: #14130f; }
.slideshow .slide {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.1s var(--ease), transform 6s linear;
  transform: scale(1.04);
  z-index: 1;
}
.slideshow .slide.active { opacity: 1; transform: scale(1); z-index: 2; }
.slideshow .slide.missing { display: none; }       /* hide broken <img> so fallback shows */
.ph-fallback {
  position: absolute; inset: 0; z-index: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; color: rgba(255,255,255,.92);
}
/* Only reveal the placeholder text when an image actually fails to load */
.ph .cover.missing ~ .ph-fallback,
.ph .slide.missing ~ .ph-fallback { display: flex; }

/* ---- Single cover image (blog cards, contact, featured) ---- */
.ph .cover {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.ph .cover.missing { display: none; }   /* broken img hidden -> fallback shows */
.ph-name { font-size: 15px; font-weight: 600; padding: 0 24px; max-width: 90%; }

/* ===================== VISUAL OVERLAYS ===================== */
.dots { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; gap: 7px; z-index: 4; }
.dot {
  width: 22px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.4); overflow: hidden;
  transition: width .3s var(--ease);
}
.dot.active { width: 30px; }
.dot i { display: block; height: 100%; width: 0; background: #fff; border-radius: 999px; }
.dot i.run { animation: fillBar 5s linear forwards; }
@keyframes fillBar { from { width: 0; } to { width: 100%; } }

.round-arrow {
  position: absolute; right: 24px; bottom: 22px; z-index: 4;
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.85); color: #1c1c1a; font-size: 17px;
  display: grid; place-items: center;
  transition: transform .3s var(--ease), background .3s;
}
.round-arrow:hover { transform: scale(1.08); background: #fff; }

.contact-foot {
  position: absolute; left: 26px; right: 26px; bottom: 24px; z-index: 4;
  display: flex; gap: 30px; color: #fff; flex-wrap: wrap;
}
.contact-foot > div { display: flex; flex-direction: column; gap: 3px; }
.cf-label { font-size: 12px; opacity: .75; }
.cf-val { font-size: 14px; font-weight: 600; }

/* ===================== ANIMATIONS ===================== */
.reveal { opacity: 0; transform: translateY(16px); }
.page.is-active .reveal { animation: rise .7s var(--ease) forwards; }
.page.is-active .reveal[data-delay="1"] { animation-delay: .08s; }
.page.is-active .reveal[data-delay="2"] { animation-delay: .16s; }
.page.is-active .reveal[data-delay="3"] { animation-delay: .24s; }
.page.is-active .reveal[data-delay="4"] { animation-delay: .32s; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: var(--gap);
    gap: 6px;
  }
  /* Content first, imagery pushed to the bottom */
  .content {
    order: 1;
    padding: 4px 22px 28px;
  }
  .visual {
    order: 2;
    position: relative;
    top: 0;
    height: 48vh;
    min-height: 320px;
  }
  /* Top-align the content instead of vertical-centering (less floaty) */
  .page-inner {
    margin: 0;
    max-width: 100%;
    padding: 8px 0 8px;
  }
  .form { grid-template-columns: 1fr; max-width: 100%; }
  .form-foot, .form-status { max-width: 100%; }
  .nav-list { margin: 0; overflow-x: auto; }

  /* Hide Adab & Aqeedah chips on phones */
  .hide-mobile { display: none; }

  /* "Best viewed on desktop" note — subtle caption at the very top */
  .desktop-note {
    display: block;
    order: -1;
    margin: 0;
    padding: 2px 0 0;
    background: none;
    border: none;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--ink-faint);
    text-align: center;
  }

  /* Classes page: show the image at the TOP instead of the bottom */
  .app[data-page="blog"] .visual { order: 0; }
  .app[data-page="blog"] .content { order: 1; }

  /* Home: centre the hero (heading, buttons, subject chips) on phones */
  .app[data-page="home"] .home-inner { text-align: center; }
  .app[data-page="home"] .cta-row,
  .app[data-page="home"] .logo-cloud { justify-content: center; }

  /* Phone-only fonts: characterful headings + friendly body */
  body { font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif; }
  .display, .title, .subhead, .blog-card h3, .child-title {
    font-family: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
    letter-spacing: -.02em;
  }
  .nav-list a, .desktop-note {
    font-family: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
  }

  /* Selected nav tab: clean underline accent instead of the grey pill */
  .nav-list a.active {
    background: transparent;
    color: var(--green);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
  }
  .nav-list a.active:hover { color: var(--green); }

  /* Remove the brand wordmark over the About photo (phones only) */
  .app[data-page="about"] .brand { display: none; }

  /* Phones: float the toggle to the right, level with the page heading */
  .content { position: relative; }
  .theme-toggle {
    position: absolute; top: 50px; right: 0; z-index: 6;
    display: inline-flex; align-items: center; gap: 5px;
    width: auto; height: 29px; padding: 0 11px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: inherit; font-size: 12px; font-weight: 600;
    white-space: nowrap;
    transition: background .25s, border-color .25s;
  }
  .theme-toggle:hover { background: var(--soft); border-color: var(--ink-faint); transform: none; }
  .theme-toggle .ti { font-size: 14px; }
  .theme-toggle .tl { display: inline; }   /* label shown on phones */

  /* Show the toggle only on Home, Fees & Contact — hide on About & Classes */
  .app[data-page="about"] .theme-toggle,
  .app[data-page="blog"] .theme-toggle { display: none; }
}
@media (max-width: 560px) {
  .nav-list { width: 100%; justify-content: flex-start; overflow-x: auto; }
  .content { padding: 4px 18px 24px; }
  .display { font-size: 36px; }
  .title { font-size: 32px; }
  .visual { height: 42vh; min-height: 280px; }
}
