/* ============================================================
   mobile.css – Mobile layout, responsive grids & nav drawer
   Aligned with Stitch Mobile Design (Royal Heraldic Order)
   ============================================================ */

@property --drawer-backdrop {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

/* ── Navigation Drawer (<dialog>) ──────────────────────────── */
.nav-drawer {
  --drawer-width: min(20rem, 82dvw, calc(100dvw - 48px));
  --drawer-backdrop: 0;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}
.nav-drawer:not([open]) {
  display: none;
}
.nav-drawer::backdrop {
  background: #1c1b1b;
  opacity: calc(var(--drawer-backdrop) * 0.55);
}

.nav-drawer-scroller {
  position: relative;
  display: grid;
  grid-template-columns: var(--drawer-width) 100%;
  overflow-x: scroll;
  overscroll-behavior: none;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.nav-drawer-scroller::-webkit-scrollbar {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .nav-drawer-scroller {
    scroll-behavior: smooth;
  }
}
.nav-drawer-scroller::after {
  content: '';
  scroll-snap-align: end;
  scroll-initial-target: nearest;
}

.nav-drawer-sheet {
  display: flex;
  flex-direction: column;
  height: 100svh;
  background: var(--color-surface);
  color: var(--color-on-surface);
  overflow-y: auto;
  scroll-snap-align: start;
  scrollbar-width: none;
  border-right: 1px solid var(--color-secondary);
}
.nav-drawer-sheet::-webkit-scrollbar {
  display: none;
}

@supports (animation-timeline: scroll()) {
  .nav-drawer {
    timeline-scope: --drawer-fade;
    animation: fade-drawer-backdrop linear both;
    animation-timeline: --drawer-fade;
  }
  .nav-drawer-scroller {
    scroll-timeline: --drawer-fade x;
  }
  @keyframes fade-drawer-backdrop {
    0%   { --drawer-backdrop: 1; }
    100% { --drawer-backdrop: 0; }
  }
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-outline-variant);
}
.nav-drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-headline);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  line-height: 1.25;
}
.nav-drawer-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.nav-drawer-close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  flex-shrink: 0;
}
.nav-drawer-close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav-drawer-links {
  display: flex;
  flex-direction: column;
  padding-block: 8px;
}
.nav-drawer-links a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 20px;
  font-family: var(--font-headline);
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--color-on-surface);
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--color-outline-variant);
  transition: background-color 0.15s, color 0.15s;
}
.nav-drawer-links a:hover {
  color: var(--color-primary);
  background: var(--color-surface-container-low);
}
.nav-drawer-links a[aria-current="page"],
.nav-drawer-links a.active {
  color: var(--color-primary);
  background: var(--color-primary-fixed);
  border-left-color: var(--color-primary);
  font-weight: 700;
}
.nav-drawer-links a:focus-visible,
.nav-drawer-admin:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.nav-drawer-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
}
.nav-drawer-admin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-family: var(--font-label);
  font-size: var(--fs-label-sm);
  letter-spacing: var(--ls-label-sm);
  text-transform: uppercase;
  color: var(--color-primary);
}

/* ── Tablet & Small Desktop (<= 1024px) ────────────────────── */
@media (max-width: 1024px) {
  .nav-links   { display: none; }
  .nav-actions { display: none; }
  .nav-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
  }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .site-footer .footer-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Collapse 12-col & About Grids (<= 900px) ──────────────── */
@media (max-width: 900px) {
  .grid-12 {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .grid-12 > *,
  .col-span-4,
  .col-span-5,
  .col-span-7,
  .col-span-8,
  .col-span-12 {
    grid-column: 1 / -1;
  }

  .about-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "intro"
      "cards"
      "cta";
    gap: 28px;
  }
  .about-intro { text-align: center; }
  .about-intro .about-eyebrow { justify-content: center; }
  .about-intro p { text-align: left; }
  .about-cta { text-align: center; }
}

/* ── Mobile (<= 768px) ─────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --fs-display-lg:  26px;
    --lh-display-lg:  34px;
    --ls-display-lg:  0.04em;
    --fs-headline-lg: 22px;
    --lh-headline-lg: 30px;
    --ls-headline-lg: 0.02em;
    --fs-title-md:    18px;
    --lh-title-md:    26px;
    --space-section:  48px;
    --space-gutter:   20px;
  }

  .container {
    padding-inline: var(--space-margin-mobile);
  }

  /* Compact sticky mobile header */
  .site-nav .container {
    height: 68px;
    gap: 12px;
  }
  .nav-brand {
    gap: 10px;
    min-width: 0;
  }
  .nav-brand img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .nav-brand-text .brand-line1 {
    font-size: 10px;
    letter-spacing: 0.12em;
  }
  .nav-brand-text .brand-line2 {
    font-size: 13px;
  }
  .nav-brand-text .brand-line3 {
    font-size: 9px;
    letter-spacing: 0.16em;
  }

  /* Hero */
  .hero {
    min-height: auto;
    padding-block: 44px 52px;
  }
  .hero-eyebrow {
    font-size: 16px;
    margin-bottom: 16px;
  }
  .hero-crest {
    width: 136px;
    height: 136px;
    margin-bottom: 20px;
  }
  .hero-title {
    font-size: clamp(1.5rem, 6.5vw, 2rem);
    line-height: 1.25;
  }
  .hero-subtitle {
    font-size: clamp(1.25rem, 5.2vw, 1.65rem);
    line-height: 1.25;
    margin-bottom: 18px;
  }
  .heraldic-divider {
    margin-block: 18px;
  }
  .hero-location {
    font-size: 12px;
    letter-spacing: 0.14em;
    line-height: 1.6;
    max-width: 290px;
    margin-inline: auto;
  }
  .hero-motto {
    font-size: 16px;
    line-height: 1.5;
    max-width: 300px;
    margin-inline: auto;
    margin-bottom: 28px;
  }

  /* Touch-friendly buttons */
  .btn-primary,
  .btn-ghost,
  .btn-outline-light {
    min-height: 44px;
    justify-content: center;
  }

  /* Single-column grids */
  .grid-2,
  .grid-3,
  .grid-4,
  .form-row-2 {
    grid-template-columns: 1fr;
  }

  /* Value cards */
  .value-card {
    padding: 24px 20px;
  }
  .value-card .card-icon {
    width: 56px;
    height: 56px;
  }

  /* Homepage events horizontal snap carousel */
  .events-carousel-mobile {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 16px;
    margin-inline: calc(var(--space-margin-mobile) * -1);
    padding: 4px var(--space-margin-mobile) 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .events-carousel-mobile::-webkit-scrollbar {
    display: none;
  }
  .events-carousel-mobile .event-card {
    flex: 0 0 82vw;
    max-width: 320px;
    scroll-snap-align: center;
  }
  .event-card .card-body p {
    min-height: 0;
  }

  /* Gallery strip */
  .gallery-strip {
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: var(--space-margin-mobile);
  }
  .gallery-strip img {
    height: 180px;
    max-width: 82vw;
    scroll-snap-align: center;
  }

  /* Quote section */
  .quote-section {
    padding-block: 48px;
  }
  .quote-icon {
    font-size: 36px;
    margin-bottom: 14px;
  }
  blockquote.heraldic-quote {
    font-size: 17px;
    line-height: 1.6;
    letter-spacing: 0.03em;
  }

  /* Inner page hero & breadcrumb */
  .page-hero {
    padding-block: 36px;
  }
  .page-hero h1 {
    font-size: clamp(1.3rem, 5.5vw, 1.75rem);
    line-height: 1.3;
  }
  .page-hero p {
    font-size: 16px;
  }
  .breadcrumb .container {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  /* Contact form (16px prevents iOS Safari auto-zoom) */
  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 16px;
    width: 100%;
  }
  .contact-form .btn-primary {
    width: 100%;
  }

  /* Activity filter tabs */
  .event-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 24px;
  }
  .event-filters::-webkit-scrollbar {
    display: none;
  }
  .event-filters .filter-btn {
    flex-shrink: 0;
    padding: 8px 16px;
  }

  /* Footer */
  .site-footer .footer-grid {
    grid-template-columns: 1fr;
    gap: 36px;
    padding-block: 48px 36px;
  }
  .footer-brand {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
  }
  .footer-brand p {
    max-width: 300px;
  }
  .footer-socials {
    justify-content: center;
  }
  .site-footer ul a {
    display: inline-block;
    padding-block: 4px;
  }
  .footer-bottom .container {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
}

/* ── Narrow Phones (<= 400px) ──────────────────────────────── */
@media (max-width: 400px) {
  .nav-brand {
    gap: 8px;
  }
  .nav-brand img {
    width: 36px;
    height: 36px;
  }
  .nav-brand-text .brand-line2 {
    font-size: 12px;
  }
  .hero-crest {
    width: 120px;
    height: 120px;
  }
}
