/* ==========================================================================
   planes.css — Planar Taxonomy (cosmology wheel)
   Load AFTER /css/site.css (uses its :root variables and body styles)
   planes.js sets --stage-w / --stage-h / --u on #cosmology.
   ========================================================================== */

/* --- Page header --- */
.planes-header {
    position: absolute; top: 10px; left: 14px;
    z-index: 5;
    pointer-events: none;
}
.planes-header a {
    pointer-events: auto;
    color: var(--gold);
    font-size: 0.75rem;
    text-decoration: none;
}
/* the link out is a travel plaque (site.css) */
.planes-header { --travel-accent: var(--gold); --travel-ink: #e0e0e0; --travel-bg: #000000; --travel-bg2: #0e1626; }
.planes-header a.travel-link { font-size: 0.72rem; }
.planes-header h1 {
    margin: 4px 0 0;
    font-family: var(--font-fantasy);
    color: var(--gold);
    font-size: 1rem;
}

/* --- Stage (an ellipse that fills the screen) --- */
#cosmology {
    --u: 500; /* scale unit in px, set by planes.js */
    position: relative;
    width: 100vw; height: 100vh;
    background: #000;
    overflow: hidden;
}

.astral-sea,
.void-ring {
    position: absolute; left: 50%; top: 50%;
    width: var(--stage-w, 96vmin);
    height: var(--stage-h, 96vmin);
    transform: translate(-50%, -50%);
    border-radius: 50%;
}

.astral-sea {
    overflow: hidden;
    background: radial-gradient(circle, #1a4a6e 0%, #0c2744 42%, #071018 78%, #000 100%);
    box-shadow: inset 0 0 60px rgba(80, 180, 255, 0.35);
    animation: sea 14s ease-in-out infinite alternate,
               sea-breathe 9s ease-in-out infinite;
}
@keyframes sea { to { filter: hue-rotate(18deg) brightness(1.12); } }

/* The sea breathes: it swells and settles, and a lighter tide rises and falls inside it */
@keyframes sea-breathe {
    0%, 100% { transform: translate(-50%, -50%) scale(0.995); }
    50%      { transform: translate(-50%, -50%) scale(1.02); }
}
.astral-sea::before {
    content: '';
    position: absolute; inset: 0;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 50%,
        rgba(120, 200, 255, 0.30) 0%, rgba(60, 140, 210, 0.12) 38%, transparent 66%);
    animation: sea-swell 9s ease-in-out infinite;
}
@keyframes sea-swell {
    0%, 100% { transform: scale(0.78); opacity: 0.35; }
    50%      { transform: scale(1.06); opacity: 1; }
}
/* The sea is a link to its own page (astral-sea.html) */
a.astral-sea { display: block; cursor: pointer; text-decoration: none; }
a.astral-sea:hover span,
a.astral-sea:focus-visible span {
    color: rgba(200, 235, 255, 0.95);
    text-shadow: 0 0 12px rgba(124, 200, 255, 0.8);
}
a.astral-sea:focus-visible { outline: 1px solid rgba(124, 200, 255, 0.6); }
.astral-sea span {
    position: absolute; left: 50%; top: 0.9rem;
    transform: translateX(-50%);
    color: rgba(150, 210, 255, 0.5);
    font-family: var(--font-fantasy);
    font-size: 0.7rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.void-ring {
    border: 2px solid #2a2a2a;
    box-shadow: 0 0 0 100vmax #000;
    pointer-events: none;
}
.void-ring a {
    position: absolute; left: 50%; bottom: -1.2rem;
    transform: translateX(-50%);
    color: #444;
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    white-space: nowrap;
    text-decoration: none;
    pointer-events: auto; /* the ring itself ignores the mouse; its label is a link */
    transition: color 0.3s ease, text-shadow 0.3s ease;
}
/* The label, or anywhere in the black beyond the sea, opens Non-existence (planes.js) */
.void-ring a:hover,
.void-ring a:focus-visible,
#cosmology.void-hover .void-ring a {
    color: #8fb4ff;
    text-shadow: 0 0 10px rgba(80, 120, 255, 0.8);
}

/* ==========================================================================
   Energy beams (drawn by planes.js)
   Each beam = a tapered ribbon (thick at the inner plane, thin at the outer
   one) + a thin core line with sparks flowing from inner to outer plane.
   ========================================================================== */
.plane-links {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* The Astral Sea's own effects (lights, storms, crystals, the Portal of Portals,
   the wind of change and the reality barrier). Created by planes.js right after
   .void-ring, so it draws over the sea and the ring but under the beams. */
.sea-fx {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Per-plane effects drawn by planes.js (Delenthor's tendril, Pandemonium's funnel, ...) */
.plane-fx {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

.beam { transition: opacity 0.35s ease; }
#cosmology.focus .beam { opacity: 0.12; }
#cosmology.focus .beam.active { opacity: 1; }

.beam-core {
    fill: none;
    stroke: rgba(255, 255, 255, 0.85);
    stroke-width: 1;
    stroke-linecap: round;
    stroke-dasharray: 2 12;
    animation: beam-flow var(--flow, 2s) linear infinite;
}
@keyframes beam-flow { to { stroke-dashoffset: -28; } }

/* ==========================================================================
   Bubbles (position and size are set by planes.js)
   Every bubble takes its look from --accent; individual planes below.
   ========================================================================== */
.bubble {
    --accent: #ffd700;
    --glow: color-mix(in srgb, var(--accent) 38%, transparent);
    position: absolute; z-index: 2;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    padding: 6px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(8, 12, 22, 0.82);
    border: 1.5px solid var(--accent);
    box-shadow: 0 0 12px var(--glow), inset 0 0 18px color-mix(in srgb, var(--accent) 12%, transparent);
    box-sizing: border-box;
    backdrop-filter: blur(4px);
    will-change: left, top;
    user-select: none;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.bubble h3 {
    margin: 0 0 3px;
    color: var(--accent);
    font-family: var(--font-fantasy);
    font-size: clamp(0.55rem, calc(var(--u) * 0.0225px), 0.95rem);
}
.bubble p {
    margin: 0;
    font-size: clamp(0.5rem, calc(var(--u) * 0.0195px), 0.75rem);
    line-height: 1.25;
    max-width: 92%;
}
.bubble:hover {
    z-index: 4;
    box-shadow: 0 0 26px color-mix(in srgb, var(--accent) 70%, transparent),
                inset 0 0 22px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Canvas inside a bubble for effects that happen within the plane (added by planes.js).
   The text sits above it. */
.bubble-fx {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}
.bubble > h3,
.bubble > p { position: relative; z-index: 1; }

/* --- Plane types --- */
.core-plane { z-index: 3; }

/* Minor planes show only a title and are wrapped by the Ethereal Realm:
   a faded ghost bubble around each of them. */
.minor-plane { padding: 0; overflow: visible; }
.minor-plane h3 {
    margin: 0;
    font-size: clamp(0.5rem, calc(var(--u) * 0.0165px), 0.8rem);
    line-height: 1.1;
}
.minor-plane::before {
    content: '';
    position: absolute; inset: -18%;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(205, 228, 255, 0) 56%,
        rgba(205, 228, 255, 0.17) 70%,
        rgba(205, 228, 255, 0.05) 100%);
    animation: ghost-breathe 7s ease-in-out infinite alternate;
}
@keyframes ghost-breathe {
    from { opacity: 0.45; transform: scale(0.96); }
    to   { opacity: 1;    transform: scale(1.05); }
}

/* ==========================================================================
   Individual planes
   ========================================================================== */

/* Axon Core: gold anchor with a slowly turning ring of law */
[data-id="axon"] {
    --accent: #ffd700;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.26) 0%, rgba(60, 40, 0, 0.78) 80%);
    border-width: 2px;
    box-shadow: 0 0 34px rgba(255, 215, 0, 0.5), inset 0 0 30px rgba(255, 215, 0, 0.22);
}
[data-id="axon"]::after {
    content: '';
    position: absolute; inset: 5px;
    border: 1px dashed rgba(255, 215, 0, 0.55);
    border-radius: 50%;
    pointer-events: none;
    animation: spin 40s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Keeps the text readable over the effects drawn inside these planes */
[data-id="axon"] p, [data-id="carceri"] p, [data-id="pandemonium"] p,
[data-id="arcadia"] p, [data-id="auryon"] p, [data-id="oros"] p { text-shadow: 0 0 4px #000, 0 0 2px #000; }

/* Auryon (Zaenta): pure knowledge, bright blue, double rim */
[data-id="auryon"] {
    --accent: #4dd2ff;
    background: radial-gradient(circle, rgba(77, 210, 255, 0.22), rgba(5, 20, 45, 0.88) 75%);
    border-style: double; border-width: 4px;
}

/* Bytopia (Ralios / Rhaius): order and freedom, split in two */
[data-id="bytopia"] {
    --accent: #ffc44d;
    background: linear-gradient(135deg, rgba(255, 196, 77, 0.28) 50%, rgba(77, 214, 160, 0.28) 50%), rgba(8, 12, 22, 0.85);
    border-color: #ffc44d #4dd6a0 #4dd6a0 #ffc44d;
    border-width: 2px;
}

/* Arcadia: ungoverned, open to all gods; soft and dotted.
   planes.js changes --accent live while a visiting god reshapes it. */
[data-id="arcadia"] {
    --accent: #f2c28b;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 18%, transparent), rgba(30, 20, 20, 0.7) 80%);
    border-style: dotted; border-width: 3px;
}

/* Elysium (Aletha): white-energy rest, pearl */
[data-id="elysium"] {
    --accent: #f6f3e7;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.24), rgba(25, 28, 40, 0.8) 80%);
    box-shadow: 0 0 22px rgba(255, 255, 255, 0.4), inset 0 0 24px rgba(255, 255, 255, 0.2);
}

/* Added by planes.js for the rare split second when Elysium cracks */
[data-id="elysium"].fracturing { animation: elysium-fracture 0.65s steps(1) forwards; }
@keyframes elysium-fracture {
    0%       { transform: translate(-50%, -50%); filter: brightness(1.7); }
    12%      { transform: translate(calc(-50% + 2px), calc(-50% - 1px)); filter: brightness(0.7) contrast(1.4); }
    24%      { transform: translate(calc(-50% - 1px), calc(-50% + 1px)); filter: brightness(1.35); }
    38%      { transform: translate(-50%, -50%); filter: brightness(0.85); }
    52%      { transform: translate(calc(-50% + 1px), -50%); filter: brightness(1.2); }
    70%, 100% { transform: translate(-50%, -50%); filter: none; }
}

/* Pandemonium (Ae'lith): souls bound to no god, pale violet */
[data-id="pandemonium"] {
    --accent: #b9a6e8;
    background: radial-gradient(circle at 50% 30%, rgba(185, 166, 232, 0.22), rgba(14, 10, 28, 0.9) 80%);
    border-style: double; border-width: 4px;
}

/* Added by planes.js while the white funnel arrives */
[data-id="pandemonium"].funnel-active { animation: soul-surge 3.4s ease-in-out; }
@keyframes soul-surge {
    0%, 100% {
        border-color: var(--accent);
        box-shadow: 0 0 12px var(--glow), inset 0 0 18px color-mix(in srgb, var(--accent) 12%, transparent);
    }
    55% {
        border-color: #fff;
        box-shadow: 0 0 42px 10px rgba(255, 255, 255, 0.7), inset 0 0 40px rgba(255, 255, 255, 0.45);
    }
}

/* Drypnos: imagination, blue and green that never settle */
[data-id="drypnos"] {
    --accent: #38d6c4;
    background: linear-gradient(120deg, rgba(40, 120, 255, 0.35), rgba(40, 220, 130, 0.35), rgba(40, 120, 255, 0.35)) 0 0 / 250% 250%, rgba(8, 12, 22, 0.85);
    animation: drift 9s ease-in-out infinite alternate;
}
@keyframes drift { to { background-position: 100% 100%, 0 0; } }

/* Carceri: the 1000 Faces, unstable and flickering */
[data-id="carceri"] {
    --accent: #c07be0;
    background: radial-gradient(circle, rgba(192, 123, 224, 0.18), rgba(15, 8, 22, 0.9) 80%);
    border-style: dashed; border-width: 2px;
    animation: flicker 3.3s steps(1) infinite;
}
/* Added by planes.js as the chains lock tight */
[data-id="carceri"].shackled { animation: flicker 3.3s steps(1) infinite, shackle-jolt 0.45s ease-out; }
@keyframes shackle-jolt {
    0%   { transform: translate(-50%, -50%) scale(1); }
    20%  { transform: translate(-50%, -50%) scale(0.94); }
    45%  { transform: translate(calc(-50% + 1.5px), -50%) scale(0.97); }
    70%  { transform: translate(calc(-50% - 1px), -50%) scale(0.99); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes flicker {
    0%, 100% { opacity: 1; }   8% { opacity: 0.78; }  10% { opacity: 1; }
    47% { opacity: 1; }       48% { opacity: 0.6; }   50% { opacity: 1; }
    81% { opacity: 0.85; }    83% { opacity: 1; }
}

/* Arborea (Phy'rae): emotional vitality, living green.
   planes.js changes --accent live to match how it feels about nearby planes. */
[data-id="arborea"] {
    --accent: #3fcf8e;
    background: radial-gradient(circle at 50% 70%, color-mix(in srgb, var(--accent) 28%, transparent), rgba(5, 22, 28, 0.88) 80%);
}

/* Gehenna (Osius): chance, yellow burning into red */
[data-id="gehenna"] {
    --accent: #ffb300;
    background: linear-gradient(160deg, rgba(255, 220, 0, 0.3), rgba(255, 60, 20, 0.34)), rgba(15, 8, 4, 0.85);
    border-color: #ff7a1a;
}

/* Nine Hells (The Old King): black and red desolation */
[data-id="hells"] {
    --accent: #d1121f;
    background: radial-gradient(circle, rgba(70, 5, 5, 0.9), rgba(5, 0, 0, 0.96) 85%);
    border-width: 2.5px;
    box-shadow: 0 0 22px rgba(209, 18, 31, 0.5), inset 0 0 26px rgba(120, 0, 0, 0.6);
}
[data-id="hells"] h3 { text-shadow: 0 0 8px rgba(209, 18, 31, 0.8); }
/* The rim smoulders; the flames themselves are drawn by planes.js */
[data-id="hells"] { animation: hellfire-rim 1.3s ease-in-out infinite alternate; }
@keyframes hellfire-rim {
    0%   { border-color: #d1121f; }
    60%  { border-color: #ff5a1a; }
    100% { border-color: #ff9a2a; }
}

/* Oros Aeterna (Helm): a grey-blue bastion, thick and plain */
[data-id="oros"] {
    --accent: #86a3bd;
    background: radial-gradient(circle, rgba(134, 163, 189, 0.16), rgba(10, 16, 24, 0.92) 85%);
    border-width: 5px;
}

/* Dracarus: dragons and dragonborn, scaled bronze */
[data-id="dracarus"] {
    --accent: #e0832f;
    background:
        radial-gradient(circle at 50% 100%, transparent 0 42%, rgba(224, 131, 47, 0.3) 43% 48%, transparent 49%) 0 0 / 14px 10px,
        radial-gradient(circle, rgba(120, 50, 10, 0.4), rgba(14, 8, 4, 0.9) 85%);
}

/* Beastlands (Ta'asis): primal growth, earthy green */
[data-id="beastlands"] {
    --accent: #8bc34a;
    background: radial-gradient(circle at 40% 60%, rgba(139, 195, 74, 0.26), rgba(30, 22, 8, 0.9) 80%);
}

/* Elemental planes */
[data-id="fire"]  { --accent: #ff5a1f; background: radial-gradient(circle at 50% 80%, rgba(255, 90, 31, 0.4), rgba(25, 5, 0, 0.9) 80%); }
[data-id="air"]   { --accent: #a9defa; background: radial-gradient(circle, rgba(169, 222, 250, 0.2), rgba(10, 20, 32, 0.8) 80%); border-width: 1px; }
[data-id="water"] { --accent: #2f86e8; background: radial-gradient(circle at 50% 30%, rgba(47, 134, 232, 0.35), rgba(2, 10, 32, 0.9) 80%); }
[data-id="earth"] { --accent: #a37b45; background: radial-gradient(circle at 50% 80%, rgba(163, 123, 69, 0.34), rgba(20, 14, 6, 0.92) 80%); border-width: 2.5px; }

/* Material planes */
[data-id="equespir"] {
    --accent: #5fd65f;
    background: radial-gradient(circle at 50% 60%, rgba(95, 214, 95, 0.26), rgba(6, 24, 8, 0.9) 80%);
}
[data-id="jhorun"] {
    --accent: #cfd8e3;
    background: radial-gradient(circle, rgba(207, 216, 227, 0.12), rgba(12, 14, 20, 0.92) 85%);
    border-width: 1px;
    outline: 1px solid rgba(207, 216, 227, 0.45); outline-offset: 4px;
}
[data-id="delenthor"] {
    --accent: #9a96a6;
    background: radial-gradient(circle at 72% 28%, #000 0 20%, transparent 21%), radial-gradient(circle, rgba(154, 150, 166, 0.18), rgba(10, 8, 16, 0.92) 85%);
    border-style: dashed;
}

/* Minor planes */
[data-id="shadow"] {
    --accent: #8a5cf6;
    background: radial-gradient(circle, #000 35%, #1a0d33 100%);
}
[data-id="fey"] {
    --accent: #ff7ad9;
    background: radial-gradient(circle, rgba(255, 122, 217, 0.26), rgba(28, 8, 26, 0.88) 80%);
    animation: shimmer 8s ease-in-out infinite alternate;
}
@keyframes shimmer { to { filter: hue-rotate(40deg) brightness(1.15); } }

/* Planes that have their own page (data-href): a small arrow shows they open one */
.bubble.has-page::after {
    content: '\2197';
    position: absolute; top: 12%; right: 16%;
    font-size: 0.7rem;
    color: var(--accent);
    opacity: 0.7;
}
.bubble.has-page:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Hovering the black beyond the sea (class set by planes.js) */
#cosmology.void-hover { cursor: pointer; }

/* ==========================================================================
   Visual quality tiers (html[data-quality], fx-quality.js)
   Light: the sea keeps its breathing but not its colour drift (a filter on a
   screen-sized element, redone every frame), and the bubbles never blur what
   is behind them (the PixiJS interiors replace that blur anyway once ready).
   ========================================================================== */
html[data-quality="light"] .astral-sea { animation: sea-breathe 9s ease-in-out infinite; }
html[data-quality="light"] .bubble { backdrop-filter: none; -webkit-backdrop-filter: none; }

/* ==========================================================================
   Phones (planes.js sets #cosmology.phone on phone-sized screens, upright or
   on their side): the bubbles show only their names, sized to fit (fitNames);
   a tap opens the plane's card at the bottom, with its description, its lore
   and, for planes with their own page, a button to enter it.
   ========================================================================== */
#cosmology.phone .bubble { padding: 2px; }
#cosmology.phone .bubble p { display: none; }
#cosmology.phone .bubble h3 {
    margin: 0;
    line-height: 1.05;
    max-width: 96%;
    hyphens: auto;
    text-shadow: 0 0 4px #000, 0 0 2px #000;
}
#cosmology.phone .astral-sea span { top: 2.6rem; font-size: 0.6rem; }

.plane-card {
    --accent: #ffd700;
    position: fixed;
    left: 10px; right: 10px; bottom: 10px;
    z-index: 50;
    max-height: 46vh;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 16px 18px 14px;
    background: rgba(6, 10, 22, 0.94);
    border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
    border-radius: 14px;
    box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--text-color);
    animation: plane-card-in 0.25s ease-out;
}
.plane-card[hidden] { display: none; }
@keyframes plane-card-in { from { opacity: 0; transform: translateY(16px); } }
.plane-card h2 {
    margin: 0 36px 6px 0;
    font-family: var(--font-fantasy);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0.06em;
}
.plane-card p { margin: 0 0 8px; line-height: 1.45; font-size: 0.95rem; }
.plane-card-short { font-style: italic; color: #cfdaf0; }
.plane-card-lore { color: #b9c6dc; }
.plane-card-close {
    position: absolute; top: 8px; right: 10px;
    width: 32px; height: 32px;
    background: none;
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 1.2rem; line-height: 1;
    cursor: pointer;
}
.plane-card-enter {
    display: block;
    margin: 6px 0 0 auto;
    padding: 8px 16px;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: var(--accent);
    font-family: var(--font-fantasy);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    cursor: pointer;
}
.plane-card-enter[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .plane-card { animation: none; } }
