/* =============================================
   COSMIC CONFESSION — Black Hole Theme
   Theme: Black Hole / Astronaut / Planets
   ============================================= */

:root {
    --bg-void: #030308;
    --bg-deep: #08081a;
    --bg-surface: rgba(12, 12, 30, 0.75);
    --bg-glass: rgba(18, 18, 45, 0.5);
    --amber: #ff9d4a;
    --amber-light: #ffbe85;
    --amber-glow: rgba(255, 157, 74, 0.35);
    --orange-hot: #ff4500;
    --violet: #8b5cf6;
    --violet-deep: #4a0080;
    --cyan: #7dd3fc;
    --rose: #f472b6;
    --teal: #06d6a0;
    --text-primary: #eeeef4;
    --text-secondary: rgba(238, 238, 244, 0.55);
    --text-dim: rgba(238, 238, 244, 0.25);
    --font-display: 'Cormorant Garamond', serif;
    --font-body: 'Space Grotesk', sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg-void);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* --- Canvas --- */
#cosmos { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* --- Glow Overlays --- */
.glow { position: fixed; border-radius: 50%; filter: blur(100px); pointer-events: none; z-index: 1; }
.glow-accretion {
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(255,69,0,0.15) 0%, rgba(139,0,128,0.08) 50%, transparent 70%);
    top: 5%; left: 50%; transform: translateX(-50%);
    animation: glow-pulse 8s ease-in-out infinite;
}
.glow-nebula-1 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, var(--violet) 0%, transparent 70%);
    bottom: -5%; left: -8%; opacity: 0.08;
    animation: glow-drift 25s ease-in-out infinite alternate;
}
.glow-nebula-2 {
    width: 350px; height: 350px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    bottom: 10%; right: -5%; opacity: 0.06;
    animation: glow-drift 30s ease-in-out infinite alternate-reverse;
}
@keyframes glow-pulse {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.15); }
}
@keyframes glow-drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -20px) scale(1.1); }
}

/* =============================================
   ASTRONAUT
   ============================================= */
.astronaut {
    position: fixed; top: 12%; right: 8%; width: 50px; z-index: 5; opacity: 0.55;
    animation: float-astro 12s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(125,211,252,0.15));
}
@keyframes float-astro {
    0%, 100% { transform: translate(0, 0) rotate(-5deg); }
    25% { transform: translate(8px, -18px) rotate(3deg); }
    50% { transform: translate(-6px, -28px) rotate(-8deg); }
    75% { transform: translate(-14px, -12px) rotate(2deg); }
}

/* =============================================
   PLANETS
   ============================================= */
.planet { position: fixed; border-radius: 50%; z-index: 4; pointer-events: none; }
.planet-mars {
    width: 14px; height: 14px; bottom: 22%; left: 8%;
    background: radial-gradient(circle at 35% 30%, #ef9a6e, #c0392b);
    box-shadow: 0 0 12px rgba(192,57,43,0.3);
    animation: float-p1 22s ease-in-out infinite;
}
.planet-saturn {
    width: 18px; height: 18px; top: 35%; left: 5%;
    background: radial-gradient(circle at 35% 30%, #f0c27f, #c9913d);
    box-shadow: 0 0 12px rgba(201,145,61,0.25);
    animation: float-p2 28s ease-in-out infinite;
}
.saturn-ring {
    position: absolute; top: 50%; left: 50%;
    width: 30px; height: 8px;
    border: 1.5px solid rgba(240,194,127,0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotateX(65deg);
}
.planet-neptune {
    width: 10px; height: 10px; bottom: 30%; right: 6%;
    background: radial-gradient(circle at 35% 30%, #60a5fa, #1e40af);
    box-shadow: 0 0 12px rgba(96,165,250,0.3);
    animation: float-p3 18s ease-in-out infinite;
}
@keyframes float-p1 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(20px, -30px); }
    66% { transform: translate(-15px, -15px); }
}
@keyframes float-p2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(25px, 20px); }
}
@keyframes float-p3 {
    0%, 100% { transform: translate(0, 0); }
    40% { transform: translate(-18px, -25px); }
    80% { transform: translate(10px, -10px); }
}

/* =============================================
   BLACK HOLE
   ============================================= */
.black-hole {
    position: relative;
    width: clamp(130px, 28vw, 190px);
    aspect-ratio: 1;
    margin: 0 auto clamp(1.5rem, 4vw, 2.5rem);
}
.accretion-disk {
    position: absolute; inset: -40%;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(255,157,74,0.6), rgba(255,69,0,0.45), rgba(139,0,80,0.25),
        rgba(74,0,130,0.15), rgba(255,100,0,0.3), rgba(255,157,74,0.6));
    filter: blur(14px);
    animation: spin-disk 12s linear infinite;
}
.accretion-disk-inner {
    position: absolute; inset: -15%;
    border-radius: 50%;
    background: conic-gradient(from 180deg,
        rgba(255,190,133,0.5), rgba(255,69,0,0.35), rgba(255,190,133,0.1),
        rgba(255,69,0,0.35), rgba(255,190,133,0.5));
    filter: blur(6px);
    animation: spin-disk 6s linear infinite reverse;
}
@keyframes spin-disk { to { transform: rotate(360deg); } }

.event-horizon {
    position: absolute; inset: 15%;
    border-radius: 50%;
    background: radial-gradient(circle, #000 55%, rgba(0,0,0,0.8) 70%, transparent 100%);
    box-shadow: 0 0 50px 15px rgba(255,100,0,0.15), 0 0 100px 30px rgba(139,0,80,0.08),
                inset 0 0 40px 15px rgba(0,0,0,0.9);
    z-index: 2;
}
.singularity {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    color: var(--amber);
    text-shadow: 0 0 20px var(--amber-glow), 0 0 50px var(--amber-glow);
    z-index: 3;
    animation: pulse-singularity 3s ease-in-out infinite;
}
@keyframes pulse-singularity {
    0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
}

/* Orbit dots */
.orbit-dot {
    position: absolute; top: 50%; left: 50%;
    width: 4px; height: 4px;
    background: var(--amber); border-radius: 50%;
    box-shadow: 0 0 8px var(--amber-glow), 0 0 16px rgba(255,69,0,0.2);
    z-index: 4;
}
.od-1 { animation: orbit-a 3s linear infinite; }
.od-2 { animation: orbit-b 4.5s linear infinite; }
.od-3 { animation: orbit-c 2.2s linear infinite; }
@keyframes orbit-a {
    from { transform: translate(-50%,-50%) rotate(0deg) translateX(clamp(52px,12vw,80px)) rotate(0deg); }
    to   { transform: translate(-50%,-50%) rotate(360deg) translateX(clamp(52px,12vw,80px)) rotate(-360deg); }
}
@keyframes orbit-b {
    from { transform: translate(-50%,-50%) rotate(120deg) translateX(clamp(62px,14vw,95px)) rotate(-120deg); }
    to   { transform: translate(-50%,-50%) rotate(480deg) translateX(clamp(62px,14vw,95px)) rotate(-480deg); }
}
@keyframes orbit-c {
    from { transform: translate(-50%,-50%) rotate(240deg) translateX(clamp(42px,10vw,65px)) rotate(-240deg); }
    to   { transform: translate(-50%,-50%) rotate(600deg) translateX(clamp(42px,10vw,65px)) rotate(-600deg); }
}

/* =============================================
   STATES
   ============================================= */
.state {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 10;
    opacity: 0; visibility: hidden;
    transition: opacity 1.2s var(--ease), visibility 0s 1.2s;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-y: auto;
}
.state.active { opacity: 1; visibility: visible; transition: opacity 1.2s var(--ease), visibility 0s; }

/* =============================================
   LOCKED STATE
   ============================================= */
.lock-container {
    text-align: center;
    max-width: 520px; width: 100%;
    padding: clamp(1rem, 4vw, 2rem);
    z-index: 10;
}
.title {
    font-family: var(--font-display); font-weight: 300;
    margin-bottom: 0.8rem; line-height: 1.15;
}
.title-line {
    display: block;
    font-size: clamp(1.8rem, 5.5vw, 2.8rem);
    letter-spacing: 0.02em;
    opacity: 0; animation: fade-up 1s var(--ease) forwards;
}
.title-line:nth-child(2) { animation-delay: 0.3s; }
.title-line.accent {
    color: var(--amber);
    font-style: italic;
    font-size: clamp(2rem, 6.5vw, 3.2rem);
    text-shadow: 0 0 30px var(--amber-glow);
}
@keyframes fade-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.subtitle {
    font-size: clamp(0.8rem, 2.2vw, 0.95rem);
    color: var(--text-secondary);
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
    line-height: 1.7; letter-spacing: 0.03em;
    opacity: 0; animation: fade-up 1s var(--ease) 0.6s forwards;
}

/* Input */
.input-wrapper {
    position: relative;
    margin-bottom: 1rem;
    opacity: 0; animation: fade-up 1s var(--ease) 0.9s forwards;
}
.input-glow {
    position: absolute; inset: -2px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--amber), var(--orange-hot), var(--violet), var(--amber));
    background-size: 400% 400%;
    animation: glow-rotate 6s linear infinite;
    opacity: 0; transition: opacity 0.5s; z-index: 0;
}
.input-wrapper:focus-within .input-glow { opacity: 0.6; }
@keyframes glow-rotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
#passphrase-input {
    width: 100%;
    padding: clamp(0.8rem, 2.5vw, 1rem) 3.5rem clamp(0.8rem, 2.5vw, 1rem) 1.2rem;
    background: var(--bg-surface);
    border: 1px solid rgba(255,157,74,0.15);
    border-radius: 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    letter-spacing: 0.05em;
    outline: none; position: relative; z-index: 1;
    transition: border-color 0.3s, background 0.3s;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#passphrase-input::placeholder { color: var(--text-dim); font-style: italic; }
#passphrase-input:focus { border-color: rgba(255,157,74,0.4); background: rgba(12,12,30,0.9); }
#submit-btn {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 44px; height: 44px;
    border: none; border-radius: 10px;
    background: linear-gradient(135deg, var(--amber), var(--orange-hot));
    color: var(--bg-void); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s var(--bounce), box-shadow 0.3s;
}
#submit-btn:hover { transform: translateY(-50%) scale(1.05); box-shadow: 0 4px 20px var(--amber-glow); }
#submit-btn:active { transform: translateY(-50%) scale(0.95); }

/* Error */
.error-msg {
    color: var(--rose); font-size: clamp(0.75rem, 2vw, 0.85rem);
    min-height: 1.5rem; margin-bottom: 0.5rem;
    opacity: 0; transition: opacity 0.4s;
}
.error-msg.visible { opacity: 1; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%, 55%, 85% { transform: translateX(-6px); }
    35%, 75% { transform: translateX(6px); }
}
.input-wrapper.shake { animation: shake 0.5s ease-in-out; }

/* Hint */
.hint-btn {
    background: none;
    border: 1px solid rgba(125,211,252,0.15);
    border-radius: 20px;
    color: var(--cyan); font-family: var(--font-body);
    font-size: clamp(0.7rem, 2vw, 0.8rem);
    padding: 0.4rem 1.2rem; cursor: pointer;
    display: inline-flex; align-items: center; gap: 0.5rem;
    transition: all 0.3s;
    opacity: 0; animation: fade-up 1s var(--ease) 1.2s forwards;
}
.hint-btn:hover { background: rgba(125,211,252,0.08); border-color: rgba(125,211,252,0.3); }
.hint-icon {
    width: 18px; height: 18px; border-radius: 50%;
    border: 1px solid var(--cyan);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 600;
}
.hint-box {
    margin-top: 1rem; padding: 0.8rem 1.2rem;
    background: var(--bg-glass);
    border: 1px solid rgba(125,211,252,0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    font-size: clamp(0.78rem, 2vw, 0.85rem);
    color: var(--text-secondary); line-height: 1.7;
    transition: opacity 0.5s, transform 0.5s var(--ease);
}
.hint-box.hidden { opacity: 0; transform: translateY(-10px); pointer-events: none; }

/* =============================================
   UNLOCKED STATE
   ============================================= */
.confession-container {
    max-width: 640px; width: 100%;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    text-align: center; z-index: 10;
}
.confession-header { margin-bottom: clamp(1.5rem, 5vw, 3rem); }
.constellation-icon { margin-bottom: 1.5rem; opacity: 0; }
.const-star { animation: pulse-singularity 3s ease-in-out infinite; }
.const-star:nth-child(2) { animation-delay: 0.5s; }
.const-star:nth-child(3) { animation-delay: 1s; }
.const-star:nth-child(4) { animation-delay: 1.5s; }
.const-star:nth-child(5) { animation-delay: 2s; }
.const-star:nth-child(6) { animation-delay: 2.5s; }
.confession-title {
    font-family: var(--font-display); font-weight: 300;
    font-size: clamp(1.6rem, 5vw, 2.5rem);
    color: var(--amber);
    text-shadow: 0 0 40px var(--amber-glow);
    letter-spacing: 0.03em; opacity: 0;
}
.confession-body {
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 3vw, 1.35rem);
    font-weight: 300; line-height: 2;
    color: var(--text-primary);
    margin-bottom: clamp(1.5rem, 5vw, 3rem);
}
.confession-body .word {
    display: inline-block; opacity: 0; transform: translateY(8px);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
    margin: 0 0.15em;
}
.confession-body .word.visible { opacity: 1; transform: translateY(0); }
.confession-body .word.glow { color: var(--amber-light); text-shadow: 0 0 15px var(--amber-glow); }
.confession-body .line-break { display: block; height: 0.8em; }
.confession-footer { opacity: 0; }
.signature-line {
    width: 60px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--amber), transparent);
    margin: 0 auto 1rem;
}
.signature {
    font-family: var(--font-display); font-style: italic;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: var(--text-secondary); letter-spacing: 0.05em;
}

/* =============================================
   AUDIO TOGGLE
   ============================================= */
.audio-toggle {
    position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 100;
    width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid rgba(238,238,244,0.1);
    background: var(--bg-glass); color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s;
}
.audio-toggle:hover { border-color: rgba(255,157,74,0.3); color: var(--amber); }
.audio-toggle .hidden { display: none; }

/* Flash overlay */
.flash-overlay {
    position: fixed; inset: 0;
    background: radial-gradient(circle at center, var(--amber-glow), rgba(255,69,0,0.15) 40%, transparent 70%);
    z-index: 50; opacity: 0; pointer-events: none;
    animation: flash 1.8s var(--ease) forwards;
}
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 0.7; } 100% { opacity: 0; } }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .astronaut { width: 38px; top: 8%; right: 5%; opacity: 0.4; }
    .planet-saturn { top: 28%; }
    .glow-accretion { width: 350px; height: 350px; }
}
@media (max-width: 480px) {
    .astronaut { width: 30px; top: 6%; right: 4%; opacity: 0.3; }
    .planet-mars { width: 10px; height: 10px; }
    .planet-saturn { width: 13px; height: 13px; }
    .saturn-ring { width: 22px; height: 6px; }
    .planet-neptune { width: 8px; height: 8px; }
    .glow-accretion { width: 250px; height: 250px; }
}
@media (max-width: 380px) {
    .astronaut { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-void); }
::-webkit-scrollbar-thumb { background: rgba(255,157,74,0.2); border-radius: 3px; }
::selection { background: rgba(255,157,74,0.3); color: var(--text-primary); }

/* =============================================
   MEMORY POPUPS
   ============================================= */
.memory-popup {
    position: fixed; z-index: 20;
    padding: 8px 8px 30px 8px;
    background: #e4e4e7;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 20px rgba(255,157,74,0.2);
    opacity: 0; transform: scale(0.8) translateY(20px);
    transition: opacity 1s var(--ease), transform 1s var(--ease);
    pointer-events: none;
    max-width: 220px;
}
.memory-popup.visible {
    opacity: 1; transform: scale(1) translateY(0);
}
.memory-popup img {
    width: 100%; height: auto;
    border-radius: 2px;
    display: block;
}
@media (max-width: 768px) {
    .memory-popup { max-width: 160px; }
}
@media (max-width: 480px) {
    .memory-popup {
        max-width: 130px;
        z-index: 5; /* Behind text on very small screens */
        opacity: 0 !important;
    }
    .memory-popup.visible {
        opacity: 0.25 !important; /* Faint on mobile */
    }
}
