/*
 * FlinkerAge — global, restrained paper patina.
 *
 * The background and navigation use the same ageing state.
 * Text remains legible throughout.
 */

:root {
    --flinker-age: 0;
    --flinker-age-factor: 1;
    --flinker-patina: 0;

    --flinker-paper: #fffdf8;
    --flinker-sepia: #b49a6a;

    --flinker-menu-color: #ffffff;
}


/* Base document: full-page ageing layer */

html {
    min-height: 100%;
    background: #fffdf8;
}

body {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    background: transparent !important;
}

/* Full-width patina, independent of content containers */

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;

    background:
        linear-gradient(
            to bottom,
            #fffdf8 0%,
            rgba(255, 253, 248, 0.96) 18%,
            rgba(239, 229, 207, var(--flinker-mid-opacity, 0)) 65%,
            rgba(202, 178, 137, var(--flinker-bottom-opacity, 0)) 100%
        );

    transition: background 900ms ease;
}

/*
 * Keep the patina behind page content.
 */

body > * {
    position: relative;
    z-index: 1;
}

/*
 * Panels slowly become translucent parchment.
 */

main,
main section,
.main-content,
.hero,
article,
.content-panel {
    background-color: rgba(
        255,
        253,
        248,
        var(--flinker-panel-alpha, 1)
    ) !important;

    transition: background-color 900ms ease;
}

/*
 * Section-specific ageing rates.
 *
 * These factors are read by flinker-age.js.
 */

body[data-flinker-section="archive"] {
    --flinker-age-factor: 2.8;
}

body[data-flinker-section="tools"] {
    --flinker-age-factor: 1.7;
}

body[data-flinker-section="dictionary"] {
    --flinker-age-factor: 1.25;
}

body[data-flinker-section="new"] {
    --flinker-age-factor: 0.45;
}

/*
 * Navigation ageing.
 *
 * Navigation text gradually changes from fresh white to
 * warm parchment as the rest of the page ages.
 */

header nav a {
    color: var(--flinker-menu-color, #ffffff);

    transition:
        color 900ms ease,
        text-decoration-color 300ms ease;
}

/*
 * Hover and keyboard focus temporarily restore fresh white.
 * This also improves visual feedback and accessibility.
 */

header nav a:hover,
header nav a:focus-visible {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-color: #ffffff;
}

/*
 * Keyboard focus must remain clearly visible.
 */

header nav a:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 4px;
}

/*
 * Respect users who prefer reduced motion.
 */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }
}