/* Journey of Avalon world bible: storybook parchment style. Colours come from data/theme.css (palettes.json). */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  color: var(--ink); line-height: 1.55; font-size: 17px;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(255, 250, 238, 0.65), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(201, 160, 102, 0.18), transparent 60%),
    radial-gradient(circle at 50% 50%, transparent 60%, rgba(124, 92, 60, 0.16));
  background-attachment: fixed;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--sea); text-decoration-color: rgba(47, 95, 130, 0.35); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: rgba(124, 92, 60, 0.1); padding: 0 4px; border-radius: 3px; }
h1, h2, h3, h4 { font-variant: small-caps; letter-spacing: 0.04em; line-height: 1.2; margin: 1.2em 0 0.4em; color: var(--ink); }
h1 { font-size: 2.2rem; margin-top: 0.4em; }
h2 { font-size: 1.5rem; border-bottom: 2px solid rgba(90, 70, 54, 0.25); padding-bottom: 4px; }
h3 { font-size: 1.2rem; }

.site-head { display: flex; align-items: center; gap: 18px; padding: 10px 22px; background: rgba(90, 70, 54, 0.92); color: var(--parchment); box-shadow: 0 2px 10px rgba(0,0,0,0.25); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
.brand { color: var(--parchment); text-decoration: none; font-variant: small-caps; font-size: 1.35rem; letter-spacing: 0.06em; white-space: nowrap; }
.brand small { font-size: 0.8rem; opacity: 0.8; margin-left: 6px; letter-spacing: 0.02em; }
.brand-mark { color: var(--gold); }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.site-nav a { color: var(--parchment); text-decoration: none; padding: 5px 11px; border-radius: 4px; font-variant: small-caps; letter-spacing: 0.05em; }
.site-nav a:hover, .site-nav a.active { background: rgba(231, 220, 195, 0.18); color: #fff; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid rgba(231,220,195,0.5); color: var(--parchment); font-size: 1.2rem; border-radius: 4px; padding: 2px 9px; }
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 24px 40px; outline: none; }
main.full { max-width: none; padding: 0; }
.site-foot { text-align: center; font-size: 0.85rem; padding: 14px; color: var(--ink-soft); border-top: 1px solid rgba(90,70,54,0.2); }
#js-errors { position: fixed; bottom: 0; left: 0; right: 0; background: #7a1f1f; color: #fff; white-space: pre-wrap; padding: 8px 14px; z-index: 999; font-family: monospace; }

.badge { display: inline-block; font-family: inherit; font-size: 0.72rem; font-variant: normal; letter-spacing: 0.02em; vertical-align: middle;
  color: #6a3b16; background: rgba(214, 162, 74, 0.28); border: 1px solid rgba(184, 96, 62, 0.55); border-radius: 999px; padding: 1px 9px; margin-left: 8px; white-space: nowrap; }
.badge.inline { margin-left: 6px; }
.lore { background: rgba(255, 252, 244, 0.55); border-left: 4px solid var(--gold); padding: 8px 14px; border-radius: 0 6px 6px 0; font-style: italic; }
.todo { border: 2px dashed rgba(90, 70, 54, 0.35); border-radius: 8px; padding: 6px 16px 10px; margin: 14px 0; background: rgba(255, 255, 255, 0.18); }
.todo h3 { margin: 10px 0 2px; font-size: 1.05rem; }
.todo p { margin: 0 0 6px; color: var(--ink-soft); font-style: italic; }
.muted { color: var(--ink-soft); }
.lead { font-size: 1.15rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin: 14px 0; }
.card { display: block; background: rgba(255, 251, 240, 0.6); border: 1px solid rgba(90, 70, 54, 0.3); border-radius: 10px; padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: 0 2px 0 rgba(90,70,54,0.15); transition: transform 0.12s, box-shadow 0.12s; position: relative; overflow: hidden; }
a.card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(90,70,54,0.2); color: var(--ink); }
.card .swatch-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 7px; }
.card h3 { margin: 0 0 4px 4px; }
.card p { margin: 4px 0 0 4px; font-size: 0.93rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: rgba(255, 251, 240, 0.55); border: 1px solid rgba(90,70,54,0.25); border-radius: 8px; padding: 8px 12px; }
.stat b { display: block; font-size: 1.45rem; color: var(--accent); }
.stat span { font-size: 0.85rem; color: var(--ink-soft); }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; }
.hero img { width: 100%; border-radius: 8px; border: 3px solid rgba(90,70,54,0.45); box-shadow: 0 6px 20px rgba(90,70,54,0.3); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 10px 0; }
.facts dt { font-variant: small-caps; color: var(--ink-soft); }
.facts dd { margin: 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--ink); border-radius: 3px; vertical-align: -2px; margin-right: 6px; }
.bars { margin: 8px 0; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 52px; gap: 10px; align-items: center; font-size: 0.92rem; margin: 3px 0; }
.bar { height: 12px; border-radius: 6px; border: 1px solid rgba(90,70,54,0.45); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 0.93rem; background: rgba(255, 251, 240, 0.45); }
th, td { border: 1px solid rgba(90, 70, 54, 0.25); padding: 5px 9px; text-align: left; vertical-align: top; }
th { background: rgba(90, 70, 54, 0.1); font-variant: small-caps; letter-spacing: 0.03em; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
input[type=search], select { font: inherit; font-size: 0.95rem; padding: 6px 10px; border: 1px solid rgba(90,70,54,0.45); border-radius: 6px; background: rgba(255,252,244,0.85); color: var(--ink); }
.btn { display: inline-block; font: inherit; font-variant: small-caps; letter-spacing: 0.04em; padding: 5px 14px; border-radius: 6px; border: 1px solid var(--ink); background: var(--ink); color: var(--parchment); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.atlas-img { width: 100%; border-radius: 6px; border: 2px solid rgba(90,70,54,0.4); }
.breadcrumb { font-size: 0.9rem; color: var(--ink-soft); margin-top: 6px; }

/* ------------------------------------------------ interactive map */
.map-page { position: relative; height: calc(100vh - 56px); min-height: 480px; display: flex; }
.map-viewport { position: relative; flex: 1; overflow: hidden; background: #3F7FA0; cursor: grab; touch-action: none; user-select: none; }
.map-viewport.dragging { cursor: grabbing; }
.map-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.map-world img { position: absolute; left: 0; top: 0; width: 1024px; height: 1024px; pointer-events: none; }
.map-world img.px { image-rendering: pixelated; }
.map-world svg { position: absolute; left: 0; top: 0; width: 1024px; height: 1024px; overflow: visible; }
.map-world svg .road { fill: none; stroke: #8A3B2A; stroke-width: 2.2; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; opacity: 0.9; }
.map-world svg .river-hit { fill: none; stroke: transparent; stroke-width: 12; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: stroke; }
.map-world svg .river-sel { fill: none; stroke: var(--poppy); stroke-width: 4; vector-effect: non-scaling-stroke; opacity: 0.85; }
.map-world svg .wall { fill: none; stroke: #2B4538; stroke-width: 4; vector-effect: non-scaling-stroke; stroke-dasharray: 2 3; opacity: 0.8; }
.map-world svg .wall-ice { fill: none; stroke: #EEF1F4; stroke-width: 2; vector-effect: non-scaling-stroke; }
.map-overlay { position: absolute; inset: 0; pointer-events: none; }
.mk { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; }
.mk svg { position: absolute; transform: translate(-50%, -50%); filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35)); }
.mk .lbl { position: absolute; left: 10px; top: -9px; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--ink);
  text-shadow: 0 0 3px #F3E9D3, 0 0 3px #F3E9D3, 0 0 2px #F3E9D3; letter-spacing: 0.02em; }
.mk.sel svg { filter: drop-shadow(0 0 4px var(--poppy)) drop-shadow(0 0 2px #fff); }
.lab { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap; transform: translate(-50%, -50%); text-align: center; }
.lab span { display: block; text-shadow: 0 0 4px #F3E9D3, 0 0 3px #F3E9D3, 0 0 2px #F3E9D3; }
.lab.region { font-variant: small-caps; font-weight: 700; letter-spacing: 0.12em; font-size: 19px; color: #3d2f24; }
.lab.region small { font-size: 12px; letter-spacing: 0.05em; font-weight: 600; font-style: italic; color: var(--ink-soft); display: block; }
.lab.sea { font-style: italic; letter-spacing: 0.3em; color: #E9F4F4; font-size: 15px; }
.lab.sea span { text-shadow: 0 0 4px #2F5F82, 0 0 3px #2F5F82; }
.lab.lake, .lab.river { font-style: italic; color: var(--sea); font-size: 12.5px; }
.lab.range { font-variant: small-caps; letter-spacing: 0.15em; color: #4c4651; font-size: 13px; font-weight: 600; }
.lab.isle { font-size: 12.5px; color: var(--ink); font-style: italic; }
.lab.peak { transform: translate(-6px, -50%); text-align: left; font-size: 12px; color: #6B2F2A; font-weight: 600; }
.lab.wall { font-variant: small-caps; letter-spacing: 0.25em; color: #2B4538; font-size: 14px; font-weight: 700; }
.zlow .lab.region { font-size: 15px; letter-spacing: 0.08em; }
.zlow .lab.region small { font-size: 10.5px; }
.lab.hidden, .mk.hidden { display: none; }
.lab.sel span { outline: 2px solid var(--poppy); outline-offset: 2px; border-radius: 4px; }

.map-panel { position: absolute; z-index: 5; background: rgba(240, 228, 205, 0.95); border: 1px solid rgba(90,70,54,0.5); border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.map-layers { left: 12px; top: 12px; width: 230px; max-height: calc(100% - 24px); overflow: auto; padding: 8px 12px; font-size: 0.88rem; }
.map-layers h4 { margin: 8px 0 2px; font-size: 0.95rem; }
.map-layers label { display: flex; align-items: center; gap: 6px; padding: 1px 0; cursor: pointer; }
.map-layers .collapse { float: right; background: none; border: none; font: inherit; cursor: pointer; color: var(--ink-soft); }
.map-layers.closed .layer-list { display: none; }
.map-search { left: 50%; transform: translateX(-50%); top: 12px; width: min(420px, 60%); padding: 6px; }
.map-search input { width: 100%; }
.map-search ul { list-style: none; margin: 4px 0 0; padding: 0; max-height: 300px; overflow: auto; }
.map-search li { padding: 4px 8px; cursor: pointer; border-radius: 4px; font-size: 0.92rem; }
.map-search li:hover, .map-search li.active { background: rgba(90,70,54,0.14); }
.map-search li small { color: var(--ink-soft); margin-left: 6px; }
.map-side { right: 12px; top: 12px; width: 330px; max-height: calc(100% - 24px); overflow: auto; padding: 12px 16px; }
.map-side[hidden] { display: none; }
.map-side h2 { margin: 2px 0 6px; font-size: 1.35rem; border: none; padding: 0; }
.map-side .close { float: right; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--ink-soft); }
.map-side .facts { font-size: 0.92rem; }
.map-status { left: 12px; bottom: 12px; padding: 5px 12px; font-size: 0.85rem; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 24px); }
.scalebar { display: inline-flex; flex-direction: column; font-size: 0.78rem; }
.scalebar i { display: block; height: 7px; border: 2px solid var(--ink); border-top: none; background: repeating-linear-gradient(90deg, var(--ink) 0 25%, transparent 25% 50%); }
.map-zoom { right: 12px; bottom: 12px; display: flex; flex-direction: column; overflow: hidden; }
.map-zoom button { font: inherit; font-size: 1.2rem; width: 38px; height: 34px; border: none; background: transparent; cursor: pointer; color: var(--ink); }
.map-zoom button:hover { background: rgba(90,70,54,0.12); }
.map-zoom button + button { border-top: 1px solid rgba(90,70,54,0.3); }
.compass { position: absolute; right: 64px; bottom: 16px; z-index: 4; font-variant: small-caps; color: #F3E9D3; font-weight: 700; text-shadow: 0 0 3px #2F5F82; pointer-events: none; }

@media (max-width: 860px) {
  body { font-size: 16px; }
  .hero { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .site-nav { display: none; width: 100%; }
  .site-nav.open { display: flex; }
  .map-layers { width: 190px; }
  .map-layers:not(.opened) .layer-list { display: none; }
  .map-search { left: auto; right: 12px; transform: none; width: calc(100% - 230px); }
  .map-side { left: 12px; right: 12px; top: auto; bottom: 52px; width: auto; max-height: 50%; }
  main { padding: 12px 14px 30px; }
}
