/* ==========================================================================
   nainarnagendran.in — Responsive layer
   Breakpoints: 1180 / 1024 / 860 / 640 / 420
   Goal: zero horizontal scroll, no clipped faces, generous touch targets.
   ========================================================================== */

/* ---------- Large desktop refinement ---------- */
@media (max-width: 1360px) {
    :root { --shell: 1180px; }
}

/* ---------- Nav collapses to drawer ---------- */
@media (max-width: 1180px) {
    .nav-toggle { display: flex; }

    .site-nav {
        position: fixed;
        inset: var(--header-h) 0 0 0;
        background: var(--paper);
        border-top: 1px solid var(--line-soft);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity .26s var(--ease), transform .26s var(--ease), visibility .26s;
        z-index: 110;
    }
    .site-nav.is-open { opacity: 1; visibility: visible; transform: none; }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: clamp(1rem, 4vw, 2rem) var(--gutter) 3rem;
        max-width: var(--shell);
        margin: 0 auto;
    }
    .nav-list li { border-bottom: 1px solid var(--line-soft); }
    .nav-list a {
        font-size: .9rem;
        letter-spacing: .1em;
        padding: 1.15rem 0;
        min-height: 54px;
        display: flex;
        align-items: center;
    }
    .nav-list a::after { display: none; }
    .nav-list a[aria-current="page"] { color: var(--copper); }
    .nav-list a[aria-current="page"]::before {
        content: "";
        width: 6px; height: 6px;
        background: var(--copper);
        border-radius: 50%;
        margin-right: .8rem;
        flex: none;
    }
    body.nav-open { overflow: hidden; }
}

/* ---------- Tablet landscape ---------- */
@media (max-width: 1024px) {
    :root { --section-y: clamp(3.4rem, 8vw, 5.5rem); }

    .hero::before { width: 100%; top: auto; height: 46%; bottom: 0; }
    .hero-grid { grid-template-columns: minmax(0,1fr); gap: 2.4rem; }
    .hero-copy { padding-right: 0; }
    .hero-figure { max-width: 620px; margin-inline: auto; width: 100%; }

    .masthead-grid { grid-template-columns: minmax(0,1fr); align-items: start; gap: 1.6rem; }
    .masthead-note { max-width: 62ch; }

    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .factband { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .factband > div:nth-child(2n) { border-right: 0; }
    .factband > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }

    .dossier-row { grid-template-columns: 62px minmax(0,1fr); }
    .dossier-row .dossier-body { grid-column: 2; }

    .plates { grid-template-columns: repeat(2, minmax(0,1fr)); }

    .m-4, .m-5, .m-7, .m-8 { grid-column: span 6; }

    .chapters { position: static; margin-bottom: 2.4rem; }
    .chapter-nav { display: flex; flex-wrap: wrap; border-left: 0; border-top: 1px solid var(--line); padding-top: .6rem; gap: 0 .4rem; }
    .chapter-nav li { flex: 0 0 auto; }
    .chapter-nav a { padding: .5rem .8rem; border-left: 0; border-top: 2px solid transparent; margin: 0; }
    .chapter-nav a:hover, .chapter-nav a.is-active { border-left-color: transparent; border-top-color: var(--copper); }
    .chapter-nav .cn-num { display: inline; margin-right: .35rem; }
}

/* ---------- Tablet portrait / large phone ---------- */
@media (max-width: 860px) {
    .split, .split--wide-left, .split--wide-right { grid-template-columns: minmax(0,1fr); gap: 2rem; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0,1fr); }

    /* Spine timeline → single column left rail */
    .spine::before { left: 7px; transform: none; }
    .spine > li { grid-template-columns: 15px minmax(0,1fr); gap: clamp(1rem, 3vw, 1.6rem); margin-bottom: 1.8rem; }
    .spine-node { grid-column: 1; padding-top: .9rem; place-items: start; }
    .spine > li:nth-child(odd) .spine-card,
    .spine > li:nth-child(even) .spine-card { grid-column: 2; text-align: left; }
    .spine > li:nth-child(odd) .spine-card .spine-tag { justify-content: flex-start; }

    .ledger-row { grid-template-columns: minmax(0,1fr); gap: .3rem; }

    .footer-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
    .footer-brand { grid-column: 1 / -1; }

    .m-4, .m-5, .m-6, .m-7, .m-8 { grid-column: span 12; }

    .rail { grid-auto-columns: minmax(215px, 78vw); }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
    :root { --header-h: 66px; --section-y: clamp(3rem, 11vw, 4.2rem); }

    body { font-size: .97rem; line-height: 1.68; }

    .brand-mark { width: 34px; height: 34px; font-size: .85rem; }
    .brand-name { font-size: .96rem; }
    .brand-sub { font-size: .55rem; letter-spacing: .16em; }

    .factband { grid-template-columns: minmax(0,1fr); }
    .factband > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
    .factband > div:last-child { border-bottom: 0; }

    .plates { grid-template-columns: minmax(0,1fr); }

    .dossier-row { grid-template-columns: minmax(0,1fr); gap: .7rem; }
    .dossier-row .dossier-body { grid-column: 1; }

    .contact-lines a, .contact-lines .static { grid-template-columns: minmax(0,1fr); gap: .3rem; padding: 1rem 0; }

    .explore-item { grid-template-columns: 40px minmax(0,1fr); gap: .9rem; }
    .explore-item .go { display: none; }

    .chapter-head { flex-direction: column; gap: .4rem; align-items: flex-start; }

    .pullquote { margin: 2rem 0; }
    .dropcap::first-letter { font-size: 3.1em; }

    .footer-grid { grid-template-columns: minmax(0,1fr); }
    .footer-base { flex-direction: column; align-items: flex-start; }

    .btn { width: 100%; }
    .hero-meta { gap: 1.3rem 1.8rem; }
    .frame--fixed, .frame--wide { aspect-ratio: 3 / 2; }
    .plate .frame { aspect-ratio: 3 / 2; }

    table.record { min-width: 620px; }
    .table-scroll-hint { display: block; }
}

/* ---------- Small phones (360 / 375) ---------- */
@media (max-width: 420px) {
    :root { --gutter: 1.1rem; }
    .hero-name { font-size: clamp(2.2rem, 12vw, 2.9rem); }
    .display { font-size: clamp(2rem, 10.5vw, 2.7rem); }
    .masthead h1 { font-size: clamp(1.95rem, 9.6vw, 2.5rem); }
    .hero-meta { display: grid; grid-template-columns: minmax(0,1fr); gap: 1.1rem; }
    .gate-panel { max-width: 100%; }
    .social a, .social span { width: 42px; height: 42px; }
    .frame--fixed, .frame--wide, .plate .frame { aspect-ratio: 4 / 3; }
}

/* ---------- Very wide screens ---------- */
@media (min-width: 1700px) {
    :root { --shell: 1400px; --shell-narrow: 1000px; }
}

/* ---------- Landscape phones: keep the gate usable ---------- */
@media (max-height: 560px) and (orientation: landscape) {
    .gate { min-height: auto; padding-block: 2.6rem; }
    .gate-mark { margin-bottom: 1.2rem; width: 50px; height: 50px; }
    .gate-sub { margin-bottom: 1.4rem; }
}

/* ---------- Print ---------- */
@media print {
    .site-header, .site-footer, .scroll-hint, .nav-toggle, .lightbox { display: none !important; }
    body { background: #fff; color: #000; }
    .on-dark, .masthead { background: #fff !important; color: #000 !important; }
    .on-dark h1, .on-dark h2, .on-dark h3, .masthead h1 { color: #000 !important; }
    a { text-decoration: underline; }
}

/* Named ratio splits collapse with everything else */
@media (max-width: 1024px) {
    .split--index { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .split--portrait { grid-template-columns: minmax(0, 1fr); }
}
