/* ─── Variables & Reset ───────────────────────────────────────────────────────── */
:root {
    --bg-color: #020205;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --accent: #1a1a2e;
    --font-sans: "Inter", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    cursor: none;
}

body.showcase-body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ─── Opening Overlay (GSAP controls animation, CSS just sets base state) ─────── */
.opening-overlay {
    position: fixed;
    inset: 0;
    background: #ffffff;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    will-change: transform, opacity;
}

/* ─── Custom Cursor ───────────────────────────────────────────────────────────── */
#cursor {
    position: fixed;
    width: 18px;
    height: 18px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(140, 180, 255, 0.55);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    will-change: transform;
    box-shadow:
        0 0 12px rgba(100, 150, 255, 0.4),
        0 0 28px rgba(100, 150, 255, 0.15),
        inset 0 0 6px rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px) contrast(1.4);
    transition:
        box-shadow 0.3s ease,
        border-color 0.3s ease,
        background 0.3s ease;
}

#cursor.hover {
    background: rgba(0, 0, 0, 0.92);
    border-color: rgba(160, 200, 255, 0.8);
    box-shadow:
        0 0 20px rgba(120, 170, 255, 0.6),
        0 0 50px rgba(100, 150, 255, 0.25),
        inset 0 0 10px rgba(255, 255, 255, 0.2);
}

/* ─── WebGL Background Canvas ─────────────────────────────────────────────────── */
#bg-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.85;
}

/* ─── Navigation ──────────────────────────────────────────────────────────────── */
.showcase-nav {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 50;
    will-change: transform, opacity;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition:
        color 0.3s ease,
        gap 0.3s ease;
}

.back-link:hover {
    color: var(--text-primary);
    gap: 0.75rem;
}

/* ─── Main Layout ─────────────────────────────────────────────────────────────── */
.showcase-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 25vh 2rem 15vh;
}

/* ─── Header / Glitch / Scramble ──────────────────────────────────────────────── */
.showcase-header {
    margin-bottom: 10rem;
    text-align: left;
    will-change: transform, opacity;
}

.glitch-text {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    position: relative;
    display: inline-block;
    color: #fff;
    text-transform: uppercase;
}

/* RGB Glitch on hover via pseudo-elements */
.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    clip: rect(0, 0, 0, 0);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glitch-text:hover::before,
.glitch-text:hover::after {
    opacity: 1;
}

.glitch-text::before {
    left: 2px;
    text-shadow: -2px 0 #ff00c1;
    animation: glitch-1 2s infinite linear alternate-reverse;
}

.glitch-text::after {
    left: -2px;
    text-shadow: -2px 0 #00fff9;
    animation: glitch-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0% {
        clip: rect(20px, 9999px, 85px, 0);
    }
    20% {
        clip: rect(92px, 9999px, 8px, 0);
    }
    40% {
        clip: rect(43px, 9999px, 66px, 0);
    }
    60% {
        clip: rect(10px, 9999px, 14px, 0);
    }
    80% {
        clip: rect(78px, 9999px, 5px, 0);
    }
    100% {
        clip: rect(54px, 9999px, 32px, 0);
    }
}

@keyframes glitch-2 {
    0% {
        clip: rect(12px, 9999px, 90px, 0);
    }
    20% {
        clip: rect(23px, 9999px, 67px, 0);
    }
    40% {
        clip: rect(74px, 9999px, 14px, 0);
    }
    60% {
        clip: rect(45px, 9999px, 88px, 0);
    }
    80% {
        clip: rect(89px, 9999px, 2px, 0);
    }
    100% {
        clip: rect(32px, 9999px, 55px, 0);
    }
}

.scramble-text {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 1.5rem;
    min-height: 1.5em;
    letter-spacing: 0.1em;
}

/* ─── Lab Sections ────────────────────────────────────────────────────────────── */
.lab-section {
    margin-bottom: 12rem;
    will-change: transform, opacity;
}

.section-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

/* ─── 01 / Glow Cards ─────────────────────────────────────────────────────────── */
.glow-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
}

.glow-card {
    position: relative;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

/* Mouse-tracked radial glow via CSS custom properties set by JS */
.glow-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        700px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(255, 255, 255, 0.09),
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 0;
    pointer-events: none;
}

.glow-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.glow-card:hover::before {
    opacity: 1;
}

.glow-card-content {
    position: relative;
    z-index: 1;
    background: #050508;
    margin: 1px;
    height: calc(100% - 2px);
    padding: 3.5rem 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    will-change: transform;
}

.icon-svg {
    margin-bottom: 2rem;
    opacity: 0.65;
    transition: opacity 0.3s ease;
}

.glow-card:hover .icon-svg {
    opacity: 1;
}

.glow-card-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.glow-card-content p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.65;
}

/* ─── Magnetic Wrapper ────────────────────────────────────────────────────────── */
.magnetic {
    will-change: transform;
}

/* ─── 02 / 3D Tilt Cards ──────────────────────────────────────────────────────── */
.tilt-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 4rem;
}

.tilt-card-wrapper {
    perspective: 2000px;
}

.tilt-card {
    position: relative;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 4rem 3rem;
    height: 450px;
    transform-style: preserve-3d;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.85);
    overflow: hidden;
    will-change: transform;
    transition: box-shadow 0.4s ease;
}

.tilt-card:hover {
    box-shadow:
        0 40px 80px rgba(0, 0, 0, 0.9),
        0 0 60px rgba(100, 140, 255, 0.06);
}

.tilt-card-content {
    transform: translateZ(80px);
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.tilt-chip {
    align-self: flex-start;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: auto;
}

.tilt-card-content h3 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: -0.02em;
}

.tilt-card-content p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* Glare layer — position is set via CSS vars from JS */
.tilt-card-glare {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at var(--glare-x, 50%) var(--glare-y, 50%),
        rgba(255, 255, 255, 0.14) 0%,
        transparent 60%
    );
    pointer-events: none;
    z-index: 1;
    transform: translateZ(1px);
}

/* ─── 03 / Quantum Motion Grid ────────────────────────────────────────────────── */
.quantum-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
}

.quantum-card {
    position: relative;
    height: 250px;
    background: #050508;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 40px;
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

.quantum-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Dot-grid texture */
.quantum-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(
        circle at 2px 2px,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 0
    );
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 1;
}

/* CRT scanline overlay */
.quantum-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.08) 50%),
        linear-gradient(
            90deg,
            rgba(255, 0, 0, 0.018),
            rgba(0, 255, 0, 0.009),
            rgba(0, 0, 255, 0.018)
        );
    background-size:
        100% 2px,
        3px 100%;
    pointer-events: none;
    z-index: 2;
}

.quantum-card-content {
    position: relative;
    z-index: 10;
    will-change: transform;
}

.quantum-tag {
    font-size: 10px;
    color: #4ade80;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.quantum-card h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.quantum-card p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 250px;
    line-height: 1.55;
}

/* ─── Neural Flow Canvas ──────────────────────────────────────────────────────── */
#flow-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.45;
    pointer-events: none;
}

/* ─── Phase Shift Card ────────────────────────────────────────────────────────── */
.shift-card::before {
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(140, 180, 255, 0.04) 1px,
        rgba(140, 180, 255, 0.04) 2px
    );
    background-size: 100% 4px;
    animation: scanline 12s linear infinite;
}

@keyframes scanline {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 0 100%;
    }
}

.shift-layers {
    position: relative;
    font-size: 26px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
    will-change: transform;
}

.shift-layers span {
    display: block;
}

.shift-r,
.shift-b {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition:
        transform 0.22s ease,
        opacity 0.22s ease;
}

.shift-r {
    color: #f0f;
    mix-blend-mode: screen;
}
.shift-b {
    color: #0ff;
    mix-blend-mode: screen;
}

.shift-card:hover .shift-r {
    opacity: 0.85;
    transform: translate(4px, -2px);
}
.shift-card:hover .shift-b {
    opacity: 0.85;
    transform: translate(-4px, 2px);
}

/* ─── Liquid Surface Card ─────────────────────────────────────────────────────── */
.liquid-box {
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, #1a1a2e, #16213e);
    opacity: 0.3;
    transition: opacity 0.4s ease;
}

.liquid-card:hover .liquid-box {
    opacity: 0.5;
    filter: url(#liquid-filter);
    animation: liquid-pan 6s infinite linear;
}

@keyframes liquid-pan {
    from {
        background-position: 0% 0%;
    }
    to {
        background-position: 100% 100%;
    }
}

/* ─── Mirror Rift Card ────────────────────────────────────────────────────────── */
.mirror-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0%,
        transparent 50%,
        rgba(255, 255, 255, 0.02) 100%
    );
    transition: opacity 0.35s ease;
}

/* Rotating conic gradient on hover — z-index sits behind quantum-card::after */
.mirror-card::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
        from 180deg at 50% 50%,
        rgba(140, 180, 255, 0.06) 0deg,
        transparent 90deg,
        rgba(140, 180, 255, 0.06) 180deg,
        transparent 270deg
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 3;
}

.mirror-card:hover::after {
    opacity: 1;
    animation: rotate-mirror 5s infinite linear;
}

@keyframes rotate-mirror {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ─── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .quantum-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    /* Fix tilt card grid — minmax(380px) causes horizontal overflow */
    .tilt-cards-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .tilt-card {
        height: 360px;
        padding: 3rem 2rem;
    }
    .tilt-card-content h3 {
        font-size: 2rem;
    }

    /* Fix glow card grid */
    .glow-cards-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 640px) {
    body.showcase-body {
        overflow-x: hidden;
    }

    .showcase-container {
        padding: 18vh 1.25rem 8vh;
    }

    .showcase-nav {
        top: 1.25rem;
        left: 1.25rem;
    }

    .back-link {
        font-size: 0.82rem;
    }

    .glitch-text {
        font-size: clamp(2.6rem, 13vw, 4rem);
        letter-spacing: -0.03em;
    }

    .scramble-text {
        font-size: 0.82rem;
        letter-spacing: 0.07em;
    }

    .showcase-header {
        margin-bottom: 7rem;
    }

    .lab-section {
        margin-bottom: 7rem;
    }

    .section-title {
        margin-bottom: 2.5rem;
        letter-spacing: 0.2em;
    }

    .glow-card-content {
        padding: 2.5rem 1.75rem;
    }

    .tilt-card {
        height: 320px;
        padding: 2.5rem 1.75rem;
    }

    .tilt-card-content h3 {
        font-size: 1.75rem;
    }

    .tilt-card-content p {
        font-size: 0.9rem;
    }

    .quantum-card {
        height: 200px;
        padding: 28px;
    }

    .quantum-card h3 {
        font-size: 18px;
    }

    .quantum-card p {
        font-size: 13px;
    }

    .shift-layers {
        font-size: 22px;
    }
}

/* ─── Cursor Trail ────────────────────────────────────────────────────────────── */
.cursor-trail {
    position: fixed;
    width: 5px;
    height: 5px;
    background: rgba(140, 180, 255, 0.7);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9997;
    will-change: transform, opacity, width, height;
    filter: blur(0.5px);
    box-shadow: 0 0 4px rgba(140, 180, 255, 0.5);
}

/* Hide trail on touch/mobile */
@media (hover: none) and (pointer: coarse) {
    .cursor-trail,
    #cursor {
        display: none;
    }
    * {
        cursor: auto !important;
    }
}

/* ─── 04 / Warp Engine Section ────────────────────────────────────────────────── */
.warp-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
}

.warp-card {
    position: relative;
    height: 260px;
    background: #050508;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

.warp-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.warp-card-content {
    position: relative;
    z-index: 10;
    padding: 28px 32px;
    margin-top: auto;
}

.warp-card-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.warp-card-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
    max-width: 260px;
}

.warp-tag {
    font-size: 9px;
    color: #4ade80;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 6px;
    font-family: var(--font-mono);
}

/* Warp Drive card */
.hyper-card {
    background: #010103;
}

#warp-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.9;
}

/* Holographic card */
.holo-card {
    cursor: none;
    background: linear-gradient(135deg, #0a0a12, #0d0d1a);
    transform-style: preserve-3d;
}

.holo-layers {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.holo-base {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 0, 128, 0.04),
        rgba(0, 255, 200, 0.04),
        rgba(100, 0, 255, 0.04)
    );
}

.holo-shine {
    position: absolute;
    inset: 0;
    background: conic-gradient(
        from var(--holo-angle, 0deg) at var(--holo-x, 50%) var(--holo-y, 50%),
        rgba(255, 0, 128, 0.5) 0deg,
        rgba(255, 140, 0, 0.5) 45deg,
        rgba(255, 237, 0, 0.5) 90deg,
        rgba(0, 255, 128, 0.5) 135deg,
        rgba(0, 192, 255, 0.5) 180deg,
        rgba(128, 0, 255, 0.5) 225deg,
        rgba(255, 0, 128, 0.5) 270deg,
        transparent 315deg
    );
    opacity: 0;
    mix-blend-mode: screen;
    transition: opacity 0.4s ease;
    will-change: opacity;
}

.holo-card:hover .holo-shine {
    opacity: 0.35;
}

.holo-glare {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        circle at var(--holo-x, 50%) var(--holo-y, 50%),
        rgba(255, 255, 255, 0.12) 0%,
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.holo-card:hover .holo-glare {
    opacity: 1;
}

/* Terminal card */
.terminal-card {
    background: #020204;
    display: flex;
    flex-direction: column;
}

.terminal-chrome {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.t-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
}

.t-dot:nth-child(1) {
    background: #ff5f57;
}
.t-dot:nth-child(2) {
    background: #febc2e;
}
.t-dot:nth-child(3) {
    background: #28c840;
}

.t-title {
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 0.5rem;
}

.terminal-body {
    flex: 1;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.65;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.75);
}

.term-line {
    margin: 0;
    white-space: pre;
    overflow: hidden;
    text-overflow: clip;
}

.term-cmd {
    color: #7dd3fc;
}
.term-success {
    color: #4ade80;
}
.term-dim {
    color: rgba(255, 255, 255, 0.35);
}
.term-cursor {
    display: inline-block;
    width: 7px;
    height: 13px;
    background: rgba(255, 255, 255, 0.8);
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* Void (Singularity) card */
.void-card {
    background: #010102;
}

#void-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.85;
}

/* Responsive warp grid */
@media (max-width: 760px) {
    .warp-grid {
        grid-template-columns: 1fr;
    }
    .warp-card {
        height: 230px;
    }
}

@media (max-width: 640px) {
    .warp-card {
        height: 200px;
    }
    .warp-card-content {
        padding: 20px 22px;
    }
    .warp-card-content h3 {
        font-size: 17px;
    }
}
