/* ============================================================
   MOBILE-FIRST OVERRIDES — AQIQAH INVITATION
   Fixes: canvas flow bug, broken 2-col grids, tap targets,
   vertical rhythm. Loaded last so it wins.
   ============================================================ */

/* ---------- 1. CANVAS: take it out of document flow ---------- */
canvas#ambient-canvas,
.ambient-canvas {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  display: block;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}

body > main,
body > header,
body > footer {
  position: relative;
  z-index: 1;
}

/* ---------- 2. GLOBAL MOBILE BASELINE ---------- */
* { min-width: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 84px;
}

body {
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

img, svg, video { max-width: 100%; height: auto; }

/* Canvas must never be stretched: the swarm takeover overlay and Leaflet both
   size their own canvases in px. A global `height:auto` collapses them to 1px. */
canvas { max-width: 100%; }

/* Kill the forced 100vh hero on small screens */
.hero-section {
  min-height: 0 !important;
  display: block;
  padding: 88px 18px 44px !important;
}

.hero-stage-grid {
  display: flex !important;
  flex-direction: column;
  gap: 30px !important;
  min-height: 0 !important;
  margin-top: 0 !important;
}

/* Reorder for mobile: name/portrait first, then supporting cards */
.hero-center-col { order: 1; width: 100%; max-width: 100%; margin: 0 !important; }
.left-flank      { order: 2; }
.right-flank     { order: 3; }

/* ---------- 3. TYPE SCALE (mobile) ---------- */
.hero-script {
  font-size: 20px !important;
  line-height: 1.35;
  margin-bottom: 6px !important;
}

.hero-name {
  font-size: clamp(34px, 11vw, 46px) !important;
  line-height: 1.08 !important;
  letter-spacing: -0.015em;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.hero-desc {
  font-size: 15px !important;
  line-height: 1.68 !important;
  max-width: 100% !important;
  margin-top: 14px !important;
}

.section-title {
  font-size: clamp(24px, 7.4vw, 30px) !important;
  line-height: 1.24 !important;
}

.section-label { font-size: 11px !important; letter-spacing: 0.16em; }

/* ---------- 4. FIX THE BROKEN TWO-COLUMN GRIDS ---------- */
.about-grid {
  grid-template-columns: 1fr !important;
  gap: 22px !important;
  padding: 22px 18px !important;
}

.about-text,
.about-grid p,
.quote-box {
  font-size: 15px !important;
  line-height: 1.72 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.quote-box {
  padding: 20px 18px !important;
  border-radius: 14px !important;
}

/* Cards: generous padding, full width */
.glass-card {
  padding: 22px 18px !important;
  border-radius: 16px !important;
  width: 100% !important;
}

/* ---------- 5. SECTIONS + RHYTHM ---------- */
.section {
  padding: 52px 16px !important;
  min-height: 0 !important;
}

.section-header { margin-bottom: 24px !important; }

.section-divider-bar {
  padding: 12px 16px !important;
  font-size: 11px !important;
  gap: 10px !important;
}

/* ---------- 6. EVENT / COUNTDOWN ---------- */
.countdown-row,
#countdown {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 8px !important;
  max-width: 100% !important;
  width: 100% !important;
}

.countdown-cell {
  padding: 12px 4px !important;
  border-radius: 12px !important;
  min-width: 0;
}

.cd-num {
  font-size: clamp(22px, 7vw, 28px) !important;
  line-height: 1 !important;
  font-variant-numeric: tabular-nums;
}

.cd-lbl {
  font-size: 9px !important;
  letter-spacing: 0.1em !important;
  color: #475569 !important;
}

.countdown-name { font-size: clamp(20px, 6vw, 26px) !important; }

.event-subgrid {
  grid-template-columns: 1fr !important;
  gap: 16px !important;
}

.event-countdown-card,
.highlighted-card { padding: 20px 16px !important; }

/* ---------- 7. BENTO GRID ---------- */
.bento-grid {
  grid-template-columns: 1fr !important;
  gap: 14px !important;
}

.bento-card {
  padding: 20px 18px !important;
  min-height: 0 !important;
}

.bento-title { font-size: 17px !important; }
.bento-desc  { font-size: 14px !important; line-height: 1.66 !important; }

/* Filter chips: horizontal scroll, never wrap ugly */
.filter-row,
.filter-chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar,
.filter-chips::-webkit-scrollbar { display: none; }

.filter-btn {
  flex: 0 0 auto;
  padding: 9px 16px !important;
  font-size: 13px !important;
  white-space: nowrap;
}

/* ---------- 8. TAP TARGETS >= 44px ---------- */
.btn-crimson,
.btn-blue,
.btn-glass,
.btn-primary,
.btn-sm,
.copy-btn,
.social-pill,
.filter-btn {
  min-height: 46px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px !important;
  border-radius: 12px !important;
  font-size: 14px !important;
  touch-action: manipulation;
}

.btn-sm { min-height: 44px !important; padding: 10px 16px !important; font-size: 13px !important; }

.hero-actions {
  flex-direction: column !important;
  gap: 10px !important;
  width: 100% !important;
}

.hero-actions .btn-crimson,
.hero-actions .btn-blue,
.hero-actions .btn-glass { width: 100% !important; }

/* ---------- 9. CONTACT ---------- */
.contact-card { padding: 24px 18px !important; }

.email-action-box {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 10px !important;
  padding: 16px !important;
  width: 100% !important;
}

.email-address {
  font-size: clamp(17px, 5.2vw, 21px) !important;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.social-row,
.contact-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  width: 100%;
}

.social-row > *,
.contact-actions > * { flex: 1 1 100%; }

/* ---------- 10. HERO STATS ---------- */
.hero-stats-row {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px !important;
  width: 100% !important;
  margin-top: 20px !important;
}

.hero-stat-box { padding: 12px 6px !important; text-align: center; }
.stat-val { font-size: 16px !important; }
.stat-lbl { font-size: 11px !important; line-height: 1.3; }

/* ---------- 11. PORTRAIT / MEDALLION ---------- */
.hero-cutout-wrap {
  width: min(100%, 300px) !important;
  margin: 0 auto !important;
}

.hero-portrait-panel,
.hero-center-col > * { max-width: 100%; }

.hud-stack { gap: 10px !important; margin-top: 18px !important; }
.hud-card { padding: 16px !important; border-radius: 14px !important; }
.hud-card-title { font-size: 17px !important; }
.hud-card-desc { font-size: 14px !important; line-height: 1.6 !important; }

/* ---------- 12. DOCK NAV ---------- */
.dock-container {
  top: 10px !important;
  padding: 0 12px !important;
  width: 100% !important;
  max-width: 100%;
}

.nav-dock {
  width: 100% !important;
  justify-content: space-between !important;
  gap: 8px !important;
  padding: 7px 12px !important;
  border-radius: 999px !important;
}

.nav-links { display: none !important; }

.nav-item {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  font-size: 12px !important;
  border-radius: 999px;
}

/* ---------- 13. FOOTER + MISC ---------- */
.footer-meta { font-size: 12px !important; }
.tech-tag { font-size: 12px !important; padding: 6px 10px !important; }

.section-divider-bar .divider-line { display: none !important; }
.brand-label, .grid-coord { display: none !important; }

/* Prevent any stray fixed-width element from bleeding out */
.wrap, .container { max-width: 100% !important; }

/* ---------- 14. TOAST ---------- */
.toast-notification {
  left: 12px !important;
  right: 12px !important;
  bottom: 16px !important;
  transform: translateY(120%);
  width: auto !important;
  max-width: none !important;
}
.toast-notification.show { transform: translateY(0) !important; }

/* ============================================================
   TABLET — 640px and up
   ============================================================ */
@media (min-width: 640px) {
  .hero-section { padding: 96px 28px 56px !important; }
  .hero-name { font-size: clamp(42px, 7vw, 56px) !important; }
  .section-title { font-size: clamp(28px, 4.4vw, 36px) !important; }

  .section { padding: 64px 24px !important; }
  .glass-card { padding: 26px 24px !important; }

  .event-subgrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  .hero-actions {
    flex-direction: row !important;
    flex-wrap: wrap !important;
  }
  .hero-actions .btn-crimson,
  .hero-actions .btn-blue,
  .hero-actions .btn-glass { width: auto !important; }

  .social-row > *,
  .contact-actions > * { flex: 0 1 auto; }

  .countdown-row, #countdown { gap: 12px !important; }
  .cd-num { font-size: 30px !important; }
  .cd-lbl { font-size: 10px !important; }
}

/* ============================================================
   DESKTOP — 1024px and up (original 3-column layout)
   ============================================================ */
@media (min-width: 1024px) {
  .hero-section {
    min-height: min(100vh, 100svh) !important;
    padding: 96px 32px 64px !important;
  }

  /* Two rows: the copy (left) and the ayat cards (right) sit on top, and the
     photo gallery runs the full hero width underneath. A single-row layout
     would squeeze the gallery into the 380px middle column. */
  .hero-stage-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    grid-template-areas:
      'left right'
      'photo photo';
    grid-template-rows: auto auto;
    align-items: start;
    gap: 32px !important;
    min-height: 0 !important;
  }

  .hero-center-col {
    order: 0;
    grid-area: photo;
    justify-self: stretch;
    width: 100%;
    max-width: 100% !important;
    margin: 0 !important;
  }
  .left-flank      { order: 0; grid-area: left; }
  .right-flank     { order: 0; grid-area: right; }

  .hero-script { font-size: 44px !important; }
  .hero-name { font-size: clamp(64px, 6.4vw, 92px) !important; }
  .hero-desc { font-size: 16px !important; max-width: 56ch !important; }

  .section { padding: 96px 32px !important; }
  .section-title { font-size: 42px !important; }

  .about-grid { grid-template-columns: 1fr 1fr !important; gap: 32px !important; padding: 36px 32px !important; }
  .glass-card { padding: 32px !important; }

  .event-subgrid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important; }

  .bento-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)) !important; gap: 20px !important; }

  .countdown-row, #countdown { gap: 12px !important; max-width: 560px !important; }
  .cd-num { font-size: 36px !important; }
  .cd-lbl { font-size: 10px !important; }

  .hero-stats-row { gap: 16px !important; }
  .stat-val { font-size: 20px !important; }
  .stat-lbl { font-size: 13px !important; }

  .hero-cutout-wrap { width: min(100%, 380px) !important; }

  .nav-links { display: flex !important; }
  .nav-dock { justify-content: center !important; gap: 10px !important; }

  .toast-notification {
    left: auto !important;
    right: 24px !important;
    width: auto !important;
    max-width: 380px !important;
  }
}

/* ============================================================
   SMALL PHONES — 360px and below
   ============================================================ */
@media (max-width: 360px) {
  .hero-section { padding: 84px 14px 40px !important; }
  .hero-name { font-size: clamp(30px, 10.5vw, 36px) !important; }
  .section { padding: 44px 14px !important; }
  .glass-card { padding: 18px 14px !important; }
  .countdown-row, #countdown { gap: 6px !important; }
  .countdown-cell { padding: 10px 2px !important; }
  .cd-num { font-size: 20px !important; }
  .cd-lbl { font-size: 8px !important; }
  .btn-crimson, .btn-blue, .btn-glass, .social-pill { font-size: 13px !important; padding: 11px 16px !important; }
}

/* ============================================================
   LANDSCAPE PHONE
   ============================================================ */
@media (max-height: 480px) and (orientation: landscape) {
  .hero-section { min-height: 0 !important; padding: 78px 24px 36px !important; }
  .hero-stage-grid { gap: 20px !important; }
  .hero-cutout-wrap { width: min(100%, 220px) !important; }
}
/* ============================================================
   15. FINAL POLISH — nav taps + countdown label legibility
   ============================================================ */
.nav-brand {
  min-width: 44px !important;
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.dock-cta {
  min-height: 44px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px 16px !important;
  font-size: 13px !important;
}

/* Countdown labels: minimum legible size */
.cd-lbl {
  font-size: 11px !important;
  letter-spacing: 0.05em !important;
  line-height: 1.25 !important;
}

/* Keep countdown cells wide enough for 11px labels on the smallest phones */
@media (max-width: 360px) {
  .cd-lbl { font-size: 11px !important; letter-spacing: 0 !important; }
  .countdown-row, #countdown { gap: 5px !important; }
  .countdown-cell { padding: 10px 2px !important; }
}
