/* ==========================================================================
   Portfolio stylesheet
   Change the look from the tokens in :root — everything else derives from them.
   ========================================================================== */

:root {
    --bg: #070c15;
    --surface: #0d1622;
    --surface-2: #132030;
    --border: #1e3146;
    --text: #e6eef5;
    --muted: #8fa4ba;
    --accent: #3dd6e0;
    --accent-ink: #04161a; /* text on top of the accent colour */

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

    --radius: 10px;
    --page: 1120px;
    --gutter: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f8fc;
        --surface: #ffffff;
        --surface-2: #e8f0f7;
        --border: #d2dfea;
        --text: #0f1a24;
        --muted: #52657a;
        --accent: #0b7f96;
        --accent-ink: #ffffff;
    }
}

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

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; }

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

/* Full-screen canvas drawn by js/background.js from shaders/background.frag */
.shader-bg { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }

.container { width: 100%; max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 100;
    padding: 0.5rem 0.9rem; background: var(--accent); color: var(--accent-ink);
    border-radius: 6px; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.9rem;
}

.muted { color: var(--muted); }

/* ---------- Buttons & chips ---------- */

.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.7rem 1.15rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: transparent; color: var(--text);
    font: inherit; font-weight: 600; font-size: 0.95rem;
    text-decoration: none; cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

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

.chip {
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--border); border-radius: 999px;
    font-family: var(--font-mono); font-size: 0.72rem;
    color: var(--muted); white-space: nowrap;
}

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

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

.site-header .container {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; min-height: 3.75rem;
}

.brand {
    font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem;
    text-decoration: none; white-space: nowrap;
}
.brand span { color: var(--accent); }

.nav { display: flex; align-items: center; gap: clamp(0.75rem, 2.5vw, 1.75rem); overflow-x: auto; }
.nav a:not(.btn) {
    color: var(--muted); text-decoration: none; font-size: 0.93rem; white-space: nowrap;
    transition: color 0.15s;
}
.nav a:not(.btn):hover { color: var(--text); }

@media (max-width: 560px) {
    .nav .nav-optional { display: none; }
}

/* ---------- Sections ---------- */

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

.section-head { margin-bottom: 2rem; max-width: 46rem; }
.section-head h2 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
.section-head p { color: var(--muted); margin-top: 0.75rem; }

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

.hero { padding-block: clamp(4rem, 11vw, 7.5rem) clamp(3rem, 7vw, 5rem); }
.hero h1 { font-size: clamp(2.3rem, 6.5vw, 4.25rem); max-width: 17ch; }
.hero .lead { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--muted); max-width: 40rem; margin: 1.5rem 0 2rem; }

.facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 1px; margin: 3.5rem 0 0;
    background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden;
}
.facts div { background: var(--surface); padding: 1rem 1.15rem; }
.facts dt {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
}
.facts dd { margin: 0.2rem 0 0; font-weight: 600; }

/* ---------- Media frames (reel, covers, video) ---------- */

.frame {
    position: relative; aspect-ratio: 16 / 9; overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.frame > iframe, .frame > video, .frame > img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }

.frame-placeholder {
    display: grid; place-items: center; text-align: center; padding: 1.5rem;
    color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem;
    background:
        linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 100% 2.5rem,
        linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 2.5rem 100%,
        var(--surface);
}

/* Generated cover used when a project has no image yet. Colour comes from --hue. */
.cover {
    --hue: 190;
    position: relative; aspect-ratio: 16 / 9; overflow: hidden;
    display: grid; place-items: center;
    background:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 100% 1.75rem,
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 1.75rem 100%,
        linear-gradient(135deg, hsl(var(--hue) 55% 30%), hsl(calc(var(--hue) + 45) 60% 13%));
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-mark {
    font-family: var(--font-mono); font-weight: 700; font-size: clamp(2rem, 6vw, 3rem);
    color: rgba(255, 255, 255, 0.85); letter-spacing: 0.04em;
}

/* ---------- Project grid ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.75rem; }

.filter {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border); border-radius: 999px;
    background: transparent; color: var(--muted);
    font: inherit; font-size: 0.88rem; cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.filter:hover { color: var(--text); border-color: var(--muted); }
.filter[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 600; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.25rem; }

.card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; text-decoration: none;
    transition: transform 0.18s, border-color 0.18s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card[hidden] { display: none; }

.card-body { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.15rem 1.25rem 1.3rem; flex: 1; }
.card-body h3 { font-size: 1.15rem; }
.card-body p { color: var(--muted); font-size: 0.93rem; margin: 0; }
.card-meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.card .chips { margin-top: auto; padding-top: 0.4rem; }

.badge {
    position: absolute; top: 0.75rem; left: 0.75rem; z-index: 1;
    padding: 0.15rem 0.55rem; border-radius: 4px;
    background: var(--accent); color: var(--accent-ink);
    font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
}

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

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

.skill-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.35rem 1.4rem; }
.skill-group h3 { font-size: 1rem; margin-bottom: 0.85rem; }
.skill-group li { color: var(--muted); font-size: 0.93rem; padding-block: 0.3rem; border-top: 1px solid var(--border); }
.skill-group li:first-child { border-top: 0; }

/* ---------- Experience ---------- */

.timeline { display: grid; gap: 2.25rem; }

.role { display: grid; grid-template-columns: 11rem 1fr; gap: 0.5rem 2rem; }
.role-when { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); padding-top: 0.25rem; }
.role h3 { font-size: 1.1rem; }
.role-where { color: var(--muted); margin: 0.2rem 0 0.75rem; }

@media (max-width: 640px) {
    .role { grid-template-columns: 1fr; }
}

.bullets { display: grid; gap: 0.45rem; }
.bullets li { position: relative; padding-left: 1.25rem; color: var(--muted); }
.bullets li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 0.5rem; height: 1px; background: var(--accent); }

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

.about { display: grid; grid-template-columns: minmax(0, 14rem) 1fr; gap: clamp(1.5rem, 5vw, 3.5rem); align-items: start; }
.about-photo { aspect-ratio: 1; border-radius: var(--radius); }
.about-text { max-width: 40rem; }
.about-text p { color: var(--muted); }

@media (max-width: 640px) {
    .about { grid-template-columns: 1fr; }
    .about-photo { max-width: 10rem; }
}

/* ---------- Contact & footer ---------- */

.contact h2 { font-size: clamp(1.9rem, 5vw, 3rem); max-width: 18ch; }
.contact-email {
    display: inline-block; margin: 1.5rem 0 2rem;
    font-family: var(--font-mono); font-size: clamp(1.05rem, 3vw, 1.5rem);
    color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.3em;
    overflow-wrap: anywhere;
}

.site-footer { border-top: 1px solid var(--border); padding-block: 1.75rem; color: var(--muted); font-size: 0.88rem; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; }

/* ---------- Project (case study) page ---------- */

.project-page { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3.5rem, 8vw, 6rem); }

.back-link { display: inline-block; margin-bottom: 2rem; color: var(--muted); text-decoration: none; font-size: 0.93rem; }
.back-link:hover { color: var(--text); }

.project-title { font-size: clamp(2rem, 5.5vw, 3.4rem); }
.project-tagline { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--muted); max-width: 44rem; margin: 1rem 0 1.5rem; }

.project-media { margin-block: 2rem; }
.project-media .cover { border: 1px solid var(--border); border-radius: var(--radius); }

.project-layout { display: grid; grid-template-columns: 1fr 17rem; gap: clamp(2rem, 5vw, 4rem); align-items: start; }

@media (max-width: 820px) {
    .project-layout { grid-template-columns: 1fr; }
    .project-aside { order: -1; }
}

/* The write-up, rendered from the Markdown in projects/<slug>.md */
.project-content { min-width: 0; }
.project-content > :first-child { margin-top: 0; }
.project-content > :last-child { margin-bottom: 0; }
.project-content h2 { font-size: 1.4rem; margin: 2.75rem 0 0.9rem; }
.project-content h3 { font-size: 1.1rem; margin: 2.25rem 0 0.9rem; }
.project-content p, .project-content li { color: var(--muted); max-width: 44rem; }
.project-content strong { color: var(--text); }
.project-content a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.project-content ul, .project-content ol { display: grid; gap: 0.45rem; margin: 0 0 1rem; }
.project-content li > ul, .project-content li > ol { margin: 0.45rem 0 0; }
.project-content ul > li { position: relative; padding-left: 1.25rem; }
.project-content ul > li::before { content: ""; position: absolute; left: 0; top: 0.7em; width: 0.5rem; height: 1px; background: var(--accent); }
.project-content ol { padding-left: 1.25rem; }
.project-content img, .project-content video, .project-content iframe {
    margin-block: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius);
}
.project-content pre { margin-block: 1.5rem; }
.project-content :not(pre) > code {
    padding: 0.1em 0.35em; border-radius: 4px; background: var(--surface-2);
    font-family: var(--font-mono); font-size: 0.88em;
}
.project-content blockquote { margin: 1.5rem 0; padding-left: 1.1rem; border-left: 2px solid var(--accent); }
.project-content hr { margin-block: 2.75rem; border: 0; border-top: 1px solid var(--border); }
.project-content table { display: block; overflow-x: auto; margin-block: 1.5rem; border-collapse: collapse; font-size: 0.93rem; }
.project-content th, .project-content td { padding: 0.5rem 0.85rem; border: 1px solid var(--border); text-align: left; }
.project-content th { background: var(--surface); }

.project-aside {
    position: sticky; top: 5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.35rem 1.4rem;
}
@media (max-width: 820px) {
    .project-aside { position: static; }
}
.project-aside dl { margin: 0; display: grid; gap: 0.9rem; }
.project-aside dt {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
}
.project-aside dd { margin: 0.15rem 0 0; font-weight: 600; }
.project-aside .chips { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

pre {
    margin: 0; padding: 1.1rem 1.25rem; overflow-x: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.6; tab-size: 4;
}

.project-pager {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border);
}
.project-pager a { text-decoration: none; }
.project-pager small { display: block; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.project-pager strong { font-size: 1.05rem; }
.project-pager a:hover strong { color: var(--accent); }
.project-pager .next { text-align: right; margin-left: auto; }

.empty-state { padding-block: 5rem; text-align: center; }
.empty-state h1 { font-size: 2rem; margin-bottom: 1rem; }
.empty-state p { color: var(--muted); margin-bottom: 1.5rem; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}
