/* =========================================
   1. CSS VARIABLES & RESET
========================================= */
:root {
    --bg: #ffffff;
    --text: #111111;
    --accent: #FF5500; /* Bright Orange */
    --gray: #888888;
    --grid-line: rgba(0, 0, 0, 0.05);
    --card-tint: rgba(255, 255, 255, 0.9);
    --font-stack: "Neue Haas Grotesk Display Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --transition: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg: #000000;
    --text: #ffffff;
    --gray: #aaaaaa;
    --grid-line: rgba(255, 255, 255, 0.1);
    --card-tint: rgba(0, 0, 0, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: none; /* Hide default cursor for XR Lens */
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-stack);
    line-height: 1.3;
    width: 100%;
    transition: background-color var(--transition), color var(--transition);
}

/* =========================================
   GRID BACKGROUND
========================================= */
.grid-background {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: -1;
    background-image: 
        linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
    background-size: 5vw 100%, 100% 5vh;
}

/* =========================================
   SCROLL PROGRESS
========================================= */
#scroll-progress {
    position: fixed;
    top: 0; left: 0; width: 0%; height: 2px;
    background-color: var(--accent);
    z-index: 10000;
}

/* =========================================
   2. XR LENS CURSOR
========================================= */
.cursor-lens {
    position: fixed;
    top: 0; left: 0;
    width: 16px; height: 16px;
    background-color: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    transition: width 0.2s ease-out, 
                height 0.2s ease-out,
                background-color 0.2s ease-out;
    mix-blend-mode: difference; 
}

.cursor-lens.active {
    width: 80px;
    height: 80px;
    background-color: #ffffff;
}

/* =========================================
   3. NAVIGATION & LAYOUT
========================================= */
nav {
    position: fixed;
    top: 0; left: 0; width: 100%;
    padding: 2rem 4rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: var(--bg);
    opacity: 0.95;
    transition: background var(--transition), padding 0.4s ease;
}

nav.scrolled {
    padding: 1.2rem 4rem;
    border-bottom: 1px solid var(--grid-line);
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--text);
    color: var(--text);
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), 
                background 0.3s ease, 
                color 0.3s ease,
                border-color 0.3s ease;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--text);
    color: var(--bg);
}

[data-theme="dark"] .theme-toggle {
    transform: rotate(180deg);
}

section {
    min-height: 60vh;
    padding: 6rem 4rem;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

#hero {
    padding-top: 14rem; /* Safe headspace */
}

/* Scroll Reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

h1 {
    font-size: clamp(3rem, 8vw, 9rem);
    letter-spacing: -0.04em;
    line-height: 0.9;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2rem;
}

h2 {
    font-size: clamp(2rem, 4vw, 4rem);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--text);
    padding-bottom: 1rem;
    margin-bottom: 3rem;
    transition: border-color var(--transition);
}

p.lead {
    font-size: clamp(1.2rem, 2vw, 2rem);
    max-width: 800px;
    color: var(--gray);
    font-weight: 400;
}

/* TYPOGRAPHIC ROTATION */
.rotating-terms {
    display: inline-block;
    height: 1em;
    overflow: hidden;
    vertical-align: bottom;
    position: relative;
}

.term-list {
    display: flex;
    flex-direction: column;
    animation: rotate-terms 10s cubic-bezier(0.76, 0, 0.24, 1) infinite;
}

.term-list span {
    display: block;
    height: 1em;
    white-space: nowrap;
}

@keyframes rotate-terms {
    0%, 15% { transform: translateY(0); }
    20%, 35% { transform: translateY(-1em); }
    40%, 55% { transform: translateY(-2em); }
    60%, 75% { transform: translateY(-3em); }
    80%, 95% { transform: translateY(-4em); }
    100% { transform: translateY(-5em); }
}

/* =========================================
   NEWS TICKER MARQUEE
========================================= */
.marquee {
    width: 100%;
    overflow: hidden;
    background: var(--text);
    color: var(--bg);
    padding: 1rem 0;
    white-space: nowrap;
    position: relative;
    z-index: 10;
    border-top: 1px solid var(--accent);
    border-bottom: 1px solid var(--accent);
    margin-top: -2rem;
    margin-bottom: 4rem;
}

.marquee-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 30s linear infinite;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 1.2rem;
}

@keyframes marquee {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-100%, 0); }
}

/* =========================================
   4. EDUCATIONAL FLASHCARDS (GAMES)
========================================= */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    width: 100%;
}

.game-card {
    height: 350px;
    border: 2px solid var(--text);
    position: relative;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    transition: all 0.4s ease;
    container-type: inline-size; /* Enable Container Queries */
}

.game-card:hover {
    border-color: var(--accent);
    transform: translateY(-5px);
}

.card-front, .card-back, .card-video {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-video {
    z-index: 1;
    opacity: 0;
    background: #222;
    transition: opacity 0.4s;
    overflow: hidden;
}

.card-video::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 85, 0, 0.1) 2px, rgba(255, 85, 0, 0.1) 4px);
    z-index: 2;
}

.game-card:hover .card-video {
    opacity: 1;
}

.card-front {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg);
    z-index: 2;
    padding: 1.5rem 1rem; /* Reduced horizontal padding further */
}

.card-front h3 {
    font-size: clamp(0.8rem, 10cqw, 2.4rem); /* More aggressive scaling floor */
    line-height: 1.2;
    letter-spacing: -0.04em;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    width: 100%;
}

.card-front h3.wrap-title {
    white-space: normal; /* Allow wrapping for courses */
    word-break: normal;
    overflow-wrap: break-word;
    font-size: clamp(1rem, 10cqw, 2rem); /* Slightly smaller than brand names to ensure fit */
}

.card-front span {
    text-transform: uppercase;
    font-weight: bold;
    color: var(--accent);
}

.card-back {
    background: var(--text);
    color: var(--bg);
    transform: translateY(100%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem;
}

.card-back h4 {
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
}

.game-card:hover .card-front {
    transform: translateY(-100%);
}

.game-card:hover .card-back {
    transform: translateY(0);
}

/* =========================================
   5. DYNAMIC BLUEPRINT (PUBLICATIONS)
========================================= */
.filter-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: none;
    border: 1px solid var(--gray);
    color: var(--gray);
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.filter-btn.active, .filter-btn:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.pub-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.pub-item {
    display: grid;
    grid-template-columns: 80px 1fr 150px;
    gap: 2rem;
    align-items: center;
    padding: 2.5rem 1rem;
    border-bottom: 1px solid var(--grid-line);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top;
    cursor: pointer;
    width: 100%;
}

.pub-item:hover {
    background: rgba(255, 85, 0, 0.02);
    padding-left: 2rem;
}

.pub-year {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: bold;
}

.pub-title {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 500;
    letter-spacing: -0.01em;
    position: relative;
    transition: color 0.3s ease;
}

.pub-item:hover .pub-title {
    color: var(--accent);
}

.pub-type {
    text-align: right;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.cite-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    font-weight: 800;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.pub-item:hover .cite-btn {
    opacity: 1;
    transform: translateX(0);
}

.pub-abstract {
    grid-column: 2 / -1;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    color: var(--gray);
    font-size: 1.1rem;
    line-height: 1.6;
}

.pub-item.active .pub-abstract {
    max-height: 500px;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* =========================================
   NETWORK GRAPH CONTAINER
========================================= */
#network-graph {
    width: 100%;
    height: 500px;
    border: 1px solid var(--grid-line);
    margin-bottom: 4rem;
    background: transparent;
}

/* =========================================
   6. FOOTER / CONTACT
========================================= */
#contact {
    background: var(--text);
    color: var(--bg);
    min-height: 80vh;
    transition: background-color var(--transition), color var(--transition);
}

#contact h2 {
    border-bottom-color: var(--bg);
}

.contact-link {
    font-size: clamp(2rem, 6vw, 7rem);
    color: var(--bg);
    text-decoration: none;
    display: block;
    margin-top: 2rem;
    transition: color 0.3s;
}

.contact-link:hover {
    color: var(--accent);
}

.toast {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: var(--accent);
    color: #fff;
    padding: 1rem 2rem;
    font-weight: bold;
    z-index: 10001;
    transform: translateY(200%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
    transform: translateY(0);
}

/* =========================================
   TOPOGRAPHICAL WIREFRAME
========================================= */
#hero-canvas {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.topo-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1;
    opacity: 0.2;
    transition: stroke var(--transition);
}

[data-theme="dark"] .topo-line {
    opacity: 0.4;
}

/* =========================================
   PROJECT DETAIL MODAL
========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* When modal is active, hide the mobile nav capsule to prevent overlap */
.modal-overlay.active ~ .mobile-nav-capsule {
    opacity: 0;
    pointer-events: none;
}

.modal-container {
    background: var(--bg);
    border: 4px solid var(--text);
    width: 95%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 4rem;
    transform: translateY(20px);
    transition: transform var(--transition);
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 2rem; right: 2rem;
    background: none;
    border: 2px solid var(--text);
    color: var(--text);
    font-size: 1.5rem;
    width: 50px; height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--text);
    color: var(--bg);
}

.modal-header span {
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.modal-header h2 {
    border: none;
    padding: 0;
    margin: 0.5rem 0;
    font-size: clamp(2rem, 5vw, 4rem);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
}

.modal-info h4 {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    color: var(--gray);
    font-size: 0.8rem;
}

.modal-info p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-tech-list {
    list-style: none;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.modal-tech-list li {
    background: var(--text);
    color: var(--bg);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

/* Contact Section Expansion */
.contact-wrapper {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 6rem;
    align-items: center;
    margin-top: 4rem;
    transition: all 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

#contact.expanded-profile .contact-wrapper {
    grid-template-columns: 1fr;
    gap: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

#contact.expanded-profile .contact-image {
    order: -1;
    max-width: 280px;
    margin: 0 auto 3rem auto;
    transform: scale(1.05); /* Subtle focus scale */
}

#contact.expanded-profile .contact-details {
    text-align: center;
}

#contact.expanded-profile .bio-intro {
    margin-left: auto;
    margin-right: auto;
    opacity: 0.7 !important; /* Soften the intro to focus on the story */
    transition: opacity 0.8s ease;
}

/* Accordion Styles */
.about-toggle {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--bg);
    padding: 0.8rem 1.5rem;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

#contact.expanded-profile .about-toggle {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    border: none;
}

.about-toggle:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--bg);
    opacity: 1 !important;
}

.about-accordion {
    max-height: 0;
    overflow: hidden;
    transition: max-height 1.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.about-accordion.active {
    max-height: 2500px; 
}

.accordion-content {
    padding-bottom: 4rem;
    margin-bottom: 4rem;
}

.accordion-content p {
    font-size: 1.15rem;
    line-height: 1.9;
    color: var(--bg);
    opacity: 0;
    transform: translateY(20px);
    margin-bottom: 2rem;
    text-align: left;
    transition: all 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Staggered Paragraph Entrance */
#contact.expanded-profile .accordion-content p {
    opacity: 0.85;
    transform: translateY(0);
}

#contact.expanded-profile .accordion-content p:nth-child(1) { transition-delay: 0.2s; }
#contact.expanded-profile .accordion-content p:nth-child(2) { transition-delay: 0.35s; }
#contact.expanded-profile .accordion-content p:nth-child(3) { transition-delay: 0.5s; }
#contact.expanded-profile .accordion-content p:nth-child(4) { transition-delay: 0.65s; }

#contact.expanded-profile .accordion-content p {
    text-align: justify;
}

/* CTA Section inside Accordion */
.cta-wrapper {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left; /* Align text content left */
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.cta-text {
    font-size: 1.2rem !important;
    font-weight: 500;
    margin-bottom: 1rem !important;
    opacity: 1 !important;
    color: var(--accent) !important;
}

.cta-sub {
    font-size: 1.8rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bg);
    line-height: 1.2;
    margin-bottom: 0;
}

.contact-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 4px solid var(--bg);
    overflow: hidden;
    position: relative;
    transition: all var(--transition);
}

.contact-image .base-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) contrast(1.1);
}

.contact-image .dither-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    filter: grayscale(1) url(#dither);
    clip-path: circle(0px at var(--mouse-x, 50%) var(--mouse-y, 50%));
    transition: clip-path 0.1s ease-out;
}

.contact-image:hover .dither-img {
    clip-path: circle(80px at var(--mouse-x, 50%) var(--mouse-y, 50%));
}

.contact-image:hover {
    border-color: var(--accent);
}

/* =========================================
   MOBILE CAPSULE NAV (Hidden on Desktop)
========================================= */
.mobile-nav-capsule {
    display: none;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1024px) {
    nav { padding: 1.5rem 2rem; }
    section { padding: 8rem 2rem 4rem 2rem; }
    #hero { padding-top: 12rem; }
    .pub-item { grid-template-columns: 60px 1fr 120px; }
    .modal-body { gap: 2rem; }
}

@media (max-width: 768px) {
    nav { 
        padding: 1rem 1.5rem; 
        flex-direction: row; 
        background: var(--bg);
        border-bottom: 1px solid var(--grid-line);
        justify-content: space-between; /* Left align name, right align toggle */
        align-items: center;
    }
    nav .nav-links { 
        display: flex; /* Show only theme toggle */
        gap: 0;
    }
    nav .nav-links a { display: none; } /* Hide text links */

    section { padding: 4rem 1.5rem 3rem 1.5rem; } /* Reduced mobile padding */
    #hero { padding-top: 10rem; }

    /* MOBILE CAPSULE NAV - Visible on Mobile */
    .mobile-nav-capsule {
        position: fixed;
        bottom: 2rem;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(15px);
        padding: 0.8rem 1.2rem;
        border-radius: 50px;
        display: flex; /* Show on mobile */
        gap: 1.2rem;
        z-index: 10000;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 15px 40px rgba(0,0,0,0.4);
        width: auto;
        white-space: nowrap;
        transition: opacity 0.3s ease;
    }

    .mobile-nav-capsule a {
        color: #fff;
        text-decoration: none;
        font-size: 0.65rem;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: 0.1em;
    }

    h1 { font-size: 3.2rem; margin-top: 4rem; }
    
    .pub-item { grid-template-columns: 1fr; gap: 0.5rem; padding: 2rem 1rem; }
    .pub-type { text-align: left; align-items: flex-start; }
    .pub-abstract { grid-column: 1 / -1; }
    
    .cursor-lens { display: none; }

    /* Modal Responsive */
    .modal-container {
        padding: 2.5rem 1.5rem;
        width: 95%;
        max-height: 95vh;
        border-width: 2px;
    }
    .modal-body {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .modal-header h2 {
        font-size: 1.8rem;
        line-height: 1.1;
    }
    .modal-info p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    .modal-close {
        top: 1rem; right: 1rem;
        width: 36px; height: 36px;
        font-size: 1rem;
    }
    
    .contact-wrapper {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    .contact-image {
        max-width: 260px;
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 2.8rem; }
    h2 { font-size: 2rem; }
}
