/* Main application styles - extracted from base.html */
/* Note: CSS variables defined in root.css */

/* Accessibility: Skip to content link */
.skip-to-content {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    z-index: 9999;
    font-weight: 600;
    transition: top 0.2s ease;
}

.skip-to-content:focus {
    top: 1rem;
    color: white;
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(174, 140, 252, 0.55);
    outline-offset: 2px;
}

/* Global button reset - remove browser default grey styling */
button {
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
}

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Icon-only narrow mode */
.sidebar {
    width: 64px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.logo i {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.5rem;
}

.nav {
    padding: 0.5rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem;
    margin: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.nav-item i {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
}


.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0.75rem;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.sidebar-footer-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.creator-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0 auto;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}


.creator-cta:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.creator-cta i {
    color: var(--text-muted);
}

.creator-cta:hover i {
    color: var(--text);
}

.network-cta {
    opacity: 0.72;
    transform: scale(0.92);
}

.network-cta:hover {
    opacity: 1;
    transform: scale(0.96);
}

/* Main Content */
.main {
    flex: 1;
    margin-left: 64px;
    min-height: 100vh;
    max-width: calc(100vw - 64px);
    overflow-x: hidden;
}

/* Header */
.header {
    background: rgba(26, 26, 26, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-prop-strip {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.375rem 1rem;
    overflow: hidden;
}

.value-prop-strip-inner {
    max-width: 1200px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transform: translateY(-2px);
    opacity: 0;
    animation: valuePropEnter 520ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.value-prop-kicker {
    font-weight: 700;
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.value-prop-sep {
    color: var(--text-muted);
    opacity: 0.6;
    font-size: 0.9em;
}

.value-prop-tail {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-left: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.value-prop-link {
    color: var(--text);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.value-prop-link:hover {
    color: var(--primary);
}

@keyframes valuePropEnter {
    0% {
        transform: translateY(-4px);
        opacity: 0;
        filter: blur(3px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
        filter: blur(0);
    }
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    width: 100%;
    max-width: 400px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(174, 140, 252, 0.1);
}

.search-box input {
    border: none;
    background: none;
    color: var(--text);
    outline: none;
    width: 100%;
    font-size: 0.9rem;
}

.search-box i { color: var(--text-muted); }

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    transform: translateY(-1px);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
}

/* Content */
.content {
    width: 100%;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

body[data-page="home"] .content,
body[data-page="stories"] .content,
body[data-page="worlds"] .content,
body[data-page="creators"] .content {
    max-width: 1400px;
}
.page-header {
    margin-bottom: 1.5rem;
}

.page-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.page-header .page-title {
    margin-bottom: 0.5rem;
}

.page-header .page-subtitle {
    margin-top: 0;
    font-size: 0.95rem;
}

/* Page Title */
body .page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

body .page-title i {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body { padding: 1.25rem; }

/* Buttons */
body .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    position: relative;
}

body .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 2px 8px rgba(174, 140, 252, 0.25);
}

body .btn-primary:hover {
    box-shadow: 0 4px 16px rgba(174, 140, 252, 0.35);
    transform: translateY(-1px);
}

body .btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(174, 140, 252, 0.25);
}

body .btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

body .btn-success:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

body .btn-secondary {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

body .btn-secondary:hover { background: var(--bg-hover); }

body .btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

body .btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

body .btn-warning {
    background: var(--warning);
    color: #000;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

body .btn-warning:hover {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
    transform: translateY(-1px);
}

body .btn-danger {
    background: var(--error);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

body .btn-danger:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}

/* Button sizes */
body .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

body .btn-large {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Glow Button Effect - Premium CTA styling (§9.15) */
body .btn-glow {
    position: relative;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    animation: btnGlowPulse 2.5s ease-in-out infinite;
}

body .btn-glow:hover {
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.6);
    animation: none;
}

@keyframes btnGlowPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 28px rgba(139, 92, 246, 0.55); }
}

/* Resume button special styling */
body .btn-resume {
    background: linear-gradient(135deg, var(--success), #059669);
}

body .btn-resume:hover { opacity: 0.9; }

/* Disabled button state */
.btn-disabled,
body .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* Header left section */
.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-home-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.mobile-home-btn i {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.25rem;
}

.mobile-home-btn:hover {
    background: var(--bg-hover);
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Credits Balance Pill (§9.2.2 A) */
.credits-pill {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.credits-pill:hover {
    border-color: var(--primary);
    color: var(--text);
}

.credits-pill i {
    color: var(--warning);
    font-size: 0.8rem;
}

.credits-pill.credits-low {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.credits-pill-warning {
    width: 6px;
    height: 6px;
    background: var(--warning);
    border-radius: 50%;
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Session Resume Shortcut (§9.2.2 B) */
.resume-chip {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 20px;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.resume-chip:hover {
    opacity: 0.9;
    color: white;
    transform: scale(1.02);
}

.resume-chip i {
    font-size: 0.7rem;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 200;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg-hover);
}

.user-dropdown a i {
    width: 16px;
    color: var(--text-muted);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* Mobile Bottom Tab Bar (§9.2.3) */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 0.25rem 0;
    padding-bottom: calc(0.25rem + env(safe-area-inset-bottom));
    z-index: 100;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    flex: 1;
    transition: color 0.2s;
}

.mobile-nav-item i {
    font-size: 1.1rem;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item:hover {
    color: var(--text);
}

/* Session Mode - Hide navigation (§9.2.8) */
body.session-mode .sidebar,
body.session-mode .mobile-nav,
body.session-mode .header {
    display: none !important;
}

body.session-mode .main {
    margin-left: 0;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        z-index: 150;
    }
    .main { margin-left: 0; max-width: 100vw; }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .mobile-home-btn { display: flex; }
    .mobile-nav {
        display: flex;
        justify-content: space-around;
    }
    body.has-support-widget .mobile-nav {
        padding-right: calc(44px + 16px + 16px);
    }
    .content {
        padding: 0.5rem;
        padding-bottom: 3rem;
    }
    .header {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 768px) {
    .search-box { width: 140px; padding: 0.375rem 0.75rem; }
    .search-box input { font-size: 0.85rem; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .resume-chip-text { display: none; }
    .credits-pill-balance { font-size: 0.8rem; }
    .header-btn, .user-avatar { width: 36px; height: 36px; }
    .header-actions { gap: 0.5rem; }
    .content {
        padding: 0.75rem;
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
    }
    body.has-support-widget .mobile-nav {
        padding-right: calc(44px + 16px + 16px);
    }
    .header { padding: 0.5rem 0.75rem; }
    .page-title { font-size: 1.1rem; margin-bottom: 0.5rem; }

    .value-prop-strip { padding: 0.3rem 0.5rem; }
    .value-prop-tail { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .value-prop-strip-inner {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

/* Utility classes */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* Skeleton width utilities - for loading states */
.skeleton-w-40 { width: 40%; }
.skeleton-w-60 { width: 60%; }
.skeleton-w-80 { width: 80%; }
.skeleton-w-100 { width: 100%; }
.skeleton-w-120 { width: 120px; }
.skeleton-w-200 { width: 200px; }

/* Skeleton height utilities */
.skeleton-h-sm { height: 1rem; }
.skeleton-h-md { height: 1.5rem; }
.skeleton-h-lg { height: 2rem; }
.skeleton-h-xl { height: 4rem; }

/* Icon color utilities */
.icon-success { color: var(--success); }
.icon-warning { color: var(--warning); }
.icon-error { color: var(--error); }
.icon-primary { color: var(--primary); }

/* Form error message */
.form-error-message {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    padding: 0.625rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Spacing utilities */
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }

/* Text utilities */
.text-sm { font-size: 0.9rem; }

/* ============================================================================
   Shared Animations
   ============================================================================ */

/* Shimmer animation for skeleton loading states */
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton loading utilities */
.skeleton-shimmer {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.skeleton {
    pointer-events: none;
}

/* ============================================================================
   Shared Modal Components
   ============================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    margin: 0;
}

.modal-body {
    padding: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text);
}

.modal-icon {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

.modal-icon-warning {
    color: var(--warning);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* Modal variants for centered content (used in discovery/story-detail) */
.modal-content.centered {
    text-align: center;
    padding: 2rem;
}

.modal-content.centered .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.modal-content.centered h3 {
    margin-bottom: 0.5rem;
}

.modal-content.centered p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.modal-content.centered .modal-actions {
    justify-content: center;
}

/* Modal for pages.css style (uses .modal wrapper) */
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .modal-content,
    .modal {
        max-width: 100%;
        margin: 0.5rem;
    }
}
