/* American Torii — site styles. Plain CSS, no build step. */

:root {
  --ink: #1c1a17;
  --muted: #6b645c;
  --accent: #cd3b1b; /* Inari red-orange (darkened for WCAG AA on light bg) */
  --bg: #faf8f5;
  --line: #e2ddd5;
  --max: 52rem;
  /* Two-face pairing: serif for reading text (entry prose), sans for headings
     and UI chrome (brand, nav, buttons, table heads) so hierarchy reads from
     the typeface, not just size. System stacks only — no webfont to download,
     matching the no-CDN approach used for Leaflet. */
  --font-body: ui-serif, Georgia, "Times New Roman", serif;
  --font-head: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 17px/1.6 var(--font-body);
  color: var(--ink);
  background: var(--bg);
}

/* Headings + UI chrome take the sans face; tighter tracking/leading keeps the
   larger sizes from looking loose. */
h1, h2, h3, h4,
.brand,
.site-nav,
.button,
.catalog th,
.updated,
.entry-updated,
.breadcrumb,
.location { font-family: var(--font-head); }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.01em; }

a { color: var(--accent); }
a:hover { text-decoration: none; }

/* Text selection picks up the Inari accent as a soft tint (kept light so the
   dark ink text stays fully readable on top). */
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* Visible focus ring for keyboard users only (:focus-visible keeps it off for
   mouse clicks). Applies wherever the browser shows focus — links, buttons,
   the focusable <main> skip target. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The <main> skip target shouldn't draw a ring just from being jumped to. */
.site-main:focus-visible { outline: none; }

/* "Skip to content" link: off-screen until a keyboard user tabs to it, then it
   slides into the top-left corner. Mouse users never see it. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-head);
  padding: 0.6rem 1rem;
  border-radius: 0 0 0.4rem 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* --- Layout shell --- */
.site-header,
.site-main,
.site-footer { max-width: var(--max); margin-inline: auto; padding-inline: 1.25rem; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.5rem;
  text-decoration: none;
  color: var(--ink);
}
.brand-icon {
  display: block;
  width: 1.25em;
  height: 1.25em;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.site-nav a { text-decoration: none; }
/* Current section: bold + underlined (other nav links have no underline).
   The aria-current attribute that drives this also announces it to screen
   readers. */
.site-nav a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.site-main { padding-block: 2rem 3rem; }

/* Like the header: one row with the updated date flush right, wrapping into
   stacked lines when the viewport is too narrow for both. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  border-top: 1px solid var(--line);
  padding-block: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin-block: 0; }
.site-footer .updated { font-size: 0.8rem; }

/* --- Home --- */
.hero h1 { font-size: 2.5rem; margin-bottom: 0.25rem; }
.tagline { font-size: 1.2rem; color: var(--muted); margin-top: 0; }
.stats { color: var(--muted); }
.buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 1.1rem;
  border-radius: 0.4rem;
}
.button.secondary {
  background: transparent;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* --- 404 / error page --- */
.error { text-align: center; padding-block: 1rem; }
/* The torii scene: capped width, centered, room below before the heading. */
.error-art {
  display: block;
  width: min(20rem, 75%);
  height: auto;
  margin: 0 auto 1.5rem;
}
/* Torii itself, in the site accent — same flat motif as the brand icon. */
.error-gate { fill: var(--accent); }
/* The path through the gate: a faint accent wash with a dashed centerline that
   fades toward the (empty) vanishing point. */
.error-path { fill: color-mix(in srgb, var(--accent) 9%, transparent); }
.error-path-line {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 45%, transparent);
  stroke-width: 2;
  stroke-dasharray: 5 7;
  stroke-linecap: round;
}
.error-ground { stroke: var(--line); stroke-width: 2; }
/* Oversized "404" eyebrow above the heading, in the heading face. */
.error-eyebrow {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--accent);
  margin: 0 0 0.25rem;
}
.error h1 { font-size: 2.25rem; margin: 0 0 0.75rem; }
.error p { color: var(--muted); max-width: 34rem; margin-inline: auto; }
/* .buttons is flex; center it here and give it room above. */
.error .buttons { justify-content: center; margin-top: 1.75rem; }

/* --- Lists --- */
/* Negative inline margin lets the row hover tint extend past the text while the
   text itself stays aligned with the surrounding content (li padding offsets it). */
.region-list,
.torii-list { list-style: none; padding: 0; margin-inline: -0.6rem; }
.region-list li,
.torii-list li {
  position: relative; /* anchor for the stretched-link overlay */
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  border-radius: 0.3rem;
}
/* Group multiple counts (e.g. standing + "former") at the right edge. */
.region-list .count:first-of-type { margin-inline-start: auto; }
/* Whole-row clickable: the row's first link is stretched over the entire <li>
   via an overlay, so a click anywhere in the row opens it — while the markup
   keeps just one real, properly-labelled link per row (good for screen readers).
   Trade-off: text in the row (city/counts) can't be selected with the mouse. */
.region-list li > a::after,
.torii-list li > a::after { content: ""; position: absolute; inset: 0; }
.region-list li:hover,
.torii-list li:hover,
.region-list li:focus-within,
.torii-list li:focus-within {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.region-list li:hover > a,
.torii-list li:hover > a { text-decoration: underline; }
.count, .meta { color: var(--muted); font-size: 0.9rem; }

/* --- Catalog table --- */
.catalog { width: 100%; border-collapse: collapse; }
.catalog th, .catalog td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.catalog th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* On narrow screens the multi-column table would overflow, so stack each row
   into a labelled card: hide the header row and show each cell's column name
   (from its data-label) inline beside the value. */
@media (max-width: 40rem) {
  /* Visually hide the header row (kept for screen readers). */
  .catalog thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .catalog,
  .catalog tbody,
  .catalog tr,
  .catalog td { display: block; width: 100%; }
  .catalog tr {
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.85rem;
  }
  .catalog td {
    border: none;
    padding: 0.25rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    text-align: right;
  }
  .catalog td:empty { display: none; } /* skip blank fields (e.g. no setting) */
  .catalog td::before {
    content: attr(data-label);
    font-family: var(--font-head);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-align: left;
  }
  /* Name leads each card as a full-width title line, no label. */
  .catalog td:first-child {
    justify-content: flex-start;
    text-align: left;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.3rem;
    padding-bottom: 0.45rem;
  }
  .catalog td:first-child::before { display: none; }
}

/* --- Entry page --- */
.breadcrumb { color: var(--muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--muted); }
.location { color: var(--muted); margin-top: -0.5rem; }
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.25rem;
  margin: 1.5rem 0;
}
.facts dt { font-weight: 700; color: var(--muted); }
.facts dd { margin: 0; }
.photos figure { margin: 0 0 1.5rem; }
.photos img { max-width: 100%; height: auto; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }
.credit { font-style: italic; }
.sources { font-size: 0.95rem; }
.entry-updated { margin-top: 2rem; color: var(--muted); font-size: 0.8rem; }

/* --- Media frame --- */
/* Entry photos and the map share one hairline frame (the site's --line rule
   color) so framed imagery looks consistent everywhere. */
.photos img,
#map {
  border: 1px solid var(--line);
  border-radius: 0.4rem;
}

/* --- Map --- */
#map {
  height: 70vh;
  min-height: 360px;
}
/* Custom torii markers: a soft shadow lifts the flat SVG off busy map tiles. */
.torii-marker {
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}
/* No-longer-standing gates (moved/removed): greyscale so they read as
   historical without competing with standing ones. */
.torii-marker--gone {
  filter: grayscale(1) drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}

/* Shown above the map when the GeoJSON fetch fails (see map.njk). */
.map-error {
  border: 1px solid var(--accent);
  border-radius: 0.4rem;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-family: var(--font-head);
  font-size: 0.95rem;
}

/* "No longer standing" toggle control (top-right of the map). */
.map-toggle {
  background: #fff;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
}
.map-toggle label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

/* Cluster bubbles in the site accent (overrides the plugin's default colors).
   Outer ring is a translucent halo; inner circle is solid with white count. */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: color-mix(in srgb, var(--accent) 90%, transparent);
  color: #fff;
}
