/* ========================================
   Apple-Inspired Elegant Design System
   ======================================== */

:root {
    /* Apple Color Palette */
    --apple-blue: #007AFF;
    --apple-blue-hover: #0051D5;
    --apple-gray-1: #F5F5F7;
    --apple-gray-2: #E8E8ED;
    --apple-gray-3: #D2D2D7;
    --apple-gray-4: #86868B;
    --apple-gray-5: #1D1D1F;
    --apple-gray-6: #161617;

    /* Semantic Colors */
    --success: #34C759;
    --warning: #FF9F0A;
    --danger: #FF3B30;
    --neutral: #8E8E93;

    /* Elevation */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.18);
}

/* ========================================
   Base Styles
   ======================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, #F5F7FA 0%, #E8EAED 100%);
    color: var(--apple-gray-5);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Card & Container Styles
   ======================================== */

.bg-white {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
}

.rounded-lg {
    border-radius: 18px !important;
}

.rounded-xl {
    border-radius: 24px !important;
}

/* ========================================
   Navigation Styles
   ======================================== */

header {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--apple-gray-2) !important;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.nav-button {
    font-weight: 500;
    font-size: 15px;
    letter-spacing: -0.02em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
}

.nav-button.nav-active {
    background: var(--apple-blue);
    color: white !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    border-bottom: none !important;
}

.nav-button.nav-inactive {
    color: var(--apple-gray-4) !important;
    border-bottom: none !important;
}

.nav-button.nav-inactive:hover {
    color: var(--apple-gray-5) !important;
    background: var(--apple-gray-1);
    transform: translateY(-1px);
}

/* Mobile Navigation */
.mobile-nav-button.nav-active {
    background: var(--apple-blue) !important;
    color: white !important;
    font-weight: 600;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.mobile-nav-button.nav-inactive {
    color: var(--apple-gray-4) !important;
}

.mobile-nav-button.nav-inactive:hover {
    background: var(--apple-gray-1) !important;
    color: var(--apple-gray-5) !important;
}

/* ========================================
   Typography
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--apple-gray-5);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* ========================================
   Buttons & Interactive Elements
   ======================================== */

button, .btn {
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

button:active, .btn:active {
    transform: translateY(0);
}

/* Primary Button */
.bg-blue-600, .bg-indigo-600 {
    background: var(--apple-blue) !important;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.bg-blue-600:hover, .bg-indigo-600:hover {
    background: var(--apple-blue-hover) !important;
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
}

/* Success Button */
.bg-green-600 {
    background: var(--success) !important;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.25);
}

.bg-green-600:hover {
    background: #30B04F !important;
}

/* ========================================
   Status Indicators & Badges
   ======================================== */

.bubble-green {
    background: linear-gradient(135deg, var(--success) 0%, #30B04F 100%);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.3);
}

.bubble-bright-green {
    background: linear-gradient(135deg, #32D74B 0%, var(--success) 100%);
    box-shadow: 0 4px 16px rgba(50, 215, 75, 0.5);
    animation: pulse-glow 2s ease-in-out infinite;
}

.bubble-yellow {
    background: linear-gradient(135deg, var(--warning) 0%, #FF8C00 100%);
    box-shadow: 0 4px 12px rgba(255, 159, 10, 0.3);
}

.bubble-red {
    background: linear-gradient(135deg, var(--danger) 0%, #E60023 100%);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

.bubble-gray {
    background: linear-gradient(135deg, var(--neutral) 0%, #636366 100%);
    box-shadow: 0 4px 12px rgba(142, 142, 147, 0.2);
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(50, 215, 75, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 20px rgba(50, 215, 75, 0.6);
        transform: scale(1.05);
    }
}

.text-green { color: var(--success); font-weight: 600; }
.text-bright-green { color: #32D74B; font-weight: 600; }
.text-yellow { color: var(--warning); font-weight: 600; }
.text-red { color: var(--danger); font-weight: 600; }
.text-gray { color: var(--neutral); }

/* ========================================
   Accordion Components
   ======================================== */

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-content.open {
    max-height: 2000px;
}

.accordion-icon {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-icon.open {
    transform: rotate(180deg);
}

/* ========================================
   Input & Form Elements
   ======================================== */

input, select, textarea {
    border: 1.5px solid var(--apple-gray-3) !important;
    border-radius: 12px !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    padding: 0.75rem 1rem;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--apple-blue) !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1) !important;
    outline: none !important;
}

/* ========================================
   Charts & Data Visualization
   ======================================== */

canvas {
    border-radius: 16px;
}

/* ========================================
   Blog & Content Typography
   ======================================== */

.blog-prose {
    color: var(--apple-gray-5);
    line-height: 1.7;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.blog-prose h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--apple-gray-6);
    letter-spacing: -0.03em;
}

.blog-prose h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--apple-gray-5);
    letter-spacing: -0.02em;
}

.blog-prose h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--apple-gray-5);
}

.blog-prose p {
    margin-bottom: 1.25rem;
}

.blog-prose ul, .blog-prose ol {
    margin-bottom: 1.25rem;
    padding-left: 1.75rem;
}

.blog-prose ul { list-style-type: disc; }
.blog-prose ol { list-style-type: decimal; }

.blog-prose li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.blog-prose a {
    color: var(--apple-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.blog-prose a:hover {
    color: var(--apple-blue-hover);
    text-decoration: underline;
}

.blog-prose blockquote {
    border-left: 4px solid var(--apple-blue);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--apple-gray-4);
    font-style: italic;
    font-size: 1.1rem;
}

.blog-prose code {
    background: var(--apple-gray-1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    color: var(--apple-blue);
    font-weight: 500;
}

.blog-prose pre {
    background: #f5f5f5;
    color: #333;
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
    font-family: 'Courier New', Courier, monospace;
    white-space: pre;
    line-height: 1.4;
}

.blog-prose pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-weight: 400;
}

.blog-prose hr {
    border: none;
    border-top: 1px solid var(--apple-gray-2);
    margin: 2rem 0;
}

.blog-prose strong {
    font-weight: 600;
    color: var(--apple-gray-6);
}

.blog-prose em {
    font-style: italic;
    color: var(--apple-gray-4);
}

/* ========================================
   Table Styles
   ======================================== */

table {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

thead {
    background: var(--apple-gray-1);
}

th {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--apple-gray-5);
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: var(--apple-gray-1);
}

/* ========================================
   Utility Classes
   ======================================== */

.fallback-notice {
    color: var(--warning);
    font-style: italic;
    margin-left: 0.5rem;
    font-weight: 500;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Selection styling */
::selection {
    background: rgba(0, 122, 255, 0.2);
    color: var(--apple-gray-6);
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

/* ========================================
   Loading States & Animations
   ======================================== */

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

.loading-shimmer {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(to right, var(--apple-gray-1) 4%, var(--apple-gray-2) 25%, var(--apple-gray-1) 36%);
    background-size: 1000px 100%;
}

/* ========================================
   Responsive Refinements
   ======================================== */

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }

    .nav-button {
        font-size: 14px;
        padding: 0.65rem 1rem;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* ========================================
   Blog-Specific Enhancements
   ======================================== */

/* Article content width for optimal readability (NYT-style) */
#blog-article-content {
    max-width: 660px;
    margin: 0 auto;
}

/* Enhanced blog prose styling (NYT-inspired) */
.blog-prose {
    font-size: 17px;
    line-height: 1.65;
    color: #333;
    font-family: Georgia, 'Times New Roman', Times, serif;
}

.blog-prose p {
    margin-bottom: 1.25rem;
}

.blog-prose h1 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-size: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-weight: 700;
    color: #1a1a1a;
}

.blog-prose h2 {
    margin-top: 2rem;
    margin-bottom: 0.875rem;
    font-size: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-weight: 700;
    color: #1a1a1a;
}

.blog-prose h3 {
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    font-weight: 600;
    color: #1a1a1a;
}

/* First paragraph drop cap (NYT-style, subtle) */
.blog-prose > p:first-of-type::first-letter {
    float: left;
    font-size: 3.5rem;
    line-height: 0.85;
    font-weight: 700;
    margin-right: 0.4rem;
    margin-top: 0.15rem;
    color: #1a1a1a;
    font-family: Georgia, 'Times New Roman', Times, serif;
}

/* Image styling within articles */
.blog-prose img {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 1.5rem 0;
    width: 100%;
    height: auto;
}

/* Pull quotes (NYT-style) */
.blog-prose blockquote {
    position: relative;
    padding: 1.25rem 1.5rem;
    margin: 1.75rem 0;
    background: #fafafa;
    border-left: 3px solid #333;
    font-size: 1.1rem;
    font-style: italic;
    color: #444;
}

.blog-prose blockquote::before {
    display: none;
}

/* Code blocks */
.blog-prose :not(pre) > code {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Lists styling (NYT-style, compact) */
.blog-prose ul, .blog-prose ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.blog-prose li {
    margin-bottom: 0.5rem;
}

.blog-prose li::marker {
    color: #333;
}

/* Horizontal rules (NYT-style) */
.blog-prose hr {
    margin: 2rem 0;
    height: 1px;
    background: #e0e0e0;
    border: none;
}

/* Tables */
.blog-prose table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.blog-prose th,
.blog-prose td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.blog-prose th {
    background: #f8f8f8;
    font-weight: 600;
    color: #333;
}

.blog-prose tr:hover {
    background: #fafafa;
}

/* Article header styling */
#blog-article-title {
    font-size: 2.75rem;
    line-height: 1.2;
    margin-bottom: 0.75rem;
    color: var(--apple-gray-6);
    font-weight: 700;
    letter-spacing: -0.03em;
}

#blog-article-date {
    font-size: 0.95rem;
    color: var(--apple-gray-4);
    font-weight: 500;
}

/* Back button */
#blog-back-btn {
    font-weight: 500;
    color: var(--apple-blue);
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

#blog-back-btn:hover {
    background: var(--apple-gray-1);
    transform: translateX(-4px);
}

/* Responsive blog enhancements (NYT-style) */
@media (max-width: 768px) {
    #blog-article-content {
        max-width: 100%;
        padding: 0 1rem;
    }

    .blog-prose {
        font-size: 16px;
        line-height: 1.7;
    }

    #blog-article-title {
        font-size: 1.75rem;
    }

    .blog-prose > p:first-of-type::first-letter {
        font-size: 2.75rem;
    }

    .blog-prose h1 {
        font-size: 1.65rem;
    }

    .blog-prose h2 {
        font-size: 1.35rem;
    }

    .blog-prose h3 {
        font-size: 1.15rem;
    }
}
