/* Base Components — mobile menu, legal modals, toasts
   Extracted from base.html inline <style> blocks */

/* Prevent horizontal overflow on mobile */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Pure CSS mobile menu - checkbox hack pattern */
#mobile-menu-toggle {
    display: none;
}

.mobile-menu-toggle-label {
    display: block;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-2xl);
    cursor: pointer;
    padding: var(--space-2);
    z-index: var(--z-fixed);
}

.mobile-menu {
    display: block;
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: var(--space-dark);
    border-left: 1px solid var(--glass-border);
    padding: var(--space-8) var(--space-6);
    transition: right 0.3s ease;
    z-index: var(--z-modal);
    overflow-y: auto;
}

#mobile-menu-toggle:checked ~ .mobile-menu {
    right: 0;
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-medium);
    z-index: var(--z-modal-backdrop);
}

#mobile-menu-toggle:checked ~ .mobile-menu-overlay {
    display: block;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--glass-border);
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-2xl);
    cursor: pointer;
    padding: var(--space-2);
}

.mobile-menu-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-menu-links li {
    margin-bottom: var(--space-4);
}

.mobile-menu-links a {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    font-size: var(--text-lg);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.mobile-menu-links a:hover,
.mobile-menu-links a.active {
    background: var(--glass-bg);
    color: var(--spacex-blue-light);
}

.mobile-menu-signin {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--glass-border);
}

@media (width <= 768px) {
    .nav-links {
        display: none !important;
    }
}

/* Legal Modals (Terms & Privacy) - Pure CSS */
#terms-modal-toggle,
#privacy-modal-toggle {
    display: none;
}

.legal-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-heavy);
    z-index: var(--z-modal);
    overflow-y: auto;
    padding: var(--space-6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#terms-modal-toggle:checked ~ .legal-modal.terms-modal,
#privacy-modal-toggle:checked ~ .legal-modal.privacy-modal {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.legal-modal-content {
    max-width: 800px;
    margin: var(--space-12) auto;
    background: var(--space-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    position: relative;
}

.legal-modal-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--text-2xl);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.legal-modal-close:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

/* Auth Modal - Pure CSS checkbox pattern */
#auth-modal-toggle {
    display: none;
}

.auth-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-heavy);
    z-index: var(--z-modal);
    overflow-y: auto;
    padding: var(--space-6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    justify-content: center;
    align-items: center;
}

#auth-modal-toggle:checked ~ .auth-modal {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.auth-modal-content {
    width: 100%;
    max-width: 400px;
    background: var(--space-gray-900);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-10) var(--space-8);
    position: relative;
    box-shadow: var(--shadow-xl), var(--glow-blue);
}

.auth-modal-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-xl);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.auth-modal-close:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.auth-modal-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-modal-icon {
    font-size: var(--text-3xl);
    color: var(--spacex-blue-light);
    margin-bottom: var(--space-4);
    display: block;
}

.auth-modal-title {
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.auth-modal-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.auth-modal-providers {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.auth-modal-provider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    text-decoration: none;
    transition: all var(--transition-base);
    background: var(--space-gray-800);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.auth-modal-provider:hover {
    transform: var(--hover-lift-sm);
    box-shadow: var(--glow-blue);
    background: var(--space-gray-700);
    border-color: var(--spacex-blue);
    color: var(--text-primary);
}

.auth-modal-provider:active {
    transform: translateY(0);
}

.auth-modal-legal {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-disabled);
    line-height: 1.5;
}

.auth-modal-legal-link {
    color: var(--spacex-blue-light);
    cursor: pointer;
    text-decoration: none;
}

.auth-modal-legal-link:hover {
    text-decoration: underline;
}

@media (width <= 480px) {
    .auth-modal-content {
        padding: var(--space-8) var(--space-6);
        margin: var(--space-4);
        border-radius: var(--radius-xl);
    }
}

/* Sign-in CTA (inline content replacement for unauthenticated users) */
.sign-in-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    padding: var(--space-12) var(--space-8);
    border-radius: var(--radius-xl);
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
}

.sign-in-cta__text {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.sign-in-cta__button {
    cursor: pointer;
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-sm);
}

/* Toast Notifications */
.toast-notification {
    background: var(--space-gray-800);
    border: 1px solid var(--spacex-blue);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    animation: toast-in 0.3s ease forwards;
    text-decoration: none;
    display: block;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-notification:hover {
    border-color: var(--spacex-blue-bright);
    transform: translateX(-4px);
}

.toast-notification--error {
    border-color: var(--color-error);
}

.toast-notification--error:hover {
    border-color: #f87171; /* hardcoded: error hover lighter red */
}

.toast-notification--error .toast-notification__topic {
    color: var(--color-error);
}

.toast-notification.toast-out {
    animation: toast-out 0.3s ease forwards;
}

.toast-notification__topic {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--spacex-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-1);
}

.toast-notification__title {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* ========================================
   Rendered Markdown — theme-aware prose
   Apply .rendered-md to any container
   whose innerHTML comes from | md | safe
   ======================================== */

.rendered-md {
    color: var(--text-secondary);
    line-height: 1.6;
}

.rendered-md p {
    margin: 0 0 var(--space-2);
}

.rendered-md p:last-child { margin-bottom: 0; }

.rendered-md strong,
.rendered-md b {
    color: var(--text-primary);
    font-weight: 600;
}

.rendered-md em,
.rendered-md i:not(.fas, .far, .fab) {
    font-style: italic;
}

.rendered-md a {
    color: var(--spacex-blue-light);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}

.rendered-md a:hover {
    border-bottom-color: var(--spacex-blue-light);
}

.rendered-md h1,
.rendered-md h2,
.rendered-md h3,
.rendered-md h4 {
    margin: 0 0 var(--space-1);
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

.rendered-md h1 { font-size: 1.15em; }

.rendered-md h2 { font-size: 1.1em; }

.rendered-md h3,
.rendered-md h4 { font-size: 1em; }

.rendered-md blockquote {
    margin: var(--space-2) 0;
    padding: var(--space-2) var(--space-4);
    border-left: 3px solid var(--spacex-blue);
    color: var(--text-secondary);
    font-style: italic;
}

.rendered-md blockquote p { margin: 0; }

.rendered-md ul,
.rendered-md ol {
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.rendered-md li { margin-bottom: var(--space-1); }

.rendered-md code {
    background: var(--glass-bg);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

.rendered-md pre {
    background: var(--glass-bg);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: var(--space-2) 0;
}

.rendered-md pre code {
    background: none;
    padding: 0;
}

/* Compact variant — for cards with line-clamp */
.rendered-md-compact {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rendered-md-compact p,
.rendered-md-compact h1,
.rendered-md-compact h2,
.rendered-md-compact h3,
.rendered-md-compact h4,
.rendered-md-compact blockquote,
.rendered-md-compact ul,
.rendered-md-compact ol {
    margin: 0;
    display: inline;
}

.rendered-md-compact br { display: none; }
