/* Hearth world map. Chrome uses theme variables; the painted map is canvas ink. */
@font-face {
  font-family: "Hearth Atlas";
  src: url("../../../fonts/im-fell-english-sc-normal-latin.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

.hw-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--page, #101012);
  color: var(--ink, #f3e6c8);
  font-family: var(--sans, Roboto, system-ui, sans-serif);
  padding-top: var(--hearth-safe-top, env(safe-area-inset-top, 0px));
  padding-right: var(--hearth-safe-right, env(safe-area-inset-right, 0px));
  padding-bottom: var(--hearth-safe-bottom, env(safe-area-inset-bottom, 0px));
  padding-left: var(--hearth-safe-left, env(safe-area-inset-left, 0px));
}
.hw-root[hidden] { display: none !important; }
body.hw-open { overflow: hidden; }

.hw-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 10px;
  background:
    linear-gradient(90deg, rgba(255, 217, 147, 0.03), transparent 22%, rgba(0, 0, 0, 0.18)),
    var(--tex, none), var(--card-surface, #18181b);
  border-bottom: 1px solid var(--rim, rgba(201, 163, 106, 0.5));
  box-shadow: 0 3px 14px rgba(13,13,15, 0.28);
}
.hw-title { flex: 1; min-width: 0; }
.hw-title b {
  display: block;
  font: 400 19px/1.15 "Hearth Atlas", "Iowan Old Style", "Palatino Linotype", var(--serif, Georgia, serif);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hw-title small { display: block; color: var(--ink-faded, #c9a771); font-size: 12px; }

.hw-btn {
  appearance: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--rim-strong, var(--gold-deep, #a08050));
  background:
    linear-gradient(180deg, rgba(255, 226, 170, 0.06), rgba(0, 0, 0, 0.14)),
    var(--card-surface, #1c1c20);
  color: var(--ink, #f4e6cc);
  font: 600 14px/1.2 var(--sans, Roboto, system-ui, sans-serif);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 158, 0.035), 0 2px 5px rgba(9,9,10, 0.16);
}
.hw-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
/* Fixed brass and ink. Theme gold runs from near-black to near-white, so a
   theme text colour cannot clear 4.5:1 on every fill. This pair is the same
   in all 25 palettes: #1a120c on #d7b56a is about 8.6:1. */
.hw-root .hw-btn.hw-primary {
  background: #d7b56a;
  color: #1a120c;
  -webkit-text-fill-color: #1a120c;
  border-color: #46464e;
}
.hw-btn.hw-quiet { background: transparent; }
.hw-btn.hw-on { box-shadow: inset 0 0 0 2px var(--gold, #d7b072), 0 2px 7px rgba(9,9,10, 0.22); }
.hw-btn:focus-visible { outline: 2px solid var(--gold, #d7b072); outline-offset: 2px; }
.hw-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.24); }
.hw-btn:disabled { opacity: 0.45; cursor: default; }
.hw-btn.hw-block { width: 100%; }

.hw-body { flex: 1; min-height: 0; display: flex; position: relative; }
.hw-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: radial-gradient(circle at 45% 38%, #ead9b7, #c7a875 88%);
}
.hw-stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.hw-tokens { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.hw-token {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: grab;
  color: inherit;
}
.hw-token:focus-visible { outline: 2px solid #d7b56a; outline-offset: 2px; }
.hw-token.hw-sel { outline: 2px dashed #f3e6c8; outline-offset: 1px; }
.hw-token.hw-secret { opacity: 0.45; }
.hw-token:active { cursor: grabbing; }
.hw-sheet {
  position: absolute; inset: 0; overflow: auto; padding: 16px; box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  /* The stage under this sheet is parchment (#ead9b7 falling to #c7a875).
     Theme --ink is a light vellum colour, so body copy has to be dark ink here. */
  --parch-ink: #2a2118;
  color: #2a2118;
}
.hw-sheet .hw-lead,
.hw-sheet .hw-help,
.hw-sheet .hw-label { color: #2a2118; }
.hw-sheet .hw-card { color: var(--ink, #f3e6c8); }
.hw-root.hw-map .hw-sheet { display: none; }
.hw-root:not(.hw-map) .hw-stage canvas { display: none; }

.hw-side {
  display: none;
  box-sizing: border-box;
  overflow: auto;
  background: var(--tex-parch, none), var(--parch, var(--card-surface, #efe2c4));
  --parch-ink: #2a2118;
  color: #2a2118;
  border-top: 1px solid var(--rim, rgba(56,56,64, 0.35));
  padding: 12px;
  z-index: 2;
}
.hw-root.hw-panel .hw-side {
  display: block;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 52%;
}
.hw-side .hw-btn { color: var(--parch-ink, #2a2118); background: transparent; }
.hw-side .hw-btn.hw-primary { background: #d7b56a; color: #1a120c; -webkit-text-fill-color: #1a120c; border-color: #c9993f; }
.hw-label {
  display: block;
  margin: 10px 0 4px;
  font: 700 11px/1.2 var(--sans, Roboto, sans-serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2a2118;
}
/* Beats html[data-theme="dark"] input, which would paint light theme ink
   onto these fields. The library and create screens sit on parchment. */
.hw-root :is(.hw-field, .hw-side select, .hw-side input[type="text"], .hw-side input[type="number"], .hw-side textarea, .hw-sheet input[type="text"], .hw-sheet input[type="number"], .hw-sheet select, .hw-sheet textarea, .hw-sheet input[type="range"]) {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #1f1f23 25%, transparent);
  background: #f6edd6;
  color: #2a2118;
  font: 16px/1.3 var(--sans, Roboto, sans-serif);
  padding: 8px 10px;
}
.hw-side textarea { min-height: 88px; resize: vertical; }
.hw-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hw-row .hw-btn { flex: 1 1 auto; }
.hw-help { font: 13px/1.45 var(--serif, Georgia, serif); margin: 0 0 12px; }
.hw-readout {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--parch-ink, #1f1f23) 8%, transparent);
  font: 14px/1.4 var(--serif, Georgia, serif);
}
.hw-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.hw-swatch {
  width: 44px; height: 44px; min-width: 44px; padding: 0;
  border-radius: 8px; border: 2px solid transparent; cursor: pointer;
}
.hw-swatch.hw-on { border-color: var(--parch-ink, #1f1f23); }
.hw-check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; }
.hw-check input { width: 22px; height: 22px; }

.hw-tools {
  flex: none;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 10px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.15), transparent 34%, rgba(255, 210, 135, 0.035)),
    var(--tex, none), var(--card-surface, #18181b);
  border-top: 1px solid var(--rim, rgba(201, 163, 106, 0.5));
  box-shadow: 0 -3px 14px rgba(13,13,15, 0.22);
}
.hw-tools .hw-btn { flex: none; }
.hw-root:not(.hw-map) .hw-tools { display: none; }
.hw-tools, .hw-side, .hw-sheet { scrollbar-color: var(--gold-deep, #8a6a32) transparent; scrollbar-width: thin; }

.hw-cards { display: flex; flex-direction: column; gap: 12px; }
.hw-card {
  display: flex; gap: 12px; align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--rim, rgba(201, 163, 106, 0.35));
  background: var(--tex, none), var(--card-surface, #18181b);
  color: var(--ink, #f4e6cc);
}
.hw-card img { width: 84px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--page-deep, #0b0b0d); flex: none; }
.hw-card .hw-meta { flex: 1; min-width: 0; }
.hw-card b { display: block; font: 600 16px/1.3 var(--serif, Georgia, serif); }
.hw-card small { color: var(--ink-faded, #c9a771); }
.hw-lead { font: 16px/1.45 var(--serif, Georgia, serif); max-width: 42rem; }
.hw-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.hw-seg { display: flex; gap: 8px; }
.hw-seg .hw-btn { flex: 1; }

.hw-root.hw-player { padding-bottom: calc(96px + var(--hearth-safe-bottom, env(safe-area-inset-bottom, 0px))); }

/* Navigation toolkit (world-nav.js): drawer, minimap and the status chip, all inside the stage. */
.hw-nav {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  max-height: 58%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--tex-parch, none), var(--parch, #efe2c4);
  color: var(--parch-ink, #2a2118);
  border-top: 1px solid var(--rim, rgba(56,56,64, 0.35));
  box-shadow: 0 -8px 22px rgba(11,11,13, 0.28);
}
.hw-nav[hidden] { display: none; }
.hw-nav .hw-btn { color: var(--parch-ink, #2a2118); background: transparent; }
.hw-nav .hw-btn.hw-primary { background: #d7b56a; color: #1a120c; -webkit-text-fill-color: #1a120c; border-color: #c9993f; }
.hw-nav .hw-btn.hw-on, .hw-nav .hw-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--gold, #d7b072) 30%, transparent);
  box-shadow: inset 0 0 0 2px var(--gold-deep, #8a6a32);
}
/* The palette reskin paints every [aria-pressed="true"] as a dark ember card, which is unreadable on parchment. */
html:root[data-palette][data-palette] body .hw-nav .hw-btn[aria-pressed="true"],
html:root[data-palette][data-palette] body .hw-chip .hw-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--gold, #d7b072) 38%, #f3e6c8) !important;
  color: var(--parch-ink, #2a2118) !important;
  box-shadow: inset 0 0 0 2px var(--gold-deep, #8a6a32) !important;
}
.hw-nav-head { flex: none; display: flex; align-items: flex-start; gap: 6px; padding: 8px 8px 4px; }
.hw-nav-quick { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.hw-nav-quick .hw-btn { flex: 1 0 auto; padding: 0 10px; }
.hw-nav-close { flex: none; }
.hw-nav-tabs { flex: none; display: flex; gap: 6px; padding: 4px 8px 6px; border-bottom: 1px solid color-mix(in srgb, var(--parch-ink, #1f1f23) 18%, transparent); }
.hw-nav-tabs .hw-btn { flex: 1; }
.hw-nav-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 10px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.hw-nav-results { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 2px; }
.hw-nav-hit, .hw-nav-row .hw-grow { justify-content: space-between; text-align: left; width: 100%; }
.hw-nav-hit span, .hw-nav-row .hw-grow span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-nav-hit small, .hw-nav-row .hw-grow small { flex: none; font-weight: 400; font-size: 12px; opacity: 0.75; }
.hw-nav-row .hw-grow.hw-nav-who { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding-top: 4px; padding-bottom: 4px; line-height: 1.2; }
.hw-nav-row .hw-grow.hw-nav-who span, .hw-nav-row .hw-grow.hw-nav-who small { max-width: 100%; }
.hw-nav-row .hw-grow.hw-nav-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-nav-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.hw-nav-row .hw-grow { flex: 1 1 auto; min-width: 0; }
.hw-nav-row .hw-btn:not(.hw-grow) { flex: none; }
.hw-nav-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #f3e6c8; box-shadow: 0 0 0 1px #1f1f23; }
.hw-nav-dot-party { background: #f4e2a8; box-shadow: 0 0 0 1px #393941; }
.hw-nav-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.hw-nav-toggles .hw-btn { width: 100%; }
.hw-nav .hw-row .hw-field { flex: 1 1 180px; width: auto; }
.hw-nav input[type="search"]::-webkit-search-cancel-button { width: 18px; height: 18px; }

.hw-mini {
  position: absolute;
  top: 52px; right: 10px;
  z-index: 3;
  box-sizing: content-box;
  border: 1px solid #1f1f23;
  outline: 2px solid rgba(243, 230, 200, 0.9);
  border-radius: 4px;
  overflow: hidden;
  background: #e9dbb8;
  box-shadow: 0 4px 12px rgba(11,11,13, 0.35);
}
.hw-mini[hidden] { display: none; }
.hw-mini canvas { cursor: grab; }
.hw-chip {
  position: absolute;
  top: 52px; left: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  padding: 4px 4px 4px 12px;
  border-radius: 10px;
  border: 1px solid rgba(31,31,35, 0.55);
  background: rgba(243, 230, 200, 0.97);
  color: #2a2118;
  font: 14px/1.35 var(--serif, Georgia, serif);
  box-shadow: 0 4px 12px rgba(11,11,13, 0.3);
}
.hw-chip[hidden] { display: none; }
.hw-chip-text { flex: 1 1 auto; min-width: 0; }
.hw-chip .hw-btn { flex: none; color: #2a2118; background: transparent; border-color: rgba(31,31,35, 0.5); }
.hw-root:not(.hw-map) .hw-nav, .hw-root:not(.hw-map) .hw-mini, .hw-root:not(.hw-map) .hw-chip { display: none !important; }

@media (min-width: 1000px) and (orientation: landscape), (min-width: 1280px) {
  .hw-nav {
    left: 12px; right: auto; top: 12px; bottom: auto;
    width: 360px;
    max-height: calc(100% - 24px);
    border: 1px solid var(--rim, rgba(56,56,64, 0.45));
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(11,11,13, 0.35);
  }
  .hw-root.hw-nav-open .hw-chip { left: 384px; }
}

/* Encounters (world-encounters.js): the drawer reuses the navigation drawer's frame. */
.hw-tools .hw-btn { position: relative; }
.hw-enc-badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box;
  border-radius: 9px; background: #7a2e22; color: #f3e6c8;
  font: 700 11px/18px var(--sans, Roboto, sans-serif); text-align: center;
}
.hw-enc-two { grid-template-columns: 1fr 1fr; }
.hw-enc-step, .hw-enc-crow { display: flex; align-items: center; gap: 6px; margin: 4px 0; min-height: 44px; }
.hw-enc-step-label, .hw-enc-cname { flex: 1 1 auto; min-width: 0; font: 600 14px/1.25 var(--sans, Roboto, sans-serif); }
.hw-enc-step-label small, .hw-enc-cname small { display: block; font-weight: 400; font-size: 12px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-enc-cname { overflow: hidden; text-overflow: ellipsis; }
.hw-enc-step .hw-btn, .hw-enc-crow .hw-btn { flex: none; padding: 0; width: 44px; }
.hw-enc-step-val { flex: none; min-width: 40px; text-align: center; font: 700 15px/1 var(--sans, Roboto, sans-serif); }
.hw-enc-card {
  margin: 2px 0 10px; padding: 8px 10px 4px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--parch-ink, #1f1f23) 22%, transparent);
  background: color-mix(in srgb, var(--parch-ink, #1f1f23) 5%, transparent);
}
.hw-enc textarea, .hw-enc-prompt textarea { min-height: 72px; resize: vertical; font: 15px/1.35 var(--sans, Roboto, sans-serif); }
.hw-enc .hw-row .hw-field, .hw-enc-prompt .hw-row .hw-field { flex: 1 1 160px; width: auto; }
.hw-enc .hw-row .hw-field.hw-enc-count { flex: 0 0 84px; }
.hw-enc .hw-field + .hw-field { margin-top: 6px; }
.hw-enc .hw-row { margin: 6px 0; }
.hw-enc-prompt {
  position: absolute;
  left: 8px; right: 8px; bottom: 8px;
  z-index: 5;
  max-height: calc(100% - 64px);
  overflow: auto;
  box-sizing: border-box;
  padding: 10px 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--rim, rgba(56,56,64, 0.45));
  background: var(--tex-parch, none), var(--parch, #efe2c4);
  color: var(--parch-ink, #2a2118);
  box-shadow: 0 10px 28px rgba(11,11,13, 0.4);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.hw-enc-prompt[hidden] { display: none; }
.hw-enc-prompt .hw-btn { color: var(--parch-ink, #2a2118); background: transparent; }
.hw-enc-prompt .hw-btn.hw-primary { background: #d7b56a; color: #1a120c; -webkit-text-fill-color: #1a120c; border-color: #c9993f; }
.hw-enc-prompt .hw-field { width: 100%; }
.hw-enc-phead { display: flex; align-items: center; gap: 8px; font: 700 12px/1.3 var(--sans, Roboto, sans-serif); letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.hw-enc-phead svg, .hw-enc-private svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.hw-enc-phead span { flex: 1 1 auto; min-width: 0; }
.hw-enc-phead small { flex: none; font-weight: 600; text-transform: none; letter-spacing: 0; }
.hw-enc-title { margin: 6px 0 4px; font: 600 20px/1.25 var(--serif, Georgia, serif); }
.hw-enc-private { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 13px; opacity: 0.85; }
.hw-enc-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.hw-enc-actions .hw-btn { width: 100%; min-width: 0; padding: 0 6px; white-space: nowrap; }
.hw-enc-actions .hw-btn.hw-primary { grid-column: span 2; }
.hw-enc-chip { top: 104px; }
.hw-root:not(.hw-map) .hw-enc-prompt { display: none !important; }

@media (min-width: 1000px) and (orientation: landscape), (min-width: 1280px) {
  .hw-enc-prompt { left: auto; right: 12px; bottom: 12px; width: 420px; max-height: calc(100% - 24px); }
  .hw-root.hw-enc-open .hw-chip { left: 384px; }
}

@media (min-width: 1000px) and (orientation: landscape), (min-width: 1280px) {
  .hw-root.hw-panel .hw-side {
    position: relative;
    left: auto; right: auto; bottom: auto;
    max-height: none;
    width: 320px;
    border-top: 0;
    border-left: 1px solid var(--rim, rgba(56,56,64, 0.35));
  }
  .hw-sheet { padding: 28px 32px; }
}

@media (max-width: 420px) {
  .hw-title b { font-size: 16px; }
  .hw-btn span.hw-hide-sm { display: none; }
}
/* Map tools go icon-only below tablet landscape so the Journey and Edit switch stays on screen. */
@media (max-width: 820px) {
  .hw-tools .hw-btn span.hw-hide-sm { display: none; }
}
