/* ─────────────────────────────────────────────────
       CSS VARIABLES
    ───────────────────────────────────────────────── */
:root {
    --bg: #050c14;
    --surface: #080f1a;
    --card: rgba(8, 18, 34, 0.85);
    --border: rgba(0, 212, 170, 0.14);
    --border-warm: rgba(212, 160, 80, 0.2);
    --glow-teal: #00d4aa;
    --glow-rose: #e8956d;
    --accent: #5ee7d0;
    --gold: #d4a050;
    --gold-light: #f0c878;
    --text: #dde8f0;
    --muted: #7a91a8;
    --font-display: "IM Fell English", serif;
    --font-body: "Spectral", serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─────────────────────────────────────────────────
       HEX-GRID BACKGROUND (CSS only, no image)
    ───────────────────────────────────────────────── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.03;
    background-image:
        linear-gradient(
            30deg,
            #00d4aa 12%,
            transparent 12.5%,
            transparent 87%,
            #00d4aa 87.5%,
            #00d4aa
        ),
        linear-gradient(
            150deg,
            #00d4aa 12%,
            transparent 12.5%,
            transparent 87%,
            #00d4aa 87.5%,
            #00d4aa
        ),
        linear-gradient(
            30deg,
            #00d4aa 12%,
            transparent 12.5%,
            transparent 87%,
            #00d4aa 87.5%,
            #00d4aa
        ),
        linear-gradient(
            150deg,
            #00d4aa 12%,
            transparent 12.5%,
            transparent 87%,
            #00d4aa 87.5%,
            #00d4aa
        ),
        linear-gradient(
            60deg,
            rgba(0, 212, 170, 0.15) 25%,
            transparent 25.5%,
            transparent 75%,
            rgba(0, 212, 170, 0.15) 75%,
            rgba(0, 212, 170, 0.15)
        ),
        linear-gradient(
            60deg,
            rgba(0, 212, 170, 0.15) 25%,
            transparent 25.5%,
            transparent 75%,
            rgba(0, 212, 170, 0.15) 75%,
            rgba(0, 212, 170, 0.15)
        );
    background-size: 60px 104px;
    background-position:
        0 0,
        0 0,
        30px 52px,
        30px 52px,
        0 0,
        30px 52px;
    pointer-events: none;
}

/* ─────────────────────────────────────────────────
       AURORA GLOW — top + bottom
    ───────────────────────────────────────────────── */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(
            ellipse 70% 45% at 50% -5%,
            rgba(0, 180, 140, 0.18) 0%,
            transparent 70%
        ),
        radial-gradient(
            ellipse 50% 35% at 100% 100%,
            rgba(212, 100, 60, 0.1) 0%,
            transparent 60%
        ),
        radial-gradient(
            ellipse 40% 40% at 0% 80%,
            rgba(0, 100, 140, 0.12) 0%,
            transparent 60%
        );
}

/* ─────────────────────────────────────────────────
       FLOATING PARTICLES (canvas)
    ───────────────────────────────────────────────── */
#particles {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* ─────────────────────────────────────────────────
       LAYOUT
    ───────────────────────────────────────────────── */
#app {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

/* ─────────────────────────────────────────────────
       SECTION SYSTEM
    ───────────────────────────────────────────────── */
.section {
    display: none;
    width: 100%;
    max-width: 580px;
}

.section.active {
    display: block;
    animation: sectionIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.section.leaving {
    animation: sectionOut 0.35s ease forwards;
}

@keyframes sectionIn {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes sectionOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ─────────────────────────────────────────────────
       CARD
    ───────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2.75rem 2.5rem;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
        0 0 0 1px rgba(0, 212, 170, 0.04),
        0 0 80px rgba(0, 180, 140, 0.07),
        0 2px 50px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(0, 212, 170, 0.07),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* corner accent lines */
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 10%,
        rgba(0, 212, 170, 0.4) 50%,
        transparent 90%
    );
}

.card::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 10%,
        rgba(212, 160, 80, 0.2) 50%,
        transparent 90%
    );
}

/* ─────────────────────────────────────────────────
       ORNAMENTAL SYMBOL
    ───────────────────────────────────────────────── */
.sigil {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 0 10px rgba(0, 212, 170, 0.5));
    animation: sigilFloat 4s ease-in-out infinite;
}

@keyframes sigilFloat {
    0%,
    100% {
        transform: translateY(0px);
        filter: drop-shadow(0 0 10px rgba(0, 212, 170, 0.5));
    }
    50% {
        transform: translateY(-5px);
        filter: drop-shadow(0 0 20px rgba(0, 212, 170, 0.8));
    }
}

/* ─────────────────────────────────────────────────
       TYPOGRAPHY
    ───────────────────────────────────────────────── */
.t-display {
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    line-height: 1.15;
}

.t-label {
    font-family: var(--font-body);
    font-weight: 200;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-size: 0.65rem;
}

.t-body {
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.85;
    color: var(--muted);
    font-size: 1rem;
}

/* ─────────────────────────────────────────────────
       DIVIDER
    ───────────────────────────────────────────────── */
.rune-divider {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 1.6rem 0;
}

.rune-divider::before,
.rune-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 212, 170, 0.3));
}

.rune-divider::after {
    background: linear-gradient(90deg, rgba(0, 212, 170, 0.3), transparent);
}

.rune-divider span {
    font-family: var(--font-display);
    color: var(--accent);
    font-size: 0.9rem;
    opacity: 0.6;
}

/* ─────────────────────────────────────────────────
       BUTTONS
    ───────────────────────────────────────────────── */
.btn-main {
    display: block;
    width: 100%;
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--bg);
    background: linear-gradient(135deg, #00c49a 0%, #00d4aa 50%, #00bfa0 100%);
    border: none;
    border-radius: 0.85rem;
    padding: 1rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 24px rgba(0, 212, 170, 0.35),
        0 4px 20px rgba(0, 0, 0, 0.4);
}

.btn-main::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.15) 0%,
        transparent 50%
    );
    pointer-events: none;
}

.btn-main:hover {
    transform: translateY(-2px);
    box-shadow:
        0 0 40px rgba(0, 212, 170, 0.55),
        0 8px 28px rgba(0, 0, 0, 0.4);
}

.btn-main:active {
    transform: translateY(0);
}

.btn-ghost {
    display: block;
    width: 100%;
    font-family: var(--font-display);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: var(--accent);
    background: transparent;
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: 0.85rem;
    padding: 0.85rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.75rem;
}

.btn-ghost:hover {
    background: rgba(0, 212, 170, 0.06);
    border-color: rgba(0, 212, 170, 0.4);
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.15);
}

/* ─────────────────────────────────────────────────
       TEXT INPUT
    ───────────────────────────────────────────────── */
.input-label {
    display: block;
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.65rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.6rem;
    opacity: 0.75;
}

.name-input {
    width: 100%;
    background: rgba(0, 212, 170, 0.04);
    border: 1px solid rgba(0, 212, 170, 0.18);
    border-radius: 0.85rem;
    padding: 1rem 1.3rem;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 300;
    font-style: italic;
    outline: none;
    transition: all 0.3s ease;
}

.name-input::placeholder {
    color: rgba(122, 145, 168, 0.45);
    font-style: italic;
}

.name-input:focus {
    border-color: rgba(0, 212, 170, 0.5);
    background: rgba(0, 212, 170, 0.06);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

/* ─────────────────────────────────────────────────
       ERROR
    ───────────────────────────────────────────────── */
.error-msg {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-style: italic;
    color: #f87171;
    display: none;
}

/* ─────────────────────────────────────────────────
       PRIVACY NOTE
    ───────────────────────────────────────────────── */
.privacy-note {
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--muted);
    opacity: 0.45;
    text-align: center;
}

/* ─────────────────────────────────────────────────
       LOADING ORB — teal crystal
    ───────────────────────────────────────────────── */
.crystal-orb {
    width: 100px;
    height: 100px;
    margin: 0 auto 2rem;
    position: relative;
}

.crystal-orb-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(
        circle at 30% 28%,
        rgba(150, 255, 230, 0.6),
        rgba(0, 212, 170, 0.25) 45%,
        rgba(0, 80, 70, 0.2) 70%,
        transparent
    );
    border: 1px solid rgba(0, 212, 170, 0.35);
    box-shadow:
        0 0 30px rgba(0, 212, 170, 0.4),
        0 0 70px rgba(0, 212, 170, 0.15),
        inset 0 0 30px rgba(0, 212, 170, 0.12);
    animation: crystalPulse 2.2s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

.crystal-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 170, 0.15);
}

.crystal-ring-1 {
    inset: -10px;
    animation: ringRotate 4s linear infinite;
}

.crystal-ring-2 {
    inset: -22px;
    border-style: dashed;
    border-color: rgba(0, 212, 170, 0.07);
    animation: ringRotate 7s linear infinite reverse;
}

.crystal-ring-3 {
    inset: -38px;
    border-color: rgba(212, 160, 80, 0.05);
    animation: ringRotate 12s linear infinite;
}

@keyframes crystalPulse {
    0%,
    100% {
        box-shadow:
            0 0 30px rgba(0, 212, 170, 0.4),
            0 0 70px rgba(0, 212, 170, 0.15);
        transform: scale(1);
    }
    50% {
        box-shadow:
            0 0 50px rgba(0, 212, 170, 0.65),
            0 0 100px rgba(0, 212, 170, 0.25);
        transform: scale(1.06);
    }
}

@keyframes ringRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Loading text */
#loading-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-style: italic;
    color: var(--accent);
    font-size: 1.05rem;
    letter-spacing: 0.03em;
    min-height: 1.8em;
}

/* ─────────────────────────────────────────────────
       RESULT — BIG NUMBER
    ───────────────────────────────────────────────── */
.result-number-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 180px;
    margin: 0.5rem 0;
}

.result-number {
    font-family: var(--font-display);
    font-size: clamp(5.5rem, 22vw, 9rem);
    line-height: 1;
    background: linear-gradient(
        135deg,
        #40e0c0 0%,
        #00ffcc 30%,
        #00d4aa 60%,
        #b8f0e0 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: numGlow 2.8s ease-in-out infinite;
    position: relative;
    z-index: 3;
}

.result-halo {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 170, 0.12);
}

.result-halo-1 {
    width: 140px;
    height: 140px;
    animation: ringRotate 9s linear infinite;
}
.result-halo-2 {
    width: 180px;
    height: 180px;
    border-style: dashed;
    border-color: rgba(0, 212, 170, 0.06);
    animation: ringRotate 15s linear infinite reverse;
}

@keyframes numGlow {
    0%,
    100% {
        filter: drop-shadow(0 0 16px rgba(0, 212, 170, 0.55));
    }
    50% {
        filter: drop-shadow(0 0 36px rgba(0, 212, 170, 0.9))
            drop-shadow(0 0 60px rgba(0, 212, 170, 0.4));
    }
}

/* ─────────────────────────────────────────────────
       ARCHETYPE TAG
    ───────────────────────────────────────────────── */
.archetype-badge {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--gold-light);
    background: rgba(212, 160, 80, 0.08);
    border: 1px solid rgba(212, 160, 80, 0.22);
    border-radius: 2rem;
    padding: 0.45rem 1.3rem;
}

/* ─────────────────────────────────────────────────
       LETTER MAPPING DISPLAY (result breakdown)
    ───────────────────────────────────────────────── */
.letter-map {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin: 1rem 0;
}

.letter-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 212, 170, 0.06);
    border: 1px solid rgba(0, 212, 170, 0.12);
    border-radius: 0.5rem;
    padding: 0.35rem 0.55rem;
    min-width: 2.4rem;
    animation: chipIn 0.4s ease forwards;
    opacity: 0;
}

@keyframes chipIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.letter-chip .lc-char {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--accent);
    line-height: 1;
}

.letter-chip .lc-num {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 300;
    color: var(--gold);
    line-height: 1;
    margin-top: 2px;
}

/* ─────────────────────────────────────────────────
       TRAIT CARDS
    ───────────────────────────────────────────────── */
.trait-block {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 212, 170, 0.08);
    border-radius: 1rem;
    padding: 1.2rem 1.4rem;
    transition:
        border-color 0.3s ease,
        background 0.3s ease;
}

.trait-block:hover {
    border-color: rgba(0, 212, 170, 0.22);
    background: rgba(0, 212, 170, 0.04);
}

.trait-label {
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.6rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.4rem;
    opacity: 0.65;
}

.trait-content {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.95rem;
    line-height: 1.65;
    color: rgba(221, 232, 240, 0.82);
}

/* ─────────────────────────────────────────────────
       CALC FORMULA
    ───────────────────────────────────────────────── */
.calc-formula {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 200;
    font-style: italic;
    color: var(--muted);
    opacity: 0.55;
    text-align: center;
    letter-spacing: 0.05em;
}

/* ─────────────────────────────────────────────────
       LINK TO LIFE PATH
    ───────────────────────────────────────────────── */
.lifepath-link {
    display: block;
    text-align: center;
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.82rem;
    font-style: italic;
    color: var(--muted);
    opacity: 0.5;
    transition:
        opacity 0.3s ease,
        color 0.3s ease;
    text-decoration: none;
}

.lifepath-link:hover {
    opacity: 1;
    color: var(--accent);
}

.lifepath-link span {
    color: var(--gold);
}

/* ─────────────────────────────────────────────────
       MOBILE
    ───────────────────────────────────────────────── */
@media (max-width: 480px) {
    .card {
        padding: 2rem 1.4rem;
    }
    .result-number-wrap {
        height: 150px;
    }
}
