/* ============================================================
   aiice.quest — A digital sanctum of algorithmic luxury
   Palette: ethereal blue with rare glitch incursions
   Typography: Nunito (rounded-sans, extra-light) + Questrial
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    background: #0a1628;
}

body {
    font-family: 'Questrial', 'Inter', sans-serif;
    font-size: clamp(1rem, 1.15vw, 1.125rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: #e8f0f6;
    background: #0a1628;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

/* ---------- Root tokens ---------- */
:root {
    --void: #0a1628;
    --void-deep: #060d17;
    --mid: #0f2238;
    --atmosphere: #1a3a5c;
    --atmosphere-bright: #2d6187;
    --luminance: #5ba4d9;
    --glow: #8dc4e6;
    --text-primary: #e8f0f6;
    --text-muted: #9db4c8;
    --glitch-magenta: #d94b8a;
    --glitch-chartreuse: #7ae68a;

    --ease-sanctum: cubic-bezier(0.22, 1, 0.36, 1);
    --section-pad: clamp(4rem, 12vw, 12rem);
}

/* ---------- Typography helpers ---------- */
.eyebrow {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(141, 196, 230, 0.6);
    margin-bottom: 2.25rem;
}

.headline {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(1.75rem, 3.5vw, 3rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.25;
    margin-bottom: 3rem;
}

.prose {
    max-width: 680px;
    color: var(--text-muted);
}

.prose p + p {
    margin-top: 1.6rem;
}

/* ============================================================
   THRESHOLD (Hero)
   ============================================================ */
.threshold {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 30% 70%, rgba(91, 164, 217, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 25%, #2d6187 0%, #1a3a5c 22%, #0f2238 55%, #0a1628 85%);
    isolation: isolate;
}

.threshold-breath {
    position: absolute;
    inset: -10%;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(91, 164, 217, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 60%, rgba(141, 196, 230, 0.08) 0%, transparent 60%);
    animation: breathe 12s ease-in-out infinite;
    z-index: -1;
    will-change: transform;
}

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

.threshold-luminescence {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(91, 164, 217, 0.05), transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.threshold-curve {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
    z-index: -1;
    pointer-events: none;
}

.threshold-inner {
    text-align: center;
    padding: 2rem;
    position: relative;
}

.threshold-eyebrow {
    margin-bottom: 4rem;
    animation: fadein 1.6s ease-out 0.3s both;
}

.logotype {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 200;
    font-size: clamp(4rem, 10vw, 9rem);
    letter-spacing: 0.25em;
    text-transform: lowercase;
    color: var(--text-primary);
    line-height: 1;
    padding-left: 0.25em; /* balance letter-spacing visually */
    animation: pulse 6s ease-in-out infinite;
    position: relative;
    will-change: opacity, transform;
}

@keyframes pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

.threshold-tagline {
    font-family: 'Questrial', 'Inter', sans-serif;
    font-size: 1rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-top: 2.5rem;
    opacity: 0;
    animation: fadein 1.6s ease-out 1s forwards;
}

.threshold-line {
    width: 1px;
    height: 80px;
    margin: 5rem auto 1.75rem;
    background: linear-gradient(to bottom, rgba(141, 196, 230, 0.3), transparent);
    opacity: 0;
    animation: fadein 1.6s ease-out 1.5s forwards;
}

.threshold-scrollhint {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(141, 196, 230, 0.35);
    opacity: 0;
    animation: fadein 1.6s ease-out 2s forwards;
}

@keyframes fadein {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Curve Dividers
   ============================================================ */
.divider {
    display: block;
    width: 100%;
    height: clamp(60px, 10vh, 120px);
    line-height: 0;
    overflow: hidden;
}

.divider svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ============================================================
   Panels (shared)
   ============================================================ */
.panel {
    position: relative;
    padding: var(--section-pad) clamp(1.5rem, 20vw, 20vw);
    overflow: hidden;
    isolation: isolate;
}

.panel-void {
    background: #0a1628;
}

.panel-illuminated {
    background: #0f2238;
}

.panel-inner {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.panel-inner-center {
    text-align: center;
}

/* ---------- Panel: Premise ---------- */
.panel-premise {
    min-height: 90vh;
    display: flex;
    align-items: center;
}

.illustration {
    position: absolute;
    pointer-events: none;
    opacity: 0.9;
    z-index: 1;
}

.illustration-neural {
    top: 50%;
    right: -80px;
    transform: translateY(-50%);
    width: clamp(280px, 28vw, 460px);
    height: auto;
    opacity: 0.55;
}

/* ---------- Panel: Depth ---------- */
.panel-depth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
}

.bg-curves {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.06;
    z-index: 1;
    pointer-events: none;
}

.illustration-lattice {
    top: 50%;
    left: -40px;
    transform: translateY(-50%);
    width: clamp(240px, 22vw, 380px);
    height: auto;
    opacity: 0.4;
}

.panel-depth .panel-inner {
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
}

/* ---------- Panel: Revelation ---------- */
.panel-revelation {
    min-height: 80vh;
    display: grid;
    place-items: center;
    padding-top: clamp(4rem, 10vw, 8rem);
    padding-bottom: clamp(4rem, 10vw, 8rem);
    background: #0a1628;
}

.illustration-topo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.18;
    z-index: 1;
    pointer-events: none;
}

.revelation-statement {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 200;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.04em;
    line-height: 1.25;
    color: var(--text-primary);
    max-width: 960px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.revelation-emphasis {
    font-weight: 300;
    color: var(--glow);
    font-style: italic;
    letter-spacing: 0.06em;
}

/* ============================================================
   TERMINUS / RETURN
   ============================================================ */
.terminus {
    background: #060d17;
    min-height: 60vh;
    display: grid;
    place-items: center;
    padding: clamp(4rem, 10vw, 10rem) 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.terminus::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 80%, rgba(91, 164, 217, 0.04), transparent 60%);
    pointer-events: none;
}

.terminus-inner {
    max-width: 680px;
    position: relative;
    z-index: 2;
}

.terminus-line {
    width: 1px;
    height: 80px;
    margin: 0 auto 3rem;
    background: linear-gradient(to top, rgba(141, 196, 230, 0.3), transparent);
}

.terminus-eyebrow {
    margin-bottom: 3rem;
}

.terminus-statement {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(1.25rem, 2.4vw, 1.75rem);
    letter-spacing: 0.08em;
    line-height: 1.7;
    color: var(--text-muted);
    margin-bottom: 4rem;
}

.terminus-word {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 200;
    font-size: clamp(2.25rem, 5vw, 4rem);
    letter-spacing: 0.32em;
    text-transform: lowercase;
    color: var(--glow);
    padding-left: 0.32em;
    margin-bottom: 4rem;
}

.terminus-colophon {
    font-family: 'Nunito', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(141, 196, 230, 0.35);
}

/* ============================================================
   Scroll reveal
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1.2s var(--ease-sanctum), transform 1.2s var(--ease-sanctum);
    will-change: opacity, transform;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   SVG path-draw animation
   ============================================================ */
.draw-group .draw {
    fill: none;
    stroke: var(--luminance);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke-dashoffset 2.5s var(--ease-sanctum);
    will-change: stroke-dashoffset;
}

.illustration-topo .draw-group .draw {
    stroke: #5ba4d9;
    stroke-width: 1.5;
}

/* ============================================================
   GLITCH SYSTEM
   ============================================================ */
.scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 1px;
    background: rgba(217, 75, 138, 0.4);
    box-shadow: 0 0 6px rgba(217, 75, 138, 0.45);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(0);
}

body.glitch-active .scan-line {
    animation: scan 150ms linear;
}

@keyframes scan {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 1; transform: translateY(100vh); }
}

body.glitch-active {
    animation: shiver 150ms steps(3) 1;
}

@keyframes shiver {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-3px); }
    50%  { transform: translateX(4px); }
    75%  { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

body.glitch-active .logotype,
body.glitch-active .headline,
body.glitch-active .revelation-statement,
body.glitch-active .terminus-word {
    text-shadow:
        -2px 0 var(--glitch-magenta),
         2px 0 var(--glitch-chartreuse);
    animation: channel-split 150ms steps(2) 1;
}

@keyframes channel-split {
    0%, 100% {
        text-shadow:
            -2px 0 var(--glitch-magenta),
             2px 0 var(--glitch-chartreuse);
    }
    50% {
        text-shadow:
            -3px 0 var(--glitch-magenta),
             3px 0 var(--glitch-chartreuse);
    }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 780px) {
    .illustration-neural,
    .illustration-lattice {
        opacity: 0.22;
    }

    .panel {
        padding-left: clamp(1.25rem, 6vw, 2rem);
        padding-right: clamp(1.25rem, 6vw, 2rem);
    }

    .logotype {
        letter-spacing: 0.2em;
    }

    .terminus-word {
        letter-spacing: 0.24em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .threshold-breath,
    .logotype {
        animation: none;
    }
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
