/* ==========================================================================
   BUILT FROM THE INSIDE OUT - RESPONSIVE STYLESHEET
   Mobile-first & Desktop-first Breakpoint Adaptations
   ========================================================================== */

/* --- Global Overflow Containment (prevents horizontal gap on all screens) --- */
*,
*::before,
*::after {
    max-width: 100%;
}

/* Exclude elements that legitimately need to overflow (marquee tracks, absolute positions) */
.announcement-track,
.marquee-track-inner,
.floating-blueprint-card,
.bp-marker,
.divine-backlight,
.compass-dial-ring,
.compass-dial-inner {
    max-width: none;
}

/* Ensure all top-level sections clip their content
   (note: 100% not 100vw — 100vw includes the scrollbar width,
   which pushed the header's right edge off-screen and clipped the hamburger) */
section,
header,
footer,
.site-header,
.top-announcement-bar,
.section-author,
.section-about-book,
.section-blueprint-pillars,
.section-fruits-anatomy,
.section-endorsements,
.section-final-cta,
.quote-callout-banner {
    max-width: 100%;
    overflow-x: hidden;
}


/* --- Large Desktops (max-width: 1400px) --- */
@media (max-width: 1400px) {
    :root {
        --container-wide: 1200px;
    }

    .hero-grid {
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }

    /* Keep footer headings on one line at narrower desktop widths */
    .footer-heading {
        font-size: 0.95rem;
    }

    .anatomy-interactive-wrapper {
        gap: 40px;
    }
}

/* --- Laptops & Small Desktops (max-width: 1200px) --- */
@media (max-width: 1200px) {
    .pillars-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }

    .anatomy-interactive-wrapper {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .anatomy-dial-stage {
        margin: 0 auto;
    }

    .footer-main-grid {
        grid-template-columns: 1fr 1fr;
        gap: 40px;
    }

    .desktop-nav .nav-links {
        gap: 12px;
    }

    .nav-link {
        font-size: 0.78rem;
        padding: 8px 0;
    }

    .brand-title {
        font-size: 0.95rem;
    }

    .brand-subtitle {
        font-size: 0.55rem;
    }

    #headerGetBookBtn {
        padding: 9px 14px;
        font-size: 0.85rem;
    }
}

/* --- Tablets & Horizontal Mobile (max-width: 1024px) --- */
@media (max-width: 1024px) {
    .desktop-nav {
        display: none;
    }

    .mobile-toggle {
        display: flex;
        flex-shrink: 0;
    }

    /* Header: keep logo but shrink brand text */
    .brand-title {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }

    .brand-subtitle {
        font-size: 0.58rem;
    }

    .hero-section {
        padding: 50px 0 70px;
        min-height: auto;
    }

    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 50px;
    }

    .hero-content {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-quote-tagline {
        border-left: none;
        padding-left: 0;
        border-bottom: 2px solid var(--gold-primary);
        padding-bottom: 12px;
        display: inline-block;
    }

    .hero-cta-group {
        justify-content: center;
    }

    .hero-specs-row {
        justify-content: center;
    }

    .hero-visual-col {
        order: -1;
        margin-bottom: 10px;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .about-visual-side {
        max-width: 500px;
        margin: 0 auto;
    }

    /* Author section - collapse to single column */
    .author-card-plate {
        padding: 40px 30px;
        max-width: 100%;
    }

    .author-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    /* Allow grid columns to shrink below intrinsic content width */
    .author-grid > * {
        min-width: 0;
    }

    .author-image-column {
        max-width: 460px;
        margin: 0 auto;
        width: 100%;
    }

    .author-content-column {
        text-align: left;
    }

    .editions-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .bp-marker {
        display: none; /* Hide edge technical coordinates on tablets/phones to avoid clutter */
    }

    .card-quote {
        left: 0;
        top: 0;
    }

    .card-specs {
        right: 0;
        bottom: 0;
    }
}

/* --- Mobile Devices (max-width: 768px) --- */
@media (max-width: 768px) {
    :root {
        --header-height: 68px;
    }

    /* =========================================================
       HEADER RESPONSIVE FIXES
       ========================================================= */
    .header-container {
        padding: 0 16px;
        gap: 8px;
    }

    /* Make brand logo area constrained */
    .brand-logo {
        gap: 10px;
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .brand-logo-img {
        height: 40px;
        flex-shrink: 0;
    }

    .brand-text {
        min-width: 0;
    }

    .brand-title {
        font-size: 0.95rem;
        letter-spacing: 0.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .brand-subtitle {
        font-size: 0.55rem;
        letter-spacing: 1px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-actions {
        gap: 10px;
        flex-shrink: 0;
    }

    /* Hide the GET A BOOK button label text on small screens, keep icon */
    .btn-label-desktop {
        display: none;
    }

    #headerGetBookBtn {
        padding: 10px 14px;
        font-size: 1rem;
        gap: 0;
    }

    /* =========================================================
       HERO SECTION
       ========================================================= */
    .hero-section {
        padding: 40px 0 60px;
    }

    .hero-book-img {
        max-width: 300px;
    }

    .book-3d-stage {
        max-width: 320px;
    }

    .divine-backlight {
        width: 300px;
        height: 300px;
    }

    .compass-dial-ring {
        width: 310px;
        height: 310px;
    }

    .compass-dial-inner {
        width: 250px;
        height: 250px;
    }

    .floating-blueprint-card {
        display: none; /* Hide floating overlay badges in mobile hero */
    }

    .hero-specs-row {
        gap: 14px;
    }

    .metric-num {
        font-size: 1.5rem;
    }

    .metric-lbl {
        font-size: 0.68rem;
    }

    .banner-quote-text {
        font-size: 1.6rem;
    }

    /* =========================================================
       PILLARS / CARDS
       ========================================================= */
    .pillars-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .core-actions-grid {
        grid-template-columns: 1fr;
    }

    /* =========================================================
       ANATOMY DIAL ON MOBILE
       ========================================================= */
    .anatomy-dial-stage {
        max-width: 340px;
        height: 340px;
    }

    .center-heart-core {
        width: 100px;
        height: 100px;
    }

    .heart-title {
        font-size: 1.05rem;
    }

    .heart-cross-glyph {
        font-size: 1.2rem;
    }

    .heart-subtitle {
        font-size: 0.5rem;
    }

    .fruit-node-badge {
        padding: 4px 10px;
    }

    .fruit-node-badge .node-name {
        font-size: 0.72rem;
    }

    .fruit-node-badge .node-dot {
        width: 4px;
        height: 4px;
    }

    /* Dial Positions adjusted for 340px */
    .node-pos-0 { top: 15px; }
    .node-pos-1 { top: 50px; right: 10px; }
    .node-pos-2 { top: 130px; right: 0; }
    .node-pos-3 { bottom: 90px; right: 15px; }
    .node-pos-4 { bottom: 15px; right: 60px; }
    .node-pos-5 { bottom: 15px; left: 60px; }
    .node-pos-6 { bottom: 90px; left: 15px; }
    .node-pos-7 { top: 130px; left: 0; }
    .node-pos-8 { top: 50px; left: 10px; }

    .anatomy-inspector-card {
        padding: 24px;
    }

    .inspector-title {
        font-size: 1.9rem;
    }

    /* =========================================================
       3D COVER FLIPPER
       ========================================================= */
    .interactive-cover-stage, .cover-flipper {
        min-height: 520px;
    }

    /* =========================================================
       ENDORSEMENT CARDS
       ========================================================= */
    .endorsement-card {
        width: 320px;
        min-width: 320px;
        padding: 22px;
    }

    .endorsement-quote {
        font-size: 1.05rem;
    }

    /* =========================================================
       ABOUT THE AUTHOR SECTION - RESPONSIVE FIX
       ========================================================= */
    .section-author {
        padding: 80px 0;
    }

    .author-card-plate {
        padding: 30px 20px;
        border-radius: 16px;
    }

    .author-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .author-grid > * {
        min-width: 0;
    }

    .author-image-column {
        max-width: 100%;
        width: 100%;
    }

    .author-content-column {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Ministry pillars row must wrap instead of forcing column wider than screen */
    .author-ministry-pillars {
        flex-wrap: wrap;
        gap: 10px 16px;
        font-size: 1rem;
        letter-spacing: 1.5px;
    }

    .author-photo-frame {
        max-width: 380px;
        margin: 0 auto;
    }

    .author-heading {
        font-size: clamp(2.4rem, 8vw, 3.5rem);
        letter-spacing: 2px;
    }

    .author-card-plate {
        padding: 30px 18px;
    }

    .signature-plate {
        padding: 4px 10px;
    }

    .author-sig-img {
        height: 36px;
    }

    .author-conviction-quote {
        padding: 14px 18px;
    }

    .author-cta-row {
        flex-direction: column;
        gap: 14px;
    }

    .author-cta-row .btn {
        width: 100%;
        justify-content: center;
    }

    .ministry-pillars-row {
        flex-direction: column;
        gap: 12px;
    }

    /* =========================================================
       CTA / FOOTER
       ========================================================= */
    .final-cta-box {
        padding: 40px 20px;
    }

    .footer-main-grid {
        grid-template-columns: 1fr;
        gap: 35px;
    }

    /* =========================================================
       MODAL
       ========================================================= */
    .modal-dialog-card {
        padding: 28px 20px;
    }

    .format-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

    .format-item-preview {
        flex-direction: column;
        text-align: center;
    }

    .retailer-grid {
        grid-template-columns: 1fr;
    }

    .sampler-form {
        flex-direction: column;
    }
}

/* --- Small Mobile Phones (max-width: 480px) --- */
@media (max-width: 480px) {
    :root {
        --header-height: 62px;
    }

    /* On very small screens, hide brand text and only show logo image */
    .brand-text {
        display: none;
    }

    .brand-logo {
        gap: 0;
    }

    .brand-logo-img {
        height: 38px;
    }

    /* =========================================================
       HERO
       ========================================================= */
    .title-word-built, .title-word-inside {
        font-size: 3.2rem;
        letter-spacing: 2px;
    }

    .title-word-inside {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .title-word-sub {
        font-size: 1.05rem;
        letter-spacing: 6px;
    }

    .title-word-sub .sub-rule {
        width: 20px;
    }

    .hero-author-strip {
        font-size: 1rem;
        flex-direction: column;
        gap: 4px;
    }

    .hero-author-strip .author-sep {
        display: none;
    }

    .btn {
        width: 100%;
    }

    /* Header buttons must NOT stretch to 100% — that inflated .header-actions
       and pushed the hamburger icon outside the viewport (clipped by overflow-x:hidden) */
    .header-actions .btn {
        width: auto;
    }

    .hero-cta-group {
        width: 100%;
    }

    .hero-cta-group .btn {
        width: 100%;
    }

    .about-action-row .btn {
        width: 100%;
    }

    .btn-toggle {
        width: 100%;
        justify-content: center;
        font-size: 0.95rem;
    }

    .interactive-cover-stage, .cover-flipper {
        min-height: 440px;
    }

    /* Preloader on small phones - keep title on one line */
    .preloader-content {
        padding: 0 12px;
    }

    .preloader-subtitle {
        font-size: 0.6rem;
        letter-spacing: 1.5px;
    }

    .preloader-title {
        font-size: clamp(0.95rem, 4.6vw, 1.35rem);
        letter-spacing: 1.5px;
    }

    .preloader-status {
        font-size: 0.62rem;
        letter-spacing: 1px;
    }

    /* Author section on very small phones */
    .author-card-plate {
        padding: 24px 14px;
    }
    .author-heading {
        font-size: clamp(1.9rem, 10vw, 2.4rem);
        letter-spacing: 1px;
    }

    .author-roles-tagline {
        font-size: 0.72rem;
        letter-spacing: 1px;
    }

    .author-ministry-pillars {
        font-size: 0.9rem;
        gap: 8px 12px;
    }

    .movement-sub-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .movement-details {
        text-align: center;
    }

    /* Header actions - only icon for GET A BOOK */
    #headerGetBookBtn {
        padding: 9px 12px;
        font-size: 0.95rem;
    }
}

/* --- Very Small Phones (max-width: 360px) --- */
@media (max-width: 360px) {
    .header-container {
        padding: 0 12px;
    }

    .mobile-toggle {
        width: 38px;
        height: 38px;
    }

    #headerGetBookBtn {
        padding: 8px 10px;
    }

    .author-heading {
        font-size: clamp(1.7rem, 9vw, 2rem);
    }
}
