@import url('https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap');

/* ============================================================
   TOKENS  — lifted verbatim from the reference build
   ============================================================ */
:root {
  --stone-50:  oklch(98.5% .001 106.423);
  --stone-100: oklch(97%   .001 106.424);
  --stone-200: oklch(92.3% .003 48.717);
  --stone-300: oklch(86.9% .005 56.366);
  --stone-400: oklch(70.9% .01  56.259);
  --stone-500: oklch(55.3% .013 58.071);
  --stone-600: oklch(44.4% .011 73.639);
  --stone-700: oklch(37.4% .01  67.558);
  --stone-800: oklch(26.8% .007 34.298);
  --stone-900: oklch(21.6% .006 56.043);
  --stone-950: oklch(14.7% .004 49.25);

  --background: oklch(98.5% .001 106);
  --foreground: oklch(14.7% .004 49);
  --border: oklch(90.5% .006 106);
  --border-subtle: #f5f5f4;

  --highlight-bg: #fef3c7;
  --highlight-fg: #1c1917;
  --selection-bg: #f59e0b;
  --selection-fg: #1c1917;
  --accent-hover: #92400e;

  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);

  --font-sans: "Geist", system-ui, -apple-system, sans-serif;
  --tracking-tight: -0.025em;

  --measure: 44rem;   /* 704px content shell */
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border: 0 solid var(--border); }
html { -webkit-text-size-adjust: 100%; tab-size: 4; line-height: 1.5; scroll-behavior: smooth; }
ul, ol, menu { list-style: none; }
a { color: inherit; text-decoration: none; transition: color .16s var(--ease-out); }
button { font: inherit; letter-spacing: inherit; color: inherit; background: transparent; border-radius: 0; cursor: pointer; }
img, svg { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6 { font-size: inherit; font-weight: inherit; }
strong, b { font-weight: bolder; }

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-feature-settings: "rlig", "calt";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.625;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--selection-bg); color: var(--selection-fg); }
:focus-visible { outline: 2px solid var(--stone-500); outline-offset: 2px; }

/* ============================================================
   SHELL
   ============================================================ */
.shell { display: flex; min-height: 100dvh; flex-direction: column; background: var(--stone-50); color: var(--stone-900); }
.shell-inner { display: flex; min-height: 0; width: 100%; flex: 1; flex-direction: column; }

.site-header {
  width: 100%; max-width: var(--measure); margin-inline: auto;
  padding-inline: 1.25rem;
  padding-top: 2.5rem; padding-bottom: 2.5rem;
  display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem;
}
.site-wordmark { font-size: 16px; font-weight: 500; letter-spacing: var(--tracking-tight); color: var(--stone-900); }
.site-wordmark:hover { color: var(--stone-600); }

.site-nav { display: flex; align-items: baseline; gap: 1.25rem; flex-shrink: 0; }
.site-nav-link {
  font-size: 16px; letter-spacing: var(--tracking-tight); color: var(--stone-500);
  transition: color .16s var(--ease-out), transform .14s var(--ease-out);
}
.site-nav-link:hover { color: var(--stone-900); }
.site-nav-link[aria-current="page"] { color: var(--stone-900); font-weight: 500; }

.site-main {
  width: 100%; max-width: var(--measure); margin-inline: auto; flex: 1;
  padding-inline: 1.25rem; padding-bottom: 5rem;
}

@media (min-width: 640px) {
  .site-header { padding-inline: 2rem; padding-top: 3.5rem; padding-bottom: 3.5rem; }
  .site-nav { gap: 1.75rem; }
  .site-main   { padding-inline: 2rem; padding-bottom: 7rem; }
}

/* ============================================================
   TYPE PRIMITIVES
   ============================================================ */
.page-title {
  font-size: 22px; line-height: 1.25; font-weight: 500;
  letter-spacing: var(--tracking-tight); color: var(--stone-900);
}
.section-label {
  font-size: 16px; line-height: 1.625; font-weight: 500;
  letter-spacing: var(--tracking-tight); color: var(--stone-500);
  padding-top: 2rem; padding-bottom: .75rem;
  scroll-margin-top: 6rem;
}
@media (min-width: 640px) { .section-label { padding-top: 2.5rem; padding-bottom: 1rem; } }

.entry-title {
  font-size: 16px; line-height: 1.4; font-weight: 500; color: var(--stone-900);
  transition: color .16s var(--ease-out);
}
.entry-meta { font-size: 16px; line-height: 1.625; color: var(--stone-500); }

.page-lede { margin-top: .75rem; color: var(--stone-500); }

/* ============================================================
   PROSE
   ============================================================ */
.prose-site { color: var(--stone-800); font-size: 16px; line-height: 1.625; }
.prose-site h2, .prose-site h3, .prose-site h4 {
  letter-spacing: var(--tracking-tight); color: var(--stone-900);
  font-weight: 600; line-height: 1.35; font-size: 16px;
}
.prose-site h2 { letter-spacing: -0.01em; margin-top: 2.75rem; margin-bottom: .875rem; }
.prose-site > h2:first-of-type { margin-top: 2.25rem; }
.prose-site h3 { margin-top: 2.125rem; margin-bottom: .5rem; }
.prose-site h4 { margin-top: 1.875rem; margin-bottom: .5rem; }
.prose-site p { margin-bottom: 1.5rem; }
.prose-site p:last-child { margin-bottom: 0; }
.prose-site strong { font-weight: 600; color: var(--stone-800); }
.prose-site a {
  color: var(--stone-900);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: text-decoration-thickness .16s var(--ease-out), color .16s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .prose-site a:hover { color: var(--stone-600); text-decoration-thickness: 2px; }
}

/* Inline brand link: bold word + favicon chip + ↗ */
.brand-inline-link {
  display: inline-flex; align-items: center; gap: .25rem; vertical-align: baseline;
  text-decoration: none; text-underline-offset: 2px;
}
.brand-inline-link strong { font-weight: 600; }
.brand-chip {
  display: inline-block; height: 1rem; width: 1rem; flex-shrink: 0;
  transform: translateY(-1px); border-radius: 3px;
  background-size: cover; background-position: center; background-color: var(--stone-200);
}
.icon-shift {
  color: var(--stone-300); font-size: 12px; line-height: 1;
  transition: transform .2s var(--ease-out), color .16s var(--ease-out);
}
.brand-inline-link:hover .icon-shift,
.essay-link:hover .icon-shift { color: var(--stone-500); transform: translateX(2px); }

/* ============================================================
   LIST ENTRIES
   ============================================================ */
.entry-list > li { border-bottom: 1px solid color-mix(in oklab, var(--stone-100) 80%, transparent); }
.entry-list > li:last-child { border-bottom: 0; }

.essay-link {
  display: block; min-width: 0;
  padding-block: .75rem;
  transition: transform .2s var(--ease-out), color .16s var(--ease-out);
}
@media (min-width: 640px) { .essay-link { padding-block: .625rem; } }
.essay-link:hover { transform: translateX(2px); }
.essay-link:hover .entry-title { color: var(--stone-600); }
.essay-link:active { transform: scale(.99); }
.essay-link:hover:active { transform: translateX(2px) scale(.99); }

.entry-row { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.entry-title-inline { display: inline-flex; align-items: baseline; gap: .375rem; }

/* Press feedback — used on every control */
.press { transition: transform .14s var(--ease-out), color .16s var(--ease-out), background-color .16s var(--ease-out); }
.press:active { transform: scale(.97); }

/* ============================================================
   IDEAS — CAROUSEL CARD
   ============================================================ */
.ideas-carousel-stage { margin-bottom: 2.5rem; }
@media (min-width: 640px) { .ideas-carousel-stage { margin-bottom: 3rem; } }

.idea-card {
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--stone-200) 90%, transparent);
  background: color-mix(in oklab, #fff 70%, transparent);
  display: flex; flex-direction: column;
  touch-action: pan-y;
  scroll-margin-top: 6rem;
}
.idea-carousel-panel {
  display: flex; flex-direction: column;
  will-change: transform;
  transition: transform .2s var(--ease-out), opacity .18s var(--ease-out);
}
.idea-carousel-panel[data-leaving="next"] { opacity: 0; transform: translateX(-12px); }
.idea-carousel-panel[data-leaving="prev"] { opacity: 0; transform: translateX(12px); }
.idea-carousel-panel[data-entering="next"] { opacity: 0; transform: translateX(12px); }
.idea-carousel-panel[data-entering="prev"] { opacity: 0; transform: translateX(-12px); }
.idea-carousel-panel[data-dragging="true"] { transition: none; }

.idea-content { padding: 1.25rem; touch-action: pan-y; }
@media (min-width: 640px) { .idea-content { padding: 1.5rem; } }
.idea-content p { margin-bottom: .75rem; }
.idea-content p:last-child { margin-bottom: 0; }
.idea-content strong { font-weight: 600; color: var(--stone-800); }
.idea-content a { color: var(--stone-700); text-decoration: underline; text-underline-offset: 2px; }
.idea-content a:hover { color: var(--stone-900); }
/* highlights intentionally off — <mark> renders as plain text */
.idea-content mark, .prose-site mark {
  background: transparent; color: inherit; padding: 0; border-radius: 0;
}

.idea-card-footer {
  flex-shrink: 0;
  border-top: 1px solid color-mix(in oklab, var(--stone-100) 90%, transparent);
  padding: 1rem 1.25rem;
}
@media (min-width: 640px) { .idea-card-footer { padding-inline: 1.5rem; } }
.idea-card-footer a {
  display: inline-block; color: var(--stone-900);
  text-decoration: underline; text-decoration-color: var(--stone-300);
  text-underline-offset: 4px;
  transition: color .16s var(--ease-out), text-decoration-color .16s var(--ease-out);
}
.idea-card-footer a:hover { text-decoration-color: var(--stone-900); }

.carousel-hint-row { margin-top: 1rem; display: flex; align-items: center; justify-content: flex-start; gap: .75rem; }
.carousel-hint {
  display: inline-flex; align-items: center; gap: .5rem;
  height: 2.75rem; border-radius: 9999px;
  border: 1px solid color-mix(in oklab, var(--stone-200) 90%, transparent);
  background: color-mix(in oklab, #fff 70%, transparent);
  padding-inline: .875rem;
  font-size: 14px; color: var(--stone-500);
  user-select: none;
}
.carousel-hint .keys { display: inline-flex; align-items: center; gap: .25rem; color: var(--stone-400); }
.carousel-hint .keys span { font-size: 18px; line-height: 1; }
.hint-desktop { display: none; }
@media (min-width: 640px) { .hint-desktop { display: inline-flex; } .hint-touch { display: none; } }

/* ============================================================
   IDEAS — TABLE OF CONTENTS (fixed rail, xl and up)
   ============================================================ */
.ideas-toc-wrap {
  pointer-events: auto; position: fixed; left: 1.25rem; top: 12.125rem; z-index: 10;
  display: none; max-width: 13rem;
}
@media (min-width: 1280px) { .ideas-toc-wrap { display: block; } }
.ideas-toc { min-width: 0; width: 100%; padding-right: .5rem; }
.ideas-toc ul > li + li { margin-top: .5rem; }
.ideas-toc li.toc-lead { padding-bottom: .75rem; margin-bottom: .5rem; }
.ideas-toc a {
  display: block; max-width: 100%; min-width: 0; overflow-wrap: break-word;
  border-radius: 2px; padding-block: .125rem;
  text-align: left; font-size: 13px; line-height: 1.375;
  color: var(--stone-500);
  transition: color .22s var(--ease-out), transform .22s var(--ease-out);
  outline-offset: 4px;
}
.ideas-toc a:hover { color: var(--stone-700); transform: translateX(1px); }
.ideas-toc a[data-active="true"] { color: var(--stone-900); font-weight: 500; transform: translateX(1px); }

/* ============================================================
   ENTRANCE ANIMATIONS
   ============================================================ */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-in-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.animate-fade-in, .ideas-page { animation: fade-in .22s var(--ease-out) forwards; }

.ideas-page-stage { animation: fade-in-rise .24s var(--ease-out) both; opacity: 0; }
.ideas-page-stage--header   { animation-delay: 0s; }
.ideas-page-stage--carousel { animation-delay: 45ms; }
.ideas-page-stage--label    { animation-delay: 90ms; }
.ideas-page-stage--list     { animation-delay: .12s; }

.ideas-list-stagger > section > h3,
.ideas-list-stagger > section > ul > li { animation: fade-in-rise .24s var(--ease-out) both; opacity: 0; }
.ideas-list-stagger > section > h3 { animation-delay: 0s; }
.ideas-list-stagger > section > ul > li:first-child     { animation-delay: 30ms; }
.ideas-list-stagger > section > ul > li:nth-child(2)    { animation-delay: 55ms; }
.ideas-list-stagger > section > ul > li:nth-child(3)    { animation-delay: 80ms; }
.ideas-list-stagger > section > ul > li:nth-child(4)    { animation-delay: .105s; }
.ideas-list-stagger > section > ul > li:nth-child(5)    { animation-delay: .13s; }
.ideas-list-stagger > section > ul > li:nth-child(6)    { animation-delay: .155s; }
.ideas-list-stagger > section > ul > li:nth-child(7)    { animation-delay: .18s; }
.ideas-list-stagger > section > ul > li:nth-child(n+8)  { animation-delay: .2s; }

.stagger-children > * { animation: fade-in-rise .26s var(--ease-out) forwards; opacity: 0; }
.stagger-children > :first-child      { animation-delay: 0s; }
.stagger-children > :nth-child(2)     { animation-delay: 30ms; }
.stagger-children > :nth-child(3)     { animation-delay: 60ms; }
.stagger-children > :nth-child(4)     { animation-delay: 90ms; }
.stagger-children > :nth-child(5)     { animation-delay: .12s; }
.stagger-children > :nth-child(6)     { animation-delay: .15s; }
.stagger-children > :nth-child(7)     { animation-delay: .18s; }
.stagger-children > :nth-child(8)     { animation-delay: .205s; }
.stagger-children > :nth-child(9)     { animation-delay: .225s; }
.stagger-children > :nth-child(n+10)  { animation-delay: .24s; }

/* ============================================================
   REDUCED MOTION — mirrors the reference build's overrides
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .animate-fade-in, .ideas-page, .ideas-page-stage,
  .ideas-list-stagger > section > h3, .ideas-list-stagger > section > ul > li,
  .stagger-children > * { animation-duration: .2s; animation-timing-function: ease-out; }
  @keyframes fade-in-rise { from { opacity: 0; transform: none; } to { opacity: 1; transform: none; } }
  .idea-carousel-panel { transition: none; }
  .idea-carousel-panel[data-leaving], .idea-carousel-panel[data-entering] { opacity: 1; transform: none; }
  .essay-link, .essay-link:hover, .essay-link:active, .essay-link:hover:active,
  .site-nav-link, .site-nav-link:hover,
  .press, .press:active { transition: color .16s ease-out; transform: none; }
  .group:hover .icon-shift, .icon-shift { transform: none !important; }
}

/* ============================================================
   PAGE HEADER SPACING  (matches reference: pt-2 pb-10 sm:pb-12 mb-2
   on Ideas; pt-2 pb-8 sm:pb-10 mb-8 sm:mb-10 on About)
   ============================================================ */
.ideas-page-header { padding-top: .5rem; padding-bottom: 2.5rem; margin-bottom: .5rem; }
.about-page-header { padding-top: .5rem; padding-bottom: 2rem; margin-bottom: 2rem; }
.section-label--lead { padding-top: .5rem; padding-bottom: 1.5rem; }
.section-gap { margin-top: 3rem; }

@media (min-width: 640px) {
  .ideas-page-header { padding-bottom: 3rem; }
  .about-page-header { padding-bottom: 2.5rem; margin-bottom: 2.5rem; }
  .section-gap { margin-top: 3.5rem; }
}

/* ============================================================
   IDEA DETAIL PAGE
   (reference: header pt-2 pb-5 sm:pb-6 mb-6 sm:mb-8;
    back link block mt-16 pt-10 border-t border-stone-200)
   ============================================================ */
.idea-page-header { padding-top: .5rem; padding-bottom: 1.25rem; margin-bottom: 1.5rem; }
.idea-page-header .section-label { padding: 0; margin-bottom: .5rem; }

.back-block { margin-top: 4rem; padding-top: 2.5rem; border-top: 1px solid var(--stone-200); }
.back-link {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: 16px; color: var(--stone-500);
  transition: color .16s var(--ease-out), transform .14s var(--ease-out);
}
.back-link:hover { color: var(--stone-700); }
.back-link .icon-shift { display: inline-block; }
.back-link:hover .icon-shift { transform: translateX(-2px); color: var(--stone-500); }

@media (min-width: 640px) {
  .idea-page-header { padding-bottom: 1.5rem; margin-bottom: 2rem; }
}

/* Category with no entries yet */
.entry-empty {
  font-size: 16px; line-height: 1.625; color: var(--stone-400);
  padding-block: .75rem;
}
@media (min-width: 640px) { .entry-empty { padding-block: .625rem; } }
