/* =============================================================
   xity.one — the one
   Minimalism weaponised with glitch disruption.
   Aurora gradient as living canvas.
   ============================================================= */

/* Custom property registration for smooth gradient interpolation */
@property --aurora-1 {
    syntax: "<color>";
    inherits: false;
    initial-value: #7b2ff7;
}
@property --aurora-2 {
    syntax: "<color>";
    inherits: false;
    initial-value: #00c9a7;
}
@property --aurora-3 {
    syntax: "<color>";
    inherits: false;
    initial-value: #ff6b9d;
}
@property --aurora-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 135deg;
}

:root {
    /* Aurora palette */
    --aurora-violet: #7b2ff7;
    --aurora-teal:   #00c9a7;
    --aurora-rose:   #ff6b9d;
    --void-black:    #08080a;
    --ghost-white:   #f0f0f5;
    --glitch-red:    #ff3333;
    --muted-lavender:#9d8ec7;

    --font-display: "Syne", "Inter", system-ui, sans-serif;
    --font-body:    "Source Sans 3", "Inter", system-ui, sans-serif;
    --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

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

html, body {
    width: 100%;
    min-height: 100%;
    background: var(--void-black);
    color: var(--ghost-white);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
}

body {
    position: relative;
    min-height: 100vh;
}

/* =============================================================
   AURORA BACKGROUND SYSTEM
   ============================================================= */
.aurora {
    position: fixed;
    inset: 0;
    z-index: -3;
    --aurora-1: #7b2ff7;
    --aurora-2: #00c9a7;
    --aurora-3: #ff6b9d;
    --aurora-angle: 135deg;
    background:
        radial-gradient(80% 60% at 20% 25%, color-mix(in oklab, var(--aurora-1), transparent 30%), transparent 70%),
        radial-gradient(70% 70% at 85% 30%, color-mix(in oklab, var(--aurora-2), transparent 35%), transparent 70%),
        radial-gradient(80% 80% at 50% 90%, color-mix(in oklab, var(--aurora-3), transparent 40%), transparent 70%),
        linear-gradient(var(--aurora-angle), var(--aurora-1), var(--aurora-2), var(--aurora-3));
    background-size: 100% 100%, 100% 100%, 100% 100%, 200% 200%;
    background-position: 0 0, 100% 0, 50% 100%, 0 0;
    animation:
        aurora-cycle 30s ease-in-out infinite,
        aurora-pan   45s linear infinite,
        aurora-angle 60s linear infinite;
    filter: saturate(1.05);
}

.aurora::after {
    /* Vignette / void fade at the bottom */
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 90% at 50% 30%, transparent 40%, rgba(8,8,10,0.45) 80%, var(--void-black) 100%),
        linear-gradient(180deg, transparent 60%, rgba(8,8,10,0.85) 95%, var(--void-black) 100%);
    pointer-events: none;
}

@keyframes aurora-cycle {
    0% {
        --aurora-1: #7b2ff7;
        --aurora-2: #00c9a7;
        --aurora-3: #ff6b9d;
    }
    33% {
        --aurora-1: #00c9a7;
        --aurora-2: #ff6b9d;
        --aurora-3: #7b2ff7;
    }
    66% {
        --aurora-1: #ff6b9d;
        --aurora-2: #7b2ff7;
        --aurora-3: #00c9a7;
    }
    100% {
        --aurora-1: #7b2ff7;
        --aurora-2: #00c9a7;
        --aurora-3: #ff6b9d;
    }
}

@keyframes aurora-pan {
    0%   { background-position: 0 0,   100% 0,   50% 100%, 0% 0%; }
    50%  { background-position: 10% 5%, 90% 10%, 45% 95%,  100% 50%; }
    100% { background-position: 0 0,   100% 0,   50% 100%, 0% 100%; }
}

@keyframes aurora-angle {
    0%   { --aurora-angle: 135deg; }
    50%  { --aurora-angle: 195deg; }
    100% { --aurora-angle: 135deg; }
}

/* =============================================================
   SCANLINES + NOISE OVERLAY
   ============================================================= */
.scanlines {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        rgba(0,0,0,0.035) 2px,
        rgba(0,0,0,0.035) 3px
    );
    mix-blend-mode: multiply;
    opacity: 0.7;
}

.noise {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px);
    background-size: 3px 3px, 5px 5px;
    background-position: 0 0, 1px 2px;
    opacity: 0.55;
    mix-blend-mode: overlay;
    animation: noise-jitter 1.6s steps(6) infinite;
}

@keyframes noise-jitter {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-1px, 1px); }
    40%  { transform: translate(1px, -1px); }
    60%  { transform: translate(-2px, 0); }
    80%  { transform: translate(0, 2px); }
    100% { transform: translate(0, 0); }
}

/* =============================================================
   FLOATING BUBBLES
   ============================================================= */
.bubbles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    bottom: -10vh;
    left: var(--b-left, 50%);
    width: var(--b-size, 28px);
    height: var(--b-size, 28px);
    border-radius: 50%;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.22);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: inset 0 0 12px rgba(255,255,255,0.08);
    animation: bubble-rise var(--b-dur, 11s) ease-in var(--b-delay, 0s) infinite;
    will-change: transform, opacity;
}

@keyframes bubble-rise {
    0%   { transform: translateY(20vh) scale(0.5); opacity: 0; }
    10%  { opacity: 0.7; }
    75%  { opacity: 0.7; transform: translateY(-90vh) scale(1); }
    85%  { opacity: 0.4; transform: translateY(-100vh) scale(1.05); }
    100% { transform: translateY(-110vh) scale(0); opacity: 0; }
}

/* =============================================================
   HUD FRAME
   ============================================================= */
.hud {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    color: var(--ghost-white);
}

.hud-tick {
    position: absolute;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(240,240,245,0.4);
}
.hud-tl { top: 18px;    left: 18px;    border-right: none; border-bottom: none; }
.hud-tr { top: 18px;    right: 18px;   border-left:  none; border-bottom: none; }
.hud-bl { bottom: 18px; left: 18px;    border-right: none; border-top:    none; }
.hud-br { bottom: 18px; right: 18px;   border-left:  none; border-top:    none; }

.hud-meta {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: rgba(240,240,245,0.55);
    text-transform: lowercase;
    white-space: nowrap;
}
.hud-meta-tl { top: 24px; left: 58px; }
.hud-meta-tr { top: 24px; right: 58px; }
.hud-meta-bl { bottom: 24px; left: 58px; }
.hud-meta-br { bottom: 24px; right: 58px; }

@media (max-width: 720px) {
    .hud-meta { font-size: 0.62rem; }
    .hud-meta-tr, .hud-meta-br { display: none; }
}

/* =============================================================
   THE SIGNAL (HERO)
   ============================================================= */
.signal {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 0 7vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 1.4rem;
}

.signal-pretitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.18em;
    color: var(--muted-lavender);
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(8px);
    animation: fade-up 1s ease forwards 0.2s;
}

.signal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 9vw, 6.5rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ghost-white);
    text-shadow: 0 2px 30px rgba(8,8,10,0.35);
    display: inline-flex;
    align-items: center;
    gap: 0.05em;
    word-break: break-word;
}

.typewriter {
    display: inline-block;
    white-space: pre;
    font-variation-settings: "wght" 700;
}

.cursor {
    display: inline-block;
    color: var(--ghost-white);
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85em;
    transform: translateY(-0.05em);
    animation: cursor-blink 1.05s steps(2) infinite;
}

@keyframes cursor-blink {
    50% { opacity: 0; }
}

/* Glitch state on the signal title */
.signal-title.is-glitching .typewriter {
    animation: glitch-shake 0.18s steps(4) 1;
    text-shadow:
        2px 0 0 var(--glitch-red),
       -2px 0 0 #00d8ff,
        0 0 18px rgba(255,255,255,0.35);
    color: var(--ghost-white);
}

@keyframes glitch-shake {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-2px, 1px); }
    50%  { transform: translate(2px, -1px); }
    75%  { transform: translate(-1px, 2px); }
    100% { transform: translate(0, 0); }
}

.signal-sub {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    color: rgba(240,240,245,0.78);
    max-width: 38ch;
    opacity: 0;
    transform: translateY(8px);
    animation: fade-up 1s ease forwards 1.2s;
}

@keyframes fade-up {
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================
   THE GRID OF ONE — exactly three panels, asymmetric rhythm
   ============================================================= */
.grid-of-one {
    position: relative;
    z-index: 2;
    padding: 14vh 7vw 18vh;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 4rem 2rem;
    align-items: start;
}

.panel {
    position: relative;
    color: var(--ghost-white);
    padding: 1.6rem 1.6rem 2rem;
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.1, 1);
}

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

.panel-1 {
    grid-column: 1 / span 5;
    margin-top: 0;
}
.panel-2 {
    grid-column: 6 / span 5;
    margin-top: 12vh;
}
.panel-3 {
    grid-column: 3 / span 7;
    margin-top: 6vh;
}

.panel-tag {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted-lavender);
    margin-bottom: 1.2rem;
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 4.2vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--ghost-white);
    margin-bottom: 1.1rem;
    font-variation-settings: "wght" 600;
}

.panel-body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: rgba(240,240,245,0.85);
    max-width: 42ch;
}

.panel-line {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(240,240,245,0.55) 12%,
        rgba(240,240,245,0.55) 88%,
        transparent 100%
    );
}
.panel-line-l { left: 0; }
.panel-line-r { right: 0; }

@media (max-width: 900px) {
    .grid-of-one { gap: 6rem 0; padding-top: 8vh; padding-bottom: 14vh; }
    .panel-1, .panel-2, .panel-3 {
        grid-column: 1 / -1;
        margin-top: 0;
    }
}

/* =============================================================
   THE VOID (FOOTER)
   ============================================================= */
.void {
    position: relative;
    z-index: 2;
    min-height: 60vh;
    padding: 30vh 7vw 6vh;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: linear-gradient(180deg, transparent 0%, rgba(8,8,10,0.6) 55%, var(--void-black) 100%);
}

.void-line {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.16em;
    text-transform: lowercase;
    color: rgba(240,240,245,0.45);
}

/* =============================================================
   GLITCH OVERLAY LAYER
   The full-viewport screen-tear / channel-separation effect.
   Triggered via JS by adding .is-glitching to <body>.
   ============================================================= */
.glitch-layer {
    position: fixed;
    inset: 0;
    z-index: 9;
    pointer-events: none;
    opacity: 0;
}

body.is-glitching .glitch-layer {
    opacity: 1;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 2px,
            rgba(255,255,255,0.04) 2px,
            rgba(255,255,255,0.04) 3px
        );
    animation: glitch-overlay 150ms steps(3) 1;
}

@keyframes glitch-overlay {
    0%   { transform: translate(0, 0); }
    33%  { transform: translate(-8px, 0); clip-path: inset(30% 0 60% 0); }
    66%  { transform: translate(8px, 0);  clip-path: inset(60% 0 30% 0); }
    100% { transform: translate(0, 0); }
}

/* When the body has .is-glitching, also apply channel separation to all text */
body.is-glitching .signal-title,
body.is-glitching .panel-title {
    animation: channel-split 150ms steps(3) 1;
}

@keyframes channel-split {
    0% {
        text-shadow: 0 0 0 transparent;
        transform: translate(0, 0);
    }
    33% {
        text-shadow:
            -2px 0 0 var(--glitch-red),
             2px 0 0 #00d8ff;
        transform: translate(2px, 0);
    }
    66% {
        text-shadow:
             2px 0 0 var(--glitch-red),
            -2px 0 0 #00d8ff;
        transform: translate(-2px, 0);
    }
    100% {
        text-shadow: 0 0 0 transparent;
        transform: translate(0, 0);
    }
}

/* Scroll-triggered horizontal screen-tear */
body.is-tearing::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(50% - 2px),
        var(--glitch-red) calc(50% - 1px),
        rgba(255,255,255,0.6) 50%,
        var(--glitch-red) calc(50% + 1px),
        transparent calc(50% + 2px),
        transparent 100%
    );
    mix-blend-mode: screen;
    animation: tear-shift 150ms steps(2) 1;
}

@keyframes tear-shift {
    0%   { transform: translateX(0); }
    50%  { transform: translateX(-8px); }
    100% { transform: translateX(0); }
}

/* =============================================================
   SELECTION
   ============================================================= */
::selection {
    background: var(--aurora-rose);
    color: var(--void-black);
}

/* =============================================================
   REDUCED MOTION FALLBACK
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
    .aurora { animation: aurora-cycle 60s linear infinite; }
    .noise, .bubbles { display: none; }
    .signal-title.is-glitching .typewriter { animation: none; }
    body.is-glitching .glitch-layer { animation: none; opacity: 0; }
    body.is-glitching .signal-title,
    body.is-glitching .panel-title { animation: none; }
    body.is-tearing::before { animation: none; opacity: 0; }
}
