/**
 * Critical CSS — Above-the-fold styles
 * Loaded synchronously for first render.
 */

/* CSS Variables & Global Styles */
:root {
    /* Colors - Set by JavaScript (critical.js) */
    --primary: #C9A961;
    --primary-dark: #A68B4F;
    --primary-light: #E8D5A3;
    --primary-rgb: 201, 169, 97;
    --primary-light-rgb: 232, 213, 163;
    
    /* Base Colors - Dark Mode (Default) */
    --bg: #0f222e;
    --bg-rgb: 15, 34, 46;
    --text: #FFFFFF;
    --text-rgb: 255, 255, 255;
    --text-light: rgba(255, 255, 255, 0.7);
    --text-lighter: rgba(255, 255, 255, 0.5);
    
    /* Spacing */
    --spacing: 100px;
    --spacing-lg: 150px;
    --spacing-xl: 200px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
    --transition: ease 0.3s;
    --easing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --easing-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    
    /* Typography System — Major Third (1.250) type scale */

    /* Font Families (latin-ext for Turkish characters) */
    --font-primary: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-heading: "Lato", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-footer: "Montserrat", "Segoe UI", -apple-system, sans-serif;

    /* Type Scale (1.250 ratio, base 16px) */
    --fs-xs:   clamp(0.75rem, 0.7rem + 0.15vw, 0.8125rem);    /* 12–13px  meta, caption */
    --fs-sm:   clamp(0.8125rem, 0.775rem + 0.2vw, 0.875rem);   /* 13–14px  small labels  */
    --fs-base: clamp(0.9375rem, 0.875rem + 0.25vw, 1rem);      /* 15–16px  body text     */
    --fs-md:   clamp(1rem, 0.95rem + 0.3vw, 1.125rem);         /* 16–18px  lead text     */
    --fs-lg:   clamp(1.125rem, 1rem + 0.4vw, 1.25rem);         /* 18–20px  subheading    */
    --fs-xl:   clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);         /* 20–24px  h4            */
    --fs-2xl:  clamp(1.5rem, 1.25rem + 1vw, 2rem);             /* 24–32px  h3            */
    --fs-3xl:  clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);         /* 28–40px  h2            */
    --fs-4xl:  clamp(2rem, 1.5rem + 2vw, 3rem);                /* 32–48px  h1            */
    --fs-5xl:  clamp(2.5rem, 1.75rem + 3vw, 4rem);             /* 40–64px  display       */

    /* Line Heights */
    --lh-tight:   1.1;
    --lh-snug:    1.25;
    --lh-normal:  1.5;
    --lh-relaxed: 1.625;
    --lh-loose:   1.75;

    /* Font Weights */
    --fw-normal:   400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;

    /* Letter Spacing */
    --ls-tight:    -0.025em;
    --ls-normal:    0em;
    --ls-wide:      0.04em;
    --ls-wider:     0.08em;
}

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

/* Font antialiasing */
html {
    font-size: 100%;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    background: #0a1a24;
    transition: background 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-font-smoothing: subpixel-antialiased;
    -moz-osx-font-smoothing: auto;
    text-rendering: optimizeLegibility;
    font-smooth: always;
    font-feature-settings: "kern" 1, "liga" 1, "locl" 1;
}

/* Turkish language support */
html[lang="tr"] {
    font-feature-settings: "kern" 1, "liga" 1, "locl" 1, "calt" 1;
}

/* HiDPI / Retina */
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
    html {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

body {
    font-family: var(--font-primary);
    font-weight: var(--fw-normal);
    font-size: var(--fs-base);
    font-style: normal;
    background: radial-gradient(ellipse at center 30%,
        #0f222e 0%,
        #0d1f2a 15%,
        #0b1c26 30%,
        #0a1a24 45%,
        #091821 60%,
        #08161e 75%,
        #07141c 90%,
        #061219 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    overflow-x: hidden;
    line-height: var(--lh-relaxed);
    letter-spacing: var(--ls-normal);
    transition: background 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Heading Hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    font-style: normal;
    font-weight: var(--fw-medium);
    line-height: var(--lh-snug);
    letter-spacing: var(--ls-tight);
}

h1 { font-size: var(--fs-4xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl);  }
h5 { font-size: var(--fs-lg);  }
h6 { font-size: var(--fs-md);  }

/* Navbar tagline uses Lato */
.nav-headline {
    font-family: var(--font-heading);
    font-style: normal;
}

/* Skip link — keyboard/screen reader accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100001;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    font-family: var(--font-primary);
    font-style: normal;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transition: top 0.2s ease, box-shadow 0.2s ease;
}
.skip-link:focus {
    top: 16px;
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4);
}

/* Earth containers — visible immediately (parallax.js controls opacity) */
.hero-earth-container,
.hero-earth,
#earth3DContainer,
.earth-ring {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Scroll to Top — Critical (prevent FOUC) */
.scroll-to-top {
    position: fixed !important;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    width: 48px;
    height: 48px;
}

.scroll-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Responsive — Critical */

/* Tablet (<=1024px) */
@media (max-width: 1024px) {
    .hero-center {
        max-width: min(90vw, 600px);
    }
    
    .hero-buttons-layer {
        top: 68%;
    }
    
    .hero-logo-image {
        width: clamp(140px, 32vw, 320px);
        max-height: min(36vh, 180px);
    }
}

/* Mobile (<=768px) */
@media (max-width: 768px) {
    /* Hide custom cursor on mobile */
    .custom-cursor,
    .custom-cursor-dot {
        display: none !important;
    }
    
    /* Hero — mobile responsive layout (flex instead of fixed) */
    .hero {
        min-height: 100vh;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding-bottom: 72px; /* scroll indicator area */
    }
    
    .hero-center {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        max-width: 90vw;
        gap: clamp(12px, 3vw, 20px);
    }
    
    .hero-logo-image {
        width: clamp(120px, 50vw, 260px);
        max-height: min(30vh, 160px);
    }
    
    .hero-tagline {
        font-size: var(--fs-base);
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        max-width: 90vw;
    }
    
    .hero-buttons-layer {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        transform: none !important;
        margin-top: clamp(24px, 5vw, 36px);
    }
    
    .hero-links {
        flex-direction: row;
        gap: clamp(20px, 5vw, 32px);
        align-items: center;
    }
    
    .hero-link {
        font-size: var(--fs-xs);
        padding: 8px 4px;
        letter-spacing: var(--ls-wider);
    }
    
    .hero-scroll-wrapper {
        bottom: clamp(16px, 3vw, 28px);
    }
    
    .hero-scroll-indicator {
        width: 24px;
        height: 36px;
    }
    
    .hero-scroll-indicator-line {
        height: 24px;
    }
}

/* Small Mobile (<=480px) */
@media (max-width: 480px) {
    .hero {
        padding-bottom: 64px;
    }
    
    .hero-center {
        gap: clamp(10px, 2.5vw, 16px);
    }
    
    .hero-logo-image {
        width: clamp(100px, 55vw, 200px);
        max-height: min(25vh, 130px);
    }
    
    .hero-tagline {
        font-size: var(--fs-sm);
        line-height: var(--lh-normal);
    }
    
    .hero-buttons-layer {
        margin-top: clamp(20px, 4vw, 28px);
    }
    
    .hero-link {
        font-size: var(--fs-xs);
    }
}

@keyframes sunRise {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Theme Transition — smooth light/dark switch */
html.theme-transitioning,
body.theme-transitioning {
    transition: background 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.theme-transitioning * {
    transition: background-color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing);
    width: 100%;
    will-change: opacity;
    background: transparent !important;
}

/* Sections — transparent, body gradient shows through */
section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
    padding: var(--spacing) 0;
    overflow: hidden;
    border: none;
    outline: none;
    background: transparent !important;
    box-shadow: none !important;
    will-change: opacity;
}

section:not(.hero)::before {
    display: none;
}

/* Hero section */
section.hero {
    z-index: 1;
    opacity: 1 !important;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Hero — dynamic height */
.hero {
    --hero-height: min(100vh, 100dvh);
    --hero-logo-top: 48%;
    min-height: 100vh;
    min-height: 100dvh;
    height: var(--hero-height);
    padding: 0;
    justify-content: center;
    align-items: center;
    position: relative;
}

@media (max-height: 600px) {
    .hero {
        --hero-height: min(100vh, 100dvh);
        --hero-logo-top: 48%;
    }
}

@media (min-width: 1200px) {
    .hero {
        --hero-logo-top: 48%;
    }
}

/* Hero center — logo + buttons */
.hero-center {
    position: fixed;
    left: 50%;
    top: var(--hero-logo-top);
    transform: translate(-50%, -50%);
    z-index: 99999;
    pointer-events: auto !important;
    opacity: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 4vw, 28px);
    max-width: min(92vw, 720px);
    transition: top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.hero-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-logo-image {
    width: clamp(160px, 38vw, 380px);
    height: auto;
    max-height: min(42vh, 220px);
    object-fit: contain;
    transition: width 0.3s ease, max-height 0.3s ease;
    filter: brightness(0) invert(1)
            drop-shadow(0 0 40px rgba(var(--primary-rgb), 0.25))
            drop-shadow(0 0 20px rgba(0, 0, 0, 0.3));
}

/* Hero tagline */
.hero-tagline {
    margin: 0;
    padding-left: 1rem;
    padding-right: 1rem;
    font-family: var(--font-primary);
    font-style: normal;
    font-weight: var(--fw-normal);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    color: var(--text-light);
    text-align: center;
    max-width: min(90vw, 560px);
    letter-spacing: var(--ls-normal);
}

/* Hero buttons layer */
.hero-buttons-layer {
    position: fixed;
    left: 50%;
    top: 66%;
    transform: translate(-50%, -50%);
    z-index: 100000;
    pointer-events: auto !important;
    opacity: 1;
}

/* Hero links */
.hero-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 4vw, 40px);
    pointer-events: auto !important;
    position: relative;
    z-index: 100001;
}

.hero-link {
    display: block;
    padding: 6px 0;
    font-family: var(--font-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    letter-spacing: var(--ls-wider);
    text-transform: uppercase;
    text-decoration: none;
    color: var(--text-light);
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 100001;
    transition: border-bottom-color 0.2s ease, color 0.2s ease;
}

.hero-link:hover,
.hero-link.is-hover {
    color: var(--text-light);
    border-bottom-color: var(--primary);
}

.hero-link.active {
    color: var(--text-light);
    border-bottom-color: var(--primary);
}

.hero-link:active {
    opacity: 0.9;
}

/* Scroll indicator wrapper */
.hero-scroll-wrapper {
    position: fixed;
    bottom: clamp(24px, 4vw, 40px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    pointer-events: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hero scroll indicator */
.hero-scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 28px;
    height: 44px;
    cursor: pointer !important;
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: auto !important;
    text-decoration: none;
    color: inherit;
}

.hero-scroll-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.hero-scroll-indicator-line {
    width: 2px;
    height: 32px;
    background: linear-gradient(to bottom,
        rgba(255, 255, 255, 0.9),
        rgba(255, 255, 255, 0.2));
    border-radius: 2px;
    flex-shrink: 0;
}

.hero-scroll-indicator-dot {
    width: 8px;
    height: 8px;
    margin-top: -4px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.6);
    animation: heroScrollBounce 2s ease-in-out infinite;
}

@keyframes heroScrollBounce {
    0%, 100% { -webkit-transform: translateY(0); transform: translateY(0); opacity: 1; }
    50% { -webkit-transform: translateY(10px); transform: translateY(10px); opacity: 0.7; }
}

/* Background — Parallax Stars */
.blue-notes-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none !important;
    z-index: 1;
    opacity: 0;
    visibility: visible;
    transition: opacity 1s ease-in-out;
    background: transparent;
}

#blueNotesCanvas {
    width: 100%;
    height: 100%;
    background: transparent;
}

/* Entrance Overlay — Page loading animation */
.entrance-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse 120% 100% at 50% 40%,
        #0f222e 0%,
        #0d1f2a 25%,
        #0a1a24 55%,
        #061219 85%,
        #040d12 100%);
    transition: opacity 0.8s cubic-bezier(0.33, 1, 0.68, 1);
    pointer-events: auto;
}

.entrance-overlay-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 70% at 50% 50%, transparent 40%, rgba(0, 0, 0, 0.5) 100%);
    pointer-events: none;
}

.entrance-overlay-glow {
    position: absolute;
    width: 320px;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center, rgba(var(--primary-rgb), 0.08) 0%, transparent 70%);
    pointer-events: none;
}

body.entrance-complete .entrance-overlay {
    opacity: 0;
    pointer-events: none;
}

.entrance-overlay-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.75rem;
    padding: 2rem;
}

.entrance-logo-wrap {
    filter: drop-shadow(0 0 24px rgba(255, 255, 255, 0.2))
            drop-shadow(0 0 48px rgba(255, 255, 255, 0.08));
    animation: entranceLogoWrapIn 1s cubic-bezier(0.33, 1, 0.68, 1) 0.15s forwards;
    opacity: 0;
}

.entrance-logo {
    width: 180px;
    height: auto;
    max-height: 90px;
    object-fit: contain;
    display: block;
    filter: brightness(0) invert(1);
    animation: entranceLogoIn 1s cubic-bezier(0.33, 1, 0.68, 1) 0.2s forwards;
    opacity: 0;
    transform: scale(0.94) translateY(8px);
}

@keyframes entranceLogoWrapIn {
    to { opacity: 1; }
}

@keyframes entranceLogoIn {
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.entrance-divider {
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb), 0.5), transparent);
    animation: entranceDividerIn 0.8s cubic-bezier(0.33, 1, 0.68, 1) 0.5s forwards;
}

@keyframes entranceDividerIn {
    to { width: 120px; }
}

.entrance-progress {
    position: relative;
    width: 240px;
    height: 2px;
    border-radius: 2px;
    overflow: visible;
}

.entrance-progress-track {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
}

.entrance-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.4);
    animation: entranceProgressFill 1.7s cubic-bezier(0.33, 1, 0.68, 1) 0.7s forwards;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.entrance-progress-shine {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(105deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.35) 50%,
        transparent 60%,
        transparent 100%);
    background-size: 200% 100%;
    animation: entranceShine 1.2s ease-in-out 1.2s;
}

@keyframes entranceProgressFill {
    to { width: 100%; }
}

@keyframes entranceShine {
    0% { background-position: 200% 0; }
    100% { background-position: -100% 0; }
}

.entrance-percent {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wider);
    color: rgba(255, 255, 255, 0.6);
    font-family: var(--font-primary);
    font-style: normal;
    margin-top: 0.75rem;
    opacity: 0;
    animation: entrancePercentIn 0.5s cubic-bezier(0.33, 1, 0.68, 1) 0.9s forwards;
}

@keyframes entrancePercentIn {
    to { opacity: 1; }
}

/* Page content hidden during entrance, visible after */
body.entrance-loading .page-content {
    opacity: 0;
    pointer-events: none;
}

body.entrance-complete .page-content {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.8s cubic-bezier(0.33, 1, 0.68, 1);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .entrance-overlay {
        transition-duration: 0.2s;
    }
    .entrance-logo-wrap,
    .entrance-logo {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .entrance-divider {
        animation: none;
        width: 120px;
    }
    .entrance-progress-bar {
        animation-duration: 0.5s;
    }
    .entrance-progress-shine {
        animation: none;
    }
    .entrance-percent {
        animation: none;
        opacity: 1;
    }
    body.entrance-complete .page-content {
        transition-duration: 0.2s;
    }
}
