/* ============================================================
   BlogSphere AI — Core Design System
   "Discover. Learn. Share. Inspire."
   ============================================================
   This file is the single source of visual truth for the whole
   site. Every page loads this first. Category colors below are
   the site's signature: each niche keeps ONE color everywhere
   (nav underline, article tags, badges) so readers always know
   which section they're in at a glance — like colored tabs in a
   print magazine.
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300..700&family=Fraunces:ital,opsz,wght@1,9..144,400..600&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Base palette — warm ink & paper, not the default cream/terracotta combo */
  --ink: #1C1B19;
  --ink-soft: #4A4842;
  --paper: #FAF9F6;
  --paper-raised: #FFFFFF;
  --paper-sunken: #F1EFE9;
  --rule: #DEDAD2;
  --rule-strong: #C6C1B6;
  --brand: #5B3FF0;        /* electric violet — primary UI accent */
  --brand-soft: #ECE7FE;

  /* Category signature colors — the "magazine tabs" (vibrant, saturated) */
  --cat-personal: #FF6F59;
  --cat-travel: #00BFA6;
  --cat-food: #FFA400;
  --cat-tech: #2F6FED;
  --cat-ai: #8338EC;
  --cat-finance: #06A77D;
  --cat-health: #FF3D77;
  --cat-lifestyle: #C86BFA;
  --cat-photography: #E6B800;
  --cat-books: #D7263D;

  /* Semantic */
  --success: #06A77D;
  --warning: #FFA400;
  --danger: #D7263D;

  /* Type scale */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;
  --fs-5xl: 4rem;

  /* Spacing (8px base) */
  --sp-1: 0.5rem;
  --sp-2: 0.75rem;
  --sp-3: 1rem;
  --sp-4: 1.5rem;
  --sp-5: 2rem;
  --sp-6: 3rem;
  --sp-7: 4rem;
  --sp-8: 6rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(28,27,25,0.08);
  --shadow-md: 0 4px 16px rgba(28,27,25,0.10);
  --shadow-lg: 0 12px 32px rgba(28,27,25,0.14);

  --container-max: 1240px;
  --transition: 180ms ease;
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
  --ink: #F2F0EB;
  --ink-soft: #C7C3BA;
  --paper: #171614;
  --paper-raised: #201F1C;
  --paper-sunken: #121110;
  --rule: #34322D;
  --rule-strong: #45423B;
  --brand-soft: #2A2350;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-base);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-5xl); }
h2 { font-size: var(--fs-3xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-lg); }

/* Visible keyboard focus everywhere — accessibility floor */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--brand); color: #fff;
  padding: var(--sp-2) var(--sp-3); z-index: 999;
}
.skip-link:focus { left: var(--sp-3); top: var(--sp-3); }

/* ============ MASTHEAD (site nameplate) ============ */
.masthead {
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-2) 0;
}
.masthead .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
}
.masthead-date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.masthead-actions { display: flex; align-items: center; gap: var(--sp-3); }

.logo {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.logo-mark { color: var(--brand); font-style: italic; }
.tagline {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ============ PRIMARY NAV ============ */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-2) 0;
}
.nav-links {
  display: flex; gap: var(--sp-4); flex-wrap: wrap;
  overflow-x: auto;
}
.nav-links a {
  font-size: var(--fs-sm); font-weight: 500;
  padding: var(--sp-1) 0; white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: border-color var(--transition), color var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--brand); border-color: var(--brand); }
/* When a category link is active, underline in that category's own color */
.nav-links a[data-cat="travel"].active { border-color: var(--cat-travel); color: var(--cat-travel); }
.nav-links a[data-cat="food"].active { border-color: var(--cat-food); color: var(--cat-food); }
.nav-links a[data-cat="tech"].active { border-color: var(--cat-tech); color: var(--cat-tech); }
.nav-links a[data-cat="ai"].active { border-color: var(--cat-ai); color: var(--cat-ai); }
.nav-links a[data-cat="finance"].active { border-color: var(--cat-finance); color: var(--cat-finance); }
.nav-links a[data-cat="health"].active { border-color: var(--cat-health); color: var(--cat-health); }
.nav-links a[data-cat="lifestyle"].active { border-color: var(--cat-lifestyle); color: var(--cat-lifestyle); }
.nav-links a[data-cat="photography"].active { border-color: var(--cat-photography); color: var(--cat-photography); }
.nav-links a[data-cat="books"].active { border-color: var(--cat-books); color: var(--cat-books); }
.nav-links a[data-cat="personal"].active { border-color: var(--cat-personal); color: var(--cat-personal); }

.nav-tools { display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-sunken); color: var(--ink);
  transition: background var(--transition);
}
.icon-btn:hover { background: var(--rule); }

.nav-toggle { display: none; }

@media (max-width: 900px) {
  .nav-links {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    flex-direction: column; gap: 0; padding: var(--sp-2) var(--sp-4);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: var(--sp-2) 0; border-bottom: 1px solid var(--rule); width: 100%; }
  .nav-toggle { display: flex; }
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-outline { border: 1px solid var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--paper); }
.btn-ghost { color: var(--brand); }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }

/* ============ CATEGORY TAG / BADGE (signature element) ============ */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: var(--fs-xs);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px;
}
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-personal { background: color-mix(in srgb, var(--cat-personal) 12%, transparent); color: var(--cat-personal); }
.tag-travel { background: color-mix(in srgb, var(--cat-travel) 12%, transparent); color: var(--cat-travel); }
.tag-food { background: color-mix(in srgb, var(--cat-food) 12%, transparent); color: var(--cat-food); }
.tag-tech { background: color-mix(in srgb, var(--cat-tech) 12%, transparent); color: var(--cat-tech); }
.tag-ai { background: color-mix(in srgb, var(--cat-ai) 12%, transparent); color: var(--cat-ai); }
.tag-finance { background: color-mix(in srgb, var(--cat-finance) 12%, transparent); color: var(--cat-finance); }
.tag-health { background: color-mix(in srgb, var(--cat-health) 12%, transparent); color: var(--cat-health); }
.tag-lifestyle { background: color-mix(in srgb, var(--cat-lifestyle) 12%, transparent); color: var(--cat-lifestyle); }
.tag-photography { background: color-mix(in srgb, var(--cat-photography) 12%, transparent); color: var(--cat-photography); }
.tag-books { background: color-mix(in srgb, var(--cat-books) 12%, transparent); color: var(--cat-books); }

/* Left "spine" accent bar used on article cards — the color-tab signature */
.spine { border-left: 4px solid var(--cat-personal); padding-left: var(--sp-3); }
.spine.travel { border-color: var(--cat-travel); }
.spine.food { border-color: var(--cat-food); }
.spine.tech { border-color: var(--cat-tech); }
.spine.ai { border-color: var(--cat-ai); }
.spine.finance { border-color: var(--cat-finance); }
.spine.health { border-color: var(--cat-health); }
.spine.lifestyle { border-color: var(--cat-lifestyle); }
.spine.photography { border-color: var(--cat-photography); }
.spine.books { border-color: var(--cat-books); }

/* ============ CARDS ============ */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-img { aspect-ratio: 16/10; background: var(--paper-sunken); overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
.card-title { font-size: var(--fs-lg); font-weight: 600; font-family: var(--font-display); }
.card-excerpt { font-size: var(--fs-sm); color: var(--ink-soft); }
.card-meta {
  display: flex; align-items: center; gap: var(--sp-2);
  font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-soft);
}

/* ============ GRIDS ============ */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Masonry (real columns, progressively enhanced by masonry.js if present) */
.masonry { column-count: 3; column-gap: var(--sp-4); }
.masonry .card { break-inside: avoid; margin-bottom: var(--sp-4); }
@media (max-width: 1000px) { .masonry { column-count: 2; } }
@media (max-width: 640px) { .masonry { column-count: 1; } }

/* ============ SECTION ============ */
.section { padding: var(--sp-7) 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: var(--sp-5); gap: var(--sp-3); flex-wrap: wrap;
}
.section-head h2 { font-size: var(--fs-3xl); }

/* ============ HERO ============ */
.hero {
  padding: var(--sp-7) 0;
  border-bottom: 1px solid var(--rule);
}
.hero-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-5); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.hero-lead { position: relative; border-radius: var(--radius-lg); overflow: hidden; }
.hero-lead img { width: 100%; height: 460px; object-fit: cover; }
.hero-lead-text {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--sp-5);
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  color: #fff;
}
.hero-lead-text h1 { font-size: var(--fs-3xl); color: #fff; }
.hero-side { display: flex; flex-direction: column; gap: var(--sp-3); }
.hero-side-item {
  display: flex; gap: var(--sp-3); padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--rule);
}
.hero-side-item img { width: 96px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }

/* ============ NEWSLETTER ============ */
.newsletter-box {
  background: linear-gradient(135deg, var(--brand) 0%, #8338EC 55%, #D7263D 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--sp-6); text-align: center;
}
.newsletter-box h2 { color: #fff; }
.newsletter-form {
  display: flex; gap: var(--sp-2); max-width: 460px; margin: var(--sp-4) auto 0;
}
.newsletter-form input {
  flex: 1; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm); border: none;
}
.newsletter-form .btn { background: #fff; color: var(--brand); }

/* ============ FOOTER ============ */
.site-footer {
  background: var(--paper-sunken);
  border-top: 1px solid var(--rule);
  padding: var(--sp-7) 0 var(--sp-4);
  margin-top: var(--sp-8);
}
.footer-grid {
  display: grid; grid-template-columns: 1.5fr repeat(4, 1fr);
  gap: var(--sp-5); padding-bottom: var(--sp-5);
}
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
.footer-col h4 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-3); }
.footer-col ul { display: flex; flex-direction: column; gap: var(--sp-2); }
.footer-col a { font-size: var(--fs-sm); color: var(--ink-soft); }
.footer-col a:hover { color: var(--brand); }
.footer-bottom {
  border-top: 1px solid var(--rule); padding-top: var(--sp-4);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--ink-soft);
}
.footer-social { display: flex; gap: var(--sp-2); }

/* ============ TOAST ============ */
.toast-wrap { position: fixed; bottom: var(--sp-4); right: var(--sp-4); z-index: 999; display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  background: var(--ink); color: var(--paper);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm);
  animation: toast-in 200ms ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ SKELETON LOADING ============ */
.skeleton {
  background: linear-gradient(90deg, var(--paper-sunken) 25%, var(--rule) 37%, var(--paper-sunken) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ============ READING PROGRESS BAR ============ */
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--brand); z-index: 200; transition: width 80ms linear;
}

/* ============ UTILITIES ============ */
.text-center { text-align: center; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-5 { margin-top: var(--sp-5); } .mt-auto { margin-top: auto; }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-5 { margin-bottom: var(--sp-5); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
