/* ============================================================
   AutoPulse — Main stylesheet
   Mobile-first, fully responsive layout
   ============================================================ */

:root {
    --color-bg: #0b1220;
    --color-bg-elevated: #111b2d;
    --color-surface: #182438;
    --color-surface-2: #1f2e47;
    --color-accent: #3b82f6;
    --color-accent-hover: #2563eb;
    --color-text: #e6e9ef;
    --color-muted: #9aa3b2;
    --color-border: rgba(148, 163, 184, 0.15);
    --color-danger: #ef4444;
    --color-success: #22c55e;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    --max-width: 1280px;
    --header-height: 4rem;
    --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-head: 'Manrope', var(--font-body);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
}

/* Containers */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: 1rem;
}

@media (min-width: 768px) {
    .container {
        padding-inline: 1.5rem;
    }
}

/* Skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: -9999px;
    background: var(--color-accent);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    z-index: 1000;
}
.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* Header */
.site-header {
    background: rgba(11, 18, 32, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1.25rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: linear-gradient(135deg, var(--color-accent), #06b6d4);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.brand-text {
    color: #fff;
}

/* Primary nav */
.primary-nav {
    display: none;
}

.primary-nav ul {
    display: flex;
    gap: 1.25rem;
}

.primary-nav a {
    color: var(--color-muted);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.25rem 0;
    position: relative;
}

.primary-nav a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--color-accent);
    transition: width 0.2s ease;
}

.primary-nav a:hover,
.primary-nav a.is-active {
    color: #fff;
}
.primary-nav a:hover::after,
.primary-nav a.is-active::after {
    width: 100%;
}

@media (min-width: 1024px) {
    .primary-nav {
        display: block;
    }
}

/* Mobile menu button */
.icon-btn {
    background: transparent;
    border: 0;
    color: #fff;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    position: relative;
    transition: background 0.2s;
}
.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: #fff;
    transition: transform 0.2s, top 0.2s;
}
.hamburger::before { top: -7px; }
.hamburger::after { top: 7px; }

#menuToggle[aria-expanded="true"] .hamburger {
    background: transparent;
}
#menuToggle[aria-expanded="true"] .hamburger::before {
    top: 0;
    transform: rotate(45deg);
}
#menuToggle[aria-expanded="true"] .hamburger::after {
    top: 0;
    transform: rotate(-45deg);
}

.mobile-nav {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: var(--color-bg-elevated);
    padding: 1.5rem;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.mobile-nav[hidden] {
    display: block;
}
.mobile-nav.is-open {
    transform: translateX(0);
}
.mobile-nav ul {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}
.mobile-nav a {
    color: var(--color-text);
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}
.mobile-nav a:hover {
    color: var(--color-accent);
}

@media (min-width: 1024px) {
    .icon-btn {
        display: none;
    }
    .mobile-nav {
        display: none !important;
    }
}

/* Page wrapper */
.page {
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
}
.page > main {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s, border-color 0.2s;
}
.btn:active {
    transform: scale(0.98);
}
.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}
.btn-ghost {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-ghost:hover {
    background: var(--color-surface-2);
}

/* Hero */
.hero {
    position: relative;
    padding: 3rem 0 2.5rem;
    background: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.1), transparent 40%);
    border-bottom: 1px solid var(--color-border);
}

.hero-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .hero-grid {
        grid-template-columns: 1.2fr 1fr;
    }
}

.hero-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    min-height: 280px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.hero-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.hero-card .media {
    position: relative;
    height: 180px;
    overflow: hidden;
}
.hero-card .media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.hero-card .body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.hero-card h3 {
    font-family: var(--font-head);
    font-size: 1.1rem;
    line-height: 1.35;
    color: #fff;
}
.hero-card .meta {
    font-size: 0.8rem;
    color: var(--color-muted);
}

@media (min-width: 768px) {
    .hero-card:first-child {
        grid-row: span 2;
    }
    .hero-card:first-child .media {
        height: 320px;
    }
    .hero-card:first-child h3 {
        font-size: 1.45rem;
    }
}

/* Section headings */
.section {
    padding: 2.5rem 0;
}
.section-title {
    font-family: var(--font-head);
    font-size: 1.35rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* Article cards */
.card-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1fr;
}

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

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

.card {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}
.card-media {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-surface-2);
}
.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.card:hover .card-media img {
    transform: scale(1.03);
}
.category-pill {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(11, 18, 32, 0.85);
    color: #fff;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}
.card-title {
    font-family: var(--font-head);
    font-size: 1.05rem;
    line-height: 1.35;
    color: #fff;
}
.card-excerpt {
    color: var(--color-muted);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* Article page */
.article-header {
    padding: 2.5rem 0 1.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
}
.article-header h1 {
    font-family: var(--font-head);
    font-size: 1.75rem;
    line-height: 1.25;
    margin-bottom: 1rem;
    color: #fff;
}
@media (min-width: 768px) {
    .article-header h1 {
        font-size: 2.25rem;
    }
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}
.article-hero {
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-border);
}
.article-hero img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}
.article-content {
    font-size: 1rem;
    color: var(--color-text);
}
.article-content h2,
.article-content h3,
.article-content h4 {
    font-family: var(--font-head);
    color: #fff;
    margin: 1.5rem 0 0.75rem;
}
.article-content p,
.article-content ul,
.article-content ol {
    margin-bottom: 1rem;
}
.article-content ul {
    padding-left: 1.25rem;
    list-style: disc;
}
.article-content strong {
    color: #fff;
}
.article-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Layout for article with sidebar */
.with-sidebar {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
    .with-sidebar {
        grid-template-columns: minmax(0, 2fr) 380px;
        align-items: start;
    }
}

/* Sidebar widgets */
.widget {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}
.widget-title {
    font-family: var(--font-head);
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #fff;
}
.widget-list li {
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 0;
}
.widget-list li:last-child {
    border-bottom: 0;
}
.widget-list a {
    color: var(--color-text);
    font-weight: 500;
    display: block;
}
.widget-list a:hover {
    color: var(--color-accent);
}

/* Static pages */
.prose {
    max-width: 75ch;
    margin-inline: auto;
}
.prose h1 {
    font-family: var(--font-head);
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #fff;
}
.prose h2 {
    font-family: var(--font-head);
    font-size: 1.35rem;
    margin: 2rem 0 0.75rem;
    color: #fff;
}
.prose p,
.prose ul,
.prose ol {
    margin-bottom: 1rem;
    color: var(--color-text);
}
.prose ul {
    padding-left: 1.25rem;
    list-style: disc;
}
.prose a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.prose a:hover {
    color: var(--color-accent-hover);
}

/* 404 */
.not-found {
    text-align: center;
    padding: 5rem 1rem;
}
.not-found h1 {
    font-family: var(--font-head);
    font-size: 4rem;
    color: var(--color-accent);
    line-height: 1;
}
.not-found p {
    margin: 1.5rem 0;
    color: var(--color-muted);
}

/* Cookie banner */
.cookie-banner {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 200;
}
.cookie-banner p {
    font-size: 0.9rem;
    color: var(--color-text);
}
.cookie-banner a {
    color: var(--color-accent);
    text-decoration: underline;
}
.cookie-actions {
    display: flex;
    gap: 0.75rem;
}
@media (min-width: 640px) {
    .cookie-banner {
        left: auto;
        right: 1.5rem;
        bottom: 1.5rem;
        max-width: 420px;
    }
}

/* Footer */
.site-footer {
    background: var(--color-bg-elevated);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
    padding: 3rem 0 1.5rem;
}
.footer-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}
@media (min-width: 640px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .footer-grid {
        grid-template-columns: 2fr repeat(3, 1fr);
    }
}
.footer-desc {
    color: var(--color-muted);
    margin-top: 0.75rem;
    max-width: 30ch;
    font-size: 0.95rem;
}
.footer-title {
    font-family: var(--font-head);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    margin-bottom: 0.75rem;
}
.footer-links li {
    margin-bottom: 0.5rem;
}
.footer-links a {
    color: var(--color-muted);
    font-size: 0.95rem;
}
.footer-links a:hover {
    color: var(--color-accent);
}
.footer-bottom {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-muted);
}

/* Accessibility focus */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Breadcrumbs */
.breadcrumbs {
    padding: 1rem 0;
    font-size: 0.875rem;
    color: var(--color-muted);
}
.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.breadcrumbs li:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: var(--color-muted);
}
.breadcrumbs a {
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumbs a:hover {
    color: var(--color-accent);
}
.breadcrumbs li[aria-current="page"] {
    color: var(--color-text);
}
