/* ════════════════════════════════════════════════════════════════════════
 * BUNYAN — POLISH LAYER
 *
 * Mobile-fit, scroll progress bar, section ornaments, cinematic reveals.
 * Pure CSS — zero added JS. Total weight ~6 KB.
 *
 * Performance budget:
 *   - Only `opacity`, `transform`, `scale-x` are animated (compositor-only).
 *   - Scroll progress uses scroll-driven animations where supported,
 *     otherwise a fixed bar that doesn't update (graceful degradation).
 *   - Hamburger menu is `details/summary` (zero JS, native).
 *   - All section ornaments are SVG paths in CSS data-URI (no extra requests).
 * ════════════════════════════════════════════════════════════════════════ */


/* ── 0. SCROLLBAR & VIEWPORT GUARD ───────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100vw; overflow-x: hidden; }   /* kill any horizontal overflow */
img, svg, video { max-width: 100%; height: auto; }


/* ── 1. SCROLL PROGRESS BAR (CSS-only, scroll-driven) ────────────────── */
.bn-scrollbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 1100;
  pointer-events: none;
}
.bn-scrollbar::after {
  content: '';
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c9a45a, #4d3c20 50%, #c9a45a);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
/* Modern browsers — scroll-driven animation (zero JS) */
@supports (animation-timeline: scroll()) {
  .bn-scrollbar::after {
    animation: bn-scrollbar-grow linear;
    animation-timeline: scroll(root);
  }
  @keyframes bn-scrollbar-grow { to { transform: scaleX(1); } }
}
/* RTL: flip origin */
html[dir="rtl"] .bn-scrollbar::after { transform-origin: 100% 50%; }


/* ── 2. MOBILE NAV — HAMBURGER (zero-JS via <details>) ──────────────── */
/* The legacy markup is preserved; we only show a hamburger summary on mobile
 * and reformat the link list as a dropdown panel. */

.bn-burger {
  display: none;                       /* desktop hidden */
  background: transparent;
  border: 1px solid var(--color-border, #e8dec0);
  border-radius: 10px;
  width: 40px; height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin-inline-start: auto;
  position: relative;
  z-index: 105;
}
.bn-burger svg { width: 22px; height: 22px; color: var(--bn-stone-700, #3a2d18); }

/* Mobile (<= 820px): collapse legacy nav into a hamburger panel */
@media (max-width: 820px) {
  /* Show the burger we'll inject in HTML */
  .bn-burger { display: inline-flex; }

  /* Compact nav row: brand right, burger left (RTL) — hide the rest */
  .nav-inner {
    flex-wrap: nowrap !important;
    gap: var(--space-2, 8px) !important;
    padding: 10px 14px !important;
  }
  /* Hide all middle controls EXCEPT brand + the burger + signed-in avatar.
   * The avatar stays visible so users can access account without opening menu. */
  .nav-inner > :not(.brand):not(.bunyan-lockup):not(.bn-burger):not(.bn-mobile-panel):not(.nav-avatar-wrap) {
    display: none !important;
  }
  /* Compact the avatar a bit on mobile */
  .nav-inner > .nav-avatar-wrap { margin-inline-end: 8px !important; }
  .nav-inner > .nav-avatar-wrap .nav-avatar { width: 34px !important; height: 34px !important; }
  /* The mobile panel: drawer that slides down when burger is open */
  .bn-mobile-panel {
    position: fixed;
    top: 0; right: 0; left: 0;
    transform: translateY(-100%);
    transition: transform .32s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--color-surface-raised, #fff);
    box-shadow: 0 18px 40px rgba(36, 26, 14, .22);
    z-index: 100;
    padding: 80px 24px 28px;
    max-height: 100vh;
    overflow-y: auto;
    display: flex !important;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid var(--color-divider, #f0e8d2);
  }
  .bn-mobile-panel.open { transform: translateY(0); }
  .bn-mobile-panel a,
  .bn-mobile-panel button {
    display: block;
    width: 100%;
    text-align: right;
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-divider, #f0e8d2);
    font: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--bn-ink-strong, #180f06);
    text-decoration: none;
    border-radius: 8px;
    transition: background .15s ease;
  }
  .bn-mobile-panel a:active,
  .bn-mobile-panel button:active { background: var(--bn-sand-100, #faf3e0); }
  .bn-mobile-panel .bn-mobile-cta {
    background: linear-gradient(135deg, #3a2d18, #4d3c20) !important;
    color: #fff !important;
    margin-top: 16px;
    text-align: center;
    border: none;
    border-radius: 999px;
    padding: 14px 24px;
    font-weight: 700;
  }

  /* Backdrop when the panel is open */
  .bn-mobile-backdrop {
    position: fixed; inset: 0;
    background: rgba(36, 26, 14, .55);
    opacity: 0; pointer-events: none;
    transition: opacity .28s ease;
    z-index: 99;
  }
  .bn-mobile-backdrop.open { opacity: 1; pointer-events: auto; }
}


/* ── 3. SECTION ORNAMENTS — refined dividers between sections ─────────── */
/* A subtle "diamond + line" divider that breathes between content blocks.
 * Drawn with pseudo-elements so it adds 0 DOM nodes. */
.section + .section::before,
.how + section::before,
section.section-ornament::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bn-stone-300, #c9b274) 50%, transparent);
  margin: 0 auto;
  width: min(80%, 800px);
  opacity: .35;
}

/* Diamond ornament: a tiny rotated square nested between sections */
.bn-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: clamp(2rem, 4vw, 3.5rem) auto;
  gap: 14px;
  opacity: .65;
}
.bn-divider::before,
.bn-divider::after {
  content: '';
  flex: 1; max-width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bn-gold-400, #c9a45a));
}
.bn-divider::after { background: linear-gradient(90deg, var(--bn-gold-400, #c9a45a), transparent); }
.bn-divider span {
  width: 8px; height: 8px;
  background: var(--bn-gold-400, #c9a45a);
  transform: rotate(45deg);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(201, 164, 90, .15);
}


/* ── 4. CINEMATIC SECTION REVEALS — upgraded ─────────────────────────── */
/* Make the existing .bn-reveal slightly more cinematic: a touch of scale
 * + a longer ease curve. Mobile gets a shorter, simpler version. */
.bn-reveal {
  /* override motion.css base: a hint of scale for an "approaching" feel */
  transform: translateY(36px) scale(0.985);
}
.bn-reveal.bn-in { transform: translateY(0) scale(1); }

@media (max-width: 720px) {
  .bn-reveal { transform: translateY(20px); }    /* drop the scale for mobile */
  .bn-reveal.bn-in { transform: translateY(0); }
}


/* ── 5. MOBILE TYPOGRAPHY POLISH ──────────────────────────────────────── */
@media (max-width: 720px) {
  .hero-elevated .hero-content { padding-inline: 18px !important; }
  .hero-elevated h1 {
    font-size: clamp(2.4rem, 9vw, 3.6rem) !important;
    line-height: .96 !important;
  }
  .hero-elevated .hero-tagline { font-size: 1.05rem !important; }
  .hero-elevated .hero-lead    { font-size: .95rem !important; line-height: 1.7 !important; }
  .hero-elevated .cta-row      { flex-direction: column; align-items: stretch; }
  .hero-elevated .btn-primary,
  .hero-elevated .btn-demo-hero { width: 100%; padding: 14px 22px !important; }
  .hero-elevated .stats { grid-template-columns: 1fr 1fr !important; gap: 1rem !important; }
  .hero-elevated .stat strong { font-size: 1.6rem !important; }
  .hero-elevated .scroll-hint { display: none !important; }

  /* Tighten section containers */
  .container { padding-inline: 16px !important; }
  .section-head { margin-bottom: 1.8rem !important; }
  .section-head h2 { font-size: clamp(1.6rem, 6.5vw, 2.4rem) !important; line-height: 1.15 !important; }

  /* Step grid: one column with breathing room */
  .steps-grid { grid-template-columns: 1fr !important; gap: 1rem !important; }

  /* Avatar menu: full-width drop */
  .nav-avatar-menu {
    position: fixed !important;
    top: 64px; left: 14px; right: 14px;
    width: auto !important;
    max-width: none !important;
  }
}


/* ── 6. PERFORMANCE GUARDRAILS ───────────────────────────────────────── */
/* Below-the-fold images use lazy-loading + native decoding */
img[loading="lazy"] { content-visibility: auto; }

/* Skip rendering work on far-below-fold sections (desktop only — we already
 * disabled this on mobile to avoid clipping fixed-position descendants). */
@media (min-width: 900px) {
  footer.footer { content-visibility: auto; contain-intrinsic-size: 1px 500px; }
}

/* Reduce expensive blurs on low-DPR small screens */
@media (max-width: 720px) and (max-resolution: 1.5dppx) {
  *, *::before, *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}


/* ── 7. REDUCED-MOTION (absolute respect) ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .bn-reveal, .bn-reveal.bn-in {
    transform: none !important; opacity: 1 !important; transition: none !important;
  }
  .bn-scrollbar::after,
  .bn-mobile-panel, .bn-mobile-backdrop {
    animation: none !important; transition: none !important;
  }
}


/* ─────────────────────────────────────────────────────────────────────
 * Sprint 5 — Land-first journey polish
 * Section heading, optional-intake link button, photo <details> styling
 * to keep the simplified Pane 1 visually consistent with the rest of the
 * journey (and the site's gold/blue/sand palette).
 * ───────────────────────────────────────────────────────────────────── */
.dj-section-title {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: #1a3556;
  margin: 1.4rem 0 .6rem;
  padding-right: .55rem;
  border-right: 3px solid #c9a45a;
}

.btn-link {
  background: none;
  border: none;
  color: #1a3556;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: .35rem .55rem;
  font: inherit;
  cursor: pointer;
  opacity: .8;
  transition: opacity .15s ease;
}
.btn-link:hover { opacity: 1; }

/* Optional photo upload — collapses by default to keep the Land pane lean. */
.dj-land-photo[open] summary { margin-bottom: .8rem; }
.dj-land-photo > summary {
  cursor: pointer;
  padding: .8rem 1rem;
  border: 1px dashed #c9a45a;
  border-radius: 12px;
  background: #fdf8ee;
  color: #1a3556;
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem;
}
.dj-land-photo > summary::-webkit-details-marker { display: none; }
.dj-land-photo > summary:hover { background: #fbf3e1; }
.dj-land-photo > summary::after {
  content: '▾';
  color: #c9a45a;
  font-size: 1rem;
  transition: transform .2s ease;
}
.dj-land-photo[open] > summary::after { transform: rotate(180deg); }
