/* ================================================
   REALMS OF CINDER — site styles
   Warm, bookish dark theme. No glass, no glow.
   ================================================ */
:root {
  --bg:         #16120c;
  --bg-alt:     #1c1710;
  --panel:      #221c13;
  --ink:        #e9e1cf;
  --foreground: #e9e1cf;
  --muted:      #9d9179;
  --accent:     #c8a35c;
  --accent-dim: #8c743f;
  --accent-fg:  #191307;
  --border:     #3a3222;
  --border-soft:#2b2418;
  --link:       #d9b871;
  --font-display: 'Cinzel', 'Times New Roman', serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --radius: 3px;
  --transition: 150ms ease;
  font-family: var(--font-body);
}

/* ================================================ RESET & BASE */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  font-size: 15px;
}

/* ================================================ TYPOGRAPHY */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
  margin-top: 0;
  font-weight: 600;
}
p, ul, ol { margin-top: 0; }
.muted { color: var(--muted); }
a { color: var(--link); }

/* Ornamental divider used under headings */
.ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent-dim);
  margin: 10px 0 26px;
}
.ornament::before, .ornament::after {
  content: '';
  height: 1px;
  width: 64px;
  background: var(--border);
}
.ornament span { font-size: 11px; letter-spacing: 0.2em; }
.ornament.center { justify-content: center; }

/* ================================================ NAVIGATION */
.nav-wrap {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(22, 18, 12, 0.97);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: 1160px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
}
.logo { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.logo-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.06em;
  line-height: 1;
}
.logo-text {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0.08em;
}
.main-nav { display: flex; gap: 2px; align-items: center; }
.nav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-bottom: 2px solid transparent;
  transition: color var(--transition);
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-item:focus-visible { color: var(--accent); outline: none; }
.nav-item.cta {
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 7px 14px;
  margin-left: 8px;
}
.nav-item.cta:hover { background: var(--accent); color: var(--accent-fg); }

/* ================================================ HERO */
.hero {
  position: relative;
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.hero-bg {
  position: absolute;
  inset: 0;
  background-image: url('https://i.imgur.com/0Kp2oji.png');
  background-size: cover;
  background-position: center;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(22,18,12,0.55) 0%, rgba(22,18,12,0.35) 45%, var(--bg) 100%);
}
.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 780px;
  padding: 90px 24px;
}
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 18px;
  font-family: var(--font-body);
}
.headline {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-shadow: 0 2px 24px rgba(0,0,0,0.6);
}
.subhead {
  color: var(--ink);
  opacity: 0.85;
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 34px; }

/* ================================================ BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 26px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.05em;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
  font-family: var(--font-body);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: #d9b871; color: var(--accent-fg); }
.btn-outline, .btn.outline {
  border-color: var(--accent-dim);
  color: var(--accent);
}
.btn-outline:hover, .btn.outline:hover { background: rgba(200,163,92,0.1); }
.btn-giant { padding: 13px 32px; font-size: 15px; }

/* ================================================ SECTIONS */
.section { padding: 72px 24px; }
.section + .section { border-top: 1px solid var(--border-soft); }
.container { max-width: 1060px; margin: 0 auto; }
.section-title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  letter-spacing: 0.04em;
}
.section-lead {
  color: var(--muted);
  margin: 0 0 30px;
  font-size: 15px;
  max-width: 620px;
}

/* ================================================ ABOUT LIST (replaces feature cards) */
.about-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 56px;
  margin-top: 8px;
}
.about-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-soft);
}
.about-item h4 {
  font-size: 15px;
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.about-item p { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.6; }
.about-list.cols-3 { grid-template-columns: repeat(3, 1fr); gap: 0 40px; }

/* Callout strip (e.g. the one-mod note on the homepage) */
.mod-note {
  margin-top: 34px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-alt);
  padding: 14px 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}
.mod-note strong { color: var(--accent); }

/* ================================================ NATION ROWS */
.nation-rows { border-top: 1px solid var(--border); margin-top: 8px; }
.nation-row {
  display: grid;
  grid-template-columns: 18px 170px 1fr;
  gap: 20px;
  align-items: baseline;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.nation-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
  align-self: center;
}
.nation-row h4 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.05em;
}
.nation-row .nation-detail { color: var(--muted); font-size: 14px; }
.nation-row .nation-detail strong { color: var(--ink); font-weight: 600; }

/* ================================================ FINAL CTA */
.final-cta { text-align: center; }
.final-title {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  margin: 0 0 10px;
  letter-spacing: 0.03em;
}
.final-lead { color: var(--muted); margin: 0; font-size: 15px; }
.cta-row { display: flex; gap: 14px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }

/* ================================================ FOOTER */
.site-footer {
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--muted);
  font-size: 13.5px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  max-width: 1060px;
  margin: 0 auto;
}
.footer-links { list-style: none; padding: 0; margin: 10px 0 0; }
.footer-links li { margin-bottom: 6px; }
.footer-links a { color: var(--muted); text-decoration: none; transition: color var(--transition); }
.footer-links a:hover { color: var(--accent); }
.site-footer strong,
.site-footer .logo { color: var(--ink); font-size: 14px; font-family: var(--font-display); letter-spacing: 0.05em; }

/* ================================================ MAP PAGE */
.map-page main { display: flex; flex-direction: column; }

.map-topbar {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.map-title h1 { font-size: 24px; margin: 0; letter-spacing: 0.05em; }
.map-title p  { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.map-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.legend-item { display: flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--muted); }
.legend-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.55);
}

.map-actions { display: flex; gap: 10px; align-items: center; }
.map-actions select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  cursor: pointer;
}
.map-actions select:focus { outline: none; border-color: var(--accent-dim); }
.map-actions .btn { padding: 8px 16px; font-size: 13.5px; }

/* The stage: map fills it, panels float on top */
.map-stage-wrap {
  position: relative;
  max-width: 1400px;
  width: calc(100% - 48px);
  margin: 0 auto 28px;
}
.map-stage {
  position: relative;
  height: calc(100vh - 200px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #100d08;
  overflow: hidden;
}
.svg-container { position: absolute; inset: 0; }
.svg-container svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.svg-container svg:active { cursor: grabbing; }
.svg-container svg.placing, .svg-container svg.placing:active { cursor: crosshair; }

/* Zoom controls */
.map-zoom {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
.map-zoom button {
  width: 34px; height: 34px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.map-zoom button:hover { border-color: var(--accent-dim); color: var(--accent); }

/* Info panel floats over the map */
.info-panel {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 270px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  z-index: 5;
  background: rgba(28, 23, 16, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.info-panel h2 {
  font-size: 17px;
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 8px;
}
.info-panel p { font-size: 13.5px; color: var(--muted); margin: 8px 0 0; }
.info-faction { display: inline-flex; align-items: center; gap: 7px; }

/* Map province shapes */
.map-path { cursor: pointer; }
.map-path.selected {
  stroke: var(--accent) !important;
  stroke-width: 3;
}

/* Place-marker toggle button active state */
#place-town-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* ── Editor-only controls (map.html?editor) ─────
   Placing, exporting, and resetting markers is only
   available in editor mode; visitors never see these. */
#place-town-btn, #export-towns-btn, #reset-towns-btn { display: none; }
body.is-editor #place-town-btn,
body.is-editor #export-towns-btn,
body.is-editor #reset-towns-btn { display: inline-flex; }

/* ── Map view modes ─────────────────────────────
   Settlement markers + placement only in Settlements view;
   relations legend only in Diplomacy view. */
body[data-map-mode="territory"] #place-town-btn,
body[data-map-mode="diplomacy"] #place-town-btn { display: none; }
body[data-map-mode="territory"] #town-layer,
body[data-map-mode="diplomacy"] #town-layer { display: none; }
body[data-map-mode="diplomacy"] .legend-factions { display: none; }
body[data-map-mode="territory"] .legend-relations,
body[data-map-mode="settlements"] .legend-relations { display: none; }

/* ── Settlement screenshots ─────────────────────── */
.town-shots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.shot-thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.shot-thumb img {
  display: block;
  width: 100%;
  height: 72px;
  object-fit: cover;
  cursor: zoom-in;
}
.shot-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(22,18,12,0.85);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.shot-del:hover { color: #d67c72; }
.shot-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10,8,5,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.shot-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ================================================ MODAL */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  visibility: hidden;
  opacity: 0;
  transition: opacity 180ms ease, visibility 180ms ease;
}
.modal[aria-hidden="false"], .modal.open { visibility: visible; opacity: 1; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 5, 0.8);
}
.modal-content {
  position: relative;
  z-index: 10;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 28px;
  border-radius: var(--radius);
  min-width: 340px;
  max-width: 520px;
  width: 90%;
}
.modal-content h3 { margin: 0 0 8px; font-size: 20px; letter-spacing: 0.04em; }
.modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); }
.server-block { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.server-block code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.05em;
  flex: 1;
}
.server-block .btn { padding: 10px 16px; }

/* ================================================ MARKER PLACEMENT FORM */
.town-placement-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 248px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.tpf-title {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: 0.05em;
}
.tpf-input, .tpf-textarea {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  margin-bottom: 8px;
  resize: none;
}
.tpf-input:focus, .tpf-textarea:focus { outline: none; border-color: var(--accent-dim); }
.tpf-textarea { min-height: 52px; }
.tpf-type-row { display: flex; gap: 4px; margin-bottom: 10px; }
.tpf-type-btn {
  flex: 1;
  padding: 5px 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
}
.tpf-type-btn:hover { border-color: var(--accent-dim); color: var(--ink); }
.tpf-type-btn.active {
  background: rgba(200,163,92,0.14);
  border-color: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.tpf-actions { display: flex; gap: 8px; margin-top: 4px; }
.tpf-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  font-weight: 500;
}
.tpf-btn:hover { border-color: var(--accent-dim); }
.tpf-btn-primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.tpf-btn-primary:hover { background: #d9b871; }

.tpf-action-btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-family: var(--font-body);
  cursor: pointer;
  font-weight: 500;
}
.tpf-action-btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.tpf-delete-btn { color: #d67c72; border-color: rgba(214,124,114,0.3); }
.tpf-delete-btn:hover { border-color: #d67c72; color: #d67c72; }

/* ================================================ RESPONSIVE */
@media (max-width: 900px) {
  .about-list, .about-list.cols-3 { grid-template-columns: 1fr; }
  .nation-row { grid-template-columns: 18px 1fr; }
  .nation-row .nation-detail { grid-column: 2; }
  .info-panel {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 12px;
    border-radius: var(--radius);
  }
  .map-stage { height: 62vh; min-height: 380px; margin-bottom: 0; }
  .map-stage-wrap { padding-bottom: 28px; }
}
@media (max-width: 720px) {
  .section { padding: 56px 20px; }
  .hero-content { padding: 70px 20px; }
  .main-nav { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .map-stage { width: calc(100% - 32px); }
}
