/* ============================================
   relativity.studio - Styles
   Aesthetic: Editorial | Palette: Dark-Neon
   Typography: Bebas Neue + Work Sans + Space Mono
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-void: #0a0a1a;
    --abyss: #050510;
    --neon-cyan: #00fff5;
    --hot-magenta: #ff2d95;
    --ultraviolet: #7b2dff;
    --bubble-interior: #e0fffc;
    --steel-text: #c8d0e0;
    --fog: #3a3e5c;
    --card-bg: #0a0a12;
    --card-bg-hover: #0d0d20;
    --scroll-speed: 1;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep-void);
    background-image: radial-gradient(ellipse at 50% 50%, var(--deep-void) 0%, var(--abyss) 100%);
    color: var(--steel-text);
    font-family: 'Work Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.875rem, 1.1vw, 1.05rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Bubble Container (Fixed Background) --- */
#bubble-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--neon-cyan);
    background: rgba(224, 255, 252, 0.1);
    box-shadow: 0 0 8px rgba(0, 255, 245, 0.15), 0 0 20px rgba(0, 255, 245, 0.05);
    will-change: transform;
    contain: layout style;
    animation: bubbleRise var(--bubble-duration, 14s) linear infinite;
    animation-delay: var(--bubble-delay, 0s);
}

.bubble::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.bubble-pulse {
    animation: bubbleRise var(--bubble-duration, 14s) linear infinite,
               bubblePulse var(--pulse-duration, 5s) ease-in-out infinite;
    animation-delay: var(--bubble-delay, 0s), var(--pulse-delay, 0s);
}

@keyframes bubbleRise {
    0% {
        transform: translateY(110vh) translateX(var(--drift-start, 0px));
        opacity: 0;
    }
    5% {
        opacity: var(--bubble-opacity, 0.6);
    }
    50% {
        transform: translateY(50vh) translateX(var(--drift-mid, 15px));
    }
    95% {
        opacity: var(--bubble-opacity, 0.6);
    }
    100% {
        transform: translateY(-10vh) translateX(var(--drift-end, -10px));
        opacity: 0;
    }
}

@keyframes bubblePulse {
    0%, 100% { transform: scale(0.97); }
    50% { transform: scale(1.03); }
}

/* Footer bubbles sink instead of rise */
.bubble-sink {
    animation: bubbleSink var(--bubble-duration, 14s) linear infinite;
    animation-delay: var(--bubble-delay, 0s);
}

@keyframes bubbleSink {
    0% {
        transform: translateY(-10vh) translateX(var(--drift-start, 0px));
        opacity: 0;
    }
    5% {
        opacity: var(--bubble-opacity, 0.6);
    }
    50% {
        transform: translateY(50vh) translateX(var(--drift-mid, 15px));
    }
    95% {
        opacity: var(--bubble-opacity, 0.6);
    }
    100% {
        transform: translateY(110vh) translateX(var(--drift-end, -10px));
        opacity: 0;
    }
}

/* --- Refraction Lines --- */
#refraction-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.2;
}

#refraction-lines line {
    stroke: var(--fog);
    stroke-width: 1;
}

/* --- Masthead --- */
#masthead {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    z-index: 2;
    overflow: hidden;
}

.masthead-bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 66%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.masthead-bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--neon-cyan);
    background: rgba(224, 255, 252, 0.1);
    box-shadow: 0 0 8px rgba(0, 255, 245, 0.15), 0 0 20px rgba(0, 255, 245, 0.05);
    opacity: 0;
    animation: mastheadBubbleFadeIn 400ms ease-out forwards,
               bubbleRise var(--bubble-duration, 14s) linear infinite;
    animation-delay: var(--fade-delay, 0ms), var(--rise-delay, 0ms);
}

.masthead-bubble::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

@keyframes mastheadBubbleFadeIn {
    0% { opacity: 0; }
    100% { opacity: var(--bubble-opacity, 0.6); }
}

.masthead-content {
    position: relative;
    z-index: 1;
    padding: 0 5vw 10vh 0;
    text-align: right;
}

.site-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    line-height: 0.95;
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    text-shadow:
        0 0 4px #00fff5,
        0 0 12px rgba(0, 255, 245, 0.5),
        0 0 30px rgba(0, 255, 245, 0.2),
        0 0 60px rgba(0, 255, 245, 0.1);
}

.title-line {
    display: block;
    font-size: clamp(4rem, 12vw, 10rem);
    opacity: 0;
    transform: translateY(20px);
    animation: titleFadeUp 600ms ease-out forwards;
}

.title-line-1 {
    animation-delay: 1.2s;
}

.title-line-2 {
    animation-delay: 1.5s;
}

@keyframes titleFadeUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Neon glow pulse on the title */
@keyframes neonPulse {
    0%, 100% {
        text-shadow:
            0 0 4px #00fff5,
            0 0 12px rgba(0, 255, 245, 0.5),
            0 0 30px rgba(0, 255, 245, 0.2),
            0 0 60px rgba(0, 255, 245, 0.1);
    }
    50% {
        text-shadow:
            0 0 6px #00fff5,
            0 0 18px rgba(0, 255, 245, 0.6),
            0 0 40px rgba(0, 255, 245, 0.3),
            0 0 80px rgba(0, 255, 245, 0.15);
    }
}

.title-line.animate-glow {
    animation: titleFadeUp 600ms ease-out forwards, neonPulse 4s ease-in-out infinite;
}

.title-line-1.animate-glow {
    animation-delay: 1.2s, 2.5s;
}

.title-line-2.animate-glow {
    animation-delay: 1.5s, 2.5s;
}

.masthead-rule {
    width: 100vw;
    height: 1px;
    background: rgba(0, 255, 245, 0.4);
    position: absolute;
    bottom: 8vh;
    left: -100%;
    right: 0;
    transform: scaleX(0);
    transform-origin: center;
    animation: ruleExpand 500ms ease-out forwards;
    animation-delay: 2.0s;
}

@keyframes ruleExpand {
    0% { transform: scaleX(0); }
    100% { transform: scaleX(1); left: 0; }
}

/* --- Portfolio Grid --- */
#portfolio,
#portfolio-2,
#portfolio-3 {
    position: relative;
    z-index: 2;
    padding: 4rem 3vw;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Grid item sizes */
.grid-item {
    position: relative;
    background: var(--card-bg);
    border: 1px solid rgba(0, 255, 245, 0.15);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 300ms ease, background-color 300ms ease;

    /* Hidden for scroll reveal */
    opacity: 0;
    transform: translateY(30px);
}

.grid-item.revealed {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 500ms ease-out, transform 500ms ease-out, border-color 300ms ease, background-color 300ms ease;
}

.grid-item.feature {
    grid-column: span 3;
    grid-row: span 2;
}

.grid-item.standard {
    grid-column: span 2;
    grid-row: span 1;
}

.grid-item.accent {
    grid-column: span 1;
    grid-row: span 1;
}

/* Card hover */
.grid-item:hover {
    border-color: rgba(0, 255, 245, 0.6);
    background-color: var(--card-bg-hover);
}

/* Card Image */
.card-image {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.feature .card-image {
    aspect-ratio: 16/9;
}

.standard .card-image {
    aspect-ratio: 4/3;
}

.accent .card-image {
    aspect-ratio: 4/3;
}

.card-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to top, var(--card-bg), transparent);
    transition: height 300ms ease;
    z-index: 1;
}

.grid-item:hover .card-image-overlay {
    height: 15%;
}

/* Card bubble decorations */
.card-bubbles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.card-bubble-deco {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 245, 0.2);
    background: rgba(224, 255, 252, 0.05);
    animation: bubblePulse var(--pulse-duration, 5s) ease-in-out infinite;
}

/* Card Content */
.card-content {
    padding: 1rem 1.2rem 1.2rem;
}

.card-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.04em;
    line-height: 1.1;
    text-transform: uppercase;
    color: #fff;
    margin-bottom: 0.4rem;
}

.card-desc {
    font-family: 'Work Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.8rem);
    letter-spacing: 0.02em;
    line-height: 1.4;
    color: var(--steel-text);
    margin-bottom: 0.6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.65rem, 0.85vw, 0.75rem);
    letter-spacing: 0.05em;
    color: var(--neon-cyan);
}

.meta-type {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fog);
}

/* Hover micro-bubbles */
.hover-bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 255, 245, 0.5);
    background: rgba(224, 255, 252, 0.08);
    pointer-events: none;
    z-index: 10;
    animation: hoverBubbleDrift 600ms ease-out forwards;
}

@keyframes hoverBubbleDrift {
    0% {
        opacity: 0.7;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--drift-x, 20px), var(--drift-y, -20px)) scale(0.5);
    }
}

/* --- Interstitial Sections --- */
.interstitial {
    position: relative;
    z-index: 2;
    height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(90deg, rgba(255, 45, 149, 0.05) 0%, transparent 100%);
}

.interstitial-bubbles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.interstitial-bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 45, 149, 0.3);
    background: rgba(255, 45, 149, 0.05);
    animation: bubblePulse var(--pulse-duration, 5s) ease-in-out infinite;
}

.interstitial-text {
    position: relative;
    z-index: 1;
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.06em;
    line-height: 0.95;
    text-transform: uppercase;
    color: var(--hot-magenta);
    text-shadow:
        0 0 4px #ff2d95,
        0 0 12px rgba(255, 45, 149, 0.5),
        0 0 30px rgba(255, 45, 149, 0.2),
        0 0 60px rgba(255, 45, 149, 0.1);
    text-align: center;
    padding: 0 5vw;
}

/* Character reveal animation */
.interstitial-text .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.interstitial-text .char.visible {
    opacity: 1;
    transform: none;
}

.interstitial-text .char-space {
    display: inline-block;
    width: 0.3em;
}

/* --- Footer Basin --- */
#footer-basin {
    position: relative;
    z-index: 2;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, var(--deep-void) 0%, #000000 100%);
    overflow: hidden;
}

.footer-bubbles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.footer-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.footer-nav {
    display: flex;
    gap: 3rem;
}

.footer-link {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--steel-text);
    text-decoration: none;
    transition: color 300ms ease, text-shadow 300ms ease;
}

.footer-link:hover {
    color: var(--hot-magenta);
    text-shadow:
        0 0 4px #ff2d95,
        0 0 12px rgba(255, 45, 149, 0.4);
}

.footer-contact {
    text-align: center;
}

.footer-email {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.05em;
    color: var(--neon-cyan);
}

.footer-copy {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: 'Work Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fog);
}

.footer-divider {
    color: var(--fog);
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .bubble,
    .bubble-pulse,
    .bubble-sink,
    .masthead-bubble,
    .interstitial-bubble,
    .card-bubble-deco,
    .hover-bubble {
        animation: none !important;
        transition: none !important;
    }

    .title-line {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .masthead-rule {
        transform: scaleX(1);
        left: 0;
        animation: none;
    }

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

    .interstitial-text .char {
        opacity: 1;
        transform: none;
    }

    #refraction-lines {
        display: none;
    }
}

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

    .grid-item.feature {
        grid-column: span 2;
        grid-row: span 2;
    }

    .grid-item.standard {
        grid-column: span 2;
    }

    .grid-item.accent {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .grid-item.feature {
        grid-column: span 2;
        grid-row: span 1;
    }

    .grid-item.standard {
        grid-column: span 2;
    }

    .grid-item.accent {
        grid-column: span 1;
    }

    .masthead-content {
        padding: 0 4vw 8vh 0;
    }

    .footer-nav {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .interstitial {
        height: 30vh;
    }
}

@media (max-width: 480px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .grid-item.feature,
    .grid-item.standard,
    .grid-item.accent {
        grid-column: span 1;
        grid-row: span 1;
    }
}
