/**
 * Default Theme Stylesheet
 * ActionBD
 * Mobile-First Responsive Design
 */

/* ============================================
   CSS Variables (can be overridden by theme.json)
   ============================================ */
:root {
    --theme-primary: #dc2626;
    --theme-primary-dark: #b91c1c;
    --theme-primary-light: #fecaca;
    --theme-secondary: #1f2937;
    --theme-accent: #3b82f6;
    --theme-success: #16a34a;
    --theme-warning: #d97706;
    --theme-danger: #dc2626;
    --theme-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --theme-container-width: 1200px;
    --theme-border-radius: 0.5rem;
    --theme-transition: 0.2s ease;

    /* Mobile-specific variables */
    --theme-mobile-padding: 1rem;
    --theme-touch-target: 44px; /* Minimum touch target size */
}

/* ============================================
   Base Styles - Mobile First
   ============================================ */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--theme-font-family);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Safe area support for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* ============================================
   Container - Mobile First
   ============================================ */
.theme-container {
    width: 100%;
    max-width: var(--theme-container-width);
    margin: 0 auto;
    padding: 0 var(--theme-mobile-padding);
}

@media (min-width: 640px) {
    .theme-container {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .theme-container {
        padding: 0 2rem;
    }
}

/* ============================================
   Hero Section - Mobile First
   ============================================ */
.theme-hero {
    background: linear-gradient(135deg, var(--theme-primary) 0%, var(--theme-primary-dark) 100%);
    color: white;
    padding: 2.5rem var(--theme-mobile-padding);
    text-align: center;
}

.theme-hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.2;
    word-wrap: break-word;
}

.theme-hero p {
    font-size: 1rem;
    opacity: 0.9;
    max-width: 100%;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

/* Tablet */
@media (min-width: 640px) {
    .theme-hero {
        padding: 3.5rem 1.5rem;
    }

    .theme-hero h1 {
        font-size: 2.25rem;
    }

    .theme-hero p {
        font-size: 1.125rem;
        max-width: 600px;
    }
}

/* Desktop */
@media (min-width: 768px) {
    .theme-hero {
        padding: 5rem 2rem;
    }

    .theme-hero h1 {
        font-size: 3rem;
    }

    .theme-hero p {
        font-size: 1.25rem;
        max-width: 800px;
        margin-bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .theme-hero {
        padding: 6rem 2rem;
    }

    .theme-hero h1 {
        font-size: 3.5rem;
    }
}

/* ============================================
   Buttons - Mobile First with Touch Targets
   ============================================ */
.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--theme-touch-target);
    padding: 0.75rem 1.25rem;
    border-radius: var(--theme-border-radius);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--theme-transition);
    cursor: pointer;
    text-decoration: none;
    border: 2px solid transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* Full-width buttons on very small screens */
@media (max-width: 479px) {
    .theme-btn-block-mobile {
        display: flex;
        width: 100%;
    }
}

@media (min-width: 640px) {
    .theme-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

.theme-btn-primary {
    background: var(--theme-primary);
    color: white;
    border-color: var(--theme-primary);
}

.theme-btn-primary:hover,
.theme-btn-primary:focus {
    background: var(--theme-primary-dark);
    border-color: var(--theme-primary-dark);
}

.theme-btn-primary:active {
    transform: scale(0.98);
}

.theme-btn-outline {
    background: transparent;
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

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

.theme-btn-white {
    background: white;
    color: var(--theme-primary);
    border-color: white;
}

.theme-btn-white:hover,
.theme-btn-white:focus {
    background: rgba(255,255,255,0.9);
}

/* Button group for mobile */
.theme-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

@media (min-width: 480px) {
    .theme-btn-group {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: auto;
    }
}

/* ============================================
   Cards - Mobile First
   ============================================ */
.theme-card {
    background: white;
    border-radius: var(--theme-border-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.25rem;
    transition: box-shadow var(--theme-transition), transform var(--theme-transition);
}

@media (min-width: 640px) {
    .theme-card {
        padding: 1.5rem;
    }
}

.theme-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Remove hover transform on touch devices to prevent jank */
@media (hover: hover) {
    .theme-card:hover {
        transform: translateY(-2px);
    }
}

.dark .theme-card {
    background: #1f2937;
    color: #f3f4f6;
}

/* ============================================
   Sections - Mobile First
   ============================================ */
.theme-section {
    padding: 2.5rem var(--theme-mobile-padding);
}

@media (min-width: 640px) {
    .theme-section {
        padding: 3rem 1.5rem;
    }
}

@media (min-width: 768px) {
    .theme-section {
        padding: 4rem 2rem;
    }
}

.theme-section-alt {
    background: #f9fafb;
}

.dark .theme-section-alt {
    background: #111827;
}

/* ============================================
   Section Titles - Mobile First
   ============================================ */
.theme-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2rem;
    color: var(--theme-secondary);
    line-height: 1.3;
}

@media (min-width: 640px) {
    .theme-section-title {
        font-size: 1.75rem;
        margin-bottom: 2.5rem;
    }
}

@media (min-width: 768px) {
    .theme-section-title {
        font-size: 2rem;
        margin-bottom: 3rem;
    }
}

.dark .theme-section-title {
    color: white;
}

/* ============================================
   Grid System - Mobile First
   ============================================ */
.theme-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .theme-grid {
        gap: 1.25rem;
    }
}

@media (min-width: 768px) {
    .theme-grid {
        gap: 1.5rem;
    }
}

/* 2-column grid */
.theme-grid-2 {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .theme-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 3-column grid */
.theme-grid-3 {
    grid-template-columns: 1fr;
}

@media (min-width: 480px) {
    .theme-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .theme-grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 4-column grid */
.theme-grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
    .theme-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .theme-grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .theme-grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================
   CMS Content Styles - Mobile First
   ============================================ */
.cms-content {
    font-family: var(--theme-font-family);
    color: var(--theme-secondary);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.cms-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--theme-secondary);
    line-height: 1.2;
}

.cms-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
    color: var(--theme-secondary);
    line-height: 1.25;
}

.cms-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1.25rem;
    line-height: 1.3;
}

.cms-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    line-height: 1.35;
}

@media (min-width: 640px) {
    .cms-content h1 {
        font-size: 2rem;
    }

    .cms-content h2 {
        font-size: 1.75rem;
        margin-top: 2rem;
    }

    .cms-content h3 {
        font-size: 1.375rem;
        margin-top: 1.5rem;
    }

    .cms-content h4 {
        font-size: 1.25rem;
    }
}

@media (min-width: 768px) {
    .cms-content h1 {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }

    .cms-content h2 {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }

    .cms-content h3 {
        font-size: 1.5rem;
    }
}

.cms-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
    font-size: 1rem;
}

.cms-content ul,
.cms-content ol {
    margin-bottom: 1rem;
    padding-left: 1.25rem;
}

@media (min-width: 640px) {
    .cms-content ul,
    .cms-content ol {
        padding-left: 1.5rem;
    }
}

.cms-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.cms-content ul li {
    list-style-type: disc;
}

.cms-content ol li {
    list-style-type: decimal;
}

.cms-content a {
    color: var(--theme-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cms-content a:hover,
.cms-content a:focus {
    color: var(--theme-primary-dark);
}

/* Ensure links are tappable */
.cms-content a {
    display: inline;
    padding: 0.125rem 0;
}

.cms-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--theme-border-radius);
    margin: 1rem 0;
    display: block;
}

.cms-content blockquote {
    border-left: 4px solid var(--theme-primary);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #4b5563;
}

/* Mobile-friendly tables */
.cms-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
    .cms-content table {
        display: table;
    }
}

.cms-content th,
.cms-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: left;
    min-width: 100px;
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .cms-content th,
    .cms-content td {
        padding: 0.75rem;
        font-size: 1rem;
    }
}

.cms-content th {
    background: #f3f4f6;
    font-weight: 600;
    white-space: nowrap;
}

.cms-content hr {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid #e5e7eb;
}

@media (min-width: 640px) {
    .cms-content hr {
        margin: 2rem 0;
    }
}

/* Embedded videos responsive */
.cms-content iframe,
.cms-content video {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

/* Dark Mode CMS */
.dark .cms-content {
    color: #f3f4f6;
}

.dark .cms-content h1,
.dark .cms-content h2,
.dark .cms-content h3,
.dark .cms-content h4 {
    color: #ffffff;
}

.dark .cms-content p,
.dark .cms-content li {
    color: #d1d5db;
}

.dark .cms-content blockquote {
    color: #9ca3af;
    border-left-color: #ef4444;
}

.dark .cms-content th {
    background: #374151;
    color: #f3f4f6;
}

.dark .cms-content td {
    border-color: #4b5563;
}

.dark .cms-content hr {
    border-top-color: #4b5563;
}

/* ============================================
   Navigation - Mobile Improvements
   ============================================ */
.theme-nav-link {
    display: flex;
    align-items: center;
    min-height: var(--theme-touch-target);
    padding: 0.5rem 0.75rem;
    color: #374151;
    text-decoration: none;
    transition: color var(--theme-transition);
}

.theme-nav-link:hover,
.theme-nav-link:focus {
    color: var(--theme-primary);
}

.dark .theme-nav-link {
    color: #d1d5db;
}

.dark .theme-nav-link:hover,
.dark .theme-nav-link:focus {
    color: var(--theme-primary-light);
}

/* Mobile menu animation */
.theme-mobile-menu {
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.theme-mobile-menu.hidden {
    max-height: 0;
    opacity: 0;
}

.theme-mobile-menu.open {
    max-height: 500px;
    opacity: 1;
}

/* ============================================
   Form Elements - Mobile First
   ============================================ */
.theme-input,
.theme-select,
.theme-textarea {
    display: block;
    width: 100%;
    min-height: var(--theme-touch-target);
    padding: 0.625rem 0.875rem;
    font-size: 16px; /* Prevents iOS zoom on focus */
    line-height: 1.5;
    color: #374151;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: var(--theme-border-radius);
    transition: border-color var(--theme-transition), box-shadow var(--theme-transition);
    -webkit-appearance: none;
    appearance: none;
}

.theme-input:focus,
.theme-select:focus,
.theme-textarea:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.dark .theme-input,
.dark .theme-select,
.dark .theme-textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.theme-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================================
   Utility Classes - Mobile First
   ============================================ */
.theme-text-primary {
    color: var(--theme-primary);
}

.theme-bg-primary {
    background-color: var(--theme-primary);
}

.theme-text-center {
    text-align: center;
}

/* Responsive spacing */
.theme-mt-1 { margin-top: 0.25rem; }
.theme-mt-2 { margin-top: 0.5rem; }
.theme-mt-4 { margin-top: 1rem; }
.theme-mt-8 { margin-top: 2rem; }

.theme-mb-1 { margin-bottom: 0.25rem; }
.theme-mb-2 { margin-bottom: 0.5rem; }
.theme-mb-4 { margin-bottom: 1rem; }
.theme-mb-8 { margin-bottom: 2rem; }

.theme-py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.theme-py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.theme-py-16 { padding-top: 4rem; padding-bottom: 4rem; }

/* Mobile spacing utilities */
@media (max-width: 639px) {
    .theme-py-16 {
        padding-top: 2.5rem;
        padding-bottom: 2.5rem;
    }
}

/* Hide on mobile */
.theme-hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .theme-hide-mobile {
        display: block;
    }
}

/* Show only on mobile */
.theme-show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .theme-show-mobile {
        display: none;
    }
}

/* ============================================
   Accessibility - Focus States
   ============================================ */
:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

/* Skip link for accessibility */
.theme-skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: 1rem;
    background: var(--theme-primary);
    color: white;
    z-index: 9999;
    transition: top 0.2s;
}

.theme-skip-link:focus {
    top: 0;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .theme-hero {
        background: none !important;
        color: black !important;
        padding: 1rem 0 !important;
    }

    .theme-btn,
    .theme-nav-link,
    #mobile-menu-btn,
    #back-to-top {
        display: none !important;
    }

    .theme-card {
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
}
