/* Base reset + global paper-aesthetic typography. */

/* Native cross-document View Transitions: supported in Chromium 126+, Safari 18+.
 * Browsers without support fall back to the normal (still smoother than a white
 * flash because the inline critical CSS paints the paper background first). */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 200ms;
    animation-timing-function: cubic-bezier(0.2, 0.6, 0.2, 1);
}

::view-transition-old(root) {
    animation-name: fade-out;
}

::view-transition-new(root) {
    animation-name: fade-in;
}

@keyframes fade-out {
    to { opacity: 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    color: var(--ink-umber);
    background: var(--paper-cream);
    position: relative;
    overflow-x: hidden;
}

/* Subtle paper-grain overlay. Fixed + pointer-events-none + low z so it
 * doesn't invalidate paint on scroll; mix-blend-mode removed because it
 * forces full repaints on every scroll frame. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.05;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.65'/></svg>");
}

main, section, article, header, footer, nav {
    position: relative;
    z-index: 1;
}

/* ----- Typography ----- */

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: var(--leading-tight);
    color: var(--ink-umber);
    letter-spacing: -0.015em;
    margin: 0 0 var(--sp-4);
    /* Variable-font optical-size axis: Source Serif 4 carries opsz 8-60.
     * Browsers auto-select when font-optical-sizing is on. */
    font-optical-sizing: auto;
    font-feature-settings: "kern", "liga", "calt", "ss01";
    text-wrap: balance;
}

h1 { font-size: var(--text-4xl); letter-spacing: -0.022em; line-height: 1.02; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.018em; }
h3 { font-size: var(--text-2xl); letter-spacing: -0.012em; }
h4 { font-size: var(--text-xl);  letter-spacing: -0.008em; }
h5 { font-size: var(--text-lg); }

@media (max-width: 640px) {
    h1 { font-size: clamp(2rem, 11vw, 2.75rem); }
    h2 { font-size: clamp(1.65rem, 8vw, 2.15rem); }
    h3 { font-size: clamp(1.35rem, 6.5vw, 1.75rem); }
}

p { text-wrap: pretty; }

p {
    margin: 0 0 var(--sp-4);
}

a {
    color: var(--accent-ink);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    transition: color var(--dur-fast) var(--ease-standard);
}

img,
svg,
canvas,
video,
iframe {
    max-width: 100%;
}

a:hover,
a:focus-visible {
    color: var(--accent-rust);
}

strong { font-weight: 600; color: var(--ink-umber); }
em { font-style: italic; color: var(--ink-walnut); }

code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--paper-kraft);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-xs);
}

hr {
    border: 0;
    border-top: 1px solid var(--paper-shadow);
    margin: var(--sp-6) 0;
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: 500;
    text-align: left;
    margin-bottom: var(--sp-5);
}

.page-body {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--sp-4) var(--sp-7);
}

/* ----- Masthead (funder + consortium logos) ----- */

.masthead {
    border-bottom: 1px solid var(--paper-shadow);
    padding: var(--sp-4) var(--sp-5);
    margin: 0 0 var(--sp-6);
}

.masthead-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-6);
    flex-wrap: wrap;
}


.masthead-row {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
}

.masthead-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    opacity: 0.9;
    transition: opacity var(--dur-fast) var(--ease-standard);
}

.masthead-logo--psa {
    height: 48px;
}

.masthead-logo--iisc {
    height: 56px;
}

.masthead-logo:hover { opacity: 1; }

@media (max-width: 760px) {
    .masthead-inner { flex-direction: column; align-items: flex-start; }
    .masthead-consortium { align-items: flex-start; }
    .masthead-row { flex-wrap: wrap; gap: var(--sp-4); }
    .masthead-logo { height: 34px; }
    .masthead-logo--psa { height: 40px; }
}

/* ----- Focus ring: paper-palette rust, visible across all interactive elements ----- */

:focus-visible {
    outline: 2px solid var(--accent-rust);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
    transition: outline-offset var(--dur-fast) var(--ease-standard);
}

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline-width: 2px;
    outline-color: var(--accent-rust);
    outline-offset: 3px;
}

/* ----- Selection ----- */

::selection {
    background: var(--accent-ochre-soft);
    color: var(--ink-umber);
}

/* ----- Scrollbar (Webkit only) ----- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--paper-shadow);
    border-radius: var(--radius-pill);
    border: 2px solid var(--paper-cream);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-mist); }

/* ----- Reduced motion ----- */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ----- Screen reader only ----- */

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
