/* ========================================
   SleepWell - UK Sleep Guides & Advice Site
   Mobile-First Responsive Design
   ======================================== */

/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2d3a8c;
  --primary-light: #4f5bd5;
  --primary-dark: #1a237e;
  --accent: #7c4dff;
  --accent-light: #b388ff;
  --bg: #f8f9fc;
  --bg-white: #ffffff;
  --text: #1a1a2e;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1200px;
  --header-height: 64px;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #0f0f1a;
  --bg-white: #1a1a2e;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --text-muted: #64748b;
  --border: #2d3748;
  --border-light: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

[data-theme="dark"] .header {
  background: #1a1a2e;
  border-bottom-color: #2d3748;
}

[data-theme="dark"] .nav-mobile {
  background: #1a1a2e;
}

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3e 50%, #2d1a4e 100%);
}

[data-theme="dark"] .hero-search input {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

[data-theme="dark"] .newsletter {
  background: linear-gradient(135deg, #0a0a1a, #1a1a3e);
}

[data-theme="dark"] .footer {
  background: #0a0a1a;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-light); }

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.nav-desktop {
  display: none;
}

.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  background: var(--border-light);
  transform: scale(1.1);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Mobile Nav */
.nav-mobile {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-white);
  padding: 1rem;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  z-index: 99;
}

.nav-mobile.open {
  transform: translateX(0);
}

.nav-mobile a {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  font-weight: 500;
}

.nav-mobile a:hover {
  color: var(--primary);
}

/* === HERO === */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
  color: white;
  padding: 3rem 1rem;
  text-align: center;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.hero p {
  font-size: 1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

.hero-search {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.hero-search input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 3rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  font-size: 1rem;
  background: rgba(255,255,255,0.15);
  color: white;
  backdrop-filter: blur(10px);
}

.hero-search input::placeholder {
  color: rgba(255,255,255,0.7);
}

.hero-search input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.25);
}

.hero-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  opacity: 0.7;
}

/* === CATEGORIES GRID === */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.section-subtitle {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.category-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.category-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.category-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.category-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* === ARTICLE CARDS === */
.article-grid {
  display: grid;
  gap: 1rem;
}

.article-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.article-image {
  height: 160px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.article-content {
  padding: 1.25rem;
}

.article-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--border-light);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.article-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  line-height: 1.3;
}

.article-excerpt {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === NEWSLETTER === */
.newsletter {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  margin: 2rem 0;
}

.newsletter h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.newsletter p {
  opacity: 0.9;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.newsletter-form {
  display: flex;
  gap: 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}

.newsletter-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.9rem;
}

.newsletter-form input::placeholder {
  color: rgba(255,255,255,0.7);
}

.newsletter-form button {
  padding: 0.75rem 1.5rem;
  background: white;
  color: var(--primary);
  border: none;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* === FOOTER === */
.footer {
  background: var(--text);
  color: rgba(255,255,255,0.7);
  padding: 2rem 1rem;
  margin-top: 2rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer h4 {
  color: white;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.footer a {
  display: block;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

.footer a:hover {
  color: white;
}

.footer-bottom {
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  text-align: center;
}

/* === RESPONSIVE === */
@media (min-width: 640px) {
  .hero h1 { font-size: 2.25rem; }
  .categories-grid { grid-template-columns: repeat(3, 1fr); }
  .article-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .nav-desktop {
    display: flex;
    gap: 0.25rem;
  }
  
  .nav-toggle {
    display: none;
  }
  
  .nav-desktop a {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    font-size: 0.9rem;
  }
  
  .nav-desktop a:hover {
    background: var(--bg);
    color: var(--primary);
  }
  
  .hero { padding: 4rem 2rem; }
  .hero h1 { font-size: 2.5rem; }
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
  .section { padding: 3rem 2rem; }
}

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

/* === UTILITY === */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
