/* ==========================================================================
   Villages — legal site
   Plain CSS. No build step, no framework, no JavaScript.

   Type register (founder ruling, matches the app):
     display headings ....... EB Garamond
     body / long prose ...... Cormorant Garamond
     UI, links, navigation .. Inter
     metadata, eyebrows ..... JetBrains Mono, uppercase, wide tracking

   Colour is drawn from the app's own tokens in src/theme/colors.ts:
     ground  #F6F3ED  (backgroundPaper)      ink   #191714 (textHand)
     soft    #56514B  (textHandSoft)         rule  #D5D0C7 (borderHandSoft)
     clay    #A8482E  (palette.terracotta / colors.textAccent)
   ========================================================================== */

/* --- Palette ------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --ground:       #F6F3ED;
  --ground-raise: #FFFDF9;
  --ink:          #191714;
  --prose:        #211E1A;
  --soft:         #56514B;
  --meta:         #6B655D;
  --rule:         #D5D0C7;
  --rule-strong:  #B9B2A6;
  --clay:         #A8482E;
  --clay-hover:   #8C3820;
  --selection:    rgba(168, 72, 46, 0.16);

  --font-display: 'EB Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino,
                  Georgia, 'Times New Roman', serif;
  --font-prose:   'Cormorant Garamond', 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-ui:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                  'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo,
                  Consolas, 'Liberation Mono', monospace;

  --measure: 34rem;
  --gutter:  clamp(1.25rem, 5vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:       #17110E;
    --ground-raise: #201814;
    --ink:          #F5EADA;
    --prose:        #E8DCCA;
    --soft:         #C8B9A6;
    --meta:         #A89684;
    --rule:         #372C25;
    --rule-strong:  #4E3F35;
    --clay:         #D69A83;
    --clay-hover:   #E7B29D;
    --selection:    rgba(214, 154, 131, 0.22);
  }
}

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

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--prose);
  font-family: var(--font-prose);
  font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.1875rem);
  line-height: 1.68;
  font-feature-settings: 'kern' 1, 'liga' 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

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

/* --- Focus & skip link -------------------------------------------------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  background: var(--ground-raise);
  color: var(--clay);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--clay);
  text-decoration: none;
}

.skip-link:focus {
  left: var(--gutter);
  top: 0.75rem;
}

/* --- Shell -------------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

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

.site-header {
  border-bottom: 1px solid var(--rule);
}

.site-header .shell {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding-block: 1.5rem 1.25rem;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.wordmark:hover { color: var(--clay); }

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
}

.site-nav a,
.site-footer nav a {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--soft);
  text-decoration: none;
  padding-block: 0.25rem;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover,
.site-footer nav a:hover {
  color: var(--clay);
  border-bottom-color: var(--clay);
}

.site-nav a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--rule-strong);
}

/* --- Eyebrow / metadata ------------------------------------------------- */

.eyebrow,
.meta dt,
.notice-label,
.decision-label,
.updated {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.5;
  color: var(--meta);
}

.eyebrow {
  margin: 0 0 0.875rem;
}

/* --- Page head ---------------------------------------------------------- */

main { display: block; }

.page-head {
  padding-block: clamp(2.5rem, 8vw, 4.5rem) 0;
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.25rem, 1.6rem + 3.2vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 1rem;
  text-wrap: balance;
}

.standfirst {
  font-family: var(--font-prose);
  font-size: 1.1875em;
  font-style: italic;
  line-height: 1.55;
  color: var(--soft);
  margin: 0 0 2rem;
  max-width: 30rem;
}

/* --- The working-draft notice.
       Prominent, near the top of every page, marked by a clay rule rather
       than a box. Do not soften. ---------------------------------------- */

.notice {
  border-left: 2px solid var(--clay);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 2rem 0 2.5rem;
}

.notice-label {
  color: var(--clay);
  margin: 0 0 0.5rem;
}

.notice p {
  font-size: 0.9375em;
  line-height: 1.6;
  margin: 0 0 0.75rem;
  color: var(--soft);
}

.notice p:last-child { margin-bottom: 0; }
.notice strong { color: var(--ink); }

.notice a,
.open-decision a {
  color: var(--clay);
  font-family: var(--font-ui);
  font-size: 0.9375em;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.notice a:hover,
.open-decision a:hover {
  color: var(--clay-hover);
  text-decoration-thickness: 2px;
}

/* --- Document metadata block -------------------------------------------- */

.meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.125rem 1.5rem;
  margin: 0 0 2.5rem;
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

@media (min-width: 34rem) {
  .meta { grid-template-columns: 11rem minmax(0, 1fr); }
  .meta dt { padding-top: 0.3rem; }
}

.meta dt { margin: 0; }

.meta dd {
  margin: 0 0 0.75rem;
  font-size: 0.9375em;
  line-height: 1.5;
  color: var(--prose);
}

@media (min-width: 34rem) {
  .meta dd { margin-bottom: 0.5rem; }
}

.meta dd:last-of-type { margin-bottom: 0; }

.placeholder {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--clay);
  background: var(--ground-raise);
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--rule-strong);
  white-space: normal;
}

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

.prose { padding-bottom: 1rem; }

.prose > * { max-width: var(--measure); }

.prose h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 1.25rem + 1.2vw, 1.9375rem);
  line-height: 1.2;
  color: var(--ink);
  margin: 3.25rem 0 0.875rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  text-wrap: balance;
}

.prose h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1875em;
  line-height: 1.3;
  color: var(--ink);
  margin: 2.25rem 0 0.5rem;
}

.prose p { margin: 0 0 1.15rem; }

.prose strong {
  font-weight: 600;
  color: var(--ink);
}

.prose em { font-style: italic; }

.prose ul,
.prose ol {
  margin: 0 0 1.25rem;
  padding-left: 1.35rem;
}

.prose ol { padding-left: 1.5rem; }

.prose li { margin-bottom: 0.5rem; }

.prose ul li::marker { color: var(--rule-strong); }

.prose ol li::marker {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--meta);
}

.prose a,
.prose-link {
  color: var(--clay);
  font-family: var(--font-ui);
  font-size: 0.9375em;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.prose a:hover,
.prose-link:hover {
  color: var(--clay-hover);
  text-decoration-thickness: 2px;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

/* --- Open decision blocks.
       These mark genuinely undecided points. They are part of the document,
       not decoration — never replace one with invented text. -------------- */

.open-decision {
  border-left: 2px solid var(--rule-strong);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.75rem 0 2rem;
}

.decision-label {
  color: var(--soft);
  margin: 0 0 0.5rem;
}

.open-decision p {
  font-size: 0.9375em;
  line-height: 1.6;
  color: var(--soft);
  margin: 0 0 0.75rem;
}

.open-decision p:last-child { margin-bottom: 0; }
.open-decision strong { color: var(--ink); }

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

.table-scroll {
  max-width: var(--measure);
  overflow-x: auto;
  margin: 0 0 1.5rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-block: 0.5rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 30rem;
  font-size: 0.9375em;
}

caption {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--meta);
  text-align: left;
  padding-block: 0.5rem 0.75rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.5;
}

th {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
}

tbody tr:last-child th,
tbody tr:last-child td { border-bottom: 0; }

/* --- Index: document list ----------------------------------------------- */

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}

.doc-list li { border-bottom: 1px solid var(--rule); }

.doc-list a {
  display: block;
  padding: 1.5rem 0;
  text-decoration: none;
  color: inherit;
}

.doc-list a:hover .doc-title {
  color: var(--clay);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.doc-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 0.375rem;
}

.doc-blurb {
  display: block;
  font-size: 0.9375em;
  line-height: 1.55;
  color: var(--soft);
  max-width: 30rem;
}

/* --- Back link ---------------------------------------------------------- */

.back {
  margin: 3rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.back a {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--clay);
  text-decoration: none;
}

.back a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

.site-footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--rule);
}

.site-footer .shell {
  padding-block: 2rem 3.5rem;
}

.site-footer nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 0;
}

.site-footer p {
  font-size: 0.9375em;
  line-height: 1.6;
  color: var(--soft);
  margin: 0 0 0.5rem;
  max-width: var(--measure);
}

.site-footer .eyebrow { margin-bottom: 0.75rem; }

.site-footer a:not(.site-footer nav a) {
  color: var(--clay);
  font-family: var(--font-ui);
  font-size: 0.9375em;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* --- Print -------------------------------------------------------------- */

@media print {
  .skip-link, .site-nav, .back { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .prose > * { max-width: none; }
  a { text-decoration: underline; }
}
