/* ============================================
   Verity Standard - Publication Style
   Mobile-First Design System Implementation
   ============================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Design Tokens - Following DESIGN_SYSTEM.md */
    --primary-color: #000000;
    --primary-hover: #333333;
    --accent-color: #2563eb;
    --accent-hover: #1e40af;
    --text-dark: #1a1a1a;
    --text-medium: #4a4a4a;
    --text-light: #6b6b6b;
    --bg-white: #ffffff;
    --bg-light: #fafafa;
    --border-color: #e5e5e5;
    --category-color: #666666;
    
    /* Spacing - Mobile First */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    
    /* Typography - Mobile Base */
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 28px;
    --font-size-4xl: 32px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Touch Target Size */
    --touch-target: 44px;
}

/* Base Styles - Mobile First (320px+) */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.7;
    color: var(--text-dark);
    background-color: var(--bg-white);
    font-size: var(--font-size-base); /* Prevents iOS zoom */
    overflow-x: hidden;
}

/* Container - Mobile First */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4); /* 16px mobile */
}

/* ============================================
   HEADER - Mobile First
   ============================================ */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    /* Safe area for notched devices */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.header-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) 0;
    gap: var(--space-4);
    flex-wrap: wrap;
}

/* Logo - Mobile */
.logo a {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.5px;
    display: block;
    min-height: var(--touch-target); /* Touch-friendly */
    line-height: var(--touch-target);
}

/* Mobile Navigation - Hamburger Menu */
.mobile-menu-toggle {
    display: block;
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    position: relative;
    z-index: 1001;
}

.mobile-menu-toggle:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.hamburger {
    width: 24px;
    height: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text-dark);
    border-radius: 2px;
    transition: all var(--transition-base);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

/* Desktop Navigation - Hidden on Mobile */
.main-nav {
    display: none;
    width: 100%;
    order: 3;
}

.main-nav.active {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: var(--space-4) 0;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.main-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.main-nav li {
    border-bottom: 1px solid var(--border-color);
}

.main-nav a {
    display: block;
    padding: var(--space-4) var(--space-4);
    color: var(--text-medium);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-size-base);
    min-height: var(--touch-target);
    line-height: var(--touch-target);
    transition: background-color var(--transition-fast);
}

.main-nav a:active,
.main-nav a:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Search - Mobile */
.header-search {
    flex: 1;
    order: 2;
    min-width: 0;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base); /* Prevents iOS zoom */
    background: var(--bg-light);
    transition: all var(--transition-base);
    min-height: var(--touch-target);
    -webkit-appearance: none;
    appearance: none;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input::placeholder {
    color: var(--text-light);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    padding-top: 0;
}

/* ============================================
   FEATURED SECTION - Mobile First
   ============================================ */
.featured-section {
    padding: var(--space-8) 0;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.featured-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: var(--space-6);
}

.featured-large {
    background: var(--bg-white);
    padding: var(--space-5);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.article-category {
    display: inline-block;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--category-color);
    margin-bottom: var(--space-4);
}

.featured-large .article-title {
    font-size: var(--font-size-3xl); /* 28px mobile */
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-4);
    letter-spacing: -0.5px;
}

.featured-large .article-title a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color var(--transition-base);
    display: block;
}

.featured-large .article-title a:active {
    color: var(--accent-color);
}

.article-excerpt {
    font-size: var(--font-size-lg);
    line-height: 1.6;
    color: var(--text-medium);
    margin-bottom: var(--space-6);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-light);
}

.article-date {
    color: var(--text-light);
}

.article-topic {
    color: var(--accent-color);
    font-weight: 500;
}

.featured-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.featured-small {
    background: var(--bg-white);
    padding: var(--space-5);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.featured-small:active {
    transform: scale(0.98);
}

.featured-small .article-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-3);
}

.featured-small .article-title a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color var(--transition-base);
    display: block;
}

.featured-small .article-title a:active {
    color: var(--accent-color);
}

/* ============================================
   TOPICS SECTION - Mobile First
   ============================================ */
.topics-section {
    padding: var(--space-8) 0;
    background: var(--bg-white);
}

.topics-title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    margin-bottom: var(--space-8);
    letter-spacing: -0.5px;
}

.topics-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: var(--space-6);
}

.topic-card {
    background: var(--bg-light);
    padding: var(--space-6);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    display: block;
    min-height: var(--touch-target); /* Ensure touch-friendly */
}

.topic-card:active {
    background: var(--bg-white);
    border-color: var(--border-color);
    box-shadow: var(--shadow);
    transform: scale(0.98);
}

.topic-icon {
    font-size: 40px;
    margin-bottom: var(--space-4);
}

.topic-card h3 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--text-dark);
}

.topic-card p {
    color: var(--text-medium);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-base);
}

.topic-count {
    font-size: var(--font-size-sm);
    color: var(--text-light);
    font-weight: 500;
}

/* ============================================
   ARTICLES SECTION - Mobile First
   ============================================ */
.articles-section {
    padding: var(--space-8) 0;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
}

.section-header {
    margin-bottom: var(--space-10);
}

.section-title {
    font-size: var(--font-size-4xl);
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-dark);
}

.articles-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: var(--space-8);
}

.article-card {
    background: var(--bg-white);
    padding: 0;
    transition: transform var(--transition-base);
}

.article-card:active {
    transform: translateY(-2px);
}

.article-card .article-category {
    margin-bottom: var(--space-3);
}

.article-card .article-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-3);
}

.article-card .article-title a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color var(--transition-base);
    display: block;
}

.article-card .article-title a:active {
    color: var(--accent-color);
}

.article-card .article-excerpt {
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-medium);
    margin-bottom: var(--space-4);
}

.article-card .article-meta {
    font-size: var(--font-size-sm);
}

/* ============================================
   QUESTIONS SECTION - Mobile First
   ============================================ */
.questions-section {
    padding: var(--space-8) 0;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

.questions-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: var(--space-6);
}

.question-card {
    background: var(--bg-white);
    padding: var(--space-6);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.question-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-hover);
}

.question-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--space-3);
}

.question-title a {
    color: var(--text-dark);
    text-decoration: none;
    transition: color var(--transition-base);
    display: block;
}

.question-title a:active {
    color: var(--accent-color);
}

.question-excerpt {
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: var(--text-medium);
}

/* ============================================
   FOOTER - Mobile First
   ============================================ */
.site-footer {
    background: var(--text-dark);
    color: #ffffff;
    padding: var(--space-12) 0 var(--space-6);
    margin-top: var(--space-16);
    /* Safe area for home indicator */
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: var(--space-10);
    margin-bottom: var(--space-8);
}

.footer-section h3,
.footer-section h4 {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: #ffffff;
}

.footer-section p {
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: var(--space-2);
}

.footer-section a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-base);
    display: inline-block;
    min-height: var(--touch-target);
    line-height: var(--touch-target);
}

.footer-section a:active {
    color: #ffffff;
}

.footer-bottom {
    text-align: center;
    padding-top: var(--space-6);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: var(--font-size-xs);
}

/* ============================================
   RESPONSIVE ENHANCEMENTS - Progressive
   ============================================ */

/* Large Mobile (480px+) */
@media (min-width: 480px) {
    .container {
        padding: 0 var(--space-5);
    }
    
    .header-container {
        padding: 0 var(--space-5);
    }
    
    .featured-large {
        padding: var(--space-6);
    }
    
    .featured-large .article-title {
        font-size: var(--font-size-4xl); /* 32px */
    }
}

/* Tablet (768px+) */
@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-6);
    }
    
    .header-container {
        padding: 0 var(--space-6);
    }
    
    /* Hide hamburger, show desktop nav */
    .mobile-menu-toggle {
        display: none;
    }
    
    .main-nav {
        display: block;
        position: static;
        width: auto;
        order: 2;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        max-height: none;
        overflow: visible;
    }
    
    .main-nav ul {
        flex-direction: row;
        gap: var(--space-8);
    }
    
    .main-nav li {
        border-bottom: none;
    }
    
    .main-nav a {
        padding: 0;
        background: transparent;
        min-height: auto;
        line-height: 1.5;
    }
    
    .main-nav a:hover {
        background: transparent;
    }
    
    /* Search positioning */
    .header-search {
        flex: 1;
        max-width: 300px;
        order: 3;
    }
    
    /* Featured section */
    .featured-section {
        padding: var(--space-12) 0;
    }
    
    .featured-grid {
        grid-template-columns: 2fr 1fr;
        gap: var(--space-8);
    }
    
    .featured-large {
        padding: var(--space-10);
    }
    
    .featured-large .article-title {
        font-size: 36px; /* Between mobile and desktop */
    }
    
    /* Topics grid */
    .topics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Articles grid */
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-8);
    }
    
    /* Questions grid */
    .questions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (968px+) */
@media (min-width: 968px) {
    .header-content {
        flex-wrap: nowrap;
    }
    
    .featured-large .article-title {
        font-size: 42px; /* Desktop size */
    }
    
    .topics-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .articles-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
    
    .questions-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .footer-content {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    /* Hover states for desktop */
    .featured-small:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }
    
    .topic-card:hover {
        background: var(--bg-white);
        border-color: var(--border-color);
        box-shadow: var(--shadow);
        transform: translateY(-2px);
    }
    
    .article-card:hover {
        transform: translateY(-4px);
    }
    
    .question-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-hover);
    }
    
    .featured-large .article-title a:hover,
    .article-card .article-title a:hover,
    .question-title a:hover {
        color: var(--accent-color);
    }
}

/* Wide Desktop (1200px+) */
@media (min-width: 1200px) {
    .container {
        padding: 0 var(--space-6);
    }
    
    .section-title {
        font-size: 36px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
