/* ==========================================================================
   DATASEC design system
   One set of tokens for every page. Page stylesheets may compose with these
   but must not introduce new palettes, type scales or easing curves.
   ========================================================================== */

:root {
    /* Surfaces: warm near-black, four steps only */
    --ink-900: #0b0a09;
    --ink-800: #121110;
    --ink-700: #1a1817;
    --ink-600: #232120;

    /* Ink on those surfaces */
    --paper: #e8e4de;
    --paper-dim: #a8a29b;
    --paper-mute: #858078;

    /* One accent. Used for emphasis, never for decoration.
       --brand is the raw value; --accent is what components read. The alias
       lets migrated page styles point their old accent names at the brand
       colour without creating a var() cycle. */
    --brand: #c8814b;
    --brand-quiet: rgba(200, 129, 75, 0.14);
    --accent: var(--brand);

    /* Hairlines carry most of the structure, so they get two weights */
    --line: rgba(232, 228, 222, 0.1);
    --line-strong: rgba(232, 228, 222, 0.2);

    /* Shadows are almost invisible on a near-black page; they exist so the
       light theme has depth. */
    --shadow: rgba(11, 10, 9, 0.5);

    /* Type: one grotesk, plus mono for anything the machine produced.
       Display and UI share the family; hierarchy comes from size, weight and
       tracking rather than from a second typeface. */
    --font-sans: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: var(--font-sans);
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

    /* Display type is set tight; body stays at normal tracking. */
    --track-display: -0.03em;
    --track-label: 0.14em;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1.0625rem;
    --text-lg: 1.1875rem;
    --display-xs: clamp(1.375rem, 2vw, 1.625rem);
    --display-sm: clamp(1.75rem, 3.2vw, 2.375rem);
    --display-md: clamp(2.125rem, 5vw, 3.25rem);
    --display-lg: clamp(2.5rem, 7vw, 4.75rem);

    /* Spacing on a 4px base */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --s-8: 4rem;
    --s-9: 6rem;
    --s-10: 9rem;

    /* Exactly three radii. Small radii read as precise; large ones read cheap. */
    --r-sm: 2px;
    --r-md: 4px;
    --r-lg: 8px;

    /* Motion. Every transition on the site uses one of these. */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --dur-1: 120ms;
    --dur-2: 180ms;
    --dur-3: 320ms;
    --dur-4: 560ms;

    --measure: 68ch;
    --wrap: 1240px;
    --gutter: clamp(1.25rem, 5vw, 4rem);
    --nav-h: 68px;
}

[data-theme="light"] {
    --ink-900: #f6f3ee;
    --ink-800: #efebe4;
    --ink-700: #ffffff;
    --ink-600: #e7e2d9;

    --paper: #171513;
    --paper-dim: #57524c;
    --paper-mute: #6f6862;

    --brand: #8f5629;
    --brand-quiet: rgba(143, 86, 41, 0.1);

    --line: rgba(23, 21, 19, 0.12);
    --line-strong: rgba(23, 21, 19, 0.24);
    --shadow: rgba(23, 21, 19, 0.1);
}

/* --------------------------------------------------------------- reset */

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

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

body {
    background: var(--ink-900);
    color: var(--paper);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    font-feature-settings: 'kern' 1, 'liga' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: background var(--dur-3) var(--ease-in-out),
                color var(--dur-3) var(--ease-in-out);
}

img,
svg,
canvas {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

::selection {
    background: var(--accent);
    color: var(--ink-900);
}

/* --------------------------------------------------------- typography */

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.05;
    letter-spacing: var(--track-display);
    text-wrap: balance;
}

h1 {
    font-size: var(--display-lg);
}

h2 {
    font-size: var(--display-md);
}

h3 {
    font-size: var(--display-sm);
}

h4 {
    font-size: var(--display-xs);
}

p {
    text-wrap: pretty;
}

/* Small caps label that replaces the old "//01" section markers */
/* Section eyebrow. Mono, because it labels rather than speaks. */
.label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--paper-mute);
}

.lede {
    font-size: var(--text-lg);
    line-height: 1.55;
    color: var(--paper-dim);
    max-width: var(--measure);
}

.mono {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    letter-spacing: -0.01em;
}

/* Emphasis is carried by the accent colour, not by a second typeface. */
em,
.accent-text {
    font-style: normal;
    color: var(--accent);
}

/* ------------------------------------------------------------- layout */

.wrap {
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.section {
    padding-block: var(--s-10);
    scroll-margin-top: calc(var(--nav-h) + var(--s-4));
}

.section--tight {
    padding-block: var(--s-9);
}

.section-head {
    display: grid;
    gap: var(--s-4);
    max-width: var(--measure);
    margin-bottom: var(--s-8);
}

.rule {
    border: 0;
    border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------- links */

/* Underline draws in from the left rather than simply appearing. */
.link {
    position: relative;
    display: inline-block;
    color: var(--paper);
}

.link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur-2) var(--ease-out);
}

.link:hover::after,
.link:focus-visible::after {
    transform: scaleX(1);
}

/* Text link with a trailing arrow that nudges on hover */
.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--paper);
    transition: color var(--dur-2) var(--ease-out);
}

.link-arrow svg {
    width: 1em;
    height: 1em;
    transition: transform var(--dur-2) var(--ease-out);
}

.link-arrow:hover {
    color: var(--accent);
}

.link-arrow:hover svg {
    transform: translateX(3px);
}

/* ------------------------------------------------------------ buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 0.8125rem var(--s-5);
    border-radius: var(--r-md);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: background var(--dur-2) var(--ease-out),
                border-color var(--dur-2) var(--ease-out),
                color var(--dur-2) var(--ease-out),
                transform var(--dur-1) var(--ease-out);
}

.btn svg {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

.btn:active {
    transform: scale(0.985);
}

.btn--primary {
    background: var(--paper);
    color: var(--ink-900);
    border: 1px solid var(--paper);
}

.btn--primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink-900);
}

.btn--ghost {
    background: transparent;
    color: var(--paper);
    border: 1px solid var(--line-strong);
}

.btn--ghost:hover {
    border-color: var(--paper);
    background: var(--ink-800);
}

/* --------------------------------------------------------------- cards */

.card {
    display: flex;
    flex-direction: column;
    background: var(--ink-800);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    transition: border-color var(--dur-2) var(--ease-out),
                background var(--dur-2) var(--ease-out),
                transform var(--dur-2) var(--ease-out);
}

.card:hover {
    border-color: var(--line-strong);
    background: var(--ink-700);
    transform: translateY(-2px);
}

/* A row in a ruled index. Replaces card grids where items are peers. */
.row {
    display: grid;
    align-items: baseline;
    gap: var(--s-4);
    padding-block: var(--s-5);
    border-top: 1px solid var(--line);
    transition: border-color var(--dur-2) var(--ease-out);
}

.row:last-child {
    border-bottom: 1px solid var(--line);
}

.row:hover {
    border-top-color: var(--line-strong);
}

/* Status is information, not a badge: mono small-caps, no box, no fill.
   A bordered pill on every item is one of the clearest template tells. */
.tag {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 400;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--paper-mute);
    white-space: nowrap;
}

/* Reserved for the one item that genuinely differs from its peers. */
.tag--accent {
    color: var(--accent);
}

/* ------------------------------------------------------------- figures */

/* Numeric facts, separated by rules instead of floated in card boxes */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    border-top: 1px solid var(--line);
}

.fact {
    padding: var(--s-5) var(--s-5) var(--s-5) 0;
    border-bottom: 1px solid var(--line);
}

.fact dt {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--paper-mute);
    margin-bottom: var(--s-2);
}

.fact dd {
    font-size: var(--display-xs);
    font-weight: 500;
    letter-spacing: var(--track-display);
    line-height: 1;
    color: var(--paper);
}

/* ----------------------------------------------------------------- nav */

.nav {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    background: color-mix(in srgb, var(--ink-900) 82%, transparent);
    backdrop-filter: blur(16px) saturate(140%);
    border-bottom: 1px solid transparent;
    transition: border-color var(--dur-3) var(--ease-out),
                background var(--dur-3) var(--ease-out);
}

/* Set by JS once the page is scrolled, so the hairline only appears when
   there is content above it */
.nav[data-scrolled='true'] {
    border-bottom-color: var(--line);
}

.nav__inner {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
    display: flex;
    align-items: center;
    gap: var(--s-6);
}

.wordmark {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.16em;
    color: var(--paper);
    margin-right: auto;
}

.nav__links {
    display: flex;
    align-items: center;
    gap: var(--s-5);
}

.nav__links > a {
    font-size: var(--text-sm);
    color: var(--paper-dim);
    transition: color var(--dur-2) var(--ease-out);
}

.nav__links > a:hover {
    color: var(--paper);
}

.nav__tools {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding-left: var(--s-5);
    border-left: 1px solid var(--line);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    color: var(--paper-dim);
    transition: color var(--dur-2) var(--ease-out),
                background var(--dur-2) var(--ease-out);
}

.icon-btn:hover {
    color: var(--paper);
    background: var(--ink-800);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
    display: none;
}

.lang {
    display: flex;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.08em;
}

/* Keyed on the class the script toggles, not on the element */
.lang-btn {
    padding: var(--s-1) var(--s-2);
    color: var(--paper-mute);
    transition: color var(--dur-2) var(--ease-out);
}

.lang-btn:hover {
    color: var(--paper-dim);
}

.lang-btn.active {
    color: var(--paper);
}

.burger {
    display: none;
    width: 32px;
    height: 32px;
    place-items: center;
}

.burger span {
    display: block;
    width: 16px;
    height: 1px;
    background: var(--paper);
    transition: transform var(--dur-2) var(--ease-out),
                opacity var(--dur-1) var(--ease-out);
}

.burger span + span {
    margin-top: 4px;
}

.burger.active span:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
}

.burger.active span:nth-child(2) {
    opacity: 0;
}

.burger.active span:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
}

/* -------------------------------------------------------------- footer */

.footer {
    padding-block: var(--s-8) var(--s-6);
    border-top: 1px solid var(--line);
}

.footer__grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--s-7);
    align-items: start;
}

.footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2) var(--s-5);
}

.footer__links a {
    font-size: var(--text-sm);
    color: var(--paper-dim);
    transition: color var(--dur-2) var(--ease-out);
}

.footer__links a:hover {
    color: var(--paper);
}

.footer__base {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--s-3);
    margin-top: var(--s-7);
    padding-top: var(--s-5);
    border-top: 1px solid var(--line);
    font-size: var(--text-sm);
    color: var(--paper-mute);
}

/* --------------------------------------------------------------- focus */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

.skip-link {
    position: absolute;
    left: var(--s-4);
    top: var(--s-4);
    z-index: 200;
    padding: var(--s-3) var(--s-4);
    background: var(--paper);
    color: var(--ink-900);
    border-radius: var(--r-md);
    font-size: var(--text-sm);
    transform: translateY(-200%);
    transition: transform var(--dur-2) var(--ease-out);
}

.skip-link:focus {
    transform: translateY(0);
}

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

/* One entrance, on load, once. Lines rise from behind a mask rather than
   fading in. No scroll observers anywhere on the site. */
.reveal {
    display: block;
    overflow: hidden;
}

.reveal > * {
    display: block;
    animation: rise var(--dur-4) var(--ease-out) both;
}

.reveal:nth-of-type(2) > * { animation-delay: 70ms; }
.reveal:nth-of-type(3) > * { animation-delay: 140ms; }

@keyframes rise {
    from { transform: translateY(105%); }
    to   { transform: translateY(0); }
}

/* Non-text blocks that accompany a revealed heading */
.reveal-soft {
    animation: settle var(--dur-4) var(--ease-out) both;
    animation-delay: 240ms;
}

@keyframes settle {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-delay: 0ms !important;
        transition-duration: 1ms !important;
    }

    .reveal > *,
    .reveal-soft {
        transform: none;
        opacity: 1;
    }
}

/* --------------------------------------------------------- responsive */

@media (max-width: 900px) {
    :root {
        --s-10: 5rem;
        --s-9: 4rem;
    }

    .burger {
        display: grid;
        margin-left: auto;
    }

    .wordmark {
        margin-right: 0;
    }

    .nav__links {
        position: fixed;
        inset: var(--nav-h) 0 auto;
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
        padding: var(--s-5) var(--gutter) var(--s-6);
        background: var(--ink-800);
        border-bottom: 1px solid var(--line);
        clip-path: inset(0 0 100% 0);
        transition: clip-path var(--dur-3) var(--ease-out);
    }

    .nav__links.active {
        clip-path: inset(0 0 0 0);
    }

    .nav__links > a {
        width: 100%;
        padding-block: var(--s-4);
        border-bottom: 1px solid var(--line);
        font-size: var(--text-base);
    }

    .nav__tools {
        width: 100%;
        padding: var(--s-5) 0 0;
        border-left: 0;
    }

    .footer__grid {
        grid-template-columns: 1fr;
    }
}
