/* ============================================================
   aiice.dev — Frosted-Glass Arctic Laboratory
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@300;400;500&display=swap');

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

:root {
    --glacial-white: #F0F7FA;
    --deep-fjord: #1B2A4A;
    --crevasse-blue: #3B82C4;
    --frost-silver: #A8C8D8;
    --ice-mist: #C8DDE6;
    --snow-glow: #E8F4F8;
    --ice-pale: #E0EFF5;
    --meltwater: #6BA3C2;
    --aurora-pink: #FF6B8A;
    --slate: #4A7B8C;
    --pure-white: #FFFFFF;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(180deg, var(--glacial-white) 0%, var(--ice-pale) 100%);
    color: var(--deep-fjord);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Glacial Background Layer --- */
.glacial-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background:
        radial-gradient(ellipse 70% 50% at 25% 15%, rgba(255, 255, 255, 0.4) 0%, transparent 60%),
        radial-gradient(ellipse 60% 60% at 75% 70%, rgba(200, 221, 230, 0.3) 0%, transparent 50%),
        linear-gradient(180deg, var(--glacial-white) 0%, var(--ice-pale) 100%);
    pointer-events: none;
}

/* --- Hexagonal Grid Background --- */
.hex-grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='92.376'%3E%3Cpath d='M40 0 L80 23.094 L80 69.282 L40 92.376 L0 69.282 L0 23.094 Z' fill='none' stroke='%23C8DDE6' stroke-width='1'/%3E%3C/svg%3E");
    background-size: 80px 92.376px;
}

/* --- Snowfall Container --- */
.snowfall-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.snow-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform;
}

@keyframes snowDrift {
    0% {
        transform: translateY(-20px) translateX(0px);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translateY(calc(100vh + 20px)) translateX(var(--drift-x, 30px));
        opacity: 0;
    }
}

/* --- Navigation Bar --- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(240, 247, 250, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.4s ease, background 0.4s ease;
}

.nav-bar.scrolled {
    border-bottom-color: var(--frost-silver);
    background: rgba(240, 247, 250, 0.85);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.nav-brand {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    color: var(--crevasse-blue);
    text-decoration: none;
    transition: color 0.3s ease;
}

.nav-brand:hover {
    color: var(--meltwater);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--slate);
    text-decoration: none;
    transition: color 0.3s ease;
    position: relative;
    padding: 0.25rem 0;
}

.nav-link:hover {
    color: var(--crevasse-blue);
}

.nav-link.active {
    color: var(--crevasse-blue);
}

.nav-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--crevasse-blue);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1px;
    width: 0;
    opacity: 0;
}

.nav-indicator.visible {
    opacity: 1;
}

/* --- Faceted Sections --- */
.faceted-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.faceted-section:not(.hero-section) {
    padding: 8rem 2rem;
}

/* Diagonal clip-path section separators */
.content-section {
    position: relative;
}

.content-section:nth-child(odd) {
    background: linear-gradient(180deg, rgba(240, 247, 250, 0.4) 0%, rgba(255, 255, 255, 0.2) 100%);
    clip-path: polygon(0 4%, 100% 0, 100% 96%, 0 100%);
}

.content-section:nth-child(even) {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.3) 0%, rgba(232, 244, 248, 0.3) 100%);
    clip-path: polygon(0 0, 100% 4%, 100% 100%, 0 96%);
}

.section-bg-fractal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.section-inner {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* --- Hero Section --- */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-fractal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    pointer-events: none;
    z-index: 1;
}

.hero-fractal-svg {
    width: 100%;
    height: 100%;
}

.hero-fractal-svg line,
.hero-fractal-svg path {
    stroke: var(--frost-silver);
    stroke-width: 1;
    stroke-linecap: round;
    opacity: 0;
}

.hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
}

.hero-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    color: var(--crevasse-blue);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.hero-title.revealed {
    opacity: 1;
    transform: scale(1);
}

.hero-subtitle {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.4vw, 1.1rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--frost-silver);
    margin-top: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

.hero-subtitle.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-hint {
    position: absolute;
    bottom: 3rem;
    z-index: 10;
    animation: scrollBounce 2s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.scroll-hint.revealed {
    opacity: 0.5;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* --- Frost Cards (Glassmorphism) --- */
.frost-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 3.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.05);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease, backdrop-filter 0.4s ease, border-color 0.4s ease;
}

.frost-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.frost-card:hover {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-color: rgba(59, 130, 196, 0.1);
}

.frost-card-wide {
    max-width: none;
}

/* Refraction Highlight */
.refraction-highlight {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.8) 30%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0.8) 70%, transparent 100%);
    z-index: 10;
    pointer-events: none;
}

/* Frost-Edge Borders (Lindenmayer-style decoration) */
.frost-edge {
    position: absolute;
    width: 80px;
    height: 80px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
    transition: opacity 0.4s ease;
}

.frost-card:hover .frost-edge {
    opacity: 0.5;
}

.frost-edge-tl {
    top: 8px;
    left: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none' stroke='%23C8DDE6' stroke-width='0.7'%3E%3Cpath d='M0 0 L30 0 M0 0 L0 30 M0 0 L20 20 M10 0 L10 15 M0 10 L15 10 M5 5 L18 3 M5 5 L3 18 M15 0 L20 8 M0 15 L8 20 M20 0 L25 12 M0 20 L12 25'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.frost-edge-br {
    bottom: 8px;
    right: 8px;
    transform: rotate(180deg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80' fill='none' stroke='%23C8DDE6' stroke-width='0.7'%3E%3Cpath d='M0 0 L30 0 M0 0 L0 30 M0 0 L20 20 M10 0 L10 15 M0 10 L15 10 M5 5 L18 3 M5 5 L3 18 M15 0 L20 8 M0 15 L8 20 M20 0 L25 12 M0 20 L12 25'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* --- Hex Badge --- */
.hex-badge {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.hex-icon {
    width: 40px;
    height: 35px;
    opacity: 0.5;
}

/* --- Typography --- */
.section-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 2.5rem);
    letter-spacing: -0.02em;
    color: var(--crevasse-blue);
    text-align: center;
    margin-bottom: 1.5rem;
}

.section-text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    line-height: 1.75;
    color: var(--deep-fjord);
    text-align: center;
    margin-bottom: 1rem;
    opacity: 0.85;
}

.section-text:last-of-type {
    margin-bottom: 0;
}

/* --- Interactive Crystal Canvas --- */
.crystal-canvas-wrapper {
    margin-top: 2rem;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(200, 221, 230, 0.3);
}

.crystal-canvas {
    width: 100%;
    height: 400px;
    display: block;
    background: linear-gradient(180deg, rgba(240, 247, 250, 0.5), rgba(232, 244, 248, 0.5));
    cursor: crosshair;
}

.crystal-canvas-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--frost-silver);
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.crystal-canvas-wrapper.has-crystals .crystal-canvas-hint {
    opacity: 0;
}

/* --- Code Block --- */
.code-block {
    margin-top: 2rem;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(27, 42, 74, 0.04);
    border: 1px solid rgba(200, 221, 230, 0.4);
    position: relative;
}

.code-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
}

.code-block-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.75rem 1rem;
    background: rgba(168, 200, 216, 0.1);
    border-bottom: 1px solid rgba(200, 221, 230, 0.2);
}

.code-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.code-dot-1 { background: rgba(255, 107, 138, 0.5); }
.code-dot-2 { background: rgba(168, 200, 216, 0.5); }
.code-dot-3 { background: rgba(59, 130, 196, 0.5); }

.code-filename {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--slate);
    margin-left: 0.5rem;
    opacity: 0.6;
}

.code-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.8;
    letter-spacing: 0.01em;
    padding: 1.5rem;
    color: var(--deep-fjord);
    overflow-x: auto;
    white-space: pre;
    tab-size: 2;
}

.code-content .kw { color: var(--crevasse-blue); }
.code-content .str { color: var(--meltwater); }
.code-content .val { color: var(--aurora-pink); }
.code-content .fn { color: var(--crevasse-blue); font-weight: 500; }
.code-content .cm { color: var(--frost-silver); font-style: italic; }
.code-content .ty { color: var(--slate); }
.code-content .op { color: var(--deep-fjord); opacity: 0.6; }

.code-line {
    display: block;
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.code-line.typed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Structure Grid --- */
.structure-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 2.5rem;
}

.structure-item {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(200, 221, 230, 0.2);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.structure-item:hover {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(59, 130, 196, 0.15);
}

.structure-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
}

.structure-icon svg {
    width: 100%;
    height: 100%;
}

.structure-label {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--crevasse-blue);
    margin-bottom: 0.5rem;
}

.structure-desc {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--slate);
}

/* --- Aurora CTA Button --- */
.clarity-cta {
    display: flex;
    justify-content: center;
    margin-top: 2.5rem;
}

.aurora-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0.85rem 2rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    color: #fff;
    background: var(--aurora-pink);
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.aurora-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 107, 138, 0.25);
}

.aurora-btn-text {
    position: relative;
    z-index: 2;
}

.aurora-btn-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    z-index: 1;
}

/* --- Footer --- */
.glacial-footer {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 5rem 2rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.footer-fractal {
    margin-bottom: 1rem;
}

.footer-fractal svg {
    width: 120px;
    height: 60px;
}

.footer-brand {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.04em;
    color: var(--crevasse-blue);
    opacity: 0.4;
}

.footer-divider {
    width: 30px;
    height: 1px;
    background: var(--frost-silver);
    opacity: 0.3;
}

.footer-tagline {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--frost-silver);
    opacity: 0.5;
}

/* --- Click Burst Effect --- */
.click-burst-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

.click-burst-line {
    position: absolute;
    width: 12px;
    height: 1px;
    background: var(--crevasse-blue);
    transform-origin: left center;
    opacity: 0;
    animation: burstOut 0.35s ease-out forwards;
}

@keyframes burstOut {
    0% {
        opacity: 0.6;
        transform: rotate(var(--angle)) scaleX(0);
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 0;
        transform: rotate(var(--angle)) scaleX(1) translateX(15px);
    }
}

/* --- Section Background Fractal SVGs --- */
.section-bg-fractal svg {
    position: absolute;
    opacity: 0.12;
    pointer-events: none;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-links {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.75rem;
    }

    .faceted-section:not(.hero-section) {
        padding: 6rem 1.25rem;
    }

    .frost-card {
        padding: 2.5rem 1.5rem;
    }

    .structure-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .crystal-canvas {
        height: 280px;
    }

    .hero-fractal-container {
        width: 350px;
        height: 350px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        display: none;
    }

    .frost-card {
        padding: 2rem 1.25rem;
    }

    .frost-edge {
        width: 50px;
        height: 50px;
    }

    .crystal-canvas {
        height: 220px;
    }
}
