/* ============================================================
   cinematic.css - Depth overhaul for Profile v2
   Layered OVER styles.css. Adds:
     • Sticky diorama for About (3 cards fly through as you scroll)
     • Sticky horizontal career timeline
     • Card polish - deeper shadows, reactive glow, tilt
     • Film grain + nebula atmosphere
   ============================================================ */

/* ---- perspective applied per-card (see .card-grid--repos etc.)
   so that position: fixed elements keep the viewport as their containing block
   and don't inherit document-height sizing. ---- */
body {
    position: relative;
    overflow-x: hidden;
}

/* ==============================================
   1) Film grain + ambient nebula
   ============================================== */
.grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 51;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.22 0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    opacity: 0.22;
    mix-blend-mode: overlay;
}
[data-theme='night'] .grain-overlay {
    opacity: 0.12;
}

/* Subtle vignette - keeps eye on content, deepens edges */
.vignette-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    box-shadow: inset 0 0 240px 40px rgba(20, 10, 60, 0.18);
}
[data-theme='night'] .vignette-overlay {
    box-shadow: inset 0 0 260px 60px rgba(0, 0, 0, 0.55);
}

/* ==============================================
   3) Cards - light spotlight on hover
   ============================================== */
.about-card,
.lead-card,
.write-card,
.skill-cat,
.cert,
.contact-card,
.book,
.impact__cell {
    position: relative;
    transform-style: preserve-3d;
    transition:
        transform 0.5s cubic-bezier(0.16, 0.84, 0.44, 1),
        box-shadow 0.5s,
        border-color 0.3s;
}

/* Per-card cursor-follow glow */
.about-card::before,
.lead-card::before,
.write-card::before,
.skill-cat::before,
.cert::before,
.contact-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
    background: radial-gradient(
        360px circle at var(--mx, 50%) var(--my, 50%),
        rgba(119, 68, 204, 0.18),
        transparent 55%
    );
    pointer-events: none;
    z-index: 0;
}
[data-theme='night'] .about-card::before,
[data-theme='night'] .lead-card::before,
[data-theme='night'] .write-card::before,
[data-theme='night'] .skill-cat::before,
[data-theme='night'] .cert::before,
[data-theme='night'] .contact-card::before {
    background: radial-gradient(
        360px circle at var(--mx, 50%) var(--my, 50%),
        rgba(170, 119, 255, 0.24),
        transparent 55%
    );
}
.about-card:hover::before,
.lead-card:hover::before,
.write-card:hover::before,
.skill-cat:hover::before,
.cert:hover::before,
.contact-card:hover::before {
    opacity: 1;
}

.about-card > *,
.lead-card > *,
.write-card > *,
.skill-cat > *,
.contact-card > * {
    position: relative;
    z-index: 1;
}

/* Disable old .lead-card::before left-stripe that conflicts with our spotlight */
.lead-card::before {
    left: unset;
    top: unset;
    bottom: unset;
    width: unset;
    background: radial-gradient(
        360px circle at var(--mx, 50%) var(--my, 50%),
        rgba(212, 160, 16, 0.22),
        transparent 55%
    );
}
[data-theme='night'] .lead-card::before {
    background: radial-gradient(
        360px circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 204, 51, 0.3),
        transparent 55%
    );
}

/* ==============================================
   4) Sticky diorama - About section
   ============================================== */
.section--about {
    padding: 0 !important;
    max-width: none;
}
.diorama {
    position: relative;
    height: 360vh; /* longer scroll = slower transitions */
}
.diorama__sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 48px;
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 var(--pad);
    overflow: visible;
}
@media (max-width: 900px) {
    .diorama {
        height: 320vh;
    }
    .diorama__sticky {
        grid-template-columns: 1fr;
        gap: 24px;
        padding-top: 80px;
        padding-bottom: 40px;
        overflow: hidden;
        align-items: start;
    }
    .diorama__stage {
        height: min(420px, 50vh);
    }
}

.diorama__copy {
    position: relative;
    z-index: 2;
}
.diorama__copy .section__eyebrow {
    margin-bottom: 10px;
}
.diorama__copy .section__title {
    margin-bottom: 16px;
}
.diorama__copy .section__sub {
    margin-bottom: 24px;
    max-width: 44ch;
}
.diorama__progress {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.diorama__progress span {
    width: 40px;
    height: 3px;
    border-radius: 2px;
    background: var(--border-strong);
    transition:
        background 0.4s,
        transform 0.4s;
}
.diorama__progress span.active {
    background: var(--color-mint);
    transform: scaleY(1.6);
}

.diorama__stage {
    position: relative;
    height: 500px;
    perspective: 1800px;
    transform-style: preserve-3d;
    /* In preserve-3d with tz≈0, the stage plane and its active card are
       coplanar, so hit-tests can land on the stage instead of the card.
       Making the stage pointer-transparent lets clicks reach the cards,
       which manage their own pointer-events per-scroll-position. */
    pointer-events: none;
}

.stage-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(360px, 90%);
    padding: 32px 28px;
    border-radius: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    transform-origin: center;
    /* no transition - driven directly by scroll every frame */
    transition: none !important;
    opacity: 0;
    backdrop-filter: blur(12px);
    box-shadow:
        0 10px 24px rgba(20, 10, 60, 0.1),
        0 40px 80px rgba(20, 10, 60, 0.14),
        0 100px 140px rgba(119, 68, 204, 0.18);
    will-change: transform, opacity;
}
[data-theme='night'] .stage-card {
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.4),
        0 60px 110px rgba(0, 0, 0, 0.5),
        0 120px 160px rgba(170, 119, 255, 0.25);
}
.stage-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--glow-lavender);
    color: var(--color-lavender);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 20px;
    margin-bottom: 16px;
}
.stage-card:nth-child(2) .icon {
    background: var(--glow-mint);
    color: var(--color-mint);
}
.stage-card:nth-child(3) .icon {
    background: var(--glow-peach);
    color: var(--color-peach);
}
.stage-card h3 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 26px;
    margin: 0 0 12px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.stage-card p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.65;
    margin: 0;
}
.stage-card .tag-row {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.stage-card .tag-row span {
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--glow-mint);
    color: var(--color-mint);
}

/* Impact row sits directly under the hero as a stats strip */
.hero-impact {
    max-width: var(--max);
    margin: 0 auto;
    padding: 40px var(--pad) 80px;
    position: relative;
    z-index: 2;
}

/* ==============================================
   5) Sticky career - reuses the About diorama
   ============================================== */
.section--career {
    padding: 0 !important;
    max-width: none;
}
/* Peach accent on career dots to distinguish from about's mint */
.career-dio .diorama__progress span.active {
    background: var(--color-peach);
}

/* Career only: flip the diorama so the copy sits on the right and the
   stage cards sit on the left, and align the two columns with About's
   columns above (card left edge = About title left edge; title block
   center = About card center). Mobile (<=900px) stacks to one column
   and order is irrelevant there, so scope this to the 2-column layout. */
@media (min-width: 901px) {
    .section--career .diorama__sticky .diorama__copy {
        order: 2;
        justify-self: center;
        max-width: 36ch;
    }
    .section--career .diorama__sticky .diorama__stage {
        order: 1;
        width: min(360px, 100%);
        justify-self: start;
    }
}

/* Career stage cards carry a date eyebrow + byline on top of the about base */
.stage-card--career {
    cursor: pointer;
}
.stage-card--career .stage-card__date {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-peach);
    margin-bottom: 8px;
}
.stage-card--career .stage-card__co {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 14px;
    font-weight: 500;
}
.stage-card--career .stage-card__co a {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-strong);
}
.stage-card--career .stage-card__co a:hover {
    color: var(--color-peach);
    border-bottom-color: var(--color-peach);
}
.stage-card--career .icon {
    background: var(--glow-peach);
    color: var(--color-peach);
}
.stage-card--career h3 {
    margin-bottom: 4px;
}
.stage-card--career p {
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stage-card--career .stage-card__more {
    background: transparent;
    border: 0;
    color: var(--color-peach);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 0;
    cursor: pointer;
    transition:
        color 0.2s,
        text-decoration-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 3px;
}
.stage-card--career .stage-card__more:hover {
    text-decoration-color: currentColor;
}
.stage-card--career .stage-card__more .arr {
    transition: transform 0.2s;
}
.stage-card--career .stage-card__more:hover .arr {
    transform: translateX(3px);
}

.stage-card--career[data-tail='true'] .icon {
    background: var(--glow-lavender);
    color: var(--color-lavender);
}
.stage-card--career[data-tail='true'] h3 {
    font-style: italic;
}
.stage-card--career[data-tail='true'] .stage-card__more {
    color: var(--color-lavender);
}

/* hide the old vertical line (unused since the pivot redesign) */
.section--career .career__line {
    display: none;
}

/* ==============================================
   6) Scroll reveal - depth-based, not the old one
   ============================================== */
[data-depth-reveal] {
    opacity: 0;
    transform: translateY(40px) translateZ(-80px) scale(0.97);
    filter: blur(4px);
    transition:
        opacity 1s cubic-bezier(0.16, 0.84, 0.44, 1),
        transform 1.1s cubic-bezier(0.16, 0.84, 0.44, 1),
        filter 1s;
}
[data-depth-reveal].in {
    opacity: 1;
    transform: none;
    filter: none;
}

/* ==============================================
   7) Nebula - replaces the old three.js hero bg
   ============================================== */
.nebula {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(1100px 700px at 15% 10%, var(--glow-lavender), transparent 60%),
        radial-gradient(900px 600px at 85% 5%, var(--glow-mint), transparent 60%),
        radial-gradient(1000px 700px at 50% 95%, var(--glow-peach), transparent 65%);
    filter: blur(25px);
    opacity: 0.9;
    transition: transform 0.1s linear;
    will-change: transform;
}

/* Turn off old depth canvas and hero-3d */
#ambient-canvas,
#hero-3d {
    display: none !important;
}
.bg-noise,
.bg-grid {
    opacity: 0 !important;
}

/* ==============================================
   8) Hero tweaks - ask card deeper, more cinematic
   ============================================== */
.hero {
    perspective: 1800px;
    transform-style: preserve-3d;
}
.ask {
    box-shadow:
        0 8px 16px rgba(20, 10, 60, 0.1),
        0 40px 80px rgba(20, 10, 60, 0.14),
        0 90px 160px rgba(119, 68, 204, 0.22);
}
[data-theme='night'] .ask {
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.5),
        0 80px 140px rgba(170, 119, 255, 0.25),
        0 120px 180px rgba(0, 0, 0, 0.4);
}

/* ==============================================
   9) Section-wash slabs - deep drop shadow between sections
   ============================================== */
.section--wash {
    box-shadow:
        0 -30px 60px rgba(20, 10, 60, 0.08),
        0 30px 60px rgba(20, 10, 60, 0.08);
    position: relative;
    z-index: 2;
}
[data-theme='night'] .section--wash {
    box-shadow:
        0 -40px 80px rgba(0, 0, 0, 0.4),
        0 40px 80px rgba(0, 0, 0, 0.4);
}

/* ==============================================
   10) Remove old floating hint arrow; it overlaps the diorama
   ============================================== */
.hero__hint {
    opacity: 0.7;
}

/* ==============================================
   11) Cinematic treatment for Skills/Leadership/Writing/Contact
   ============================================== */

/* Deeper shadow + lift on ALL interactive cards in day mode */
.about-card,
.lead-card,
.write-card,
.skill-cat,
.cert,
.contact-card {
    box-shadow:
        0 10px 20px rgba(20, 10, 60, 0.06),
        0 30px 60px rgba(20, 10, 60, 0.09),
        0 80px 120px rgba(119, 68, 204, 0.1);
}
[data-theme='night'] .about-card,
[data-theme='night'] .lead-card,
[data-theme='night'] .write-card,
[data-theme='night'] .skill-cat,
[data-theme='night'] .cert,
[data-theme='night'] .contact-card {
    box-shadow:
        0 16px 32px rgba(0, 0, 0, 0.35),
        0 50px 100px rgba(0, 0, 0, 0.45),
        0 120px 160px rgba(170, 119, 255, 0.18);
}

/* Parallax section titles - gently float as you scroll through them */
.section__title {
    will-change: transform;
}

/* Stagger the grid children with depth reveal for cinema feel */
.skill-grid [data-depth-reveal]:nth-child(1) {
    transition-delay: 0.05s;
}
.skill-grid [data-depth-reveal]:nth-child(2) {
    transition-delay: 0.15s;
}
.skill-grid [data-depth-reveal]:nth-child(3) {
    transition-delay: 0.25s;
}
.skill-grid [data-depth-reveal]:nth-child(4) {
    transition-delay: 0.35s;
}

.lead-grid [data-depth-reveal]:nth-child(1) {
    transition-delay: 0.05s;
}
.lead-grid [data-depth-reveal]:nth-child(2) {
    transition-delay: 0.15s;
}
.lead-grid [data-depth-reveal]:nth-child(3) {
    transition-delay: 0.25s;
}
.lead-grid [data-depth-reveal]:nth-child(4) {
    transition-delay: 0.35s;
}
.lead-grid [data-depth-reveal]:nth-child(5) {
    transition-delay: 0.45s;
}
.lead-grid [data-depth-reveal]:nth-child(6) {
    transition-delay: 0.55s;
}

.writing-grid [data-depth-reveal]:nth-child(1) {
    transition-delay: 0.05s;
}
.writing-grid [data-depth-reveal]:nth-child(2) {
    transition-delay: 0.18s;
}
.writing-grid [data-depth-reveal]:nth-child(3) {
    transition-delay: 0.31s;
}
.writing-grid [data-depth-reveal]:nth-child(4) {
    transition-delay: 0.44s;
}
.writing-grid [data-depth-reveal]:nth-child(5) {
    transition-delay: 0.57s;
}
.writing-grid [data-depth-reveal]:nth-child(6) {
    transition-delay: 0.7s;
}

.certs [data-depth-reveal]:nth-child(n) {
    transition-delay: calc(var(--i, 0) * 60ms);
}

/* Each section slab gently tilts into view */
.section--skills,
.section--leadership,
.section--publications,
.section--certs,
.section--contact {
    perspective: 1800px;
}

/* Book card gets a cinematic pedestal */
.book {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 0.84, 0.44, 1);
}
.book:hover {
    transform: rotateY(-3deg) rotateX(2deg) translateZ(8px);
}
.book__cover {
    transition:
        transform 0.6s cubic-bezier(0.16, 0.84, 0.44, 1),
        box-shadow 0.6s;
}
.book:hover .book__cover {
    transform: translateZ(40px) rotateY(4deg);
    box-shadow:
        0 40px 80px var(--glow-lavender),
        0 80px 140px rgba(119, 68, 204, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}

/* Contact pedestal */
.contact-card {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 0.84, 0.44, 1);
}
.contact-card:hover {
    transform: translateZ(10px);
}
.contact-card h3 {
    transition: transform 0.5s cubic-bezier(0.16, 0.84, 0.44, 1);
}
.contact-card:hover h3 {
    transform: translateZ(30px);
}

/* Slightly larger cursor spotlight over sections with cards */
.section--skills,
.section--leadership,
.section--publications,
.section--certs,
.section--contact {
    position: relative;
    z-index: 2;
}
