/* Core Variables & Reset */
:root {
    /* "Rich Dark" Palette */
    --bg-color: #050505;
    --surface-color: #0f0f0f;
    --surface-hover: #161616;
    --border-color: #262626;
    --text-primary: #ededed;
    --text-secondary: #a1a1a1;
    --accent: #ffffff;
    /* Stark white for emphasis */
    --accent-dim: #555555;

    /* Spacing & Layout */
    --container-width: 1200px;
    --nav-height: 80px;
    --border-radius: 8px;

    /* Animation */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 0.2s var(--ease-out-expo);
    --transition-slow: 0.8s var(--ease-out-expo);
}

/* Force override for any stubborn browser defaults */
* {
    cursor: none !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    cursor: none;
    /* Hide default cursor */
}

html {
    scroll-behavior: smooth;
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Touch Support for Pointers */
@media (hover: none) and (pointer: coarse) {
    * {
        cursor: auto !important;
    }

    #custom-cursor,
    #pointer-light {
        display: none !important;
    }

    .magnetic-btn {
        transform: none !important;
        transition: none !important;
    }
}

/* Hide Scrollbar Globally */
html,
body {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
    width: 0;
    height: 0;
}

body {
    overflow-x: hidden;
    position: relative;
    /* Disable Text Selection/Copying */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

ul {
    list-style: none;
}

/* Utilities */
.btn-primary {
    background: var(--text-primary);
    color: var(--bg-color);
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.section-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 6rem 1.5rem;
}

/* Cinematic Noise Overlay */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Loading Screen with CODAME Text */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    /* Totally black as requested */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.6s ease-out;
}

#preloader.loaded {
    opacity: 0;
    pointer-events: none;
}

/* Loading SVG - Centered to match Hero Logo */
#preloader .loading-logo {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 1;
}

/* Pure Line Drawing Effect */
@keyframes drawTextLoader {
    0% {
        stroke-dashoffset: var(--stroke-length, 2000);
        opacity: 1;
        stroke: #ffffff;
        fill: transparent;
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 1;
        stroke: #ffffff;
        fill: transparent;
        /* Keep as pure lines */
    }
}

/* Apply Animation */

#preloader .base-text {
    opacity: 1;
    /* CHANGE LOADING TIME HERE (drawing speed) */
    animation: drawTextLoader 1.5s ease-in-out forwards;
}

#preloader .highlight-text {
    opacity: 1;
    /* CHANGE LOADING TIME HERE (drawing speed) */
    animation: drawTextLoader 1.5s ease-in-out 0.1s forwards;
}


.terminal-loader {
    font-family: 'Courier New', monospace;
    text-align: center;
}

.terminal-text {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
}

.progress-bar {
    width: 200px;
    height: 2px;
    background: #333;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--text-primary);
    animation: progressLoad 2s ease-in-out forwards;
}

@keyframes progressLoad {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

/* Mouse Follower Spotlight (Global) */
/* Mouse Follower Spotlight (Global) - Replaced by body::after */
.spotlight-cursor {
    display: none;
}

/* Global Ambient Flashlight (Very Soft) - Only appears on mouse movement */
/* Optimized Flashlight Pointer */
#pointer-light {
    position: fixed;
    top: 0;
    left: 0;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    /* Ensures no square edges */
    pointer-events: none;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.5s ease;
    will-change: transform;
    mix-blend-mode: lighten;
    /* Better blending */
}

body.mouse-active #pointer-light {
    opacity: 1;
}


/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    background: rgba(5, 5, 5, 0.7);
    backdrop-filter: blur(12px);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Brand Container */
.nav-brand-container {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: none;
    /* Force Custom Cursor */
    text-decoration: none;
    color: inherit;
}

.nav-logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.nav-logo-text {
    font-weight: 800;
    font-size: clamp(1.2rem, 3vw, 1.4rem);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--text-primary);
}

/* Hero Section */
.hero-section {
    height: 100vh;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center Vertically */
    align-items: center;
    /* Center Horizontally */
    overflow: hidden;
    padding-top: var(--nav-height);
    text-align: center;
}

.hero-bg-parallax {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Radial base + Grid Pattern */
    background:
        radial-gradient(circle at center, rgba(20, 20, 20, 0.8) 0%, #050505 80%),
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    background-position: center;
    z-index: -2;
}

.hero-content {
    z-index: 10;
    max-width: 800px;
    padding: 0 1rem;
}

.hero-title {
    /* Fluid typography: Min 2.5rem, Max 5rem */
    font-size: clamp(2.5rem, 8vw, 5rem);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: clamp(0.5rem, 65vh - 40vw, 45vh);
    /* Fluid gap: Closed on desktop, large on mobile to reveal background */
    color: var(--text-primary);
    transition: font-size 0.3s ease, margin-bottom 0.3s ease;
    /* Gradual change */
}

.hero-title span {
    display: block;
    /* Stack them or inline-block based on preference. Block resembles the GTA style more. */
}

/* Reveal Animation States - Synchronized with CODAME animation */
.reveal-text {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s var(--ease-out-expo) forwards;
}

.reveal-text:nth-child(2) {
    animation-delay: 0.1s;
}

.reveal-text:nth-child(3) {
    animation-delay: 0.2s;
}

.reveal-opacity {
    opacity: 0;
    animation: fadeIn 1s ease forwards;
    animation-delay: 0.4s;
    /* Reduced from 0.6s */
}

.hero-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* Custom Cursor */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    pointer-events: none;
    mix-blend-mode: difference;
    transform: translate(-50%, -50%);
    color: white;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.2rem;
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.1s ease-out;
}

/* Global Button Styles */
.btn-primary,
.btn-hero {
    display: inline-block;
    padding: 0.8rem 1.8rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 30px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

/* Button Shimmer Effect */
.btn-primary::before,
.btn-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    transition: 0.5s;
}

.btn-primary:hover::before,
.btn-hero:hover::before {
    left: 100%;
}

.btn-primary:hover,
.btn-hero:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #ffffff;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Hero Logo Layer - SVG Implementation */
.hero-logo-layer {
    position: absolute;
    /* Changed from fixed to absolute to lock into Hero section */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 1;
    /* Fully visible during animation */
    transition: opacity 0.3s ease;
}

.logo-text {
    /* Use system fonts optimized for display - cleaner rendering */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Arial', sans-serif;
    font-weight: 900;
    font-size: 18vw;
    letter-spacing: 0.02em;
    /* Slight spacing prevents overlaps */

    /* SVG Rendering Optimizations */
    paint-order: stroke fill;
    stroke-linejoin: round;
    stroke-linecap: round;
    shape-rendering: geometricPrecision;
}

/* 1. Base Text (Always visible, faint) - Animated */
.base-text {
    fill: none;
    stroke: rgba(120, 120, 120, 0.2);
    stroke-width: 1.5px;
    transition: stroke 0.2s ease-out, fill 0.2s ease-out;
    /* Fast scroll response */
    opacity: 0.5;
    /* Final state */

    /* Default to fully drawn for Hero Section */
    stroke-dasharray: var(--stroke-length, 2000);
    stroke-dashoffset: 0;
}

/* Old drawText animation removed/deprecated for main text, used custom loader animation instead */
@keyframes drawText {
    0% {
        stroke-dashoffset: var(--stroke-length, 2000);
        opacity: 0;
        stroke: rgba(255, 255, 255, 0.8);
    }

    50% {
        opacity: 0.9;
        stroke: rgba(255, 255, 255, 0.9);
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 0.5;
        stroke: rgba(120, 120, 120, 0.2);
    }
}

/* 2. Highlight Text (Revealed by Mask) - Animated with Delay */
.highlight-text {
    fill: none;
    stroke: rgba(255, 255, 255, 0.5);
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.1));
    opacity: 1;
    /* Always ready for mask reveal */
    transition: stroke 0.2s ease-out, filter 0.2s ease-out;

    /* Default to fully drawn */
    stroke-dasharray: var(--stroke-length, 2000);
    stroke-dashoffset: 0;
}

@keyframes drawTextHighlight {
    0% {
        stroke-dashoffset: var(--stroke-length, 2000);
        opacity: 0;
        stroke: rgba(255, 255, 255, 0.9);
    }

    50% {
        opacity: 0.95;
        stroke: rgba(255, 255, 255, 1);
        filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.4));
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 1;
        stroke: rgba(255, 255, 255, 0.5);
        filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.1));
    }
}

/* Scroll Effect: JavaScript handles progressive fade */
.hero-logo-layer.is-scrolling .base-text {
    /* JavaScript dynamically controls fill/stroke opacity */
    transition: fill 0.2s ease-out, stroke 0.2s ease-out;
}

.hero-logo-layer.is-scrolling .highlight-text {
    stroke: rgba(255, 255, 255, 0.6);
    /* Slightly brighter when scrolling */
    filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.12));
    transition: stroke 0.2s ease-out, filter 0.2s ease-out;
}

/* Section Common Styles */
.section-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.03em;
}

.section-line {
    flex-grow: 1;
    height: 1px;
    background: var(--border-color);
}

/* Events Grid */
.events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

.event-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.event-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-dim);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.05);
}

.event-image {
    width: 100%;
    height: 200px;
    background-color: #222;
    object-fit: cover;
}

.event-content {
    padding: 1.5rem;
}

.event-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
}

.event-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.event-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Competitions */
.competitions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.competition-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

@media (max-width: 768px) {
    .competition-card {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }

    .competition-card .comp-date {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    .competition-card .btn-primary {
        margin-top: 0.5rem;
        width: 100%;
        text-align: center;
    }
}

.competition-card:hover {
    background: var(--surface-hover);
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2), 0 0 15px rgba(255, 255, 255, 0.03);
}

.comp-date {
    width: 60px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-right: 2rem;
    font-weight: 600;
}

.comp-info {
    flex-grow: 1;
}

.comp-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.2rem;
}

.comp-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.comp-status {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.comp-status.live {
    border-color: #4CAF50;
    /* Subtle green for status only */
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.site-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    background: #222;
    color: #aaa;
    margin-left: 5px;
}

.site-badge.codechef {
    color: #d7ccc8;
    border: 1px solid #5d4037;
}

.site-badge.codeforces {
    color: #90caf9;
    border: 1px solid #1e3a8a;
}

.site-badge.leetcode {
    color: #ffa116;
    border: 1px solid #9c6c21;
}

/* Members Grid */
.members-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
}

.member-card {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.member-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: #333;
    margin: 0 auto 1rem;
    object-fit: cover;
}

.member-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.member-role {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Resources Section */
.resources-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.resource-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    cursor: none;
    /* Force Custom Cursor */
    text-decoration: none;
    color: var(--text-primary);
}

.resource-item:hover {
    background: var(--surface-hover);
    border-color: var(--accent-dim);
    transform: translateX(8px);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.05);
}

.res-icon {
    font-size: 1.8rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.res-title {
    flex-grow: 1;
    font-size: 1.05rem;
    font-weight: 500;
}

.res-arrow {
    font-size: 1.5rem;
    margin-left: 1rem;
    opacity: 0.5;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.resource-item:hover .res-arrow {
    opacity: 1;
    transform: translateX(5px);
}

/* Footer */
.footer {
    border-top: 1px solid var(--border-color);
    padding: 4rem 1.5rem;
    margin-top: 6rem;
    background: #050505;
}

.footer-content {
    max-width: var(--container-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-brand {
    font-weight: 700;
    font-size: 1.2rem;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Animations Keyframes */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Media Queries */
@media (max-width: 768px) {
    .section-container {
        padding: 4rem 1rem;
    }

    /* Mobile: Split content to reveal background "CODAME" */
    .hero-content {
        margin-top: 0;
        /* Reset offset to center the gap */
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 80vh;
        /* Ensure enough height to spread */
    }

    /* .hero-title margin is handled by fluid base style now */

    .hero-subtitle {
        padding: 0 10px;
    }

    .nav-links {
        display: none;
    }

    /* Show 2 member cards per row on mobile */
    .members-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Member Team Badge */
.member-team-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
    background: rgba(255, 255, 255, 0.03);
}

/* Magnetic Button */
.magnetic-btn {
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* Scroll Animation Utilities */
.fade-in-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.section-header,
.competition-card,
.resource-item {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.section-header.is-visible,
.competition-card.is-visible,
.resource-item.is-visible {
    opacity: 1;
    transform: translateY(0);
}
