/* Ace Citizenship - Custom Theme
   Matching iOS app design system */

:root {
    /* Light mode (default) */
    --ace-primary: #7AA4F7;
    --ace-primary-text: #4A7FD9; /* Darker for text - WCAG AA compliant */
    --ace-secondary: #242839;
    --ace-success: #73D9CA;
    --ace-error: #F67590;
    --ace-background: #F5F5F5;
    --ace-surface: #FFFFFF; /* White cards on gray background for better figure-ground */
    --ace-surface-border: rgba(0, 0, 0, 0.06);
    --ace-text-primary: #242839;
    --ace-text-secondary: #33374A;
    --ace-disabled: #999BB3;

    /* Bootstrap overrides */
    --bs-primary: var(--ace-primary);
    --bs-body-bg: var(--ace-background);
    --bs-body-color: var(--ace-text-primary);
    --bs-link-color: var(--ace-primary-text);
}

[data-theme="dark"] {
    --ace-primary: #7AA4F7;
    --ace-primary-text: #7AA4F7;
    --ace-secondary: #F5F5F5;
    --ace-success: #73D9CA;
    --ace-error: #F67590;
    --ace-background: #121318;
    --ace-surface: #1E2028;
    --ace-surface-border: rgba(255, 255, 255, 0.1);
    --ace-text-primary: #E8EAF6;
    --ace-text-secondary: #A0A4B8;
    --ace-disabled: #575D8A;

    --bs-body-bg: var(--ace-background);
    --bs-body-color: var(--ace-text-primary);
    --bs-link-color: var(--ace-primary-text);
}

/* Typography - Rounded system fonts */
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--ace-background);
    color: var(--ace-text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--ace-text-primary);
}

/* Override Bootstrap's text-muted for proper contrast */
.text-muted {
    color: var(--ace-text-secondary) !important;
}

/* Secondary text class for descriptions */
.text-secondary-custom {
    color: var(--ace-text-secondary);
}

/* Navbar */
.navbar {
    background-color: var(--ace-surface);
    transition: background-color 0.3s ease;
}

.navbar-brand {
    font-weight: 700;
    color: var(--ace-text-primary) !important;
}

.nav-link {
    color: var(--ace-text-primary) !important;
    font-weight: 500;
}

.nav-link:hover {
    color: var(--ace-primary) !important;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 2px solid var(--ace-text-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--ace-text-primary);
}

.theme-toggle:hover {
    background-color: var(--ace-primary);
    border-color: var(--ace-primary);
    color: white;
}

/* Theme toggle icons - show moon in light mode, sun in dark mode */
.theme-icon-light {
    display: inline;
}

.theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: inline;
}

/* Logo switching */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

/* Cards and surfaces */
.card {
    background-color: var(--ace-surface);
    border: 1px solid var(--ace-surface-border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Buttons */
.btn-primary {
    background-color: var(--ace-primary);
    border-color: var(--ace-primary);
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: #6894e7;
    border-color: #6894e7;
}

.btn-outline-primary {
    color: var(--ace-primary);
    border-color: var(--ace-primary);
    border-radius: 12px;
    padding: 12px 24px;
    font-weight: 600;
}

.btn-outline-primary:hover {
    background-color: var(--ace-primary);
    color: white;
}

/* Hero section */
.hero {
    padding: 100px 0;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--ace-text-primary);
}

.hero .lead {
    font-size: 1.25rem;
    line-height: 1.7;
    color: var(--ace-text-secondary);
    margin-bottom: 2rem;
    max-width: 480px;
}

/* Hero mascot */
.hero-mascot {
    position: relative;
}

.mascot-image {
    max-width: 280px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.15));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Features section */
.features {
    padding: 80px 0;
}

.feature-icon {
    width: 56px;
    height: 56px;
    background-color: var(--ace-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    color: white;
}

.feature-icon span {
    font-size: 1.5rem;
    line-height: 1;
}

/* Feature icon color variants */
.feature-icon--primary { background-color: var(--ace-primary); }
.feature-icon--success { background-color: var(--ace-success); }
.feature-icon--error { background-color: var(--ace-error); }
.feature-icon--dark { background-color: var(--ace-secondary); }
.feature-icon--gradient {
    background: linear-gradient(135deg, var(--ace-background), var(--ace-secondary));
    color: var(--ace-text-primary);
}

[data-theme="dark"] .feature-icon--gradient {
    background: linear-gradient(135deg, #3a3d4a, #1B1D25);
    color: var(--ace-text-primary);
}

.feature-card {
    text-align: center;
    padding: 2rem;
}

.feature-card h5 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ace-text-primary);
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: var(--ace-text-secondary);
    line-height: 1.6;
    margin-bottom: 0;
}

/* CTA section */
.cta {
    padding: 100px 0;
    background-color: var(--ace-surface);
    border-top: 1px solid var(--ace-surface-border);
    border-bottom: 1px solid var(--ace-surface-border);
    text-align: center;
}

.cta h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ace-text-primary);
    margin-bottom: 1rem;
}

.cta p {
    color: var(--ace-text-secondary);
    font-size: 1.125rem;
    line-height: 1.6;
}

/* Footer */
.footer {
    background-color: var(--ace-surface);
    padding: 40px 0;
    margin-top: auto;
}

.footer-brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--ace-text-primary);
}

.footer h6 {
    color: var(--ace-text-primary);
}

.footer p {
    color: var(--ace-text-secondary);
}

.footer a {
    color: var(--ace-text-secondary);
    text-decoration: none;
}

.footer a:hover {
    color: var(--ace-primary);
}

/* App Store badge */
.app-store-badge {
    height: 50px;
    transition: transform 0.2s ease;
}

.app-store-badge:hover {
    transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.25rem;
        letter-spacing: -0.01em;
    }

    .hero {
        padding: 60px 0;
    }

    .hero .lead {
        max-width: 100%;
    }

    .features {
        padding: 60px 0;
    }

    .cta {
        padding: 60px 0;
    }

    .cta h2 {
        font-size: 1.5rem;
    }
}

/* Legal pages */
.legal-content {
    padding: 60px 0;
}

.legal-content h1 {
    margin-bottom: 2rem;
}

.legal-content h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.legal-content p, .legal-content ul {
    color: var(--ace-text-secondary);
    line-height: 1.8;
}

/* Support page */
.support-content {
    padding: 60px 0;
}

.faq-item {
    margin-bottom: 1.5rem;
}

.faq-question {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.faq-answer {
    color: var(--ace-text-secondary);
}

/* Focus states for keyboard accessibility */
:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 2px;
}

.btn-primary:focus-visible,
.btn-outline-primary:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(122, 164, 247, 0.25);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 2px;
}

.nav-link:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.footer a:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.app-store-badge:focus-visible {
    outline: 2px solid var(--ace-primary);
    outline-offset: 4px;
    border-radius: 8px;
}

/* =============================================================================
   BLOG STYLES
   ============================================================================= */

/* Blog page */
.blog-page {
    min-height: 60vh;
}

.blog-header {
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    background-color: var(--ace-surface);
    border: 1px solid var(--ace-surface-border);
    color: var(--ace-text-primary);
    border-radius: 12px;
    padding: 12px 16px;
}

.search-input:focus {
    background-color: var(--ace-surface);
    border-color: var(--ace-primary);
    color: var(--ace-text-primary);
    box-shadow: 0 0 0 3px rgba(122, 164, 247, 0.15);
}

.search-input::placeholder {
    color: var(--ace-disabled);
}

/* Post cards */
.post-card-link {
    display: block;
    color: inherit;
}

.post-card {
    height: 100%;
}

.post-card .card-body {
    padding: 1.5rem;
}

.post-card .post-title {
    color: var(--ace-text-primary);
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.post-card .post-excerpt {
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card .post-meta {
    padding-top: 0.75rem;
    border-top: 1px solid var(--ace-surface-border);
}

.post-card .post-image img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 16px 16px 0 0;
}

/* Single blog post */
.blog-post {
    max-width: 800px;
    margin: 0 auto;
}

.blog-post .post-header {
    margin-bottom: 2rem;
}

.blog-post .post-featured-image img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 16px;
}

/* Prose styles for blog content */
.post-body.prose {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--ace-text-secondary);
}

.post-body.prose h2 {
    font-size: 1.5rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--ace-text-primary);
}

.post-body.prose h3 {
    font-size: 1.25rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--ace-text-primary);
}

.post-body.prose p {
    margin-bottom: 1.5rem;
}

.post-body.prose ul, .post-body.prose ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

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

.post-body.prose a {
    color: var(--ace-primary-text);
    text-decoration: underline;
}

.post-body.prose a:hover {
    color: var(--ace-primary);
}

.post-body.prose blockquote {
    border-left: 4px solid var(--ace-primary);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--ace-text-secondary);
}

.post-body.prose code {
    background-color: var(--ace-surface-border);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

.post-body.prose pre {
    background-color: var(--ace-secondary);
    color: #f8f8f2;
    padding: 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.post-body.prose pre code {
    background: none;
    padding: 0;
}

/* Share section */
.share-section {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Related posts */
.related-post-card {
    color: var(--ace-text-primary);
    transition: border-color 0.2s ease;
}

.related-post-card:hover {
    border-color: var(--ace-primary);
}

.related-post-card .card-title {
    color: var(--ace-text-primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Back to top button */
.back-to-top {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Alpine.js cloak */
[x-cloak] {
    display: none !important;
}

/* Pagination */
.pagination-nav .btn {
    border-radius: 8px;
    padding: 8px 16px;
}

/* No posts state */
.no-posts {
    padding: 4rem 0;
}

/* Admin styles */
.admin-posts .table {
    background-color: var(--ace-surface);
}

.admin-posts .table th {
    color: var(--ace-text-primary);
    border-color: var(--ace-surface-border);
}

.admin-posts .table td {
    color: var(--ace-text-secondary);
    border-color: var(--ace-surface-border);
    vertical-align: middle;
}

.admin-edit textarea#content_md {
    min-height: 400px;
}
