/* === TERRITORY MAP — House Signature page === */

.tm-host { position: absolute; inset: 0 0 198px; }
.tm-host svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* The model shares the portal frame. Its map occupies the upper field and its
   navigation lives in the reserved lower field of that very same frame. */
.model-canvas.is-territory { top: 182px; right: 232px; bottom: 50px; left: 406px; }
.model-canvas.is-territory svg { width: 88%; margin: 0 auto; }

/* House Signature left column: smaller mini-map */
.slide[data-section="1"] .visual-index { height: 120px; margin-bottom: 12px; }
.slide[data-section="1"] .entry-title { font-size: 36px; }
.slide[data-section="1"] .entry-summary { font-size: 16px; }

/* terrain */
.tm-shadow { fill: rgba(38, 38, 38, 0.05); filter: blur(9px); transform: translateY(4px); }
.tm-bed { fill: #eae8e3; stroke: rgba(38, 38, 38, 0.16); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* territories */
.tm-territory { cursor: pointer; outline: none; transition: opacity 200ms ease; }
.tm-territory .tm-surface {
  fill: rgba(255, 255, 255, 0.44);
  stroke: rgba(38, 38, 38, 0.22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: fill 180ms ease, stroke 180ms ease;
}
/* light red wash on hover, brand content stays visible */
.tm-territory:hover .tm-surface,
.tm-territory:focus-visible .tm-surface {
  fill: rgba(155, 47, 37, 0.12);
  stroke: var(--accent, #9b2f25);
  stroke-width: 1.4;
}
.tm-territory:hover .tm-growth { opacity: 0.4; }

.tm-growth { fill: rgba(38, 38, 38, 0.03); stroke: rgba(38, 38, 38, 0.08); stroke-width: 0.8; vector-effect: non-scaling-stroke; pointer-events: none; }
.tm-growth.is-dashed { fill: none; stroke-dasharray: 3 6; }

.tm-wall { fill: none; stroke: var(--paper, #f2f2f0); stroke-width: var(--wall, 10); stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.tm-seam { fill: none; stroke: rgba(38, 38, 38, 0.16); stroke-width: 0.7; vector-effect: non-scaling-stroke; pointer-events: none; }

/* territory title block */
.tm-content { pointer-events: none; transition: opacity 200ms ease; }
.tm-content.is-muted { opacity: 0.2; }
.tm-content.is-hovered .tm-title-primary { fill: var(--accent, #9b2f25); }

.tm-title { pointer-events: none; }
.tm-title-primary { fill: var(--ink, #262626); font-family: var(--display); font-size: 25px; font-weight: 300; letter-spacing: -0.03em; }
.tm-title-secondary { fill: var(--soft-ink, #535250); font-family: "Songti SC", "STSong", serif; font-size: 15px; font-weight: 600; letter-spacing: 0.05em; }
.tm-title-type { fill: var(--muted, #858582); font-family: var(--label); font-size: 8.5px; letter-spacing: 0.14em; text-transform: uppercase; }

/* brand fields */
.tm-field { pointer-events: none; transition: opacity 200ms ease; }
.tm-field ellipse { fill: var(--brand); stroke: var(--brand); }
.tm-field .tm-field-outer { fill-opacity: 0.04; stroke-opacity: 0.26; }
.tm-field .tm-field-mid { fill-opacity: 0.06; stroke-opacity: 0.2; }
.tm-field .tm-field-core { fill-opacity: 0.13; stroke-opacity: 0.22; }
.tm-field text { fill: color-mix(in srgb, var(--brand) 70%, #101010); font-family: var(--label); font-size: 11px; text-anchor: middle; dominant-baseline: middle; }
.tm-field.is-neutral .tm-field-outer { fill-opacity: 0; stroke-opacity: 0.28; }
.tm-field.is-neutral text { fill: rgba(60, 58, 52, 0.78); font-size: 10.5px; }
.tm-field.is-note text { fill: var(--muted, #858582); font-family: var(--display); font-size: 12px; font-style: italic; text-anchor: middle; dominant-baseline: middle; }

/* villages */
.tm-villages { pointer-events: none; }
.tm-village circle { fill: var(--muted, #858582); }
.tm-village text { fill: var(--muted, #858582); font-family: var(--label); font-size: 9.5px; letter-spacing: 0.02em; }
.tm-village.is-rare circle { fill: var(--accent, #9b2f25); }
.tm-village.is-rare text { fill: var(--accent, #9b2f25); }

/* expansion */
.tm-expand-target { fill: rgba(155, 47, 37, 0.05); stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.tm-expand-link { fill: none; stroke: var(--brand); stroke-width: 1.2; stroke-dasharray: 3 7; opacity: 0.75; vector-effect: non-scaling-stroke; }

/* overlap weights drawn inside the focused territory */
.tm-weights { pointer-events: none; }
.tm-weight rect { fill: var(--brand); opacity: 0.45; }
.tm-weight text { fill: var(--soft-ink, #535250); font-family: var(--label); font-size: 10px; }

/* ---------- level emphasis ---------- */
/* FIELD: territories only, no brand marks */
[data-level="field"] .tm-field { display: none; }

[data-level="brand"] .tm-territory.is-muted { opacity: 0.32; }
[data-level="brand"] .tm-territory.is-owned .tm-surface { fill: rgba(255, 255, 255, 0.86); stroke: rgba(38, 38, 38, 0.42); }
[data-level="brand"] .tm-field { opacity: 0.1; }
[data-level="brand"] .tm-field.is-selected-brand { opacity: 1; }
[data-level="brand"] .tm-field.is-selected-brand .tm-field-core { fill-opacity: 0.2; }

/* OVERLAP: no brand until a territory is chosen, then only its brands */
[data-level="overlap"] .tm-field { display: none; }
[data-level="overlap"] .tm-content.is-focus .tm-field { display: block; }
[data-level="overlap"] .tm-content.is-muted { opacity: 0.2; }
[data-level="overlap"] .tm-territory.is-muted { opacity: 0.2; }
[data-level="overlap"] .tm-territory.is-focus .tm-surface { fill: rgba(255, 255, 255, 0.92); stroke: rgba(38, 38, 38, 0.5); stroke-width: 1.4; }

[data-level="expansion"] .tm-territory.is-ghost { opacity: 0.22; }
[data-level="expansion"] .tm-territory.is-owned .tm-surface { fill: rgba(255, 255, 255, 0.8); stroke: rgba(38, 38, 38, 0.4); }
[data-level="expansion"] .tm-field { opacity: 0.12; }
[data-level="expansion"] .tm-field.is-selected-brand { opacity: 1; }

/* ---------- controls ---------- */
.tm-controls { position: absolute; top: 10px; right: 12px; z-index: 6; display: flex; align-items: center; gap: 14px; }
.tm-control-group { display: flex; align-items: center; gap: 6px; }
.tm-control-group[hidden] { display: none; }
.tm-controls .caption { color: var(--muted); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }
.tm-controls button {
  border: 1px solid var(--line, rgba(38,38,38,.16));
  background: rgba(255, 255, 255, 0.5);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 10px;
  color: var(--muted);
  transition: 150ms ease;
}
.tm-controls button:hover { border-color: var(--line-strong); color: var(--ink); }
.tm-controls button[aria-pressed="true"] { border-color: var(--accent, #9b2f25); color: var(--accent, #9b2f25); background: var(--white, #fffefa); }

/* ---------- reading line under the map ---------- */
.tm-reading { position: absolute; z-index: 6; left: 32px; right: 32px; bottom: 30px; }.tm-reading-lead { margin: 0; max-width: 900px; font-family: var(--display); font-size: 17px; font-weight: 300; line-height: 1.3; color: var(--soft-ink, #535250); }
.tm-reading-note { margin: 6px 0 0; font-family: var(--label); font-size: 10px; letter-spacing: 0.04em; color: var(--muted, #858582); }

/* ---------- horizontal level menu, centred under the map ---------- */
.tm-levels {
  position: absolute;
  z-index: 6;
  left: 32px;
  right: 32px;
  bottom: 122px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 22px;
}
.tm-level {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 4px 2px 8px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 160ms ease;
}
.tm-level:hover { color: var(--ink); }
.tm-level.is-active { color: var(--accent); box-shadow: inset 0 -2px 0 0 var(--accent); }
.tm-level-sep { color: var(--line-strong); font-size: 19px; }

/* ---------- second level: selection list, in the right rail ---------- */
.tm-selector {
  margin: auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 400px;
}
.tm-selector[hidden] { display: none; }
.tm-selector-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 8px; letter-spacing: 0.15em; text-transform: uppercase; }
.tm-selector-list { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.tm-selector-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  padding: 6px 3px;
  color: var(--muted);
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}
.tm-selector-item:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.tm-selector-item.is-active { background: var(--white); }
.tm-selector-item.is-active .tm-selector-name { color: var(--accent); }
.tm-selector-name { font-family: var(--display); font-size: 14px; font-weight: 300; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-selector-note { color: var(--muted); font-size: 9px; white-space: nowrap; }

/* ---------- overlap list in the left column ---------- */
.tm-overlap-list { display: flex; flex-direction: column; gap: 7px; }
.tm-overlap-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 34px; align-items: center; gap: 8px; font-size: 10px; }
.tm-overlap-name { color: var(--soft-ink, #535250); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-overlap-bar { height: 5px; background: rgba(38, 38, 38, 0.08); }
.tm-overlap-bar i { display: block; height: 100%; background: var(--brand); }
.tm-overlap-share { color: var(--muted); text-align: right; }
.tm-occupant.is-rare { border-color: var(--accent); color: var(--accent); }
.tm-occupant.is-target { border-style: dashed; }

/* ---------- left column detail ---------- */
#territoryDetail { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.tm-detail { margin-top: 16px; border-top: 1px solid var(--line-strong, rgba(38,38,38,.36)); padding-top: 14px; }
.tm-detail-index { color: var(--accent, #9b2f25); font-family: var(--display); font-size: 20px; font-weight: 300; line-height: 1; }
.tm-detail-kicker { margin-top: 6px; color: var(--accent, #9b2f25); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; }
.tm-detail-title { margin: 6px 0 0; font-family: var(--display); font-size: 27px; font-weight: 300; letter-spacing: -0.03em; line-height: 0.98; }
.tm-detail-zh { margin: 4px 0 0; font-family: "Songti SC", "STSong", serif; font-size: 13px; font-weight: 600; }
.tm-detail-summary { margin: 10px 0 0; color: var(--soft-ink, #535250); font-family: var(--display); font-size: 14px; font-weight: 300; line-height: 1.28; }
.tm-detail-question { margin: 10px 0 0; border-left: 2px solid var(--accent, #9b2f25); padding-left: 12px; color: var(--muted, #858582); font-size: 10px; line-height: 1.45; }
.tm-detail-block { margin-top: 10px; border-top: 1px solid var(--line, rgba(38,38,38,.16)); padding-top: 9px; }
.tm-detail-label { display: block; margin-bottom: 6px; color: var(--muted, #858582); font-size: 8px; letter-spacing: 0.15em; text-transform: uppercase; }
.tm-detail-block p { margin: 0; color: var(--muted, #858582); font-size: 10px; line-height: 1.45; }
.tm-occupants { display: flex; flex-wrap: wrap; gap: 5px; }
.tm-occupant { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line, rgba(38,38,38,.16)); border-radius: 999px; padding: 3px 7px; color: var(--soft-ink, #535250); font-size: 9px; }
