/* ==========================================================================
   Charles S. Carreon — Portfolio styles
   Dark theme by default; light theme via html[data-theme="light"].
   No-JS safe: everything readable without this file.
   ========================================================================== */

:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d212a;
    --text: #e6e8eb;
    --text-strong: #ffffff;
    --muted: #9aa3ad;
    --border: #2a2f3a;
    --accent: #2dd4a7;
    --accent-strong: #5eead4;
    --accent-contrast: #08120f;
    --link: #2dd4a7;
    --hover: #5eead4;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);

    /* Skill proficiency level colors (dark theme) */
    --familiar-bg: rgba(138, 180, 248, 0.14);
    --familiar-border: rgba(138, 180, 248, 0.5);
    --familiar-text: #8ab4f8;
    --proficient-bg: rgba(255, 209, 102, 0.14);
    --proficient-border: rgba(255, 209, 102, 0.5);
    --proficient-text: #ffd166;
    --advanced-bg: rgba(116, 209, 160, 0.14);
    --advanced-border: rgba(116, 209, 160, 0.5);
    --advanced-text: #74d1a0;
}

[data-theme="light"] {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1a1d21;
    --text-strong: #000000;
    --muted: #5b6470;
    --border: #dde1e7;
    --accent: #0e7a70;
    --accent-strong: #0f766e;
    --accent-contrast: #ffffff;
    --link: #0e7a70;
    --hover: #0f766e;
    --shadow: 0 4px 20px rgba(20, 30, 40, 0.08);

    /* Skill proficiency level colors (light theme) */
    --familiar-bg: rgba(10, 88, 202, 0.22);
    --familiar-border: rgba(10, 88, 202, 0.6);
    --familiar-text: #0842a0;
    --proficient-bg: rgba(180, 83, 9, 0.22);
    --proficient-border: rgba(180, 83, 9, 0.6);
    --proficient-text: #9a3f00;
    --advanced-bg: rgba(21, 115, 71, 0.22);
    --advanced-border: rgba(21, 115, 71, 0.6);
    --advanced-text: #0f5c39;
}

/* ---------- Base ---------- */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.65;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    line-height: 1.25;
    margin: 0 0 0.75rem;
}

h1 { font-size: clamp(2rem, 5vw, 2.9rem); }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); }
h3 { font-size: 1.1rem; }

p {
    margin: 0 0 1rem;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

strong { color: var(--text-strong); }

img,
iframe {
    max-width: 100%;
}

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

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

/* ---------- Accessibility helpers ---------- */

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.skip-link {
    position: absolute;
    top: -2.5rem;
    left: 1rem;
    z-index: 50;
    background-color: var(--accent);
    color: var(--accent-contrast);
    padding: 0.5rem 1rem;
    border-radius: 0 0 0.5rem 0.5rem;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
}

.skip-link:focus {
    top: 0;
    color: var(--accent-contrast);
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Header / navigation ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background-color: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.site-nav {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0.75rem clamp(1rem, 4vw, 1.25rem);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-strong);
    text-decoration: none;
    margin-right: auto;
}

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

.nav-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.nav-list a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0.1rem;
}

.nav-list a:hover { color: var(--text-strong); }

.nav-list a[aria-current="page"] {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

/* Theme switch — only shown when JS is available */
.theme-switch {
    display: none;
}

.no-js .theme-switch { display: none; }

html.js .theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 1.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    padding: 0;
    margin-left: 1rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

html.js .theme-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html.js .theme-switch .theme-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0.2rem;
    width: 0.95rem;
    height: 0.95rem;
    color: var(--text-strong);
    transition: left 0.2s ease;
    pointer-events: none;
}

html.js .theme-switch .theme-icon--sun {
    display: block;
}

html.js .theme-switch .theme-icon--moon {
    display: none;
}

html.js[data-theme="light"] .theme-switch .theme-icon {
    left: calc(100% - 0.2rem - 0.95rem);
}

html.js[data-theme="light"] .theme-switch .theme-icon--sun {
    display: none;
}

html.js[data-theme="light"] .theme-switch .theme-icon--moon {
    display: block;
}

/* Without CSS/JS the button shows its text label; hide icons without JS so the
   fallback is a clean labelled button. */
html.no-js .theme-switch svg {
    display: none;
}

/* Larger tap target on touch devices (~44px) */
@media (pointer: coarse) {
    html.js .theme-switch {
        width: 2.75rem;
        height: 1.5rem;
    }

    html.js .theme-switch .theme-icon {
        width: 1.05rem;
        height: 1.05rem;
        left: 0.25rem;
    }

    html.js[data-theme="light"] .theme-switch .theme-icon {
        left: calc(100% - 0.25rem - 1.05rem);
    }

    /* Expand the theme switch's touch area to ~44x44px without changing its
       compact look: a transparent, centered hit zone on top of the pill. */
    html.js .theme-switch::after {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 2.75rem;
        height: 2.75rem;
        transform: translate(-50%, -50%);
        pointer-events: none;
    }

    /* 44px-tall touch targets for gallery controls and pill links */
    .gallery-nav button,
    .links a,
    .btn,
    .project-dialog-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 2.75rem;
        line-height: 1;
    }
}

html.home .theme-switch {
    margin-left: 0;
}

html.projects .theme-switch,
html.skills .theme-switch,
html.achievements .theme-switch,
html.experience .theme-switch {
    flex: 0 0 auto;
    margin-left: 0;
}

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

main {
    max-width: 1040px;
    margin: 0 auto;
    padding: 2.5rem clamp(1rem, 4vw, 1.25rem) 3rem;
    overflow-wrap: anywhere;
}

html.home {
    /* Script.js writes progress from 0 at the top of the page to 1 at the end
       of the shrink, so the cover follows the scroll instead of snapping. */
    --hero-progress: 0;
    --hero-viewport: 100vh;
    --hero-min: 11rem;
    --hero-height: calc(var(--hero-min) + (var(--hero-viewport) - var(--hero-min)) * (1 - var(--hero-progress)));
    /* There is no sticky header to clear on the homepage. */
    scroll-padding-top: 1rem;
    /* Opting out of scroll anchoring keeps the browser from moving scrollY
       while the cover changes height. */
    overflow-anchor: none;
}

html.home main {
    padding-top: 0;
}

main:focus {
    outline: none;
}

.section,
main > .card {
    margin-bottom: 2.5rem;
}

.section > :last-child,
.card > :last-child {
    margin-bottom: 0;
}

.projects-head,
.skills-head,
.certs-head,
.achievements-head,
.experience-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.projects-head__copy,
.skills-head__copy,
.certs-head__copy,
.achievements-head__copy,
.experience-head__copy {
    max-width: 46rem;
}

.projects-head h2,
.skills-head h2,
.certs-head h2,
.achievements-head h2,
.experience-head h2 {
    margin-top: 0;
}

.projects-head p,
.skills-head p,
.certs-head p,
.achievements-head p,
.experience-head p {
    margin-bottom: 0;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.featured-card {
    display: flex;
    flex-direction: column;
}

.featured-card h3 {
    margin-top: 0;
}

.featured-card p {
    margin-bottom: 0.75rem;
}

.featured-card__more {
    margin-top: auto;
    padding-top: 0.75rem;
}

.featured-more {
    margin-top: 1.25rem;
}

.skills-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.skills-summary__group h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

@media (max-width: 760px) {
    .featured-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .skills-summary {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    max-width: 46rem;
    margin: 0 auto 3rem;
    padding: 2.5rem clamp(1rem, 4vw, 1.25rem) 0;
    text-align: center;
}

.hero .tagline {
    font-size: clamp(1.1rem, 3vw, 1.35rem);
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1.25rem;
}

/* The availability line belongs to the tagline as one thought, so it closes the
   gap the tagline leaves instead of opening a new block. Browsers without
   :has() simply keep the normal tagline spacing. */
.hero .tagline:has(+ .hero-availability) {
    margin-bottom: 0.4rem;
}

.hero-availability {
    margin: 0 0 1.25rem;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
}

.hero-cta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.5rem 0 0;
}

/* The primary contact row outranks the social links, so the social links are
   muted rather than removed. Every one of them is still reachable. */
.hero .contact {
    margin-top: 1.25rem;
    font-size: 0.88rem;
}

.hero .contact a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
}

.hero .contact svg {
    display: block;
    width: 1.1rem;
    height: 1.1rem;
    flex: none;
}

.hero .contact a:hover {
    color: var(--hover);
}

@supports (height: 100svh) {
    html.home {
        --hero-viewport: 100svh;
    }

    html.home.js .hero {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        max-width: none;
        min-height: var(--hero-height);
        margin-bottom: 0;
        padding: calc(2rem - 0.5rem * var(--hero-progress)) clamp(1rem, 4vw, 1.25rem);
    }

    html.home.js .hero > :not(.scroll-cue) {
        width: 100%;
        max-width: 46rem;
    }

    html.home.js .hero h1 {
        font-size: calc(clamp(2rem, 5vw, 2.9rem) - clamp(0.45rem, 1.2vw, 0.9rem) * var(--hero-progress));
    }

    html.home.js .hero .tagline {
        font-size: calc(clamp(1.1rem, 3vw, 1.35rem) - clamp(0.15rem, 0.5vw, 0.25rem) * var(--hero-progress));
        margin-bottom: calc(1.25rem - 1.05rem * var(--hero-progress));
    }

    html.home.js .hero .tagline:has(+ .hero-availability) {
        margin-bottom: calc(0.4rem - 0.2rem * var(--hero-progress));
    }

    html.home.js .hero .hero-availability {
        margin-bottom: calc(1.25rem - 0.65rem * var(--hero-progress));
        font-size: calc(0.95rem - 0.1rem * var(--hero-progress));
    }

    html.home.js .hero > p:not(.tagline):not(.hero-availability):not(.hero-cta):not(.contact) {
        font-size: calc(1rem - 0.08rem * var(--hero-progress));
    }

    html.home.js .hero .hero-cta {
        margin-top: calc(1.5rem - 0.65rem * var(--hero-progress));
    }

    html.home.js .hero .contact {
        margin-top: calc(1.25rem - 0.55rem * var(--hero-progress));
        font-size: calc(0.88rem - 0.08rem * var(--hero-progress));
    }

    html.home main {
        padding-top: 2.5rem;
    }
}

/* ---------- Cover heroes: bare down chevron ---------- */

.scroll-cue {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    color: var(--muted);
    transition: color 160ms ease, opacity 160ms ease;
}

.scroll-cue[hidden] {
    display: none;
}

.scroll-cue svg {
    display: block;
    width: 1.35rem;
    height: 1.35rem;
}

.scroll-cue:hover,
.scroll-cue:focus-visible {
    color: var(--hover);
}

.scroll-cue--down {
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    animation: cue-bob 1.8s ease-in-out infinite;
    opacity: calc(1 - var(--hero-progress) * 4);
}

@keyframes cue-bob {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 0.35rem); }
}

.scroll-cue--back {
    top: 50%;
    left: clamp(0.5rem, 3vw, 1.5rem);
    transform: translateY(-50%);
    opacity: calc(1 - var(--hero-progress) * 4);
}

.scroll-cue__bob {
    display: block;
    line-height: 0;
    animation: cue-sway 1.8s ease-in-out infinite;
}

.scroll-cue__label {
    position: absolute;
    top: 50%;
    left: calc(100% + 0.35rem);
    opacity: 0;
    transform: translate(-0.5rem, -50%);
    transition: opacity 160ms ease, transform 160ms ease;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.scroll-cue--back:hover .scroll-cue__label,
.scroll-cue--back:focus-visible .scroll-cue__label {
    opacity: 1;
    transform: translate(0, -50%);
}

@keyframes cue-sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(0.35rem); }
}

.contact {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 0.75rem;
    row-gap: 0.25rem;
    margin-top: 1.5rem;
}

.contact a {
    white-space: nowrap;
}

/* Footer link groups: icons with visible labels, no literal separators */
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 0.75rem;
    row-gap: 0.25rem;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.footer-links svg {
    display: block;
    width: 1rem;
    height: 1rem;
    flex: none;
}

.footer-links span {
    overflow-wrap: anywhere;
}

/* ---------- Cards ---------- */

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: clamp(1.25rem, 3vw, 1.75rem);
    box-shadow: var(--shadow);
}

/* Homepage cards use a tighter frame than the shared card rule. These stay
   after .card so the scoped padding and radius win the cascade. */
.summary-card {
    padding: 1rem;
    border-radius: 0.75rem;
}

.featured-card {
    padding: 0.85rem;
    border-radius: 0.75rem;
}

.entry-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.25rem 1rem;
}

.entry-head h3 {
    margin-bottom: 0;
}

.entry-head time {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.entry-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 1rem;
    row-gap: 0.25rem;
    align-items: baseline;
}

.entry-grid h3 {
    margin-bottom: 0;
}

.entry-grid time {
    grid-column: 2;
    justify-self: end;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.entry-grid .subtitle {
    grid-column: 1;
}

.entry-grid .location {
    grid-column: 2;
    justify-self: end;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.subtitle {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    background-color: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 999px;
    padding: 0.28rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.tech-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0 0;
}

/* ---------- About ---------- */

.about-card {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.about-card .portrait {
    margin: 0;
    flex: 0 0 auto;
}

.portrait img {
    width: 100%;
    max-width: 250px;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent);
}

.about-card > div {
    flex: 1 1 320px;
    min-width: 0;
}

.headline {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

/* ---------- About: fact list and stat tiles ---------- */

/* Facts sit between the headline and the prose so the card is scannable before
   it is readable. Labels are decorative emphasis; the values carry the meaning. */
.quick-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
}

.quick-facts dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding-top: 0.12rem;
}

.quick-facts dd {
    margin: 0;
}

/* Counts and outcomes as large text, not decoration: they stay readable with
   the stylesheet gone, and a screen reader announces number then label. */
.stat-row {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.stat-row li {
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    padding: 0.85rem 1rem;
}

.stat-row__num {
    display: block;
    color: var(--accent);
    font-size: clamp(1.5rem, 3.5vw, 1.9rem);
    font-weight: 700;
    line-height: 1.15;
}

.stat-row__label {
    display: block;
    margin-top: 0.1rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.35;
}

/* ---------- Alternative: larger card image details ---------- */

.entry-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.entry-list > li {
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
}

.entry-list > li:first-child { padding-top: 0; }
.entry-list > li:last-child { padding-bottom: 0; border-bottom: 0; }

/* ---------- Projects ---------- */

/* Two shorter cards per row on wide screens, one column below that. The
   wrapper owns the section spacing now that the cards are no longer direct
   children of main. */
.project-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 820px) {
    .project-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.project {
    display: flex;
    flex-direction: column;
    padding: 1.1rem;
    border-radius: 0.75rem;
    transition: transform 180ms ease;
}

html.dialog-capable .project {
    cursor: pointer;
}

.project:focus-within {
    transform: translateY(-0.25rem);
}

@media (hover: hover) and (pointer: fine) {
    .project:hover {
        transform: translateY(-0.25rem);
    }
}

.project h2 {
    margin-bottom: 0.6rem;
    font-size: 1.2rem;
}

.project > p:not([class]) {
    font-size: 0.92rem;
}

.project .meta {
    row-gap: 0.25rem;
    margin-bottom: 1rem;
}

/* Positioning context for the award pill, which overlaps the still rather
   than taking a line of its own between the image and the title. */
.project-thumb-wrap {
    position: relative;
    margin-bottom: 0.9rem;
}

/* A compact award badge on the top-left of the still. It uses the site's
   accent throughout: accent fill, uppercase accent-contrast label and a
   contrasting tile holding a teal trophy. */
.project-badge {
    position: absolute;
    z-index: 1;
    top: 0.7rem;
    left: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.28rem 0.6rem 0.28rem 0.42rem;
    border: 1px solid color-mix(in srgb, var(--accent-contrast) 22%, transparent);
    border-radius: 0.5rem;
    background-color: var(--accent);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    color: var(--accent-contrast);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.2;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}

.project-badge__icon {
    box-sizing: content-box;
    width: 0.8rem;
    height: 0.8rem;
    flex: none;
    padding: 0.2rem;
    border-radius: 0.35rem;
    background-color: var(--accent-contrast);
    color: var(--accent);
}

/* One still per card, so the project list is visual before it is textual. The
   same crop and border as the gallery images keeps it inside the site's
   existing image language. height:auto stops the width/height attributes from
   stretching the box away from its 16:9 ratio. */
.project .project-thumb,
.featured-card .project-thumb {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background-color: var(--surface-2);
}

/* Homepage featured cards use a thinner inset frame. The wrapper carries the
   border, so the image sits inside the card rather than becoming the frame. */
.featured-card .project-thumb-wrap {
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background-color: var(--surface-2);
}

.featured-card .project-thumb {
    border: 0;
    border-radius: 0.45rem;
}

/* Achievement lead images use a figure so the shared image class can be reused.
   Reset the UA figure margin to match the plain project card images. */
.project > figure.project-thumb-wrap {
    margin: 0 0 0.9rem;
}

/* Topic chips: plain text rather than links, so they add searchable words
   without adding a second set of destinations to the panel. */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.tags li {
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: var(--surface-2);
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.gallery img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    background-color: var(--surface-2);
}

/* Carousel mode — added by script.js when JS is available */
.gallery.is-carousel {
    display: block;
    position: relative;
}

.gallery.is-carousel img {
    display: none;
    width: auto;
    max-height: min(70vh, 520px);
    aspect-ratio: auto;
    object-fit: contain;
    margin: 0 auto;
}

.gallery.is-carousel img.is-active {
    display: block;
}

.gallery-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.gallery-nav button {
    background-color: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.gallery-nav button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.gallery-nav .gallery-count {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---------- Project metadata ---------- */

.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.35rem;
    margin: 0 0 1.25rem;
}

.meta dt {
    font-weight: 600;
    color: var(--muted);
}

.meta dd {
    margin: 0;
}

/* Per-project detail: a native modal dialog. The page dims, the card list stays
   where it is, and focus containment, Escape and background inertness are the
   browser's job rather than ours. The panel stays visible inline by default;
   script.js adds `dialog-capable` only after it confirms showModal() exists, so
   a reader without JavaScript still gets the text. */
.project-dialog {
    display: block;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background-color: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* Inline fallback only: the panel reads as a section under the links row.
   Nothing here applies once the dialog can actually be modal, because the
   margin would displace the browser's own centring. */
html:not(.dialog-capable) .project-dialog {
    margin: 1.25rem 0 0;
}

/* `margin: auto` is load-bearing: the card list's `.card > :last-child` rule
   zeroes the bottom margin this dialog is the last child of, and without it the
   UA's centring collapses and the panel hangs off the bottom of the viewport. */
.project-dialog[open] {
    margin: auto;
    width: min(42rem, calc(100vw - 2rem));
    max-height: min(85dvh, 44rem);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.project-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .project-dialog::backdrop {
    background-color: rgba(20, 30, 40, 0.45);
}

html.dialog-capable .project-dialog:not([open]) {
    display: none;
}

.project-dialog-body {
    padding: clamp(1.25rem, 4vw, 1.75rem);
}

.project-dialog-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.project-dialog-head h3 {
    margin: 0;
}

.project-dialog-close {
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--link);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.35rem 1rem;
    cursor: pointer;
}

.project-dialog-close:hover {
    background-color: var(--surface-2);
    border-color: var(--link);
    color: var(--hover);
}

.project-dialog h4 {
    margin: 1.25rem 0 0.25rem;
    font-size: 1rem;
}

/* Only the module list gets list indentation and spaced items. Scoping away
   from .tags keeps every topic chip the same height in the flex row. */
.project-dialog ul:not(.tags) {
    margin: 0.5rem 0 0;
    padding-left: 1.15rem;
}

.project-dialog ul:not(.tags) li {
    margin-bottom: 0.35rem;
}

.project-dialog ul:not(.tags) li:last-child {
    margin-bottom: 0;
}

/* Screenshots: 1200px assets shown in a ~600px column, so they are exactly 2x
   at the largest size the panel reaches. The width/height attributes on each
   image carry the same ratio, so the panel does not jump as they decode. */
.project-dialog figure {
    margin: 1.25rem 0 0;
}

.project-dialog img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background-color: var(--surface-2);
}

.project-dialog figcaption {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.dialog-actions {
    margin: 1.25rem 0 0;
}

/* The trigger sits beside the solid project links, so it is drawn with an
   inset shadow rather than a border: the row keeps exactly the same height. */
.links a.project-detail-open {
    background-color: transparent;
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--link);
}

.links a.project-detail-open:hover {
    background-color: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--link);
    color: var(--hover);
}

/* Phones: the panel becomes the screen instead of a card with a scrollbar
   inside it. dvh, so the mobile URL bar cannot clip the close button. */
@media (max-width: 620px) {
    .project-dialog[open] {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

}

/* Get in touch mail draft. It stays hidden until script.js confirms showModal()
   exists and the trigger opens it, so the plain mailto anchor is the no-JS view. */
.contact-dialog {
    display: none;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background-color: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.contact-dialog[open] {
    display: block;
    margin: auto;
    width: min(34rem, calc(100vw - 2rem));
    max-height: min(85dvh, 42rem);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--muted) transparent;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.contact-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .contact-dialog::backdrop {
    background-color: rgba(20, 30, 40, 0.45);
}

.contact-dialog__body {
    padding: clamp(1.25rem, 4vw, 1.75rem);
}

.contact-dialog__to {
    margin: 0.75rem 0 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.contact-dialog__label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.contact-dialog__input,
.contact-dialog__textarea {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background-color: var(--surface-2);
    color: var(--text);
    font: inherit;
    padding: 0.65rem 0.75rem;
}

.contact-dialog__textarea {
    min-height: 9rem;
    resize: vertical;
}

.contact-dialog__actions {
    display: flex;
    justify-content: flex-end;
    margin: 1rem 0 0;
}

/* Phones: the panel becomes the screen instead of a card with a scrollbar
   inside it. dvh, so the mobile URL bar cannot clip the close button. */
@media (max-width: 620px) {
    .contact-dialog[open] {
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }
}

/* Inline code in card copy: a package name and a target framework. Monospace
   is right here, but the browser default sits a size below the body text and
   clashes with the system stack, so it is pulled in line. */
.card code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    padding: 0.1em 0.35em;
    border-radius: 0.3rem;
    background-color: var(--surface-2);
}

.links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 1.25rem 0 0;
}

.project .links {
    margin-top: auto;
    padding-top: 1.25rem;
}

.links a,
.btn {
    display: inline-block;
    background-color: var(--accent);
    color: var(--accent-contrast);
    border-radius: 999px;
    padding: 0.4rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.links a:hover,
.btn:hover {
    background-color: var(--accent-strong);
    color: var(--accent-contrast);
    text-decoration: none;
}

.btn {
    border: none;
    cursor: pointer;
}

/* Hero call to action: a single primary button, sized up so it reads as the
   main action rather than one of the inline project pills. */
.btn--lg {
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
}

/* ---------- Scratch embeds ---------- */

.scratch-embed {
    margin: 0 0 1.25rem;
}

.scratch-embed iframe {
    display: block;
    width: min(100%, 485px);
    height: auto;
    aspect-ratio: 485 / 402;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background-color: var(--surface-2);
}

.scratch-embed figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.scratch-embed figcaption a {
    display: inline-block;
    color: var(--link);
    text-decoration: none;
}

/* ---------- Skills ---------- */

.skills-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 760px) {
    .skills-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.skill-category {
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.skill-category h2 {
    margin: 0 0 0.6rem;
    font-size: 1.05rem;
}

.skill-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.skill-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.15rem 0.75rem;
    padding: 0.4rem 0;
    line-height: 1.35;
    border-bottom: 1px solid var(--border);
}

.skill-list li:last-child {
    border-bottom: 0;
}

.skill-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-strong);
}

.skill-level {
    background-color: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.skill-level--familiar {
    background-color: var(--familiar-bg);
    border-color: var(--familiar-border);
    color: var(--familiar-text);
}

.skill-level--proficient {
    background-color: var(--proficient-bg);
    border-color: var(--proficient-border);
    color: var(--proficient-text);
}

.skill-level--advanced {
    background-color: var(--advanced-bg);
    border-color: var(--advanced-border);
    color: var(--advanced-text);
}

/* ---------- Certifications ---------- */

.cert-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 620px) {
    .cert-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 960px) {
    .cert-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.cert-grid--home {
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.cert-card {
    display: flex;
    flex-direction: column;
    padding: 0.9rem;
    border-radius: 0.75rem;
    background-color: var(--surface-2);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.cert-thumb-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 8rem;
    padding: 0.35rem;
    overflow: hidden;
    border-radius: 0.5rem;
    background-color: var(--surface);
}

.cert-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

/* Homepage certificate cards use the same inset frame as featured projects. */
.cert-grid--home .cert-card {
    padding: 0.85rem;
}

.cert-grid--home .cert-thumb-wrap {
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
}

.cert-card h3 {
    margin: 0.85rem 0 0.15rem;
    font-size: 1rem;
    line-height: 1.35;
}

.cert-issuer {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.cert-card__footer {
    margin-top: auto;
    padding-top: 0.65rem;
}

.cert-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.cert-tag {
    background-color: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.cert-more {
    margin: 0;
    padding-top: 0.85rem;
}

.cert-more a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent);
    color: var(--accent-contrast);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.cert-more a:hover {
    background-color: var(--accent-strong);
    color: var(--accent-contrast);
    border-color: transparent;
}

/* ---------- Footer ---------- */

.site-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 1rem clamp(1rem, 4vw, 1.25rem);
    color: var(--muted);
}

.site-footer address {
    font-style: normal;
    margin-bottom: 0.5rem;
}

.site-footer address p:last-child,
.site-footer > p {
    margin-bottom: 0;
}

.site-footer a {
    white-space: normal;
}

/* ---------- Table of contents ---------- */

/* The TOC now carries the theme switch, so it stays visible at every width.
   Below the sidebar breakpoint it becomes a compact row above the content. */
.toc {
    display: block;
}

.toc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.toc__title {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc a {
    display: inline-block;
    padding: 0.15rem 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 0.9rem;
}

.toc a:hover {
    color: var(--text-strong);
    text-decoration: none;
}

.toc a[aria-current="true"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.page-grid {
    display: flex;
    flex-direction: column;
}

.page-grid .toc {
    order: -1;
    margin-bottom: 1.5rem;
}

@media (min-width: 1160px) {
    .page-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 11.5rem;
        gap: 3rem;
        align-items: start;
    }

    .page-grid .toc {
        order: 0;
        margin-bottom: 0;
        position: sticky;
        top: 2rem;
    }

    .toc ul {
        display: block;
        border-left: 1px solid var(--border);
    }

    .toc a {
        display: block;
        padding: 0.35rem 0 0.35rem 0.85rem;
        margin-left: -1px;
        border-bottom: 0;
        border-left: 2px solid transparent;
    }

    .toc a[aria-current="true"] {
        border-left-color: var(--accent);
        border-bottom-color: transparent;
    }
}

/* ---------- Responsive tweaks ---------- */

/* Tablet portrait / small tablets: collapse two-column data grids when space is tight */
@media (max-width: 760px) {
    .entry-grid {
        grid-template-columns: 1fr;
    }

    .entry-grid time,
    .entry-grid .location {
        grid-column: 1;
        justify-self: start;
    }

    .meta {
        grid-template-columns: 1fr;
        row-gap: 0.15rem;
    }

    .meta dd {
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 620px) {
    .site-nav {
        gap: 0.5rem;
    }

    .brand {
        flex-basis: 100%;
    }

    .nav-list {
        margin-right: auto;
    }

    .scroll-cue--back {
        top: 1rem;
        left: 0.5rem;
        transform: none;
    }

    .contact {
        flex-direction: column;
        row-gap: 0.35rem;
        justify-content: center;
        align-items: center;
    }

    .footer-links {
        align-items: center;
    }

    .contact a {
        white-space: normal;
    }

    html.home.js .hero {
        margin-bottom: 2rem;
    }

    .project-grid {
        margin-bottom: 1.5rem;
    }

    .hero .tagline {
        margin-bottom: 0.75rem;
    }

    .section h2 {
        text-align: center;
    }

    .about-card {
        justify-content: center;
        text-align: center;
    }

    /* Centred text misreads a label/value list, so the facts stay left-aligned
       and stack one per line on narrow screens. */
    .quick-facts {
        grid-template-columns: 1fr;
        gap: 0.1rem;
        text-align: left;
    }

    .quick-facts dt {
        margin-top: 0.5rem;
    }

    .quick-facts dt:first-child {
        margin-top: 0;
    }

    .stat-row {
        text-align: center;
    }

    .entry-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.15rem;
    }

    .gallery img {
        aspect-ratio: auto;
        height: auto;
    }
}

/* Small phones */
@media (max-width: 400px) {
    main {
        padding-top: 1.75rem;
    }

    html.home.js .hero {
        margin-bottom: 1.5rem;
    }

    .hero .tagline {
        font-size: 1.05rem;
    }

    /* Keep the three tiles two-up instead of stacking all three. */
    .stat-row {
        grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
        gap: 0.5rem;
    }
}

/* Very small phones: drop the hero contact group below 360px so it doesn't
   render as a cramped column; the footer link group still shows all contacts
   on every width, so contact access is preserved. */
@media (max-width: 360px) {
    .hero .contact {
        display: none;
    }
}

/* Short / landscape viewports: trim vertical spacing so content stays
   above the fold without a tall empty hero. */
@media (orientation: landscape) and (max-height: 520px) {
    main {
        padding-top: 1.25rem;
        padding-bottom: 1.5rem;
    }

    html.home.js .hero {
        min-height: auto;
        margin-bottom: 1.5rem;
        padding-top: 2rem;
    }

    .scroll-cue {
        display: none;
    }

    .hero .tagline {
        margin-bottom: 0.75rem;
    }

    .section,
    main > .card {
        margin-bottom: 1.5rem;
    }
}

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

    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }

    .project:hover,
    .project:focus-within {
        transform: none;
    }
}

/* ---------- Print ---------- */

@media print {
    .site-header,
    .theme-switch,
    .skip-link,
    .scroll-cue,
    .gallery-nav,
    .toc,
    .project-detail-open,
    .contact-dialog {
        display: none !important;
    }

    html.home.js .hero {
        display: block;
        min-height: auto;
        margin-bottom: 0;
        padding: 0 0 1.5rem;
    }

    html.home .page-grid {
        display: block;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    main {
        max-width: none;
    }

    /* Panels expand inside each card for print, so the two-column screen grid
       becomes a single column of full-width cards. */
    .project-grid {
        display: block;
    }

    .project {
        margin-bottom: 1rem;
    }

    /* Every project's detail is in the printout, not only the panel that
       happened to be open on screen. */
    html.dialog-capable .project-dialog:not([open]) {
        display: block;
        margin: 1.25rem 0 0;
    }
}