/* Neubrutalist version of the site: cream paper, thick ink outlines, hard offset shadows, flat bright fills,
   buttons that press into their shadow. Fonts are hosted on this server (fonts/, SIL Open Font License). */
@font-face {
    font-family: 'Jersey 10';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/jersey-10-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Jersey 10';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/jersey-10-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Jersey 10 has no → and ←: this tiny self-made font fills them in */
@font-face {
    font-family: 'Jersey 10';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/jersey-10-arrow.woff2?v=2') format('woff2');
    unicode-range: U+2190, U+2192;
}

/* Running text (variable fonts: one file for weights 400-700) */
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/ibm-plex-sans-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/ibm-plex-sans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Labels, tags, code */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Colors: light (the default for neubrutalism) ---------- */
:root {
    color-scheme: light;

    --paper: #FFF4DF;        /* page background */
    --paper-dots: #E9D9B8;   /* dot grid on the paper */
    --card: #FFFFFF;         /* panels */
    --ink: #111111;          /* text, outlines, shadows */
    --ink-soft: #2B2B2B;     /* running text */
    --ink-muted: #5E574B;    /* dates, hints */
    --on-fill: #111111;      /* text on the bright fills, in both themes */

    /* Bright fills: the same in both themes, always with black text on them */
    --yellow: #FFD23F;
    --pink: #FF7AB6;
    --mint: #3EE6A8;
    --blue: #5AA9FF;
    --orange: #FF8A3D;
    --red: #FF5A5A;

    --icon-filter: brightness(0);              /* nav icons in ink */

    --line: 3px;          /* outline width */
    --shadow: 6px;        /* shadow offset of panels */
    --radius: 6px;

    /* Older names the page stylesheets still use, mapped onto the palette above */
    --color-background: var(--paper);
    --color-page: var(--paper);
    --color-primary: var(--ink);
    --color-secondary: var(--ink-muted);
    --color-accent: #D23C3C;
    --color-border: #1F5FD1;       /* links */
    --color-card: var(--card);
    --color-card-bar: var(--yellow);
    --color-line: var(--ink);
    --color-text-soft: var(--ink-soft);
    --color-screen: var(--paper);
    --color-live: #1F9A3D;
    --color-shadow: var(--ink);
    --shadow-soft: 4px 4px 0 var(--ink);
    --shadow-soft-up: none;

    /* Fonts */
    --font-display: 'Jersey 10', monospace;
    --font-body: 'IBM Plex Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --font-primary: var(--font-display);

    /* Layout */
    --page-width: 1240px;
    --nav-height: 64px;
    --nav-top: 12px;                    /* the nav floats this far below the top edge */
    --gutter: clamp(16px, 4vw, 40px);
    --bottom-bar: 0px;                  /* room the phone tab bar takes at the bottom */
}

/* ---------- Colors: dark ----------
   Black outlines vanish on a dark page, so the ink turns light; the bright fills stay */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --paper: #17171C;
        --paper-dots: #2A2A33;
        --card: #222229;
        --ink: #F3EEE3;
        --ink-soft: #D9D4CA;
        --ink-muted: #A9A296;
        --color-accent: #FF6B6B;
        --color-border: #7DB8FF;
        --color-live: #4CD964;
        --icon-filter: brightness(0) invert(0.94);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #17171C;
    --paper-dots: #2A2A33;
    --card: #222229;
    --ink: #F3EEE3;
    --ink-soft: #D9D4CA;
    --ink-muted: #A9A296;
    --color-accent: #FF6B6B;
    --color-border: #7DB8FF;
    --color-live: #4CD964;
    --icon-filter: brightness(0) invert(0.94);
}

/* Short landscape screens (phones held sideways): a slimmer bar */
@media screen and (max-height: 500px) {
    :root {
        --nav-height: 52px;
    }
}

html {
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--nav-height) + var(--nav-top) + 16px);
}

body {
    margin: 0;
    background-color: var(--paper);
    background-image: radial-gradient(var(--paper-dots) 1.5px, transparent 1.5px);
    background-size: 22px 22px;
    color: var(--ink);
    font-family: var(--font-body);
}

img {
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

:focus-visible {
    outline: 3px dashed var(--ink);
    outline-offset: 4px;
}

/* ---------- Navigation: a floating bar ---------- */
nav {
    position: fixed;
    top: var(--nav-top);
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    width: calc(100% - 2 * var(--gutter));
    max-width: var(--page-width);
    height: var(--nav-height);
    margin: 0 auto;
    padding: 0 10px;
    box-sizing: border-box;
    background-color: var(--card);
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    box-shadow: 4px 4px 0 var(--ink);
}

.home_button {
    display: flex;
}

.home_button a {
    display: grid;
    place-items: center;
    width: 48px;
    height: 42px;
    box-sizing: border-box;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    background-color: var(--yellow);
    box-shadow: 3px 3px 0 var(--ink);
    transition: translate 0.08s, box-shadow 0.08s;
}

/* 13 x 11 px pixel art, drawn at 2px per pixel; always black on the yellow */
.home_button img {
    width: 26px;
    height: 22px;
    image-rendering: pixelated;
    filter: brightness(0);
}

/* Desktop: the house is the only icon, the pages are text links */
.home_button span,
.page_selection img {
    display: none;
}

.page_selection {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.page_selection a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    box-sizing: border-box;
    border: var(--line) solid transparent;
    border-radius: var(--radius);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: clamp(22px, 2.2vw, 28px);
    text-decoration: none;
    white-space: nowrap;
    transition: translate 0.08s, box-shadow 0.08s;
}

.page_selection a.active {
    border-color: var(--ink);
    background-color: var(--pink);
    color: var(--on-fill);
    box-shadow: 3px 3px 0 var(--ink);
}

/* Light / dark switch: a blue box after the links (see theme.js) */
.theme_toggle[hidden] {
    display: none;
}

.theme_toggle {
    display: grid;
    place-items: center;
    flex: none;
    width: 48px;
    height: 42px;
    padding: 0;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    background-color: var(--blue);
    box-shadow: 3px 3px 0 var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: translate 0.08s, box-shadow 0.08s;
}

.theme_toggle img {
    display: block;
    width: 26px;
    height: 22px;
    image-rendering: pixelated;
    filter: brightness(0);
}

@media (hover: hover) {
    .page_selection a:not(.active):hover {
        border-color: var(--ink);
        background-color: var(--paper);
    }

    .home_button a:hover,
    .theme_toggle:hover {
        translate: -2px -2px;
        box-shadow: 5px 5px 0 var(--ink);
    }
}

.home_button a:active,
.page_selection a.active:active,
.theme_toggle:active {
    translate: 3px 3px;
    box-shadow: 0 0 0 var(--ink);
}

/* ---------- Page ---------- */
main {
    display: block;
    width: 100%;
    max-width: var(--page-width);
    min-height: 100vh;
    min-height: 100svh;
    margin: 0 auto;
    padding-top: calc(var(--nav-height) + var(--nav-top) + 8px);
    box-sizing: border-box;
}

/* Shared neubrutalist panel: outline + hard shadow */
.brutal {
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    background-color: var(--card);
    box-shadow: var(--shadow) var(--shadow) 0 var(--ink);
}

/* Big tilted page title on a yellow block */
.page_title {
    display: inline-block;
    margin: clamp(24px, 4vw, 40px) 0 0;
    padding: 4px 22px 8px;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    background-color: var(--yellow);
    box-shadow: var(--shadow) var(--shadow) 0 var(--ink);
    color: var(--on-fill);
    font-family: var(--font-display);
    font-size: clamp(52px, 8vw, 88px);
    font-weight: normal;
    line-height: 0.95;
    rotate: -1.5deg;
}

/* Main button: bright fill, presses into its shadow */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 26px 10px;
    border: var(--line) solid var(--ink);
    border-radius: var(--radius);
    background-color: var(--yellow);
    color: var(--on-fill);
    font-family: var(--font-display);
    font-size: 30px;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 5px 5px 0 var(--ink);
    transition: translate 0.08s, box-shadow 0.08s;
}

@media (hover: hover) {
    .btn:hover {
        translate: -2px -2px;
        box-shadow: 7px 7px 0 var(--ink);
    }
}

.btn:active {
    translate: 5px 5px;
    box-shadow: 0 0 0 var(--ink);
}

/* ---------- Phones: tab bar at the bottom, within thumb reach ---------- */
@media screen and (max-width: 760px) {
    :root {
        --shadow: 4px;
        --nav-top: 0px;
        --bottom-bar: calc(var(--nav-height) + 10px);
    }

    nav {
        gap: 0;
        width: auto;
        margin: 0 10px 10px;
        padding: 0 4px;
    }

    /* The two groups dissolve, so all tabs share the width evenly */
    .home_button,
    .page_selection {
        display: contents;
    }

    .home_button a,
    .page_selection a {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        width: auto;
        min-width: 0;
        height: calc(var(--nav-height) - 14px);
        min-height: 0;
        margin: 0 2px;
        padding: 0;
        border: 2px solid transparent;
        background-color: transparent;
        box-shadow: none;
        color: var(--ink);
        font-family: var(--font-display);
        font-size: 15px;
        line-height: 1;
        text-decoration: none;
        white-space: nowrap;
        -webkit-tap-highlight-color: transparent;
    }

    .home_button img,
    .page_selection img {
        display: block;
        width: 26px;
        height: 22px;
        margin: 0;
        image-rendering: pixelated;
        filter: var(--icon-filter);
    }

    .home_button span,
    .page_selection span {
        display: block;
        overflow: hidden;
        max-width: 100%;
        text-overflow: ellipsis;
    }

    .page_selection .wide {
        display: none;
    }

    .home_button a.active,
    .page_selection a.active {
        border-color: var(--ink);
        background-color: var(--pink);
        color: var(--on-fill);
        box-shadow: 2px 2px 0 var(--ink);
    }

    .home_button a.active {
        background-color: var(--yellow);
    }

    .home_button a.active img,
    .page_selection a.active img {
        filter: brightness(0);
    }
}

/* Phones held sideways: the label sits next to the icon */
@media screen and (max-width: 760px) and (max-height: 500px) {
    .home_button a,
    .page_selection a {
        flex-direction: row;
        gap: 8px;
    }
}

/* Phones: the document itself does not scroll, the page scrolls inside <main> and the tab bar sits below it in
   normal flow (not position: fixed). Firefox on Android collapses its address bar only when the document
   scrolls and re-anchors fixed elements with a visible jump each time; this way the tab bar never moves. */
@media screen and (max-width: 760px) {
    html,
    body {
        height: 100%;
        overflow: hidden;
    }

    body {
        display: flex;
        flex-direction: column;
    }

    main {
        flex: 1 1 auto;
        min-height: 0;
        padding-top: 64px;  /* the row the light/dark switch floats in */
        padding-bottom: 0;
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }

    /* Light / dark switch: floats in the top right corner, above the page */
    .theme_toggle {
        position: fixed;
        top: 10px;
        right: 12px;
        z-index: 5;
        width: 46px;
        height: 42px;
    }

    nav {
        position: static;
        order: 2;
        flex: none;
    }
}

/* No animated transitions for visitors who turned animations off */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ---------- Page switches: cross-fade, the nav bar stays in place ---------- */
@view-transition {
    navigation: auto;
}

nav {
    view-transition-name: site-nav;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 150ms;
}

@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }
}
