/* World page: the explorable map of Tera.
   The site is ink-dark; the map is an antique sepia sheet laid on it, and
   everything that belongs to the map (cards, labels) uses the sheet's inks. */

:root {
  --sheet: #ead5a8;       /* the map's paper */
  --sheet-deep: #dcc28c;  /* paper in shadow */
  --sheet-ink: #33220f;   /* the map's ink */
  --sheet-faded: #6f5a3e; /* faded ink, lore */
  --sheet-rust: #9a4f2a;  /* rubric red */
  --map-face: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --map-caps: 'IM Fell English SC', Georgia, 'Times New Roman', serif;
}

main.atlas-page { max-width: 1440px; }
main.atlas-page > p,
main.atlas-page > .page-title .kicker { max-width: 68ch; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── The map frame ───────────────────────────────────────────────── */
.atlas {
  position: relative;
  aspect-ratio: 806 / 398;
  max-height: 80vh;
  width: 100%;
  overflow: hidden;
  background: var(--sheet);
  border: 1px solid var(--gilt-deep);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(199, 162, 75, 0.08);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  outline: none;
}
.atlas:focus-visible { box-shadow: 0 0 0 2px var(--gilt-bright), 0 18px 50px rgba(0, 0, 0, 0.55); }
.atlas.is-dragging { cursor: grabbing; }

/* Full screen: the native element fullscreen, or (iPhone Safari) a fixed
   layer over the page. */
.atlas:fullscreen,
.atlas.is-full {
  width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  aspect-ratio: auto; border: 0; box-shadow: none;
}
.atlas:-webkit-full-screen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; border: 0; }
.atlas.is-full { position: fixed; inset: 0; z-index: 1000; }
html.atlas-full-lock, html.atlas-full-lock body { overflow: hidden; }
.atlas.is-fullscreen .atlas__tools { top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); }
.atlas.is-fullscreen .atlas__zoom { top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
.atlas__full-off { display: none; }
.atlas.is-fullscreen .atlas__full-on { display: none; }
.atlas.is-fullscreen .atlas__full-off { display: inline; }
.atlas__zoom button svg { width: 18px; height: 18px; vertical-align: middle; }

.atlas__plate {
  position: absolute; left: 0; top: 0;
  width: 806px; height: 398px;
  transform-origin: 0 0;
}
/* The art scales with the plate; the markers live on their own layer in
   screen pixels so names stay sharp at any zoom. */
.atlas__detail {
  position: absolute;
  max-width: none;
  pointer-events: none;
}
/* The Underdark: its art fades in over the surface, and surface details hide. */
.atlas__art--under { opacity: 0; transition: opacity .5s ease; }
.atlas.is-under .atlas__art--under { opacity: 1; }
.atlas__detail--under { opacity: 0; transition: opacity .5s ease; }
.atlas.is-under .atlas__detail--under { opacity: 1; }
.atlas.is-under .atlas__detail--surface { opacity: 0; }
.atlas.is-under { background: #0e0b08; }
.atlas.is-under .mk__label { fill: #e3c072; stroke: #120d08; }
.atlas.is-under .mk.is-ghost { opacity: 0.38; pointer-events: none; }
.atlas.is-under .mk.is-ghost .mk__label { pointer-events: none; }
.atlas.is-under .mk.is-ghost .mk__label { fill: #c7a24b; font-style: italic; }
.atlas__art {
  position: absolute; inset: 0;
  width: 806px; height: 398px;
  max-width: none;
  pointer-events: none;
}
.atlas__marks {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.atlas__marks .mk { pointer-events: auto; }
.atlas__marks .mk.is-hidden { pointer-events: none; }

/* ── Markers ─────────────────────────────────────────────────────── */
.mk { cursor: pointer; }
.mk__hit { fill: transparent; }
.mk__label {
  font-family: var(--map-face);
  fill: var(--sheet-ink);
  paint-order: stroke;
  stroke: var(--sheet);
  stroke-width: 3px;
  stroke-linejoin: round;
  /* The name is part of the marker: hovering it must give the pointer hand,
     not the panning grab. A drag started on it still pans (pointerdown
     bubbles to the atlas; marker clicks are ignored after a move). */
  pointer-events: auto;
}
.mk--town .mk__label { font-style: italic; }
.mk--lore .mk__label { fill: var(--sheet-faded); font-style: italic; }
.mk.is-dim { opacity: 0.28; }
.mk.is-painted .mk__icon { display: none; }
.mk--place .mk__label { font-style: italic; font-size: 12px; }
.mk.is-hidden, .mk__label.is-hidden { display: none; }
.mk:hover .mk__label, .mk.is-selected .mk__label { fill: var(--sheet-rust); }
.mk__ring { fill: none; stroke: var(--sheet-rust); stroke-width: 2; opacity: 0; }
.mk.is-selected .mk__ring, .mk:focus-visible .mk__ring { opacity: 1; }
.mk:focus { outline: none; }

/* ── Tools ───────────────────────────────────────────────────────── */
.atlas__tools {
  position: absolute; left: 12px; top: 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
  max-width: calc(100% - 80px);
}
.atlas__tools input[type="search"],
.atlas__tools select,
.atlas__toggle,
.atlas__zoom button {
  font-family: var(--map-face);
  font-size: 0.95rem;
  color: var(--sheet-ink);
  background: rgba(234, 213, 168, 0.92);
  border: 1px solid rgba(51, 34, 15, 0.55);
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(51, 34, 15, 0.2);
}
.atlas__tools input[type="search"] { width: 12.5rem; padding: 6px 10px; }
.atlas__tools input::placeholder { color: var(--sheet-faded); font-style: italic; }
.atlas__tools select { padding: 6px 8px; }
.atlas__layer {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px; cursor: pointer;
  font-family: var(--map-face); font-size: 0.95rem; color: var(--sheet-ink);
  background: rgba(234, 213, 168, 0.92);
  border: 1px solid rgba(51, 34, 15, 0.55); border-radius: 2px;
  box-shadow: 0 2px 6px rgba(51, 34, 15, 0.2);
}
.atlas__layer-track {
  position: relative; width: 38px; height: 18px; flex: none;
  border-radius: 9px; background: #c9b78f; border: 1px solid rgba(51, 34, 15, 0.6);
  transition: background .3s ease;
}
.atlas__layer-thumb {
  position: absolute; top: 1px; left: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--sheet); border: 1px solid var(--sheet-ink);
  transition: transform .3s ease;
}
.atlas__layer[aria-checked="true"] .atlas__layer-track { background: #2a2018; }
.atlas__layer[aria-checked="true"] .atlas__layer-thumb { transform: translateX(20px); background: #c7a24b; }
.atlas__layer-word { opacity: 0.55; }
.atlas__layer[aria-checked="false"] .atlas__layer-word--surface,
.atlas__layer[aria-checked="true"] .atlas__layer-word--under { opacity: 1; font-style: italic; }
.atlas__layer:focus-visible { outline: 2px solid var(--sheet-rust); outline-offset: 1px; }
.atlas__tools :focus-visible, .atlas__zoom button:focus-visible { outline: 2px solid var(--sheet-rust); outline-offset: 1px; }

.atlas__zoom {
  position: absolute; right: 12px; top: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.atlas__zoom button {
  width: 36px; height: 36px; padding: 0;
  font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.atlas__zoom button:hover { background: var(--sheet); color: var(--sheet-rust); }

.atlas__status {
  position: absolute; left: 12px; bottom: 12px; margin: 0;
  padding: 6px 10px; font-family: var(--map-face);
  color: var(--sheet-ink); background: rgba(234, 213, 168, 0.92);
  border: 1px solid var(--sheet-rust);
}

/* ── The realm card ──────────────────────────────────────────────── */
.atlas__card {
  position: absolute; right: 60px; top: 12px;
  width: min(23rem, calc(100% - 84px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 18px 20px 16px;
  font-family: var(--map-face);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--sheet-ink);
  background: var(--sheet);
  background-image: radial-gradient(120% 90% at 30% 20%, rgba(255, 245, 220, 0.55), transparent 60%),
    radial-gradient(90% 70% at 90% 100%, rgba(150, 105, 50, 0.18), transparent 70%);
  border: 1px solid rgba(51, 34, 15, 0.6);
  outline: 1px solid rgba(51, 34, 15, 0.25);
  outline-offset: -5px;
  box-shadow: 0 10px 30px rgba(20, 12, 4, 0.45);
  cursor: auto;
  user-select: text;
  -webkit-user-select: text;
}
.atlas__card h3 {
  font-family: var(--map-caps);
  font-size: 1.45rem;
  color: var(--sheet-ink);
  margin: 2px 0 6px;
  padding-right: 26px;
  text-wrap: balance;
}
.atlas__card .card__eyebrow {
  margin: 0; font-style: italic; color: var(--sheet-faded); font-size: 0.92rem;
}
.atlas__card .card__levels {
  margin: 0 0 10px;
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline;
}
.atlas__card .card__band {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--map-caps); font-size: 1.05rem;
}
.atlas__card .card__band::before {
  content: ""; width: 10px; height: 10px; transform: rotate(45deg);
  background: var(--band, var(--sheet-faded)); border: 1px solid var(--sheet-ink);
}
.atlas__card .card__meta { color: var(--sheet-faded); font-style: italic; }
.atlas__card .card__about { margin: 6px 0 6px; }
.atlas__card .card__in { font-style: italic; color: var(--sheet-faded); }
.atlas__card h4 {
  font-family: var(--map-caps); font-weight: 400; font-size: 1rem;
  margin: 12px 0 4px; color: var(--sheet-rust); letter-spacing: 0.04em;
}
.atlas__card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.atlas__card li { margin: 0; }
.atlas__card .card__dir { font-style: italic; color: var(--sheet-faded); }
.atlas__card .card__from { display: block; font-size: 0.86rem; color: var(--sheet-faded); padding-left: 1rem; }
.atlas__card button.card__link {
  font: inherit; color: var(--sheet-ink); background: none; border: 0; padding: 0;
  border-bottom: 1px dotted var(--sheet-rust); cursor: pointer; text-align: left;
}
.atlas__card button.card__link:hover { color: var(--sheet-rust); }
.atlas__card button.card__link:focus-visible { outline: 2px solid var(--sheet-rust); outline-offset: 2px; }
.atlas__card .card__note { margin: 8px 0 0; font-style: italic; }
.atlas__card .card__layer {
  margin: 4px 0 2px; padding: 4px 10px;
  font: inherit; font-size: 0.92rem; font-style: italic; cursor: pointer;
  color: #e3c072; background: #2a2018; border: 1px solid #33220f; border-radius: 2px;
}
.atlas__card .card__layer:hover { background: #3a2c20; }
.atlas__card .card__layer:focus-visible { outline: 2px solid var(--sheet-rust); outline-offset: 2px; }
.atlas__card .card__close {
  position: absolute; right: 10px; top: 8px;
  width: 30px; height: 30px; padding: 0;
  font-size: 1.3rem; line-height: 1; color: var(--sheet-ink);
  background: none; border: 0; cursor: pointer;
}
.atlas__card .card__close:hover { color: var(--sheet-rust); }
.atlas__card .card__close:focus-visible { outline: 2px solid var(--sheet-rust); }

/* ── Legend ──────────────────────────────────────────────────────── */
.atlas-legend {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  font-size: 0.92rem; color: var(--muted);
}
.atlas-legend li { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.atlas-legend svg { width: 20px; height: 20px; flex: none; padding: 1px; background: var(--sheet); border-radius: 2px; }
.atlas-legend svg.wide { width: 34px; }

/* ── Realm index ─────────────────────────────────────────────────── */
.realm-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px 36px;
}
.realm-index__region { min-width: 0; }
.realm-index h3 { color: var(--gilt); margin: 1.2rem 0 0.4rem; }
.realm-index ul { list-style: none; margin: 0; padding: 0; }
.realm-index li { margin: 0 0 0.2rem; font-size: 0.98rem; line-height: 1.45; }
.realm-index a { border: 0; }
.realm-index__in { color: var(--muted); font-style: italic; font-size: 0.9rem; }
.realm-index__lv { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.realm-intro { color: var(--muted); }

/* ── Phones ──────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .atlas { aspect-ratio: auto; height: 72vh; max-height: none; }
  .atlas.is-full, .atlas:fullscreen { height: 100vh; height: 100dvh; }
  .atlas__tools { left: 8px; top: 8px; right: 56px; max-width: none; }
  .atlas__tools input[type="search"] { width: 100%; }
  .atlas__search { flex: 1 1 100%; }
  .atlas__zoom { right: 8px; top: 8px; }
  .atlas__card {
    left: 8px; right: 8px; top: auto; bottom: 8px;
    width: auto; max-height: 58%;
  }
}


@media (prefers-reduced-motion: reduce) {
  .atlas__art--under, .atlas__detail--under, .atlas__layer-track, .atlas__layer-thumb { transition: none; }
}
