/* Shared paper-and-ink surfaces. Loaded last on public pages only. */
[data-texture-theme] {
    --paper-ivory: #faf8f2;
    --paper-tint: #eef3eb;
    --paper-card: #fffdf8;
    --paper-line: #dce3d8;
    --paper-grain: url('/images/backgrounds/paper-grain.webp');
    --paper-pigment: url('/images/backgrounds/wash-sage.webp');
    --paper-grain-strength: .62;
    --paper-wash-strength: .34;
    --paper-grain-size: 360px;
    --paper-wash-size: clamp(640px, 78vw, 1200px);
    background-color: var(--paper-ivory);
}
[data-texture-theme="org"] {
    --paper-tint: #f0eff5;
    --paper-line: #e0dfeb;
    --paper-pigment: url('/images/backgrounds/wash-indigo.webp');
    --paper-wash-strength: .30;
}
[data-texture-theme="home"] { --paper-tint: #eef5ef; }
[data-texture-theme="legal"] {
    --paper-grain-strength: .34;
    --paper-wash-strength: .28;
}

/* Backgrounds are local to their section, never overlays on content. */
main > .paper-surface {
    position: relative;
    isolation: isolate;
    background: var(--paper-ivory);
}
main > .paper-surface.paper-tinted { background: var(--paper-tint); }
main > .paper-surface::before {
    content: '';
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: inherit;
    background: var(--paper-grain) 0 0 / var(--paper-grain-size) repeat;
    opacity: var(--paper-grain-strength);
    mix-blend-mode: multiply;
    box-shadow: none;
    transform: none;
    filter: none;
    z-index: 0;
    pointer-events: none;
}
main > .paper-surface::after { content: none; }
main > .paper-surface.paper-wash::after {
    content: '';
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: inherit;
    background: var(--paper-pigment) right center / var(--paper-wash-size) auto no-repeat;
    opacity: var(--paper-wash-strength);
    /* Fade within the panel, with no hard crop at its edges. */
    -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 78%, transparent);
    mask-image: linear-gradient(transparent, #000 14%, #000 78%, transparent);
    box-shadow: none;
    transform: none;
    filter: none;
    z-index: 0;
    pointer-events: none;
}
main > .paper-closing.paper-wash::after {
    background-position: center;
    background-size: min(1100px, 100%) auto;
    opacity: var(--paper-wash-strength);
}
[data-texture-theme="home"] main > .routing-hero {
    background:
        radial-gradient(ellipse at 80% 18%, #25a6ca14, transparent 65%),
        radial-gradient(ellipse at 12% 80%, #c8d92b16, transparent 60%),
        var(--paper-ivory);
}
[data-texture-theme="home"] main > .routing-hero::after {
    background-position: center;
    opacity: .32;
}

/* Opaque reading surfaces maintain a clear separation from the paper. */
[data-texture-theme] :is(.faq-card, .therapy-service-card, .program-card,
    .process-step, .org-audience-card, .contact-card, .hero-trust-panel) {
    background-color: var(--paper-card);
    background-image: none;
    border-color: var(--paper-line);
    box-shadow: 0 4px 18px rgb(42 52 37 / 6%);
}
[data-texture-theme] .faq-card[open] {
    border-color: #b6c9b8;
    box-shadow: 0 8px 26px rgb(42 52 37 / 8%);
}
[data-texture-theme] :is(.page-header, .faq-hero) > .container {
    position: relative;
    z-index: 4;
}
/* Keep the legal prose surface clear while paper remains in its margins. */
[data-texture-theme="legal"] .legal-content {
    background: var(--paper-card);
}
@media (max-width: 760px) {
    [data-texture-theme] {
        --paper-grain-strength: .52;
        --paper-wash-size: 780px;
    }
    [data-texture-theme="legal"] { --paper-grain-strength: .28; }
    main > .paper-surface.paper-wash::after { background-position: 60% 15%; }
    main > .paper-closing.paper-wash::after { background-size: 780px auto; background-position: center; }
}
@media print, (forced-colors: active) {
    main > .paper-surface::before,
    main > .paper-surface.paper-wash::after { display: none; }
    main > .paper-surface,
    main > .paper-surface.paper-tinted,
    [data-texture-theme="home"] main > .routing-hero { background: Canvas; }
}
/* Supporting copy stays readable over the darkest pigment patches. */
[data-texture-theme] :is(.page-header-subtitle, .faq-hero-copy, .contact-cta-copy p,
    .paper-wash .section-subtitle, .routing-hero-subtitle) { color: #17362d; }
[data-texture-theme] .contact-card-private { border-top-color: var(--ind-500); }
[data-texture-theme] .contact-card-org { border-top-color: var(--org-500); }
/* Match the wash alignment to the header's content layout. */
main > .faq-hero.paper-wash::after,
main > .page-header.paper-wash:not(.page-header-with-intake)::after {
    background-position-x: center;
}
@media (max-width: 860px) {
    /* Intake headers become a centered, single-column layout here. */
    main > .page-header-with-intake.paper-wash::after {
        background-position-x: center;
    }
}
@media (min-width: 861px) {
    /* Center the pigment within the right-hand copy column, not the whole hero. */
    main > .page-header-with-intake.paper-wash::after {
        left: auto;
        right: 0;
        width: 56%;
        background-position: center;
        background-size: 100% auto;
    }
}