:root {
    color-scheme: light dark;

    --bg: #f3f3f1;
    --bg-glow: #fdfdfd;
    --text: #1a1a1a;
    --text-muted: #a8a8a8;
    --accent-red: #c7392b;
    --accent-yellow: #f6d24d;
    --rule: #ccc;
}

/* Follows the system setting; no toggle, no stored preference. */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131312;
        --bg-glow: #1f1f1d;
        --text: #ececea;
        --text-muted: #6e6e69;
        --accent-red: #e2594b;
        --accent-yellow: #f6d24d;
        --rule: #45454a;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    color: var(--text);
    background: var(--bg);
}

/* Gradient lives on its own composited layer so text repaints never
   re-rasterize it. Fixed position keeps it out of the flex flow. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 30% 20%, var(--bg-glow) 0%, var(--bg) 100%);
    transform: translateZ(0);
    will-change: transform;
}

main {
    /* fit-content keeps the block only as wide as its longest line, so the
       left-aligned text still sits centered on screen. */
    width: fit-content;
    max-width: min(44rem, 100%);
    padding: 2rem;
    text-align: left;
}

p {
    /* Scales down on narrow screens so each sentence keeps its own line. */
    font-size: clamp(1.15rem, 4.6vw, 1.75rem);
    line-height: 1.6;
    letter-spacing: -0.01em;
    /* 5 lines x 1.6 line-height, plus the paragraph gap. */
    min-height: 8.6em;
}

.line {
    display: block;
}

/* Breathing room between the intro and the JavaScript/tokens couplet. */
.line.is-new-para {
    margin-top: 0.6em;
}

strong {
    font-weight: 600;
}

/* inline-block: inline boxes can't be promoted to a compositor layer,
   so opacity/transform on them repaint instead of blending. */
.was,
.now-bold,
.now {
    display: inline-block;
}

.was {
    font-weight: 300;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--accent-red);
    text-decoration-thickness: 1.5px;
}

.now-bold {
    font-weight: 700;
    color: var(--text);
}

.now {
    font-weight: 400;
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--accent-yellow);
    text-decoration-thickness: 5px;
    text-underline-offset: 4px;
}

.links {
    margin-top: 1.75rem;
    opacity: 0;
    transform: translateY(14px);
    will-change: opacity, transform;
}

.links.is-visible {
    animation: rise 1.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.links a {
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 2px;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.links a:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

@keyframes rise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.word {
    display: inline-block;
}

/* Words inside a decorated phrase carry the decoration themselves — an
   ancestor's underline isn't drawn across inline-block descendants — and keep
   their trailing space so the run stays unbroken. */
.word-deco {
    white-space: pre;
}

.was .word {
    text-decoration: line-through;
    text-decoration-color: var(--accent-red);
    text-decoration-thickness: 1.5px;
}

.now .word {
    text-decoration: underline;
    text-decoration-color: var(--accent-yellow);
    text-decoration-thickness: 5px;
    text-underline-offset: 4px;
}

/* Only opacity/transform animate, so the reveal stays on the compositor. */
.word.is-animating {
    opacity: 0;
    animation: word-rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes word-rise {
    from {
        opacity: 0;
        transform: translateY(0.4em);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .links,
    .links.is-visible {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        will-change: auto !important;
    }
}
