/* ============================================================
   Sprunke — Apple-inspired editorial design system
   Light-first, auto dark mode. 4pt spacing, fluid display type.
   ============================================================ */

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

/* ===== Design tokens ===== */
:root {
  /* Tinted neutrals — warm-cool balanced, near-black ink */
  --bg: oklch(98.5% 0.002 250);
  --bg-elevated: oklch(100% 0 0);
  --bg-subtle: oklch(96.5% 0.003 250);
  --ink: oklch(21% 0.01 250);
  --ink-secondary: oklch(45% 0.01 250);
  --ink-tertiary: oklch(58% 0.008 250);
  --hairline: oklch(90% 0.004 250);
  --hairline-strong: oklch(84% 0.005 250);

  /* Accent — Apple blue family, used sparingly (links, focus, CTA) */
  --accent: oklch(55% 0.19 255);
  --accent-hover: oklch(48% 0.19 255);
  --accent-visited: oklch(45% 0.13 265);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC",
    "PingFang SC", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro SC",
    "PingFang SC", "Helvetica Neue", system-ui, sans-serif;

  /* Fluid type scale — display dominates, body fixed for readability */
  --text-hero: clamp(2.75rem, 6.5vw, 5rem);
  --text-display: clamp(2rem, 4.5vw, 3.25rem);
  --text-title: clamp(1.375rem, 2.2vw, 1.75rem);
  --text-lead: clamp(1.0625rem, 1.4vw, 1.1875rem);
  --text-body: 1.0625rem;
  --text-sm: 0.9375rem;
  --text-xs: 0.8125rem;

  --leading-tight: 1.07;
  --leading-snug: 1.3;
  --leading-body: 1.65;

  /* 4pt spacing scale */
  --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; --space-20: 80px; --space-28: 112px;

  /* Elevation — barely-there, Apple style */
  --shadow-card: 0 1px 3px oklch(21% 0.01 250 / 0.04);
  --shadow-hover: 0 8px 28px oklch(21% 0.01 250 / 0.08);

  /* Motion */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --header-height: 52px;
  --content-width: 1120px;
  --reading-width: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(17% 0.006 255);
    --bg-elevated: oklch(21% 0.007 255);
    --bg-subtle: oklch(14.5% 0.006 255);
    --ink: oklch(93% 0.004 255);
    --ink-secondary: oklch(72% 0.008 255);
    --ink-tertiary: oklch(58% 0.007 255);
    --hairline: oklch(28% 0.008 255);
    --hairline-strong: oklch(36% 0.01 255);
    --accent: oklch(68% 0.16 250);
    --accent-hover: oklch(75% 0.14 250);
    --accent-visited: oklch(62% 0.12 265);
    --shadow-card: 0 1px 3px oklch(0% 0 0 / 0.25);
    --shadow-hover: 0 8px 28px oklch(0% 0 0 / 0.45);
  }
}

/* ===== Base ===== */
html { font-size: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

::selection { background: var(--accent); color: var(--bg-elevated); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ===== Layout helpers ===== */
.container {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 4vw, var(--space-10));
}

.container-narrow {
  max-width: 51rem;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  backdrop-filter: saturate(1.8) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}

.site-header-inner {
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: clamp(var(--space-5), 4vw, var(--space-10));
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}

.logo {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.logo:hover { color: var(--ink); text-decoration: none; }

.site-nav { display: flex; gap: clamp(var(--space-5), 3vw, var(--space-8)); }

.site-nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-secondary);
  padding: 6px 2px;
  transition: color 150ms var(--ease-out-quart);
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--ink); }

/* ===== Hero (magazine front page) ===== */
.hero {
  padding-block: clamp(var(--space-16), 9vw, var(--space-28)) var(--space-12);
  text-align: center;
}

.hero-eyebrow {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin-bottom: var(--space-4);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
  margin-inline: auto;
  max-width: 18ch;
}

.hero-sub {
  font-size: var(--text-lead);
  color: var(--ink-secondary);
  max-width: 44ch;
  margin: var(--space-5) auto 0;
  line-height: 1.55;
}

.hero-cta {
  display: inline-flex;
  margin-top: var(--space-8);
  font-size: var(--text-body);
  font-weight: 500;
}
.hero-cta .cta-arrow {
  margin-left: 4px;
  transition: transform 200ms var(--ease-out-quart);
}
.hero-cta:hover .cta-arrow { transform: translateX(3px); }

/* ===== Featured article (front-page spotlight) ===== */
.featured {
  border-block: 0.5px solid var(--hairline);
  padding-block: clamp(var(--space-10), 5vw, var(--space-16));
}
.featured-link {
  display: grid;
  gap: var(--space-6);
  color: inherit;
}
.featured-link:hover { text-decoration: none; }

.featured-eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.featured-title {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  max-width: 22ch;
  transition: color 200ms var(--ease-out-quart);
}
.featured-link:hover .featured-title { color: var(--accent); }

.featured-meta {
  font-size: var(--text-sm);
  color: var(--ink-tertiary);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.featured-meta .dot { opacity: 0.5; }

.featured-readmore {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== Section headers ===== */
.section { padding-block: clamp(var(--space-10), 5vw, var(--space-16)); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: clamp(var(--space-6), 3vw, var(--space-10));
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-title);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-more {
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

/* ===== Home grid (random picks) ===== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: var(--space-6) var(--space-5);
}

.article-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 0.5px solid var(--hairline);
  box-shadow: var(--shadow-card);
  transition: transform 300ms var(--ease-out-quart),
              box-shadow 300ms var(--ease-out-quart);
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.article-card .card-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.article-card h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.article-card a { color: var(--ink); display: block; }
.article-card a:hover { color: var(--accent); text-decoration: none; }

.article-card .card-meta {
  margin-top: auto;
  padding-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-tertiary);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.article-card .card-meta .dot { opacity: 0.5; }

/* ===== Editorial list (articles page) ===== */
.page-head {
  padding-block: clamp(var(--space-12), 6vw, var(--space-20)) var(--space-8);
  text-align: center;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: var(--leading-tight);
}
.page-head p {
  margin-top: var(--space-3);
  font-size: var(--text-lead);
  color: var(--ink-secondary);
}

.article-list {
  display: flex;
  flex-direction: column;
  max-width: var(--reading-width);
  margin-inline: auto;
  padding-block: var(--space-2) var(--space-12);
}

.article-row {
  display: block;
  padding-block: var(--space-6);
  border-bottom: 0.5px solid var(--hairline);
  transition: padding 250ms var(--ease-out-quart);
}
.article-row:first-child { border-top: 0.5px solid var(--hairline); }

.article-row h2 {
  font-family: var(--font-display);
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--ink);
  transition: color 200ms var(--ease-out-quart);
}
.article-row:hover h2 { color: var(--accent); }
.article-row:hover { text-decoration: none; }

.article-row .row-meta {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-tertiary);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.article-row .row-meta .dot { opacity: 0.5; }

/* ===== Article page ===== */
.article-hero {
  padding-block: clamp(var(--space-12), 6vw, var(--space-20)) var(--space-8);
  text-align: center;
}

.article-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  max-width: 24ch;
  margin-inline: auto;
}

.article-hero .article-meta {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--ink-tertiary);
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.article-hero .article-meta .dot { opacity: 0.5; }

.article-body {
  max-width: var(--reading-width);
  margin-inline: auto;
  padding-block: var(--space-4) clamp(var(--space-12), 6vw, var(--space-20));
  font-size: 1.0625rem;
  line-height: 1.75;
}

.article-body > * + * { margin-block-start: var(--space-5); }

.article-body h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-block: var(--space-10) var(--space-4);
}
.article-body h3 {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 600;
  margin-block: var(--space-8) var(--space-3);
}

.article-body p { max-width: 70ch; }

.article-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin-block: var(--space-6);
}

.article-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 5px;
}

.article-body pre {
  background: var(--bg-subtle);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}
.article-body pre code { background: none; padding: 0; font-variant-ligatures: none; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: var(--space-2) var(--space-5);
  color: var(--ink-secondary);
  font-style: normal;
}

.article-body ul, .article-body ol {
  padding-left: var(--space-6);
}
.article-body li { margin-block: var(--space-2); }

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.article-body th, .article-body td {
  border: 0.5px solid var(--hairline);
  padding: var(--space-3) var(--space-4);
  text-align: left;
}
.article-body th { background: var(--bg-subtle); font-weight: 600; }

.article-body hr {
  border: none;
  border-top: 0.5px solid var(--hairline);
  margin-block: var(--space-10);
}

.article-body a { word-break: break-word; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding-block: var(--space-8) var(--space-16);
}

.pagination a,
.pagination span {
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: var(--space-3);
  border-radius: 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-secondary);
  transition: background 150ms var(--ease-out-quart), color 150ms var(--ease-out-quart);
}
.pagination a:hover { background: var(--bg-subtle); color: var(--ink); text-decoration: none; }
.pagination .current {
  background: var(--ink);
  color: var(--bg-elevated);
}
.pagination .gap { color: var(--ink-tertiary); border: none; }
.pagination .disabled { opacity: 0.4; }

/* ===== Footer ===== */
.site-footer {
  border-top: 0.5px solid var(--hairline);
  background: var(--bg-subtle);
}

.site-footer-inner {
  max-width: var(--content-width);
  margin-inline: auto;
  padding: var(--space-10) clamp(var(--space-5), 4vw, var(--space-10)) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.site-footer .footer-links {
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.site-footer .footer-links a {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}
.site-footer .footer-links a:hover { color: var(--ink); text-decoration: none; }

.site-footer .footer-legal {
  font-size: var(--text-xs);
  color: var(--ink-tertiary);
}

/* ===== States: loading / empty ===== */
.state-box {
  display: grid;
  place-items: center;
  gap: var(--space-3);
  padding-block: var(--space-16);
  color: var(--ink-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

/* Skeleton shimmer for article cards */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: var(--space-6) var(--space-5);
}
.skeleton-card {
  border-radius: var(--radius-md);
  border: 0.5px solid var(--hairline);
  background: var(--bg-elevated);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.skeleton-card .sk {
  border-radius: 6px;
  background: linear-gradient(90deg,
    var(--bg-subtle) 25%,
    color-mix(in oklch, var(--bg-subtle) 60%, var(--bg-elevated)) 50%,
    var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-card .sk-line { height: 14px; width: 100%; }
.skeleton-card .sk-line.short { width: 55%; }
.skeleton-card .sk-tag { height: 10px; width: 72px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Row skeleton for list page */
.skeleton-rows { display: flex; flex-direction: column; gap: var(--space-6); }
.skeleton-row { display: flex; flex-direction: column; gap: var(--space-3); }
.skeleton-rows .sk {
  border-radius: 6px;
  height: 14px;
  background: linear-gradient(90deg,
    var(--bg-subtle) 25%,
    color-mix(in oklch, var(--bg-subtle) 60%, var(--bg-elevated)) 50%,
    var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-rows .sk-title { width: 62%; height: 20px; }
.skeleton-rows .sk-meta { width: 34%; height: 12px; }

/* ===== Entrance animation ===== */
@media (prefers-reduced-motion: no-preference) {
  .rise-in {
    opacity: 0;
    transform: translateY(14px);
    animation: rise-in 600ms var(--ease-out-expo) forwards;
    animation-delay: calc(var(--i, 0) * 60ms);
  }
  @keyframes rise-in {
    to { opacity: 1; transform: none; }
  }
  .hero h1, .hero-sub, .hero-cta {
    opacity: 0;
    animation: rise-in 700ms var(--ease-out-expo) forwards;
  }
  .hero-sub { animation-delay: 120ms; }
  .hero-cta { animation-delay: 240ms; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .site-nav { gap: var(--space-4); }
  .section-head { flex-direction: column; gap: var(--space-2); }
  .featured-link { gap: var(--space-4); }
  .article-list { padding-inline: var(--space-5); }
}

@media (max-width: 480px) {
  .hero h1 { max-width: 14ch; }
  .home-grid { grid-template-columns: 1fr; }
}

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .pagination, .hero-cta { display: none; }
  body { background: white; color: black; }
  .article-body { max-width: none; }
}
