/* ==========================================================================
   KERRI QUEEN — main.css
   Design tokens first. Nothing below invents a color or size out of thin air.
   ========================================================================== */

:root {
  /* --- palette (from the branding mockup) --- */
  --ivory: #faf6f0;
  --paper: #f4efe7;      /* slightly deeper ivory for panels */
  --warm-gray: #d9d4ca;
  --taupe: #a69b8e;
  --mauve: #b58a8f;
  --burgundy: #5a1e28;
  --charcoal: #1d1d1f;
  --gold: #b08d57;

  /* --- derived / accessible variants --- */
  --ink: var(--charcoal);
  --ink-soft: #4a4744;          /* body text, softened, still AA on ivory */
  --ink-faint: #6d675f;         /* metadata; AA on ivory at 14px+ */
  --rule: #ded8ce;
  --rule-strong: #c9c2b6;
  --burgundy-hover: #7a2a37;

  /* Text-safe variants. The display gold/taupe above fail WCAG AA as small
     text on ivory, so they are used for chips, rules, and markers only.
     Anything that carries words uses these instead. */
  --gold-ink: #7e6130;   /* 5.37:1 on ivory, 5.04:1 on paper */
  --taupe-ink: #786d62;  /* 4.70:1 on ivory */

  /* --- type --- */
  --serif: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --step--1: clamp(0.8125rem, 0.79rem + 0.11vw, 0.875rem);
  --step-0:  clamp(1.0625rem, 1.03rem + 0.17vw, 1.1875rem);
  --step-1:  clamp(1.25rem, 1.19rem + 0.3vw, 1.4375rem);
  --step-2:  clamp(1.5rem, 1.38rem + 0.6vw, 1.9375rem);
  --step-3:  clamp(1.875rem, 1.62rem + 1.28vw, 2.75rem);
  --step-4:  clamp(2.25rem, 1.78rem + 2.36vw, 3.875rem);

  /* --- space --- */
  --sp-1: 0.375rem;
  --sp-2: 0.75rem;
  --sp-3: 1.25rem;
  --sp-4: 2rem;
  --sp-5: 3rem;
  --sp-6: 4.5rem;
  --sp-7: 7rem;

  /* --- layout --- */
  --page-max: 74rem;
  --measure: 34rem;
  --rail-w: 11rem;
  --gutter: clamp(1.25rem, 5vw, 3.5rem);

  --radius: 2px;
  --shadow-lift: 0 1px 2px rgba(29, 29, 31, 0.04), 0 8px 24px rgba(29, 29, 31, 0.05);
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--ivory);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: var(--step-0);
  font-weight: 350;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Paper grain. Purely decorative, very low opacity, never over content. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

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

/* --------------------------------------------------------------------------
   TYPE
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p { text-wrap: pretty; }

a {
  color: var(--burgundy);
  text-decoration-color: var(--warm-gray);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  transition: color 0.18s var(--ease), text-decoration-color 0.18s var(--ease);
}
a:hover { color: var(--burgundy-hover); text-decoration-color: var(--mauve); }

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

::selection { background: var(--burgundy); color: var(--ivory); }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--sp-5) 0;
}

blockquote {
  margin: var(--sp-4) 0;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--gold);
  font-family: var(--serif);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--ink);
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--paper);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
}

/* --------------------------------------------------------------------------
   SHARED UTILITIES
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -4rem;
  z-index: 100;
  background: var(--burgundy);
  color: var(--ivory);
  padding: 0.6rem 1rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  text-decoration: none;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: var(--sp-3); color: var(--ivory); }

.shell {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* The mono metadata voice. Used for every label, date, and accession mark. */
.mark {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.mark--gold { color: var(--gold-ink); }

/* --------------------------------------------------------------------------
   RAIL LAYOUT
   The signature structure: a ruled margin column carrying accession marks,
   dates, and type. On mobile it becomes a single line above the content.
   -------------------------------------------------------------------------- */
.rail {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: 0 var(--sp-5);
  align-items: start;
}
.rail__aside {
  position: sticky;
  top: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding-top: 0.55rem;
  text-align: right;
  border-right: 1px solid var(--rule);
  padding-right: var(--sp-3);
  margin-right: calc(-1 * var(--sp-3));
}
.rail__body { min-width: 0; }

@media (max-width: 60rem) {
  .rail { display: block; }
  .rail__aside {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-2);
    text-align: left;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 0 0 var(--sp-2) 0;
    margin: 0 0 var(--sp-3) 0;
  }
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.site-header {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--ivory) 88%, transparent);
  backdrop-filter: blur(6px);
}
.site-header__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding-block: var(--sp-3);
}
.wordmark {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--burgundy); }

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
}
.site-nav a {
  font-family: var(--sans);
  font-size: var(--step--1);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--taupe); }
.site-nav a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--burgundy);
}

/* --------------------------------------------------------------------------
   MAIN / SECTION RHYTHM
   -------------------------------------------------------------------------- */
.main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  padding-bottom: var(--sp-7);
}
.band { padding-block: var(--sp-6); }
.band + .band { padding-top: 0; }
.band--ruled { border-top: 1px solid var(--rule); padding-top: var(--sp-6); }

.band__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.band__head h2 { font-size: var(--step-2); }

/* --------------------------------------------------------------------------
   HOMEPAGE — OPENING
   -------------------------------------------------------------------------- */
.opening { padding-block: clamp(3.5rem, 11vw, 8rem) var(--sp-6); }
.opening__meta { display: block; margin-bottom: var(--sp-4); }
.opening__sentence {
  font-family: var(--serif);
  font-size: var(--step-4);
  font-weight: 400;
  font-style: italic;
  line-height: 1.12;
  color: var(--ink);
  max-width: 22ch;
  letter-spacing: -0.01em;
}
.opening__support {
  max-width: var(--measure);
  margin-top: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  color: var(--ink-soft);
}
.opening__link {
  display: inline-block;
  margin-top: var(--sp-4);
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--burgundy);
  text-decoration: none;
  border-bottom: 1px solid var(--warm-gray);
  padding-bottom: 0.3rem;
}
.opening__link:hover { border-bottom-color: var(--burgundy); }
.opening__link::after { content: ' \2192'; }

/* --------------------------------------------------------------------------
   ENTRY LIST  (notes + fragments, home and /notes)
   -------------------------------------------------------------------------- */
.entries { list-style: none; padding: 0; display: grid; gap: 0; }
.entry {
  border-top: 1px solid var(--rule);
  padding-block: var(--sp-4);
}
.entry:last-child { border-bottom: 1px solid var(--rule); }
.entry__grid {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: 0 var(--sp-5);
  align-items: start;
}
.entry__aside { display: flex; flex-direction: column; gap: 0.35rem; text-align: right; }
.entry__title {
  font-family: var(--serif);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.18;
  margin-bottom: var(--sp-2);
}
.entry__title a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--burgundy), var(--burgundy));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.32s var(--ease), color 0.2s var(--ease);
  padding-bottom: 0.08em;
}
.entry__title a:hover { color: var(--burgundy); background-size: 100% 1px; }
.entry__excerpt { max-width: var(--measure); color: var(--ink-soft); }

.entry--fragment .entry__title { font-size: var(--step-1); }
.entry--fragment .entry__excerpt {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--ink);
}

@media (max-width: 60rem) {
  .entry__grid { display: block; }
  .entry__aside {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-2);
    text-align: left;
    margin-bottom: var(--sp-2);
  }
}

/* --------------------------------------------------------------------------
   CURRENTLY PANEL
   -------------------------------------------------------------------------- */
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--sp-5);
  align-items: start;
}

.currently {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-lift);
}
.currently__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule-strong);
  margin-bottom: var(--sp-3);
}
.currently__title {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-weight: 500;
  color: var(--ink);
}
.currently__list { display: grid; gap: 0.55rem; margin: 0; }
.currently__row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: baseline;
}
.currently__row dt { margin: 0; }
.currently__row dd {
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink);
  line-height: 1.5;
}
.currently__foot {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--rule-strong);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  align-items: baseline;
}
.currently__foot a { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }

@media (max-width: 26rem) {
  .currently__row { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* --------------------------------------------------------------------------
   ARCHIVE TRAIL
   -------------------------------------------------------------------------- */
.artifact {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}
.artifact__plate {
  aspect-ratio: 4 / 5;
  background:
    repeating-linear-gradient(
      -45deg,
      transparent 0 11px,
      rgba(166, 155, 142, 0.14) 11px 12px
    ),
    var(--paper);
  border: 1px solid var(--rule-strong);
  display: grid;
  place-items: center;
  padding: var(--sp-3);
  text-align: center;
}
.artifact__plate img { aspect-ratio: 4 / 5; object-fit: cover; width: 100%; }
.artifact__title {
  font-family: var(--serif);
  font-size: var(--step-1);
  color: var(--ink);
  margin-bottom: var(--sp-2);
}
.artifact__body { max-width: var(--measure); }
.artifact__caption { display: block; margin-top: var(--sp-3); }

@media (max-width: 44rem) {
  .artifact { grid-template-columns: 1fr; }
  .artifact__plate { max-width: 13rem; }
}

/* --------------------------------------------------------------------------
   CLOSING INVITATION
   -------------------------------------------------------------------------- */
.invitation { border-top: 1px solid var(--rule); padding-top: var(--sp-6); }
.invitation__line {
  font-family: var(--serif);
  font-size: var(--step-2);
  font-style: italic;
  color: var(--ink);
  max-width: 26ch;
}
.invitation__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
  list-style: none;
  padding: 0;
}
.invitation__links a {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid var(--warm-gray);
  padding-bottom: 0.25rem;
}
.invitation__links a:hover { border-bottom-color: var(--burgundy); }

/* --------------------------------------------------------------------------
   PAGE HEADERS (interior pages)
   -------------------------------------------------------------------------- */
.page-head { padding-block: clamp(2.5rem, 7vw, 5rem) var(--sp-5); }
.page-head__title { font-size: var(--step-3); }
.page-head__sub {
  font-family: var(--serif);
  font-size: var(--step-1);
  font-style: italic;
  color: var(--taupe-ink);
  max-width: 40ch;
  margin-top: var(--sp-2);
}

/* --------------------------------------------------------------------------
   PROSE (article body)
   -------------------------------------------------------------------------- */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--sp-3); }
.prose h2 {
  font-size: var(--step-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--rule);
}
.prose h3 { font-size: var(--step-1); margin-top: var(--sp-4); }
.prose ul, .prose ol { padding-left: 1.15rem; display: grid; gap: 0.45rem; }
.prose li { padding-left: 0.2rem; }
.prose li::marker { color: var(--taupe-ink); }
.prose strong { font-weight: 600; color: var(--ink); }
.prose figure { margin: var(--sp-4) 0; }
.prose figcaption { margin-top: var(--sp-2); }

.prose--article p { font-size: var(--step-0); }
.prose--article > p:first-of-type { font-size: var(--step-1); color: var(--ink); }

/* --------------------------------------------------------------------------
   ARTICLE FOOT / PREV-NEXT
   -------------------------------------------------------------------------- */
.article-foot {
  margin-top: var(--sp-6);
  border-top: 1px solid var(--rule);
  padding-top: var(--sp-4);
  max-width: var(--measure);
}
.pager {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.pager__item { display: flex; flex-direction: column; gap: 0.3rem; }
.pager__item--next { text-align: right; }
.pager__item a {
  font-family: var(--serif);
  font-size: var(--step-0);
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--warm-gray);
  padding-bottom: 0.2rem;
}
.pager__item a:hover { color: var(--burgundy); border-bottom-color: var(--burgundy); }
.article-foot__note { color: var(--ink-faint); font-size: var(--step--1); }

/* --------------------------------------------------------------------------
   FILTERS + YEAR ARCHIVE (/notes)
   -------------------------------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.filters button {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  min-height: 2.4rem;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.filters button:hover { border-color: var(--taupe); color: var(--ink); }
.filters button[aria-pressed='true'] {
  background: var(--burgundy);
  border-color: var(--burgundy);
  color: var(--ivory);
}

.year-archive { margin-top: var(--sp-5); }
.year-archive ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.year-archive a {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-decoration: none;
  border-bottom: 1px solid var(--warm-gray);
}

/* --------------------------------------------------------------------------
   CHANGELOG
   -------------------------------------------------------------------------- */
.log { list-style: none; padding: 0; margin: 0; }
.log__item { border-top: 1px solid var(--rule); padding-block: var(--sp-4); }
.log__item:last-child { border-bottom: 1px solid var(--rule); }
.log__version {
  font-family: var(--serif);
  font-size: var(--step-1);
  color: var(--ink);
  margin-bottom: var(--sp-1);
}
.log__body { max-width: var(--measure); }
.log__why {
  margin-top: var(--sp-2);
  padding-left: var(--sp-2);
  border-left: 2px solid var(--warm-gray);
  font-style: italic;
  color: var(--ink-faint);
  font-size: var(--step--1);
  max-width: var(--measure);
}

/* --------------------------------------------------------------------------
   PALETTE SWATCHES (colophon)
   -------------------------------------------------------------------------- */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  list-style: none;
  padding: 0;
  max-width: none;
}
.swatch__chip {
  height: 4.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  margin-bottom: var(--sp-2);
}
.swatch__name { display: block; }
.swatch__hex { display: block; color: var(--taupe-ink); }

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  padding-block: var(--sp-4);
  margin-top: auto;
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  align-items: baseline;
  justify-content: space-between;
}
.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  list-style: none;
  padding: 0;
}
.footer-nav a {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}
.footer-nav a:hover { color: var(--ink); border-bottom-color: var(--taupe); }

.footer-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-align: right;
}
@media (max-width: 44rem) { .footer-meta { text-align: left; } }

.counter { display: inline-flex; align-items: baseline; gap: 0.5rem; }
/* The Brat Tools widget writes the number and sets a state attribute.
   It injects no CSS of its own, so all counter styling lives here. */
.counter__value[data-brat-counter-state='pending'] { opacity: 0.55; }
.counter__value[data-brat-counter-state='error'] { opacity: 0.45; }
.counter__value {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  color: var(--gold-ink);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   MOTION PREFERENCES
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   PRINT
   -------------------------------------------------------------------------- */
@media print {
  body::before, .site-nav, .site-footer, .filters, .pager { display: none; }
  body { background: #fff; color: #000; }
}
