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

:root {
    --bg: #f4f1ec;
    --fg: #1a1a1a;
    --fg-dim: #666;
    --fg-dimmer: #999;
    --accent: #1a1a1a;
    --font-serif: 'Cormorant Garamond', Georgia, serif;
    --font-mono: 'Share Tech Mono', monospace;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-serif);
    overflow: hidden;
}

/* Paper texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

#scene {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

/* Title */
#title-wrap {
    margin-bottom: 28px;
    text-align: center;
    position: relative;
    z-index: 3;
}

h1 {
    font-family: var(--font-serif);
    font-weight: 300;
    font-size: clamp(2.2rem, 5vw, 3.8rem);
    letter-spacing: 0.18em;
    color: var(--fg);
    text-transform: uppercase;
    line-height: 1;
    position: relative;
}

h1.glitch {
    animation: glitch-seq 0.18s steps(1) forwards;
}

@keyframes glitch-seq {
    0%   { transform: translate(0); clip-path: none; }
    15%  { transform: translate(-2px, 1px); clip-path: inset(20% 0 60% 0); }
    30%  { transform: translate(2px, -1px); clip-path: inset(60% 0 10% 0); }
    45%  { transform: translate(-1px, 0); clip-path: inset(40% 0 30% 0); color: #888; }
    60%  { transform: translate(1px, 1px); clip-path: none; }
    75%  { transform: translate(0, -1px); }
    100% { transform: translate(0); clip-path: none; }
}

h1::before, h1::after {
    content: attr(data-text);
    position: absolute;
    left: 0; top: 0; width: 100%;
    pointer-events: none;
    opacity: 0;
}

h1.glitch::before {
    opacity: 0.5;
    color: #aaa;
    transform: translate(-3px, 0);
    clip-path: inset(0 0 70% 0);
    animation: glitch-before 0.18s steps(1) forwards;
}

h1.glitch::after {
    opacity: 0.4;
    color: #555;
    transform: translate(3px, 0);
    clip-path: inset(60% 0 0 0);
    animation: glitch-after 0.18s steps(1) forwards;
}

@keyframes glitch-before {
    0%,100% { opacity: 0; }
    20%, 60% { opacity: 0.5; }
}
@keyframes glitch-after {
    0%,100% { opacity: 0; }
    30%, 70% { opacity: 0.4; }
}

.title-sub {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.4em;
    color: var(--black);
    text-transform: uppercase;
    margin-top: 14px;
    display: block;
    background-color: burlywood;
}

/* Orrery */
#orrery {
    position: relative;
    width: 100%;
    height: 56vh;
    max-height: 620px;
}

/* faint orbit rings */
#orrery-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#orrery-nodes {
    position: absolute;
    inset: 0;
    z-index: 2;
    perspective: 1100px;
    transform-style: preserve-3d;
}

/* Project / video node */
.orb {
    position: absolute;
    left: 0;
    top: 0;
    width: 150px;
    height: 150px;
    margin-left: -75px;
    margin-top: -75px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    border-radius: 50%;
    border: 1px solid rgba(26, 26, 26, 0.55);
    background: radial-gradient(circle at 38% 32%, rgba(255,255,255,0.55), rgba(244,241,236,0.18) 60%, rgba(244,241,236,0) 78%);
    box-shadow: 0 6px 26px rgba(0,0,0,0.07), inset 0 0 22px rgba(255,255,255,0.25);
    color: var(--fg);
    cursor: pointer;
    will-change: transform, opacity;
    transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

.orb:hover,
.orb:focus-visible {
    border-color: rgba(26, 26, 26, 0.9);
    box-shadow: 0 10px 34px rgba(0,0,0,0.16), inset 0 0 26px rgba(255,255,255,0.4);
    background: radial-gradient(circle at 38% 32%, rgba(255,255,255,0.75), rgba(244,241,236,0.3) 60%, rgba(244,241,236,0) 80%);
    outline: none;
}

.orb-title {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 1.18rem;
    letter-spacing: 0.06em;
    line-height: 1.05;
    padding: 0 14px;
    color: var(--fg);
}

.orb-sub {
    font-family: var(--font-mono);
    font-size: 0.52rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--fg-dim);
    margin-top: 8px;
    max-width: 88%;
    opacity: 0.55;
    transition: opacity 0.35s ease;
}

.orb:hover .orb-sub,
.orb:focus-visible .orb-sub { opacity: 1; }

/* Moon — satellite linking to a sub-page section */
.moon {
    position: absolute;
    left: 0;
    top: 0;
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    border-radius: 50%;
    border: 1px solid rgba(26, 26, 26, 0.5);
    background: radial-gradient(circle at 38% 32%, rgba(255,255,255,0.6), rgba(244,241,236,0.15) 65%, rgba(244,241,236,0) 82%);
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    will-change: transform, opacity;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.moon:hover,
.moon:focus-visible {
    border-color: rgba(26, 26, 26, 0.9);
    box-shadow: 0 5px 18px rgba(0,0,0,0.18);
    outline: none;
}

.moon-label {
    position: absolute;
    left: 50%;
    top: calc(100% + 6px);
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.5rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-dim);
    background: rgba(244, 241, 236, 0.78);
    padding: 2px 6px;
    border-radius: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.moon:hover .moon-label,
.moon:focus-visible .moon-label { opacity: 1; }

/* Corner decoration */
.corner {
    position: fixed;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--fg-dimmer);
    letter-spacing: 0.2em;
    opacity: 0.5;
    z-index: 3;
}
.corner-tl { top: 24px; left: 24px; }
.corner-br { bottom: 24px; right: 24px; }

/* Page-exit fade */
#fade-veil {
    position: fixed;
    inset: 0;
    background: var(--bg);
    opacity: 0;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.45s ease;
}
#fade-veil.active { opacity: 1; pointer-events: auto; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    h1.glitch { animation: none; }
    .orb { transition: none; }
    #fade-veil { transition: none; }
}

/* Small screens */
@media (max-width: 560px) {
    .orb { width: 116px; height: 116px; margin-left: -58px; margin-top: -58px; }
    .orb-title { font-size: 0.95rem; }
    #orrery { height: 60vh; }
}
