:root {
    --accent: #e5b97a;
    --accent-warm: #f0c98a;
    --bg: #08080b;
    --bg-soft: #0d0d12;
    --line: rgba(255,255,255,0.08);
}
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { background: var(--bg); }
body {
    font-family: 'Inter', sans-serif;
    color: #d1d1d6;
    cursor: none;
}
@media (max-width: 768px) { body { cursor: auto; } }

/* --- Custom cursor --- */
.cursor-dot, .cursor-ring {
    position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999;
    border-radius: 9999px; transform: translate(-50%, -50%);
    mix-blend-mode: difference;
}
.cursor-dot { width: 6px; height: 6px; background: #fff; transition: transform .15s ease; }
.cursor-ring { width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.5); transition: transform .2s ease, width .25s ease, height .25s ease, border-color .25s ease; }
.cursor-ring.hover { width: 70px; height: 70px; border-color: var(--accent); }
@media (max-width: 768px) { .cursor-dot, .cursor-ring { display: none; } }

/* --- Aurora background --- */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora::before, .aurora::after {
    content: ''; position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
    filter: blur(120px); opacity: .35; animation: drift 22s ease-in-out infinite;
}
.aurora::before { background: radial-gradient(circle, #e5b97a 0%, transparent 60%); top: -20vmax; left: -10vmax; }
.aurora::after { background: radial-gradient(circle, #5b3fb4 0%, transparent 60%); bottom: -25vmax; right: -15vmax; animation-delay: -8s; opacity: .25; }
@keyframes drift {
    0%, 100% { transform: translate(0,0) scale(1); }
    50% { transform: translate(5vmax, -5vmax) scale(1.15); }
}

/* --- Grain --- */
.grain {
    position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .04;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0d0d12; }
::-webkit-scrollbar-thumb { background: #2a2a36; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- Scroll progress --- */
#scroll-progress {
    position: fixed; top: 0; left: 0; height: 2px; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
    z-index: 100; transition: width .1s ease;
}

/* --- Reveal --- */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity .9s cubic-bezier(.22,1,.36,1), transform .9s cubic-bezier(.22,1,.36,1); }
.reveal.in { opacity: 1; transform: translateY(0); }
.reveal-stagger > * { opacity: 0; transform: translateY(30px); transition: opacity .8s cubic-bezier(.22,1,.36,1), transform .8s cubic-bezier(.22,1,.36,1); }
.reveal-stagger.in > * { opacity: 1; transform: translateY(0); }
.reveal-stagger.in > *:nth-child(1) { transition-delay: .05s; }
.reveal-stagger.in > *:nth-child(2) { transition-delay: .15s; }
.reveal-stagger.in > *:nth-child(3) { transition-delay: .25s; }
.reveal-stagger.in > *:nth-child(4) { transition-delay: .35s; }
.reveal-stagger.in > *:nth-child(5) { transition-delay: .45s; }
.reveal-stagger.in > *:nth-child(6) { transition-delay: .55s; }

/* --- Headline rise --- */
.hero-line { display: block; overflow: hidden; }
.hero-line span { display: inline-block; transform: translateY(110%); animation: rise 1.1s cubic-bezier(.22,1,.36,1) forwards; }
.hero-line.delay-1 span { animation-delay: .2s; }
.hero-line.delay-2 span { animation-delay: .35s; }
.hero-line.delay-3 span { animation-delay: .5s; }
@keyframes rise { to { transform: translateY(0); } }

/* --- Nav --- */
.nav-link { position: relative; font-size: .85rem; letter-spacing: .05em; text-transform: uppercase; }
.nav-link::before {
    content: ''; position: absolute; left: 0; bottom: -4px; width: 0; height: 1px;
    background: var(--accent); transition: width .35s cubic-bezier(.22,1,.36,1);
}
.nav-link:hover::before, .nav-link.active::before { width: 100%; }
.nav-link.active { color: #fff; }

/* --- Eyebrow --- */
.eyebrow {
    font-family: 'JetBrains Mono', monospace; font-size: .72rem; letter-spacing: .25em;
    text-transform: uppercase; color: var(--accent); display: inline-flex; align-items: center; gap: .75rem;
}
.eyebrow::before { content: ''; width: 2rem; height: 1px; background: var(--accent); display: inline-block; }

/* --- Marquee --- */
.marquee { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-track { display: flex; gap: 4rem; animation: scroll 32s linear infinite; white-space: nowrap; width: max-content; }
@keyframes scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* --- Discipline portal cards (home + category bottom) --- */
.discipline-card {
    position: relative; display: block; overflow: hidden;
    border: 1px solid var(--line); border-radius: 6px;
    aspect-ratio: 4/5;
    transition: border-color .5s ease, transform .6s cubic-bezier(.22,1,.36,1);
    background: #0d0d12;
}
.discipline-card-compact { aspect-ratio: 5/4; }
.discipline-card-compact .content { padding: 1.5rem; }
.discipline-card-compact .title { font-size: clamp(1.5rem, 2.5vw, 2rem); }
.discipline-card-compact .subtitle { font-size: .82rem; margin-top: .5rem; }
.discipline-card-compact .cta { margin-top: 1rem; }
.discipline-card:hover { border-color: rgba(229,185,122,.5); transform: translateY(-6px); }
.discipline-card .bg-img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    transition: transform 1.4s cubic-bezier(.22,1,.36,1), filter .6s ease;
    filter: saturate(.7) brightness(.5);
}
.discipline-card:hover .bg-img { transform: scale(1.08); filter: saturate(1) brightness(.6); }

/* --- Collage 2x2 (replaces single bg image when 2+ unique images exist) --- */
.discipline-card .collage {
    position: absolute; inset: 0;
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
    gap: 2px;
}
.discipline-card .collage .tile {
    overflow: hidden; position: relative; background: #0d0d12;
}
.discipline-card .collage .tile img {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 1.4s cubic-bezier(.22,1,.36,1), filter .6s ease;
    filter: saturate(.6) brightness(.45);
}
.discipline-card:hover .collage .tile img {
    transform: scale(1.08);
    filter: saturate(1) brightness(.6);
}
.discipline-card:hover .collage .tile:nth-child(1) img { transition-delay: 0s; }
.discipline-card:hover .collage .tile:nth-child(2) img { transition-delay: .06s; }
.discipline-card:hover .collage .tile:nth-child(3) img { transition-delay: .12s; }
.discipline-card:hover .collage .tile:nth-child(4) img { transition-delay: .18s; }
.discipline-card::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(8,8,11,.95) 0%, rgba(8,8,11,.3) 50%, rgba(8,8,11,.6) 100%);
}
.discipline-card .content {
    position: relative; z-index: 2; height: 100%; padding: 2rem;
    display: flex; flex-direction: column; justify-content: space-between;
}
.discipline-card .num {
    font-family: 'JetBrains Mono', monospace; font-size: .7rem; letter-spacing: .25em; color: var(--accent);
}
.discipline-card .count {
    font-family: 'JetBrains Mono', monospace; font-size: .65rem; letter-spacing: .2em;
    text-transform: uppercase; color: rgba(255,255,255,.7);
    border: 1px solid rgba(255,255,255,.2); padding: .35rem .75rem; border-radius: 999px;
    background: rgba(0,0,0,.4); backdrop-filter: blur(8px);
}
.discipline-card .title {
    font-family: 'Instrument Serif', serif; font-size: clamp(2.2rem, 4vw, 3.5rem);
    color: #fff; line-height: 1; letter-spacing: -.01em;
}
.discipline-card .subtitle {
    color: rgba(255,255,255,.75); font-size: .9rem; line-height: 1.5;
    margin-top: .75rem; max-width: 90%;
}
.discipline-card .cta {
    display: inline-flex; align-items: center; gap: .5rem;
    margin-top: 1.5rem; color: var(--accent);
    font-family: 'JetBrains Mono', monospace; font-size: .7rem; letter-spacing: .2em; text-transform: uppercase;
    transition: gap .3s ease;
}
.discipline-card:hover .cta { gap: 1rem; }

/* --- Filter buttons --- */
.filter-btn {
    position: relative; font-family: 'JetBrains Mono', monospace; font-size: .72rem;
    letter-spacing: .15em; text-transform: uppercase; padding: .75rem 1.25rem;
    border: 1px solid var(--line); color: #9ca3af; background: transparent;
    transition: all .3s ease; border-radius: 999px;
}
.filter-btn:hover { color: #fff; border-color: rgba(229,185,122,.5); }
.filter-btn.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }

/* --- Portfolio cards (category page) --- */
.portfolio-item {
    position: relative; overflow: hidden; border-radius: 4px;
    background: #15151c; border: 1px solid var(--line);
    transition: transform .6s cubic-bezier(.22,1,.36,1), border-color .4s ease;
}
.portfolio-item:hover { transform: translateY(-8px); border-color: rgba(229,185,122,.4); }
.portfolio-item img {
    transition: transform 1.2s cubic-bezier(.22,1,.36,1), filter .6s ease;
    filter: saturate(.9) brightness(.85);
}
.portfolio-item:hover img { transform: scale(1.06); filter: saturate(1.1) brightness(1); }
.portfolio-overlay {
    position: absolute; inset: 0; padding: 1.5rem; display: flex; flex-direction: column; justify-content: flex-end;
    background: linear-gradient(to top, rgba(8,8,11,.95) 0%, rgba(8,8,11,.5) 40%, transparent 70%);
}
.portfolio-tag {
    font-family: 'JetBrains Mono', monospace; font-size: .65rem; letter-spacing: .2em;
    text-transform: uppercase; color: var(--accent); margin-bottom: .5rem;
}

/* --- Buttons --- */
.btn-primary {
    display: inline-flex; align-items: center; gap: .75rem; padding: 1rem 2rem;
    background: var(--accent); color: var(--bg); font-weight: 600; letter-spacing: .02em;
    border-radius: 999px; transition: all .4s cubic-bezier(.22,1,.36,1);
    font-size: .9rem;
}
.btn-primary:hover { background: var(--accent-warm); transform: translateY(-2px); box-shadow: 0 20px 40px -20px rgba(229,185,122,.6); }
.btn-ghost {
    display: inline-flex; align-items: center; gap: .75rem; padding: 1rem 2rem;
    border: 1px solid var(--line); color: #fff; border-radius: 999px;
    transition: all .4s ease; font-size: .9rem;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* --- Modal --- */
.modal-enter { animation: fadeIn 0.4s cubic-bezier(.22,1,.36,1) forwards; }
.modal-leave { animation: fadeOut 0.3s ease-in forwards; }
@keyframes fadeIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(8px); }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
#modal-content {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    animation: scaleIn .5s cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes scaleIn {
    from { transform: scale(.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
#media-container { position: relative; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#description-container { overflow-y: auto; }

/* --- Video stage (used by single videos AND video gallery) --- */
.video-stage {
    position: relative; background: #000;
    aspect-ratio: var(--video-aspect, 16/9);
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    display: block;
}
.video-stage iframe,
.video-stage video {
    width: 100%; height: 100%; background: #000; border: 0; display: block;
}

.video-stage:not([data-orient="portrait"]) {
    width: 100%;
    height: auto;
}
.video-stage[data-orient="portrait"] {
    height: 75vh;
    width: calc(75vh * var(--video-w, 9) / var(--video-h, 16));
    max-width: 100%;
}
#media-container.video-gallery-container {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    justify-items: center;
    background: #000;
}
#media-container.video-gallery-container .video-stage[data-orient="portrait"] {
    height: 60vh;
    width: calc(60vh * var(--video-w, 9) / var(--video-h, 16));
}

@media (max-width: 767px) {
    .video-stage[data-orient="portrait"] {
        height: 65vh;
        width: calc(65vh * var(--video-w, 9) / var(--video-h, 16));
    }
    #media-container.video-gallery-container .video-stage[data-orient="portrait"] {
        height: 50vh;
        width: calc(50vh * var(--video-w, 9) / var(--video-h, 16));
    }
}
#video-strip {
    display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden;
    padding: 10px; background: #0d0d12; border-top: 1px solid var(--line);
    scroll-snap-type: x mandatory;
}
#video-strip::-webkit-scrollbar { height: 6px; }
#video-strip::-webkit-scrollbar-thumb { background: #2a2a36; border-radius: 3px; }
.video-tile {
    position: relative; flex: 0 0 auto; width: 110px; aspect-ratio: 16/9;
    border: 2px solid transparent; border-radius: 4px; overflow: hidden;
    cursor: pointer; padding: 0; background: #15151c;
    scroll-snap-align: center;
    transition: border-color .25s ease, transform .25s ease;
}
.video-tile img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    filter: brightness(.7);
    transition: filter .25s ease;
}
.video-tile:hover { transform: translateY(-2px); }
.video-tile:hover img { filter: brightness(1); }
.video-tile .num {
    position: absolute; bottom: 4px; left: 4px;
    font-family: 'JetBrains Mono', monospace; font-size: .6rem; letter-spacing: .15em;
    color: #fff; background: rgba(0,0,0,.7); padding: 2px 5px; border-radius: 3px;
    pointer-events: none;
}
.video-tile.active { border-color: var(--accent); }
.video-tile.active img { filter: brightness(1) saturate(1.1); }
.video-tile.active::after {
    content: ''; position: absolute; inset: 0;
    box-shadow: inset 0 0 0 2px rgba(229,185,122,.4);
    border-radius: 4px; pointer-events: none;
}

/* --- Stats --- */
.stat-num {
    font-family: 'Instrument Serif', serif; font-size: clamp(3rem, 6vw, 5rem);
    line-height: 1; color: #fff; font-weight: 400;
}

/* --- Inputs --- */
.input-field {
    background: transparent; border: none; border-bottom: 1px solid var(--line);
    padding: .9rem 0; color: #fff; width: 100%; transition: border-color .3s ease;
    font-size: .95rem;
}
.input-field:focus { outline: none; border-bottom-color: var(--accent); }
.input-label {
    font-family: 'JetBrains Mono', monospace; font-size: .7rem;
    letter-spacing: .2em; text-transform: uppercase; color: #6b7280; margin-bottom: .25rem;
}

/* --- Loader --- */
#loader {
    position: fixed; inset: 0; background: #08080b; z-index: 10000;
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    transition: opacity .8s ease, visibility .8s ease;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-text {
    font-family: 'Instrument Serif', serif; font-size: 4rem; color: #fff;
    overflow: hidden; height: 1.2em;
}
.loader-text span { display: inline-block; animation: rise 1s cubic-bezier(.22,1,.36,1) forwards; }
.loader-bar {
    margin-top: 2rem; width: 200px; height: 1px; background: rgba(255,255,255,.1); position: relative; overflow: hidden;
}
.loader-bar::after {
    content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 0%; background: var(--accent);
    animation: load 1.4s cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes load { to { width: 100%; } }

/* --- Avatar --- */
.avatar-wrap { position: relative; }
.avatar-wrap::before {
    content: ''; position: absolute; inset: -12px; border-radius: 50%;
    border: 1px solid rgba(229,185,122,.3); animation: pulse 3s ease-in-out infinite;
}
.avatar-wrap::after {
    content: ''; position: absolute; inset: -24px; border-radius: 50%;
    border: 1px solid rgba(229,185,122,.15); animation: pulse 3s ease-in-out infinite .5s;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: .8; }
    50% { transform: scale(1.06); opacity: .3; }
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS (< 768px)
   ========================================================================== */

@media (max-width: 767px) {
    /* --- Discipline cards: shorter on mobile so 4 don't fill 2.5 screens --- */
    .discipline-card { aspect-ratio: 5/6; }
    .discipline-card .content { padding: 1.25rem; }
    .discipline-card .title { font-size: clamp(1.75rem, 7vw, 2.5rem); line-height: 1; }
    .discipline-card .subtitle { font-size: .85rem; margin-top: .5rem; }
    .discipline-card .cta {
        /* No hover on touch — always show the CTA */
        opacity: 1; margin-top: 1rem;
    }
    .discipline-card .cta { gap: .5rem; }

    /* --- Compact card: tighter on mobile too --- */
    .discipline-card-compact { aspect-ratio: 5/6; }

    /* --- Hero h1: prevent overflow on narrow screens --- */
    .text-\[clamp\(2\.8rem\,7vw\,6\.5rem\)\] { font-size: clamp(2.4rem, 9vw, 3.5rem); }

    /* --- Big serif headlines: scale down --- */
    .font-serif.text-5xl { font-size: 2.5rem; }
    .font-serif.text-6xl { font-size: 2.75rem; }
    .font-serif.text-7xl { font-size: 3rem; }

    /* --- Stats: single value per row gets too wide; keep 3 cols but shrink --- */
    .stat-num { font-size: clamp(2.25rem, 9vw, 3rem); }

    /* --- Filter buttons: slightly bigger touch targets --- */
    .filter-btn { padding: .85rem 1.1rem; font-size: .7rem; }

    /* --- Modal: edge-to-edge backdrop, tighter content padding --- */
    #project-modal { padding: .5rem; }
    #modal-content {
        max-height: 95vh; border-radius: 6px;
        /* Override desktop grid — on mobile, stack content tightly with
           description filling remaining space. This kills the giant black
           gap above/below short videos. */
        display: flex !important;
        flex-direction: column;
    }
    #media-container,
    #media-container.video-gallery-container {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        flex: 0 0 auto;
        background: #000;
    }
    #media-container.video-gallery-container .video-stage,
    #media-container .video-stage {
        margin: 0 auto;
    }
    #description-container {
        /* size to content, scroll if too long */
        flex: 0 0 auto;
        padding: 1.25rem !important;
        overflow-y: auto;
        max-height: 50vh;
    }
    #description-container h3 { font-size: 1.5rem !important; }

    /* --- Video gallery strip: smaller tiles to fit more visible --- */
    .video-tile { width: 88px; }
    #video-strip { padding: 8px; gap: 4px; }

    /* --- Loader: scale text down --- */
    .loader-text { font-size: clamp(2rem, 10vw, 3rem); }

    /* --- Avatar: slightly smaller so it doesn't dominate --- */
    .avatar-wrap img { width: 12rem !important; height: 12rem !important; }

    /* --- Category page hero padding --- */
    .cat-hero { padding-top: 8rem; padding-bottom: 3rem; }

    /* --- Marquee: smaller, faster on mobile to feel less heavy --- */
    .marquee-track { animation-duration: 20s; }
}

/* --- Touch-device specific (no hover) --- */
@media (hover: none) and (pointer: coarse) {
    /* Bump tap areas on small icon links (social icons, etc.) */
    a[aria-label] svg { pointer-events: none; }
    a[aria-label] {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }
    /* Active-state press effect (replaces hover for touch) */
    a:active, button:active { opacity: .7; transition: opacity .1s; }
}

/* --- Smallest screens (iPhone SE, etc.) --- */
@media (max-width: 380px) {
    .py-32 { padding-top: 5rem; padding-bottom: 5rem; }
    .container { padding-left: 1rem !important; padding-right: 1rem !important; }
    .btn-primary, .btn-ghost { padding: .85rem 1.5rem; font-size: .85rem; }
}

/* --- Category page hero --- */
.cat-hero { padding-top: 11rem; padding-bottom: 5rem; }
.cat-back {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: 'JetBrains Mono', monospace; font-size: .72rem;
    letter-spacing: .2em; text-transform: uppercase; color: #9ca3af;
    transition: color .3s ease, gap .3s ease;
}
.cat-back:hover { color: var(--accent); gap: .8rem; }
