/* shogun.info
 *
 * Several short pages, no scripts. Newsreader for display, the system stack
 * for body, and the system's own Japanese fonts wherever a page quotes
 * Japanese.
 *
 * The palette is bright on purpose: a warm white ground, and one strong
 * colour for each period, used for that page's band, its cards and its
 * diagrams. The theme classes set --theme (the band and accents) and
 * --theme-text (the same hue, readable as text on the ground). White text on
 * every --theme passes 4.5:1. The diagrams in public/images/ copy these
 * colours, so a change here is also a change in bin/make-diagrams.mjs.
 *
 * Light only, whatever the operating system prefers: Julian wants the bright
 * version shown to everyone (16 September 2026). color-scheme and the
 * color-scheme meta tag in the layout keep browsers from darkening it.
 */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/newsreader-latin.woff2") format("woff2");
}

:root {
  --ground: #FFFBF3;
  --ink: #1C1B2B;
  --muted: #57546A;
  --border: #EADFCB;
  --card: #FFFFFF;
  --tint: #FFF3DC;
  --shadow: 0 1px 2px rgba(28, 27, 43, 0.06), 0 10px 28px -14px rgba(28, 27, 43, 0.22);
  --bar: #FFFFFF;

  --display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  --jp: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", "Noto Serif CJK JP", "MS Mincho", serif;

  --c-word: #C8321C;     --t-word: #C8321C;
  --c-first: #7A3AA8;    --t-first: #7A3AA8;
  --c-kamakura: #2F55D4; --t-kamakura: #2F55D4;
  --c-ashikaga: #A85A05; --t-ashikaga: #A85A05;
  --c-warring: #B8232F;  --t-warring: #B8232F;
  --c-tokugawa: #0A7F74; --t-tokugawa: #0A7F74;
  --c-end: #1D6FB8;      --t-end: #1D6FB8;
  --c-novel: #B8246B;    --t-novel: #B8246B;
  --c-series: #5B3CC4;   --t-series: #5B3CC4;
  --c-glossary: #3A4A6B; --t-glossary: #3A4A6B;
  --sun: #FFC23D;

  --container: 68rem;
  --measure: 40rem;
  --wide: 52rem;
  --edge: clamp(1rem, 4vw, 2.5rem);
  color-scheme: light;
}

/* Each theme class points --theme at one period's colour. Cards and pager
   links carry their own class, so a card for Kamakura is blue on any page. */
.theme-home, .theme-word { --theme: var(--c-word); --theme-text: var(--t-word); }
.theme-first { --theme: var(--c-first); --theme-text: var(--t-first); }
.theme-kamakura { --theme: var(--c-kamakura); --theme-text: var(--t-kamakura); }
.theme-ashikaga { --theme: var(--c-ashikaga); --theme-text: var(--t-ashikaga); }
.theme-warring { --theme: var(--c-warring); --theme-text: var(--t-warring); }
.theme-tokugawa { --theme: var(--c-tokugawa); --theme-text: var(--t-tokugawa); }
.theme-end { --theme: var(--c-end); --theme-text: var(--t-end); }
.theme-novel { --theme: var(--c-novel); --theme-text: var(--t-novel); }
.theme-series { --theme: var(--c-series); --theme-text: var(--t-series); }
.theme-glossary { --theme: var(--c-glossary); --theme-text: var(--t-glossary); }

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

a {
  color: var(--theme-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--ink); text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--theme-text); outline-offset: 3px; border-radius: 4px; }

:lang(ja) { font-family: var(--jp); font-style: normal; }

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--edge));
  margin: 0 auto;
  padding-left: var(--edge);
  padding-right: var(--edge);
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
}
.skip:focus { top: 1rem; }

/* ---- Site bar ------------------------------------------------------------ */

.site { background: var(--bar); border-bottom: 1px solid var(--border); }
.site-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  background: var(--c-word);
  color: #FFFFFF;
  font-size: 0.8rem;
  line-height: 1;
  letter-spacing: 0;
}
.menu { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.menu a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}
.menu a:hover { background: var(--tint); }
.menu a[aria-current="page"] { background: var(--theme); color: #FFFFFF; }

/* ---- Band ---------------------------------------------------------------- */

.band {
  position: relative;
  overflow: hidden;
  background: var(--theme);
  color: #FFFFFF;
}
/* A rising sun behind the heading, drawn in CSS so no picture is needed. */
.band::before {
  content: "";
  position: absolute;
  right: -6rem;
  top: 50%;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0 45%, rgba(255, 255, 255, 0.08) 46% 60%, transparent 61%);
}
.theme-home .band::before {
  background: radial-gradient(circle, var(--sun) 0 42%, rgba(255, 194, 61, 0.35) 43% 58%, transparent 59%);
}
@media (max-width: 40rem) {
  .band::before { right: -12rem; opacity: 0.6; }
}

.band a { color: #FFFFFF; }
.band a:focus-visible { outline-color: #FFFFFF; }

.intro {
  position: relative;
  max-width: calc(var(--measure) + 2 * var(--edge));
  margin-left: max(0px, calc((100% - var(--container) - 2 * var(--edge)) / 2));
  padding-top: clamp(2.5rem, 8vw, 5rem);
  padding-bottom: clamp(2.5rem, 7vw, 4.5rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}

.name {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(2.75rem, 1.6rem + 5.5vw, 5.25rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
}

.kanji {
  margin: 0 0 1.5rem;
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  letter-spacing: 0.15em;
}
.kanji .reading {
  margin-left: 0.6rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.92);
}

.lead {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.5rem);
  line-height: 1.45;
}

/* One stripe of every period's colour under each band. */
.stripe {
  height: 8px;
  background: linear-gradient(90deg,
    var(--c-first) 0 14%, var(--c-kamakura) 14% 28%, var(--c-ashikaga) 28% 42%,
    var(--c-warring) 42% 56%, var(--c-tokugawa) 56% 70%, var(--c-end) 70% 84%,
    var(--c-novel) 84% 100%);
}

/* ---- Main ---------------------------------------------------------------- */

main.container { padding-top: clamp(2rem, 5vw, 3.5rem); padding-bottom: 1rem; }

.story { max-width: var(--measure); margin: 0 auto; }
.story > section + section { margin-top: clamp(2.5rem, 6vw, 3.5rem); }

h2 {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(1.625rem, 1.4rem + 1vw, 2.125rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  scroll-margin-top: 1rem;
}
.story h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 4px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--theme);
}

.dates {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--theme-text);
}

p { margin: 0 0 1rem; }

.intro-text { font-size: 1.1875rem; }
.note {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: var(--tint);
  font-size: 0.9375rem;
  color: var(--muted);
}

/* ---- Pronunciation ------------------------------------------------------- */
/* A respelling, and a Listen button that pronounce.js shows only when the
   device has a Japanese voice of its own. */

.say {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.5rem;
  vertical-align: baseline;
}
.say-text {
  font-family: var(--body);
  font-size: 0.9375rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}
.listen {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.9rem;
  padding: 0.15rem 0.7rem 0.15rem 0.55rem;
  border: 0;
  border-radius: 999px;
  background: var(--theme);
  color: #FFFFFF;
  font: 600 0.8125rem/1 var(--body);
  letter-spacing: 0;
  cursor: pointer;
}
.listen[hidden] { display: none; }
.listen::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 0.32rem solid transparent;
  border-bottom: 0.32rem solid transparent;
  border-left: 0.5rem solid currentColor;
}
.listen:hover { filter: brightness(1.1); }
.listen:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* In the coloured band the respelling and button sit on the theme colour. */
.band .say-text { color: rgba(255, 255, 255, 0.92); }
.band .listen { background: #FFFFFF; color: var(--theme); }
.kanji .say { margin-left: 0.6rem; }

.glossary dt .say { display: flex; margin-top: 0.15rem; }
.words td:first-of-type { font-size: 1.125rem; }

.rules { padding-left: 1.4rem; }
.rules li + li { margin-top: 0.6rem; }

/* ---- Cards --------------------------------------------------------------- */

.section-wide { max-width: var(--wide); margin: clamp(2.5rem, 6vw, 3.5rem) auto 0; }
.section-wide h2 { text-align: center; }
.section-intro { text-align: center; color: var(--muted); }

.cards {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1rem;
}
@media (min-width: 36rem) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 56rem) {
  .cards:not(.cards-two) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.card a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 1.1rem 1.25rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 6px solid var(--theme);
  border-radius: 14px;
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.card a:hover { transform: translateY(-2px); background: var(--tint); }
.card a:focus-visible { outline: 3px solid var(--theme-text); outline-offset: 2px; }
.card-dates {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--theme-text);
}
.card-title { font-family: var(--display); font-size: 1.5rem; line-height: 1.15; font-weight: 500; }
.card-text { font-size: 0.9375rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .card a { transition: none; }
  .card a:hover { transform: none; }
}

/* ---- Diagrams ------------------------------------------------------------ */

.figure { max-width: var(--wide); margin: 2rem auto; }
.story .figure { margin: 2rem 0; }
@media (min-width: 56rem) {
  .story .figure { margin-left: calc((var(--measure) - var(--wide)) / 2); margin-right: calc((var(--measure) - var(--wide)) / 2); }
}
.figure img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.story .figure.narrow { max-width: 36rem; margin-left: auto; margin-right: auto; }
.figure-strip { margin-top: 0; }
.figure-strip img { box-shadow: none; }
.figure figcaption {
  max-width: var(--measure);
  margin: 0.75rem auto 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- Tables and lists ---------------------------------------------------- */

/* Wide tables scroll inside their own box rather than widening the page. */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; }
.table-wrap .facts { min-width: 34rem; margin: 0; }
.table-wrap .facts-narrow { min-width: 0; }

.facts {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.facts caption {
  text-align: left;
  padding-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts th, .facts td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.facts tbody tr:last-child > * { border-bottom: 0; }
.facts thead th {
  background: var(--theme);
  color: #FFFFFF;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.facts td.num { font-variant-numeric: tabular-nums; }
.facts .row-mark > * { background: var(--tint); font-weight: 600; }
.facts .row-kamakura th { box-shadow: inset 5px 0 var(--c-kamakura); }
.facts .row-ashikaga th { box-shadow: inset 5px 0 var(--c-ashikaga); }
.facts .row-tokugawa th { box-shadow: inset 5px 0 var(--c-tokugawa); }

.facts-list { margin: 0 0 1.5rem; border-top: 3px solid var(--theme); }
.facts-list div,
.glossary div {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.facts-list dt {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--theme-text);
  padding-top: 0.25em;
}
.facts-list dd, .glossary dd { margin: 0; }
.glossary { margin: 0; border-top: 3px solid var(--theme); }
.glossary dt { font-weight: 600; }
.glossary dt span { display: block; font-weight: 400; color: var(--muted); }
@media (max-width: 26rem) {
  .facts-list div, .glossary div { grid-template-columns: minmax(0, 1fr); }
}

.sources { padding-left: 1.25rem; font-size: 0.9375rem; }
.sources li + li { margin-top: 0.35rem; }

/* ---- Reading order ------------------------------------------------------- */

.pager {
  max-width: var(--wide);
  margin: clamp(2.5rem, 6vw, 4rem) auto 0;
  display: grid;
  gap: 1rem;
}
@media (min-width: 36rem) {
  .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.25rem;
  border-radius: 14px;
  background: var(--theme);
  color: #FFFFFF;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.pager-link:hover { color: #FFFFFF; filter: brightness(1.08); }
.pager-link:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.pager-next { text-align: right; }
@media (min-width: 36rem) {
  .pager-next:only-child { grid-column: 2; }
}
.pager-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.92;
}
.pager-title { font-family: var(--display); font-size: 1.375rem; line-height: 1.2; }

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

.foot {
  max-width: 44rem;
  margin: clamp(2.5rem, 6vw, 4rem) auto 0;
  padding-block: 1.75rem 2.5rem;
  border-top: 1px solid var(--border);
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--muted);
}
.foot p { margin: 0; }
.foot-name { font-family: var(--display); font-size: 1.25rem; line-height: 1.3; color: var(--ink); }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.25rem; }
.foot-links a { font-weight: 600; }
.foot-links a[aria-current="page"] { color: var(--ink); text-decoration: none; }
.foot-note { max-width: 34rem; font-size: 0.8125rem; }

/* ---- Privacy notice ------------------------------------------------------ */

.legal h2 { margin-top: 2rem; font-size: 1.375rem; }
.legal h2:first-child { margin-top: 0; }
.legal .meta { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
