/* ==========================================================================
   Tollivar website stylesheet
   Single source of CSS for the site. Implements the Tollivar Design System.
   Visual identity is governed by the tollivar-design-system skill.
   ========================================================================== */

/* ---- Fonts (self-hosted, no third-party CDN, GDPR requirement) ---------- */

@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/SourceSerif4Variable-Roman.ttf.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/SourceSerif4Variable-Italic.ttf.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/assets/fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---- Design tokens ------------------------------------------------------ */

:root {
  /* Warm neutral ramp, hue 70 */
  --ground: #FDFCF8;         /* parchment, the page */
  --document: #F3EFEC;       /* table rows, input fills, code only */
  --rule: #E1DDDA;           /* hairlines, secondary button outline */
  --muted-inverse: #AEAAA5;  /* secondary text on charcoal */
  --muted: #6C6863;          /* captions, nav labels, uppercase labels */
  --rule-inverse: #4B4743;   /* hairlines on charcoal */
  --body: #33302C;           /* running text */
  --inverse: #221E1C;        /* the dark band */
  --ink: #1D1A17;            /* headings, wordmark */
  --white: #FFFFFF;

  /* Oxblood ramp, hue 25 */
  --accent: #6A3633;         /* links, primary button fill, focus ring */
  --accent-strong: #562421;  /* link and button hover, light grounds */
  --accent-inverse: #C99691; /* links and accents on charcoal */
  --tint: #F8E6E4;           /* text selection only */

  /* Status */
  --error: #843C36;
  --caution: #754B00;
  --affirm: #2B6339;

  /* Type */
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Helvetica, system-ui, sans-serif;

  /* Layout */
  --rail-page: 1080px;
  --rail-reading: 720px;
  --rail-tabular: 1280px;
  --gutter: 32px;
  --measure: 68ch;
  --measure-narrow: 54ch;
}

/* ---- Reset and base ----------------------------------------------------- */

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

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--body);
  font-family: var(--serif);
  font-size: 1.125rem;      /* 18px */
  line-height: 1.5556;      /* 28px baseline */
  font-weight: 400;
  font-optical-sizing: auto;
  font-feature-settings: "pnum" 1, "onum" 1; /* proportional oldstyle in prose */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--tint); }

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

/* ---- Headings ----------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;          /* headings are never bold */
  color: var(--ink);
  margin: 0;
  line-height: 1.18;
}

.display {
  font-size: 3.4375rem;      /* 55px */
  line-height: 1.06;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-weight: 400;
  margin: 0;
}
h1, .h1 { font-size: 2.75rem;  line-height: 1.12; letter-spacing: -0.018em; }  /* 44 */
h2, .h2 { font-size: 2.1875rem; line-height: 1.18; letter-spacing: -0.012em; } /* 35 */
h3, .h3 { font-size: 1.75rem;  line-height: 1.22; letter-spacing: -0.008em; }  /* 28 */
h4, .h4 { font-size: 1.375rem; line-height: 1.3;  letter-spacing: 0; }         /* 22 */

.lead {
  font-size: 1.375rem;       /* 22px */
  line-height: 1.4;
  color: var(--body);
}

.small { font-size: 0.875rem; line-height: 1.5; }
.caption { font-size: 0.875rem; line-height: 1.5; color: var(--muted); }

/* ---- Labels and eyebrows ------------------------------------------------ */

.label, .eyebrow {
  font-family: var(--sans);
  font-size: 0.6875rem;      /* 11px */
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-feature-settings: "lnum" 1, "tnum" 1; /* lining figures on labels */
  color: var(--muted);
  display: inline-block;
}
.eyebrow { margin-bottom: 16px; }
.eyebrow--accent { color: var(--accent); }
.eyebrow--inverse { color: var(--muted-inverse); }

/* ---- Links -------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 120ms ease-out;
}
a:hover { color: var(--accent-strong); }

/* ---- Prose -------------------------------------------------------------- */

.prose { max-width: var(--measure); }
.prose.measure-full { max-width: var(--measure); }
.prose p { margin: 0 0 1.5rem; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; }
.prose em, cite { font-style: italic; } /* case names, titles, never emphasis */
.center .prose { margin-left: auto; margin-right: auto; }

/* ---- Rule (the only divider) -------------------------------------------- */

hr, .rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 4rem 0;
  width: 100%;
}

/* ---- Layout: bands and rails -------------------------------------------- */

.band {
  width: 100%;
  background: var(--ground);
  padding-block: 8rem;       /* default 128px */
}
.band--white { background: var(--white); }
.band--charcoal { background: var(--inverse); color: var(--muted-inverse); }
.band--tight { padding-block: 6rem; }   /* 96px */
.band--loose { padding-block: 12rem; }  /* 192px */
.band--divider { border-top: 1px solid var(--rule); }
.band--charcoal.band--divider { border-top-color: var(--rule-inverse); }

.rail {
  max-width: var(--rail-page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.rail--reading { max-width: var(--rail-reading); }
.rail--tabular { max-width: var(--rail-tabular); }

/* inverse ground remapping */
.band--charcoal h1, .band--charcoal h2, .band--charcoal h3,
.band--charcoal h4, .band--charcoal .display { color: var(--ground); }
.band--charcoal p, .band--charcoal .lead, .band--charcoal li { color: var(--ground); }
.band--charcoal a { color: var(--accent-inverse); }
.band--charcoal a:hover { color: var(--ground); }
.band--charcoal .eyebrow, .band--charcoal .label { color: var(--muted-inverse); }
.band--charcoal hr, .band--charcoal .rule { border-top-color: var(--rule-inverse); }

/* spacing helpers on the baseline scale */
.stack > * + * { margin-top: 1.5rem; }      /* 24px */
.stack-block > * + * { margin-top: 4rem; }   /* 64px */
.center { text-align: center; }
.center .prose, .center .section-heading { margin-inline: auto; }

/* ---- SectionHeading ----------------------------------------------------- */

.section-heading { max-width: var(--measure); }
.center .section-heading { margin-inline: auto; }
.section-heading .lead { margin-top: 1.5rem; }

/* ---- Buttons ------------------------------------------------------------ */

.btn {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-feature-settings: "lnum" 1;
  display: inline-block;
  padding: 12px 24px;
  border-radius: 0;
  border: 1px solid transparent;
  text-decoration: none;
  text-align: center;
  line-height: 1.3;
  cursor: pointer;
  transition: color 120ms ease-out, background-color 120ms ease-out, border-color 120ms ease-out;
}
.btn--primary {
  background: var(--accent);
  color: var(--ground);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--ground); }
.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.btn--secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn--text {
  padding: 0;
  border: 0;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.btn--text:hover { color: var(--accent-strong); }
.band--charcoal .btn--secondary { color: var(--ground); border-color: var(--rule-inverse); }
.band--charcoal .btn--secondary:hover { border-color: var(--ground); }

.btn-row { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.center .btn-row { justify-content: center; }

/* ---- IndexList (replaces cards) ----------------------------------------- */

.index-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.band--charcoal .index-list { border-top-color: var(--rule-inverse); }
.index-list__row {
  display: flex;
  gap: 24px;
  align-items: baseline;
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
}
.band--charcoal .index-list__row { border-bottom-color: var(--rule-inverse); }
.index-list__num {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-feature-settings: "lnum" 1, "tnum" 1;
  flex: 0 0 auto;
  min-width: 2.5em;
  padding-top: 0.4em;
}
.index-list__body { flex: 1 1 auto; }
.index-list__title { font-size: 1.375rem; line-height: 1.3; color: var(--ink); margin: 0; }
.index-list__title a { color: var(--ink); text-decoration: none; }
.index-list__title a:hover { color: var(--accent); }
.index-list__desc { margin: 8px 0 0; color: var(--body); }
.index-list__meta {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-feature-settings: "lnum" 1, "tnum" 1;
  text-align: right;
  padding-top: 0.4em;
  white-space: nowrap;
}
.band--charcoal .index-list__title { color: var(--ground); }
.band--charcoal .index-list__title a { color: var(--ground); }
.band--charcoal .index-list__desc { color: var(--muted-inverse); }

.index-list--tight .index-list__row { padding: 12px 0; align-items: flex-start; }
.index-list--tight .index-list__desc { margin: 0; }

/* ---- PullQuote ---------------------------------------------------------- */

.pullquote { max-width: var(--measure-narrow); margin: 3rem 0; }
.center .pullquote { margin-inline: auto; }
.pullquote p { font-size: 1.375rem; line-height: 1.4; color: var(--ink); margin: 0; }
.pullquote .attribution {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 16px;
  display: block;
}

/* ---- Tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-feature-settings: "lnum" 1, "tnum" 1; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}
tbody tr:nth-child(odd) td { background: var(--document); }

/* ---- Site header -------------------------------------------------------- */

.site-header { background: var(--ground); border-bottom: 1px solid var(--rule); }
.site-header__inner {
  max-width: var(--rail-page);
  margin-inline: auto;
  padding: 24px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.site-header__mark img { width: 180px; height: auto; }
.site-header__mark { display: inline-flex; }

.nav { display: flex; align-items: center; gap: 32px; }
.nav__list { display: flex; align-items: center; gap: 32px; list-style: none; margin: 0; padding: 0; }
.nav__item { position: relative; }
.nav__link {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 0;
  display: inline-block;
}
.nav__link:hover, .nav__link[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 0.3em; }

/* dropdown: no shadow, no radius, hairline only */
.nav__submenu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--ground);
  border: 1px solid var(--rule);
  list-style: none;
  margin: 0;
  padding: 8px 0;
  display: none;
  z-index: 20;
}
.nav__item--has-menu:hover .nav__submenu,
.nav__item--has-menu:focus-within .nav__submenu { display: block; }
.nav__submenu a {
  display: block;
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 24px;
}
.nav__submenu a:hover { color: var(--ink); background: var(--document); }

.nav__cta { margin-left: 8px; }

/* mobile nav toggle */
.nav__toggle {
  display: none;
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 0;
}

/* ---- Site footer -------------------------------------------------------- */

.site-footer { background: var(--inverse); color: var(--muted-inverse); }
.site-footer__inner {
  max-width: var(--rail-page);
  margin-inline: auto;
  padding: 6rem var(--gutter);
}
.site-footer__top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 64px;
}
.site-footer__mark { flex: 0 0 auto; }
.site-footer__mark img { width: 180px; height: auto; }
.footer-cols {
  flex: 1 1 520px;
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 48px;
}
.footer-col__title {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-inverse);
  margin: 0 0 16px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 12px; }
.footer-col a { color: var(--ground); text-decoration: none; font-size: 0.9375rem; }
.footer-col a:hover { color: var(--accent-inverse); text-decoration: underline; text-underline-offset: 0.18em; }
.site-footer__legal {
  margin-top: 4rem;
  padding-top: 24px;
  border-top: 1px solid var(--rule-inverse);
  font-size: 0.875rem;
  color: var(--muted-inverse);
  text-align: center;
}
.site-footer__legal p { margin: 0 0 8px; }

/* ---- Forms (TextField) -------------------------------------------------- */

.form { max-width: var(--rail-reading); }
.field { margin-bottom: 2rem; }
.field__label {
  display: block;
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field__input, .field__textarea {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 0;
  font-family: var(--serif);
  font-size: 1.125rem;
  color: var(--body);
}
.field__textarea { resize: vertical; min-height: 7rem; }
.field__input:focus, .field__textarea:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.field__hint { font-size: 0.875rem; color: var(--muted); margin-top: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form-note { font-size: 0.875rem; color: var(--muted); margin-top: 1.5rem; }

.form-feedback { padding: 16px 0; font-size: 1.125rem; }
.form-feedback--ok { color: var(--affirm); }
.form-feedback--error { color: var(--error); }

/* ---- Article ------------------------------------------------------------ */

.article__meta {
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 0;
}
.article__body { max-width: var(--measure); }
.article__body h2 { margin-top: 3rem; }
.article__body h3 { margin-top: 2rem; }
.article__body p { margin: 0 0 1.5rem; }

/* ---- Focus (accessibility) ---------------------------------------------- */

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}
.btn--primary:focus-visible { outline-color: var(--ground); outline-offset: -4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--ground);
  padding: 12px 16px;
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---- Utilities ---------------------------------------------------------- */

.page-title { max-width: var(--measure); }
.center .page-title { margin-inline: auto; }
.lede-narrow { max-width: var(--measure-narrow); }

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

@media (max-width: 820px) {
  .display { font-size: 2.75rem; }
  h1, .h1 { font-size: 2.1875rem; }
  h2, .h2 { font-size: 1.75rem; }
  h3, .h3 { font-size: 1.375rem; }
  .band { padding-block: 6rem; }
  .band--loose { padding-block: 8rem; }
  .footer-cols { grid-template-columns: 1fr; gap: 32px; }

  .nav__toggle { display: inline-block; }
  .nav { display: none; }
  .nav--open { display: block; position: static; width: 100%; }
  .nav--open .nav__list { flex-direction: column; align-items: flex-start; gap: 0; width: 100%; }
  .nav--open .nav__item { width: 100%; border-top: 1px solid var(--rule); }
  .nav--open .nav__link { display: block; padding: 16px 0; width: 100%; }
  .nav--open .nav__submenu {
    position: static; display: block; border: 0; padding: 0 0 8px 16px; min-width: 0;
  }
  .nav--open .nav__submenu a { padding: 10px 0; }
  .nav--open .nav__cta { margin: 16px 0 0; }
  .site-header__inner { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .rail, .site-header__inner, .site-footer__inner, .rail--reading, .rail--tabular { padding-inline: 20px; }
  .index-list__row { flex-wrap: wrap; gap: 8px; }
  .index-list__meta { text-align: left; }
}
