/* Realms of Salt & Iron — parchment editorial */
:root {
  --paper: #efe5cd;
  --paper-deep: #e6d8b8;
  --ink: #3b2f22;
  --ink-soft: #6c5b44;
  --rule: rgba(96, 74, 46, 0.32);
  --accent: #8a3b2a;
  --salt: #f8f3e6;
}

/* dark parchment — same editorial feel, lamplit rather than daylit */
:root[data-theme="dark"] {
  --paper: #241c14;
  --paper-deep: #1a140d;
  --ink: #e9dfc7;
  --ink-soft: #b3a184;
  --rule: rgba(233, 223, 199, 0.16);
  --accent: #d98a5a;
  --salt: #2f2519;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(120% 90% at 30% 20%, rgba(217, 138, 90, 0.10), rgba(0, 0, 0, 0) 60%),
    radial-gradient(100% 100% at 80% 95%, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0) 55%),
    var(--paper);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "EB Garamond", Garamond, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 30% 20%, rgba(255, 250, 235, 0.5), rgba(0, 0, 0, 0) 60%),
    radial-gradient(100% 100% at 80% 95%, rgba(122, 94, 54, 0.10), rgba(0, 0, 0, 0) 55%),
    var(--paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* faint paper grain over everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxODAnIGhlaWdodD0nMTgwJz48ZmlsdGVyIGlkPSduJz48ZmVUdXJidWxlbmNlIHR5cGU9J2ZyYWN0YWxOb2lzZScgYmFzZUZyZXF1ZW5jeT0nMC45JyBudW1PY3RhdmVzPScyJy8+PC9maWx0ZXI+PHJlY3Qgd2lkdGg9JzE4MCcgaGVpZ2h0PScxODAnIGZpbHRlcj0ndXJsKCNuKScvPjwvc3ZnPg==");
}

.smallcaps {
  font-variant: small-caps;
  letter-spacing: 0.14em;
}

/* ============ masthead ============ */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 40px 18px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand:hover .brand-mark { border-color: var(--accent); color: var(--accent); }

.brand-mark {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--rule);
}

.brand h1 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.brand .tagline {
  margin: 4px 0 0;
  font-size: 15px;
  font-style: italic;
  color: var(--ink-soft);
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: 26px;
}

.masthead nav a {
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0 0 2px;
  margin: 0;
  font: inherit;
  text-decoration: none;
  font-size: 15px;
  font-variant: small-caps;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.masthead nav a:hover { color: var(--accent); border-color: var(--accent); }

/* ---- theme toggle: a small switch, not a text link ---- */
.theme-toggle {
  --track-w: 40px;
  --track-h: 22px;
  --thumb: 16px;
  flex: none;
  width: var(--track-w);
  height: var(--track-h);
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper-deep);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.theme-toggle:hover { border-color: var(--accent); }

.theme-toggle-thumb {
  display: block;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: var(--ink-soft);
  transform: translateX(0);
  transition: transform 0.25s ease, background 0.2s;
}

.theme-toggle[aria-checked="true"] {
  background: var(--ink);
  border-color: var(--ink);
}

.theme-toggle[aria-checked="true"] .theme-toggle-thumb {
  background: var(--accent);
  transform: translateX(calc(var(--track-w) - var(--thumb) - 8px));
}

/* ============ layout ============ */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 2fr 1fr;
  min-height: 0;
}

/* ---- globe pane (left two-thirds) ---- */
.globe-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#globeHost {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: pan-y;
}

#globeHost.grabbing { cursor: grabbing; }

#globeHost canvas { display: block; }

#globeShadow {
  position: absolute;
  left: 50%;
  top: 51.5%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 52, 26, 0.30) 38%, rgba(74, 52, 26, 0.10) 52%, rgba(0, 0, 0, 0) 68%);
  pointer-events: none;
  z-index: 0;
}

#globeHost, #markers { z-index: 1; }

#markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: opacity 0.25s;
  will-change: transform;
}

/* generous invisible hit target centred on the dot */
.marker::before {
  content: "";
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.marker-dot {
  position: absolute;
  left: -5.5px;
  top: -5.5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--salt);
  box-shadow: 0 0 0 1.5px var(--accent), 0 1px 4px rgba(59, 47, 34, 0.4);
  transition: transform 0.2s;
}

.marker-label {
  position: absolute;
  left: 14px;
  top: 0;
  transform: translateY(-50%);
  font-size: 16px;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-shadow:
    0 0 6px var(--paper), 0 0 6px var(--paper),
    0 0 2px var(--paper), 0 0 2px var(--paper);
}

.marker:hover .marker-dot { transform: scale(1.35); }
.marker:hover .marker-label { color: var(--accent); }

.marker.active .marker-dot {
  background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 6px rgba(138, 59, 42, 0.22);
}

.marker.active .marker-label { color: var(--accent); font-weight: 600; }

.globe-caption {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-soft);
  pointer-events: none;
  white-space: nowrap;
}

#globeLoading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
  font-variant: small-caps;
  letter-spacing: 0.22em;
  font-size: 15px;
  color: var(--ink-soft);
  background: transparent;
  transition: opacity 0.6s;
}

#globeLoading.gone { opacity: 0; pointer-events: none; }

#compassRose {
  position: absolute;
  right: 28px;
  bottom: 22px;
  z-index: 2;
  width: 150px;
  height: 165px;
  opacity: 0.85;
  pointer-events: none;
}

/* ---- reading pane (right third) ---- */
.reading-pane {
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(255, 250, 235, 0.35), rgba(0, 0, 0, 0) 30%);
}

.pane-head {
  padding: 26px 30px 18px;
  border-bottom: 1px solid var(--rule);
}

.pane-kicker {
  margin: 0 0 10px;
  font-size: 13px;
  font-variant: small-caps;
  letter-spacing: 0.22em;
  color: var(--accent);
}

#paneTitle {
  margin: 0;
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 600;
  line-height: 1.08;
}

#paneSub {
  margin: 6px 0 0;
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink-soft);
}

#cityChips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  font-family: inherit;
  font-size: 13.5px;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 5px 13px;
  cursor: pointer;
  transition: all 0.18s;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--salt);
}

#articleList {
  list-style: none;
  margin: 0;
  padding: 8px 30px 40px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.dispatch { border-bottom: 1px solid var(--rule); }

.dispatch:last-child { border-bottom: 0; }

.dispatch-link {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 20px 2px;
  text-decoration: none;
  color: inherit;
}

.dispatch-tags {
  font-size: 12.5px;
  font-variant: small-caps;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.dispatch-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.18;
  text-wrap: pretty;
  transition: color 0.18s;
}

.dispatch-link:hover .dispatch-title {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.dispatch-excerpt {
  font-size: 15.5px;
  line-height: 1.42;
  color: var(--ink-soft);
  font-style: italic;
  text-wrap: pretty;
}

.dispatch-meta {
  font-size: 13px;
  font-variant: small-caps;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ============ about overlay ============ */
#aboutOverlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(59, 47, 34, 0.42);
  backdrop-filter: blur(3px);
}

#aboutOverlay[hidden] { display: none; }

.about-card {
  max-width: 560px;
  background: var(--salt);
  border: 1px solid var(--rule);
  box-shadow: 0 24px 60px rgba(40, 28, 12, 0.35);
  padding: 44px 48px 40px;
  position: relative;
  outline: none;
}

.about-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--rule);
  pointer-events: none;
}

.about-card h2 {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 600;
}

.about-kicker {
  margin: 0 0 18px;
  font-size: 13px;
  font-variant: small-caps;
  letter-spacing: 0.22em;
  color: var(--accent);
}

.about-card p {
  margin: 0 0 14px;
  font-size: 16.5px;
  line-height: 1.55;
  text-wrap: pretty;
}

.about-card p:last-of-type { margin-bottom: 0; }

#aboutClose {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  font-size: 22px;
  font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
}

#aboutClose:hover { color: var(--accent); }

/* ============ mobile ============ */
@media (max-width: 920px) {
  body { overflow: auto; }

  .masthead { padding: 20px 22px 14px; }

  .brand { gap: 13px; }
  .brand-mark { width: 44px; height: 44px; font-size: 16px; }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: min(58vh, 480px) auto;
  }

  .globe-pane { min-height: min(58vh, 480px); }

  .reading-pane {
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  #articleList { overflow-y: visible; }

  .marker-label { font-size: 14px; }

  #compassRose { width: 96px; height: 106px; right: 14px; bottom: 14px; }

  .globe-caption { font-size: 12px; bottom: 10px; }
}
