/* ----- tokens ------------------------------------------------------------ */

/* Garage retro: cream paper, asphalt black and racing red, with signage type. */
:root {
    --bg: #f3ead8;
    --surface: #fbf6ea;
    --surface-glass: rgb(251 246 234 / 0.93);
    --text: #1c1a17;
    --muted: #5f574b;
    --line: #d6c8ab;
    --accent: #b3261e;
    --accent-ink: #fbf6ea;
    --teal: #1f5a45;

    --font-display: 'Bebas Neue', 'Arial Narrow', Impact, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

    --gutter: 20px;
    --max: 68.75rem;
    --header: 60px;
    --radius: 6px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --bg: #171513;
        --surface: #221f1b;
        --surface-glass: rgb(34 31 27 / 0.92);
        --text: #f1e7d3;
        --muted: #b3a892;
        --line: #3d362d;
        --accent: #f0604f;
        --accent-ink: #171513;
        --teal: #8fbfa5;
        color-scheme: dark;
    }
}

:root[data-theme='dark'] {
    --bg: #171513;
    --surface: #221f1b;
    --surface-glass: rgb(34 31 27 / 0.92);
    --text: #f1e7d3;
    --muted: #b3a892;
    --line: #3d362d;
    --accent: #f0604f;
    --accent-ink: #171513;
    --teal: #8fbfa5;
    color-scheme: dark;
}

/* ----- base -------------------------------------------------------------- */

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

html {
    /* 16px up to laptop widths, growing to 20px on very large displays. */
    font-size: clamp(16px, 0.42vw + 9.9px, 20px);
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header) + 12px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1rem/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

h1 {
    font-size: clamp(3.4rem, 11vw, 6.4rem);
}

h2 {
    font-size: clamp(2.3rem, 6vw, 3.4rem);
}

h3 {
    font-size: 1.45rem;
}

p {
    margin: 0;
}

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
}

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

[hidden] {
    display: none !important;
}

/* Wording that only makes sense with a keyboard, or only on a touch screen. */
.touch-only {
    display: none;
}

@media (pointer: coarse) {
    .keys-only {
        display: none;
    }

    .touch-only {
        display: inline;
    }
}

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

.wrap {
    width: min(var(--max), 100% - var(--gutter) * 2);
    margin-inline: auto;
}

.eyebrow {
    font: 500 0.78rem/1.4 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 30;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-ink);
}

.skip-link:focus {
    top: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.2rem;
    border: 2px solid var(--accent);
    border-radius: 4px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 400 1.15rem/1 var(--font-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.button--ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--text);
}

.button--small {
    padding: 0.45rem 0.9rem;
    font-size: 1rem;
}

.link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.3rem;
}

.link-row a,
.text-link {
    color: var(--text);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.link-row a:hover,
.text-link:hover {
    color: var(--accent);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chips li {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--bg);
    font: 500 0.82rem/1.3 var(--font-mono);
}

/* ----- header ------------------------------------------------------------ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header);
    border-bottom: 3px solid var(--accent);
    box-shadow: 0 6px 0 -3px var(--text);
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 100%;
}

.brand {
    font: 400 1.6rem/1 var(--font-display);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
}

.site-nav {
    display: none;
    gap: 1.4rem;
    margin-left: auto;
    font-size: 0.92rem;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
}

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

.site-header__actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1.5px solid var(--line);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

/* A half-filled disc: reads as "light / dark" in either theme. */
.theme-toggle__icon {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text);
    border-radius: 50%;
    background: linear-gradient(90deg, var(--text) 50%, transparent 50%);
}

@media (min-width: 760px) {
    .site-nav {
        display: flex;
    }

    .site-header__actions {
        margin-left: 0;
    }
}

/* ----- hero -------------------------------------------------------------- */

.hero {
    display: grid;
    gap: 2.5rem;
    align-items: center;
    padding-block: clamp(2.5rem, 8vw, 6rem);
}

.hero__text {
    display: grid;
    gap: 1.1rem;
    justify-items: start;
}

.hero__lede {
    font: 600 clamp(1.15rem, 2.4vw, 1.4rem)/1.4 var(--font-body);
}

.hero__body {
    max-width: 58ch;
    color: var(--muted);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 0.4rem;
}

.hero__photo {
    width: min(300px, 74%);
    justify-self: center;
    /* Framed like an instant print. */
    padding: 12px 12px 54px;
    background: #fdfbf5;
    box-shadow: 0 2px 0 rgb(0 0 0 / 0.08), 0 16px 34px rgb(0 0 0 / 0.28);
    transform: rotate(-2.5deg);
}

.hero__photo img {
    aspect-ratio: 1;
    object-fit: cover;
}

@media (min-width: 860px) {
    .hero {
        grid-template-columns: 1.4fr 1fr;
        gap: 4rem;
    }

    .hero__photo {
        width: min(360px, 100%);
    }
}

/* ----- sections ---------------------------------------------------------- */

.section {
    padding-block: clamp(3rem, 8vw, 5.5rem);
    border-top: 1px solid var(--line);
}

.section-head {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.section-head h2::after {
    content: '';
    display: block;
    width: 84px;
    height: 10px;
    margin-top: 0.5rem;
    border-top: 4px solid var(--accent);
    border-bottom: 2px solid var(--text);
}

.section-head__note {
    max-width: 52ch;
    color: var(--muted);
}

.journey__start {
    justify-self: start;
    margin-top: 0.6rem;
    cursor: pointer;
}

/* ----- journey: plain timeline (default, and the fallback) ---------------- */

.journey {
    padding-top: clamp(3rem, 8vw, 5.5rem);
    border-top: 1px solid var(--line);
}

.journey__canvas,
.journey__hint,
.journey__rail,
.journey__sound {
    display: none;
}

.journey__list {
    width: min(var(--max), 100% - var(--gutter) * 2);
    margin: 0 auto;
    padding-bottom: clamp(3rem, 8vw, 5.5rem);
    counter-reset: stop;
}

.milestone {
    position: relative;
    display: grid;
    gap: 0.35rem;
    max-width: 62ch;
    padding: 0 0 2.2rem 2rem;
    border-left: 2px solid var(--line);
}

.journey__end {
    max-width: 62ch;
    padding-left: 2rem;
    font: 500 0.82rem/1.5 var(--font-mono);
    color: var(--accent);
}

.milestone::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 4px;
    width: 14px;
    height: 14px;
    border: 3px solid var(--accent);
    border-radius: 50%;
    background: var(--bg);
}

.milestone__meta {
    font: 500 0.78rem/1.4 var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--muted);
}

.milestone__role {
    font-weight: 600;
    color: var(--teal);
}

.milestone > p:last-child,
.milestone ul {
    color: var(--muted);
    font-size: 0.95rem;
}

.milestone ul {
    display: grid;
    gap: 0.35rem;
    padding-left: 1.1rem;
    list-style: disc;
}

/* ----- journey: 3D ride (added by js/journey once WebGL is running) -------- */

/* How to ride only matters while the 3D ride is running. */
.journey:not(.is-3d) .journey__controls {
    display: none;
}

.journey.is-3d .journey__end,
.journey.is-3d .journey__aside {
    display: none;
}

.journey.is-3d .journey__track {
    height: calc(var(--stops, 7) * 100vh);
}

.journey.is-3d .journey__stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}

.journey.is-3d .journey__canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.journey.is-3d .journey__list {
    position: absolute;
    left: var(--gutter);
    right: var(--gutter);
    bottom: 20px;
    width: auto;
    margin: 0;
    padding: 0;
}

.journey.is-3d .milestone {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 430px;
    max-height: 46svh;
    overflow-y: auto;
    padding: 1.1rem 1.25rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-glass);
    backdrop-filter: blur(8px);
    box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.journey.is-3d .milestone::before {
    display: none;
}

.journey.is-3d .milestone.is-active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.journey.is-3d .journey__rail {
    position: absolute;
    top: calc(var(--header) + 18px);
    left: 50%;
    display: flex;
    justify-content: space-between;
    width: min(520px, 100% - var(--gutter) * 2);
    transform: translateX(-50%);
}

.journey__rail::before,
.journey__rail::after {
    content: '';
    position: absolute;
    left: 10px;
    right: 10px;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 3px;
    background: rgb(255 255 255 / 0.4);
}

.journey__rail::after {
    background: #e2493b;
    transform: scaleX(var(--progress, 0));
    transform-origin: left;
}

.journey__dot {
    position: relative;
    z-index: 1;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #1c1a17;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

/* The dot stays small; the tappable area around it is finger-sized. */
.journey__dot::after {
    content: '';
    position: absolute;
    inset: -13px;
}

.journey__dot.is-passed {
    background: #e2493b;
}

.journey__dot[aria-current='step'] {
    transform: scale(1.35);
}

.journey__dot:focus-visible {
    outline-color: #ffffff;
    border-radius: 50%;
}

.journey.is-3d .journey__hint {
    display: block;
    position: absolute;
    top: calc(var(--header) + 58px);
    left: 50%;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: rgb(14 26 36 / 0.7);
    color: #f1eadc;
    font: 500 0.75rem/1.4 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    /* Leaves room for the music button on the right. */
    max-width: calc(100% - (var(--gutter) + 52px) * 2);
    text-align: center;
    white-space: nowrap;
    transform: translateX(-50%);
    transition: opacity 0.3s ease;
}

.journey__hint .end-only,
.journey__hint .welcome-only,
.journey__hint.is-end .keys-only,
.journey__hint.is-end .touch-only,
.journey__hint.is-welcome .keys-only,
.journey__hint.is-welcome .touch-only {
    display: none;
}

.journey__hint.is-welcome .welcome-only {
    display: inline;
}

.journey.is-3d .journey__hint.is-end {
    white-space: normal;
    width: max-content;
    border-radius: 14px;
}

.journey__hint.is-end .end-only {
    display: inline;
}

.journey__hint.is-hidden {
    opacity: 0;
}

/* Music toggle: a round button on small screens, a labelled pill on wide ones. */
.journey.is-3d .journey__sound {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    position: absolute;
    top: calc(var(--header) + 52px);
    right: var(--gutter);
    min-width: 44px;
    height: 44px;
    padding: 0 0.8rem;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: rgb(14 26 36 / 0.7);
    color: #f1eadc;
    font: 500 0.75rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.journey__sound > span:first-child {
    font-size: 1.15rem;
    opacity: 0.55;
}

.journey.is-3d .journey__sound[aria-pressed='true'] {
    background: #e2493b;
}

.journey__sound[aria-pressed='true'] > span:first-child {
    opacity: 1;
}

.journey__sound:focus-visible {
    outline-color: #ffffff;
}

.journey__sound-label {
    display: none;
}

/* Short screens, such as a phone on its side: keep the card and rail compact. */
@media (max-height: 520px) {
    .journey.is-3d .milestone {
        max-width: 360px;
        max-height: 62svh;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    .journey.is-3d .journey__rail {
        top: calc(var(--header) + 10px);
    }

    .journey.is-3d .journey__hint {
        top: calc(var(--header) + 40px);
    }

    .journey.is-3d .journey__sound {
        top: calc(var(--header) + 34px);
    }
}

@media (min-width: 760px) {
    .journey__sound-label {
        display: inline;
    }

    .journey.is-3d .journey__list {
        left: max(var(--gutter), (100% - var(--max)) / 2);
        bottom: 36px;
    }
}

/* ----- journey: Explore mode (free roaming, desktop only) ------------------ */

.journey__explore,
.journey__explore-hud,
.journey__prompt {
    display: none;
}

/* What the E key would do here, top centre, clear of the card. */
.journey.is-exploring .journey__prompt {
    display: block;
    position: absolute;
    left: 50%;
    top: 76px;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    background: rgb(14 26 36 / 0.8);
    color: #f1eadc;
    font: 500 0.85rem/1.4 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 0.2s ease;
}

.journey.is-exploring .journey__prompt.is-shown {
    opacity: 1;
}

@media (hover: hover) and (pointer: fine) and (min-width: 1024px) {
    .journey.is-3d .journey__explore {
        display: inline-flex;
        justify-self: start;
        margin-top: 0.6rem;
        cursor: pointer;
    }
}

/* The stage takes over the window; the page behind it does not scroll. */
html.is-exploring {
    overflow: hidden;
}

.journey.is-exploring .journey__stage {
    position: fixed;
    inset: 0;
    z-index: 40;
    height: 100vh;
    height: 100dvh;
}

.journey.is-exploring .journey__rail,
.journey.is-exploring .journey__hint {
    display: none;
}

.journey.is-exploring .journey__sound {
    top: 16px;
}

.journey.is-exploring .journey__explore-hud {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: absolute;
    top: 16px;
    left: var(--gutter);
}

.journey__keys {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: rgb(14 26 36 / 0.7);
    color: #f1eadc;
    font: 500 0.75rem/1.4 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.journey__keys kbd {
    display: inline-block;
    min-width: 1.5em;
    margin: 0 0.15em 0 0.5em;
    padding: 0 0.3em;
    border: 1px solid rgb(255 255 255 / 0.6);
    border-radius: 4px;
    font: inherit;
    text-align: center;
}

.journey__keys kbd:first-child {
    margin-left: 0;
}

/* ----- skills ------------------------------------------------------------ */

.skill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.skill-group {
    display: grid;
    gap: 0.8rem;
    align-content: start;
    padding: 1.2rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.skill-group h3 {
    font-size: 1.3rem;
}

/* ----- certifications ---------------------------------------------------- */

.cert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.7rem;
}

.cert-grid li {
    display: grid;
    gap: 0.3rem;
    align-content: start;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    background: var(--surface);
    font-weight: 500;
    font-size: 0.95rem;
}

.cert__meta {
    font: 400 0.76rem/1.4 var(--font-mono);
    color: var(--muted);
}

/* ----- projects ---------------------------------------------------------- */

.project {
    display: grid;
    gap: 2rem;
    padding: clamp(1.2rem, 3vw, 2rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.project__text {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.project__text > p:first-of-type {
    color: var(--muted);
}

.flow {
    display: grid;
    gap: 1.4rem;
    align-content: start;
    justify-items: start;
}

.flow li {
    position: relative;
}

.flow span {
    display: block;
    padding: 0.5rem 0.9rem;
    border: 1.5px solid var(--teal);
    border-radius: 8px;
    font: 500 0.85rem/1.2 var(--font-mono);
}

/* Connector down to the next step. */
.flow li:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 1.4rem;
    top: 100%;
    height: 1.4rem;
    border-left: 2px solid var(--line);
}

/* The view counter is a second path, starting again from the visitor. */
.flow li:nth-child(4)::after {
    display: none;
}

.flow__branch {
    margin-top: 0.6rem;
}

.flow__branch::before {
    content: 'View counter';
    display: block;
    margin-bottom: 0.4rem;
    font: 500 0.72rem/1.4 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

@media (min-width: 860px) {
    .project {
        grid-template-columns: 1.6fr 1fr;
    }
}

/* ----- footer ------------------------------------------------------------ */

.site-footer::before {
    content: '';
    display: block;
    height: 16px;
    background: repeating-conic-gradient(var(--text) 0 25%, transparent 0 50%) 0 0 / 16px 16px;
    opacity: 0.85;
}

.site-footer {
    color: var(--muted);
    font-size: 0.92rem;
}

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem 2rem;
    padding-block: 2rem;
}

.view-counter {
    font: 500 0.82rem/1.4 var(--font-mono);
}

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

    * {
        transition: none !important;
    }
}
