/* ============================================================
   Collin Wittenstein - Personal Site (Reworked)
   Shared stylesheet for index.html and impressum.html
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --ink: #1A1A1A;
    --paper: #ffffff;
    --crimson: #9B001F;
    --slate: #565B66;
    --steel: #1F6F8B;
    --sage: #4C9F70;
    --ochre: #C77F0A;
    --purple: #6A4C93;
    --sun: #C77F0A;
    --coral: #9B001F;

    --nav-width: 200px;
    --content-gap: 28px;
    --radius-card: 24px;
    --radius-pill: 999px;
    --shadow-card: 8px 8px 0 rgba(86, 91, 102, 0.14);
    --border-card: 2px solid rgba(86, 91, 102, 0.42);
    --font-body: 'Arial Rounded MT Bold', 'Trebuchet MS', Arial, sans-serif;
    --font-mono: 'Courier New', monospace;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 12% 6%, rgba(155, 0, 31, 0.08), transparent 24rem),
        radial-gradient(circle at 88% 12%, rgba(86, 91, 102, 0.10), transparent 26rem),
        var(--paper);
    color: var(--ink);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.24;
    background-image:
        linear-gradient(rgba(86, 91, 102, 0.075) 1px, transparent 1px),
        linear-gradient(90deg, rgba(86, 91, 102, 0.075) 1px, transparent 1px),
        linear-gradient(rgba(31, 111, 139, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 111, 139, 0.055) 1px, transparent 1px);
    background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
    -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.72), rgba(0,0,0,0.20));
    mask-image: linear-gradient(180deg, rgba(0,0,0,0.72), rgba(0,0,0,0.20));
}

/* --- Links --- */
a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 2px solid var(--crimson);
    font-weight: 700;
    transition: color 0.16s ease, border-color 0.16s ease;
}

a:hover,
a:focus-visible {
    color: var(--crimson);
    border-bottom-color: var(--ink);
}

/* --- Typography --- */
h1 {
    font-size: clamp(52px, 10vw, 120px);
    font-weight: 900;
    line-height: 0.92;
    color: var(--ink);
    max-width: 920px;
    text-wrap: balance;
    overflow-wrap: break-word;
}

h2 {
    font-size: clamp(40px, 7vw, 86px);
    font-weight: 900;
    line-height: 0.92;
    color: var(--ink);
    text-wrap: balance;
    overflow-wrap: break-word;
    margin-bottom: 36px;
}

h3 {
    font-size: 24px;
    font-weight: 900;
    margin: 36px 0 16px;
    color: var(--ink);
}

p {
    font-size: 18px;
    line-height: 1.65;
    max-width: 820px;
    color: var(--ink);
    overflow-wrap: break-word;
    margin-bottom: 18px;
}

/* --- Doodle Field (background decorations) --- */
.doodle-field {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.doodle-field::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.58;
    background-image:
        linear-gradient(rgba(86, 91, 102, 0.075) 1px, transparent 1px),
        linear-gradient(90deg, rgba(86, 91, 102, 0.075) 1px, transparent 1px),
        linear-gradient(rgba(31, 111, 139, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 111, 139, 0.055) 1px, transparent 1px);
    background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
    -webkit-mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0.30) 66%, rgba(0, 0, 0, 0.12));
    mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0.30) 66%, rgba(0, 0, 0, 0.12));
}

.doodle {
    position: absolute;
    display: grid;
    place-items: center;
    color: var(--ink);
    font-family: var(--font-mono);
    font-weight: 900;
    line-height: 1;
    opacity: 0.52;
    animation: doodleFloat var(--duration, 10s) ease-in-out infinite;
    transition: opacity 0.6s ease;
    will-change: transform;
    z-index: 1;
}

.doodle.symbol {
    min-width: 56px;
    min-height: 56px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.82);
    border: 2px solid var(--fill, var(--crimson));
    border-radius: var(--radius-pill);
    font-size: clamp(20px, 2.6vw, 32px);
    transform: rotate(var(--rot, 0deg));
    letter-spacing: 0.02em;
}

.doodle.loop,
.doodle.spark,
.doodle.branch {
    border: 2px solid var(--fill, var(--slate));
    background: transparent;
}

.doodle.loop {
    width: 82px;
    height: 42px;
    border-radius: 50%;
    transform: rotate(var(--rot, 0deg));
}

.doodle.spark {
    width: 36px;
    height: 36px;
    border-width: 0;
}

.doodle.spark::before,
.doodle.spark::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 38px;
    background: var(--fill, var(--slate));
    border-radius: 99px;
    transform: translate(-50%, -50%);
}

.doodle.spark::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.doodle.branch {
    width: 92px;
    height: 50px;
    border-left: 0;
    border-bottom: 0;
    border-radius: 0 50px 0 0;
    transform: rotate(var(--rot, 0deg));
}

.doodle.branch::before,
.doodle.branch::after {
    content: "";
    position: absolute;
    right: 4px;
    width: 24px;
    height: 18px;
    border: 2px solid var(--fill, var(--slate));
    border-left: 0;
    border-bottom: 0;
    border-radius: 0 24px 0 0;
}

.doodle.branch::before { top: -4px; transform: rotate(-36deg); }
.doodle.branch::after { top: 18px; transform: rotate(36deg); }

.doodle:nth-child(1) { left: 24%; top: 7%; --fill: var(--sage); --duration: 12s; --rot: -2deg; }
.doodle:nth-child(2) { right: 9%; top: 15%; --fill: var(--slate); --duration: 15s; --rot: 2deg; }
.doodle:nth-child(3) { left: 45%; top: 4%; --fill: var(--purple); --duration: 11s; --rot: 1deg; }
.doodle:nth-child(4) { right: 16%; top: 42%; --fill: var(--ochre); --duration: 13s; --rot: -1deg; }
.doodle:nth-child(5) { left: 18%; top: 61%; --fill: var(--steel); --duration: 16s; --rot: -3deg; }
.doodle:nth-child(6) { right: 8%; bottom: 10%; --fill: var(--steel); --duration: 14s; --rot: 2deg; }
.doodle:nth-child(7) { left: 50%; bottom: 7%; --fill: var(--slate); --duration: 10s; --rot: 3deg; }
.doodle:nth-child(8) { left: 24%; bottom: 24%; --fill: var(--crimson); --duration: 17s; --rot: -2deg; }

.thematic-doodle {
    position: absolute;
    width: clamp(48px, 5.5vw, 76px);
    height: auto;
    opacity: 0.48;
    animation: doodleFloat var(--duration, 12s) ease-in-out infinite;
    transition: opacity 0.6s ease;
    will-change: transform;
    z-index: 1;
}

.thematic-doodle:nth-of-type(1) { left: 30%; top: 20%; --duration: 13s; }
.thematic-doodle:nth-of-type(2) { right: 7%; top: 31%; --duration: 15s; }
.thematic-doodle:nth-of-type(3) { left: 21%; top: 43%; --duration: 16s; }
.thematic-doodle:nth-of-type(4) { right: 13%; bottom: 28%; --duration: 14s; }
.thematic-doodle:nth-of-type(5) { left: 36%; bottom: 13%; --duration: 17s; }
.thematic-doodle:nth-of-type(6) { right: 29%; top: 8%; --duration: 12s; }
.thematic-doodle:nth-of-type(7) { left: 58%; top: 54%; --duration: 18s; }
.thematic-doodle:nth-of-type(8) { left: 16%; bottom: 7%; --duration: 15s; }
.thematic-doodle:nth-of-type(9) { right: 22%; bottom: 8%; --duration: 16s; }

@keyframes doodleFloat {
    0%, 100% { translate: 0 0; rotate: 0deg; }
    50% { translate: 0 -10px; rotate: 0.6deg; }
}

/* --- Side Navigation --- */
.side-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--nav-width);
    height: 100vh;
    background:
        radial-gradient(circle at 28px 32px, rgba(155, 0, 31, 0.10), transparent 76px),
        radial-gradient(circle at 170px 220px, rgba(31, 111, 139, 0.10), transparent 92px),
        rgba(255, 255, 255, 0.94);
    z-index: 1000;
    padding: 34px 14px;
    transition: transform 0.3s ease;
    border-right: 2px solid rgba(86, 91, 102, 0.28);
    border-radius: 0 26px 26px 0;
    box-shadow: 8px 0 0 rgba(86, 91, 102, 0.10);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.side-nav::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 2px dashed rgba(86, 91, 102, 0.14);
    border-radius: 0 20px 20px 0;
    pointer-events: none;
}

.side-nav::after {
    content: "\2207";
    position: absolute;
    right: 16px;
    bottom: 18px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--crimson);
    border: 2px solid rgba(155, 0, 31, 0.32);
    border-radius: 999px 999px 999px 12px;
    background: rgba(155, 0, 31, 0.06);
    font-family: var(--font-mono);
    font-weight: 900;
    opacity: 0.82;
}

.side-nav .logo {
    position: relative;
    display: block;
    font-size: 24px;
    font-weight: 900;
    color: var(--ink);
    padding: 12px 12px 18px;
    text-transform: uppercase;
    letter-spacing: 0;
    border-bottom: 2px solid var(--crimson);
    margin-bottom: 20px;
    text-decoration: none;
    border-bottom-color: var(--crimson);
    z-index: 1;
}

.side-nav .logo:hover {
    color: var(--crimson);
}

.side-nav a:not(.logo) {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 42px;
    color: var(--ink);
    text-decoration: none;
    padding: 10px 13px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    border: 1px solid rgba(86, 91, 102, 0.18);
    border-left: 4px solid transparent;
    border-radius: 999px;
    border-bottom: none;
    background: rgba(255, 255, 255, 0.68);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    z-index: 1;
}

.side-nav a:not(.logo):hover,
.side-nav a:not(.logo).active {
    background: rgba(155, 0, 31, 0.08);
    color: var(--ink);
    border-left-color: var(--crimson);
    border-color: rgba(155, 0, 31, 0.32);
    box-shadow: 4px 4px 0 rgba(86, 91, 102, 0.12);
    transform: translateX(3px) rotate(-0.4deg);
}

/* --- Mobile Menu Toggle --- */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 22px;
    left: 22px;
    z-index: 1001;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    border: 2px solid var(--crimson);
    padding: 8px 12px 8px 10px;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    border-radius: var(--radius-pill);
    min-width: 96px;
    height: 42px;
    line-height: 1;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
    box-shadow: 5px 5px 0 rgba(86, 91, 102, 0.16);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus-visible,
.mobile-menu-toggle.is-open {
    background: var(--crimson);
    color: #fff;
    outline: none;
    transform: translateY(-1px);
}

.mobile-menu-toggle.is-open {
    box-shadow: 3px 3px 0 rgba(86, 91, 102, 0.18);
}

.nav-toggle-icon {
    position: relative;
    width: 18px;
    height: 14px;
    display: inline-grid;
    align-items: center;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after,
.nav-toggle-icon span {
    content: "";
    display: block;
    width: 18px;
    height: 2px;
    border-radius: var(--radius-pill);
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle-icon::before { transform: translateY(-4px); }
.nav-toggle-icon::after { transform: translateY(4px); }
.mobile-menu-toggle.is-open .nav-toggle-icon span { opacity: 0; }
.mobile-menu-toggle.is-open .nav-toggle-icon::before { transform: translateY(2px) rotate(45deg); }
.mobile-menu-toggle.is-open .nav-toggle-icon::after { transform: translateY(-2px) rotate(-45deg); }

.mobile-menu-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* Mobile Backdrop */
.mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.38);
    backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.mobile-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 2;
    margin-left: calc(var(--nav-width) + 20px);
    padding: var(--content-gap);
    max-width: calc(100vw - var(--nav-width) - 20px);
}

/* --- Section Cards --- */
section {
    margin: 0 0 var(--content-gap);
    padding: clamp(46px, 7vw, 92px);
    border: var(--border-card);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

section::before {
    content: "";
    position: absolute;
    inset: 16px;
    border: 2px dashed rgba(86, 91, 102, 0.18);
    border-radius: 20px;
    pointer-events: none;
}

#legal-notice h1 {
    margin-bottom: clamp(34px, 5vw, 56px);
}

.legal-contact {
    margin-bottom: 34px;
}

/* --- Utility classes --- */
.subtitle {
    font-size: 18px;
    font-weight: 700;
    color: var(--slate);
}

.h3-small {
    font-size: 20px;
}

.caption {
    font-size: 0.75rem;
    color: var(--slate);
    margin-top: 0.3rem;
    text-align: left;
}

.geothermal-banner-link {
    display: inline-block;
    margin: 40px 0;
    text-decoration: none;
    border: none;
}

.geothermal-banner-link:hover,
.geothermal-banner-link:focus-visible {
    border: none;
}

/* Remove tap highlight from clickable images */
img {
    -webkit-tap-highlight-color: transparent;
}

/* --- About Section --- */
#about {
    min-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        linear-gradient(90deg, rgba(155, 0, 31, 0.10), transparent 34%),
        var(--paper);
}

#about::after {
    content: "{ PDEs }";
    position: absolute;
    right: clamp(20px, 8vw, 90px);
    top: clamp(18px, 6vw, 70px);
    padding: 10px 16px;
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    background: var(--paper);
    font-family: var(--font-mono);
    font-weight: 900;
    transform: rotate(1deg);
    animation: doodleFloat 9s ease-in-out infinite;
}

.accent-box {
    display: inline-block;
    background: var(--coral);
    color: #fff;
    padding: 20px;
    font-weight: 700;
    transform: rotate(-0.5deg);
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    box-shadow: 6px 6px 0 rgba(86, 91, 102, 0.16);
    max-width: 100%;
    line-height: 1.2;
    margin: 20px 0;
}

.about-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 60px;
    margin-top: 40px;
}

.headshot-figure {
    margin: 0;
}

#headshot-container {
    position: relative;
    width: 100%;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#headshot-container img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    transition: opacity 0.8s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#headshot {
    position: relative;
    opacity: 1;
}

#headshot-easter {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#headshot-easter.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.headshot-caption {
    margin-top: 6px;
    color: rgba(86, 91, 102, 0.72);
    font-size: 0.68rem;
    line-height: 1.25;
    text-align: right;
}

/* --- Publications --- */
.pub-item {
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    color: var(--ink);
    padding: 28px;
    margin: 16px 0;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    max-width: 700px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pub-item:hover {
    transform: translate(-3px, -3px);
    box-shadow: 12px 12px 0 rgba(86, 91, 102, 0.18);
}

.pub-title {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 8px;
    line-height: 1.25;
}

.pub-title a {
    color: var(--ink);
    border-bottom: 2px solid var(--crimson);
}

.pub-title a:hover {
    color: var(--crimson);
    border-bottom-color: var(--ink);
}

.pub-authors {
    font-size: 15px;
    color: var(--slate);
    margin-bottom: 4px;
}

.pub-venue {
    font-size: 15px;
    color: var(--slate);
}

.status-message,
.error-message {
    padding: 20px;
    background: rgba(255, 255, 255, 0.78);
    border: var(--border-card);
    border-radius: 16px;
    margin: 20px 0;
}

.update-banner {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.04);
    border-left: 4px solid var(--crimson);
    margin-bottom: 30px;
    font-size: 15px;
    color: var(--ink);
    line-height: 1.8;
    border-radius: 0 12px 12px 0;
}

.update-banner a {
    color: var(--crimson);
    border-bottom-color: var(--crimson);
}

/* --- Research --- */
.research-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    margin-right: 14px;
    padding: 4px 10px;
    background: #fff;
    color: var(--ink);
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 0.72em;
    line-height: 1;
    text-transform: none;
    vertical-align: middle;
    transform: rotate(-1deg);
}

.video-brutal {
    width: 100%;
    max-width: 700px;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    margin: 40px 0;
}

.video-container {
    margin-top: 1.5rem;
    border-radius: 22px;
    overflow: hidden;
}

.related-links {
    margin: 20px 0;
    max-width: 800px;
}

.related-links ul {
    margin-left: 20px;
}

.related-links li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.related-links a {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* --- Open Source --- */
.repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.repo-card {
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 28px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.repo-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 12px 12px 0 rgba(86, 91, 102, 0.18);
}

.repo-name {
    font-weight: 900;
    margin-bottom: 10px;
}

.repo-description {
    font-size: 16px;
    color: var(--ink);
    margin-bottom: 15px;
}

.contribution-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.contribution-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 700;
    background: #fff;
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    color: var(--ink);
    transition: background 0.15s ease;
}

.contribution-badge:hover {
    background: rgba(155, 0, 31, 0.12);
    color: var(--ink);
}

.repo-language {
    font-size: 13px;
    color: var(--slate);
}

/* --- CV --- */
.cv-download-section {
    margin: 30px 0;
    padding: 25px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.download-btn {
    display: inline-block;
    background: #fff;
    color: var(--ink);
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 700;
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    transition: all 0.2s ease;
}

.download-btn:hover {
    background: var(--crimson);
    color: #fff;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.12);
}

.cv-section {
    margin-bottom: 40px;
}

.cv-list {
    margin: 10px 0 10px 20px;
}

.cv-list li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* --- Book Browser --- */
.book-pages {
    position: relative;
    max-width: 680px;
    margin: 40px 0 96px 0;
    min-height: 470px;
    touch-action: pan-y pinch-zoom;
    outline: none;
}

.book-pages:focus-visible {
    outline: 3px solid rgba(155, 0, 31, 0.45);
    outline-offset: 10px;
}

.book-page {
    width: min(100%, 560px);
    min-height: 430px;
    max-height: 470px;
    background: #fff;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    padding: clamp(24px, 4vw, 34px);
    position: absolute;
    top: 0;
    left: 50%;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-50%) translateY(12px) scale(0.92);
    transition: transform 0.38s ease, opacity 0.38s ease, visibility 0.38s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
}

.book-page.current,
.book-page.is-current {
    z-index: 10;
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.book-page.next,
.book-page.is-next {
    z-index: 5;
    transform: translateX(calc(-50% + 90px)) translateY(18px) scale(0.94);
    opacity: 0.42;
    visibility: visible;
}

.book-page.prev,
.book-page.is-prev {
    z-index: 5;
    transform: translateX(calc(-50% - 90px)) translateY(18px) scale(0.94);
    opacity: 0.42;
    visibility: visible;
}

.book-page.hidden,
.book-page.is-hidden {
    z-index: 1;
}

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page-title {
    font-weight: 900;
    font-size: 26px;
    margin-bottom: 5px;
    line-height: 1.2;
}

.page-author {
    font-size: 17px;
    font-weight: 700;
    color: var(--slate);
}

.page-description {
    font-size: 14px;
    color: #555;
    line-height: 1.5;
    margin-top: 20px;
    margin-bottom: 10px;
    max-width: 100%;
}

.page-quote {
    font-style: italic;
    font-size: 15px;
    color: #333;
    line-height: 1.4;
    margin-top: 15px;
    padding: 15px 20px;
    background: rgba(155, 0, 31, 0.05);
    border-left: 4px solid rgba(155, 0, 31, 0.3);
    border-radius: 0 12px 12px 0;
    position: relative;
    text-align: left;
}

.page-quote::before {
    content: '\201C';
    font-size: 40px;
    color: rgba(155, 0, 31, 0.4);
    position: absolute;
    top: -5px;
    left: 5px;
    font-family: serif;
}

.page-quote::after {
    content: '\201D';
    font-size: 40px;
    color: rgba(155, 0, 31, 0.4);
    position: absolute;
    bottom: -15px;
    right: 5px;
    font-family: serif;
}

.page-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.94);
    color: var(--crimson);
    border: 2px solid var(--crimson);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 900;
    z-index: 20;
    box-shadow: 4px 4px 0 rgba(86, 91, 102, 0.14);
    -webkit-tap-highlight-color: transparent;
}

.page-nav:hover,
.page-nav:focus-visible {
    background: var(--crimson);
    border-color: var(--crimson);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.page-nav-prev { left: 0; }
.page-nav-next { right: 0; }

.page-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%) scale(0.9);
}

/* Progress dots hidden by default */
.book-progress { display: none; }

.page-flip-hint {
    position: absolute;
    bottom: -92px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    color: #666;
    font-style: italic;
    text-align: center;
    width: min(100%, 560px);
}

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

/* --- Footer --- */
.footer-brutal {
    position: relative;
    z-index: 2;
    background:
        radial-gradient(circle at 48px 34px, rgba(155, 0, 31, 0.10), transparent 96px),
        radial-gradient(circle at calc(100% - 60px) 80%, rgba(31, 111, 139, 0.10), transparent 110px),
        rgba(255, 255, 255, 0.92);
    color: var(--ink);
    padding: 40px 50px;
    margin-left: calc(var(--nav-width) + 20px);
    margin-right: var(--content-gap);
    margin-bottom: var(--content-gap);
    border: 2px solid rgba(86, 91, 102, 0.28);
    border-radius: 26px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.footer-brutal::before {
    content: "";
    position: absolute;
    inset: 16px;
    border: 2px dashed rgba(86, 91, 102, 0.14);
    border-radius: 20px;
    pointer-events: none;
}

.footer-brutal::after {
    content: "\03BB";
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--crimson);
    border: 2px solid rgba(155, 0, 31, 0.32);
    border-radius: 999px 999px 999px 12px;
    background: rgba(155, 0, 31, 0.06);
    font-family: var(--font-mono);
    font-weight: 900;
    opacity: 0.82;
}

.footer-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 28px;
    align-items: end;
}

.footer-title {
    font-weight: 900;
    font-size: 18px;
    margin-bottom: 14px;
    color: var(--ink);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.footer-links a,
.footer-meta a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid rgba(86, 91, 102, 0.18);
    border-radius: var(--radius-pill);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.68);
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.footer-links a:hover,
.footer-meta a:hover {
    background: rgba(155, 0, 31, 0.08);
    color: var(--ink);
    border-color: rgba(155, 0, 31, 0.32);
    box-shadow: 4px 4px 0 rgba(86, 91, 102, 0.12);
    transform: translateY(-1px) rotate(-0.4deg);
}

.footer-meta {
    color: var(--slate);
    text-align: right;
    line-height: 1.8;
    font-weight: 800;
}

/* --- Easter Egg: Go Brrrr --- */
@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5px, -5px); }
    20% { transform: translate(5px, 5px); }
    30% { transform: translate(-5px, 5px); }
    40% { transform: translate(5px, -5px); }
    50% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    70% { transform: translate(-5px, 5px); }
    80% { transform: translate(5px, -5px); }
    90% { transform: translate(-3px, 3px); }
}

.brrrr-shake { animation: shake 0.5s ease-in-out; }

#gpu-meter {
    position: fixed;
    right: clamp(16px, 4vw, 28px);
    bottom: clamp(16px, 4vw, 28px);
    width: min(330px, calc(100vw - 32px));
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    padding: 18px;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: 22px;
    font-family: var(--font-body);
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(18px) scale(0.96);
    transition: opacity 0.24s ease, transform 0.24s ease;
    pointer-events: none;
    box-shadow: 8px 8px 0 rgba(86, 91, 102, 0.14);
    backdrop-filter: blur(10px);
}

#gpu-meter.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.gpu-meter-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.gpu-meter-title {
    display: block;
    color: var(--crimson);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.gpu-meter-subtitle {
    display: block;
    margin-top: 3px;
    color: var(--slate);
    font-size: 12px;
    font-weight: 800;
}

#gpu-percent {
    min-width: 58px;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 900;
    line-height: 1;
    text-align: right;
}

.gpu-bar {
    width: 100%;
    height: 18px;
    background: rgba(86, 91, 102, 0.12);
    border: 2px solid rgba(86, 91, 102, 0.42);
    border-radius: 999px;
    overflow: hidden;
}

.gpu-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sage), var(--ochre), var(--crimson));
    width: 0%;
    transition: width 0.1s linear;
    border-radius: inherit;
}

.gpu-meter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    color: var(--slate);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.gpu-meter-chip {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border: 1px solid rgba(155, 0, 31, 0.28);
    border-radius: 999px;
    background: rgba(155, 0, 31, 0.06);
    color: var(--crimson);
}

/* --- Cursor doodles --- */
.cursor-doodle {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    width: 14px;
    height: 14px;
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    background: #fff;
    animation: cursorPop 900ms ease-out forwards;
}

@keyframes cursorPop {
    to { transform: translateY(-32px) scale(0.2); opacity: 0; }
}

/* --- Show More Button (open source) --- */
.show-more-btn {
    background: var(--ink);
    color: #fff;
    padding: 12px 24px;
    border: 2px solid var(--crimson);
    border-radius: var(--radius-pill);
    font-weight: 700;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.show-more-btn:hover {
    background: var(--crimson);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.12);
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .doodle,
    .thematic-doodle,
    #about::after,
    .cursor-doodle {
        animation: none !important;
        transition: none !important;
    }

    .book-page,
    .page-nav,
    .pub-item,
    .repo-card {
        transition: none;
    }
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }

    .mobile-backdrop {
        display: block;
    }

    .side-nav {
        transform: translateX(-100%);
        box-shadow: none;
        width: min(84vw, 310px);
        padding: 86px 0 28px;
        border-right: 2px solid rgba(86, 91, 102, 0.28);
        border-radius: 0 26px 26px 0;
    }

    .side-nav.open {
        transform: translateX(0);
        box-shadow: 12px 0 34px rgba(26, 26, 26, 0.18);
    }

    .side-nav .logo {
        padding-bottom: 24px;
        margin-bottom: 20px;
    }

    .side-nav a:not(.logo) {
        margin: 4px 18px 4px 14px;
        padding: 13px 16px;
        border: 1px solid rgba(86, 91, 102, 0.18);
        border-left: 4px solid transparent;
        border-radius: 999px;
    }

    .side-nav a:not(.logo):hover,
    .side-nav a:not(.logo).active {
        transform: none;
        border-color: rgba(155, 0, 31, 0.32);
    }

    /* Hide active indicator when sidebar is closed */
    .side-nav:not(.open) a:not(.logo).active {
        background: transparent !important;
        border-left-color: transparent !important;
        transform: none !important;
    }

    .main-content {
        margin-left: 0;
        padding: 14px;
        max-width: 100%;
        width: auto;
    }

    section {
        margin-bottom: 14px;
        padding: 64px 24px 44px;
        border-radius: 20px;
        box-shadow: 6px 6px 0 rgba(23, 32, 29, 0.18);
        width: auto;
        max-width: 100%;
    }

    #about {
        min-height: auto;
        padding-top: 86px;
    }

    #about::after {
        display: none;
    }

    h1 {
        font-size: clamp(42px, 13vw, 50px);
    }

    h2 {
        font-size: 36px;
    }

    h3 {
        font-size: 22px;
    }

    p {
        font-size: 15px;
        line-height: 1.55;
        max-width: 100%;
    }

    .about-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .about-grid > div {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    .accent-box {
        display: block;
        width: fit-content;
        max-width: 100%;
        padding: 14px 16px;
        border-radius: 18px;
        font-size: 14px;
    }

    #headshot-container img {
        height: auto;
    }

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

    .repo-card {
        padding: 20px;
    }

    .repo-description {
        font-size: 14px;
    }

    .footer-brutal {
        margin: 0 14px 14px;
        padding: 40px 20px;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .footer-links {
        gap: 8px;
    }

    .footer-links a,
    .footer-meta a {
        min-height: 34px;
        padding: 5px 10px;
        font-size: 14px;
    }

    .footer-meta {
        text-align: left;
    }

    /* Doodles: softer on mobile */
    .doodle-field {
        opacity: 0.45;
    }

    .doodle:nth-child(2),
    .doodle:nth-child(5),
    .doodle:nth-child(7),
    .doodle:nth-child(10),
    .doodle:nth-child(12),
    .doodle:nth-child(14) {
        opacity: 0;
        visibility: hidden;
    }

    .thematic-doodle {
        width: 44px;
        opacity: 0.32;
    }

    .thematic-doodle:nth-of-type(1),
    .thematic-doodle:nth-of-type(3),
    .thematic-doodle:nth-of-type(5),
    .thematic-doodle:nth-of-type(7),
    .thematic-doodle:nth-of-type(9),
    .thematic-doodle:nth-of-type(11),
    .thematic-doodle:nth-of-type(13),
    .thematic-doodle:nth-of-type(15) {
        opacity: 0;
        visibility: hidden;
    }

    /* Book browser mobile */
    .book-pages {
        max-width: 100%;
        margin: 30px 0 132px 0;
        min-height: 480px;
    }

    .book-page {
        width: calc(100% - 28px);
        min-height: 460px;
        max-height: 500px;
        padding: 30px 20px;
    }

    .page-title {
        font-size: 22px;
    }

    .page-author {
        font-size: 18px;
    }

    .page-description {
        font-size: 13px;
        margin-bottom: 15px;
    }

    .page-quote {
        font-size: 14px;
        padding: 12px 18px;
    }

    .page-quote::before,
    .page-quote::after {
        font-size: 30px;
    }

    .page-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .book-page.next,
    .book-page.is-next {
        transform: translateX(calc(-50% + 38px)) translateY(18px) scale(0.92);
        opacity: 0.28;
    }

    .book-page.prev,
    .book-page.is-prev {
        transform: translateX(calc(-50% - 38px)) translateY(18px) scale(0.92);
        opacity: 0.28;
    }

    .page-flip-hint {
        display: none;
    }
}

/* --- Geothermal banner image --- */
.geothermal-banner {
    display: block;
    width: 100%;
    max-width: 700px;
    border: 2px solid rgba(86, 91, 102, 0.58);
    border-radius: 22px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease;
}

.geothermal-banner:hover {
    transform: translate(-3px, -3px);
}

/* Rattleback image */
.rattleback-img {
    width: 100%;
    max-width: 700px;
    display: block;
    border-radius: 16px;
    margin: 0 auto 0 0;
}
