/* ============================================================
   Carter — own site stylesheet

   Everything user-facing flows from the design tokens in :root.
   Change a token → everything updates. This is the "ClaudeDesign"
   surface: ask Claude to retheme and it only needs to touch here.
   ============================================================ */

/* ----- 1. Design tokens --------------------------------------------------- */
:root {
  /* palette — warm paper */
  --c-bg:        #faf7f2;
  --c-surface:   #ffffff;
  --c-fg:        #1a1a1a;
  --c-muted:     #6b6b6b;
  --c-accent:    #b8472a;
  --c-accent-soft: #f4e4db;
  --c-border:    #e8e2d8;
  --c-code-bg:   #f3efe7;

  /* typography */
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-sans:  system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --fs-base: 1.0625rem;
  --lh-base: 1.65;
  --fs-h1: clamp(2rem, 1.2rem + 2.5vw, 3rem);
  --fs-h2: clamp(1.5rem, 1rem + 1.6vw, 2rem);
  --fs-h3: 1.25rem;
  --fs-small: 0.9rem;

  /* layout */
  --maxw:   780px;
  --maxw-wide: 1080px;
  --gap: 1.25rem;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(0,0,0,.06);

  color-scheme: light dark;
}

/* dark mode — auto or forced via [data-theme="dark"] on <html> */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg:        #0f0d0a;
    --c-surface:   #18140f;
    --c-fg:        #f3ece0;
    --c-muted:     #a59c8c;
    --c-accent:    #e0764e;
    --c-accent-soft: #2a1d15;
    --c-border:    #2a241c;
    --c-code-bg:   #1f1a13;
  }
}
[data-theme="dark"] {
  --c-bg:        #0f0d0a;
  --c-surface:   #18140f;
  --c-fg:        #f3ece0;
  --c-muted:     #a59c8c;
  --c-accent:    #e0764e;
  --c-accent-soft: #2a1d15;
  --c-border:    #2a241c;
  --c-code-bg:   #1f1a13;
}

/* ----- 2. Reset / base ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--c-accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
hr { border: none; border-top: 1px solid var(--c-border); margin: 2.5rem 0; }
code, pre, kbd, samp { font-family: var(--font-mono); font-size: 0.95em; }
code { background: var(--c-code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre {
  background: var(--c-code-bg);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  border: 1px solid var(--c-border);
}
pre code { background: none; padding: 0; }
blockquote {
  margin: 1.5rem 0;
  padding: .25rem 1rem;
  border-left: 3px solid var(--c-accent);
  color: var(--c-muted);
  font-style: italic;
}
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-h1); margin: 0 0 .5rem; }
h2 { font-size: var(--fs-h2); margin: 2.5rem 0 .75rem; }
h3 { font-size: var(--fs-h3); margin: 1.75rem 0 .5rem; }

/* ----- 3. Layout ---------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.25rem;
}
.page { padding-block: 2rem 4rem; }
.page-header { margin-bottom: 2rem; }
.page-header__subtitle { color: var(--c-muted); margin: .25rem 0 0; font-size: 1.1rem; }

.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;
}
.skip-link {
  position: absolute; top: -40px; left: 8px; background: var(--c-fg); color: var(--c-bg);
  padding: .5rem .75rem; border-radius: 4px; z-index: 100;
}
.skip-link:focus { top: 8px; }

/* ----- 4. Header / nav ---------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--c-border);
  background: color-mix(in srgb, var(--c-bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: .9rem; max-width: var(--maxw-wide);
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  text-decoration: none; color: var(--c-fg); font-weight: 600;
}
.brand__mark { color: var(--c-accent); }
.brand__name { font-family: var(--font-serif); font-size: 1.2rem; }

.site-nav { position: relative; display: flex; align-items: center; gap: .25rem; }
.nav-list {
  list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0;
}
.nav-list a {
  display: inline-block; padding: .4rem .7rem; border-radius: 6px;
  color: var(--c-fg); text-decoration: none; font-size: .95rem;
}
.nav-list a:hover { background: var(--c-accent-soft); }
.nav-list a[aria-current="page"] {
  color: var(--c-accent); background: var(--c-accent-soft);
}
.theme-toggle, .nav-toggle {
  background: transparent; border: 1px solid var(--c-border); color: var(--c-fg);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: .35rem;
}
.theme-toggle:hover, .nav-toggle:hover { background: var(--c-accent-soft); }
.nav-toggle { display: none; }
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  content: ""; display: block; width: 18px; height: 2px; background: currentColor;
  position: relative;
}
.nav-toggle__bars::before { position: absolute; top: -6px; }
.nav-toggle__bars::after  { position: absolute; top:  6px; }

@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; }
  .nav-list {
    position: absolute; top: calc(100% + .5rem); right: 0;
    min-width: 180px;
    flex-direction: column; gap: 0; background: var(--c-surface);
    border: 1px solid var(--c-border); border-radius: var(--radius);
    padding: .5rem; box-shadow: var(--shadow); display: none;
  }
  .site-nav[data-open="true"] .nav-list { display: flex; }
  .nav-list a { padding: .6rem .75rem; }
}

/* Progressive enhancement: if JS is disabled the toggle can't open the menu,
   so show the items inline and hide the toggle entirely. */
.no-js .nav-toggle { display: none; }
.no-js .nav-list {
  position: static !important; display: flex !important;
  flex-direction: row; flex-wrap: wrap; background: none;
  border: none; box-shadow: none; padding: 0;
}

/* ----- 5. Footer ---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  margin-top: 4rem; padding-block: 1.5rem;
  color: var(--c-muted); font-size: var(--fs-small);
}
.site-footer .wrap {
  max-width: var(--maxw-wide);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.site-footer__meta { margin: 0; }
.site-footer__links { list-style: none; display: flex; gap: 1rem; padding: 0; margin: 0; flex-wrap: wrap; }
.site-footer__links a { color: var(--c-muted); }
.site-footer__links a:hover { color: var(--c-accent); }

/* ----- 6. Home hero ------------------------------------------------------- */
.hero {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 2.5rem;
}
.hero h1 {
  font-size: clamp(2.25rem, 1.5rem + 3vw, 3.75rem);
  margin: 0 0 .75rem;
}
.hero p { font-size: 1.15rem; color: var(--c-muted); max-width: 52ch; margin: 0; }
.hero__cta { margin-top: 1.5rem; display: flex; gap: .75rem; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: .6rem 1rem; border-radius: var(--radius);
  text-decoration: none; font-weight: 500; font-size: .95rem;
  border: 1px solid var(--c-border); color: var(--c-fg); background: var(--c-surface);
  transition: transform .08s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.btn--primary:hover { background: color-mix(in srgb, var(--c-accent) 85%, black); }

/* ----- 7. Cards / grid ---------------------------------------------------- */
.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: .6rem;
}
.card header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card__title { margin: 0; font-size: 1.15rem; font-family: var(--font-serif); }
.card__title a { color: var(--c-fg); text-decoration: none; }
.card__title a:hover { color: var(--c-accent); }
.card__summary { margin: 0; color: var(--c-muted); }

.badge {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .15rem .5rem; border-radius: 999px; background: var(--c-accent-soft); color: var(--c-accent);
  white-space: nowrap;
}
.badge--shipped { background: #dcf0dc; color: #2e6b2e; }
.badge--wip     { background: #fdeccb; color: #8c5a12; }
.badge--archived{ background: #e4e4e4; color: #555; }
.badge--idea    { background: var(--c-accent-soft); color: var(--c-accent); }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0; }
.tags li {
  font-size: .75rem; color: var(--c-muted);
  border: 1px solid var(--c-border); border-radius: 999px; padding: .1rem .55rem;
}

/* ----- 8. Post / prose ---------------------------------------------------- */
.prose { font-size: 1.05rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose h2 { margin-top: 2.25rem; }
.prose a { color: var(--c-accent); }
.post-meta, .eyebrow { color: var(--c-muted); font-size: var(--fs-small); margin: .25rem 0 1rem; }
.eyebrow a { color: var(--c-muted); }
.post-footer { margin-top: 3rem; border-top: 1px solid var(--c-border); padding-top: 1rem; }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 0; border-bottom: 1px solid var(--c-border);
}
.post-list li:last-child { border-bottom: none; }
.post-list a { font-weight: 500; color: var(--c-fg); text-decoration: none; }
.post-list a:hover { color: var(--c-accent); }
.post-list time { color: var(--c-muted); font-variant-numeric: tabular-nums; }

/* ----- 9. Project page ---------------------------------------------------- */
.project-meta {
  display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem;
  margin: 1rem 0 2rem; font-size: .95rem;
}
.project-meta dt { color: var(--c-muted); }
.project-meta dd { margin: 0; }
.lede { font-size: 1.15rem; color: var(--c-muted); max-width: 55ch; margin: .25rem 0 1.25rem; }

/* ----- 10. Now / Uses lists ----------------------------------------------- */
.stack-list { list-style: none; padding: 0; margin: 0 0 2rem; }
.stack-list li {
  display: grid; grid-template-columns: minmax(140px, 180px) 1fr;
  gap: 1rem; padding: .6rem 0; border-bottom: 1px dashed var(--c-border);
}
.stack-list strong { font-weight: 600; }
.stack-list span { color: var(--c-muted); }

/* ----- 11. Contact -------------------------------------------------------- */
.contact-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin: 1.5rem 0; }
.contact-grid a {
  display: block; padding: 1rem; border: 1px solid var(--c-border);
  border-radius: var(--radius); background: var(--c-surface); text-decoration: none; color: var(--c-fg);
}
.contact-grid a:hover { border-color: var(--c-accent); }
.contact-grid .label { display: block; color: var(--c-muted); font-size: .85rem; }
.contact-grid .value { font-weight: 500; }

/* ----- 12. 404 ------------------------------------------------------------ */
.notfound { text-align: center; padding: 5rem 0; }
.notfound h1 { font-size: 6rem; margin: 0; color: var(--c-accent); }

/* ----- 13. Card links / tag sections ------------------------------------- */
.card__links { margin: 0; display: flex; gap: .75rem; font-size: .85rem; }
.card__links a { color: var(--c-muted); text-decoration: none; border-bottom: 1px solid var(--c-border); }
.card__links a:hover { color: var(--c-accent); border-color: var(--c-accent); }

.tags a { color: inherit; text-decoration: none; }
.tags a:hover { color: var(--c-accent); }
.tags--big { gap: .5rem; margin-bottom: 2rem; }
.tags--big li { font-size: .95rem; padding: .25rem .75rem; }

.tag-section { margin-top: 2.5rem; }
.tag-section h2 { margin-top: 0; }
.tag-section :target,
section:target > h2 { color: var(--c-accent); }
.post-list__kind {
  color: var(--c-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
}

/* ----- 14. Utilities ----------------------------------------------------- */
.u-mt-1 { margin-top: 1rem; }
.u-mt-2 { margin-top: 2rem; }
.u-center { text-align: center; }

/* ----- 15. Focus + motion ------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ----- 17. Notes / backlinks --------------------------------------------- */
.badge--seedling  { background: #dcf0dc; color: #2e6b2e; }
.badge--budding   { background: #fdeccb; color: #8c5a12; }
.badge--evergreen { background: #d4e8f2; color: #245a78; }

.backlinks {
  margin-top: 3rem; padding: 1rem 1.25rem;
  background: var(--c-accent-soft);
  border-radius: var(--radius);
}
.backlinks h2 { margin: 0 0 .5rem; font-size: 1rem; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.backlinks ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.backlinks li { display: flex; align-items: center; gap: .5rem; }
.backlinks a { color: var(--c-fg); text-decoration: none; border-bottom: 1px solid var(--c-border); }
.backlinks a:hover { color: var(--c-accent); border-color: var(--c-accent); }

.note-meta { color: var(--c-muted); font-size: var(--fs-small); display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* ----- 18. Library ------------------------------------------------------- */
.library-jump { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; font-size: .95rem; }
.library-jump a { color: var(--c-muted); text-decoration: none; border-bottom: 1px solid var(--c-border); padding-bottom: 2px; }
.library-jump a:hover { color: var(--c-accent); border-color: var(--c-accent); }

.library { list-style: none; padding: 0; margin: 0 0 2.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.library__item {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface);
}
.library__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.library__kind {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--c-muted); padding: .15rem .55rem; border: 1px solid var(--c-border); border-radius: 999px;
}
.library__title { margin: 0; font-family: var(--font-serif); font-size: 1.15rem; flex: 1 1 auto; }
.library__title a { color: var(--c-fg); text-decoration: none; }
.library__title a:hover { color: var(--c-accent); }
.library__rating { color: var(--c-accent); letter-spacing: 1px; }
.library__byline { color: var(--c-muted); font-size: .9rem; margin: .25rem 0 .5rem; }
.library__note { margin: .5rem 0 .25rem; }

/* ----- 19. Changelog / timeline ----------------------------------------- */
.timeline { list-style: none; padding: 0; margin: 1.5rem 0; }
.timeline__item {
  display: grid; grid-template-columns: 8.5rem max-content 1fr;
  gap: .75rem 1rem; align-items: baseline;
  padding: .65rem 0; border-bottom: 1px dashed var(--c-border);
}
.timeline__date { color: var(--c-muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.timeline__kind {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  padding: .1rem .55rem; border-radius: 999px; color: var(--c-muted);
  border: 1px solid var(--c-border); white-space: nowrap;
}
.timeline__kind--post    { color: #245a78; border-color: #c6dce8; background: #eef5fa; }
.timeline__kind--note    { color: #2e6b2e; border-color: #cfe6cf; background: #f0f7f0; }
.timeline__kind--project { color: #8c5a12; border-color: #ebd5b0; background: #faf2e3; }
.timeline__title { font-weight: 500; color: var(--c-fg); text-decoration: none; }
.timeline__title:hover { color: var(--c-accent); }
@media (max-width: 600px) {
  .timeline__item { grid-template-columns: 1fr; gap: .2rem; }
}

/* ----- 20. Search ------------------------------------------------------- */
.search-form { margin: 0 0 1rem; }
.search-form__input {
  width: 100%; padding: .75rem 1rem; font-size: 1.1rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-fg);
  font-family: var(--font-sans);
}
.search-form__input:focus { outline: 2px solid var(--c-accent); outline-offset: 0; border-color: var(--c-accent); }
.search-form__hint { color: var(--c-muted); font-size: var(--fs-small); margin: .5rem 0 0; }

.search-results { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.search-hit { padding-bottom: 1.25rem; border-bottom: 1px solid var(--c-border); }
.search-hit:last-child { border-bottom: none; }
.search-hit h3 { margin: 0 0 .25rem; font-family: var(--font-serif); font-size: 1.1rem; }
.search-hit h3 a { color: var(--c-fg); text-decoration: none; }
.search-hit h3 a:hover { color: var(--c-accent); }
.search-hit__meta { color: var(--c-muted); font-size: .85rem; margin: 0 0 .5rem; display: flex; gap: .5rem; }
.search-hit__kind {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  padding: 0 .5rem; border-radius: 999px; border: 1px solid var(--c-border);
}
.search-hit__snippet { margin: 0; color: var(--c-muted); }
.search-hit mark, .search-results mark { background: var(--c-accent-soft); color: var(--c-accent); padding: 0 .15em; border-radius: 2px; }
.search-results__empty { color: var(--c-muted); }

/* ----- 21. Keyboard help dialog ----------------------------------------- */
.kbd-help {
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: var(--c-surface); color: var(--c-fg);
  padding: 1.5rem 1.75rem; max-width: 420px; width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}
.kbd-help::backdrop { background: rgba(0,0,0,.35); }
.kbd-help h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.kbd-help__list {
  display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem;
  margin: 0 0 1.25rem; font-size: .95rem;
}
.kbd-help__list dt { display: flex; gap: .25rem; }
kbd {
  display: inline-block; font-family: var(--font-mono); font-size: .85em;
  padding: .05em .45em; border: 1px solid var(--c-border); border-bottom-width: 2px;
  border-radius: 4px; background: var(--c-code-bg); color: var(--c-fg);
}

/* ----- 22. Copy-code button --------------------------------------------- */
pre { position: relative; }
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  padding: .15rem .55rem; font-size: .75rem;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 4px;
  color: var(--c-muted); cursor: pointer; opacity: 0;
  transition: opacity .15s ease;
}
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { color: var(--c-fg); border-color: var(--c-accent); }

/* ----- 23. Footer nav (secondary) --------------------------------------- */
.site-footer__nav ul {
  list-style: none; display: flex; gap: 1rem; padding: 0; margin: 0; flex-wrap: wrap;
}
.site-footer__nav a { color: var(--c-muted); text-decoration: none; }
.site-footer__nav a:hover { color: var(--c-accent); }
.site-footer .wrap {
  flex-direction: column; align-items: flex-start; gap: .75rem;
}
.site-footer__meta kbd { font-size: .8em; }

/* ----- 16. Print --------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .theme-toggle, .nav-toggle, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #555; }
  .wrap { max-width: none; padding: 0; }
  .card { break-inside: avoid; }
}
