/* =========================================
   Design Tokens — Light (default)
   ========================================= */
:root {
  --bg: #f4f7f5;
  --bg-2: #e8f0eb;
  --text: #0e1f28;
  --text-2: #1a2f3a;
  --muted: #536d7a;
  --card: #ffffff;
  --line: #d1ddd5;
  --brand: #0a7c86;
  --brand-light: rgba(10, 124, 134, 0.1);
  --accent: #e9722e;
  --accent-2: #22577a;
  --shadow-sm: 0 2px 8px rgba(22, 38, 40, 0.06);
  --shadow: 0 8px 30px rgba(22, 38, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(22, 38, 40, 0.12);
  --radius: 0.75rem;
  --radius-lg: 1.1rem;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --header-bg: rgba(244, 247, 245, 0.88);
  color-scheme: light;
}

/* =========================================
   Design Tokens — Dark
   ========================================= */
[data-theme="dark"] {
  --bg: #0f171c;
  --bg-2: #162028;
  --text: #e2eae5;
  --text-2: #c5d0ca;
  --muted: #8a9da8;
  --card: #1a2730;
  --line: #283840;
  --brand: #2cc5d0;
  --brand-light: rgba(44, 197, 208, 0.12);
  --accent: #f0944e;
  --accent-2: #5badd4;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(15, 23, 28, 0.9);
  color-scheme: dark;
}

/* =========================================
   Reset & Base
   ========================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle gradient overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(34, 87, 122, 0.12), transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(233, 114, 46, 0.08), transparent 50%);
}

/* =========================================
   Background Orbs
   ========================================= */
.bg-orb {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.25;
  transition: opacity var(--transition);
}

[data-theme="dark"] .bg-orb {
  opacity: 0.1;
}

.orb-a {
  width: 320px;
  height: 320px;
  right: -100px;
  top: 60px;
  background: #7fd4d7;
}

.orb-b {
  width: 280px;
  height: 280px;
  left: -90px;
  bottom: 40px;
  background: #f8a77d;
}

/* =========================================
   Layout
   ========================================= */
.container {
  width: min(1140px, 90vw);
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* =========================================
   Header & Navigation
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  transition: opacity var(--transition);
}

.brand:hover {
  opacity: 0.8;
}

.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--accent-2));
  box-shadow: 0 2px 8px rgba(10, 124, 134, 0.3);
}

/* Mobile hamburger button */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
  border-radius: var(--radius);
  transition: background var(--transition);
}

.nav-toggle:hover {
  background: var(--brand-light);
}

.nav-toggle svg {
  display: block;
  width: 24px;
  height: 24px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--brand-light);
}

.site-nav a.active {
  color: var(--brand);
  background: var(--brand-light);
}

/* Dark mode toggle in nav */
.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 999px;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  margin-left: 0.35rem;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--brand-light);
  border-color: var(--brand);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }

[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }

/* =========================================
   Hero Section
   ========================================= */
.hero {
  padding: 4rem 0 2.5rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 2rem;
  align-items: start;
}

.hero-copy h1 {
  margin: 0.4rem 0 0.8rem;
  line-height: 1.15;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero-copy p {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-2);
}

.kicker {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--brand);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  background: var(--brand-light);
}

.hero-actions {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.7rem 1.2rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--accent-2));
  box-shadow: 0 4px 14px rgba(10, 124, 134, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(10, 124, 134, 0.35);
}

.btn-ghost {
  color: var(--text);
  border-color: var(--line);
  background: var(--card);
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

/* =========================================
   Hero Side Panel
   ========================================= */
.hero-panel {
  display: grid;
  gap: 1rem;
}

/* =========================================
   Cards — Shared Base
   ========================================= */
.panel-card,
.topic-card,
.article-card,
.article-main,
.side-card,
.page-content,
.cta-banner {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

/* =========================================
   Panel Cards
   ========================================= */
.panel-card {
  padding: 1.2rem 1.3rem;
}

.panel-card h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
}

.panel-card ul {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  color: var(--text-2);
}

/* =========================================
   Ad Slots
   ========================================= */
.ad-slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 0.8rem 1rem;
}

.ad-slot.compact {
  min-height: 110px;
}

.ad-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.ad-slot p {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* =========================================
   Topic Grid (Focus Areas)
   ========================================= */
.topic-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
}

.topic-card {
  padding: 1.1rem;
}

.topic-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.topic-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.topic-card p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* =========================================
   Section Headers
   ========================================= */
.section-head {
  margin-bottom: 0.25rem;
}

.section-head h2 {
  margin-bottom: 0.2rem;
  font-size: 1.6rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* =========================================
   Article Grid & Cards
   ========================================= */
.article-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.article-card {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.chip {
  margin: 0;
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.article-card h3 {
  margin: 0.55rem 0 0.4rem;
  line-height: 1.35;
  font-size: 1.05rem;
}

.article-card h3 a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.article-card h3 a:hover {
  color: var(--brand);
}

.article-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  flex: 1;
}

/* Article card metadata */
.article-card .article-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.article-card .article-meta time {
  font-weight: 500;
}

.read-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}
}

/* =========================================
   CTA Banner
   ========================================= */
.cta-banner {
  margin: 2rem 0 2.5rem;
  padding: 1.5rem 1.5rem;
  text-align: left;
}

.cta-banner h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.cta-banner p {
  margin: 0.3rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.cta-banner a {
  color: var(--brand);
  font-weight: 600;
}

.cta-banner a:hover {
  color: var(--accent);
}

/* =========================================
   Forms
   ========================================= */
.inline-form,
.stack-form {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.55rem;
}

.inline-form input,
.stack-form input,
.stack-form textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  background: var(--card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.inline-form input:focus,
.stack-form input:focus,
.stack-form textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.inline-form button,
.stack-form button {
  font: inherit;
  border: 0;
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
}

.inline-form button:hover,
.stack-form button:hover {
  background: #d5641f;
  transform: translateY(-1px);
}

/* =========================================
   Article Layout (two-column)
   ========================================= */
.article-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.5rem;
  padding: 2rem 0;
}

.article-main,
.article-side .side-card,
.page-content {
  padding: 1.4rem 1.5rem;
}

.article-main h1 {
  margin: 0.2rem 0 0.3rem;
  line-height: 1.2;
  font-size: 1.8rem;
  letter-spacing: -0.01em;
}

.article-main h2 {
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
  font-size: 1.3rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

.article-main h3 {
  margin-top: 1.3rem;
  margin-bottom: 0.3rem;
}

.article-meta {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.article-main pre {
  margin: 1rem 0;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: #101b22;
  color: #d8f4ee;
  overflow-x: auto;
  border: 1px solid #1e3040;
  font-size: 0.88rem;
  line-height: 1.55;
  position: relative;
}

.article-main code {
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.88rem;
}

/* Inline code */
.article-main p code,
.article-main li code,
.page-content p code,
.page-content li code {
  background: var(--brand-light);
  color: var(--brand);
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.85em;
}

[data-theme="dark"] .article-main p code,
[data-theme="dark"] .article-main li code,
[data-theme="dark"] .page-content p code,
[data-theme="dark"] .page-content li code {
  background: rgba(44, 197, 208, 0.12);
}

.article-main ul,
.article-side ul,
.page-content ul {
  padding-left: 1.3rem;
}

.article-main li,
.page-content li {
  margin-bottom: 0.3rem;
}

/* =========================================
   Article Sidebar
   ========================================= */
.article-side {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  position: sticky;
  top: 4.8rem;
  height: fit-content;
}

.side-card h3 {
  margin-top: 0;
  font-size: 1rem;
}

.side-card ul {
  margin: 0;
}

.side-card a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition);
}

.side-card a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* =========================================
   Standalone Content Pages
   ========================================= */
.page-content {
  margin: 2rem auto;
  max-width: 760px;
  padding: 2rem 2.2rem;
}

.page-content h1 {
  font-size: 1.8rem;
  margin-top: 0;
}

.page-content h2 {
  margin-top: 1.8rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

/* =========================================
   Forms — Stacked
   ========================================= */
.stack-form {
  flex-direction: column;
}

.stack-form label {
  font-weight: 600;
  margin-top: 0.2rem;
}

/* =========================================
   Breadcrumbs
   ========================================= */
.breadcrumb {
  font-size: 0.88rem;
  color: var(--muted);
  padding: 0.6rem 0;
}

.breadcrumb a {
  color: var(--brand);
  text-decoration: none;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.breadcrumb .sep {
  margin: 0 0.4rem;
  opacity: 0.5;
}

/* =========================================
   Footer
   ========================================= */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  background: var(--card);
}

.footer-row {
  padding: 1.2rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.footer-row p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.footer-row nav {
  display: flex;
  gap: 1rem;
}

.footer-row a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color var(--transition);
}

.footer-row a:hover {
  color: var(--brand);
}

/* =========================================
   Accessibility Utilities
   ========================================= */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.75rem 1.5rem;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(10, 124, 134, 0.4);
  transition: top 0.2s ease;
}

.skip-to-content:focus {
  top: 1rem;
}

/* Enhanced focus indicators */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

.site-nav a:focus-visible {
  outline-offset: 4px;
}

.article-card:focus-within {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--brand);
}

/* =========================================
   Reveal Animations
   ========================================= */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delay for grids */
.reveal-stagger > *:nth-child(1) { transition-delay: 0s; }
.reveal-stagger > *:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger > *:nth-child(3) { transition-delay: 0.16s; }
.reveal-stagger > *:nth-child(4) { transition-delay: 0.24s; }

/* =========================================
   Back to Top Button
   ========================================= */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 50;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition), background var(--transition);
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* =========================================
   Responsive — Tablet
   ========================================= */
@media (max-width: 960px) {
  .hero-grid,
  .article-grid {
    grid-template-columns: 1fr;
  }

  .topic-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .article-shell {
    grid-template-columns: 1fr;
  }

  .article-side {
    position: static;
  }

  .page-content {
    padding: 1.5rem;
  }
}

/* =========================================
   Responsive — Mobile
   ========================================= */
@media (max-width: 640px) {
  .nav-toggle {
    display: block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 0.75rem 1.25rem 1rem;
    gap: 0.1rem;
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    width: 100%;
  }

  .site-nav a:hover {
    background: var(--brand-light);
  }

  .theme-toggle {
    width: fit-content;
    margin-left: 0.75rem;
    margin-top: 0.25rem;
  }

  .topic-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
  }

  .hero {
    padding-top: 2.5rem;
  }

  .hero-copy h1 {
    font-size: 1.7rem;
  }

  .cta-banner {
    padding: 1.3rem;
  }

  .back-to-top {
    bottom: 1.2rem;
    right: 1.2rem;
  }
}

/* =========================================
   Selection Styling
   ========================================= */
::selection {
  background: rgba(10, 124, 134, 0.2);
  color: var(--text);
}

/* =========================================
   Smooth transitions for theme switch
   ========================================= */
body,
.site-header,
.panel-card,
.topic-card,
.article-card,
.article-main,
.side-card,
.page-content,
.cta-banner,
.site-footer,
.ad-slot {
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}
