/*
 * r30 UI density guardrail
 *
 * Shared first-viewport and vertical-rhythm corrections. This file loads
 * after route-owned component styles so one bounded layer controls display
 * scale and top-of-page density without expanding the central stylesheet.
 */

html.ui-density-r30 {
    --density-section-space: clamp(4rem, 6vw, 5.75rem);
    --density-section-space-mobile: 3.5rem;
    --density-heading-gap: clamp(1.7rem, 3vw, 2.8rem);
    --density-page-hero-min: 34rem;
    --density-page-hero-pad: clamp(2.4rem, 4vw, 3.7rem);
}

/* First viewport --------------------------------------------------------- */

html.ui-density-r30 .page-hero {
    min-height: var(--density-page-hero-min);
}

html.ui-density-r30 .page-hero__inner {
    min-height: calc(var(--density-page-hero-min) - var(--header-h));
    padding-block: var(--density-page-hero-pad);
    gap: clamp(2rem, 5vw, 5rem);
    align-items: start;
}

html.ui-density-r30 .display--page {
    max-width: 11ch;
    font-size: clamp(3.65rem, 6.65vw, 6.75rem);
    line-height: 0.87;
}

html.ui-density-r30 .page-hero__lead {
    margin-block: 1.25rem 1rem;
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.58;
}

html.ui-density-r30 .page-hero__aside {
    padding: 1.2rem;
}

html.ui-density-r30 .page-hero__aside dl {
    margin-top: 1rem;
}

html.ui-density-r30 .page-hero--loop {
    min-height: 36rem;
}

html.ui-density-r30 .page-hero--loop .page-hero__inner {
    min-height: calc(36rem - var(--header-h));
}

html.ui-density-r30 .page-hero--loop .display--page,
html.ui-density-r30 .display--profile {
    font-size: clamp(3.6rem, 6.2vw, 6.25rem);
}

html.ui-density-r30 .page-hero--timeline {
    min-height: 39rem;
}

html.ui-density-r30 .page-hero--timeline .page-hero__inner {
    min-height: calc(39rem - var(--header-h));
    padding-block: clamp(2.35rem, 3.8vw, 3.4rem);
    align-items: start;
}

html.ui-density-r30 .page-hero--timeline .display--page {
    font-size: clamp(3.8rem, 6.8vw, 7rem);
    line-height: 0.86;
}

html.ui-density-r30 .page-hero--timeline .page-hero__lead {
    margin-top: 1.25rem;
    line-height: 1.6;
}

/* The homepage keeps its two-column proposition, but no longer consumes an
   entire desktop viewport before the next research entry point appears. */
html.ui-density-r30 .hero__inner {
    min-height: min(43rem, calc(100svh - var(--header-h)));
    padding-block: clamp(2.65rem, 4.2vw, 3.8rem) 2.5rem;
    gap: clamp(2.5rem, 5vw, 4.8rem);
}

html.ui-density-r30 .display--hero {
    font-size: clamp(4rem, 6.4vw, 6.15rem);
    line-height: 0.9;
}

html.ui-density-r30 .hero__status {
    margin-bottom: 1rem;
}

html.ui-density-r30 .hero__kicker {
    margin-bottom: 1rem;
}

html.ui-density-r30 .hero__lead {
    margin-block: 1.25rem 0.8rem;
    font-size: clamp(1rem, 1.25vw, 1.15rem);
    line-height: 1.55;
}

html.ui-density-r30 .hero__signal-line {
    margin-bottom: 1rem;
}

html.ui-density-r30 .hero-paths {
    margin-top: 1.2rem;
}

html.ui-density-r30 .hero-terminal__visual {
    min-height: 18rem;
    padding: 1.45rem;
    gap: 1.35rem;
}

html.ui-density-r30 .hero-terminal__tabs button {
    min-height: 3.85rem;
}

html.ui-density-r30 .hero__metrics div {
    min-height: 4.6rem;
}

/* Section rhythm --------------------------------------------------------- */

html.ui-density-r30 body main > .section:not(.section--section-workbench) {
    padding-block: var(--density-section-space);
}

html.ui-density-r30 .section-heading {
    margin-bottom: var(--density-heading-gap);
}

html.ui-density-r30 .section-heading h2 {
    font-size: clamp(2.65rem, 4.55vw, 4.75rem);
    line-height: 0.95;
}

html.ui-density-r30 .section-heading > p:last-child {
    font-size: clamp(0.98rem, 1.15vw, 1.15rem);
    line-height: 1.58;
}

html.ui-density-r30 .manifesto-band,
html.ui-density-r30 .manifesto-band--compact {
    padding-block: clamp(4.75rem, 7vw, 6.5rem);
}

html.ui-density-r30 .manifesto-band h2,
html.ui-density-r30 .final-question h2 {
    font-size: clamp(2.8rem, 4.9vw, 5rem);
    line-height: 0.95;
}

html.ui-density-r30 .manifesto-band p:not(.eyebrow) {
    font-size: clamp(1.05rem, 1.45vw, 1.3rem);
}

html.ui-density-r30 .manifesto-band__declaration {
    margin-top: 2rem;
}

html.ui-density-r30 #archive-title,
html.ui-density-r30 .model-switcher__display h3 {
    font-size: clamp(2.5rem, 4.2vw, 4.25rem);
    line-height: 0.96;
}

/* Large evidence-module titles were visually overpowering their records.
   They retain display hierarchy while staying below the page title. */
html.ui-density-r30 :is(
    .temporal-grammar__hero,
    .enochic-manuscripts__hero,
    .enochic-passages__hero,
    .enochic-apparatus__hero,
    .collation-room__header,
    .insurrection-outcomes__hero,
    .contested-label-method__hero,
    .current-directory-provenance__hero,
    .archival-reappearance__hero,
    .enochic-cosmos__hero,
    .participation-wheel__heading,
    .survivor-inversion__hero
) h2 {
    font-size: clamp(2.7rem, 4.65vw, 4.8rem);
    line-height: 0.94;
}

html.ui-density-r30 :is(
    .restrainer-context__record-header,
    .symbol-context__record-header,
    .rhetoric-context__record-header
) h3 {
    font-size: clamp(2.2rem, 3.75vw, 3.6rem);
    line-height: 0.94;
}

html.ui-density-r30 .site-footer {
    padding-top: clamp(3.75rem, 6vw, 5.5rem);
}

html.ui-density-r30 .site-footer__signal {
    padding-bottom: clamp(3rem, 5vw, 4.75rem);
}

/* Error routes still orient the reader quickly instead of vertically
   centering a large display in an otherwise empty viewport. */
html.ui-density-r30 .error-signal {
    min-height: min(42rem, 100svh);
    place-items: start center;
}

html.ui-density-r30 .error-signal__inner {
    padding-block: clamp(3.25rem, 8vh, 5.5rem);
}

html.ui-density-r30 .error-signal p:not(.eyebrow) {
    margin-block: 1.35rem;
    font-size: 1.05rem;
}

@media (max-width: 980px) {
    html.ui-density-r30 .page-hero,
    html.ui-density-r30 .page-hero--loop,
    html.ui-density-r30 .page-hero--timeline {
        min-height: auto;
    }

    html.ui-density-r30 .page-hero__inner,
    html.ui-density-r30 .page-hero--loop .page-hero__inner,
    html.ui-density-r30 .page-hero--timeline .page-hero__inner {
        min-height: 0;
        padding-block: 3rem;
        gap: 2rem;
        align-content: start;
    }

    html.ui-density-r30 .hero__inner {
        min-height: 0;
        padding-block: 3.25rem 2.6rem;
        gap: 2.4rem;
    }

    html.ui-density-r30 .display--hero {
        font-size: clamp(3.75rem, 10.5vw, 5.8rem);
    }
}

@media (max-width: 720px) {
    html.ui-density-r30 {
        --density-page-hero-pad: 2.45rem;
    }

    html.ui-density-r30 body main > .section:not(.section--section-workbench) {
        padding-block: var(--density-section-space-mobile);
    }

    html.ui-density-r30 .page-hero__inner,
    html.ui-density-r30 .page-hero--loop .page-hero__inner,
    html.ui-density-r30 .page-hero--timeline .page-hero__inner {
        padding-block: 2.45rem;
        gap: 1.55rem;
    }

    html.ui-density-r30 .display--page,
    html.ui-density-r30 .page-hero--loop .display--page,
    html.ui-density-r30 .page-hero--timeline .display--page,
    html.ui-density-r30 .display--profile {
        font-size: clamp(3rem, 13.4vw, 3.55rem);
        line-height: 0.9;
    }

    html.ui-density-r30 .page-hero__lead {
        margin-top: 1rem;
        font-size: 0.97rem;
    }

    html.ui-density-r30 .page-hero__aside {
        padding: 1rem;
    }

    html.ui-density-r30 .hero__inner {
        padding-block: 2.55rem 2.3rem;
        gap: 2rem;
    }

    html.ui-density-r30 .display--hero {
        font-size: clamp(3.25rem, 14.2vw, 3.8rem);
    }

    html.ui-density-r30 .hero__lead {
        margin-top: 1rem;
        font-size: 0.96rem;
    }

    html.ui-density-r30 .hero-terminal__visual {
        min-height: 0;
        padding: 1.25rem 1rem;
    }

    html.ui-density-r30 .section-heading {
        margin-bottom: 1.8rem;
    }

    html.ui-density-r30 .section-heading h2,
    html.ui-density-r30 .manifesto-band h2,
    html.ui-density-r30 .final-question h2,
    html.ui-density-r30 #archive-title,
    html.ui-density-r30 .model-switcher__display h3,
    html.ui-density-r30 :is(
        .temporal-grammar__hero,
        .enochic-manuscripts__hero,
        .enochic-passages__hero,
        .enochic-apparatus__hero,
        .collation-room__header,
        .insurrection-outcomes__hero,
        .contested-label-method__hero,
        .current-directory-provenance__hero,
        .archival-reappearance__hero,
        .enochic-cosmos__hero,
        .participation-wheel__heading,
        .survivor-inversion__hero
    ) h2 {
        font-size: clamp(2.35rem, 10.7vw, 2.8rem);
        line-height: 0.96;
    }

    html.ui-density-r30 :is(
        .restrainer-context__record-header,
        .symbol-context__record-header,
        .rhetoric-context__record-header
    ) h3 {
        font-size: clamp(2rem, 9.5vw, 2.45rem);
        line-height: 0.96;
    }

    html.ui-density-r30 .manifesto-band,
    html.ui-density-r30 .manifesto-band--compact {
        padding-block: 4rem;
    }

    html.ui-density-r30 .site-footer {
        padding-top: 3.5rem;
    }

    html.ui-density-r30 .error-signal__inner {
        padding-block: 3rem;
    }
}

@media (max-width: 420px) {
    html.ui-density-r30 .page-hero__inner,
    html.ui-density-r30 .page-hero--loop .page-hero__inner,
    html.ui-density-r30 .page-hero--timeline .page-hero__inner {
        padding-block: 2.1rem;
    }

    html.ui-density-r30 .display--page,
    html.ui-density-r30 .page-hero--loop .display--page,
    html.ui-density-r30 .page-hero--timeline .display--page,
    html.ui-density-r30 .display--profile {
        font-size: clamp(2.75rem, 13vw, 3.25rem);
    }

    html.ui-density-r30 .display--hero {
        font-size: clamp(3rem, 14vw, 3.5rem);
    }
}

@media print {
    html.ui-density-r30 .page-hero,
    html.ui-density-r30 .page-hero--loop,
    html.ui-density-r30 .page-hero--timeline,
    html.ui-density-r30 .error-signal {
        min-height: 0;
    }

    html.ui-density-r30 .page-hero__inner,
    html.ui-density-r30 .error-signal__inner {
        min-height: 0;
        padding-block: 1.5rem;
    }
}
