/* ==========================================================================
   Responsive rules — desktop, laptop, tablet, mobile
   Mobile-considered, no horizontal scrolling at any width.
   ========================================================================== */

/* ---- Large laptops ---------------------------------------------------- */
@media (max-width: 1180px) {
    .chapter-grid        { grid-template-columns: repeat(3, 1fr); }
    .feature-grid        { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Tablet landscape ------------------------------------------------- */
@media (max-width: 1024px) {
    .theme-grid          { grid-template-columns: repeat(2, 1fr); }
    .stat-grid           { grid-template-columns: repeat(3, 1fr); }
    .ops-grid            { grid-template-columns: repeat(2, 1fr); }
    .edition-grid        { grid-template-columns: repeat(3, 1fr); }
    .excerpt-preview     { grid-template-columns: 1fr; }
    .prose-columns       { columns: 1; max-width: 60ch; }

    .hero-content        { grid-template-columns: 1fr 0.7fr; }
    .cover-frame         { width: clamp(200px, 30vw, 300px); }
}

/* ---- Tablet portrait / small: mobile navigation kicks in ------------- */
@media (max-width: 900px) {

    html { scroll-padding-top: 76px; }

    /* --- Mobile navigation drawer --- */
    .nav-toggle { display: flex; }

    .nav-menu {
        position: fixed;
        top: 0; right: 0;
        height: 100vh; height: 100dvh;
        width: min(82vw, 340px);
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 0.5rem;
        padding: 5rem 2.2rem 2.2rem;
        background: linear-gradient(160deg, var(--c-navy), var(--c-midnight));
        border-left: 1px solid var(--line-dark);
        box-shadow: -20px 0 50px -20px rgba(0,0,0,0.6);
        transform: translateX(100%);
        transition: transform 0.4s var(--ease);
        overflow-y: auto;
    }
    .nav-menu.is-open { transform: translateX(0); }
    .nav-menu li { width: 100%; }
    .nav-link {
        display: block;
        width: 100%;
        font-size: 1rem;
        padding: 0.9rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .nav-link::after { display: none; }

    /* Toggle -> X when open */
    body.nav-open { overflow: hidden; }
    .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
    .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Header should read as solid whenever the drawer is open */
    body.nav-open .site-header { background: rgba(9,22,37,0.98); }

    /* --- Layout stacking --- */
    .hero {
        min-height: auto;
        padding: 7rem 0 4rem;
        text-align: center;
    }
    .hero-content {
        grid-template-columns: 1fr;
        gap: 2.5rem;
    }
    .hero-cover { order: -1; }
    .hero-intro { margin-left: auto; margin-right: auto; text-align: left; }
    .hero-actions { justify-content: center; }
    .hero-byline { align-items: center; }
    .hero-scroll { display: none; }
    .cover-frame { width: clamp(200px, 52vw, 260px); }

    .two-col,
    .two-col--align     { grid-template-columns: 1fr; }
    .book-overview      { grid-template-columns: 1fr; }
    .book-overview-cover{ position: static; max-width: 380px; margin: 0 auto; }
    .author-bio         { grid-template-columns: 1fr; }
    .author-portrait-col{ position: static; max-width: 360px; margin: 0 auto; }

    .message-inner      { grid-template-columns: 1fr; text-align: center; }
    .message-portrait   { order: -1; }
    .message-body .quote-mark { text-align: center; }
    .message-sign       { align-items: center; }

    .theme-detail       { grid-template-columns: 1fr; gap: 1.2rem; }
    .theme-detail-aside { flex-direction: row; align-items: center; gap: 1.2rem; }

    /* Fixed-attachment parallax is jittery on touch — pin these to scroll */
    .section-cta-band,
    .image-band         { background-attachment: scroll; }

    .photo-mosaic       { grid-template-columns: repeat(2, 1fr); }
    .mosaic-item--wide  { grid-column: span 2; }
}

/* ---- Small tablets / large phones ------------------------------------ */
@media (max-width: 720px) {
    .chapter-grid,
    .chapter-grid--full { grid-template-columns: repeat(2, 1fr); }
    .stat-grid          { grid-template-columns: repeat(2, 1fr); }
    .role-grid          { grid-template-columns: 1fr; }
    .ops-grid           { grid-template-columns: 1fr; }
    .region-grid        { grid-template-columns: 1fr; }
    .edition-grid       { grid-template-columns: 1fr; max-width: 420px; margin: 0 auto; }
    .feature-grid       { grid-template-columns: 1fr; }
    .theme-grid         { grid-template-columns: 1fr; }

    .footer-inner       { grid-template-columns: 1fr; gap: 2rem; }
    .footer-base        { flex-direction: column; text-align: center; }

    .photo-mosaic       { grid-auto-rows: clamp(140px, 32vw, 200px); }
    .mosaic-item--tall  { grid-row: span 1; }
}

/* ---- Phones ----------------------------------------------------------- */
@media (max-width: 480px) {
    :root { --space-section: 3.75rem; }

    .brand-title        { font-size: 0.7rem; }
    .brand-author       { font-size: 0.78rem; }
    .brand-cover        { width: 32px; height: 48px; }

    .chapter-grid,
    .chapter-grid--full { grid-template-columns: 1fr; }
    .stat-grid          { grid-template-columns: 1fr; }

    .hero-title-main    { font-size: clamp(2.6rem, 15vw, 3.4rem); }
    .btn                { width: 100%; }
    .hero-actions .btn  { width: 100%; }
    .cta-actions .btn   { width: 100%; }

    .prose-columns      { column-gap: 0; }
    .message-item       { grid-template-columns: 1fr; gap: 0.5rem; }
    .to-top             { right: 1rem; bottom: 1rem; }
}

/* ---- Very small phones ------------------------------------------------ */
@media (max-width: 360px) {
    .brand-text         { display: none; }
    .wrap               { padding-left: 1rem; padding-right: 1rem; }
}

/* ---- Larger screens: a touch more grandeur ---------------------------- */
@media (min-width: 1600px) {
    :root { --wrap: 1320px; }
}
