:root {
    color-scheme: light;
    --bg-image: url('../assets/bg.jpg');
    --bg: #fffdf8;
    --bg-top-accent: rgba(132, 160, 188, 0.16);
    --bg-bottom-accent: rgba(109, 130, 154, 0.18);
    --bg-start: #fffefb;
    --bg-end: #f3eee5;
    --bg-image-tint: rgba(255, 252, 247, 0.82);
    --bg-image-fade: rgba(243, 238, 229, 0.88);
    --grid-line: rgba(31, 26, 22, 0.035);
    --panel: rgba(255, 255, 252, 0.94);
    --panel-float: rgba(255, 255, 252, 0.5);
    --panel-strong: rgba(255, 255, 253, 0.98);
    --line: rgba(38, 31, 25, 0.08);
    --text: #181411;
    --muted: #4f5d6d;
    --accent: #46627e;
    --accent-soft: #d8e3ec;
    --hero-accent: rgba(141, 170, 198, 0.18);
    --hero-top: rgba(255, 255, 252, 0.84);
    --hero-bottom: rgba(248, 243, 236, 0.9);
    --section-overlay: rgba(255, 255, 255, 0.56);
    --section-top: rgba(255, 255, 253, 0.98);
    --section-bottom: rgba(245, 239, 231, 0.94);
    --card-top: rgba(255, 255, 255, 0.33);
    --card-bottom: rgba(244, 236, 227, 0.5);
    --featured-accent: rgba(141, 170, 198, 0.18);
    --featured-top: rgba(255, 255, 255, 0.5);
    --featured-bottom: rgba(244, 232, 219, 0.5);
    --muted-card-top: rgba(250, 245, 239, 0.5);
    --muted-card-bottom: rgba(239, 232, 224, 0.5);
    --button-primary-top: #28211c;
    --button-primary-bottom: #171210;
    --button-primary-text: #f8f1e9;
    --button-secondary-top: rgba(255, 255, 255, 0.82);
    --button-secondary-bottom: rgba(243, 235, 226, 0.82);
    --project-link-top: rgba(70, 98, 126, 0.08);
    --project-link-bottom: rgba(70, 98, 126, 0.14);
    --project-link-border: rgba(70, 98, 126, 0.2);
    --shadow: 0 18px 40px rgba(55, 38, 26, 0.08);
    --max-width: 1120px;
}

:root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #0c1118;
    --bg-top-accent: rgba(84, 118, 160, 0.22);
    --bg-bottom-accent: rgba(39, 57, 82, 0.32);
    --bg-start: #111923;
    --bg-end: #090d13;
    --bg-image-tint: rgba(4, 6, 14, 0.32);
    --bg-image-fade: rgba(2, 4, 10, 0.48);
    --grid-line: rgba(205, 218, 238, 0.05);
    --panel: rgba(18, 27, 39, 0.9);
    --panel-float: rgba(18, 27, 39, 0.5);
    --panel-strong: rgba(16, 24, 35, 0.96);
    --line: rgba(164, 184, 214, 0.09);
    --text: #edf3fb;
    --muted: #b7c7dd;
    --accent: #b1caeb;
    --accent-soft: #1d2c40;
    --hero-accent: rgba(98, 138, 187, 0.14);
    --hero-top: rgba(17, 27, 39, 0.82);
    --hero-bottom: rgba(9, 14, 22, 0.9);
    --section-overlay: rgba(116, 145, 184, 0.05);
    --section-top: rgba(18, 27, 39, 0.98);
    --section-bottom: rgba(11, 17, 25, 0.98);
    --card-top: rgba(24, 35, 51, 0.5);
    --card-bottom: rgba(14, 21, 31, 0.5);
    --featured-accent: rgba(98, 138, 187, 0.12);
    --featured-top: rgba(27, 40, 58, 0.5);
    --featured-bottom: rgba(15, 23, 34, 0.5);
    --muted-card-top: rgba(20, 29, 42, 0.5);
    --muted-card-bottom: rgba(11, 17, 25, 0.5);
    --button-primary-top: #dce8f6;
    --button-primary-bottom: #b7c9dd;
    --button-primary-text: #0c1219;
    --button-secondary-top: rgba(30, 43, 61, 0.88);
    --button-secondary-bottom: rgba(18, 27, 39, 0.92);
    --project-link-top: rgba(144, 175, 216, 0.18);
    --project-link-bottom: rgba(144, 175, 216, 0.1);
    --project-link-border: rgba(144, 175, 216, 0.22);
    --shadow: 0 24px 44px rgba(2, 6, 12, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, var(--bg-image-tint), var(--bg-image-fade)),
        var(--bg-image) center top / cover fixed no-repeat,
        radial-gradient(circle at top left, var(--bg-top-accent), transparent 30%),
        radial-gradient(circle at right 20% bottom 10%, var(--bg-bottom-accent), transparent 24%),
        linear-gradient(180deg, var(--bg-start) 0%, var(--bg) 42%, var(--bg-end) 100%);
    transition: background-color 180ms ease, color 180ms ease;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 90%);
}

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

.page-shell {
    width: min(calc(100% - 2rem), var(--max-width));
    margin: 0 auto;
    padding: 1.25rem 0 4rem;
}

.site-header {
    display: block;
    padding: 0;
}

.brand,
.site-nav a,
.theme-toggle,
.button,
.project-links a,
.eyebrow,
.section-label,
.project-meta {
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.brand {
    font-size: 0.82rem;
    font-weight: 800;
}

.site-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
}

.site-nav a,
.theme-toggle {
    color: var(--muted);
}

.link-label {
    display: inline;
}

.button,
.project-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.button::before,
.project-links a::before {
    content: '→';
    opacity: 0.7;
    transform: translateX(0);
    transition: transform 180ms ease, opacity 180ms ease;
}

.theme-toggle {
    padding: 0;
    font: inherit;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.hero,
.content-section {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.hero {
    margin-top: 1.5rem;
    padding: clamp(3rem, 10vw, 8rem);
    min-height: calc(100vh - 8rem);
    display: grid;
    align-content: center;
    /* background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
        linear-gradient(135deg, var(--hero-accent), transparent 28%),
        linear-gradient(180deg, var(--hero-top), var(--hero-bottom)); */
}

.eyebrow,
.section-label,
.project-meta {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
}

.section-label {
    margin-bottom: 0.6rem;
}

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

.hero-formula {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-family: 'STIX Two Text', 'Times New Roman', serif;
    font-size: clamp(0.9rem, 1.8vw, 1.08rem);
    font-weight: 500;
    letter-spacing: 0.01em;
    text-transform: none;
    font-variant-ligatures: common-ligatures;
    -webkit-font-smoothing: antialiased;
}

.formula-symbol,
.formula-equals {
    flex: 0 0 auto;
}

.formula-fraction {
    display: inline-grid;
    justify-items: center;
    line-height: 1.1;
}

.formula-numerator,
.formula-denominator {
    padding: 0 0.2rem;
    white-space: nowrap;
}

.formula-numerator {
    border-bottom: 1px solid currentColor;
    padding-bottom: 0.18rem;
}

.formula-denominator {
    padding-top: 0.18rem;
}

.hero-formula sub,
.hero-formula sup {
    font-size: 0.72em;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: 'Newsreader', serif;
    font-weight: 700;
    line-height: 0.95;
}

h1 {
    margin-top: 1rem;
    font-size: 7.5rem;
    max-width: 100%;
    line-height: 0.9;
    white-space: nowrap;
    letter-spacing: -0.03em;
}

.hero-copy,
.section-copy,
.project-card p {
    max-width: 42rem;
    font-size: clamp(1rem, 2vw, 1.15rem);
    line-height: 1.7;
    /* color: var(--muted); */
}

.hero-copy {
    margin: 1.5rem 0 0;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    transition: color 180ms ease, text-decoration-color 180ms ease;
}

.button:hover .link-label,
.button:focus-visible .link-label,
.project-links a:hover .link-label,
.project-links a:focus-visible .link-label,
.site-nav a:hover .link-label,
.site-nav a:focus-visible .link-label,
.theme-toggle:hover .link-label,
.theme-toggle:focus-visible .link-label,
.brand:hover,
.brand:focus-visible {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.button:hover::before,
.button:focus-visible::before,
.project-links a:hover::before,
.project-links a:focus-visible::before {
    opacity: 1;
    transform: translateX(0.12rem);
}

.button::before,
.project-links a::before {
    text-decoration: none;
}

.button-primary {
    color: var(--text);
}

.button-secondary {
    color: var(--accent);
}

.content-section {
    margin-top: 1.25rem;
    padding: clamp(1.5rem, 4vw, 3rem);
    /* background:
        linear-gradient(180deg, var(--section-overlay), transparent 40%),
        linear-gradient(180deg, var(--section-top), var(--section-bottom)); */
}

.section-heading {
    display: grid;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
}

h2 {
    font-size: clamp(2.3rem, 7vw, 4.5rem);
    max-width: 10ch;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.project-card {
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 2rem;
    /* background: linear-gradient(145deg, var(--card-top), var(--card-bottom)); */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Faint large index number removed */

.project-card-featured {
    /* background:
        linear-gradient(135deg, var(--featured-accent), transparent 40%),
        linear-gradient(160deg, var(--featured-top), var(--featured-bottom)); */
}

/* Coloured top accent line on featured card */
.project-card-featured::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    /* background: linear-gradient(90deg, var(--accent), transparent 70%); */
    opacity: 0.9;
}

.project-card-muted {
    /* background: linear-gradient(160deg, var(--muted-card-top), var(--muted-card-bottom)); */
    opacity: 0.85;
}

h3 {
    margin-top: 0.65rem;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.project-card p {
    margin: 0.9rem 0 0;
    flex: 1;
}

.project-links {
    margin-top: 1.5rem;
}

.project-links a {
    display: inline-flex;
    align-items: center;
    min-height: auto;
    padding: 0;
    color: var(--accent);
    background: transparent;
    border: 0;
}

/* Tech tag pills */
.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: none;
}

@media (max-width: 720px) {
    .page-shell {
        width: min(calc(100% - 1rem), var(--max-width));
        padding-bottom: 2.5rem;
    }

    .header-inner {
        width: min(calc(100% - 1rem), var(--max-width));
    }

    .header-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        min-height: auto;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }
}

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

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

/* ============================================================
   Parallax, Motion & Depth Enhancements
   ============================================================ */

/* Sticky glass header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 400ms ease, backdrop-filter 400ms ease,
                -webkit-backdrop-filter 400ms ease, border-color 400ms ease,
                box-shadow 400ms ease;
    border-bottom: 1px solid transparent;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(calc(100% - 2rem), var(--max-width));
    margin: 0 auto;
    padding: 0.75rem 0;
}

.header-floating {
    background: var(--panel-float);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border-bottom-color: var(--line);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

/* Hero parallax layers */
#particles-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.5;
    pointer-events: none;
    will-change: transform;
}

.hero-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(100px);
    will-change: transform;
}

.hero-orb-1 {
    width: clamp(280px, 55%, 680px);
    aspect-ratio: 1;
    background: radial-gradient(circle, var(--accent-soft), transparent 70%);
    top: -30%;
    left: -15%;
    opacity: 0.85;
}

.hero-orb-2 {
    width: clamp(220px, 42%, 520px);
    aspect-ratio: 1;
    background: radial-gradient(circle, var(--hero-accent), transparent 70%);
    bottom: -25%;
    right: -10%;
    opacity: 0.75;
}

.hero-inner {
    position: relative;
    z-index: 1;
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    animation: scroll-indicator-in 1s 2.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.scroll-indicator-line {
    order: -1;
    width: 1px;
    height: 2.5rem;
    background: linear-gradient(180deg, transparent, var(--muted));
    transform: scaleY(0);
    transform-origin: top center;
    animation: scroll-line-draw 2.4s 2.2s ease-in-out infinite;
}

@keyframes scroll-indicator-in {
    to { opacity: 0.65; }
}

@keyframes scroll-line-draw {
    0%   { transform: scaleY(0); transform-origin: top    center; opacity: 1; }
    44%  { transform: scaleY(1); transform-origin: top    center; opacity: 1; }
    45%  { transform-origin: bottom center; }
    88%  { transform: scaleY(0); transform-origin: bottom center; opacity: 0; }
    100% { transform: scaleY(0); transform-origin: top    center; opacity: 0; }
}

/* Scroll reveal */
[data-reveal] {
    opacity: 0;
    transform: translateY(2.2rem);
    transition: opacity 800ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 800ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

[data-reveal][data-delay='1'] { transition-delay: 120ms; }
[data-reveal][data-delay='2'] { transition-delay: 240ms; }
[data-reveal][data-delay='3'] { transition-delay: 360ms; }

/* 3D card hover tilt */
.project-card {
    transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 600ms ease;
    will-change: transform;
}

.project-card:hover {
    box-shadow: var(--shadow), 0 0 0 1px var(--line);
}

/* Hero entrance animations */
@keyframes entry-up {
    from { opacity: 0; transform: translateY(2rem); }
    to   { opacity: 1; transform: translateY(0);    }
}

@keyframes title-blur-in {
    from { opacity: 0; transform: translateY(1.5rem); filter: blur(10px); }
    to   { opacity: 1; transform: translateY(0);      filter: blur(0px);  }
}

.hero-formula {
    animation: entry-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

#hero-title {
    animation: title-blur-in 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.hero-copy {
    animation: entry-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.55s both;
}

.hero-actions {
    animation: entry-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.75s both;
}

/* Section label decoration */
.section-label::before {
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: 1.5rem;
    height: 1px;
    background: currentColor;
    margin-right: 0.6rem;
    opacity: 0.55;
}

/* Reduced motion overrides for new animations */
@media (prefers-reduced-motion: reduce) {
    .site-header {
        transition: none !important;
    }

    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .hero-formula,
    #hero-title,
    .hero-copy,
    .hero-actions {
        animation: none;
        opacity: 1;
        transform: none;
        filter: none;
    }

    .scroll-indicator {
        animation: none;
        opacity: 0.65;
    }

    .scroll-indicator-line {
        animation: none;
        transform: scaleY(1);
    }

    .project-card {
        transition: none !important;
        will-change: auto;
    }
}