/* =========================================================
   LUCAS CAMPILLO — PORTFOLIO LAB v2
   Experimental · clean-tech / lab aesthetic
   ========================================================= */

/* ---------- TOKENS ---------- */
:root {
    --bg: #060609;
    --bg-soft: #0c0c12;
    --bg-card: #101019;
    --bg-elev: #15151f;
    --line: rgba(255,255,255,0.08);
    --line-strong: rgba(255,255,255,0.16);
    --text: #f4f4f8;
    --text-soft: #a0a0b0;
    --text-mute: #5a5a6a;
    --accent: #2997ff;
    --accent-2: #7c5cff;
    --accent-3: #00e0c6;
    --glow: rgba(41,151,255,0.4);
    --radius: 18px;
    --radius-lg: 26px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --font: 'Inter', system-ui, sans-serif;
    --font-display: 'Space Grotesk', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --nav-h: 72px;
}

[data-theme="light"] {
    --bg: #f6f6f4;
    --bg-soft: #efeff0;
    --bg-card: #ffffff;
    --bg-elev: #ffffff;
    --line: rgba(0,0,0,0.1);
    --line-strong: rgba(0,0,0,0.18);
    --text: #0a0a0f;
    --text-soft: #44444f;
    --text-mute: #8a8a96;
    --accent: #0071e3;
    --glow: rgba(0,113,227,0.25);
}

/* ---------- RESET ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    max-width: 100%;
    -webkit-font-smoothing: antialiased;
    transition: background 0.6s var(--ease), color 0.6s var(--ease);
}
@media (pointer: fine) { body { cursor: none; } }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent); color: #fff; }

/* ---------- BACKGROUND ---------- */
#bg-canvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
    opacity: 0.6;
}
.grain {
    position: fixed; inset: 0; z-index: 1;
    pointer-events: none; opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- PRELOADER ---------- */
.preloader {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.8s var(--ease), visibility 0.8s;
}
.preloader.done { opacity: 0; visibility: hidden; }
.preloader-inner { width: min(360px, 80vw); text-align: center; }
.preloader-logo {
    font-family: var(--font-display); font-weight: 700; font-size: 3rem;
    letter-spacing: -0.04em; color: var(--accent);
    margin-bottom: 28px;
    animation: pulse 1.4s var(--ease) infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.preloader-status {
    font-family: var(--font-mono); font-size: 0.75rem;
    color: var(--text-mute); margin-bottom: 14px; height: 1em;
}
.preloader-bar {
    height: 2px; background: var(--line); border-radius: 2px; overflow: hidden;
}
.preloader-bar-fill {
    height: 100%; width: 0%; background: var(--accent);
    box-shadow: 0 0 12px var(--glow); transition: width 0.2s linear;
}
.preloader-pct {
    font-family: var(--font-mono); font-size: 0.7rem;
    color: var(--text-soft); margin-top: 10px;
}

/* ---------- CUSTOM CURSOR ---------- */
.cursor-dot, .cursor-ring {
    position: fixed; top: 0; left: 0; z-index: 9998;
    pointer-events: none; border-radius: 50%;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
}
.cursor-dot { width: 6px; height: 6px; background: #fff; }
.cursor-ring {
    width: 36px; height: 36px; border: 1.5px solid #fff;
    transition: width 0.25s var(--ease), height 0.25s var(--ease), background 0.25s, border-color 0.25s;
}
.cursor-ring.hover { width: 56px; height: 56px; background: rgba(255,255,255,0.1); }
.cursor-ring.view {
    width: 80px; height: 80px; mix-blend-mode: normal;
    border-color: var(--accent); background: rgba(41,151,255,0.12);
}
.cursor-ring.view::after {
    content: 'VER'; font-family: var(--font-mono); font-size: 0.6rem;
    color: var(--accent); letter-spacing: 0.1em;
}
.cursor-ring { display: flex; align-items: center; justify-content: center; }
@media (pointer: coarse) { .cursor-dot, .cursor-ring { display: none; } }

/* ---------- SCROLL PROGRESS ---------- */
.scroll-progress {
    position: fixed; top: 0; left: 0; height: 2px; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    z-index: 9990; box-shadow: 0 0 10px var(--glow);
}

/* ---------- NAVBAR ---------- */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 40px; z-index: 900;
    transition: transform 0.4s var(--ease), background 0.4s, backdrop-filter 0.4s;
}
.navbar.scrolled {
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--line);
}
.navbar.hidden { transform: translateY(-100%); }
.nav-logo {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font-display); font-weight: 700; font-size: 1.3rem;
    letter-spacing: -0.03em;
}
.nav-logo-status {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent-3);
    box-shadow: 0 0 8px var(--accent-3); animation: pulse 2s infinite;
}
.nav-center { display: flex; gap: 4px; }
.nav-link {
    font-size: 0.9rem; color: var(--text-soft); padding: 8px 14px;
    border-radius: 10px; position: relative; transition: color 0.3s;
}
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-link.active::after {
    content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.nav-right { display: flex; align-items: center; gap: 10px; }
.cmdk-trigger {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card); border: 1px solid var(--line);
    color: var(--text-soft); padding: 8px 12px; border-radius: 10px;
    font-family: var(--font); font-size: 0.82rem; transition: all 0.3s;
}
.cmdk-trigger:hover { border-color: var(--line-strong); color: var(--text); }
.cmdk-trigger kbd, .cmdk kbd {
    font-family: var(--font-mono); font-size: 0.7rem;
    background: var(--bg-elev); border: 1px solid var(--line);
    padding: 2px 6px; border-radius: 5px; color: var(--text-mute);
}
.icon-btn {
    width: 38px; height: 38px; display: grid; place-items: center;
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: 10px; color: var(--text-soft); transition: all 0.3s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---------- COMMAND PALETTE ---------- */
.cmdk-overlay {
    position: fixed; inset: 0; z-index: 9995;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(6px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 14vh; opacity: 0; visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}
.cmdk-overlay.open { opacity: 1; visibility: visible; }
.cmdk {
    width: min(560px, 92vw); background: var(--bg-elev);
    border: 1px solid var(--line-strong); border-radius: 16px;
    overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.5);
    transform: scale(0.96) translateY(-10px); transition: transform 0.25s var(--ease);
}
.cmdk-overlay.open .cmdk { transform: scale(1) translateY(0); }
.cmdk-search {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--text-mute);
}
.cmdk-search input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-family: var(--font); font-size: 1rem;
}
.cmdk-list { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmdk-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 10px; cursor: pointer;
    color: var(--text-soft); transition: background 0.15s, color 0.15s;
}
.cmdk-item .cmdk-ico { color: var(--text-mute); display: flex; }
.cmdk-item.active { background: var(--accent); color: #fff; }
.cmdk-item.active .cmdk-ico { color: #fff; }
.cmdk-item-sub { margin-left: auto; font-size: 0.75rem; color: var(--text-mute); }
.cmdk-item.active .cmdk-item-sub { color: rgba(255,255,255,0.7); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-mute); font-size: 0.9rem; }
.cmdk-footer {
    display: flex; gap: 18px; padding: 12px 18px;
    border-top: 1px solid var(--line); font-size: 0.72rem; color: var(--text-mute);
}
.cmdk-footer kbd {
    margin-right: 3px; padding: 1px 5px; border-radius: 4px;
    background: var(--bg-card); border: 1px solid var(--line);
}

/* ---------- LAYOUT ---------- */
.section {
    position: relative; z-index: 2;
    max-width: 1200px; margin: 0 auto; padding: 120px 40px;
}
.section-head {
    display: flex; align-items: center; gap: 16px; margin-bottom: 56px;
}
.section-index {
    font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent);
}
.section-tag {
    font-family: var(--font-display); font-size: 1.1rem; font-weight: 500;
    color: var(--text-soft); position: relative; padding-left: 16px;
}
.section-tag::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 6px; height: 1px; background: var(--text-mute);
}

/* ---------- HERO ---------- */
.hero {
    position: relative; z-index: 2; min-height: 100vh;
    display: flex; flex-direction: column; justify-content: center;
    max-width: 1200px; margin: 0 auto; padding: var(--nav-h) 40px 0;
}
.spotlight-layer {
    position: fixed; top: 30%; left: 50%; width: 640px; height: 640px; border-radius: 50%;
    background: radial-gradient(circle, var(--glow) 0%, transparent 62%);
    pointer-events: none; opacity: 0.5; filter: blur(50px);
    transform: translate(-50%, -50%); z-index: 1; will-change: left, top, opacity;
}
.hero-badge {
    display: inline-flex; align-items: center; gap: 10px; align-self: flex-start;
    background: var(--bg-card); border: 1px solid var(--line);
    padding: 8px 16px; border-radius: 100px; font-size: 0.82rem;
    color: var(--text-soft); margin-bottom: 32px;
}
.hero-badge-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent-3);
    box-shadow: 0 0 8px var(--accent-3); animation: pulse 2s infinite;
}
.hero-badge-sep { color: var(--text-mute); }
.hero-clock { font-family: var(--font-mono); color: var(--text-mute); }
.hero-title {
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(3rem, 9vw, 7rem); line-height: 0.98;
    letter-spacing: -0.04em; margin-bottom: 24px;
}
.hero-title-line { display: block; }
.hero-title-muted { color: var(--text-mute); }
.scramble { display: inline-block; }
.hero-roles {
    font-family: var(--font-display); font-size: clamp(1.4rem, 3.2vw, 2.1rem);
    font-weight: 400; color: var(--text-soft); margin-bottom: 10px;
}
.hero-role-accent { color: var(--accent); font-weight: 600; }
.hero-cap {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    font-family: var(--font-display); font-size: clamp(1rem, 2.2vw, 1.35rem);
    font-weight: 400; margin-bottom: 28px;
}
.hero-cap-pre { color: var(--text-mute); }
.hero-role-rotator {
    position: relative; height: 1.3em; overflow: hidden; display: inline-block;
    min-width: 220px;
}
.hero-role-item {
    display: block; color: var(--accent); font-weight: 600;
}
.hero-desc {
    max-width: 560px; font-size: 1.1rem; color: var(--text-soft); margin-bottom: 40px;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 15px 26px; border-radius: 100px; font-size: 0.95rem; font-weight: 500;
    transition: transform 0.3s var(--ease), background 0.3s, border-color 0.3s, color 0.3s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 30px var(--glow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px var(--glow); }
.btn-ghost { background: var(--bg-card); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.hero-stats {
    display: flex; gap: 48px; margin-top: 72px; flex-wrap: wrap;
}
.hero-stat { display: flex; flex-direction: column; }
.hero-stat-num {
    font-family: var(--font-display); font-size: 2.6rem; font-weight: 600;
    line-height: 1; display: inline;
}
.hero-stat-plus { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent); }
.hero-stat-label { font-size: 0.8rem; color: var(--text-mute); margin-top: 8px; text-transform: uppercase; letter-spacing: 0.08em; }
.hero-scroll {
    position: absolute; bottom: 36px; right: 40px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-mute);
    text-transform: uppercase; letter-spacing: 0.15em;
}
@media (max-height: 760px), (max-width: 640px) { .hero-scroll { display: none; } }
.hero-scroll-line { width: 1px; height: 40px; background: linear-gradient(var(--text-mute), transparent); position: relative; overflow: hidden; }
.hero-scroll-line::after { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 50%; background: var(--accent); animation: scrolldown 2s var(--ease) infinite; }
@keyframes scrolldown { 0% { transform: translateY(-100%); } 100% { transform: translateY(200%); } }

/* ---------- MARQUEE ---------- */
.marquee {
    position: relative; z-index: 2; overflow: hidden;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    padding: 24px 0; background: var(--bg-soft);
}
.marquee-track {
    display: flex; gap: 32px; white-space: nowrap; width: max-content;
    animation: marquee 28s linear infinite;
    font-family: var(--font-display); font-size: 1.5rem; color: var(--text-soft);
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-dot { color: var(--accent); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- ABOUT ---------- */
.about-grid { display: grid; grid-template-columns: 380px 1fr; gap: 64px; align-items: start; }
.about-photo-wrap { position: relative; border-radius: var(--radius-lg); overflow: hidden; transform-style: preserve-3d; }
.about-photo { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: var(--radius-lg); }
.about-photo-frame { position: absolute; inset: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); pointer-events: none; }
.about-photo-tag {
    position: absolute; bottom: 16px; left: 16px;
    display: flex; align-items: center; gap: 8px;
    background: rgba(6,6,9,0.7); backdrop-filter: blur(10px);
    border: 1px solid var(--line); padding: 8px 14px; border-radius: 100px;
    font-family: var(--font-mono); font-size: 0.75rem; color: var(--text);
}
.about-photo-tag-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 6px var(--accent-3); }
.about-title { font-family: var(--font-display); font-size: clamp(1.6rem, 3.5vw, 2.6rem); font-weight: 500; line-height: 1.15; letter-spacing: -0.02em; margin-bottom: 28px; }
.about-title em { font-style: normal; color: var(--accent); }
.about-text p { color: var(--text-soft); margin-bottom: 20px; font-size: 1.05rem; }
.about-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 36px; }
.about-fact { padding: 18px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); }
.about-fact-label { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.about-fact-value { font-size: 0.9rem; color: var(--text); font-weight: 500; }

/* ---------- TIMELINE ---------- */
.timeline { position: relative; padding-left: 40px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.timeline-progress { position: absolute; left: 7px; top: 8px; width: 1px; background: linear-gradient(var(--accent), var(--accent-2)); height: 0; box-shadow: 0 0 8px var(--glow); }
.timeline-item { position: relative; padding-bottom: 48px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
    position: absolute; left: -40px; top: 6px; width: 15px; height: 15px;
    border-radius: 50%; background: var(--bg); border: 2px solid var(--line-strong);
    transition: border-color 0.4s, box-shadow 0.4s;
}
.timeline-item.in-view .timeline-marker { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.timeline-period { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); margin-bottom: 12px; }
.timeline-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; transition: border-color 0.3s, transform 0.3s; transform-style: preserve-3d; }
.timeline-card:hover { border-color: var(--line-strong); }
.timeline-card h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; margin-bottom: 6px; }
.timeline-org { display: block; font-size: 0.85rem; color: var(--accent); margin-bottom: 12px; }
.timeline-card p { color: var(--text-soft); font-size: 0.95rem; }

/* ---------- PROJECTS ---------- */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.pcard {
    position: relative; background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius-lg); overflow: hidden;
    transition: border-color 0.4s, transform 0.4s var(--ease);
    transform-style: preserve-3d;
}
.pcard-lg { grid-column: span 2; display: grid; grid-template-columns: 1.2fr 1fr; }
.pcard:hover { border-color: var(--line-strong); }
.pcard-media { overflow: hidden; background: var(--bg-soft); aspect-ratio: 16/10; }
.pcard-lg .pcard-media { aspect-ratio: auto; height: 100%; min-height: 320px; }
.pcard-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.pcard:hover .pcard-media img { transform: scale(1.06); }
.pcard-body { padding: 28px; display: flex; flex-direction: column; justify-content: center; }
.pcard-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.pcard-tags span { font-family: var(--font-mono); font-size: 0.7rem; color: var(--accent); background: var(--glow); padding: 4px 10px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pcard-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-bottom: 10px; }
.pcard-desc { color: var(--text-soft); font-size: 0.95rem; }
.pcard-num { position: absolute; top: 20px; right: 24px; font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-mute); z-index: 2; }

/* ---------- SKILLS ---------- */
.skills-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-soft); }
#skills-canvas { display: block; width: 100%; height: 480px; }
.skills-legend { position: absolute; bottom: 24px; left: 24px; right: 24px; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; pointer-events: none; }
.skills-hint { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-mute); }
.skills-cats { display: flex; gap: 8px; flex-wrap: wrap; pointer-events: auto; }
.skill-cat { background: var(--bg-card); border: 1px solid var(--line); color: var(--text-soft); padding: 7px 14px; border-radius: 100px; font-family: var(--font); font-size: 0.8rem; transition: all 0.3s; }
.skill-cat:hover { border-color: var(--line-strong); color: var(--text); }
.skill-cat.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- CONTACT ---------- */
.section-contact { text-align: center; }
.section-contact .section-head { justify-content: center; }
.contact-inner { padding: 40px 0 80px; }
.contact-title { font-family: var(--font-display); font-size: clamp(2.6rem, 8vw, 6rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1; margin-bottom: 24px; }
.contact-sub { max-width: 480px; margin: 0 auto 40px; color: var(--text-soft); font-size: 1.1rem; }
.contact-mail { display: inline-block; font-family: var(--font-display); font-size: clamp(1.1rem, 3vw, 1.8rem); color: var(--text); border-bottom: 1px solid var(--line-strong); padding-bottom: 6px; margin-bottom: 36px; transition: color 0.3s, border-color 0.3s; }
.contact-mail:hover { color: var(--accent); border-color: var(--accent); }
.contact-socials { display: flex; gap: 24px; justify-content: center; }
.contact-social { font-size: 0.95rem; color: var(--text-soft); transition: color 0.3s; }
.contact-social:hover { color: var(--accent); }
.footer { display: flex; align-items: center; justify-content: space-between; padding: 32px 0 0; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--text-mute); flex-wrap: wrap; gap: 12px; }
.footer-v { font-family: var(--font-mono); }
.footer-top { background: none; border: none; color: var(--text-soft); font-family: var(--font); font-size: 0.82rem; transition: color 0.3s; }
.footer-top:hover { color: var(--accent); }

/* ---------- REVEAL ANIMATION ---------- */
[data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out); }
[data-reveal].revealed { opacity: 1; transform: translateY(0); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
    .nav-center { display: none; }
    .cmdk-trigger span { display: none; }
    .about-grid { grid-template-columns: 1fr; gap: 40px; }
    .about-photo-wrap { max-width: 320px; }
    .projects { grid-template-columns: 1fr; }
    .pcard-lg { grid-column: span 1; grid-template-columns: 1fr; }
    .pcard-lg .pcard-media { min-height: 220px; }
    .section, .hero { padding-left: 24px; padding-right: 24px; }
    .navbar { padding: 0 20px; }
    .hero-stats { gap: 32px; }
}
@media (max-width: 540px) {
    .about-facts { grid-template-columns: 1fr; }
    .hero-stat-num { font-size: 2rem; }
    .footer { justify-content: center; text-align: center; }
}

/* =========================================================
   VIEW TRANSITIONS API
   ========================================================= */
@view-transition { navigation: auto; }

/* Cross-document page transition (root fade + subtle slide) */
::view-transition-old(root) {
    animation: vt-out 0.4s var(--ease) both;
}
::view-transition-new(root) {
    animation: vt-in 0.5s var(--ease) both;
}
@keyframes vt-out { to { opacity: 0; transform: translateY(-12px) scale(0.99); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(16px) scale(0.99); } }

/* Shared-element morph: project image -> detail hero */
.pcard-media img { view-transition-name: none; }
:root::view-transition-group(project-hero) { animation-duration: 0.6s; animation-timing-function: var(--ease); }

/* Theme toggle: circular reveal (same-document) */
html.theme-vt::view-transition-old(root) { animation: none; }
html.theme-vt::view-transition-new(root) {
    animation: theme-reveal 0.6s var(--ease) both;
    transform-origin: var(--vt-x, 90%) var(--vt-y, 6%);
}
@keyframes theme-reveal {
    from { clip-path: circle(0% at var(--vt-x, 90%) var(--vt-y, 6%)); }
    to   { clip-path: circle(150% at var(--vt-x, 90%) var(--vt-y, 6%)); }
}
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* =========================================================
   PROJECT DETAIL PAGE
   ========================================================= */
.detail-nav {
    position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 40px; z-index: 900;
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--line);
}
.detail-back {
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 0.9rem; color: var(--text-soft); transition: color 0.3s, gap 0.3s;
}
.detail-back:hover { color: var(--text); gap: 14px; }
.detail-counter { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-mute); }
.detail-hero {
    position: relative; z-index: 2; max-width: 1200px; margin: 0 auto;
    padding: calc(var(--nav-h) + 60px) 40px 0;
}
.detail-hero-img {
    width: 100%; aspect-ratio: 16/8; object-fit: cover;
    border-radius: var(--radius-lg); border: 1px solid var(--line);
    view-transition-name: project-hero;
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 20px; }
.detail-tags span {
    font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    padding: 5px 12px; border-radius: 7px;
}
.detail-title {
    font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin-bottom: 18px;
}
.detail-lead { max-width: 640px; font-size: 1.2rem; color: var(--text-soft); }
.detail-body {
    position: relative; z-index: 2; max-width: 1200px; margin: 0 auto;
    padding: 60px 40px 120px;
    display: grid; grid-template-columns: 260px 1fr; gap: 60px;
}
.detail-meta { position: sticky; top: 100px; align-self: start; display: flex; flex-direction: column; gap: 22px; }
.detail-meta-item { border-top: 1px solid var(--line); padding-top: 14px; }
.detail-meta-label { display: block; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.detail-meta-value { font-size: 0.95rem; color: var(--text); }
.detail-sections { display: flex; flex-direction: column; gap: 40px; }
.detail-block h3 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin-bottom: 14px; }
.detail-block p { color: var(--text-soft); font-size: 1.05rem; margin-bottom: 12px; }
.detail-block ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.detail-block li { color: var(--text-soft); padding-left: 24px; position: relative; }
.detail-block li::before { content: '→'; position: absolute; left: 0; color: var(--accent); }
.detail-cta { display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; padding: 14px 24px; border-radius: 100px; background: var(--accent); color: #fff; font-weight: 500; box-shadow: 0 8px 30px var(--glow); transition: transform 0.3s; }
.detail-cta:hover { transform: translateY(-2px); }
.detail-next {
    position: relative; z-index: 2; max-width: 1200px; margin: 0 auto; padding: 0 40px 100px;
}
.detail-next a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 40px; border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--bg-card); transition: border-color 0.3s, transform 0.3s;
}
.detail-next a:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.detail-next-label { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.1em; }
.detail-next-title { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; margin-top: 8px; }
.detail-next-arrow { font-size: 2rem; color: var(--accent); }
@media (max-width: 820px) {
    .detail-body { grid-template-columns: 1fr; gap: 32px; }
    .detail-meta { position: static; flex-direction: row; flex-wrap: wrap; gap: 16px; }
    .detail-meta-item { flex: 1; min-width: 130px; }
    .detail-nav, .detail-hero, .detail-body, .detail-next { padding-left: 24px; padding-right: 24px; }
}

/* =========================================================
   MOBILE MENU + TOUCH EQUIVALENCES
   ========================================================= */
.nav-burger {
    display: none; width: 38px; height: 38px;
    background: var(--bg-card); border: 1px solid var(--line); border-radius: 10px;
    position: relative; padding: 0;
}
.nav-burger span {
    position: absolute; left: 9px; right: 9px; height: 1.5px; background: var(--text);
    transition: transform 0.35s var(--ease), opacity 0.25s; border-radius: 2px;
}
.nav-burger span:nth-child(1) { top: 15px; }
.nav-burger span:nth-child(2) { top: 21px; }
.nav-burger.open span:nth-child(1) { transform: translateY(3px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { transform: translateY(-3px) rotate(-45deg); }

.mobile-menu {
    position: fixed; inset: 0; z-index: 850;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(24px) saturate(160%);
    display: flex; flex-direction: column; justify-content: center;
    padding: 0 32px; gap: 8px;
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity 0.4s var(--ease), visibility 0.4s, transform 0.4s var(--ease);
}
.mobile-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.mobile-link {
    display: flex; align-items: baseline; gap: 18px;
    font-family: var(--font-display); font-size: 2.4rem; font-weight: 600;
    letter-spacing: -0.02em; color: var(--text); padding: 8px 0;
    border-bottom: 1px solid var(--line);
    opacity: 0; transform: translateX(-20px);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), color 0.3s;
}
.mobile-menu.open .mobile-link { opacity: 1; transform: translateX(0); }
.mobile-menu.open .mobile-link[data-i="0"] { transition-delay: 0.08s; }
.mobile-menu.open .mobile-link[data-i="1"] { transition-delay: 0.14s; }
.mobile-menu.open .mobile-link[data-i="2"] { transition-delay: 0.20s; }
.mobile-menu.open .mobile-link[data-i="3"] { transition-delay: 0.26s; }
.mobile-menu.open .mobile-link[data-i="4"] { transition-delay: 0.32s; }
.mobile-link:active { color: var(--accent); }
.mobile-link-idx { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); }
.mobile-menu-foot {
    display: flex; gap: 24px; margin-top: 36px;
    opacity: 0; transition: opacity 0.5s var(--ease) 0.4s;
}
.mobile-menu.open .mobile-menu-foot { opacity: 1; }
.mobile-menu-foot a { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-soft); }

/* Touch / small screens: hide custom cursor, show burger, touch feedback */
@media (max-width: 900px), (pointer: coarse) {
    body { cursor: auto; }
    .cursor-dot, .cursor-ring { display: none !important; }
    .nav-burger { display: block; }
    .cmdk-trigger kbd { display: none; }
    .spotlight-layer { opacity: 0.35; }
    /* tap feedback replacing tilt/hover */
    .pcard:active { transform: scale(0.985); transition: transform 0.15s var(--ease); }
    .timeline-card:active { border-color: var(--accent); }
    .btn:active { transform: scale(0.97); }
}

/* Constelación: más alto en móvil y leyenda apilada */
@media (max-width: 560px) {
    #skills-canvas { height: 560px; }
    .skills-legend { flex-direction: column; align-items: stretch; gap: 12px; }
    .skills-cats { justify-content: center; }
    .hero-stats { gap: 24px 32px; }
    .marquee-track { font-size: 1.2rem; gap: 22px; }
}
