.projects-page {
    position: relative;
    min-height: 100vh;
    padding: 100px 0 0;
}

@media (min-width: 1025px) {
    .projects-page {
        margin-left: var(--sidebar-w);
    }
}

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

.projects-header {
    position: relative;
    width: 100%;
    padding: 0 60px 46px;
    border-bottom: 1px solid var(--border-faint);
}

.projects-header::before {
    content: "";
    position: absolute;
    top: -.6em;
    right: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(3rem, 11vw, 9rem);
    font-weight: 700;
    letter-spacing: -.02em;
    color: transparent;
    -webkit-text-stroke: 1px var(--border-color);
    line-height: 1;
    pointer-events: none;
    z-index: 0;
    user-select: none;
}

.eyebrow-label {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    color: var(--text-muted-2);
    font-family: "JetBrains Mono", monospace;
    font-size: .72rem;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.eyebrow-label::before {
    content: "";
    width: 26px;
    height: 1px;
    background: var(--accent-indigo);
}

.projects-heading {
    position: relative;
    z-index: 1;
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-weight: 500;
    color: var(--primary-color);
    font-size: clamp(2.8rem, 7vw, 6rem);
    line-height: 1.05;
}

.projects-heading em {
    color: var(--accent-indigo);
    font-style: italic;
}

.projects-sub {
    position: relative;
    z-index: 1;
    margin-top: 28px;
    color: var(--text-muted-5);
    font-family: Inter, sans-serif;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ===========================
   FILTERS
=========================== */

.index-filters {
    position: sticky;
    /* Slightly less than the full navbar height on purpose: this makes
       the bar stick a few px early and tuck under the navbar's higher
       z-index, guaranteeing no sliver of page background can show
       between them even if the two heights don't line up to the pixel. */
    top: calc(var(--navbar-h, 56px) - 6px);
    z-index: 20;
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 28px;
    padding: 32px 60px 22px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-faint);

    /* Same fix as .navbar: sticky + backdrop-filter can leave a faint
       compositing seam between this bar and the navbar above it on
       mobile Chrome/Safari without this. */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    isolation: isolate;
}

.index-filter {
    position: relative;
    appearance: none;
    background: transparent;
    border: none;
    color: var(--text-muted-3);
    font-family: "JetBrains Mono", monospace;
    font-size: .74rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 0 0 8px;
    cursor: pointer;
    transition: color calc(.25s * var(--transition-scale)) ease;
}

.index-filter::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent-indigo);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform calc(.35s * var(--transition-scale)) cubic-bezier(.19, 1, .22, 1);
}

.index-filter:hover {
    color: var(--primary-color);
}

.index-filter.is-active {
    color: var(--primary-color);
}

.index-filter.is-active::after {
    transform: scaleX(1);
}

.index-filter:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

/* ===========================
   DOSSIER — chapter system
=========================== */

.dossier {
    width: 100%;
    /* Left: a real gap so the tab rail doesn't butt right up against the
       sidebar. Right: no padding, so chapter content runs all the way
       out to the viewport edge (scrollbar). */
    padding: 0 0 0 40px;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 15px;
}

/* ---- sticky tab rail (the binder edge) ---- */

.dossier-rail {
    position: sticky;
    top: calc(var(--navbar-h, 56px) + 90px);
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 40px;
    padding-bottom: 40px;
}

.dossier-tab {
    appearance: none;
    background: transparent;
    border: none;
    border-left: 2px solid var(--border-faint);
    width: 56px;
    height: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted-3);
    transition: border-color calc(.3s * var(--transition-scale)) ease,
        color calc(.3s * var(--transition-scale)) ease;
}

.dossier-tab-num {
    font-family: "JetBrains Mono", monospace;
    font-size: .7rem;
    letter-spacing: .05em;
}

.dossier-tab-mark {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .35;
    transition: opacity calc(.3s * var(--transition-scale)) ease,
        box-shadow calc(.3s * var(--transition-scale)) ease;
}

.dossier-tab.is-active {
    border-left-color: var(--tab-color, var(--accent-indigo));
    color: var(--tab-color, var(--accent-indigo));
}

.dossier-tab.is-active .dossier-tab-mark {
    opacity: 1;
    box-shadow: 0 0 10px var(--tab-color, var(--accent-indigo));
}

.dossier-tab:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* ---- chapter ---- */

.chapter {
    position: relative;
    min-height: 92vh;
    display: flex;
    align-items: center;
    padding: 90px 0;
    border-bottom: 1px solid var(--border-faint);
    overflow: hidden;
    scroll-margin-top: calc(var(--navbar-h, 56px) + 30px);
}

.chapter:last-child {
    border-bottom: none;
}

.chapter.is-hidden {
    display: none;
}

.chapter-atmosphere {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: .9;
}

.chapter-frame {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 64px;
    width: 100%;
}

/* The chapter's text block (index, eyebrow, title, desc, link) is the
   first, unclassed child of .chapter-frame — nudge it right a touch so
   it doesn't sit flush against the rail gap. Desktop/tablet only; on
   mobile the rail moves to a horizontal strip above the content, so
   this offset isn't needed there. */
@media (min-width: 861px) {
    .chapter-frame>div:first-child {
        margin-left: 15px;
    }
}

.chapter-index {
    font-family: "JetBrains Mono", monospace;
    font-size: .78rem;
    letter-spacing: .12em;
    color: var(--text-muted-3);
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chapter-index::before {
    content: "";
    width: 30px;
    height: 1px;
    background: var(--tab-color, var(--accent-indigo));
}

.chapter-eyebrow {
    display: block;
    font-family: "JetBrains Mono", monospace;
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--tab-color, var(--accent-indigo));
    margin-bottom: 18px;
}

.chapter-title {
    font-family: "Playfair Display", serif;
    font-style: italic;
    font-weight: 500;
    color: var(--primary-color);
    font-size: clamp(3.4rem, 8vw, 7.5rem);
    line-height: .96;
    margin-bottom: 34px;
}

.chapter-desc {
    color: var(--text-muted-1);
    font-family: Inter, sans-serif;
    font-size: 1.08rem;
    line-height: 1.85;
    max-width: 520px;
    margin-bottom: 30px;
}

.chapter-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    text-decoration: none;
    font-family: "JetBrains Mono", monospace;
    font-size: .82rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color calc(.25s * var(--transition-scale)) ease,
        gap calc(.25s * var(--transition-scale)) ease,
        color calc(.25s * var(--transition-scale)) ease;
}

.chapter-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.chapter-link:hover {
    border-color: var(--tab-color, var(--accent-indigo));
    color: var(--tab-color, var(--accent-indigo));
    gap: 14px;
}

/* ---- spec plaque (right column) ---- */

.chapter-plaque {
    align-self: start;
    padding-top: 8px;
    border-left: 1px solid var(--border-faint);
    padding-left: 32px;
}

.chapter-spec {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-bottom: 28px;
}

.chapter-spec-row dt {
    font-family: "JetBrains Mono", monospace;
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-muted-3);
    margin-bottom: 6px;
}

.chapter-spec-row dd {
    font-family: Inter, sans-serif;
    font-size: .92rem;
    color: var(--primary-text);
    line-height: 1.5;
}

.chapter-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.chapter-status i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted-3);
    flex-shrink: 0;
}

.chapter-status.is-ongoing i {
    background: var(--accent-teal);
    box-shadow: 0 0 8px rgba(47, 214, 160, .6);
}

.chapter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chapter-tags span {
    padding: 5px 12px;
    border: 1px solid var(--border-faint);
    color: var(--text-muted-8);
    font-family: "JetBrains Mono", monospace;
    font-size: .66rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* ===========================
   BESPOKE ATMOSPHERES
=========================== */

/* --- Curvya: drifting silk ribbons --- */

.chapter[data-project="curvya"] {
    --tab-color: #E6A8B4;
    background: radial-gradient(ellipse 80% 60% at 75% 20%, rgba(230, 168, 180, 0.08), transparent 65%);
}

.ribbon {
    position: absolute;
    filter: blur(.5px);
    opacity: .5;
    animation: ribbonDrift 22s ease-in-out infinite alternate;
}

.ribbon-b {
    animation-duration: 28s;
    animation-delay: -6s;
    opacity: .35;
}

@keyframes ribbonDrift {
    from {
        transform: translate(0, 0) rotate(0deg);
    }

    to {
        transform: translate(-3%, 2.5%) rotate(2.5deg);
    }
}

/* --- Axora: vault dial + scanline --- */

.chapter[data-project="axora"] {
    --tab-color: #6E8CFF;
    background: radial-gradient(ellipse 70% 55% at 78% 30%, rgba(59, 109, 255, 0.1), transparent 65%);
}


.scanline {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(to bottom,
            rgba(122, 162, 255, .05) 0px,
            rgba(122, 162, 255, .05) 1px,
            transparent 1px,
            transparent 3px);
    mix-blend-mode: overlay;
}

.scanline::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -140px;
    height: 140px;
    background: linear-gradient(to bottom, transparent, rgba(122, 162, 255, .1), transparent);
    animation: axScan 6s linear infinite;
}

@keyframes axScan {
    0% {
        top: -140px;
    }

    100% {
        top: 100%;
    }
}


/* glitching wordmark — sits big and quiet behind the copy, RGB-split
   channels jump apart on an irregular beat instead of looping smoothly */
.glitch-type {
    position: absolute;
    top: 50%;
    right: 0%;
    transform: translateY(-50%);
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
    font-size: clamp(6rem, 17vw, 15rem);
    letter-spacing: -.03em;
    line-height: 1;
    color: rgba(110, 140, 255, 0.14);
    -webkit-text-stroke: 1px rgba(110, 140, 255, 0.3);
    white-space: nowrap;
    user-select: none;
}

.glitch-type::before,
.glitch-type::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    -webkit-text-stroke: 0;
}

.glitch-type::before {
    color: rgba(255, 70, 90, 0.4);
    mix-blend-mode: screen;
    animation: glitchA 4.2s infinite;
}

.glitch-type::after {
    color: rgba(80, 255, 220, 0.35);
    mix-blend-mode: screen;
    animation: glitchB 4.2s infinite;
}

@keyframes glitchA {

    0%,
    92%,
    100% {
        transform: translate(0, 0);
        clip-path: inset(0 0 0 0);
        opacity: 0;
    }

    93% {
        transform: translate(-6px, 2px);
        clip-path: inset(10% 0 55% 0);
        opacity: 1;
    }

    94.5% {
        transform: translate(4px, -3px);
        clip-path: inset(60% 0 5% 0);
        opacity: 1;
    }

    96% {
        transform: translate(-3px, 0);
        clip-path: inset(30% 0 40% 0);
        opacity: 1;
    }

    97.5% {
        transform: translate(0, 0);
        opacity: 0;
    }
}

@keyframes glitchB {

    0%,
    91%,
    100% {
        transform: translate(0, 0);
        clip-path: inset(0 0 0 0);
        opacity: 0;
    }

    91.5% {
        transform: translate(6px, -2px);
        clip-path: inset(45% 0 20% 0);
        opacity: 1;
    }

    93% {
        transform: translate(-4px, 3px);
        clip-path: inset(5% 0 70% 0);
        opacity: 1;
    }

    95% {
        transform: translate(3px, 0);
        clip-path: inset(50% 0 15% 0);
        opacity: 1;
    }

    96.5% {
        transform: translate(0, 0);
        opacity: 0;
    }
}

/* traveling glare beam — a bright diagonal line sweeping the full
   width of the chapter, like light catching brushed metal */
.glare-line {
    position: absolute;
    top: -10%;
    bottom: -10%;
    left: -25%;
    width: 12%;
    background: linear-gradient(100deg,
            transparent,
            rgba(255, 255, 255, 0.25) 42%,
            rgba(140, 165, 255, 0.55) 50%,
            rgba(255, 255, 255, 0.25) 58%,
            transparent);
    filter: blur(4px);
    mix-blend-mode: screen;
    animation: glareTravel 5.5s cubic-bezier(.65, 0, .35, 1) infinite;
}

@keyframes glareTravel {
    0% {
        left: -25%;
        opacity: 0;
    }

    8% {
        opacity: 1;
    }

    45% {
        left: 115%;
        opacity: 1;
    }

    52% {
        opacity: 0;
    }

    100% {
        left: 115%;
        opacity: 0;
    }
}

/* --- Insight: ledger grid + rising sparkline --- */

.chapter[data-project="insight"] {
    --tab-color: var(--accent-insight);
    background: radial-gradient(ellipse 70% 55% at 78% 30%, rgba(47, 214, 160, 0.08), transparent 65%);
}

.ledger-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(47, 214, 160, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 214, 160, 0.05) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(to left, #000 30%, transparent 85%);
    -webkit-mask-image: linear-gradient(to left, #000 30%, transparent 85%);
}

.sparkline path {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawLine 3.2s cubic-bezier(.65, 0, .35, 1) forwards, sparkFloat 6s ease-in-out 3.2s infinite;
    animation-play-state: paused;
}

.chapter.is-visible .sparkline path {
    animation-play-state: running;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes sparkFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* --- Neurix: lined notebook page --- */

.chapter[data-project="neurix"] {
    --tab-color: #7C8695;
    background: radial-gradient(ellipse 70% 55% at 78% 30%, rgba(124, 134, 149, 0.08), transparent 65%);
}

/* --- Shadow: kanban board --- */

.chapter[data-project="shadow"] {
    --tab-color: #5964FF;
    background: radial-gradient(ellipse 70% 55% at 78% 30%, rgba(124, 134, 149, 0.08), transparent 65%);
}

/* ===========================
   RESPONSIVE
=========================== */

@media (max-width: 1024px) {
    .chapter-frame {
        grid-template-columns: 1fr 300px;
        gap: 40px;
    }
}

@media (max-width: 860px) {
    .projects-page {
        padding: 90px 0 0;
    }

    .projects-header {
        padding: 0 20px 34px;
    }

    .projects-header::before {
        font-size: 3rem;
    }

    .index-filters {
        gap: 20px;
        padding: 24px 20px 18px;
        overflow-x: auto;
    }

    .dossier {
        grid-template-columns: 1fr;
        padding: 0;
    }

    .dossier-rail {
        display: none;
        position: static;
        flex-direction: row;
        padding-top: 0;
        gap: 0;
        border-bottom: 1px solid var(--border-faint);
    }

    .dossier-tab {
        flex: 1;
        border-left: none;
        border-bottom: 2px solid var(--border-faint);
        height: 56px;
        flex-direction: row;
    }

    .dossier-tab.is-active {
        border-left-color: transparent;
        border-bottom-color: var(--tab-color, var(--accent-indigo));
    }

    .chapter {
        min-height: 0;
        padding: 56px 0;
    }

    .chapter-frame {
        grid-template-columns: 1fr;
        padding: 0 20px;
        gap: 36px;
    }

    .chapter-plaque {
        border-left: none;
        border-top: 1px solid var(--border-faint);
        padding-left: 0;
        padding-top: 26px;
    }

    .chapter-atmosphere {
        opacity: .6;
    }
}

@media (max-width: 480px) {
    .chapter-title {
        font-size: clamp(2.4rem, 12vw, 3.2rem);
    }
}