/* =============================================================================
   Theme tokens
   Colors use light-dark(): OS preference by default, or data-theme from theme.js.
   ============================================================================= */

:root {
    color-scheme: light dark;

    /* Surfaces */
    --bg-color: light-dark(#e8eff7, #0e141d);
    --card-bg: light-dark(#f6f9fd, #161e2a);
    /* Match the page wash (not cards) so the bar stays distinct from main panels
       without glassy see-through over the scrolling resume. */
    --nav-bg: var(--bg-color);
    --nav-border: light-dark(rgba(45, 52, 54, 0.1), rgba(255, 255, 255, 0.1));
    --card-border: light-dark(rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.08));
    --divider-color: light-dark(#d9dee5, #2a3547);

    /* Text */
    --primary-text: light-dark(#2d3436, #e8ecf2);
    --secondary-text: light-dark(#636e72, #9aa7b5);

    /* Accent (Electric Ocean) */
    --accent-start: light-dark(#005bea, #3d8bff);
    --accent-end: light-dark(#00b0f0, #37c6ff);
    --accent-gradient: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    --accent-solid: light-dark(#005bea, #4d94ff);

    /* Chips / pills — derived from accent + card so they stay readable in both themes */
    --accent-tint: color-mix(in srgb, var(--accent-solid) 12%, var(--card-bg));
    --nav-accent-tint: color-mix(in srgb, var(--accent-solid) 14%, var(--card-bg));
    /* Light’s card-border is a white rim (fine on glassy cards, invisible on
       the near-white theme chip). Ink mix so the mobile dropdown has an edge. */
    --switcher-edge: light-dark(
        color-mix(in srgb, var(--primary-text) 16%, transparent),
        color-mix(in srgb, var(--primary-text) 22%, transparent)
    );
    --switcher-selected: light-dark(
        color-mix(in srgb, var(--accent-solid) 20%, var(--card-bg)),
        var(--nav-accent-tint)
    );
    --tag-bg: color-mix(in srgb, var(--accent-solid) 8%, var(--card-bg));
    --tag-bg-hover: color-mix(in srgb, var(--accent-solid) 14%, var(--card-bg));

    /* Shadows */
    --shadow-color-soft: light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.35));
    --shadow-soft: 0 10px 30px -5px var(--shadow-color-soft);

    /* Atmospheric washes behind the page (overridden by the paper theme) */
    --bg-wash-a: rgba(9, 132, 227, 0.05);
    --bg-wash-b: rgba(116, 185, 255, 0.05);

    /* White "paper" surfaces (resume sheet): full brightness in light mode,
       dimmed in dark mode so the sheet doesn't over-adapt the eye — which
       otherwise causes a grey afterimage when switching back to light.
       light-dark() can't hold a number, so dark overrides set this below. */
    --paper-brightness: 1;

    /* Radii & type */
    --radius-lg: 20px;
    --radius-sm: 8px;
    --page-max: 1600px;
    --page-gutter: 3rem;
    /* OS faces — no webfont swap, so Education/Projects cannot re-wrap on load. */
    --font-main: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-heading: ui-serif, 'Iowan Old Style', Palatino, Georgia, serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* Manual override from the theme toggle */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }
:root[data-theme="paper"] { color-scheme: light; }

/* Anthropic / Claude light: ivory canvas, slate ink, clay accent.
   Tokens from Anthropic’s public brand swatches (ivory / slate / clay).
   Explicit values: light-dark() only has two legs, so paper cannot ride it. */
:root[data-theme="paper"] {
    --bg-color: #f0eee6;       /* ivory-medium */
    --card-bg: #faf9f5;        /* ivory-light */
    --nav-border: #e8e6dc;     /* ivory-dark */
    --card-border: rgba(232, 230, 220, 0.95);
    --divider-color: #e8e6dc;
    --primary-text: #141413;   /* slate-dark */
    --secondary-text: #5e5d59; /* slate-light */
    --accent-start: #c6613f;   /* clay hover */
    --accent-end: #d97757;     /* clay */
    --accent-solid: #d97757;
    --shadow-color-soft: rgba(20, 20, 19, 0.08);
    --bg-wash-a: rgba(217, 119, 87, 0.07);
    --bg-wash-b: rgba(212, 162, 127, 0.08); /* kraft */
    --paper-brightness: 1;
    --switcher-edge: var(--card-border);
    --switcher-selected: var(--nav-accent-tint);
}

/* Dim paper surfaces in dark mode (OS preference or manual toggle) */
:root[data-theme="dark"] { --paper-brightness: 0.95; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) { --paper-brightness: 0.95; }
}

/* While the theme snaps, disable transitions so chips/pills don't interpolate
   light↔dark colors through a washed-out mid frame (reads as a white flash).
   Hover transitions resume after the snap has painted — see theme.js. */
html.theme-switching,
html.theme-switching * {
    transition: none !important;
}

/* =============================================================================
   Base
   ============================================================================= */

html {
    /* Smooth scrolling is enabled after load (see layout.js) so refresh
       can restore Y without animating from the top. */
    overscroll-behavior-y: none;
    /* Prevent the browser from nudging scrollY when fonts/layout reflow */
    overflow-anchor: none;
    /* iOS otherwise inflates type; em-based nav/theme sizes then drift vs 1px chrome. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Kill double-tap zoom; pinch-zoom still works. */
    touch-action: manipulation;
}

html.smooth-scroll {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-anchor: none;
    font-family: var(--font-main);
    color: var(--primary-text);
    line-height: 1.7;
}

/* Fixed atmospheric background (noise + soft radial washes) */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--bg-color);
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E"),
        radial-gradient(circle at 10% 20%, var(--bg-wash-a) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, var(--bg-wash-b) 0%, transparent 40%);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
}

/* =============================================================================
   Navigation & theme toggle
   ============================================================================= */

nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.25em;
    box-sizing: border-box;
    --nav-inset-y: 0.7rem;
    --nav-border-width: 1px;
    padding: var(--nav-inset-y) 2rem;
    background: var(--nav-bg);
    border-bottom: var(--nav-border-width) solid var(--nav-border);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--primary-text) 4%, transparent),
        0 8px 24px -12px color-mix(in srgb, var(--primary-text) 12%, transparent);
    font-size: 0.95rem;
    --nav-leading: 1.7;
    --nav-pad-y: 0.42em;
    --nav-pad-x: 0.95em;
    --nav-pill-height: calc(1em * var(--nav-leading) + var(--nav-pad-y) * 2);
    --nav-theme-size: calc(var(--nav-pill-height) * 1.2);
    --page-edge: calc((100% - min(100%, var(--page-max))) / 2 + var(--page-gutter));
    /* Filled-bar height, empty or not (border-box). See Layout / First paint. */
    min-height: calc(var(--nav-pill-height) + var(--nav-inset-y) * 2 + var(--nav-border-width));
    line-height: var(--nav-leading);
}

nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    margin: 0;
    padding: var(--nav-pad-y) var(--nav-pad-x);
    min-height: var(--nav-pill-height);
    border-radius: var(--radius-sm);
    color: var(--primary-text);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.25s ease, background-color 0.25s ease;
}

html.is-resizing nav {
    pointer-events: none;
}

nav a.active,
html:not(.is-resizing) nav a:hover {
    color: var(--accent-solid);
    background-color: var(--nav-accent-tint);
}

nav a::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 0.13em;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

nav a.active::after,
html:not(.is-resizing) nav a:hover::after {
    width: 70%;
}

.nav-row {
    display: contents;
}

.theme-switcher-slot {
    position: absolute;
    top: 50%;
    right: var(--page-edge);
    z-index: 1001;
    transform: translateY(-50%);
}

.theme-switcher {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    gap: 0.15em;
    --switcher-pad: 0.2em;
    padding: var(--switcher-pad);
    min-height: var(--nav-theme-size);
    border: 0;
    border-radius: 999px;
    background: var(--card-bg);
    /* Hairline via shadow so a 1px border can't round width ≠ height on 3× screens. */
    box-shadow: var(--shadow-soft), 0 0 0 1px var(--switcher-edge);
}

.theme-switcher button {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    flex: 0 0 auto;
    width: calc(var(--nav-theme-size) - var(--switcher-pad) * 2);
    height: calc(var(--nav-theme-size) - var(--switcher-pad) * 2);
    padding: 0;
    border: none;
    border-radius: 50%;
    line-height: 0;
    background: transparent;
    color: var(--secondary-text);
    cursor: pointer;
    transition: color 0.25s ease, background-color 0.25s ease;
}

.theme-switcher button:hover,
.theme-switcher button:focus-visible,
.theme-switcher button[aria-checked="true"] {
    background: var(--switcher-selected);
    color: var(--accent-solid);
}

.theme-switcher svg {
    display: block;
    width: 50%;
    height: 50%;
}

.theme-switcher .theme-dismiss {
    display: none;
}

/* =============================================================================
   Layout

   Hard refresh (Cmd+Shift+R) can paint the HTML before layout.js. Each page
   ships empty <nav> / <aside class="sidebar"> / <footer> mounts; CSS reserves
   their size; layout.js fills them. Three first-paint ghosts, all “old bottom
   edge stays on screen ~0.1s”:

     Nav      Empty bar was taller than the filled one (content-box min-height
              double-counted padding). Replacing it jumped main up. Fix: nav is
              border-box and always uses the filled min-height.
     Sidebar  Desktop card is position:fixed; top/bottom come from JS. First
              paint was content-height, then it stretched. Fix: hide until pin.
     Main     Hiding only the sidebar left main on screen alone. When the pinned
              sidebar then composited beside it, GPU kept a stale tile of main’s
              rounded bottom + shadow. Fix: hide main under the same class.

   html.cards-pending is set in theme.js (<head>) and lifted in layout.js after
   the pin. Desktop only; visibility (not display) so grid space stays reserved.
   ============================================================================= */

.container {
    /* Grid keeps the historic 1:3 column split; an empty flex spacer was
       losing width to main’s min-content when the card became position:fixed. */
    display: grid;
    grid-template-columns: 1fr 3fr;
    align-items: start;
    gap: 3rem;
    max-width: var(--page-max);
    /* Tighter bottom than top: shortens the fixed sidebar (pin uses this
       margin + footer) while the in-flow main still has room above the footer. */
    margin: 3rem auto 2rem;
    padding: 0 var(--page-gutter);
}

/* In-flow 1fr column while the inner .sidebar is position:fixed. */
.sidebar-spacer {
    min-width: 0;
    min-height: 22rem;
}

.sidebar {
    box-sizing: border-box;
    padding: 2.5rem;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

@media (min-width: 1001px) {
    html.cards-pending .sidebar,
    html.cards-pending .main-content {
        visibility: hidden;
    }

    /* Filled card only. The HTML placeholder stays in-flow (no 22rem ghost layer). */
    .sidebar-spacer .sidebar {
        position: fixed;
        z-index: 1;
        isolation: isolate;
        overflow: clip; /* square scroll layer otherwise flashes on the radius */
        overscroll-behavior: contain;
    }

    .sidebar header,
    .sidebar h1,
    .sidebar p {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .sidebar .profile-pic {
        max-width: 100%;
        height: auto;
        aspect-ratio: 1;
    }
}

/* Empty <aside class="sidebar" aria-busy> holds the left 1fr so main is not
   full-width before layout.js wraps it in .sidebar-spacer. Strip paint:
   a hidden box-shadow still ghosts when the node is replaced. */
.sidebar[aria-busy="true"],
.sidebar:not(:has(header)) {
    visibility: hidden;
    min-height: 22rem;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.profile-pic {
    width: 160px;
    height: 160px;
    margin-bottom: 1.5rem;
    object-fit: cover;
    border: 3px solid var(--card-bg);
    border-radius: 50%;
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--accent-solid) 35%, transparent),
        0 8px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.profile-pic:hover {
    transform: scale(1.05);
}

.main-content {
    min-width: 0;
    padding: 3rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    isolation: isolate; /* own layer once visible; see Layout / First paint */
}

/* Resume page: PDF viewer in the main (right) column */
.main-content.resume-page {
    display: flex;
    flex-direction: column;
}

.resume-viewer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.resume-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.resume-toolbar h2 {
    margin-top: 0;
    margin-bottom: 0;
}

.resume-toolbar .link-row {
    margin-bottom: 0;
}

/* PDF.js canvas preview — white page, no native viewer chrome; links overlay on top. */
.resume-pdf {
    position: relative;
    width: 100%;
    /* Hold A4 space while PDF.js paints, then fade the canvas in. */
    aspect-ratio: 210 / 297;
    color-scheme: light;
    /* Soft accent hairline + light lift: separates from the card without a grey ring
       that makes the page look muddy (esp. after dark → light). */
    border: 1px solid color-mix(in srgb, var(--accent-solid) 14%, var(--card-bg));
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
    line-height: 0;
    /* Deeper lift in dark mode so the white sheet reads as mounted, not floating. */
    box-shadow: light-dark(
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 6px 24px -6px rgba(0, 0, 0, 0.55)
    );
    filter: brightness(var(--paper-brightness));
}

/* Absolutely positioned until ready so the invisible canvas doesn’t fight
   the A4 aspect-ratio placeholder (which looked like a oversized white sheet). */
.resume-pdf-page {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.resume-pdf.is-ready .resume-pdf-page {
    position: relative;
    inset: auto;
    opacity: 1;
    pointer-events: auto;
}

.resume-pdf-page canvas {
    display: block;
    width: 100%;
    height: auto;
}

@media (prefers-reduced-motion: reduce) {
    .resume-pdf-page {
        transition: none;
    }
}

.resume-pdf-links {
    position: absolute;
    inset: 0;
}

.resume-pdf-links a {
    position: absolute;
    z-index: 1;
    border-radius: 2px;
}

.resume-pdf-links a:hover {
    background: color-mix(in srgb, var(--accent-solid) 14%, transparent);
}

.main-content p {
    max-width: 85ch;
}

.main-content ul {
    padding-left: 1.25em;
}

.main-content ul ul {
    list-style-type: circle;
}

.main-content hr {
    margin: 1.25em 0;
    border: none;
    border-top: 1px solid var(--divider-color);
}

/* =============================================================================
   Typography
   ============================================================================= */

h1, h2, h3 {
    font-family: var(--font-heading);
}

h1 {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 2.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Keep the name proportionate in the narrow sidebar */
.sidebar h1 {
    font-size: 1.5rem;
    line-height: 1.35;
    text-wrap: balance;
}

/* CFA / FRM verify links — same gradient as the title; underline signals “checkable” */
.credential-group {
    white-space: nowrap;
}

.credential-link {
    --credential-hover-from: light-dark(
        color-mix(in srgb, var(--accent-start) 72%, #000),
        color-mix(in srgb, var(--accent-start) 50%, #fff)
    );
    --credential-hover-to: light-dark(
        color-mix(in srgb, var(--accent-end) 55%, #000),
        color-mix(in srgb, var(--accent-end) 35%, #fff)
    );
    /* Solid stand-in for the hover gradient (underline can only be one color) */
    --credential-hover-line: color-mix(
        in srgb,
        var(--credential-hover-from) 55%,
        var(--credential-hover-to)
    );

    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent-solid) 40%, transparent);
    text-decoration-thickness: 0.045em;
    text-underline-offset: 0.2em;
    transition:
        text-decoration-color 0.2s ease,
        text-decoration-thickness 0.2s ease;
}

.credential-link:hover,
.credential-link:focus-visible {
    /* Light: deepen the letters; dark: brighten them */
    background: linear-gradient(
        135deg,
        var(--credential-hover-from),
        var(--credential-hover-to)
    );
    -webkit-background-clip: text;
    background-clip: text;
    text-decoration-color: var(--credential-hover-line);
    text-decoration-thickness: 0.07em;
    outline: none;
}

.credential-link:focus-visible {
    text-decoration-thickness: 0.09em;
}

h2 {
    position: relative;
    margin-top: 2rem;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    font-size: 1.5rem;
    color: var(--primary-text);
}

h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    width: 0.17em;
    height: 80%;
    border-radius: 0.17em;
    background: var(--accent-gradient);
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary-text);
}

/* =============================================================================
   Content blocks (experience, education, projects, skills)
   ============================================================================= */

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-top: 1rem;
}

.entry-meta {
    text-align: right;
    white-space: nowrap;
}

.course-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    align-items: first baseline;
    column-gap: 0.75ch;
    max-width: 600px;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.45;
}

.course-name {
    min-width: 0;
}

/* Grid items are blockified, so clone lives on the inner inline span.
   Horizontal pad is always on so hover tint never shifts spacing. */
.course-name > span {
    padding: 0 0.2em;
    margin: 0 -0.2em;
    border-radius: var(--radius-sm);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Hovering a track pill highlights its related coursework */
.school-entry:has([data-highlight-track="ai"]:is(:hover, :focus-visible))
    .course-row[data-tracks~="ai"] .course-name > span,
.school-entry:has([data-highlight-track="is"]:is(:hover, :focus-visible))
    .course-row[data-tracks~="is"] .course-name > span {
    color: var(--accent-solid);
    background: var(--accent-tint);
}

.course-grade {
    width: 2ch;
    font-weight: 500;
}

/* Education / Projects: drop the last block’s leftover margin so the card
   sits flush. Home skill rows keep theirs — that page is already stable. */
.school-entry:last-child ul:last-child,
.project-card:last-child,
.project-card ul:last-child {
    margin-bottom: 0;
}

/* Projects: outer card is the layout box (hover + clip). Inner is the fade
   target, like Education .school-entry (no extra padded box translating). */
.project-card {
    margin: 0 0 1rem;
    padding: 1.25rem 1.35rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius-sm) + 4px);
    background: transparent;
    overflow: clip;
    transition:
        transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
        box-shadow 0.3s ease,
        border-color 0.3s ease,
        background-color 0.3s ease;
}

.project-card-inner {
    min-width: 0;
}

.project-card:hover {
    transform: translateY(-3px);
    background: color-mix(in srgb, var(--accent-solid) 4%, var(--card-bg));
    border-color: color-mix(in srgb, var(--accent-solid) 16%, var(--card-border));
    box-shadow: var(--shadow-soft);
}

.project-card a:has(.github-icon) {
    flex-shrink: 0;
    line-height: 0;
}

.project-title {
    margin: 0 0 0.6rem;
    color: var(--primary-text);
}

.link-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.project-meta {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-style: normal;
    letter-spacing: 0.01em;
    color: var(--secondary-text);
}

.pill-link,
.track-pill {
    display: inline-block;
    padding: 0.22em 0.88em;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.pill-link {
    background: var(--accent-tint);
    color: var(--accent-solid);
    text-decoration: none;
}

.pill-link:hover,
.pill-link:focus-visible {
    background: var(--accent-solid);
    color: #fff;
    outline: none;
}

.pill-link.pill-disabled,
.pill-link.pill-disabled:hover,
.pill-link.pill-disabled:focus-visible {
    cursor: default;
    background: var(--accent-tint);
    color: var(--accent-solid);
}

/* Non-clickable track labels — tag-like, soft hover cues course highlight */
.track-pill {
    background: var(--tag-bg);
    color: var(--primary-text);
    cursor: default;
}

.track-pill:hover,
.track-pill:focus-visible {
    background: var(--accent-tint);
    color: var(--accent-solid);
    outline: none;
}

.github-icon {
    width: 1.25em;
    height: 1.25em;
    vertical-align: middle;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.github-icon:hover {
    opacity: 1;
}

.skill-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.2rem;
}

.skill-label {
    width: 100%;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    color: var(--secondary-text);
}

.skill-content {
    font-weight: 500;
    color: var(--primary-text);
}

.tag {
    display: inline-block;
    margin: 0 0.6em 0.6em 0;
    padding: 0.4em 0.95em;
    border-radius: 999px;
    background: var(--tag-bg);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    transition: background-color 0.25s ease;
}

/* Tags are not links — keep hover subtle */
.tag:hover {
    background: var(--tag-bg-hover);
}

footer {
    box-sizing: border-box;
    padding: 1rem 0 1.25rem;
    min-height: calc(2.25rem + 1.7em); /* filled height while the mount is empty */
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-text);
    background: transparent;
}

footer p {
    margin: 0;
}

/* =============================================================================
   Motion
   Theme crossfade: theme.js (View Transitions). Do not interpolate tokens.
   Scroll reveal: motion.js. Selectors here must match NESTED / sections there.
     Home, Resume     — whole <section>
     Education        — h2 + .school-entry
     Projects         — h2 + .project-card-inner  (not the padded .project-card)
   ============================================================================= */

@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.4s;
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }

    html.reveal-pending :is(
        .main-content > section:not(:has(.project-card, .school-entry)),
        .main-content > section:has(.project-card, .school-entry) > h2,
        .school-entry,
        .project-card-inner
    ):not(.is-visible),
    .reveal {
        opacity: 0;
        transform: translateY(10px);
    }

    .reveal {
        transition:
            opacity 0.55s cubic-bezier(0.25, 0.8, 0.25, 1),
            transform 0.55s cubic-bezier(0.25, 0.8, 0.25, 1);
        transition-delay: var(--reveal-delay, 0ms);
    }

    html.reveal-pending :is(
        .main-content > section:not(:has(.project-card, .school-entry)),
        .main-content > section:has(.project-card, .school-entry) > h2,
        .school-entry,
        .project-card-inner
    ).is-visible,
    .reveal.is-visible {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-card:hover {
        transform: none;
    }
}

/* =============================================================================
   Theme chrome (GitHub glyph in dark)
   ============================================================================= */

:root[data-theme="dark"] .github-icon {
    filter: invert(1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .github-icon {
        filter: invert(1);
    }
}

/* =============================================================================
   Responsive
   ============================================================================= */

/* Theme pill + sidebar stack together before the two-column chrome gets skinny. */
@media (max-width: 1000px) {
    :root {
        --page-gutter: 2rem;
    }

    nav {
        justify-content: center;
        --nav-inset-y: 0.6rem;
        padding: var(--nav-inset-y) calc(var(--nav-theme-size) + 0.5em) var(--nav-inset-y) 1.5rem;
        font-size: 0.9rem;
    }

    nav a {
        white-space: nowrap;
    }

    /* One control: same origin, same circle, closed or open. */
    .theme-switcher-slot,
    .theme-switcher-slot.is-open {
        top: calc(50% - var(--nav-theme-size) / 2);
        right: var(--page-edge);
        transform: none;
    }

    .theme-switcher-slot .theme-switcher {
        display: grid;
        place-items: center;
        box-sizing: border-box;
        padding: var(--switcher-pad);
        gap: 0;
        width: var(--nav-theme-size);
        max-width: var(--nav-theme-size);
        min-height: 0;
    }

    /* Fill the padded hole — do not calc a second size (that sat top-right). */
    .theme-switcher-slot .theme-switcher button {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
    }

    .theme-switcher-slot:not(.is-open) .theme-switcher {
        height: var(--nav-theme-size);
        overflow: hidden;
    }

    .theme-switcher-slot.is-open .theme-switcher {
        display: flex;
        flex-direction: column;
        align-items: center;
        height: auto;
        gap: 0.15em;
    }

    .theme-switcher-slot.is-open .theme-switcher button {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .theme-switcher-slot:not(.is-open) .theme-dismiss,
    .theme-switcher-slot:not(.is-open) .theme-switcher button:not([aria-checked="true"]) {
        display: none;
    }

    .theme-switcher-slot.is-open .theme-dismiss {
        display: grid;
    }

    .container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-top: 1.5rem;
        padding: 1rem var(--page-gutter);
    }

    .sidebar-spacer,
    .main-content {
        width: 100%;
        box-sizing: border-box;
    }

    .sidebar {
        position: static;
        top: auto;
        bottom: auto;
        left: auto;
        width: auto;
        overflow: visible;
        padding: 1.5rem;
    }

    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    :root {
        --page-gutter: 1rem;
    }

    nav {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: center;
        --nav-inset-y: 0.7em;
        --nav-row-gap: 0.45em;
        --nav-theme-size: calc(var(--nav-pill-height) * 1.4);
        gap: var(--nav-row-gap);
        padding: var(--nav-inset-y) calc(var(--nav-theme-size) + 0.5em) var(--nav-inset-y) 1.2em;
        font-size: 0.85rem;
        /* Two-row filled height (border-box). See Layout / First paint. */
        min-height: calc(var(--nav-pill-height) * 2 + var(--nav-row-gap) + var(--nav-inset-y) * 2 + var(--nav-border-width));
    }

    /* Two rows of three, equal columns so Home/Resume, Education/LinkedIn,
       Projects/GitHub share a vertical axis. */
    .nav-row {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-items: center;
        width: 100%;
        max-width: 20em;
        gap: 0.2em 0.25em;
    }

    nav a {
        display: flex;
        justify-content: center;
        width: max-content;
        text-align: center;
    }

    .container {
        margin-top: 1rem;
        padding: var(--page-gutter);
    }

    h1 {
        font-size: 2rem;
    }

    .entry-header {
        flex-direction: column;
        gap: 0.2rem;
    }

    .entry-meta {
        text-align: left;
        white-space: normal;
    }
}
