/* ============================================
   lossless.dev - Dark Neon Graffiti Portfolio
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --void: #0A0A0F;
    --surface: #12121A;
    --surface-hover: #1A1A28;
    --neon-magenta: #E839F6;
    --neon-cyan: #00F0FF;
    --neon-chartreuse: #B8FF00;
    --dim-text: #8A8A9E;
    --bright-text: #E8E8F0;
    --glow-haze: rgba(232, 57, 246, 0.15);
    --nav-width: 56px;
    --font-recursive: 'Recursive', sans-serif;
    --font-nabla: 'Nabla', system-ui;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background: var(--void);
}

body {
    font-family: var(--font-recursive);
    font-variation-settings: 'MONO' 0, 'CASL' 0, 'wght' 400, 'slnt' 0, 'CRSV' 0;
    background: var(--void);
    color: var(--dim-text);
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.7;
    overflow-x: hidden;
    padding-left: var(--nav-width);
}

/* --- Anamorphic Streak --- */
.anamorphic-streak {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100vw;
    height: 2px;
    z-index: 10;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(0, 240, 255, 0.06) 30%,
        rgba(232, 57, 246, 0.08) 50%,
        rgba(0, 240, 255, 0.06) 70%,
        transparent 100%
    );
    box-shadow:
        0 0 40px 20px rgba(232, 57, 246, 0.03),
        0 0 80px 40px rgba(0, 240, 255, 0.02);
    transform: translateY(0);
    will-change: transform;
}

/* --- Side Navigation --- */
.side-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-width);
    height: 100vh;
    background: var(--void);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    z-index: 100;
    border-right: 1px solid rgba(232, 57, 246, 0.1);
}

.nav-label {
    font-family: var(--font-recursive);
    font-variation-settings: 'MONO' 1, 'CASL' 0, 'wght' 300, 'slnt' 0;
    font-size: 11px;
    color: var(--neon-magenta);
    text-decoration: none;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    padding: 0.5rem 0;
}

.nav-label:hover {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.nav-label.active {
    color: var(--bright-text);
    text-shadow: 0 0 8px rgba(232, 57, 246, 0.4);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--void);
}

.hero-light {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.05) 40%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
}

.hero-light.active {
    animation: irisOpen 800ms 300ms ease-out forwards;
}

@keyframes irisOpen {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        width: 400px;
        height: 400px;
        opacity: 1;
    }
}

/* Neon refraction flares */
.hero-flare {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    filter: blur(40px);
    transform: translate(-50%, -50%);
}

.hero-flare--magenta {
    background: var(--neon-magenta);
}

.hero-flare--cyan {
    background: var(--neon-cyan);
}

.hero-flare--chartreuse {
    background: var(--neon-chartreuse);
}

.hero-flare.refract {
    animation: refract 1000ms 1100ms ease-out forwards;
}

.hero-flare--magenta.refract {
    --tx: -120px;
    --ty: 20px;
}

.hero-flare--cyan.refract {
    --tx: 120px;
    --ty: 10px;
}

.hero-flare--chartreuse.refract {
    --tx: 0px;
    --ty: -100px;
    width: 80px;
    height: 80px;
}

@keyframes refract {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0) scale(0.3);
    }
    50% {
        opacity: 0.25;
    }
    100% {
        opacity: 0.12;
        transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(1);
    }
}

/* Spiral Tag */
.spiral-tag {
    position: absolute;
    width: 500px;
    height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    pointer-events: none;
}

.spiral-tag path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.spiral-tag.draw path {
    animation: drawSpiral 3s 600ms ease-out forwards;
}

@keyframes drawSpiral {
    to {
        stroke-dashoffset: 0;
    }
}

/* Hero Wordmark */
.hero-wordmark {
    font-family: var(--font-nabla);
    font-size: clamp(4rem, 10vw, 8rem);
    color: var(--neon-magenta);
    position: relative;
    z-index: 5;
    display: flex;
    letter-spacing: -0.02em;
}

.hero-letter {
    display: inline-block;
    opacity: 0;
}

.hero-letter.visible {
    animation: materialize 600ms ease-out forwards;
    animation-delay: calc(var(--i) * 80ms + 500ms);
}

@keyframes materialize {
    0% {
        opacity: 0;
        filter: blur(8px);
    }
    60% {
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
    }
}

/* --- Portfolio Grid --- */
.portfolio {
    position: relative;
    width: 100%;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 0 2px;
    background: transparent;
}

.grid-cell {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--surface);
    overflow: hidden;
    cursor: default;
    transition: background 200ms ease;
    opacity: 0;
    transform: translateY(20px);
}

.grid-cell.revealed {
    transition: background 200ms ease, opacity 400ms ease, transform 400ms ease;
    opacity: 1;
    transform: translateY(0);
}

.grid-cell.revealed-up {
    transition: background 200ms ease, opacity 400ms ease, transform 400ms ease;
    opacity: 1;
    transform: translateY(0);
}

.grid-cell:nth-child(even) {
    transform: translateY(-10px);
}

.grid-cell:nth-child(even).revealed,
.grid-cell:nth-child(even).revealed-up {
    transform: translateY(0);
}

.grid-cell--span2 {
    grid-column: span 2;
}

/* Grid gap glow effect */
.grid {
    position: relative;
}

.grid::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        repeating-linear-gradient(
            to right,
            transparent,
            transparent calc(33.333% - 1px),
            var(--neon-magenta) calc(33.333% - 1px),
            var(--neon-magenta) calc(33.333% + 1px),
            transparent calc(33.333% + 1px)
        );
    opacity: 0.15;
    mix-blend-mode: screen;
}

/* Cell flare pseudo-elements */
.cell-flare {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    transition: transform 300ms ease, opacity 300ms ease;
}

[data-color="magenta"] .cell-flare {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(232, 57, 246, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(232, 57, 246, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 20%, rgba(232, 57, 246, 0.06) 0%, transparent 60%);
}

[data-color="cyan"] .cell-flare {
    background:
        radial-gradient(ellipse at 60% 30%, rgba(0, 240, 255, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 70%, rgba(0, 240, 255, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 50%, rgba(0, 240, 255, 0.06) 0%, transparent 60%);
}

[data-color="chartreuse"] .cell-flare {
    background:
        radial-gradient(ellipse at 40% 60%, rgba(184, 255, 0, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 30%, rgba(184, 255, 0, 0.07) 0%, transparent 40%),
        radial-gradient(ellipse at 20% 40%, rgba(184, 255, 0, 0.05) 0%, transparent 60%);
}

/* Cell content */
.cell-content {
    position: relative;
    z-index: 2;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.cell-label {
    font-family: var(--font-recursive);
    font-variation-settings: 'MONO' 1, 'CASL' 0, 'wght' 300, 'slnt' 0;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--dim-text);
    margin-bottom: 0.75rem;
}

.cell-heading {
    font-family: var(--font-recursive);
    font-variation-settings: 'MONO' 0, 'CASL' 0.3, 'wght' 800, 'slnt' -4;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--bright-text);
    line-height: 1.1;
    margin-bottom: 0.5rem;
    transition: font-variation-settings 300ms ease;
    --casl: 0.3;
}

.cell-text {
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--dim-text);
    line-height: 1.6;
    max-width: 40ch;
}

/* Hover states */
.grid-cell:hover {
    background: var(--surface-hover);
}

[data-color="magenta"]:hover {
    box-shadow: inset 0 0 0 1px var(--neon-magenta);
}

[data-color="cyan"]:hover {
    box-shadow: inset 0 0 0 1px var(--neon-cyan);
}

[data-color="chartreuse"]:hover {
    box-shadow: inset 0 0 0 1px var(--neon-chartreuse);
}

.grid-cell:hover .cell-flare {
    transform: scale(1.2);
    opacity: 0.9;
}

.grid-cell:hover .cell-heading {
    font-variation-settings: 'MONO' 0, 'CASL' 1, 'wght' 800, 'slnt' -4;
}

/* --- Mural Strip --- */
.mural-strip {
    width: 100%;
    height: 40vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--void);
}

.sine-wave {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.sine-path {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    opacity: 0.6;
}

.sine-path.draw {
    animation: drawSine 2s ease-out forwards;
}

@keyframes drawSine {
    to {
        stroke-dashoffset: 0;
    }
}

/* Sine wave breathing animation */
.sine-path.breathing {
    animation: breatheCurve 20s ease-in-out infinite;
}

@keyframes breatheCurve {
    0%, 100% {
        d: path("M0,80 C180,20 360,140 540,80 C720,20 900,140 1080,80 C1260,20 1440,140 1440,80");
    }
    50% {
        d: path("M0,80 C180,120 360,40 540,80 C720,120 900,40 1080,80 C1260,120 1440,40 1440,80");
    }
}

/* --- Ghost Footer --- */
.ghost-footer {
    position: relative;
    width: 100%;
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--void);
}

.ribbon-weave {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0.4;
}

.ribbon-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
}

.ribbon-path.draw {
    animation: drawRibbon 3s ease-out forwards;
}

@keyframes drawRibbon {
    to {
        stroke-dashoffset: 0;
    }
}

.ribbon-path--magenta {
    opacity: 0.8;
}

.ribbon-path--chartreuse {
    opacity: 0.6;
}

.ghost-wordmark {
    font-family: var(--font-recursive);
    font-variation-settings: 'MONO' 0, 'CASL' 0.7, 'wght' 900, 'slnt' 0;
    font-size: clamp(6rem, 15vw, 14rem);
    color: var(--bright-text);
    position: relative;
    z-index: 2;
    animation: ghostPulse 6s ease-in-out infinite;
    user-select: none;
}

@keyframes ghostPulse {
    0%, 100% {
        opacity: 0.04;
    }
    50% {
        opacity: 0.08;
    }
}

/* --- Starburst Nodes --- */
.starburst-container {
    position: fixed;
    top: 0;
    left: var(--nav-width);
    width: calc(100vw - var(--nav-width));
    height: 100vh;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.starburst {
    position: absolute;
    width: 8px;
    height: 8px;
    clip-path: polygon(
        50% 0%, 62% 38%, 100% 50%, 62% 62%,
        50% 100%, 38% 62%, 0% 50%, 38% 38%
    );
    background: var(--neon-magenta);
    opacity: 0;
    box-shadow: 0 0 6px 3px var(--glow-haze);
}

.starburst.pulse {
    animation: starPulse var(--duration) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes starPulse {
    0%, 100% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 0.6;
        transform: scale(1);
    }
}

/* --- Responsive --- */
@media (max-width: 1023px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cell--span2 {
        grid-column: span 2;
    }
}

@media (max-width: 767px) {
    :root {
        --nav-width: 0px;
    }

    .side-nav {
        display: none;
    }

    body {
        padding-left: 0;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .grid-cell--span2 {
        grid-column: span 1;
    }

    .hero-wordmark {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .ghost-wordmark {
        font-size: clamp(3rem, 15vw, 6rem);
    }

    .mural-strip {
        height: 25vh;
    }
}

/* --- Grid gap glow intensity variable --- */
.grid {
    --gap-glow: 4px;
}

.grid::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    box-shadow: inset 0 0 var(--gap-glow) 0 var(--glow-haze);
    opacity: 0.3;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .hero-light.active {
        opacity: 1;
        width: 400px;
        height: 400px;
    }

    .hero-letter.visible {
        opacity: 1;
    }

    .hero-flare.refract {
        opacity: 0.12;
    }

    .grid-cell {
        opacity: 1;
        transform: none;
    }

    .ghost-wordmark {
        opacity: 0.06;
    }

    .starburst.pulse {
        opacity: 0.3;
    }
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--void);
}

::-webkit-scrollbar-thumb {
    background: rgba(232, 57, 246, 0.3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 57, 246, 0.5);
}

/* Selection color */
::selection {
    background: rgba(232, 57, 246, 0.3);
    color: var(--bright-text);
}
