/* ==========================================================================
   DreamLab Forum — Design System Foundation
   Tailwind utility classes are handled by the Play CDN in dev
   and by Tailwind CLI tree-shaking in production.

   Shared design tokens (glass-card, mesh-bg, aurora-shimmer, ambient-orb,
   candy-gradient, skeleton, gradient-text, hover-lift, neon-pulse,
   gradient-border, scrollbar-none, fade-in) are loaded from:
     design-tokens.css  (co-located copy of src/styles/design-tokens.css)
   ========================================================================== */

/* design-tokens.css is loaded via <link data-trunk> in index.html.
   Trunk content-hashes CSS filenames, so @import cannot resolve the
   original name at runtime. Do NOT re-add an @import here. */

/* ---------------------------------------------------------------------------
   1. CSS Custom Properties (forum-specific aliases)
   --------------------------------------------------------------------------- */

:root {
    /* Legacy aliases — kept for forum components that reference these directly */
    --amber-glow: var(--dl-glow-ambient);
    --amber-glow-strong: var(--dl-glow-strong);
    --card-bg: var(--dl-card-bg);
    --card-border: var(--dl-card-border);
    --glass-bg: var(--dl-glass-bg);
    --glass-border: var(--dl-glass-border);
}

/* ---------------------------------------------------------------------------
   2. Base Reset & Typography
   --------------------------------------------------------------------------- */

body {
    margin: 0;
    padding: 0;
    background-color: #111827;
    color: #f9fafb;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* Selection */
::selection {
    background: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

/* Focus rings */
*:focus-visible {
    outline: 2px solid #f59e0b;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   3. Loading Screen
   --------------------------------------------------------------------------- */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #111827;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loading-logo {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin: 0;
    animation: gradient-shift 3s ease-in-out infinite;
    background-size: 200% 200%;
}

.loading-status {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #9ca3af;
    letter-spacing: 0.05em;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.loading-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(245, 158, 11, 0.1);
    border-top-color: #f59e0b;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ---------------------------------------------------------------------------
   4. Animations
   --------------------------------------------------------------------------- */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* ---------------------------------------------------------------------------
   5. Utility Classes
   NOTE: glass-card, gradient-text, skeleton, hover-lift, fade-in
         are now provided by design-tokens.css
   --------------------------------------------------------------------------- */

/* Glassmorphism — heavier blur variant (forum-specific) */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

/* Fade in for DM bubbles */
.animate-fadeIn {
    animation: dl-fade-in 0.3s ease-out;
}

/* Toast slide-in */
@keyframes slide-in-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-in-down {
    animation: slide-in-down 0.25s ease-out;
}

/* Subtle float for empty states */
@keyframes gentle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.animate-gentle-float {
    animation: gentle-float 3s ease-in-out infinite;
}

/* Amber glow on hover */
.glow-hover {
    transition: box-shadow 0.2s ease;
}

.glow-hover:hover {
    box-shadow: var(--amber-glow);
}

/* ---------------------------------------------------------------------------
   6. Form Elements
   --------------------------------------------------------------------------- */

input:focus,
textarea:focus,
select:focus {
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.5);
    border-color: rgba(245, 158, 11, 0.5);
}

/* ---------------------------------------------------------------------------
   7. Scrollbar
   --------------------------------------------------------------------------- */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #111827;
}

::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 9999px;
    border: 2px solid #111827;
}

::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.15);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #374151 #111827;
}

/* scrollbar-none is provided by design-tokens.css */

/* ---------------------------------------------------------------------------
   8–14. Shared visual effects
   NOTE: ambient-orb, glass-card-interactive, gradient-border, aurora-shimmer,
         neon-pulse, candy-gradient, mesh-bg, animate-ambient-breathe
         are now provided by design-tokens.css
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   15. Toast Notifications
   --------------------------------------------------------------------------- */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 400px;
}

.toast-item {
    pointer-events: auto;
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3),
                0 0 40px rgba(0, 0, 0, 0.1);
    animation: toast-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-item.toast-success {
    border-color: rgba(34, 197, 94, 0.3);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.08);
}

.toast-item.toast-error {
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.08);
}

.toast-item.toast-warning {
    border-color: rgba(245, 158, 11, 0.3);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.08);
}

.toast-item.toast-exit {
    animation: toast-exit 0.2s ease-in forwards;
}

@keyframes toast-enter {
    from { opacity: 0; transform: translateX(100%) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-exit {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(100%) scale(0.95); }
}

/* ---------------------------------------------------------------------------
   16. Modal Overlay
   --------------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: modal-fade-in 0.2s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-panel {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4),
                0 0 80px rgba(245, 158, 11, 0.05);
    animation: modal-scale-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
    width: min(90vw, 480px);
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ---------------------------------------------------------------------------
   17. Reaction Particle Burst
   --------------------------------------------------------------------------- */

.reaction-burst {
    position: relative;
    display: inline-flex;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-burst:active {
    transform: scale(1.3);
}

.reaction-burst.is-active {
    color: #fbbf24;
}

.reaction-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fbbf24;
    animation: reaction-fly 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes reaction-fly {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx, 20px), var(--dy, -20px)) scale(0); }
}

/* ---------------------------------------------------------------------------
   18. Typing Indicator
   --------------------------------------------------------------------------- */

.typing-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------------------------------------------------------------------------
   19. Mobile Bottom Navigation
   --------------------------------------------------------------------------- */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(55, 65, 81, 0.3);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: none;
}

@media (max-width: 639px) {
    .mobile-bottom-nav {
        display: flex;
    }

    /* Account for bottom nav height on mobile */
    main {
        padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
    }
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    gap: 0.125rem;
    color: #6b7280;
    transition: color 0.15s ease;
    position: relative;
    font-size: 0.625rem;
    letter-spacing: 0.025em;
}

.mobile-nav-item.active {
    color: #f59e0b;
}

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: #f59e0b;
    border-radius: 0 0 2px 2px;
}

/* ---------------------------------------------------------------------------
   20. Link Preview Cards
   --------------------------------------------------------------------------- */

.link-preview-card {
    border: 1px solid rgba(55, 65, 81, 0.4);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(31, 41, 55, 0.4);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 480px;
}

.link-preview-card:hover {
    border-color: rgba(245, 158, 11, 0.2);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.06);
}

/* ---------------------------------------------------------------------------
   21. Virtual Scroll Container
   --------------------------------------------------------------------------- */

.virtual-scroll {
    overflow-y: auto;
    will-change: transform;
    -webkit-overflow-scrolling: touch;
    contain: layout style;
}

/* ---------------------------------------------------------------------------
   22. Notification Badge
   --------------------------------------------------------------------------- */

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    border-radius: 9999px;
    background: #ef4444;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #111827;
    animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* ---------------------------------------------------------------------------
   23. Identicon Avatar
   --------------------------------------------------------------------------- */

.avatar-identicon {
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
    border: 2px solid rgba(245, 158, 11, 0.15);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.avatar-identicon:hover {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}

/* ---------------------------------------------------------------------------
   24. Emoji Picker Grid
   --------------------------------------------------------------------------- */

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-btn {
    padding: 4px;
    border-radius: 6px;
    font-size: 1.25rem;
    line-height: 1;
    text-align: center;
    cursor: pointer;
    transition: background 0.1s ease, transform 0.1s ease;
    border: none;
    background: transparent;
}

.emoji-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    transform: scale(1.15);
}

/* ---------------------------------------------------------------------------
   25. Breadcrumb Navigation
   --------------------------------------------------------------------------- */

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    color: #9ca3af;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.5rem 0;
}

.breadcrumb-nav a {
    color: #9ca3af;
    transition: color 0.15s ease;
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: #fbbf24;
}

.breadcrumb-separator {
    color: #4b5563;
    font-size: 0.75rem;
}

/* ---------------------------------------------------------------------------
   26. Global Search Overlay
   --------------------------------------------------------------------------- */

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    animation: modal-fade-in 0.15s ease-out;
}

.search-panel {
    width: min(90vw, 600px);
    background: rgba(17, 24, 39, 0.98);
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 16px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.4),
                0 0 120px rgba(245, 158, 11, 0.03);
    animation: modal-scale-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

/* ---------------------------------------------------------------------------
   27. Confirm Dialog
   --------------------------------------------------------------------------- */

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ---------------------------------------------------------------------------
   28. Category / Section Cards (Forum Index)
   --------------------------------------------------------------------------- */

.category-hero-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 160px;
}

.category-hero-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 28px rgba(245, 158, 11, 0.1),
                0 12px 40px rgba(0, 0, 0, 0.3);
}

.section-list-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.section-list-card:hover {
    border-color: rgba(245, 158, 11, 0.25);
    background: rgba(31, 41, 55, 0.7);
}

/* ---------------------------------------------------------------------------
   29. Event Cards
   --------------------------------------------------------------------------- */

.event-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.08);
}

.event-date-badge {
    width: 3.5rem;
    text-align: center;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    padding: 0.375rem;
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   30. Profile Modal
   --------------------------------------------------------------------------- */

.profile-avatar-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, #fbbf24, #f97316, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-ring > div {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Reduced-motion: disable all ambient animations
   --------------------------------------------------------------------------- */

/* Reduced-motion for forum-specific animations
   (shared tokens handle their own reduced-motion rules) */
@media (prefers-reduced-motion: reduce) {
    .typing-dot,
    .reaction-particle {
        animation: none !important;
    }
}
