/* Staring Platform Design System - Universal Light/Dark Accessibility & High Contrast */

:root, [data-theme="dark"], [data-bs-theme="dark"] {
    --st-primary: #4f46e5;
    --st-primary-hover: #4338ca;
    --st-secondary: #06b6d4;
    --st-bg: #0f172a;
    --st-card-bg: #1e293b;
    --st-text: #f8fafc;
    --st-muted: #94a3b8;
    --st-border: #334155;
    --st-header-bg: rgba(15, 23, 42, 0.95);
    --st-paywall-gradient: linear-gradient(to bottom, rgba(30,41,59,0) 0%, rgba(30,41,59,1) 90%);

    --bs-body-bg: #0f172a;
    --bs-body-color: #f8fafc;
    --bs-secondary-color: #94a3b8;
    --bs-tertiary-bg: #1e293b;
    --bs-border-color: #334155;
}

[data-theme="light"], [data-bs-theme="light"] {
    --st-primary: #4f46e5;
    --st-primary-hover: #4338ca;
    --st-secondary: #06b6d4;
    --st-bg: #f8fafc;
    --st-card-bg: #ffffff;
    --st-text: #0f172a;
    --st-muted: #64748b;
    --st-border: #e2e8f0;
    --st-header-bg: rgba(255, 255, 255, 0.95);
    --st-paywall-gradient: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 90%);

    --bs-body-bg: #f8fafc;
    --bs-body-color: #0f172a;
    --bs-secondary-color: #64748b;
    --bs-tertiary-bg: #ffffff;
    --bs-border-color: #e2e8f0;
}

body {
    background-color: var(--st-bg) !important;
    color: var(--st-text) !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

/* Force text colors according to theme variables */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--st-text) !important;
}

.text-muted, .text-secondary {
    color: var(--st-muted) !important;
}

/* Dynamic Links & Navigation Colors */
.st-nav-link {
    color: var(--st-text) !important;
    text-decoration: none;
    font-weight: 600;
    opacity: 0.85;
    transition: opacity 0.2s ease, color 0.2s ease;
}
.st-nav-link:hover {
    opacity: 1;
    color: var(--st-primary) !important;
}

.st-post-title {
    color: var(--st-text) !important;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s ease;
}
.st-post-title:hover {
    color: var(--st-primary) !important;
}

/* List group styling for high contrast */
.list-group-item {
    background-color: transparent !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}

/* Form Controls in Light & Dark Modes */
.form-control, .form-select {
    background-color: var(--st-card-bg) !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}
.form-control:focus, .form-select:focus {
    background-color: var(--st-card-bg) !important;
    color: var(--st-text) !important;
    border-color: var(--st-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
}
.form-control::placeholder {
    color: var(--st-muted) !important;
    opacity: 0.8;
}

/* Header & Sticky Navbar */
.st-header {
    background: var(--st-header-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--st-border);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.st-logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--st-text) !important;
    text-decoration: none;
}
.st-logo span {
    color: var(--st-primary) !important;
}

/* Cards & Posts Grid */
.st-card {
    background-color: var(--st-card-bg) !important;
    color: var(--st-text) !important;
    border: 1px solid var(--st-border) !important;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.st-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
}

.st-card-img {
    height: 220px;
    object-fit: cover;
    width: 100%;
}

.st-card-hero-img {
    height: 380px;
    object-fit: cover;
    width: 100%;
}

.st-badge {
    padding: 0.35em 0.75em;
    font-weight: 600;
    font-size: 0.75rem;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #ffffff !important;
}

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--st-primary), var(--st-secondary));
    width: 0%;
    z-index: 1060;
    transition: width 0.1s linear;
}

/* Smart Paywall Fade-out */
.st-paywall-container {
    position: relative;
    max-height: 280px;
    overflow: hidden;
}
.st-paywall-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: var(--st-paywall-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 2rem;
}

/* Interactive Quiz & Poll Styling */
.st-quiz-option {
    border: 2px solid var(--st-border);
    border-radius: 8px;
    padding: 12px 18px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--st-text);
}
.st-quiz-option:hover {
    border-color: var(--st-primary);
    background-color: rgba(79, 70, 229, 0.15);
}
.st-quiz-option.correct {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.2);
    color: #10b981 !important;
}
.st-quiz-option.incorrect {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444 !important;
}

/* Poll Progress Bars */
.st-poll-bar {
    height: 8px;
    border-radius: 4px;
    background-color: var(--st-primary);
    transition: width 0.6s ease;
}

/* Tables in Light & Dark Modes */
.table {
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}
.table th, .table td {
    background-color: transparent !important;
    color: var(--st-text) !important;
    border-color: var(--st-border) !important;
}

/* User Badges */
.st-user-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 12px;
    color: #ffffff !important;
}

/* Dark/Light Toggle Icon */
.st-theme-toggle {
    cursor: pointer;
    font-size: 1.25rem;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--st-border);
    background: transparent;
    color: var(--st-text) !important;
}
