/* OFOM-inspired layout: warm paper, black text and restrained red accents. */

:root {
  color-scheme: light;
  --paper: #faf9f6;
  --ink: #141414;
  --red: #a82126;
  --line: #c9c4bd;
  --soft: #f0ede7;
  --highlight: #f4d8d6;
  --nav-height: 68px;
  font-family: Arial,"DejaVu Sans",sans-serif;
  line-height: 1.65;
  font-size: 17px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--nav-height) + 18px);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

[hidden] {
  display: none!important;
}

a,a:visited,a:active {
  color: #000;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: .18em;
}

a:focus-visible,button:focus-visible,select:focus-visible,input:focus-visible,textarea:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

button,input,select,textarea {
  font: inherit;
  color: #000;
}

button,select {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: .4rem .65rem;
  cursor: pointer;
}

button:hover,select:hover {
  background: var(--soft);
}

button:disabled {
  opacity: .55;
  cursor: default;
}

input[type=text],textarea {
  border: 1px solid var(--line);
  padding: .5rem;
  background: #fff;
  border-radius: 3px;
  min-width: 0;
}

textarea {
  width: 100%;
  margin-top: .7rem;
  resize: vertical;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  padding: .5rem;
  background: #fff;
  z-index: 100;
}

.skip-link:focus {
  top: .5rem;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 2px solid var(--red);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem 1.2rem;
  max-width: 1450px;
  margin: auto;
  padding: .65rem clamp(1rem,3vw,2.4rem);
  flex-wrap: wrap;
  font-size: .86rem;
}

.site-links,.nav-controls {
  display: flex;
  align-items: center;
  gap: .65rem 1.3rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -.03em;
}

.nav-controls {
  gap: .5rem;
}

.language-label {
  font-size: .8rem;
  color: #48423d;
}

.chapters-nav {
  max-width: 1450px;
  margin: auto;
  padding: .45rem clamp(1rem,3vw,2.4rem) .75rem;
  display: flex;
  gap: .45rem 1rem;
  flex-wrap: wrap;
  font-size: .83rem;
  border-top: 1px solid var(--line);
}

.language-status {
  font-size: .85rem;
  margin: 0;
  padding: .3rem 1rem;
  text-align: center;
  background: var(--soft);
}

main {
  max-width: 1450px;
  width: 94%;
  margin: auto;
  padding: 0 1.2rem 2rem;
}

.hero {
  text-align: center;
  padding: clamp(2rem,4vw,3.8rem) 0 1.8rem;
  border-bottom: 1px solid var(--line);
}

h1,h2,h3 {
  line-height: 1.3;
  color: #171717;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.7rem,3vw,2.65rem);
  margin: 0 auto .65rem;
  max-width: 1100px;
  letter-spacing: -.035em;
}

.description {
  font-size: clamp(1.03rem,1.7vw,1.3rem);
  max-width: 980px;
  margin: .35rem auto 1.15rem;
  text-wrap: pretty;
}

.chapter {
  padding: 1.65rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
}

.chapter h2 {
  text-align: center;
  font-size: clamp(1.28rem,2.1vw,1.85rem);
  margin: .2rem auto 1.5rem;
  max-width: 1100px;
}

.chapter h3 {
  font-size: 1.15rem;
  margin: 1.6rem 0 .7rem;
}

.chapter p {
  margin: 0 0 1rem;
  text-align: justify;
  hyphens: auto;
}

.chapter p:last-child {
  margin-bottom: 0;
}

/* Article links only: retain black text and keyboard focus; reverse underline on hover. */

article a {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .18em;
}

article a:hover {
  text-decoration: none;
}

article ul,article ol {
  margin: .5rem 0 1.25rem;
  padding-left: 1.6rem;
}

article li {
  margin: .3rem 0;
}

.theory-note {
  font-style: italic;
  background: var(--soft);
  border-left: 3px solid var(--red);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  line-height: 1.65;
}

.theory-note p {
  margin: 0;
  text-align: justify;
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
  margin: 1rem 0 1.5rem;
  overscroll-behavior-inline: contain;
}

.table-scroll:focus {
  outline: none;
}

.table-scroll:focus-visible thead th {
  box-shadow: inset 0 3px var(--red);
}

table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  font-size: .94rem;
}

th,td {
  border-bottom: 1px solid var(--line);
  padding: .7rem .8rem;
  text-align: left;
  vertical-align: middle;
}

thead th {
  background: var(--soft);
  font-weight: 700;
  border-top: 2px solid var(--red);
  border-bottom: 1px solid #8a8078;
  line-height: 1.35;
}

tbody tr:nth-child(even) {
  background: #f8f6f2;
}

tbody tr:hover {
  background: var(--highlight);
}

.class-table {
  min-width: 590px;
}

.class-table th:first-child,.class-table td:first-child {
  width: 28%;
}

.ranking-table {
  min-width: 970px;
  font-size: .88rem;
}

.ranking-table th:not(:first-child),.ranking-table td {
  text-align: center;
}

.ranking-table td {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ranking-table tbody th {
  font-weight: 600;
  white-space: nowrap;
}

.ranking-table tbody tr:hover {
  background: var(--highlight);
}

.ranking-table tr.country-highlight {
  background: var(--highlight);
  font-weight: 700;
}

.ranking-table tr.country-highlight th {
  box-shadow: inset 4px 0 var(--red);
}

.ranking-table caption {
  caption-side: bottom;
  padding: 1.15rem .5rem .3rem;
  font-weight: 700;
  line-height: 1.5;
  background: var(--paper);
}

.chapter .table-heading {
  text-align: center;
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.6;
}

.chapter .historical-note {
  text-align: center;
  font-size: .83rem;
  color: #514b45;
}

.maps {
  display: grid;
  justify-items: center;
  gap: 2.1rem;
  padding: 2.1rem 0;
}

.maps figure {
  width: 100%;
  margin: 0;
  text-align: center;
}

.maps img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%,680px);
  max-height: 520px;
  margin: auto;
  object-fit: contain;
}

.maps figcaption {
  font-weight: 700;
  margin: 1rem 0 0;
}

.sources ul {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 1000px;
}

.sources li {
  padding: .62rem .25rem;
  border-bottom: 1px solid var(--line);
}

.sources li:last-child {
  border-bottom: 0;
}

.share {
  max-width: 720px;
  margin: auto;
  font-size: .84rem;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  margin: .75rem 0;
}

.share-actions button {
  font-size: .78rem;
  font-weight: 700;
}

#fediverse-panel {
  text-align: left;
  padding: 1rem;
  background: var(--soft);
  border: 1px solid var(--line);
  margin-top: .8rem;
}

#fediverse-panel p {
  margin: .35rem 0 .8rem;
}

#fediverse-panel a:hover {
  text-decoration: underline;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .45rem 0;
}

.form-row input {
  flex: 1 1 210px;
}

.remember {
  display: block;
  font-size: .83rem;
}

.share-status {
  font-size: .85rem;
}

.footer-logo img {
  display: block;
  width: min(240px,85vw);
  max-width: 100%;
  height: auto;
  margin: 0 auto 1rem;
}

footer {
  background: #fff;
  text-align: center;
  border-top: 2px solid var(--red);
  padding: 1.8rem 1rem;
  font-size: .9rem;
}

.noscript {
  text-align: center;
  padding: 1rem;
}

.copy-offscreen {
  position: fixed;
  left: -10000px;
  top: 0;
  opacity: 0;
}

@media(max-width:700px) {
  :root {
    font-size: 16px;
    --nav-height: 125px;
  }
  main {
    width: 100%;
    padding: 0 1rem 1.4rem;
  }
  .site-nav {
    gap: .5rem;
    padding: .5rem .8rem;
  }
  .site-links {
    gap: .35rem .85rem;
  }
  .nav-controls {
    width: 100%;
    justify-content: space-between;
  }
  .language-label {
    margin-right: auto;
  }
  .chapters-nav {
    max-height: 40vh;
    overflow: auto;
  }
  .chapter p,.theory-note p {
    text-align: left;
    hyphens: manual;
  }
  .chapter {
    padding: 1.3rem 0;
  }
  .hero {
    padding: 1.8rem 0 1.35rem;
  }
  .chapter h2 {
    margin-bottom: 1.1rem;
  }
  .maps {
    gap: 1.3rem;
  }
}

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

@media print {
  .sticky,.share,.skip-link,footer a[href="#top"] {
    display: none!important;
  }
  main {
    width: 100%;
    max-width: none;
    padding: 0;
  }
  body {
    background: #fff;
    font-size: 11pt;
  }
  .chapter {
    break-inside: auto;
  }
  .hero {
    padding: .5rem 0;
  }
  .table-scroll {
    overflow: visible;
  }
  .ranking-table,.class-table {
    min-width: 0;
    font-size: 8pt;
  }
  th,td {
    padding: 3pt;
  }
  .maps img {
    max-height: 15cm;
  }
  tr,figure {
    break-inside: avoid;
  }
  a {
    text-decoration: none!important;
  }
}

/* Semantic row headers retain the original table typography. */

.class-table tbody th[scope="row"] {
  font-weight: 400;
}
