:root {
    /* Default Colors */
    --bg-color: #ECEAE5;
    --text-primary: #2B2A27;   /* 12:1 on the background */
    --text-secondary: #615E58; /* 5.4:1 on the background */
    --line-faint: color-mix(in srgb, var(--text-secondary) 30%, transparent); /* light lines: header track, Work page box */

    /* Surfaces */
    --bg-thumbnail: #DCD8D0;   /* hover backgrounds */
    --bg-card: #F4F3EF;        /* cards, menus, bottom bar */
    --border-card: #D9D6CF;
    --bg-project: #7A7771;     /* project thumbnails */
    --text-on-project: #ECEAE5; /* year on thumbnails, both themes */
    --shadow-color: rgba(43, 42, 39, 0.1);

    /* Pill Tags */
    --bg-pill: #E0DDD6;
    --text-pill: #54514B;
    --border-pill: #DCD9D2;

    /* Accent Colors (4.5:1+ as text) */
    --color-blue:   #0963D3;
    --color-green:  #0F7A39;
    --color-purple: #7E3FE6;
    --color-orange: #AB4C07;
    --color-pink:   #C22A66;

    --accent-color: var(--color-blue); /* links, hover and progress */

    --font-primary: "Figtree", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Typography Scale (1rem = 16px). Fluid sizes scale from 393px to 1280px */
    --text-logo: 1.75rem;   /* 28px, fixed to fit the header */
    --text-3xs:  0.6875rem; /* 11px */
    --text-2xs: clamp(0.75rem, 0.7223rem + 0.1127vw, 0.8125rem); /* 12 → 13px */
    --text-xs: clamp(0.875rem, 0.8473rem + 0.1127vw, 0.9375rem); /* 14 → 15px */
    --text-base: clamp(1rem, 0.9723rem + 0.1127vw, 1.0625rem); /* 16 → 17px (Base) */
    --text-md: clamp(1.125rem, 1.0696rem + 0.2255vw, 1.25rem); /* 18 → 20px */
    --text-lg: clamp(1.25rem, 1.1669rem + 0.3382vw, 1.4375rem); /* 20 → 23px */
    --text-xl: clamp(1.5rem, 1.3339rem + 0.6764vw, 1.875rem); /* 24 → 30px */
    --text-2xl: clamp(1.75rem, 1.4731rem + 1.1274vw, 2.375rem); /* 28 → 38px */
    --text-3xl: clamp(2rem, 1.5569rem + 1.8038vw, 3rem); /* 32 → 48px */
    --text-4xl:  2.5rem;    /* 40px */
    --text-5xl:  3rem;      /* 48px */
    --text-6xl:  3.5rem;    /* 56px */
    --text-7xl:  4rem;      /* 64px */
    --text-8xl:  4.5rem;    /* 72px */
    --text-9xl:  5rem;      /* 80px */

    /* Line Heights (Unitless) */
    --leading-none:   1;      /* For massive hero text (72px+) */
    --leading-tight:  1.15;   /* For headings (h1, h2, h3) */
    --leading-snug:   1.3;    /* For subheadings */
    --leading-normal: 1.5;    /* For body text */
    --leading-loose:  1.7;    /* For dense, long-form reading */

    /* Font Weights */
    --weight-regular:  400;   /* Body text */
    --weight-medium:   500;   /* Emphasized body text, menu items, pills */
    --weight-semibold: 600;   /* Headings, labels and the current item */

    /* Letter Spacing */
    --tracking-logo:  -0.08em; /* NORMANLEE wordmarks */
    --tracking-tight: -0.02em; /* Small text that needs to sit snug */
    --tracking-wide:   0.06em; /* Uppercase labels */

    /* Spacing Scale: md and up scale from 393px to 1280px */
    --space-xs:  0.25rem;   /* 4px  - tiny gaps */
    --space-sm:  0.5rem;    /* 8px  - tight padding, small margins */
    --space-md: clamp(1rem, 0.7785rem + 0.9019vw, 1.5rem); /* 16 → 24px - standard padding, component gaps */
    --space-lg: clamp(1.5rem, 1.2785rem + 0.9019vw, 2rem); /* 24 → 32px - larger padding, section margins */
    --space-xl: clamp(2rem, 1.5569rem + 1.8038vw, 3rem); /* 32 → 48px - generous whitespace */
    --space-2xl: clamp(2.5rem, 1.8354rem + 2.7057vw, 4rem); /* 40 → 64px - even more generous whitespace */
    --space-3xl: clamp(3rem, 2.1139rem + 3.6077vw, 5rem); /* 48 → 80px - major section breaks */
    --space-4xl: clamp(4rem, 2.6708rem + 5.4115vw, 7rem); /* 64 → 112px - massive page gaps */

    /* Content Width */
    --content-margin: 3rem;

    /* Header Height */
    --header-height: 56px;

    /* Left edge of the content, for fixed elements */
    --page-edge: max(var(--space-md), calc((100% - 1440px) / 2 + var(--space-md)));

    /* Header Blur */
    --header-bg: rgba(236, 234, 229, 0.8);
}

/* Dark Mode */
:root.dark-theme {
    /* Background & Text */
    --bg-color: #2A2A28;
    --text-primary: #ECEAE5;   /* 12:1 on the background */
    --text-secondary: #AEABA4; /* 6.3:1 on the background */

    /* Surfaces */
    --bg-card: #333331;
    --border-card: #4A4945;
    --bg-thumbnail: #46443F;
    --bg-project: #5C5B57;
    --bg-pill: #403F3C;
    --text-pill: #CFCCC5;
    --border-pill: #444340;
    --shadow-color: rgba(0, 0, 0, 0.3);

    /* Accent Colors */
    --color-blue:   #4D9BFF;
    --color-green:  #38D27A;
    --color-purple: #B47EFF;
    --color-orange: #FF9F45;
    --color-pink:   #FF6EA8;

    /* Header Blur */
    --header-bg: rgba(42, 42, 40, 0.8);
}

html {
    scroll-padding-top: var(--header-height);
}

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

* {
    margin: 0;
    padding: 0;
    /* border: 1px solid red; */
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

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

/* Headings */
h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
    line-height: var(--leading-tight);
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

p {
    text-wrap: pretty;
}

/* Screen-reader-only text */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

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

ul {
    list-style: none;
}

/* Max content width */
body {
    max-width: 1440px;
    margin-inline: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-primary);
    background-color: var(--bg-color);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    font-weight: var(--weight-regular);
}

/* Page Fade In */
@keyframes page-fade-in {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[data-fade] {
    animation: page-fade-in 1.4s cubic-bezier(0.33, 1, 0.68, 1) backwards;
}

[data-fade="1"] { animation-delay: 0.25s; }
[data-fade="2"] { animation-delay: 0.5s; }
[data-fade="3"] { animation-delay: 0.75s; }
[data-fade="4"] { animation-delay: 1s; }
[data-fade="5"] { animation-delay: 1.25s; }
[data-fade="6"] { animation-delay: 1.5s; }
[data-fade="7"] { animation-delay: 1.75s; }

@media (prefers-reduced-motion: reduce) {
    [data-fade] {
        animation: none;
    }
}

.return-top {
    position: fixed;
    bottom: var(--space-xl);
    left: max(var(--space-lg), calc((100% - 1440px) / 2 + var(--space-lg)));
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    background-color: var(--bg-color);
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
    box-shadow: 0 4px 16px var(--shadow-color);

    /* Hidden until the page is scrolled */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);

    transition: transform 0.2s ease, opacity 0.2s ease,
                background-color 0.2s ease, visibility 0.2s;
}

.return-top.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.return-top.visible:hover {
    transform: translateY(-3px);
    background-color: var(--bg-thumbnail);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-md);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--header-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* Header line: track (::before) and scroll progress (::after) */
.header::before,
.header::after {
    content: "";
    position: absolute;
    left: var(--space-md);
    right: var(--space-md);
    bottom: 0;
    height: 1px;
    opacity: 0;
    /* hides instantly so it never overlaps the title */
    transition: none;
}

.header::before {
    background-color: var(--line-faint);
}

.header::after {
    background-color: var(--accent-color);
    transform-origin: left;
    transform: scaleX(var(--scroll-progress, 0)); /* set by script.js */
}

.header.scrolled::before,
.header.scrolled::after {
    opacity: 1;
    transition: opacity 0.2s ease;
}

.header.perma-line::before,
.header.perma-line::after {
    opacity: 1;
}

/* Landing Page */
.section-hero {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 var(--space-md) var(--space-md) var(--space-md);
    min-height: calc(100vh - var(--header-height));
    min-height: calc(100svh - var(--header-height));
}

.name {
    font-weight: var(--weight-semibold);
    font-size: var(--text-logo);
    letter-spacing: var(--tracking-logo);
}

.name a {
    position: relative;
    transition: color 0.2s ease;
}

.name a:hover,
.name a:focus-visible {
    color: var(--text-secondary);
}

/* Back-to-home chevron: slides in from the name into the side margin on hover */
.name-chevron {
    position: absolute;
    right: 100%;
    top: 50%;
    display: flex;
    opacity: 0;
    transform: translate(4px, -50%);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.name-chevron svg {
    width: 0.5em;
    height: 0.5em;
    stroke: currentColor;
    stroke-width: 1; /* matches the name's weight */
}

.name a:hover .name-chevron,
.name a:focus-visible .name-chevron {
    opacity: 1;
    transform: translate(-1px, -50%);
}

.title {
    font-size: var(--text-base);
    letter-spacing: var(--tracking-tight);
    color: var(--accent-color);
    margin-top: -16px;
    padding-left: 1px;
    position: relative;
    z-index: 101;
    pointer-events: none;
}

.nav-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Theme toggle: an icon button outside the menu, so it reads as a control
   rather than a link to another page. Hover only fills the icon (see below) */
.theme-toggle-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs);
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
}

/* Phones: a thin divider centered between the theme button and the hamburger */
.theme-toggle-btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: calc(100% + var(--space-md) / 2);
    width: 1px;
    height: 1.25rem;
    background-color: var(--line-faint);
    translate: 0 -50%;
}

.hamburger-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs);
    margin-right: calc(var(--space-xs) * -1);
    border: none;
    border-radius: 10px;
    background: none;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.hamburger-menu:hover,
.hamburger-menu[aria-expanded="true"] {
    background-color: var(--bg-thumbnail);
}

/* Hamburger: three bars that morph into an X */
.hamburger-box {
    position: relative;
    display: block;
    width: 28px;
    height: 28px;
}

.bar {
    --bar-thickness: 1.75px;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 19.25px;
    height: var(--bar-thickness);
    margin-top: calc(var(--bar-thickness) / -2); /* stays centered as thickness changes */
    border-radius: 999px;
    background-color: currentColor;
    transition: transform 0.3s ease, width 0.3s ease, height 0.3s ease,
                margin-top 0.3s ease, opacity 0.2s ease;
}

/* Closed: three horizontal bars, 7px apart */
.bar-top {
    transform: translate(-50%, -7px) rotate(0deg);
}

.bar-middle {
    transform: translate(-50%, 0);
}

.bar-bottom {
    transform: translate(-50%, 7px) rotate(0deg);
}

.hamburger-menu[aria-expanded="true"] .bar-top {
    --bar-thickness: 2.1px; /* optical correction: diagonals read thinner */
    width: 29px;
    transform: translate(-50%, 0) rotate(45deg);
}

.hamburger-menu[aria-expanded="true"] .bar-middle {
    opacity: 0;
}

.hamburger-menu[aria-expanded="true"] .bar-bottom {
    --bar-thickness: 2.1px;
    width: 29px;
    transform: translate(-50%, 0) rotate(-45deg);
}

/* Respect users who turn off animations */
@media (prefers-reduced-motion: reduce) {
    .bar {
        transition: none;
    }
}

.menu-item:hover,
.menu-item:focus-visible {
    background-color: var(--bg-thumbnail);
}

.expanded-menu{
    position: absolute;
    top: 100%;
    right: var(--space-md);
    min-width: 180px;
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);

    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow-color);

    z-index: 9999;
    transform-origin: top right;
    /* visibility waits for the fade-out */
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.expanded-menu.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
    pointer-events: none;
    visibility: hidden;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-sm);
    border: none;
    border-radius: 10px;
    background: none;
    font: inherit;
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background-color 0.15s ease;
}

.menu-item:hover,
.menu-item:focus-visible {
    background-color: var(--bg-thumbnail);
}

/* Current page */
.menu-item[aria-current] {
    font-weight: var(--weight-semibold);
}

/* Work's project list: hover only, so hidden in the phone menu */
.nav-dropdown {
    width: 100%;
}

.project-menu {
    display: none;
}

.menu-item svg {
    flex-shrink: 0;
}

/* Outline icon by default, filled icon on hover/focus */
.menu-item .icon-fill {
    display: none;
}

.menu-item:hover .icon-outline,
.menu-item:focus-visible .icon-outline,
.menu-item[aria-current] .icon-outline {
    display: none;
}

.menu-item:hover .icon-fill,
.menu-item:focus-visible .icon-fill,
.menu-item[aria-current] .icon-fill {
    display: block;
}

/* Dark Mode */
/* Theme toggle icons */
.theme-toggle-btn svg {
    display: none;
}

.theme-toggle-btn .moon-icon {
    display: block;
}

.theme-toggle-btn:hover .moon-icon {
    display: none;
}

.theme-toggle-btn:hover .moon-icon-fill {
    display: block;
}

/* Dark mode: show sun instead of moon */
:root.dark-theme .theme-toggle-btn .moon-icon,
:root.dark-theme .theme-toggle-btn .moon-icon-fill {
    display: none;
}

:root.dark-theme .theme-toggle-btn .sun-icon {
    display: block;
}

:root.dark-theme .theme-toggle-btn:hover .sun-icon {
    display: none;
}

:root.dark-theme .theme-toggle-btn:hover .sun-icon-fill {
    display: block;
}

.hero-section {
    container-type: inline-size; /* for cqi */
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex-grow: 1;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Hero eyebrow */
.hero-eyebrow {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: clamp(0.875rem, 0.8196rem + 0.2255vw, 1rem); /* 14 → 16px */
    font-weight: var(--weight-medium);
}

/* Location arrow, like the "current location" arrow in a maps app. It rests
   tilted 45° up and to the right; script.js turns it via --heading
   (0 = up, 90 = right) */
.location-arrow {
    display: flex;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    color: var(--color-blue);
}

.location-arrow svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    /* a stroke in the same color rounds the arrow's points */
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    rotate: var(--heading, 45deg);
    transition: rotate 0.7s cubic-bezier(0.22, 1, 0.36, 1); /* turns like a glance, not a snap */
}

/* 32 → 64px from 393px, smaller below so the lines still fit; always two lines */
.hero-text {
    font-size: clamp(1.75rem, 1.1139rem + 3.6077vw, 4rem);
}

.hero-text span {
    display: block;
    white-space: nowrap;
}

/* 18 → 24px; below ~450px it shrinks so the first line still fits */
.hero-description {
    font-size: clamp(0.75rem, min(100cqi / 23, 0.9589rem + 0.6764vw), 1.5rem);
    color: var(--text-secondary);
    font-weight: var(--weight-medium);
}

/* first line always whole; the last sentence wraps at most once, so 2 or 3 lines */
.hero-description span {
    display: block;
    white-space: nowrap;
}

/* Scroll-down arrow */
.scroll-down {
    display: flex;
    justify-content: center;
    align-self: center;
    padding: var(--space-xs) var(--space-xs) var(--space-sm);
    transition: color 0.2s ease;
}

.scroll-down:hover,
.scroll-down:focus-visible {
    color: var(--text-secondary);
}

/* bounce runs on a span: Firefox drops frames animating SVG */
.scroll-down-bounce {
    display: block;
    animation: arrow-bounce 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
    will-change: transform;
}

@keyframes arrow-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(7px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .scroll-down-bounce {
        animation: none;
    }

    .location-arrow svg {
        transition: none;
    }
}


/* Work Section */
.page-header {
    margin: 0 var(--space-md);
    padding-top: var(--space-xl);
    font-size: var(--text-2xl);
}

.section-work {
    display: flex;
    flex-direction: column;
    padding: 0 var(--space-md);
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.card-first {
    border-top: 1px solid var(--text-secondary);
    padding-top: var(--space-md);
}

/* whole card is clickable (script.js) */
.work-grid .work-card {
    cursor: pointer;
}

/* project titles wrap normally, not balanced */
.work-header {
    font-size: var(--text-xl);
    text-wrap: wrap;
}

h1.work-header {
    font-size: var(--text-2xl);
}

.work-description {
    font-size: var(--text-md);
    color: var(--text-secondary);
}

.work-card:has(.work-link) .work-description {
    font-weight: var(--weight-medium);
}

.project-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.project-details .content-description {
    color: var(--accent-color);
}

.detail-label {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
}

.work-title {
    font-size: var(--text-base);
    color: var(--accent-color);
}

.work-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    width: 100%;
    border-bottom: 1px solid var(--text-secondary);
}

/* Card title link */
.work-header:has(.work-link) {
    width: fit-content;
}

.work-link {
    display: inline-block;
    /* left, not transform: transform made the text bounce */
    position: relative;
    left: 0;
    transition: color 0.2s ease, left 0.2s ease;
}

.link-arrow {
    display: inline-block;
    margin-left: 0.3em;
}

.link-arrow svg {
    width: 0.8em;
    height: 0.8em;
    /* thicker lines */
    stroke: currentColor;
    stroke-width: 0.6;
}

/* hover sits on the heading, so the sliding title can't flicker */
.work-header:hover .work-link,
.work-link:focus-visible {
    color: var(--accent-color);
    left: 4px;
}

.pill-tag {
    background-color: var(--bg-pill);
    color: var(--text-pill);
    border: 1px solid var(--border-pill);
    border-radius: 25px;
    padding: 0 12px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-medium);
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.work-thumbnail {
    background-color: var(--bg-project);
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    justify-content: flex-end;
    color: var(--text-on-project);
    padding: var(--space-sm);
    border-radius: 10px;
    position: relative;
    isolation: isolate; /* no overflow clip, so the "View Details" pill can pass the edges */
    /* same faint ring as the About photos */
    outline: 1px solid var(--line-faint);
    outline-offset: -1px;
}

/* Photo fills the frame */
.work-thumbnail img {
    position: absolute;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* shade behind the year so it reads on any photo */
.work-thumbnail::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: linear-gradient(200deg, rgb(0 0 0 / 0.45), transparent 35%);
}

/* "View Details" pill: follows the cursor over the thumbnail (position set by script.js) */
.view-project {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 9999px;
    background-color: color-mix(in srgb, var(--bg-card) 55%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-card) 60%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    font-size: var(--text-2xs);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    translate: var(--x, 0px) var(--y, 0px); /* separate from scale, so scaling doesn't shrink the offset */
    transform-origin: bottom left; /* grows out from the cursor's side */
    scale: 0.85;
    opacity: 0;
    box-shadow: 0 6px 20px var(--shadow-color); /* lifts it off the photo */
    transition: opacity 0.25s ease, scale 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.view-project svg {
    width: 0.9em;
    height: 0.9em;
}

@media (hover: hover) {
    .work-thumbnail:hover .view-project {
        opacity: 1;
        scale: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .name-chevron,
    .view-project {
        transition: opacity 0.2s ease;
    }
}

/* year: trimmed so its top gap matches the right gap */
.work-thumbnail p {
    line-height: var(--leading-none);
    margin-top: -0.09em;
}

.section-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--text-secondary);
}

.section-header {
    font-size: var(--text-xl);
}

.section-content {
    font-size: var(--text-md);
    color: var(--text-secondary);
}

/* Previous / Next Project: stacked on phones, side by side from 768px.
   A gap (not a line) separates it from the content; its bottom line is the one above the footer's thanks row */
.project-pager {
    display: grid;
    row-gap: var(--space-xl);
    margin: var(--space-lg) var(--space-md) 0;
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--text-secondary);
}

/* the content's closing line gives way to the gap */
.section-work:has(+ .project-pager) > .section-item:last-child,
.toc-host:has(+ .project-pager) {
    border-bottom: none;
}

/* only the label and title are clickable, not the space around them */
.pager-link {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: fit-content;
}

.pager-next {
    justify-self: end;
    align-items: flex-end;
    text-align: right;
}

.pager-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.pager-label svg {
    width: 1.1em;
    height: 1.1em;
    transition: transform 0.2s ease;
}

.pager-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-snug);
    color: var(--text-primary);
    max-width: 24ch;
    transition: color 0.2s ease;
}

/* Same hover as the card titles: turns blue, arrow nudges outward */
.pager-link:hover .pager-title,
.pager-link:focus-visible .pager-title {
    color: var(--accent-color);
}

.pager-prev:hover svg,
.pager-prev:focus-visible svg {
    transform: translateX(-4px);
}

.pager-next:hover svg,
.pager-next:focus-visible svg {
    transform: translateX(4px);
}

@media (min-width: 768px) {
    .project-pager {
        grid-template-columns: 1fr 1fr;
        column-gap: var(--column-gap);
    }
}

/* Footer */
.section-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-3xl);
    padding: 0 var(--space-md);
    /* the big name overflows; prevents sideways scroll */
    overflow-x: clip;
}

/* sits under the line above the footer and adds the line below */
.footer-thanks {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--text-secondary);
    text-align: center;
    font-size: var(--text-2xl);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
    margin-bottom: calc(var(--space-lg) - var(--space-3xl)); /* links sit space-lg below, not the full gap */
}

.footer-details {
    display: flex;
    justify-content: space-between;
}

.footer-nav-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.footer-right {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.email-location {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* rows shrink to their content */
    gap: var(--space-sm);
}

.email-location p {
    overflow-wrap: anywhere; /* long email can wrap on very narrow screens */
}

/* Email button: reset button styles */
.email {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    text-align: left;
}

/* Toast */
.toast {
    position: fixed;
    right: max(var(--space-lg), calc((100% - 1440px) / 2 + var(--space-lg)));
    bottom: var(--space-xl);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    max-width: min(360px, calc(100vw - 2 * var(--space-lg)));
    padding: var(--space-md);

    background-color: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow-color);

    /* hidden until .show */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.toast svg {
    flex-shrink: 0;
    margin-top: 2px; /* centers the 20px icon on the first text line */
    color: var(--color-green);
}

.toast-title {
    font-weight: var(--weight-semibold);
}

.toast-message {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Small screens: beside the return-to-top button */
@media (max-width: 480px) {
    .toast {
        max-width: calc(100vw - 2 * var(--space-lg) - 48px - var(--space-sm));
    }
}

/* Shown from 1280px */
.page-toc,
.toc-top {
    display: none;
}

/* Page Navigation (About + project pages) */
.page-nav {
    --page-nav-height: 56px;
    position: fixed;
    left: 50%;
    bottom: var(--space-lg);
    z-index: 998;
    display: flex;
    align-items: flex-end; /* the back button stays at the bottom while the panel grows */
    gap: var(--space-sm);
    width: min(480px, calc(100% - 2 * var(--space-md)));
    transform: translateX(-50%);
}

/* room for the bar */
body:has(.page-nav) {
    padding-bottom: calc(var(--page-nav-height, 56px) + var(--space-lg) + var(--space-md));
}

/* toast sits above the bar */
body:has(.page-nav) .toast {
    bottom: calc(56px + var(--space-lg) + var(--space-sm));
    max-width: min(360px, calc(100vw - 2 * var(--space-lg)));
}

.page-nav-back,
.page-nav-sections {
    border: 1px solid var(--text-primary);
    background-color: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.page-nav-back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: var(--page-nav-height);
    height: var(--page-nav-height);
    border-radius: 50%;
    transition: background-color 0.15s ease;
}

/* Section pill and menu: one panel */
.page-nav-sections {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    border-radius: calc(var(--page-nav-height) / 2);
    transition: border-radius 0.3s ease, background-color 0.15s ease;
}

.page-nav-sections:has(.section-toggle[aria-expanded="true"]) {
    border-radius: 20px;
}

.section-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    height: calc(var(--page-nav-height) - 2px); /* the panel's border makes up the rest */
    position: relative;
    padding: 0 var(--space-md) 0 var(--space-sm);
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* Hover: the closed pill tints as one */
.page-nav-back:hover,
.page-nav-back:focus-visible,
.page-nav-sections:has(.section-toggle[aria-expanded="false"]:hover),
.page-nav-sections:has(.section-toggle[aria-expanded="false"]:focus-visible) {
    background-color: var(--bg-thumbnail);
}

/* Open: the chevron dims on hover */
.section-toggle[aria-expanded="true"]:hover .section-chevron,
.section-toggle[aria-expanded="true"]:focus-visible .section-chevron {
    color: var(--text-secondary);
}

/* Divider above the progress row, open only */
.section-toggle::before {
    content: "";
    position: absolute;
    top: 0;
    left: var(--space-md);
    right: var(--space-md);
    height: 1px;
    background-color: var(--border-card);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.section-toggle[aria-expanded="true"]::before {
    opacity: 1;
}

/* Progress ring (set by script.js) */
.progress-ring {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.progress-ring svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg); /* start the arc at 12 o'clock */
}

.progress-track,
.progress-fill {
    fill: none;
    stroke-width: 2.5;
}

.progress-track {
    stroke: var(--line-faint);
}

/* circle length is 100, so dash length = percent */
.progress-fill {
    stroke: var(--accent-color);
    stroke-dasharray: 0 100;
}

.progress-percent {
    font-size: var(--text-3xs); /* 11px so "100%" fits inside the ring */
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-tight);
}

.section-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
}

.section-chevron {
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.section-toggle[aria-expanded="true"] .section-chevron {
    transform: rotate(180deg);
}

/* Section menu: the grid row animates the panel's height */
.section-menu {
    display: grid;
    grid-template-rows: 1fr;
    overflow: hidden;
    transition: grid-template-rows 0.3s ease, opacity 0.25s ease, visibility 0.3s;
}

.section-menu.hidden {
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
}

.section-menu-inner {
    min-height: 0;
    padding: var(--space-sm);
    transition: padding 0.3s ease;
}

/* collapse padding too, or the closed pill is taller */
.section-menu.hidden .section-menu-inner {
    padding-block: 0;
}

.section-menu-title {
    /* item padding + dot + gap, to line up with the names */
    padding: var(--space-xs) var(--space-md) var(--space-sm) calc(var(--space-md) + 6px + var(--space-sm));
    color: var(--text-secondary);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.section-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 60vh;
    overflow-y: auto;
}

.section-list button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 10px var(--space-md);
    border: none;
    border-radius: 12px;
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-weight: var(--weight-medium);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

/* dot on every item, filled for the current one */
.section-list button::before {
    content: "";
    flex-shrink: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: transparent;
}

.section-list button:hover,
.section-list button:focus-visible {
    background-color: var(--bg-thumbnail);
}

/* Current section */
.section-list button[aria-current="true"] {
    font-weight: var(--weight-semibold);
}

.section-list button[aria-current="true"]::before {
    background-color: var(--accent-color);
}

@media (prefers-reduced-motion: reduce) {
    .section-menu,
    .section-chevron,
    .page-nav-sections {
        transition: none;
    }
}

.footer-name {
    display: flex;
    flex-direction: column;
    align-items: center;
    container-type: inline-size;
}

.bigname {
    font-weight: var(--weight-semibold);
    font-size: 18.4cqi;
    letter-spacing: var(--tracking-logo);
    padding-right: 0.09em;
    line-height: var(--leading-none);
    white-space: nowrap;
}

.bigname a {
    transition: color 0.2s ease;
}

.bigname a:hover,
.bigname a:focus-visible {
    color: var(--text-secondary);
}

.made-by {
    padding: var(--space-sm);
    width: 100%;
    border-top: 1px solid var(--text-secondary);
    border-bottom: 1px solid var(--text-secondary);
    text-align: center;
}

.copyright {
    padding: var(--space-lg) 0;
}

.nav-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

.nav-content svg {
    flex-shrink: 0;
}

/* Outline by default, filled on hover */
.nav-content .icon-fill {
    display: none;
}

.nav-content:hover .icon-outline {
    display: none;
}

.nav-content:hover .icon-fill {
    display: block;
}

.nav-content:focus-visible .icon-outline {
    display: none;
}

.nav-content:focus-visible .icon-fill {
    display: block;
}

.nav-content:focus-visible p::after {
    transform-origin: left;
    transform: scaleX(1);
}

.footer-nav-links {
    align-items: flex-start; /* rows shrink to their content */
}

.nav-content p {
    position: relative;
    width: fit-content;
}

.nav-content p::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background-color: var(--text-secondary);
    transform-origin: right;
    transform: scaleX(0);
    transition: transform 0.3s ease-out;
}

.nav-content:hover p::after {
    transform-origin: left;
    transform: scaleX(1);
}

/* Location isn't a link */
.location {
    cursor: default;
}

.location:hover p::after {
    transform: scaleX(0);
}

/* shown once script.js fills in the time */
.local-time[hidden] {
    display: none;
}

.local-time p {
    font-variant-numeric: tabular-nums;
}

/* About */
.section-photo {
    padding: var(--space-md);
}

.photo {
    position: absolute;
    overflow: hidden;
    border-radius: 9999px;
    aspect-ratio: 1;
    background-color: var(--bg-project);
    /* faint ring drawn over the photo's edge; an outline doesn't change the size or crop */
    outline: 1px solid var(--line-faint);
    outline-offset: -1px;
}

/* Phones: the cats are same-size "ears" at 45° above the photo, like a
   Mickey Mouse silhouette. The left ear sits on the left edge, which
   shifts the photo right. Everything follows the photo's size (--head) */
.photo-cluster {
    --head: clamp(9.625rem, 25vw, 20rem); /* 154px on phones up to 616px */
    --ear: calc(var(--head) * 0.57);
    --ear-gap: var(--space-xs);
    /* how far each ear's center sits left/right and up from the photo's center */
    --ear-offset: calc(((var(--head) + var(--ear)) / 2 + var(--ear-gap)) * 0.7071);
    position: relative;
    width: calc(var(--ear-offset) * 2 + var(--ear));
    height: calc(var(--ear-offset) + var(--ear) / 2 + var(--head) / 2);
}

/* Slots are the spots the photos sit in (slot-1 is the big one). Dragging a
   photo onto another swaps their slots (script.js); crops stay with the photo */
.slot-1 {
    width: var(--head);
    left: calc(var(--ear-offset) + var(--ear) / 2 - var(--head) / 2);
    top: calc(var(--ear-offset) + var(--ear) / 2 - var(--head) / 2);
}

.slot-2 {
    width: var(--ear);
    left: 0;
    top: 0;
}

.slot-3 {
    width: var(--ear);
    right: 0;
    top: 0;
}

/* Drag to swap */
.photo-cluster .photo {
    cursor: grab;
    touch-action: none; /* a drag moves the photo instead of scrolling the page */
    user-select: none;
    -webkit-user-select: none;
}

.photo-cluster .photo.dragging {
    z-index: 2;
    cursor: grabbing;
    box-shadow: 0 12px 32px var(--shadow-color);
}

/* Each photo is cropped to a square around its subject:
   width = image width / square side, left and top = the square's offset / side */
.photo {
    --crop-w: 182.86%; /* about-photo.jpg, as 1024x768: 560px square at x 410, y 140 */
    --crop-x: -73.21%;
    --crop-y: -25%;
}

.photo img {
    position: absolute;
    width: var(--crop-w);
    max-width: none;
    height: auto;
    left: var(--crop-x);
    top: var(--crop-y);
}

.photo-cat {
    --crop-w: 140.63%; /* thecutestcat.jpg, as 1125x2000: 800px square at x 20, y 610 */
    --crop-x: -2.5%;
    --crop-y: -76.25%;
}

.photo-kitten {
    --crop-w: 197.37%; /* thecutestkitten.jpg, as 1500x2000: 760px square at x 390, y 670 */
    --crop-x: -51.32%;
    --crop-y: -88.16%;
}

.about-me {
    display: flex;
    flex-direction: column;
    padding: 0 var(--space-md);
    gap: var(--space-md);
}

.greeting {
    font-size: var(--text-2xl);
}

/* text and arrow share the underline */
.download-resume {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--text-secondary);
    width: fit-content;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.download-resume:hover,
.download-resume:focus-visible {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

/* sized to the text, thickened to match the 600 weight */
.download-resume svg {
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    stroke: currentColor;
    stroke-width: 0.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.section-resume {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
    padding-bottom: 0;
}

.resume-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.resume-header {
    padding-top: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--text-secondary);
    font-size: var(--text-xl);
}

.resume-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.resume-last {
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--text-secondary);
}

/* About labels (h3) */
.content-label {
    font-size: var(--text-lg);
}

/* keeps "@ Company" together */
.keep-together {
    white-space: nowrap;
}

.content-description {
    color: var(--text-secondary);
}

/* Fun: one item per line, with a small gap so long dishes that wrap still read as separate items */
.fun-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* small note under an About label, like "Snack portions please" */
.content-sublabel {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    font-style: italic;
}
/* ===== Tablet and up (768px+) ===== */
@media (min-width: 768px) {
    /* gap between the 1/3 and 2/3 columns */
    :root {
        --column-gap: 4rem; /* 64px */
    }

    /* Header: nav links replace the hamburger */
    /* the theme button stays; it moves after the links, past a thin divider */
    .hamburger-menu {
        display: none;
    }

    .theme-toggle-btn::after {
        content: none; /* no hamburger to divide from; the divider sits before the button instead */
    }

    .nav-container {
        order: 1;
        position: relative;
        margin-left: var(--space-lg);
    }

    .nav-container::before {
        content: "";
        position: absolute;
        top: 50%;
        right: calc(100% + var(--space-lg) / 2);
        width: 1px;
        height: 1.25rem;
        background-color: var(--line-faint);
        translate: 0 -50%;
    }

    .expanded-menu {
        margin-left: auto;
    }

    .expanded-menu,
    .expanded-menu.hidden {
        position: static;
        flex-direction: row;
        align-items: center;
        gap: var(--space-lg);
        min-width: 0;
        padding: 0;
        background: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        transition: none;
    }

    .menu-item {
        width: auto;
        padding: 0;
        border-radius: 0;
    }

    .menu-item:hover,
    .menu-item:focus-visible {
        background: none;
    }

    .menu-item > span {
        position: relative;
    }

    .menu-item > span::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 1px;
        background-color: var(--text-secondary);
        transform-origin: right;
        transform: scaleX(0);
        transition: transform 0.3s ease-out;
    }

    .menu-item:hover > span::after,
    .menu-item:focus-visible > span::after,
    .nav-dropdown:hover > .menu-item > span::after,
    .nav-dropdown:focus-within > .menu-item > span::after {
        transform-origin: left;
        transform: scaleX(1);
    }

    /* Work dropdown: opens on hover or keyboard focus.
       Fills the header's height, so the menu starts just below the header line
       and the space between them stays hoverable */
    .expanded-menu {
        align-self: stretch;
    }

    .nav-dropdown {
        position: relative;
        width: auto;
        align-self: stretch;
        display: flex;
        align-items: center;
    }

    /* starts where "Work" starts (past the 20px icon and gap) */
    .project-menu {
        display: block;
        position: absolute;
        top: 100%;
        left: calc(20px + var(--space-sm));
        opacity: 0;
        visibility: hidden;
        transform: translateY(-4px);
        /* visibility waits for the fade-out */
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    }

    .nav-dropdown:hover > .project-menu,
    .nav-dropdown:focus-within > .project-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    /* spans from "Work" to the right edge of the nav, which grows slightly with the text */
    .project-menu-panel {
        display: flex;
        flex-direction: column;
        width: clamp(15rem, 14rem + 2.7vw, 16.25rem);
        padding: var(--space-sm);
        background-color: var(--bg-card);
        border: 1px solid var(--border-card);
        border-radius: 16px;
        box-shadow: 0 8px 24px var(--shadow-color);
    }

    .project-menu-item {
        padding: var(--space-sm);
        border-radius: 10px;
        font-size: var(--text-xs);
        font-weight: var(--weight-medium);
        line-height: var(--leading-snug);
        color: var(--text-primary);
        transition: background-color 0.15s ease;
    }

    .project-menu-item:hover,
    .project-menu-item:focus-visible {
        background-color: var(--bg-thumbnail);
    }

    /* Project sections: heading 1/3, text 2/3 */
    .section-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        column-gap: var(--column-gap);
        row-gap: var(--space-md);
        align-items: start;
    }

    .section-item > .section-header {
        grid-column: 1;
        grid-row: 1;
    }

    .section-item > :not(.section-header) {
        grid-column: 2;
    }

    /* About intro: photo 1/3, bio 2/3 */
    .about-intro {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        column-gap: var(--column-gap);
        align-items: start;
        padding: var(--space-md);
    }

    .about-intro .section-photo,
    .about-intro .about-me {
        padding: 0;
    }

    /* Photos trail down: the cat below and right of the photo (30° from vertical),
       the kitten below and left of the cat (45°) */
    .photo-cluster {
        --cat: calc(var(--head) * 0.55);
        --kitten: calc(var(--head) * 0.38);
        --trail-gap: var(--space-sm);
        --to-cat: calc((var(--head) + var(--cat)) / 2 + var(--trail-gap)); /* center to center */
        --to-kitten: calc((var(--cat) + var(--kitten)) / 2 + var(--trail-gap));
        --cat-x: calc(var(--head) / 2 + var(--to-cat) * 0.5); /* cat's center */
        --cat-y: calc(var(--head) / 2 + var(--to-cat) * 0.866);
        width: 100%;
        height: calc(var(--cat-y) + var(--to-kitten) * 0.7071 + var(--kitten) / 2);
    }

    .slot-1 {
        left: 0;
        top: 0;
    }

    .slot-2 {
        width: var(--cat);
        left: calc(var(--cat-x) - var(--cat) / 2);
        top: calc(var(--cat-y) - var(--cat) / 2);
    }

    .slot-3 {
        width: var(--kitten);
        right: auto;
        left: calc(var(--cat-x) - var(--to-kitten) * 0.7071 - var(--kitten) / 2);
        top: calc(var(--cat-y) + var(--to-kitten) * 0.7071 - var(--kitten) / 2);
    }

    /* About resume */
    .resume-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
        column-gap: var(--column-gap);
    }

    .resume-header {
        grid-column: 1 / -1;
    }

    /* single entries: label and value share the columns */
    .resume-content {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: subgrid;
        column-gap: var(--column-gap); /* overrides its own 8px gap */
    }

    /* paired entries: title and dates on the left... */
    .resume-content:has(+ .resume-content > :first-child:not(h3)) {
        grid-column: 1;
        display: flex;
    }

    /* ...details on the right */
    .resume-content:not(:has(.content-label)) {
        grid-column: 2;
        display: flex;
    }

    /* a note under the label stays on the left, below it */
    .content-sublabel {
        grid-column: 1;
        grid-row: 2;
    }

    .resume-content:has(.content-sublabel) {
        grid-template-rows: auto 1fr; /* the first row fits the label, so the note sits right under it */
    }

    .resume-content:has(.content-sublabel) > .content-description {
        grid-column: 2;
        grid-row: 1 / span 2;
    }
}

/* ===== Desktop (1024px+) ===== */
@media (min-width: 1024px) {
    /* Landing cards and project header: info 1/3, thumbnail 2/3 */
    #work .work-card,
    .work-card:has(> h1.work-header) {
        display: grid;
        grid-template-columns: minmax(20rem, 1fr) minmax(0, 2fr);
        grid-template-rows: auto auto auto 1fr;
        column-gap: var(--column-gap);
        row-gap: var(--space-md);
        align-items: start;
    }

    #work .work-card > :not(.work-thumbnail),
    .work-card:has(> h1.work-header) > :not(.work-thumbnail) {
        grid-column: 1;
    }

    #work .work-thumbnail,
    .work-card:has(> h1.work-header) > .work-thumbnail {
        grid-column: 2;
        grid-row: 1 / -1;
    }

    /* Work page: three vertical slices */
    /* Work heading row */
    .page-header {
        margin: 0 var(--space-md);
        padding: var(--space-lg) 0;
        border-bottom: 1px solid var(--line-faint);
    }

    /* the lines belong to the cards so they fade in with them */
    .work-grid {
        container-type: inline-size; /* for cqi units */
        display: flex;
        flex-direction: row;
        gap: 0;
        padding: 0;
        margin: 0 var(--space-md);
        /* fill the screen below the heading */
        min-height: calc(100svh - var(--header-height) - var(--text-2xl) * 1.15 - 2 * var(--space-lg) - 1px);
    }

    .work-grid .work-card {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        padding: var(--space-xl) var(--space-md) var(--space-lg);
        border-bottom: 1px solid var(--text-secondary); /* matches the footer's lines */
        border-right: 1px solid var(--line-faint);
        transition: flex-grow 0.4s ease, background-color 0.4s ease;
    }

    .work-grid .work-card:first-child {
        border-left: 1px solid var(--line-faint);
    }

    /* content keeps its normal width, so text doesn't reflow on hover */
    .work-grid .work-card > * {
        --slice-content: calc(100cqi / 3 - 2 * var(--space-md) - 1px);
        width: var(--slice-content);
        flex-shrink: 0;
    }

    /* thumbnail widens with the slice at a fixed height */
    .work-grid .work-card > .work-thumbnail {
        width: auto;
        height: calc(var(--slice-content) * 9 / 16);
        aspect-ratio: auto;
    }

    .work-grid .work-card > .work-header {
        width: max-content;
        max-width: var(--slice-content);
    }

    .work-grid .work-card:hover,
    .work-grid .work-card:focus-within {
        flex-grow: 1.1;
        background-color: var(--bg-thumbnail);
    }

    /* pills switch to the page color to stay visible */
    .work-grid .work-card:hover .pill-tag,
    .work-grid .work-card:focus-within .pill-tag {
        background-color: var(--bg-color);
    }

    .work-grid .work-thumbnail {
        transition: transform 0.4s ease;
    }

    .work-grid .work-card:hover .work-thumbnail,
    .work-grid .work-card:focus-within .work-thumbnail {
        transform: scale(1.02);
    }
}

@media (min-width: 768px) and (prefers-reduced-motion: reduce) {
    .project-menu {
        transition: none;
    }
}

/* Reduced motion: Work slices don't animate */
@media (min-width: 1024px) and (prefers-reduced-motion: reduce) {
    .work-grid .work-card,
    .work-grid .work-thumbnail {
        transition: none;
    }
}

/* ===== Wide (1280px+) ===== */
@media (min-width: 1280px) {
    /* Project and About: side list replaces the bottom bar */
    :root {
        --toc-width: 14rem; /* list column, including the gap */
    }

    .page-nav {
        display: none;
    }

    /* About intro: the bio starts where the resume's right column does
       (list column + a third of what's left after the gap, then the gap) */
    .about-intro {
        grid-template-columns: calc(var(--toc-width) + (100% - var(--toc-width) - var(--column-gap)) / 3) minmax(0, 1fr);
    }

    /* The freed space holds three circles: you top left, the kitten in the
       bottom right corner, and the cat between them with equal gaps to both.
       Designed at 1280px (a 534 x 420px area: 320px photo, 180px cat, 112px kitten,
       24px gaps); every size is a share of the area's width (cqi), so on wider
       screens the circles grow and the gaps stay in proportion */
    .photo-cluster {
        container-type: inline-size;
        height: auto;
        aspect-ratio: 534 / 420;
    }

    .slot-1 {
        width: 59.93cqi;
    }

    .slot-2 {
        width: 33.71cqi;
        left: 63.85cqi;
        top: 20.72cqi;
    }

    .slot-3 {
        width: 20.97cqi;
        left: auto;
        top: auto;
        right: 0;
        bottom: 0;
    }

    body:has(.page-nav) {
        padding-bottom: 0;
    }

    body:has(.page-nav) .toast {
        bottom: var(--space-xl);
    }

    /* sections container (set by script.js): list | sections */
    .toc-host {
        display: grid;
        grid-template-columns: var(--toc-width) minmax(0, 1fr);
        column-gap: 0;
    }

    .toc-host > * {
        grid-column: 1 / -1;
    }

    .toc-host > .section-item,
    .toc-host > .resume-item {
        grid-column: 2;
    }

    /* sticky list; --toc-offset is extra top space, removed when stuck */
    .toc-host > .page-toc {
        display: block;
        grid-column: 1;
        align-self: start;
        position: sticky;
        top: calc(var(--header-height) + var(--space-lg) - var(--toc-offset, 0px));
        padding-top: var(--toc-offset, 0px);
        padding-right: var(--space-lg);
    }

    /* one closing line across the page */
    .toc-host {
        margin-inline: var(--space-md);
        padding-inline: 0;
        border-bottom: 1px solid var(--text-secondary);
    }

    .toc-host > .section-item:last-child,
    .toc-host .resume-last {
        border-bottom: none;
    }

    /* About: start below the first heading's line */
    .section-resume > .page-toc {
        --toc-offset: calc(var(--space-xl) + var(--text-xl) * var(--leading-tight) + var(--space-md) + 1px + var(--space-md) - var(--space-sm));
    }

    /* shown after a screen of scrolling, hidden at the footer (script.js) */
    .toc-top {
        position: fixed;
        left: var(--page-edge);
        z-index: 50;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(8px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    }

    .toc-top.is-shown:not(.is-covered) {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .toc-title {
        margin-bottom: var(--space-sm);
        color: var(--text-secondary);
        font-size: var(--text-2xs);
        font-weight: var(--weight-semibold);
        letter-spacing: var(--tracking-wide);
        text-transform: uppercase;
    }

    .toc-list {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }

    /* dot marks the current section */
    .toc-list button {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        margin-left: calc(-6px - var(--space-sm)); /* dot hangs into the margin */
        padding: var(--space-xs) 0;
        border: none;
        background: none;
        color: var(--text-secondary);
        font: inherit;
        font-weight: var(--weight-medium);
        text-align: left;
        cursor: pointer;
        transition: color 0.15s ease;
    }

    .toc-list button::before {
        content: "";
        flex-shrink: 0;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: transparent;
    }

    .toc-list button:hover,
    .toc-list button:focus-visible {
        color: var(--text-primary);
    }

    .toc-list button[aria-current="true"] {
        color: var(--text-primary);
        font-weight: var(--weight-semibold);
    }

    .toc-list button[aria-current="true"]::before {
        background-color: var(--accent-color);
    }

    /* Return to Top */
    .toc-top {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
        bottom: var(--space-xl);
        border: none;
        background: none;
        color: var(--text-secondary);
        font: inherit;
        cursor: pointer;
    }

    .toc-top-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        border: 1px solid var(--text-secondary);
        border-radius: 50%;
        background-color: var(--bg-color);
        color: var(--text-primary);
        transition: background-color 0.15s ease;
    }

    .toc-top:hover,
    .toc-top:focus-visible {
        color: var(--text-primary);
    }

    .toc-top:hover .toc-top-icon,
    .toc-top:focus-visible .toc-top-icon {
        background-color: var(--bg-thumbnail);
    }
}
