/* The Cartographer's Estate — stylesheet */

:root {
  --paper: #f3ece0;
  --paper-shadow: #e8dfd0;
  --paper-deep: #ddd2bf;
  --ink: #2a2520;
  --ink-soft: #4a423a;
  --ink-faded: #6a625a;
  --sepia: #7a4a2a;
  --sepia-faded: #a37c5a;
  --rule: #c9bda8;
  --rule-soft: #d9cfba;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  padding: 0;
  font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
  font-size: 19px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  /* very faint paper grain via layered radial gradients */
  background-image:
    radial-gradient(circle at 20% 30%, rgba(180, 150, 110, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(180, 150, 110, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 60% 15%, rgba(120, 90, 60, 0.03) 0%, transparent 30%);
  min-height: 100vh;
}

/* ---------- Shared ---------- */

a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--sepia-faded);
  transition: color 120ms ease, border-color 120ms ease;
}

a:hover,
a:focus-visible {
  color: var(--sepia);
  border-bottom-color: var(--sepia);
}

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

em, i {
  font-style: italic;
}

::selection {
  background: rgba(122, 74, 42, 0.18);
}

h1, h2, h3 {
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.01em;
}

p {
  margin: 0 0 1.1em 0;
}

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

hr.rule {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3rem 0;
  max-width: 8rem;
}

hr.rule.center {
  margin-left: auto;
  margin-right: auto;
}

.locator {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin: 0 0 1.2rem 0;
  font-style: normal;
}

.subtitle {
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

/* ---------- Hub (index) ---------- */

.hub {
  max-width: 56rem;
  margin: 0 auto;
  padding: 5rem 2rem 6rem;
}

.hub-title {
  text-align: center;
  margin: 0 0 0.4rem;
  font-size: clamp(2rem, 4vw + 1rem, 3rem);
  font-style: italic;
  font-weight: 400;
}

.hub-subtitle {
  text-align: center;
  font-style: italic;
  color: var(--ink-faded);
  margin: 0 0 3rem;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

.hub-intro {
  max-width: 36rem;
  margin: 0 auto 4rem;
  color: var(--ink-soft);
}

.hub-intro p {
  text-indent: 1.4em;
}

.hub-intro p:first-child {
  text-indent: 0;
}

.hub-intro p:first-child::first-letter {
  font-size: 3rem;
  float: left;
  line-height: 0.9;
  padding: 0.1rem 0.4rem 0 0;
  font-style: italic;
  color: var(--sepia);
}

.estate {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.6rem;
  margin: 0 auto;
  max-width: 44rem;
}

.region {
  border-top: 1px solid var(--rule);
  padding-top: 1.2rem;
}

.region-label {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin: 0 0 0.9rem;
}

.region-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.region-items li {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  gap: 0.6rem;
  align-items: baseline;
}

.region-items .position {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  white-space: nowrap;
}

.region-items .leader {
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-0.25em);
  min-width: 1rem;
}

.region-items a {
  border-bottom: none;
  font-size: 1.1rem;
}

.region-items a:hover,
.region-items a:focus-visible {
  font-style: italic;
}

.region-items .gloss {
  display: block;
  font-size: 0.92rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-top: 0.1rem;
  grid-column: 1 / -1;
  padding-left: 0;
}

.hub-tools {
  text-align: center;
  margin: 4rem 0 0;
}

#random-drawer {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.95rem;
  font-style: italic;
  padding: 0.6rem 1.4rem;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
  letter-spacing: 0.02em;
}

#random-drawer:hover,
#random-drawer:focus-visible {
  border-color: var(--sepia);
  color: var(--sepia);
  background: rgba(122, 74, 42, 0.04);
  outline: none;
}

.hub-footer {
  text-align: center;
  margin-top: 5rem;
  color: var(--ink-faded);
  font-size: 0.9rem;
  font-style: italic;
}

.hub-footer a {
  border-bottom: none;
}

/* ---------- Hub ornament ---------- */

.hub-ornament {
  max-width: 22rem;
  margin: 0 auto 2.6rem;
  color: var(--ink-soft);
  opacity: 0.85;
}

.hub-ornament svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Entry page ---------- */

.entry {
  max-width: 42rem;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

.crumbs {
  margin-bottom: 3rem;
  font-size: 0.95rem;
}

.crumbs a {
  color: var(--ink-faded);
  border-bottom: none;
  font-style: italic;
}

.crumbs a:hover {
  color: var(--sepia);
}

.entry-header h1 {
  font-size: clamp(2.1rem, 3vw + 1rem, 2.8rem);
  margin: 0;
  font-weight: 400;
  font-style: italic;
  line-height: 1.1;
}

.entry-header {
  margin-bottom: 2.5rem;
}

.map {
  margin: 2.6rem auto;
  text-align: center;
  max-width: 26rem;
}

.map svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  /* faint paper-tinted background, like a sketch on parchment */
  background: rgba(0,0,0,0.012);
  padding: 0.6rem;
  border-radius: 1px;
}

.map figcaption {
  font-size: 0.85rem;
  color: var(--ink-faded);
  font-style: italic;
  margin-top: 0.8rem;
  letter-spacing: 0.02em;
}

.prose {
  margin-top: 2rem;
}

.prose p + p {
  text-indent: 1.4em;
  margin-top: 0;
}

.marginalia {
  margin: 2.8rem 0 0;
  padding: 1.2rem 1.6rem;
  border-left: 1px solid var(--rule);
  background: linear-gradient(90deg, rgba(122, 74, 42, 0.025), transparent 60%);
  color: var(--ink-soft);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.55;
  position: relative;
}

.marginalia::before {
  content: "—";
  position: absolute;
  left: -1.6rem;
  top: 1.2rem;
  color: var(--rule);
  font-style: normal;
}

.marginalia .annotator {
  display: block;
  margin-top: 0.7rem;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faded);
  font-style: normal;
}

.entry-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-style: italic;
}

.entry-footer p {
  margin: 0.3rem 0;
}

.entry-footer .next-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  font-style: normal;
}

.entry-footer .next-row a {
  border-bottom: none;
  color: var(--ink-faded);
}

.entry-footer .next-row a:hover {
  color: var(--sepia);
}

/* ---------- Colophon ---------- */

.colophon {
  max-width: 38rem;
  margin: 0 auto;
  padding: 5rem 2rem 6rem;
}

.colophon h1 {
  font-style: italic;
  font-weight: 400;
  font-size: 2.2rem;
  margin: 0 0 0.4rem;
}

.colophon .last-note {
  margin: 3rem 0;
  padding: 1.6rem 1.8rem;
  border-left: 1px solid var(--rule);
  background: linear-gradient(90deg, rgba(122, 74, 42, 0.03), transparent 70%);
  font-style: italic;
  color: var(--ink-soft);
}

.colophon .meta {
  margin-top: 3rem;
  font-size: 0.92rem;
  color: var(--ink-faded);
}

.colophon .meta dt {
  float: left;
  width: 10rem;
  font-style: italic;
}

.colophon .meta dd {
  margin: 0 0 0.5rem 10rem;
}

.colophon .meta::after {
  content: "";
  display: table;
  clear: both;
}

/* ---------- SVG map glyphs ---------- */

.map-svg {
  --map-ink: #3a322a;
  --map-faded: #8a7a64;
}

.map-svg .ink {
  stroke: var(--map-ink);
  fill: none;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-svg .faint {
  stroke: var(--map-faded);
  fill: none;
  stroke-width: 0.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-svg .dotted {
  stroke-dasharray: 1.2 2.4;
}

.map-svg .label {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 6px;
  fill: var(--map-ink);
  letter-spacing: 0.04em;
}

.map-svg .small-label {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 4.2px;
  fill: var(--map-faded);
  letter-spacing: 0.06em;
}

.map-svg .fill-soft {
  fill: rgba(122, 74, 42, 0.06);
  stroke: none;
}

.map-svg .ink-fill {
  fill: var(--map-ink);
  stroke: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 540px) {
  body { font-size: 17px; }
  .hub { padding: 3rem 1.4rem 4rem; }
  .entry { padding: 2rem 1.4rem 4rem; }
  .colophon { padding: 3rem 1.4rem 4rem; }
  .region-items li {
    grid-template-columns: 1fr;
  }
  .region-items .position { font-size: 0.78rem; }
  .region-items .leader { display: none; }
  .marginalia { padding: 1rem 1.2rem; margin-left: 0; }
  .marginalia::before { display: none; }
  .colophon .meta dt { float: none; width: auto; }
  .colophon .meta dd { margin-left: 0; margin-bottom: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media (prefers-color-scheme: dark) {
  /* Keeping the parchment aesthetic; only softening luminance for dark UA. */
  /* Intentionally not implementing a full dark mode: this is a paper object. */
}

/* ---------- Language switch (en | ру) ---------- */

html.lang-en [lang="ru"] { display: none; }
html.lang-ru [lang="en"] { display: none; }

.lang-switch {
  position: fixed;
  top: 1.1rem;
  right: 1.4rem;
  z-index: 10;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.06em;
  color: var(--ink-faded);
  background: rgba(243, 236, 224, 0.78);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  padding: 0.25rem 0.55rem;
  border-radius: 1px;
}

.lang-switch button {
  background: none;
  border: 0;
  color: var(--ink-faded);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  transition: color 120ms ease, border-color 120ms ease;
}

.lang-switch button:hover,
.lang-switch button:focus-visible {
  color: var(--sepia);
  outline: none;
}

.lang-switch button[aria-pressed="true"] {
  color: var(--sepia);
  border-bottom: 1px solid var(--sepia-faded);
}

.lang-switch .sep {
  color: var(--rule);
  margin: 0 0.1rem;
  user-select: none;
}

@media (max-width: 540px) {
  .lang-switch {
    top: 0.7rem;
    right: 0.9rem;
    font-size: 0.78rem;
  }
}
