/* ========================================
   Publication Template
   Inspired by The Atlantic & New York Times
   ======================================== */

:root {
  /* Typography */
  --font-serif: "Georgia", "Times New Roman", "Times", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Scale — major third (1.25) */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.125rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.375rem;
  --text-4xl: 3rem;
  --text-5xl: 3.75rem;

  /* Colors */
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #555555;
  --color-accent: #c0392b;
  --color-rule: #1a1a1a;
  --color-rule-light: #e0e0e0;
  --color-bg-warm: #faf8f5;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;

  /* Layout */
  --max-width: 1200px;
  --reading-width: 680px;

  /* Toggle — neumorphic surface */
  --toggle-bg: #e8e4df;
  --toggle-shadow-light: #ffffff;
  --toggle-shadow-dark: #c5c0b8;
  --toggle-knob: #ffffff;
  --toggle-knob-shadow-light: #ffffff;
  --toggle-knob-shadow-dark: #d1cdc6;
}

[data-theme="dark"] {
  --color-bg: #141414;
  --color-text: #e8e4df;
  --color-text-secondary: #999490;
  --color-accent: #e0604d;
  --color-rule: #e8e4df;
  --color-rule-light: #2a2a2a;
  --color-bg-warm: #1c1c1c;

  --toggle-bg: #2a2826;
  --toggle-shadow-light: #363330;
  --toggle-shadow-dark: #1a1816;
  --toggle-knob: #3a3735;
  --toggle-knob-shadow-light: #454240;
  --toggle-knob-shadow-dark: #1e1c1a;
}

/* ---- Image Placeholders ---- */

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(128,128,128,0.4) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(80,80,80,0.5) 0%, transparent 60%),
    radial-gradient(ellipse at 60% 80%, rgba(100,100,100,0.3) 0%, transparent 50%),
    linear-gradient(160deg, #1a1a1a 0%, #2a2a2a 100%);
}

.image-placeholder[data-section="politics"] {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(44,74,124,0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(26,42,74,0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 60% 80%, rgba(50,80,130,0.4) 0%, transparent 50%),
    linear-gradient(160deg, #0f1a2e 0%, #1a2a4a 100%);
}

.image-placeholder[data-section="culture"] {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(122,90,53,0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(74,53,32,0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 60% 80%, rgba(140,100,55,0.4) 0%, transparent 50%),
    linear-gradient(160deg, #2a1e10 0%, #4a3520 100%);
}

.image-placeholder[data-section="technology"] {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(44,106,106,0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(26,58,58,0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 60% 80%, rgba(50,120,120,0.4) 0%, transparent 50%),
    linear-gradient(160deg, #0f2020 0%, #1a3a3a 100%);
}

.image-placeholder[data-section="opinion"] {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(106,44,106,0.6) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(58,26,58,0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 60% 80%, rgba(120,50,120,0.4) 0%, transparent 50%),
    linear-gradient(160deg, #200f20 0%, #3a1a3a 100%);
}

.image-placeholder-text {
  font-family: var(--font-serif);
  font-weight: 700;
  color: rgba(255,255,255,0.06);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-3xl);
  white-space: nowrap;
  user-select: none;
}

.featured-image-placeholder .image-placeholder-text,
.section-lead-image-placeholder .image-placeholder-text {
  font-size: var(--text-5xl);
}

.story-hero-placeholder .image-placeholder-text {
  font-size: 5rem;
}

/* ---- Reset ---- */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color 0.4s ease, color 0.4s ease;
}

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

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

/* ---- Site Header ---- */

.site-header {
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
}

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

.nav-sections {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-rule-light);
  margin-bottom: var(--space-lg);
}

.nav-link {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-secondary);
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--color-text);
}

.nav-link--active {
  color: var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 2px;
}

.masthead {
  padding-bottom: var(--space-lg);
}

.masthead-link {
  display: inline-block;
}

.site-avatar {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto var(--space-sm);
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 1px var(--color-rule-light);
}

.site-name {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: var(--space-xs);
}

.site-tagline {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
}

.header-rule {
  height: 3px;
  background: var(--color-rule);
  transition: background 0.4s ease;
}

/* ---- Front Page Grid ---- */

.front-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
}

/* ---- Section Page ---- */

.section-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-xl) var(--space-2xl);
}

.section-page-header {
  text-align: center;
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-rule-light);
  margin-bottom: var(--space-2xl);
}

.section-breadcrumb {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.breadcrumb-link {
  color: var(--color-accent);
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 var(--space-sm);
  color: var(--color-text-secondary);
}

.breadcrumb-current {
  color: var(--color-text-secondary);
}

.section-page-name {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
}

.section-page-count {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.section-page-empty {
  text-align: center;
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  padding: var(--space-3xl) 0;
}

.section-lead-story {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--color-rule-light);
  margin-bottom: var(--space-2xl);
  align-items: center;
}

.section-lead-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.section-lead-image-wrap a:hover img {
  opacity: 0.9;
}

.section-lead-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.section-lead-headline {
  font-family: var(--font-serif);
  font-size: var(--text-5xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-md);
}

.section-lead-headline a:hover {
  color: var(--color-accent);
}

.section-lead-subheadline {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.section-lead-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Featured Story */

.featured-story {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--color-rule-light);
  margin-bottom: var(--space-2xl);
  align-items: center;
}

.featured-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.featured-image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.featured-image-wrap a,
.story-card > a {
  display: block;
}

.featured-image-wrap a:hover img,
.story-card > a:hover img {
  opacity: 0.9;
}

.featured-image,
.story-card-image {
  transition: opacity 0.2s ease;
}

.featured-section {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.featured-section a,
.story-card-section a {
  color: inherit;
}

.featured-section a:hover,
.story-card-section a:hover {
  text-decoration: underline;
}

.featured-headline {
  font-family: var(--font-serif);
  font-size: var(--text-5xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-md);
}

.featured-headline a:hover {
  color: var(--color-accent);
}

.featured-subheadline {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}

.featured-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Story Grid */

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.story-card {
  padding-bottom: var(--space-xl);
  border-bottom: 0.0625rem solid var(--color-rule-light);
  min-width: 0;
}

.story-card--hidden {
  display: none;
}

/* Load More Sentinel */

.load-more-sentinel {
  display: none;
}

.load-more-sentinel--active {
  display: block;
  padding: var(--space-2xl) 0;
  text-align: center;
}

.load-more-inner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
}

.load-more-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-rule-light);
  border-top-color: var(--color-text-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.story-card-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  margin-bottom: var(--space-md);
}

.story-card-image-placeholder {
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-bottom: var(--space-md);
}

.story-card-section {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
}

.story-card-headline {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}

.story-card-headline a:hover {
  color: var(--color-accent);
}

.story-card-subheadline {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

.story-card-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Section Divider */

.section-divider {
  padding: var(--space-2xl) 0 var(--space-lg);
}

.section-divider-inner {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--color-rule-light);
}

.section-divider-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--color-text-secondary);
}

/* ---- Story Breadcrumb ---- */

.story-breadcrumb {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-xl) 0;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Story Detail Page ---- */

.story-header {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl) var(--space-xl);
  text-align: center;
}

.story-detail-section {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
}

.story-detail-section a {
  color: inherit;
}

.story-detail-section a:hover {
  text-decoration: underline;
}

.story-detail-headline {
  font-family: var(--font-serif);
  font-size: var(--text-5xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-lg);
}

.story-detail-subheadline {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  line-height: 1.45;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

.story-detail-meta {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-rule-light);
}

.story-header-rule {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
  margin-top: calc(-1 * var(--space-xl) + var(--space-lg));
}

.story-header-rule-line {
  border-bottom: 1px solid var(--color-rule-light);
  margin-bottom: var(--space-2xl);
}

.story-detail-author {
  font-weight: 600;
  color: var(--color-text);
}

.story-hero-image {
  max-width: 900px;
  margin: 0 auto var(--space-2xl);
  padding: 0 var(--space-xl);
}

.story-hero-image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.story-hero-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
}

.story-image-caption {
  max-width: 900px;
  margin: calc(-1 * var(--space-2xl) + var(--space-xs)) auto var(--space-2xl);
  padding: 0 var(--space-xl);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-align: right;
}

/* Story Body — optimized for reading */

.story-body {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-3xl);
}

.story-body.markdown p {
  margin-bottom: var(--space-lg);
  font-size: var(--text-base);
  line-height: 1.8;
}

.story-body.markdown h2 {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
}

.story-body.markdown h3 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.3;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.story-body.markdown blockquote {
  border-left: 0.1875rem solid var(--color-rule);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--color-text-secondary);
  background: none;
  border-radius: 0;
}

.story-body.markdown ul,
.story-body.markdown ol {
  margin-bottom: var(--space-lg);
  padding-left: var(--space-xl);
}

.story-body.markdown li {
  margin-bottom: var(--space-sm);
}

.story-body.markdown hr {
  border: none;
  height: 0.0625rem;
  background: var(--color-rule-light);
  margin: var(--space-2xl) 0;
}

/* ---- More From Section ---- */

.more-from-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-3xl);
}

.more-from-section .section-divider {
  padding: var(--space-xl) 0 var(--space-lg);
}

.more-from-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.more-from-card {
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-rule-light);
}

.more-from-image {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  margin-bottom: var(--space-sm);
  transition: opacity 0.2s ease;
}

.more-from-card a:hover .more-from-image {
  opacity: 0.9;
}

.more-from-image-placeholder {
  width: 100%;
  aspect-ratio: 3 / 2;
  margin-bottom: var(--space-sm);
}

.more-from-headline {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
}

.more-from-headline a:hover {
  color: var(--color-accent);
}

.more-from-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.more-from-link-wrap {
  text-align: center;
}

.more-from-link {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
}

.more-from-link:hover {
  text-decoration: underline;
}

/* ---- 404 Page ---- */

.page-404 main {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
}

.page-404 h1 {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  margin-bottom: var(--space-md);
}

.page-404 p {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
}

.page-404 a {
  color: var(--color-accent);
}

.page-404 a:hover {
  text-decoration: underline;
}

/* ---- Theme Toggle (Neumorphic) ---- */

.theme-toggle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-lg);
}

.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  width: 68px;
  height: 34px;
  padding: 3px;
  border: none;
  border-radius: 17px;
  background: var(--toggle-bg);
  box-shadow:
    inset 2px 2px 5px var(--toggle-shadow-dark),
    inset -2px -2px 5px var(--toggle-shadow-light);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
  transition: color 0.3s ease;
  z-index: 1;
}

.toggle-sun {
  opacity: 0.6;
}

.toggle-moon {
  opacity: 0.6;
}

[data-theme="dark"] .toggle-moon {
  opacity: 1;
  color: var(--color-text);
}

:root:not([data-theme="dark"]) .toggle-sun {
  opacity: 1;
  color: var(--color-text);
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 14px;
  background: var(--toggle-knob);
  box-shadow:
    3px 3px 6px var(--toggle-knob-shadow-dark),
    -2px -2px 5px var(--toggle-knob-shadow-light);
  z-index: 2;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.4s ease,
              box-shadow 0.4s ease;
}

[data-theme="dark"] .toggle-knob {
  transform: translateX(34px);
}

/* ---- Footer ---- */

.site-footer {
  padding: var(--space-xl);
  text-align: center;
}

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

.footer-rule {
  height: 1px;
  background: var(--color-rule-light);
  margin-bottom: var(--space-xl);
}

.footer-name {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.footer-copyright {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .featured-story {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .featured-headline {
    font-size: var(--text-3xl);
  }

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

  .story-detail-headline {
    font-size: var(--text-3xl);
  }

  .site-name {
    font-size: var(--text-3xl);
  }

  .section-lead-story {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .section-lead-headline {
    font-size: var(--text-3xl);
  }

  .section-page-name {
    font-size: var(--text-3xl);
  }

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

@media (max-width: 600px) {
  .story-grid {
    grid-template-columns: 1fr;
  }

  .nav-sections {
    flex-wrap: wrap;
    gap: var(--space-sm) var(--space-md);
  }

  .front-page {
    padding: var(--space-xl) var(--space-md);
  }

  .site-header {
    padding: var(--space-md);
  }

  .featured-headline {
    font-size: var(--text-2xl);
  }

  .story-detail-headline {
    font-size: var(--text-2xl);
  }

  .story-header {
    padding: var(--space-xl) var(--space-md) var(--space-md);
  }

  .story-body {
    padding: 0 var(--space-md) var(--space-2xl);
  }

  .story-hero-image,
  .story-image-caption {
    padding: 0 var(--space-md);
  }

  .site-name {
    font-size: var(--text-2xl);
  }

  .section-page {
    padding: var(--space-xl) var(--space-md) var(--space-2xl);
  }

  .section-lead-headline {
    font-size: var(--text-2xl);
  }

  .section-page-name {
    font-size: var(--text-2xl);
  }

  .more-from-grid {
    grid-template-columns: 1fr;
  }

  .story-breadcrumb {
    padding: var(--space-md) var(--space-md) 0;
  }

  .more-from-section {
    padding: 0 var(--space-md) var(--space-2xl);
  }
}

/* ==================== Skip Link ==================== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bg, #fff);
  color: var(--text, #000);
  border: 2px solid var(--text, #000);
  padding: 1rem 1.25rem;
  font-weight: 600;
  z-index: 99999;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* ==================== 404 Page ==================== */
/* IDs scoped under #not-found in case generic body / page styles
   would otherwise override .not-found-code's clamp() font-size. */
#not-found {
  max-width: 38rem;
  margin: 0 auto;
  padding: 6rem 1.5rem;
  text-align: center;
}
#not-found .not-found-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  opacity: 0.6;
}
#not-found .not-found-code {
  font-family: var(--font-serif, Georgia, "Times New Roman", serif);
  font-size: clamp(7rem, 22vw, 12rem);
  font-weight: 700;
  line-height: 1;
  margin: 0 0 1.25rem;
}
#not-found .not-found-title {
  font-family: var(--font-serif, Georgia, "Times New Roman", serif);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-style: italic;
  font-weight: 400;
  margin-bottom: 1rem;
}
#not-found .not-found-description {
  margin: 0 auto 2rem;
  max-width: 32rem;
  line-height: 1.7;
  opacity: 0.8;
}
#not-found .not-found-cta {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: 1px solid currentColor;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
#not-found .not-found-cta:hover {
  background: currentColor;
}
#not-found .not-found-cta:hover {
  color: var(--bg, #fff);
}

/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== Markdown Content ====================
   Shared element styles for any rendered markdown surface.
   Apply `class="markdown"` to the wrapping element. The
   `.story-body.markdown` rules above take precedence for
   reading-optimized prose; this block fills in everything else. */

.markdown {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--color-text);
  text-align: left;
}

.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }

.markdown p {
  margin: 0 0 var(--space-lg);
  line-height: 1.8;
  color: inherit;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  font-family: var(--font-serif);
  color: var(--color-text);
  font-weight: 700;
  line-height: 1.2;
  margin: var(--space-xl) 0 var(--space-md);
}
.markdown h1 { font-size: var(--text-3xl, 2.5rem); }
.markdown h2 { font-size: var(--text-2xl); }
.markdown h3 { font-size: var(--text-xl); }
.markdown h4 {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
}

.markdown h1 a.anchor,
.markdown h2 a.anchor,
.markdown h3 a.anchor,
.markdown h4 a.anchor,
.markdown h5 a.anchor,
.markdown h6 a.anchor {
  border-bottom: none;
  color: inherit;
  text-decoration: none;
}

.markdown strong { color: var(--color-text); font-weight: 700; }
.markdown em { font-style: italic; }

.markdown a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 0.0625rem solid currentColor;
  transition: opacity 0.2s ease;
}
.markdown a:hover { opacity: 0.7; }

.markdown code {
  font-family: var(--font-sans);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--color-bg-warm);
  color: var(--color-accent);
  border-radius: 0.1875rem;
}

.markdown pre {
  background: #1a1a1a;
  color: #e8e4df;
  border-radius: 0.25rem;
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  overflow-x: auto;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent) transparent;
}
.markdown pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
.markdown pre::-webkit-scrollbar { height: 0.375rem; }
.markdown pre::-webkit-scrollbar-track { background: transparent; }
.markdown pre::-webkit-scrollbar-thumb {
  background: var(--color-accent);
  border-radius: 0.1875rem;
}

/* Prism token colors (paper-on-ink palette) */
.markdown pre .token.comment,
.markdown pre .token.prolog,
.markdown pre .token.doctype,
.markdown pre .token.cdata { color: var(--color-text-secondary); font-style: italic; }
.markdown pre .token.keyword,
.markdown pre .token.boolean,
.markdown pre .token.tag { color: #ff79c6; }
.markdown pre .token.string,
.markdown pre .token.attr-value,
.markdown pre .token.char { color: #f1d1a3; }
.markdown pre .token.number,
.markdown pre .token.constant { color: #ffb86c; }
.markdown pre .token.function,
.markdown pre .token.class-name { color: #8be9fd; }
.markdown pre .token.operator,
.markdown pre .token.punctuation { color: #e8e4df; }
.markdown pre .token.attr-name { color: #50fa7b; }

.markdown del { color: var(--color-text-secondary); text-decoration: line-through; }
.markdown mark {
  background: rgba(192, 57, 43, 0.18);
  color: var(--color-text);
  padding: 0.05em 0.25em;
  border-radius: 0.1875rem;
}
.markdown sub, .markdown sup { font-size: 0.75em; line-height: 0; }

.markdown blockquote {
  border-left: 0.1875rem solid var(--color-rule);
  padding-left: var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--color-text-secondary);
}
.markdown blockquote p { margin: 0 0 var(--space-md); color: inherit; }
.markdown blockquote p:last-child { margin-bottom: 0; }

.markdown ul,
.markdown ol {
  margin: 0 0 var(--space-lg);
  padding-left: var(--space-xl);
}
.markdown li { margin-bottom: var(--space-sm); line-height: 1.7; }
.markdown li::marker { color: var(--color-accent); }
.markdown ul ul,
.markdown ul ol,
.markdown ol ul,
.markdown ol ol { margin: var(--space-sm) 0 var(--space-sm) var(--space-lg); }

.markdown hr {
  border: none;
  height: 0.0625rem;
  background: var(--color-rule-light);
  margin: var(--space-2xl) 0;
}

.markdown img {
  max-width: 100%;
  height: auto;
  margin: var(--space-xl) 0;
  display: block;
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  background: var(--color-bg-warm);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
}
.markdown thead { background: var(--color-rule); }
.markdown thead th {
  color: var(--color-bg);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
}
.markdown th,
.markdown td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 0.0625rem solid var(--color-rule-light);
}
.markdown tr:last-child td { border-bottom: none; }
.markdown tbody tr:hover { background: rgba(192, 57, 43, 0.05); }

/* ============================================================
   jesseditson.com — site-specific additions
   ============================================================ */

/* ---- Draft notice (unpublished stories) ---- */
.draft-notice-wrap {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-xl) 0;
}
.draft-notice {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #8a6d00;
  background: #fff4cc;
  border: 1px solid #e6cf80;
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
}
[data-theme="dark"] .draft-notice {
  color: #f0d97a;
  background: #2a2410;
  border-color: #574d20;
}

/* ---- Footer social links ---- */
.footer-social {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  margin: 0 0 var(--space-lg);
}
.footer-social-link {
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.footer-social-link:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
.footer-social-sep {
  color: var(--color-rule-light);
  margin: 0 0.5rem;
}

/* ---- Imageless featured / section-lead: no empty image cell ---- */
.featured-story--no-image,
.section-lead-story--no-image {
  grid-template-columns: 1fr;
}

/* ---- Multiple sections on a story (separator between links) ---- */
.story-detail-section-sep {
  margin: 0 0.5rem;
  color: var(--color-rule-light);
}

/* ---- Latest page (unfurled newest post + month archive sidebar) ---- */
.latest-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl) var(--space-3xl);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: var(--space-3xl);
  align-items: start;
}
.latest-main { min-width: 0; }
.latest-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
}
.latest-article-section {
  text-align: left;
  margin-bottom: var(--space-sm);
}
.latest-headline {
  font-family: var(--font-serif);
  font-size: var(--text-4xl);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-md);
}
.latest-headline a { color: var(--color-text); text-decoration: none; }
.latest-headline a:hover { color: var(--color-accent); }
.latest-subheadline {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-style: italic;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.4;
}
.latest-meta {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-rule-light);
}
.latest-body { margin-top: var(--space-lg); }
.latest-permalink {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-rule-light);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.latest-permalink a { color: var(--color-accent); text-decoration: none; }
.latest-permalink a:hover { text-decoration: underline; }

.latest-sidebar {
  position: sticky;
  top: var(--space-xl);
  border-left: 1px solid var(--color-rule-light);
  padding-left: var(--space-xl);
}
.latest-sidebar-title {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
}
.latest-month {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 700;
  margin: var(--space-lg) 0 var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-rule-light);
}
.latest-month:first-of-type { margin-top: 0; }
.latest-item {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  line-height: 1.45;
  margin-bottom: var(--space-sm);
}
.latest-item a { color: var(--color-text); text-decoration: none; }
.latest-item a:hover { color: var(--color-accent); }
.latest-item--empty { color: var(--color-text-secondary); font-style: italic; }

@media (max-width: 900px) {
  .latest-layout { grid-template-columns: 1fr; gap: var(--space-2xl); }
  .latest-headline { font-size: var(--text-3xl); }
  .latest-sidebar {
    position: static;
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--color-rule-light);
    padding-top: var(--space-xl);
  }
}

