/* 1. Premium Theme Engine & Typography */
:root {
    --bg-color: #f4f4f5; 
    --panel-bg: #ffffff; 
    --text-main: #0f1115; 
    --text-muted: #52525b;
    --input-bg: #ffffff;
    --input-border: #d4d4d8;
    --btn-bg: #0f1115;
    --btn-text: #ffffff;
    --primary-glow: #9333ea; 
    --glass-border: rgba(0, 0, 0, 0.12); 
    --panel-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    --dot-color: rgba(0, 0, 0, 0.24); 
}

.dark-mode {
    color-scheme: dark; 
    --bg-color: #000000; 
    --panel-bg: #050505; 
    --text-main: #f4f4f5; 
    --text-muted: #a1a1aa;
    --input-bg: #000000;
    --input-border: #27272a;
    --btn-bg: #f4f4f5;
    --btn-text: #000000;
    --primary-glow: #00FFFF; 
    --glass-border: rgba(255, 255, 255, 0.1); 
    --panel-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
    --dot-color: rgba(255, 255, 255, 0.08); 
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--dot-color) 1px, transparent 1px);
    background-size: 24px 24px;
    color: var(--text-main);
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- THEME TOGGLE BUTTON --- */
.theme-btn {
    position: absolute; top: 20px; right: 20px; z-index: 100;
    background: var(--panel-bg); color: var(--text-main);
    border: 1px solid var(--glass-border);
    width: 44px; height: 44px; border-radius: 50%;
    font-size: 1.2rem; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    line-height: 1; padding-bottom: 2px; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: all 0.3s ease;
}
.theme-btn:hover { 
    transform: translateY(-2px); 
    border-color: var(--primary-glow);
    box-shadow: 0 0 12px var(--primary-glow); 
}

/* --- CORE UTILITIES --- */
.hidden { display: none !important; }
.text-center { text-align: center; }

/* --- STRUCTURAL CONTAINERS --- */
.screen {
    position: absolute; top: 0; left: 0; width: 100%; min-height: 100vh;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 1rem; animation: fadeIn 0.4s ease-out; z-index: 10;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- DASHBOARD ARCHITECTURE --- */
.diagnostic-panel {
    background: var(--panel-bg); border: 1px solid var(--glass-border); border-radius: 12px;
    padding: 2.5rem; width: 100%; max-width: 850px; margin: 0 auto;
    box-shadow: var(--panel-shadow); transition: all 0.3s ease; position: relative; 
}

.panel-header { margin-bottom: 2rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 1rem; }
.form-title { font-size: 1.8rem; font-weight: 800; margin: 0; letter-spacing: -0.5px; }
.form-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-top: 0.25rem; }

.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }

@media (min-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 2rem 1.5rem; }
    .full-width { grid-column: 1 / -1; }
    .panel-header { text-align: left; }
}

.form-group { display: flex; flex-direction: column; gap: 0.6rem; text-align: left; }
.form-group-sub { margin-top: 0.5rem; padding-left: 1rem; border-left: 2px solid var(--primary-glow); }

label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }

input[type="text"], input[type="number"], select, textarea {
    width: 100%; padding: 0.85rem 1rem; margin: 0;
    background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 6px;
    color: var(--text-main); font-size: 1rem; font-family: inherit; outline: none; transition: all 0.3s ease;
}

/* Locked Horizontal Textarea Constraint */
textarea {
    resize: vertical;
    min-height: 100px;
}

input:focus, select:focus, textarea:focus { 
    border-color: var(--primary-glow); 
    box-shadow: 0 0 0 1px var(--primary-glow); 
}
select option { background-color: var(--bg-color); color: var(--text-main); }

/* Custom Inputs */
.radio-group { display: flex; gap: 1.5rem; align-items: center; height: 44px; }
.radio-label, .checkbox-label {
    display: flex; align-items: center; gap: 8px; margin: 0;
    cursor: pointer; color: var(--text-main); font-size: 0.95rem; font-weight: 500;
}
input[type="radio"], input[type="checkbox"] { margin: 0; width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary-glow); }
.checkbox-text { font-size: 0.85rem; line-height: 1.4; color: var(--text-muted); padding-top: 1px; text-transform: none !important; }

/* Primary Button */
.cyber-button {
    margin-top: 1.5rem; padding: 1rem; background: var(--btn-bg); color: var(--btn-text);
    border: 1px solid var(--btn-bg); border-radius: 6px;
    font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; 
    width: 100%; text-transform: uppercase; letter-spacing: 1px;
}
.cyber-button:hover { border-color: var(--primary-glow); box-shadow: 0 0 12px var(--primary-glow); }

.error-text { color: #ef4444; margin-bottom: 1rem; font-weight: bold; font-size: 2rem; }

/* --- SVG GRAPHIC ANIMATION --- */
#initial-load-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: #09090b; display: flex; justify-content: center; align-items: center;
    z-index: 9999; transition: opacity 0.6s ease-out; 
}
#node-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; opacity: 0.6; }

#jester-container { 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    z-index: 2; width: 160px; height: 160px; 
}
.jester-original { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; }
.jester-wireframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    filter: drop-shadow(0 0 5px #00FFFF); clip-path: circle(0% at 50% 50%);
}
.wire-path { fill: none; stroke-dasharray: 100; stroke-dashoffset: 100; }

.is-animating .jester-original { animation: ignitePurple 0.6s cubic-bezier(0.25, 1, 0.5, 1) 3.5s forwards; }
.is-animating .jester-wireframe { animation: maskReveal 3.5s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.is-animating .wire-path { animation: drawWire 3.5s cubic-bezier(0.65, 0, 0.35, 1) forwards; }

@keyframes maskReveal {
    0% { clip-path: circle(0% at 50% 50%); opacity: 1; }
    35% { clip-path: circle(100% at 50% 50%); opacity: 1; } 
    65% { clip-path: circle(100% at 50% 50%); opacity: 1; } 
    100% { clip-path: circle(0% at 50% 50%); opacity: 1; } 
}
@keyframes drawWire { 0% { stroke-dashoffset: 100; } 40% { stroke-dashoffset: 0; } 60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 100; } }
@keyframes ignitePurple {
    0% { opacity: 0; transform: scale(0.9); filter: drop-shadow(0 0 0px #A855F7); }
    50% { opacity: 1; transform: scale(1.08); filter: drop-shadow(0 0 4px #A855F7) drop-shadow(0 0 16px #A855F7); } 
    100% { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 2px #A855F7) drop-shadow(0 0 8px #A855F7); } 
}
@media (min-width: 768px) { #jester-container { width: 280px; height: 280px; } }

/* --- LOADING DISCLAIMER --- */
.loading-disclaimer {
    position: absolute !important; bottom: 35px !important; left: 50% !important;
    width: 90%; max-width: 400px; text-align: center;
    color: rgba(255, 255, 255, 0.4); font-size: 0.75rem; letter-spacing: 0.5px;
    z-index: 10; pointer-events: none;
    opacity: 0; transform: translate(-50%, 10px); transition: opacity 1s ease-out, transform 1s ease-out;
}
#jester-container.is-animating ~ .loading-disclaimer { opacity: 1; transform: translate(-50%, 0); }

/* ========================================== */
/* PROCESSING & ANSWER PAGES                  */
/* ========================================== */

#post-form-flow {
    --local-dot: rgba(0, 0, 0, 0.08); 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 50; overflow: hidden; 
    background-color: var(--bg-color); 
    background-image: radial-gradient(var(--local-dot) 1px, transparent 1px); background-size: 24px 24px;
    opacity: 0; transition: opacity 0.6s ease; touch-action: none; overscroll-behavior: none;
}
.dark-mode #post-form-flow { --local-dot: rgba(255, 255, 255, 0.05); }

#theme-toggle-2 {
    position: fixed; top: 20px; right: 20px; z-index: 100;
    opacity: 0; pointer-events: none; 
    /* Merged transitions correctly to fix hover snapping */
    transition: all 0.3s ease, opacity 0.6s ease;
}
#theme-toggle-2.show-toggle { opacity: 1; pointer-events: auto; }

/* --- PROCESSING CANVAS --- */
#processing-canvas {
    position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 10; display: flex; justify-content: center; align-items: center; transition: opacity 0.6s ease;
}
#post-node-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
.jargon-container { position: relative; z-index: 5; }
.jargon-text {
    font-family: inherit; font-size: 1rem; font-weight: 600; color: var(--text-muted); 
    text-transform: uppercase; letter-spacing: 2px; opacity: 1; transition: opacity 0.4s ease; text-align: center;
}

/* --- ANSWER FLOW (HARDWARE SCROLL) --- */
#answer-flow {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; 
    transition: opacity 0.6s ease; overflow: hidden; overscroll-behavior: none;
}
#scroll-track {
    width: 100%; height: 200vh; transform: translateY(0); transition: transform 1.2s cubic-bezier(0.65, 0, 0.35, 1);
}
.view-panel {
    width: 100%; height: 100vh; position: relative; display: flex; justify-content: center; align-items: center; flex-direction: column;
}

.reveal-btn {
    width: auto; padding: 1.2rem 3rem; font-size: 1.1rem; letter-spacing: 2px;
    opacity: 0; transform: translateY(10px); pointer-events: none; transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.reveal-btn.show-btn { opacity: 1; transform: translateY(0); pointer-events: auto; }

.punchline-container { width: 90%; max-width: 800px; z-index: 5; display: flex; flex-direction: column; align-items: center; }
.punchline-title {
    font-size: clamp(1.8rem, 4vw, 3.5rem); font-weight: 900; color: var(--text-main);
    text-transform: uppercase; letter-spacing: -1px; margin-bottom: 2rem; line-height: 1.2; text-align: center;
}
.punchline-media {
    width: 100%; 
    max-width: 280px; 
    height: 280px;
    object-fit: contain;
    box-shadow: var(--panel-shadow); 
    border: 1px solid var(--glass-border);
    opacity: 0; 
    transition: opacity 0.8s ease;
}

.punchline-media.show-media {
    opacity: 1; 
}

/* --- FEEDBACK TRIGGER & BUBBLE --- */
.feedback-trigger-container { position: fixed; bottom: 30px; right: 30px; z-index: 100; }

.feedback-icon {
    background: var(--panel-bg); color: var(--text-main); border: 1px solid var(--glass-border);
    border-radius: 50%; width: 50px; height: 50px; font-size: 1.4rem; cursor: pointer; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: flex; justify-content: center; align-items: center; transition: all 0.3s ease;
}
.feedback-icon:hover { transform: scale(1.05); border-color: var(--primary-glow); box-shadow: 0 0 12px var(--primary-glow); }

.speech-bubble {
    background: var(--panel-bg); color: var(--text-main);
    padding: 8px 14px; border-radius: 30px; 
    font-size: 0.75rem; font-weight: 600; line-height: 1.3;
    border: 1px solid var(--glass-border); box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: absolute; bottom: 65px; right: 25px; 
    text-align: center; width: max-content; max-width: 220px;
    will-change: transform; 
    animation: floatBubble 4s ease-in-out infinite;
}

.speech-bubble::after {
    content: ''; position: absolute; bottom: -5px; right: 15px; left: auto;
    transform: rotate(45deg); width: 10px; height: 10px; background: var(--panel-bg);
    border-right: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border);
}

@keyframes floatBubble {
    0% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -5px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

/* --- LED JESTER SUBMISSION INDICATOR --- */
.led-jester {
    width: 85px; height: 85px; display: flex; justify-content: center; align-items: center;
    pointer-events: none; animation: ledScale 2s infinite alternate ease-in-out;
    position: relative;
}

.led-jester svg { width: 100%; height: 100%; overflow: visible; position: relative; z-index: 1; }
.led-jester svg path { animation: ledColorPulse 2s infinite alternate ease-in-out; }

@keyframes ledScale {
    0% { transform: scale(0.95); }
    100% { transform: scale(1.05); }
}

@keyframes ledColorPulse {
    0% { 
        fill: #00FFFF; 
        filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 15px #00FFFF) drop-shadow(0 0 30px #00FFFF); 
    }
    100% { 
        fill: #A855F7; 
        filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 15px #A855F7) drop-shadow(0 0 30px #A855F7); 
    }
}

/* --- FEEDBACK MODAL --- */
#feedback-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 100; display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
}
#feedback-modal-overlay.show-modal { opacity: 1; pointer-events: auto; }

.feedback-modal {
    background: var(--panel-bg); border: 1px solid var(--glass-border); padding: 2.5rem 2rem; 
    border-radius: 12px; width: 90%; max-width: 420px; box-shadow: var(--panel-shadow); position: relative;
    transform: translateY(20px); transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}
#feedback-modal-overlay.show-modal .feedback-modal { transform: translateY(0); }

.modal-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 1.2rem; line-height: 1.2; letter-spacing: -0.5px; }

.close-btn {
    position: absolute; top: 12px; right: 18px; background: none; border: none;
    font-size: 1.8rem; color: var(--text-muted); cursor: pointer; transition: color 0.2s;
}
.close-btn:hover { color: var(--text-main); }

#punchline-title {
    text-transform: none !important;
    font-size: 2.8rem !important;
    font-weight: 630 !important;
    line-height: 1.5;
    margin-bottom: 25px;
}