/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme tokens */
:root {
    --bg: #fafafa;
    --bg-secondary: #f4f4f5;
    --text-main: #09090b;
    --text-muted: #71717a;

    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --grad-1: rgba(99, 102, 241, 0.4);
    --grad-2: rgba(168, 85, 247, 0.3);
    --grad-3: rgba(59, 130, 246, 0.2);

    --true: #10b981;
    --false: #ef4444;
    --partial: #f59e0b;
    --muted: var(--text-muted);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;

    --logo-check-start: #1f2937;
    --logo-check-mid: #4b5563;
    --logo-check-end: #9ca3af;
}

:root[data-theme="dark"] {
    --bg: #050505;
    --bg-secondary: #0f0f11;
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --muted: var(--text-muted);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);

    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    --grad-1: rgba(99, 102, 241, 0.35);
    --grad-2: rgba(139, 92, 246, 0.25);
    --grad-3: rgba(59, 130, 246, 0.15);

    --primary: #818cf8;
    --primary-hover: #a5b4fc;

    --true: #34d399;
    --false: #f87171;
    --partial: #fbbf24;

    --logo-check-start: #ffffff;
    --logo-check-mid: #cbd5e1;
    --logo-check-end: #6b7280;
}

html,
body {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    width: 100%;
    overflow: hidden; /* Prevent body scroll, scroll inside main */
}

body {
    font-family: "Inter", system-ui, sans-serif;
    color: var(--text-main);
    background-color: var(--bg);
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
    position: relative;
}

h1,
h2,
h3,
h4,
h5,
.app-title {
    font-family: "Outfit", system-ui, sans-serif;
}

/* Mystical Cloud WebGL & Particle Canvases */
.webgl-cloud {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none !important;
    z-index: 0;
    opacity: 0.6;
    transition: opacity 2s ease;
    mix-blend-mode: screen;
}

[data-theme="light"] .webgl-cloud {
    mix-blend-mode: multiply;
    opacity: 0.6;
}

.particle-canvas {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none !important;
    z-index: 1;
}

/* Cinematic Reveal Animation */
.results-section.revealing {
    animation: ethereal-reveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes ethereal-reveal {
    0% {
        opacity: 0;
        filter: blur(15px);
        transform: translateY(30px) scale(0.96);
    }
    100% {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0) scale(1);
    }
}

/* App Layout */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    position: relative;
    z-index: 10;
}

/* Header */
.header {
    padding: 20px 24px;
    flex-shrink: 0;
}

.header-content {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    justify-self: center;
}

.brand-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    justify-self: start;
    transform: translateY(-2px);
}

.brand-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    content: url("assets/AD_logo.png");
}

[data-theme="light"] .brand-badge {
    background: #09090b;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .brand-badge {
    background: transparent;
    border-color: transparent;
}

.brand-logo-svg {
    height: 32px;
    width: auto;
    display: block;
    color: var(--text-main);
    transition: color 0.3s ease;
}

.brand-logo-svg .logo-text {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-size: 26px;
    letter-spacing: -0.01em;
}

#themeToggle {
    justify-self: end;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--glass-bg);
    color: var(--text-main);
}

/* Main Scrollable Area */
.main-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

/* Hide scrollbar for a cleaner look */
.main-scrollable::-webkit-scrollbar {
    width: 6px;
}
.main-scrollable::-webkit-scrollbar-track {
    background: transparent;
}
.main-scrollable::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.content-container {
    max-width: 768px;
    width: 100%;
    margin: 0 auto;
    padding-top: 4vh;
    padding-bottom: 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Welcome Section */
.welcome-section {
    text-align: center;
    margin: auto 0;
    padding-bottom: 10vh;
}

.welcome-section h2 {
    font-family: "Cormorant Garamond", serif;
    font-size: 3.8rem;
    font-weight: 500;
    font-style: italic;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

.welcome-section p {
    font-family: "Outfit", system-ui, sans-serif;
    font-size: 1.15rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    opacity: 0.9;
}

/* Bottom Area (Prompt) */
.bottom-area {
    padding: 0 24px 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

.glass-panel {
    max-width: 768px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

.floating-prompt {
    max-width: 768px;
    margin: 0 auto;
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    transition: all 0.3s ease;
}

.floating-prompt .prompt-input {
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    caret-color: var(--primary);
}

.floating-prompt.shattering .prompt-input {
    color: transparent !important;
    text-shadow: none !important;
    caret-color: transparent;
}

.prompt-container {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 12px;
    position: relative;
}

.prompt-container:focus-within {
    /* No visible border to keep it floating seamlessly */
}

/* Dropzone inside prompt */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dropzone {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

/* Textarea */
.textarea-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.prompt-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    padding: 8px 0;
    max-height: 200px;
    overflow-y: auto;
}

.prompt-input:focus {
    outline: none;
}

.prompt-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 2px;
}

.icon-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.submit-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--text-main);
    color: var(--bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    transform: scale(1.05);
    background: var(--primary);
    color: #fff;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hidden-label {
    display: none;
}
.clear-label {
    display: none;
}

.hint {
    text-align: center;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Image Preview */
.image-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 8px;
    gap: 8px;
}

.image-preview .thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border);
}

.image-preview .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(24, 24, 27, 0.72);
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    padding: 0;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-preview .remove i {
    pointer-events: none;
}

.image-preview .remove:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Loading — Cloud Morph Overlay */
.loading-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
    flex: 1;
}

.cloud-loading-overlay {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Thought Bubbles */
.thought-bubbles-container {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.thought-bubble {
    position: absolute;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 10px 18px;
    font-family: "Outfit", sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.12);
    opacity: 0;
    transform: scale(0.5) translateY(10px);
    animation: bubble-pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275)
        forwards;
}

.thought-bubble::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
}

/* Tail positions for different bubble placements */
.thought-bubble.pos-top-left::after {
    bottom: -7px;
    left: 20px;
}
.thought-bubble.pos-top-right::after {
    bottom: -7px;
    right: 20px;
}
.thought-bubble.pos-bottom-left::after {
    top: -7px;
    left: 20px;
}
.thought-bubble.pos-bottom-right::after {
    top: -7px;
    right: 20px;
}
.thought-bubble.pos-left::after {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.thought-bubble.pos-right::after {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.thought-bubble.fading {
    animation: bubble-fade-out 0.4s ease forwards;
}

@keyframes bubble-pop-in {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(10px);
    }
    60% {
        opacity: 1;
        transform: scale(1.08) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes bubble-fade-out {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.7) translateY(-10px);
    }
}

/* Results */
.results-section {
    animation: fade-in 0.5s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    font-weight: 500;
}

.claim-result {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.claim-result::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.claim-result.true::before {
    background: var(--true);
}
.claim-result.false::before {
    background: var(--false);
}
.claim-result.partial::before {
    background: var(--partial);
}

.claim-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-main);
    line-height: 1.5;
}

.verdict {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.verdict.true {
    background: rgba(16, 185, 129, 0.15);
    color: var(--true);
}
.verdict.false {
    background: rgba(239, 68, 68, 0.15);
    color: var(--false);
}
.verdict.partial {
    background: rgba(245, 158, 11, 0.15);
    color: var(--partial);
}

.confidence {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.explanation {
    color: var(--text-main);
    line-height: 1.6;
    font-size: 1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.sources {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--glass-border);
    padding-top: 16px;
}

.source-link {
    color: var(--text-main);
    text-decoration: none;
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.2s;
    border: 1px solid var(--glass-border);
}

.source-link:hover {
    background: var(--glass-bg);
}

.source-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.source-banner a {
    color: var(--primary);
    text-decoration: none;
}
.source-banner a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* ----- Results-mode footer: centered clear button ----- */
.bottom-area.results-mode .prompt-container {
    justify-content: center;
}

.bottom-area.results-mode .upload-section,
.bottom-area.results-mode .textarea-wrapper,
.bottom-area.results-mode .submit-btn {
    display: none !important;
}

.bottom-area.results-mode .action-buttons {
    width: 100%;
    justify-content: center;
    padding-bottom: 0;
}

.bottom-area.results-mode .icon-action-btn {
    width: auto;
    height: auto;
    border-radius: 14px;
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    color: #fff;
    font-family: "Outfit", sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    gap: 10px;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
}

.bottom-area.results-mode .icon-action-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 32px rgba(99, 102, 241, 0.45);
    background: linear-gradient(135deg, var(--primary-hover), #9333ea);
}

.bottom-area.results-mode .clear-label {
    display: inline !important;
}

/* Responsive */
@media (max-width: 600px) {
    .welcome-section h2 {
        font-size: 2.4rem;
    }
    .welcome-section {
        padding-bottom: 4vh;
    }
    .claim-result {
        padding: 16px;
    }
    .bottom-area {
        padding: 0 16px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .bottom-area.results-mode .icon-action-btn {
        padding: 12px 32px;
        font-size: 0.95rem;
    }
    .header {
        padding: 14px 16px;
    }
    .content-container {
        padding-top: 2vh;
        padding-bottom: 20px;
    }
    .hint {
        margin-top: 8px;
        font-size: 0.7rem;
    }
}

/* Force interactive elements to be above everything and clickable */
button,
.icon-btn,
.submit-btn,
.icon-action-btn,
.dropzone,
.prompt-input,
#themeToggle {
    pointer-events: auto !important;
    position: relative;
    z-index: 100 !important;
}
