/* =============================================================
   responsive.css — Mobile layout system for Chatsworth
   Ownership:
   - breakpoint behavior for shared and page layouts
   - mobile/tablet-only spacing, stacking, and tap-target ergonomics
   - responsive overrides that should not live in site/components
   Breakpoints: 900px, 768px, 480px, 360px
   ============================================================= */

html, body, main { overflow-x: clip; }

/* ── 900px: Home gallery teaser — stack before tablet nav breakpoint ── */
@media (max-width: 900px) {
  .gallery-teaser {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: clamp(18px, 4vw, 22px);
    max-width: min(420px, 100%);
    margin-inline: auto;
    padding: 0 var(--side-pad) 24px;
    background: transparent;
  }
  .gallery-cell {
    aspect-ratio: 3 / 4;
    height: auto;
    min-height: 0;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(28, 25, 22, 0.08);
  }
  .gallery-cell.tall {
    aspect-ratio: 3 / 4;
    grid-row: span 1;
  }
  .gallery-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .gallery-cta-cell {
    grid-column: 1 / -1;
    min-height: 188px;
    border-radius: 18px;
    padding: 28px 22px;
  }
}

/* ── 768px: Tablet / Mobile ── */
@media (max-width: 768px) {

  :root {
    --section-pad: clamp(56px, 9vw, 84px);
    --side-pad: 18px;
    /* Deliberate vertical rhythm — not compressed desktop */
    --section-block-y: clamp(52px, 10vw, 80px);
  }

  /* iOS safe areas + fixed nav: anchor scroll lands below pill header */
  html {
    scroll-padding-top: calc(12px + env(safe-area-inset-top, 0px) + 76px);
  }

  main#main-content {
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  }

  /* Nav */
  .nav-links { display: none; }
  .nav-toggle { display: flex; min-width: 44px; min-height: 44px; }
  .drawer-logo { display: flex; }
  .nav-more { display: none; }

  nav, nav.scrolled {
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 10px; right: 10px; width: auto;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(184, 151, 90, 0.12);
    /* Nearly opaque so body copy doesn’t read through while scrolling */
    background: rgba(250, 247, 242, 0.98);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(28, 25, 22, 0.08);
  }
  .nav-logo, nav.scrolled .nav-logo {
    font-size: 0.76rem; letter-spacing: 0.14em;
    color: var(--ink); text-shadow: none;
    max-width: calc(100% - 52px);
  }
  .nav-toggle span { background: var(--ink); }

  .nav-drawer {
    padding: 88px 18px 28px;
    background: rgba(250, 247, 242, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    width: 100vw;
    min-height: 100dvh;
  }
  .nav-drawer ul { gap: 6px; }
  .nav-drawer ul a {
    padding: 13px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    font-size: clamp(1.2rem, 5vw, 1.7rem);
  }
  .drawer-cta { margin: 18px auto 0; min-height: 50px; border-radius: 999px; }

  /* Hero — type & glass: components.css mobile :root tokens */
  .hero,
  .page-hero,
  .ceremony-hero {
    align-items: flex-end;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    padding-top: 88px;
  }
  /* Home: taller immersive frame; interiors: shorter so content isn’t lost below fold */
  .hero {
    min-height: min(90svh, 820px);
  }
  body[data-page="index"] .hero {
    min-height: min(92svh, 860px);
  }
  .page-hero,
  .ceremony-hero {
    min-height: min(72svh, 620px);
  }
  .hero-scroll { display: none; }

  /* Softer global scrim — photo overlays in hero-images.css carry contrast */
  .hero::before,
  .page-hero::before,
  .ceremony-hero::before {
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.16) 0%,
      rgba(0, 0, 0, 0.04) 52%,
      rgba(0, 0, 0, 0.14) 100%
    );
  }

  /* Full-bleed photo must paint behind the glass panel (WebKit / iOS stacking + height) */
  .hero-bg,
  .page-hero-bg,
  .ceremony-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    min-height: 100%;
    height: 100%;
    pointer-events: none;
    animation: none;
    transition: none;
    will-change: auto;
  }

  /* Photo heroes: one centered editorial card — same stack as every other page */
  .hero-content,
  .page-hero-content {
    position: relative;
    z-index: 2;
    width: var(--hero-content-max);
    max-width: var(--hero-content-max);
    margin-inline: auto;
    margin-bottom: 0;
    padding: var(--hero-panel-pad-y) var(--hero-panel-pad-x)
      calc(var(--hero-panel-pad-y) + 1px);
    border-radius: var(--hero-panel-r);
    align-items: center;
    text-align: center;
    gap: var(--hero-stack-gap);
    background: var(--glass-hero-bg-mobile);
    border: 1px solid var(--glass-hero-border-mobile);
    backdrop-filter: blur(var(--glass-hero-blur-mobile)) saturate(96%);
    -webkit-backdrop-filter: blur(var(--glass-hero-blur-mobile)) saturate(96%);
    box-shadow: var(--glass-hero-shadow-mobile);
  }

  .hero-eyebrow,
  .page-eyebrow {
    letter-spacing: var(--hero-eyebrow-tracking);
    color: rgba(255, 255, 255, 0.78);
    text-align: center;
    align-self: center;
  }
  .hero-title,
  .page-title {
    letter-spacing: var(--hero-title-track);
    max-width: var(--hero-title-max);
    margin: 0;
    text-align: center;
    align-self: center;
  }
  .hero-script,
  .page-script {
    max-width: min(var(--hero-script-max), 100%);
    margin: 0;
    text-align: center;
    align-self: center;
  }
  .hero-subtitle,
  .hero-sub {
    max-width: min(var(--hero-sub-max), 100%);
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.82);
    margin: 0;
    text-align: center;
    align-self: center;
  }
  .hero-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--hero-actions-gap);
    margin-top: 0;
    width: 100%;
    align-self: stretch;
  }

  .cta-band-actions,
  .cta-band-btns {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--hero-actions-gap);
    margin-top: var(--hero-actions-mt);
    width: 100%;
    justify-items: stretch;
  }

  .mh-mid-bleed-bg {
    animation: none;
    transition: none;
    will-change: auto;
  }

  /* Buttons */
  .btn-primary, .btn-outline, .btn-ghost, .form-submit {
    width: 100%; min-height: 50px; justify-content: center;
  }

  /* Layouts */
  .story, .venue-teaser, .hosts-section, .split, .philosophy {
    grid-template-columns: 1fr;
    gap: clamp(22px, 5vw, 30px);
    min-height: auto;
    padding-left: var(--side-pad); padding-right: var(--side-pad); padding-top: 0; padding-bottom: 0;
  }
  .space-card, .space-card.reverse {
    grid-template-columns: 1fr; direction: ltr; min-height: auto;
  }

  .story-content, .venue-content, .split-content {
    padding: clamp(30px, 5vw, 36px) clamp(22px, 5vw, 26px);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(247,242,235,0.94));
    border: 1px solid rgba(184, 151, 90, 0.1);
    box-shadow: 0 12px 32px rgba(28, 25, 22, 0.06);
  }

  .story-image, .venue-image, .split-img {
    aspect-ratio: 4 / 3; min-height: 240px; height: auto;
    border-radius: 18px; overflow: hidden;
    box-shadow: 0 14px 36px rgba(28, 25, 22, 0.08);
  }
  .hero-left {
    aspect-ratio: 3 / 4; min-height: 280px; height: auto;
    border-radius: 18px; overflow: hidden;
    box-shadow: 0 14px 36px rgba(28, 25, 22, 0.08);
  }
  /* Homepage story (doorway): anchor near top of frame so floor/doorway below bride crops out */
  body[data-page="index"] .story-image {
    aspect-ratio: 4 / 3;
    min-height: min(60vw, 320px);
  }
  .story-image img, .venue-image img, .split-img img, .hero-left img {
    width: 100%; height: 100%; object-fit: cover; display: block; transition: none;
  }
  /* Doorway story: pin to top of frame — trim floor gap under subject */
  body[data-page="index"] .story-image img { object-position: center 18%; }
  body[data-page="index"] .story-stat-row-mobile {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    padding: 18px 22px 22px;
    margin-top: 0;
    border-radius: 0 0 18px 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.74), rgba(247,242,235,0.95));
    border: 1px solid rgba(184, 151, 90, 0.1);
    border-top: 0;
    box-shadow: 0 12px 32px rgba(28, 25, 22, 0.06);
  }
  body[data-page="index"] .story-stat-row-desktop { display: none; }
  body[data-page="index"] .venue-image img { object-position: center 46%; }
  body[data-page="marguerite-house"] .split-img img { object-position: center 30%; }

  /* Marguerite intro: was 2 narrow columns on phone — stack so history photo is full width */
  .intro-block {
    grid-template-columns: 1fr;
    gap: clamp(32px, 6vw, 40px);
  }
  body[data-page="marguerite-house"] .intro-image {
    display: block;
    max-width: 100%;
  }
  body[data-page="marguerite-house"] .intro-image img {
    width: 100%;
    height: auto;
    flex: none;
    aspect-ratio: 4 / 3;
    min-height: min(58vw, 420px);
    object-fit: cover;
    object-position: center 52%;
  }
  body[data-page="marguerite-house"] .intro-image-badge {
    left: 14px;
    bottom: -6px;
  }

  .space-image {
    height: 58vw; min-height: 240px; border-radius: 18px; overflow: hidden;
    box-shadow: 0 14px 36px rgba(28, 25, 22, 0.08);
  }
  /* Ceremony spaces on phones: match source ratio (4:5) so subjects stop over-cropping */
  body[data-page="ceremony-spaces"] .space-image {
    height: auto;
    aspect-ratio: 4 / 5;
    min-height: 240px;
    max-height: none;
  }
  .space-image img { object-position: center 38%; }
  body[data-page="ceremony-spaces"] .space-image img {
    object-position: center 36%;
  }
  .pkg-card-img img { object-position: center 40%; }
  .micro-card img, .gallery-item img { object-position: center 40%; }

  /* Gallery page */
  .gallery-grid { columns: 2; column-gap: 14px; padding-left: var(--side-pad); padding-right: var(--side-pad); }
  .gallery-item { border-radius: 16px; overflow: hidden; }
  .gallery-item img { transition: none; }
  .gallery-item-overlay {
    background: linear-gradient(to top, rgba(28, 25, 22, 0.56), rgba(28, 25, 22, 0.08) 52%);
    justify-content: flex-end;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 14px 12px;
  }
  .gallery-item-label,
  .gallery-item-cat {
    opacity: 1;
    transform: none;
  }
  .gallery-item-label { font-size: 0.9rem; }
  .gallery-item-cat { font-size: 0.5rem; letter-spacing: 0.16em; color: rgba(255,255,255,0.82); }

  /* Filter bar — horizontal scroll */
  .filter-bar {
    display: flex; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; gap: 10px;
    padding: 22px var(--side-pad) 18px; justify-content: flex-start;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-btn {
    flex-shrink: 0; white-space: nowrap; border-radius: 999px;
    padding: 10px 20px; min-height: 44px;
  }

  /* Feature quote */
  .feature-quote {
    margin-left: var(--side-pad); margin-right: var(--side-pad);
    border-radius: 18px; padding: clamp(38px, 6vw, 44px) clamp(24px, 5vw, 28px);
  }
  .feature-quote-mark { font-size: 2.8rem; margin-bottom: 10px; }

  /* Statement */
  .statement { padding: clamp(52px, 8vw, 64px) clamp(22px, 5vw, 28px); }
  .statement-text { font-size: clamp(1.5rem, 6.5vw, 2.2rem); line-height: 1.22; }

  /* Testimonials */
  .testimonials { padding-left: var(--side-pad); padding-right: var(--side-pad); }
  .testimonials-grid { grid-template-columns: 1fr; }
  .testimonial-card { padding: clamp(26px, 4vw, 30px) clamp(22px, 4vw, 26px); border-radius: 18px; }
  .testimonial-author {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Packages */
  .packages-grid { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; gap: 20px; }
  .pkg-card { border-radius: 18px; }
  .pkg-card.featured { order: -1; transform: none; }
  .pkg-card-img { height: 196px; }

  /* CTA band */
  .cta-band-title, .cta-title {
    font-size: clamp(1.9rem, 8vw, 2.8rem); line-height: 1.08;
  }
  .cta-band-script, .cta-script { font-size: clamp(1.1rem, 4.5vw, 1.5rem); }

  /* Contact page — image → form: soft blend, lighter “sheet” (not a heavy card) */
  body[data-page="contact"] .contact-hero {
    display: block; padding: 88px var(--side-pad) 32px; min-height: 0;
  }
  body[data-page="contact"] .hero-left {
    aspect-ratio: 4 / 5; min-height: 0; height: auto;
    border-radius: 22px; overflow: hidden;
    box-shadow: 0 12px 36px rgba(28, 25, 22, 0.08);
  }
  body[data-page="contact"] .hero-left-overlay {
    background: linear-gradient(
      to bottom,
      rgba(28, 25, 22, 0.05) 0%,
      transparent 35%,
      rgba(250, 247, 242, 0.5) 82%,
      rgba(250, 247, 242, 0.92) 100%
    );
  }
  body[data-page="contact"] .hero-left img {
    height: 100%; object-fit: cover; object-position: 48% 38%;
  }
  body[data-page="contact"] .hero-right {
    margin-top: -22px; padding: 0 2px; position: relative; z-index: 2;
  }
  body[data-page="contact"] .hero-right-inner {
    width: 100%; max-width: none; margin: 0;
    padding: clamp(32px, 6vw, 40px) clamp(22px, 5vw, 28px) clamp(30px, 5vw, 36px);
    border-radius: 20px;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.82) 0%,
      rgba(250, 247, 242, 0.96) 100%
    );
    border: 1px solid rgba(184, 151, 90, 0.09);
    box-shadow: 0 8px 28px rgba(28, 25, 22, 0.05);
  }
  body[data-page="contact"] .page-title {
    color: var(--ink); text-shadow: none;
    font-size: clamp(2.2rem, 10vw, 3.2rem); max-width: 9ch;
  }
  body[data-page="contact"] .contact-intro {
    max-width: 34ch; font-size: 0.84rem;
    letter-spacing: 0.02em; text-transform: none; color: var(--ink-mid);
  }

  /* Form — 16px font-size kills iOS zoom */
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .form-field.full { grid-column: span 1; }
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    min-height: 50px; padding: 13px 14px;
    border-radius: 12px; background: rgba(255,255,255,0.85);
  }
  .form-textarea { min-height: 120px; }
  .form-submit { border-radius: 999px; min-height: 52px; }

  /* Footer — extra bottom space so text clears iOS Safari toolbar when scrolled */
  footer {
    padding-left: var(--side-pad); padding-right: var(--side-pad);
    padding-top: clamp(48px, 10vw, 72px);
    padding-bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  }
  .footer-top { grid-template-columns: 1fr; gap: clamp(32px, 8vw, 44px); }
  .footer-links { display: grid; grid-template-columns: 1fr; gap: 8px 14px; }
  .footer-links a { font-size: 0.82rem; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Closing CTA — thinner inner frame on small screens so the photograph reads larger */
  .cta-band::before,
  .gallery-cta-band::before {
    margin: clamp(18px, 4.5vw, 28px);
  }

  /* Interior sections */
  .inner-section, .inner-section-alt, .statement, .testimonials {
    padding-left: var(--side-pad); padding-right: var(--side-pad);
  }
  .spaces-intro,
  .space-card,
  .inner-section,
  .inner-section-alt {
    scroll-margin-top: calc(8px + env(safe-area-inset-top, 0px) + 68px);
  }
  .space-content { padding: clamp(34px, 5vw, 40px) clamp(22px, 5vw, 28px); }
  .inclusions-grid { grid-template-columns: 1fr; }
  .lodging-two-col { grid-template-columns: 1fr; }
  .lodging-img-wrap { min-height: 56vw; max-height: 340px; }
  .contact-info-inner { grid-template-columns: 1fr; gap: 24px; }
  .micro-grid { grid-template-columns: 1fr; max-width: 480px; margin: 0 auto; }
  .packages,
  .micro-packages,
  .availability-section,
  .inclusions,
  .timeline {
    padding-left: var(--side-pad);
    padding-right: var(--side-pad);
  }
  .micro-section { grid-template-columns: 1fr; }
  .area-hero-strip { grid-template-columns: 1fr 1fr; }
  .area-hero-strip .area-stat {
    padding: clamp(26px, 5vw, 34px) clamp(14px, 3.5vw, 22px);
  }
  .hotel-grid { grid-template-columns: 1fr; }
  .restaurant-grid { grid-template-columns: 1fr; }
  .things-grid { grid-template-columns: 1fr; gap: 18px; }
  .getting-here-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr; gap: 18px; }

  /* Kill hover transitions on touch */
  .gallery-cell img, .story-image img, .venue-image img,
  .split-img img, .hero-left img, .gallery-item img { transition: none; }
  .reveal { transition: opacity 0.36s ease, transform 0.36s ease; }
}

/* ── 769–1024px: Tablet — section image crops between desktop & phone ── */
@media (min-width: 769px) and (max-width: 1024px) {
  body[data-page="index"] .story-image img {
    object-position: center 12%;
  }
  body[data-page="index"] .venue-image img {
    object-position: center 44%;
  }
  .space-image img {
    object-position: center 36%;
  }
  body[data-page="ceremony-spaces"] .space-image img {
    object-position: center 32%;
  }
  .pkg-card-img img {
    object-position: center 36%;
  }
  body[data-page="marguerite-house"] .split-img img {
    object-position: center 35%;
  }
  body[data-page="marguerite-house"] .intro-image img {
    object-position: center 40%;
  }
  body[data-page="gallery"] .gallery-item img {
    object-position: center 44%;
  }
}

/* ── 480px: Small phones ── */
@media (max-width: 480px) {

  nav, nav.scrolled {
    left: 8px; right: 8px;
    top: max(8px, env(safe-area-inset-top, 0px));
    padding: 10px 12px; border-radius: 16px;
  }
  .hero,
  .page-hero,
  .ceremony-hero {
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
    padding-top: 80px;
  }
  .page-hero,
  .ceremony-hero {
    min-height: min(74svh, 640px);
  }
  /* Narrow phones: tokens handle type; slight touch padding only */
  .hero-content,
  .page-hero-content {
    margin-inline: auto;
  }

  :root {
    --side-pad: 16px;
  }
  .story, .venue-teaser, .split, .philosophy,
  .inner-section, .inner-section-alt,
  .statement, .testimonials, footer {
    padding-left: var(--side-pad); padding-right: var(--side-pad);
  }
  .gallery-teaser {
    padding-left: var(--side-pad); padding-right: var(--side-pad);
    padding-bottom: 22px;
  }
  .story-content, .venue-content, .split-content { padding: 26px 18px; }
  .gallery-cell, .gallery-cell.tall { aspect-ratio: 4 / 5; }
  .gallery-grid { columns: 1; }
  .space-image img,
  .pkg-card-img img { object-position: center 34%; }
  body[data-page="ceremony-spaces"] .space-image img { object-position: center 36%; }

  body[data-page="contact"] .contact-hero { padding: 80px var(--side-pad) 28px; }
  body[data-page="contact"] .hero-right { padding: 0 1px; }

  .steps-grid { grid-template-columns: 1fr; }
  .contact-info-inner { grid-template-columns: 1fr; gap: 20px; }
  .footer-links { grid-template-columns: 1fr; }

  .section-title { font-size: clamp(1.65rem, 8vw, 2.4rem); }
  .statement-text { font-size: clamp(1.4rem, 7vw, 2rem); line-height: 1.25; }
  .feature-quote-text { font-size: clamp(1rem, 4.5vw, 1.4rem); }
  .cta-band-title, .cta-title { font-size: clamp(1.8rem, 9vw, 2.5rem); }

  .pkg-card-img, .pkg-card.featured .pkg-card-img { height: 176px; }
  .pkg-body { padding: 24px 20px; }
  .things-grid { grid-template-columns: 1fr; }
  .lodging-content-l, .lodging-content-r { padding: 30px 20px; }
}

/* ── 360px: Tiny phones ── */
@media (max-width: 360px) {
  .section-title { font-size: 1.55rem; }
  nav, nav.scrolled { padding: 10px; }
  .nav-logo { font-size: 0.7rem; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms; animation-iteration-count: 1; transition-duration: 0.01ms;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-eyebrow, .hero-title, .hero-script, .hero-subtitle,
  .hero-actions, .page-eyebrow, .page-title, .page-script {
    animation: none; opacity: 1; transform: none;
  }
  body { background-attachment: scroll; }
}
