/* brownsmills.com — The Almanac & Ledger
   Design system per DESIGN.md. No frameworks, no build step. */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: "Young Serif";
  src: url("fonts/youngserif-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("fonts/publicsans-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("fonts/publicsans-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plexmono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plexmono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plexmono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --ink: #2b1d14;
  --sand: #eae3d1;
  --sand-deep: #ddd3ba;
  --pine: #1f3527;
  --pine-soft: #2c4636;
  --cedar: #5a3e2b;
  --cranberry: #7a1f2b;
  --blaze: #e8618c;
  --blaze-bright: #f491ae;
  --lake: #9db8b5;
  --caution: #f2c53d;

  --font-display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  --measure: 65ch;
  --wide: 72rem;
  --rule: 1px solid var(--cedar);
  --rule-faint: 1px solid rgba(90, 62, 43, 0.35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--sand);
  background-image: url("assets/img/texture/paper-almanac-grain-800.webp");
  background-repeat: repeat;
  background-size: 420px auto;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}
img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); }
/* Painted blaze mark under every page title, in the section's color */
main h1::after {
  content: "";
  display: block;
  width: 3.2rem;
  height: 0.42rem;
  margin-top: 0.45rem;
  background: var(--page-accent, var(--cranberry));
  border: 1px solid rgba(0, 0, 0, 0.25);
}
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); }
h3 { font-size: 1.2rem; font-family: var(--font-body); font-weight: 700; }
p { margin: 0 0 1em; max-width: var(--measure); }
ul, ol { max-width: var(--measure); padding-left: 1.4em; }
li { margin-bottom: 0.4em; }

a { color: var(--cranberry); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.band--pine a { color: var(--blaze-bright); }

:focus-visible {
  outline: 2px solid var(--cranberry);
  outline-offset: 3px;
  border-radius: 1px;
}
.band--pine :focus-visible, .site-header :focus-visible, .site-footer :focus-visible {
  outline-color: var(--caution);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--caution);
  color: #000;
  font-family: var(--font-mono);
  padding: 0.6rem 1rem;
  z-index: 99;
}
.skip-link:focus-visible { left: 0.5rem; top: 0.5rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Utility type ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cedar);
  margin: 0 0 0.7rem;
}
.band--pine .eyebrow { color: var(--lake); }

.source {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cedar);
  max-width: var(--measure);
  margin: 0.6rem 0 0;
}
.source a { color: inherit; }
.band--pine .source { color: var(--lake); }

.lede {
  font-size: 1.2rem;
  line-height: 1.55;
  max-width: 52ch;
}

/* ---------- Blazes ---------- */
.blaze {
  display: inline-block;
  width: 0.62em;
  height: 1em;
  vertical-align: -0.12em;
  margin-right: 0.55em;
  background: var(--cranberry);
  border: 1px solid rgba(0, 0, 0, 0.35);
  flex: none;
}
.blaze--record  { background: var(--blaze); }
.blaze--living  { background: var(--lake); }
.blaze--outside { background: var(--pine); }
.blaze--town    { background: var(--cedar); }
.blaze--year    { background: var(--cranberry); }
.blaze--new     { background: var(--sand); border: 2px solid var(--pine); }
.blaze--now     { background: var(--ink); }
/* Blazes on dark pine surfaces get a sand outline so pine/ink blazes stay visible */
.site-header .blaze, .site-footer .blaze, .band--pine .blaze {
  border-color: rgba(234, 227, 209, 0.6);
}

/* ---------- Header ---------- */
.site-header {
  background: var(--pine);
  color: var(--sand);
  border-bottom: 4px solid var(--blaze);
}
.site-header .wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0;
}
.wordmark {
  display: inline-block;
  color: var(--sand);
  text-decoration: none;
}
.wordmark .name {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  letter-spacing: 0.02em;
  display: block;
}
.wordmark .locale {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lake);
  display: block;
  margin-top: 0.15rem;
}
.site-nav {
  margin-top: 0.9rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav ul {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}
.site-nav a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--sand);
  text-decoration: none;
  padding: 0.65rem 0.7rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  min-height: 44px;
}
.site-nav a .blaze { margin-right: 0; width: 0.55em; height: 0.95em; }
.site-nav a:hover { border-bottom-color: var(--lake); }
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--blaze);
  color: #fff;
  font-weight: 600;
}

/* ---------- Page scaffold ---------- */
.page {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0 1.6rem;
  position: relative;
}
.page::before {
  /* full-height field-book rule between rail and content */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(1.25rem + 3.4rem);
  border-left: var(--rule-faint);
}
.rail {
  grid-column: 1;
  position: sticky;
  top: 0;
  align-self: start;
  height: max-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2.2rem;
  gap: 0.9rem;
}
.rail .blaze { width: 1.05rem; height: 1.7rem; margin: 0; }
.rail .rail-label {
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cedar);
}
.page > main { grid-column: 2; min-width: 0; padding: 2.2rem 0 3rem; }

section + section { margin-top: 3rem; }

/* ---------- Bands ---------- */
.band {
  padding: 1.6rem 1.5rem;
  border: var(--rule);
}
.band--deep { background: var(--sand-deep); }
.band--pine {
  background-color: var(--pine);
  background-image: linear-gradient(rgba(31, 53, 39, 0.88), rgba(31, 53, 39, 0.88)),
    url("assets/img/texture/pine-needle-dark-1600.webp");
  background-size: cover;
  background-position: center;
  color: var(--sand);
  border-color: var(--pine);
}
.band--pine h2, .band--pine h3 { color: var(--sand); }

/* ---------- Almanac strip ---------- */
.almanac {
  border-top: 3px solid var(--ink);
  border-bottom: var(--rule);
}
.almanac-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr auto;
  gap: 1rem;
  align-items: baseline;
  padding: 0.75rem 0.25rem;
  border-top: var(--rule-faint);
}
.almanac-row:first-child { border-top: 0; }
.almanac-when {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.almanac-what { min-width: 0; }
.almanac-what strong { font-weight: 600; }
.almanac-what .detail { color: var(--cedar); font-size: 0.92rem; display: block; }
.almanac-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cedar);
  white-space: nowrap;
}

/* ---------- Ledger ---------- */
.table-scroll { overflow-x: auto; }
.ledger {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
}
.ledger caption {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 700;
  padding-bottom: 0.5rem;
}
.ledger th {
  text-align: left;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cedar);
  border-bottom: 2px solid var(--ink);
  padding: 0.5rem 0.9rem 0.5rem 0;
}
.ledger td {
  vertical-align: top;
  border-bottom: var(--rule-faint);
  padding: 0.65rem 0.9rem 0.65rem 0;
}
.ledger .num { text-align: right; padding-right: 0; white-space: nowrap; }
.ledger th.num { padding-right: 0; }
/* .num zeroes right padding for the table edge; restore it when not last column */
.ledger td.num:not(:last-child), .ledger th.num:not(:last-child) { padding-right: 1.4rem; }
.ledger tr:nth-child(even) td { background: rgba(221, 211, 186, 0.4); }
/* Ledger inside dark pine bands */
.band--pine .ledger th {
  color: var(--lake);
  border-bottom-color: var(--sand);
}
.band--pine .ledger td { border-bottom-color: rgba(157, 184, 181, 0.35); }
.band--pine .ledger tr:nth-child(even) td { background: rgba(255, 255, 255, 0.07); }

/* ---------- Record entry ---------- */
.record-entry {
  border: var(--rule);
  background: rgba(255, 255, 255, 0.25);
  margin-top: 1.5rem;
}
.record-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  align-items: baseline;
  padding: 0.9rem 1.2rem;
  border-bottom: var(--rule-faint);
}
.record-head .when {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
}
.record-head .body-name { font-weight: 700; }
.record-body { padding: 1rem 1.2rem 1.2rem; }
.record-links {
  padding: 0.7rem 1.2rem;
  border-top: var(--rule-faint);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
}

/* ---------- Flags (SAMPLE / TODO) ---------- */
.flag-sample, .flag-todo {
  background:
    repeating-linear-gradient(-45deg, #1a1a1a 0 6px, var(--caution) 6px 12px) left / 0.9rem 100% no-repeat,
    var(--caution);
  color: #1a1a1a;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 0.8rem 0.5rem 1.7rem;
  max-width: none;
}
.flag-todo {
  background:
    repeating-linear-gradient(-45deg, var(--cedar) 0 6px, var(--sand-deep) 6px 12px) left / 0.9rem 100% no-repeat,
    var(--sand-deep);
}
.todo-link {
  font-family: var(--font-mono);
  font-size: 0.9em;
  border-bottom: 1px dashed var(--cedar);
  color: var(--cedar);
}
.band--pine .todo-link, .site-footer .todo-link {
  color: var(--lake);
  border-bottom-color: var(--lake);
}

/* ---------- Plots (ruled list, replaces "cards") ---------- */
.plots {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: none;
  border-top: 3px solid var(--ink);
}
.plots > li {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr;
  gap: 1.2rem;
  padding: 1.1rem 0.25rem;
  border-bottom: var(--rule-faint);
  margin: 0;
}
.plots .plot-key {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cedar);
}
.band--pine .plots { border-top-color: var(--sand); }
.band--pine .plots .plot-key { color: var(--lake); }
.band--pine .plots > li { border-bottom-color: rgba(157, 184, 181, 0.35); }
.plots .plot-val { min-width: 0; }
.plots .plot-val p:last-child { margin-bottom: 0; }

/* ---------- Wayfinding index (home) ---------- */
.waypoints {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1px;
  background: var(--cedar);
  border: var(--rule);
}
.waypoints li { margin: 0; }
.waypoints a {
  display: block;
  background: var(--sand);
  color: var(--ink);
  text-decoration: none;
  padding: 1.1rem 1.2rem 1.2rem;
  height: 100%;
}
.waypoints a:hover, .waypoints a:focus-visible { background: var(--sand-deep); }
.waypoints .way-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
}
.waypoints .way-desc {
  display: block;
  font-size: 0.9rem;
  color: var(--cedar);
  margin-top: 0.3rem;
}

/* ---------- Current month (set by main.js on year.html) ---------- */
.is-current-month h2 { color: var(--cranberry); }
.is-current-month .almanac { border-top-color: var(--cranberry); }

/* ---------- Photos (field-specimen treatment) ---------- */
figure.photo {
  margin: 0;
  max-width: none;
}
figure.photo img {
  width: 100%;
  border: 1px solid var(--cedar);
  background: var(--sand-deep);
}
figure.photo figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cedar);
  padding: 0.45rem 0.1rem 0;
  line-height: 1.5;
}
.band--pine figure.photo figcaption { color: var(--lake); }
.band--pine figure.photo img { border-color: var(--pine-soft); }
figure.photo .credit { opacity: 0.85; }

/* Postcards and other archival prints read as physical objects */
figure.photo--card img {
  border: 7px solid #fdfbf5;
  outline: 1px solid rgba(90, 62, 43, 0.45);
  box-shadow: 2px 4px 14px rgba(43, 29, 20, 0.22);
}
figure.photo--card { transform: rotate(-1.2deg); padding: 0.4rem 0.4rem 0; }
figure.photo--card:nth-of-type(even) { transform: rotate(0.9deg); }
figure.photo--card figcaption { padding-top: 0.7rem; }

/* Modern color photos get a light unifying warm tone */
figure.photo--tone img {
  filter: sepia(0.14) saturate(0.82) contrast(1.03);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.2rem;
  margin: 1.4rem 0;
}

/* Full-width vista band: one wide photo with a caption bar */
.vista {
  margin: 0;
  position: relative;
  border-top: 3px solid var(--ink);
  border-bottom: var(--rule);
}
.vista img {
  width: 100%;
  height: clamp(16rem, 42vw, 26rem);
  object-fit: cover;
  display: block;
}
.vista figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--sand);
  background: var(--pine);
  padding: 0.5rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.3rem 1.2rem;
}

/* Split hero: text beside a tall photo */
.hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 2.2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .hero-split { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--pine);
  color: var(--sand);
  border-top: 4px solid var(--blaze);
  margin-top: 4rem;
}
.site-footer .wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.2rem 1.25rem 2.6rem;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}
.site-footer p { color: var(--sand); }
.site-footer .foot-note {
  font-size: 0.9rem;
  color: var(--lake);
  max-width: 48ch;
}
.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--sand);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.3rem 0;
  min-height: 32px;
}
.site-footer nav a:hover { color: var(--blaze-bright); }
.site-footer .foot-mark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
}

/* ---------- Motion (opt-in only; content never starts hidden) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .almanac-row, .waypoints a, .record-entry {
    transition: background-color 160ms ease;
  }
  a { transition: text-decoration-thickness 120ms ease; }
}
/* .reveal-init is added by JS only (see main.js) — never by CSS alone, so
   a section is never left invisible if the script doesn't run. */
.reveal-init {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 500ms ease, transform 500ms ease;
}
.reveal-init.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { font-size: 1rem; }
  .page {
    display: block;
    padding: 0 1rem;
  }
  .site-nav {
    /* fade hint that the nav scrolls */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 2.2rem), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 2.2rem), transparent);
  }
  .page::before { display: none; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-bottom: var(--rule);
    padding: 0.8rem 0;
    gap: 0.7rem;
  }
  .rail .rail-label { writing-mode: horizontal-tb; letter-spacing: 0.18em; }
  .rail .blaze { width: 0.8rem; height: 1.2rem; }
  .page > main { padding-top: 1.6rem; }
  .almanac-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding: 0.85rem 0.25rem;
  }
  .almanac-tag { order: -1; }
  .plots > li { grid-template-columns: 1fr; gap: 0.3rem; }
  .site-footer .wrap { grid-template-columns: 1fr; }
  /* Tables keep legible columns and scroll sideways instead of crushing */
  .table-scroll .ledger { min-width: 34rem; }
  .record-head { padding: 0.8rem 0.9rem; }
  .record-body { padding: 0.9rem; }
  .record-links { padding: 0.7rem 0.9rem; flex-direction: column; }
}
