@import url('https://fonts.googleapis.com/css2?family=Fragment+Mono&family=Just+Me+Again+Down+Here&display=swap');

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #000000;
    --txt-light: #F8F4EE;
    --font-main: 'Fragment Mono', monospace;
    --font-hand: 'Just Me Again Down Here', cursive;
}

body, html {
    background: #000;
    color: var(--txt-light);
    font-family: var(--font-main);
    overflow-x: hidden;
}

/* =========================================
   SECTION 1: HYPERSPACE HERO
   ========================================= */
.hero-section {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #000;
}

#hyperspace-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
    touch-action: none;
    /* Bottom edge fades to black for seamless transition */
    -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.7;
    pointer-events: none;
    z-index: 10;
}

.scroll-indicator svg {
    width: 32px;
    height: 32px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* =========================================
   SECTION 2: CIRCULAR GALLERY
   ========================================= */
.gallery-section {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

/*
 * The ring is the invisible circle that holds all cards.
 * It is centered in the viewport and rotated by GSAP.
 * Cards are placed around its circumference via JS transforms.
 */
.gallery-ring {
    --cards: 8;
    --card-width: max(200px, 22vw);
    --card-height: calc(var(--card-width) * 1.5);
    --radius: calc(var(--card-width) * var(--cards) / (2 * 3.1416));

    position: absolute;
    /* Center the ring in the viewport */
    left: 50%;
    /* Push center down so the TOP of the circle aligns with viewport center */
    top: calc(50% + var(--radius));
    width: 0;
    height: 0;
    will-change: transform;
}

.gallery-card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    /* Center each card on the ring origin */
    top: calc(var(--card-height) / -2);
    left: calc(var(--card-width) / -2);

    border-radius: 24px;
    transition: filter 0.3s, opacity 0.3s, box-shadow 0.3s;
    transform-origin: center center;

    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

.gallery-card a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    border-radius: 18px;
    overflow: hidden;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center; /* Default for others */
    border-radius: 18px;
    border: none;
    /* Real chromatic aberration via SVG filter */
    filter: url(#chromatic-aberration);
}

/* Specific alignments for screenshots that should stick to the left */
.gallery-card[data-title="Portfolio Beta"] img,
.gallery-card[data-title="Pay"] img {
    object-position: left center;
}

/* Title label below card */
.gallery-card::after {
    content: attr(data-title);
    position: absolute;
    top: 100%;
    left: 1rem;
    margin-top: 1rem;
    font-family: var(--font-hand);
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    white-space: nowrap;
    color: var(--txt-light);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}

.gallery-card-desc {
    position: absolute;
    top: 100%;
    left: 1rem;
    margin-top: 4rem;
    font-size: 0.9rem;
    color: #A0AEC0;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
    transition-delay: 0.1s;
    pointer-events: none;
    width: 200%;
}

/* Active card (at the top of the ring) */
.gallery-card.active {
    filter: blur(0) grayscale(0);
    opacity: 1;
    z-index: 10;
    pointer-events: auto;
    cursor: pointer;
}

/* Inactive cards (blurred background) */
.gallery-card.inactive {
    filter: blur(6px) grayscale(0.8);
    opacity: 0.25;
    z-index: 1;
    pointer-events: none;
}

/* Hover on active card reveals title + desc */
.gallery-card.active:hover::after,
.gallery-card.active:hover .gallery-card-desc {
    opacity: 1;
    transform: translateY(0);
}

.gallery-card.active:hover {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.08);
}

/* =========================================
   SECTION 3: GLSL FOOTER
   ========================================= */
.footer-section {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#webgl-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Top edge fades from black for seamless transition */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 25%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 25%);
}

.footer-content {
    position: relative;
    z-index: 10;
    text-align: center;
    background: rgba(0, 0, 0, 0.03); /* Reduced opacity even further */
    padding: 3rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.03); /* Fainter border */
}

.footer-content h2 {
    margin: 0 0 2rem 0;
    font-size: 2rem;
    letter-spacing: 0.1em;
}

.social-links {
    display: flex;
    gap: 2.5rem;
    justify-content: center;
    align-items: center;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: transform 0.3s, opacity 0.3s;
    opacity: 0.7;
}

.social-link svg {
    width: 100%;
    height: 100%;
}

.social-link:hover {
    transform: scale(1.25) translateY(-3px);
    opacity: 1;
}

.footer-switch {
    margin-top: 1.5rem;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0.55;
}

.footer-switch a {
    color: inherit;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    transition: opacity 0.25s ease;
}

.footer-switch a:hover {
    opacity: 0.8;
}
