/* Weltkarte im Stil eines handgezeichneten Atlas.
   --k gleicht den Zoom aus, --ls die Bildschirmbreite: Schrift bleibt in jeder Lage gleich gut lesbar. */

.worldmap { --ls: 1; touch-action: pan-y; user-select: none; -webkit-user-select: none; background: #1f6474; cursor: grab; }
.worldmap:not([data-zoom="fern"]) { touch-action: none; }
.worldmap:active { cursor: grabbing; }
.map-tools { position: absolute; z-index: 2; top: .6rem; inset-inline-end: .6rem; display: flex; gap: .25rem; line-height: 1.4; }
.map-tools .tool { color: var(--paper-50); background: rgba(7, 13, 24, .72); backdrop-filter: blur(4px); }
.map-tools .tool[aria-pressed="false"] { color: var(--paper-300); }
.map-tools .tool[aria-expanded="true"] { color: #2a1c08; background: linear-gradient(180deg, var(--gold-100), var(--gold-300)); }

.map-region { cursor: pointer; }
.map-shape { stroke: #4d3b24; stroke-width: 1.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: filter .15s; }
/* Fremde Reiche: Fläche nur getönt, die Farbe der Beziehung trägt das Band an der Grenze (js/ui/map.js, region). */
.map-region:not(.map-province) .map-shape { fill-opacity: .5; }
.map-band { fill: none; stroke-width: 16px; stroke-opacity: .62; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.map-province .map-shape { stroke-dasharray: 5 4; stroke-width: 1.2; }
.map-free { stroke: #4d3b24; stroke-width: 1; vector-effect: non-scaling-stroke; }
.map-free.wald { fill: #a3b488; }
.map-free.wueste { fill: #e0c996; }
/* Meer, Wasserlinien und Grund aus Pergament mit Papierkorn (js/ui/map.js, coast). Eigene Provinzen lassen das Korn durchscheinen. */
.map-base { pointer-events: none; }
.map-province .map-shape { fill-opacity: .8; }
.map-overlay { pointer-events: none; }
.map-line { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; vector-effect: non-scaling-stroke; }
.pin { pointer-events: none; }
.pin-body { transform: scale(calc(var(--k) * var(--ls))); }
.worldmap[data-zoom="fern"] .tier-stadt, .worldmap[data-zoom="fern"] .tier-kleinstadt, .worldmap[data-zoom="mittel"] .tier-kleinstadt { display: none; }
.worldmap:not([data-zoom="nah"]) .site, .worldmap[data-zoom="fern"] .map-sub { display: none; }
.map-region:hover .map-shape { filter: brightness(1.08) saturate(1.1); }
.map-region:focus { outline: none; }
.map-region:focus-visible .map-shape, .map-region.selected .map-shape { stroke: #fff4cf; stroke-width: 3.5; stroke-dasharray: none; }
.map-region.selected .map-shape { filter: brightness(1.1) saturate(1.15); }
.map-region.place .map-shape { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.28); } }

.worldmap text { font-family: var(--display); font-weight: 600; fill: var(--ink); stroke: rgba(251, 244, 228, .78); stroke-width: 3px; paint-order: stroke; pointer-events: none; }
.worldmap .ml-namen > text { stroke-width: calc(3px * var(--k) * var(--ls)); }
.map-label { font-size: calc(21px * var(--k) * var(--ls)); letter-spacing: .1em; text-transform: uppercase; }
/* Das eigene Land: gleiche Schrift wie die Reiche, weiter gesperrt und dunkler, damit man es zuerst findet. */
.worldmap .map-land { letter-spacing: .2em; fill: #3a2410; }
.map-sub, .map-prov { font-size: calc(15px * var(--k) * var(--ls)); font-style: italic; }
.map-sea { font-size: calc(17px * var(--k) * var(--ls)); font-style: italic; letter-spacing: .14em; fill: #dff4f2 !important; stroke: rgba(11, 45, 58, .55) !important; }
.map-exit { font-size: calc(15px * var(--k) * var(--ls)); }
.pin-body .map-city { font-size: 19px; font-weight: 600; }
.pin-body .map-note { font-size: 15px; font-family: var(--text); font-weight: 400; }
/* Namen ohne freien Platz blendet js/ui/labels.js aus, beim Heranzoomen kommen sie wieder. */
.worldmap .lbl-off { visibility: hidden; }

/* Ebenen: Die Klasse hide-… steht am Feld der Karte, die Gruppen ml-… zeichnet js/ui/map.js. */
.hide-land .ml-land, .hide-fluesse .ml-fluesse, .hide-wege .ml-wege, .hide-pilger .ml-pilger, .hide-namen .ml-namen, .hide-staetten .ml-staetten, .hide-kompass .compass,
.hide-orte .worldmap:not(.realm-on) .ml-orte, .hide-orte .worldmap.realm-on .ml-orte .pin:not(.realm-node),
.hide-strassen .rm-road:not(.open):not(.closed) { display: none; }
.hide-farben .map-region:not(.map-province) { fill: #dccba6; }
.hide-farben .map-band { display: none; }

/* Doppelter Rahmen wie die Randlinie eines gedruckten Atlas. */
.scene.atlas::after {
  content: ""; position: absolute; z-index: 1; inset: 5px; pointer-events: none; border-radius: 5px;
  border: 1px solid rgba(232, 200, 119, .55); box-shadow: inset 0 0 0 3px rgba(11, 21, 36, .35), inset 0 0 0 4px rgba(232, 200, 119, .3);
}
@media (max-width: 640px) { .scene.atlas::after { display: none; } }

/* Legende: ein Schild auf Pergament, denn die Zeichen der Karte sind für hellen Grund gemacht. */
.map-key {
  color: var(--ink); background: var(--grain), linear-gradient(180deg, var(--paper-50), var(--paper-100));
  border: 1px solid var(--gold-700); border-radius: 8px; padding: .55rem .8rem .7rem;
  box-shadow: inset 0 0 0 3px var(--paper-100), inset 0 0 0 4px var(--paper-300), var(--shadow);
  scrollbar-color: var(--paper-300) transparent;
}
.key-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.key-head h3 { flex: 1; font-family: var(--display); font-size: 1.35rem; color: var(--lapis-800); }
.key-all { padding: .1rem .2rem; font-family: var(--label); font-weight: 500; font-size: .86rem; color: #1d6b66; background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; }
.key-close { min-width: 34px; min-height: 34px; padding: 0; color: var(--ink-soft); border-color: var(--paper-300); }
.key-close:hover { color: var(--ink); background: #fff; border-color: var(--gold-700); }
.key-rows { list-style: none; margin: .35rem 0 0; padding: 0; }
.key-rows li { padding: .22rem 0 .3rem; border-top: 1px solid var(--paper-300); }
.key-toggle { display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 32px; padding: 0; text-align: start; font-family: var(--label); font-weight: 700; font-size: .95rem; color: var(--lapis-800); background: none; border: 0; }
.key-toggle[aria-pressed="false"] { font-weight: 500; color: var(--ink-soft); }
.key-toggle:hover { color: var(--rubric); }
.key-check { flex: none; display: grid; place-items: center; width: 1.2rem; height: 1.2rem; color: var(--gold-100); background: var(--paper-50); border: 1px solid var(--gold-700); border-radius: 3px; }
.key-toggle[aria-pressed="true"] .key-check { background: var(--lapis-700); }
.key-check .ic { width: .95rem; height: .95rem; stroke-width: 3; }
.key-note { margin: .1rem 0 0; font-size: .82rem; line-height: 1.25; color: var(--ink-soft); }
.legend { display: flex; flex-wrap: wrap; gap: .1rem .75rem; line-height: 1.35; font-family: var(--label); font-weight: 500; font-size: .84rem; color: var(--ink); }
.legend span { display: inline-flex; align-items: center; min-height: 1.4rem; }
.legend i { flex: none; width: .75rem; height: .75rem; margin-inline-end: .32rem; border-radius: 2px; border: 1px solid rgba(0, 0, 0, .35); }
.key-sym { flex: none; width: auto; height: 1.1rem; margin-inline-end: .32rem; overflow: visible; }
.key-sym path.map-line { vector-effect: none; }

/* Das Feld zur Auswahl */
.map-card { position: relative; }
.map-close { position: absolute; z-index: 1; top: .35rem; inset-inline-end: .35rem; min-width: 34px; min-height: 34px; padding: 0; }
.map-card .mapinfo { padding-inline-end: 2.7rem; }

.mapinfo {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem 1rem; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(33, 57, 90, .62), rgba(17, 31, 51, .86));
  border: 1px solid var(--line); border-radius: 8px; padding: .65rem .9rem; font-size: .98rem; line-height: 1.35;
}
.mapinfo p { margin: 0; }
.mapinfo strong { display: block; font-family: var(--display); font-weight: 600; font-size: 1.35rem; color: var(--gold-300); }
.mapinfo span { display: block; }
.mapinfo div { flex: 1 1 280px; }

/* Eine Welt: Städte, Heere und Kunde über der Weltkarte (js/ui/realm.js).
   Orte im Städtenetz bleiben in jedem Abstand beschriftet, ihr Name rückt neben die Scheibe. */
.worldmap.realm-on .pin.realm-node { display: inline; }
.worldmap.realm-on .realm-node .map-note { transform: translateX(5px); }
.rm-pin { pointer-events: auto; cursor: pointer; }
.rm-pin:focus { outline: none; }
.rm-hit { fill: transparent; }
.rm-road { stroke: #3b2a18; stroke-opacity: .4; stroke-width: 1.6; stroke-dasharray: 2 5; }
.rm-road.open { stroke: #fff1c4; stroke-opacity: .95; stroke-width: 3; stroke-dasharray: none; }
.rm-road.closed { stroke: #a8452c; stroke-opacity: .85; stroke-width: 2.4; stroke-dasharray: 3 6; }
.rm-disc { stroke-width: 2; }
path.rm-disc { stroke: #2a1f14; stroke-width: 1.4; }
.rm-halo { fill: none; }
.rm-fort { fill: none; stroke: #2a1f14; stroke-width: 1.3; }
.rm-fort.planned { stroke: #1f7a74; stroke-width: 1.6; stroke-dasharray: 2 2.5; }
.rm-tower { fill: #2a1f14; }
.rm-moat { fill: none; stroke: #2d7f8b; stroke-width: 2.4; }
.rm-gate { fill: none; stroke: #e8c877; stroke-width: 2.6; stroke-linecap: round; }
.rm-siege { fill: none; stroke: #9c3522; stroke-width: 2.2; stroke-dasharray: 5 3.5; }
.rm-siege.mine { stroke: #1f7a74; }
.rm-port { fill: none; stroke: #17505f; stroke-width: 1.8; stroke-linecap: round; }
.rm-port.shut { stroke: #9c3522; }
.rm-lane { stroke: #dff4f2; stroke-opacity: .55; stroke-width: 1.6; stroke-dasharray: 8 7; }
.rm-lane.open { stroke: #fff1c4; stroke-opacity: .95; stroke-width: 3; }
.rm-scout { fill: none; stroke: #2a1f14; stroke-width: 1.5; stroke-dasharray: 1.5 3.5; }
.rm-badge rect { fill: #fbf4e4; stroke: #2a1f14; stroke-width: 1; }
.worldmap .rm-badge text { font-family: var(--label); font-weight: 700; font-size: 11.5px; stroke: none; }
.rm-site.mine .rm-badge rect { fill: #d9efe9; stroke: #1f7a74; }
.rm-site.unknown .rm-badge rect { fill: #e4d6b8; stroke-dasharray: 2 2; }
.worldmap .rm-site.unknown .rm-badge text { fill: var(--ink-soft); }
.rm-site.stale .rm-badge, .rm-site.stale .rm-age { opacity: .7; }
.worldmap .rm-site.rumour .rm-badge text { font-style: italic; }
/* Wem die Stadt gehört, weiß der Spieler nicht (realm.ownerSeen): ein Fragezeichen statt Farbe und Zahl. */
.rm-site.nobody .rm-disc { stroke-dasharray: 2.5 2; }
.rm-site.nobody .rm-badge { display: none; }
.worldmap .rm-what { font-family: var(--label); font-weight: 700; font-size: 11px; fill: #fbf4e4; stroke: none; }
.worldmap .rm-age { font-family: var(--text); font-size: 10.5px; font-weight: 600; fill: #3b2a18; }
.worldmap[data-zoom="fern"] .rm-age { display: none; }
.worldmap .rm-plus { font-family: var(--label); font-weight: 700; font-size: 11px; fill: #1f7a74; }
.rm-site.target .rm-hit { fill: rgba(255, 241, 196, .25); stroke: #fff1c4; stroke-width: 2; stroke-dasharray: 4 3; }
.rm-site.selected .rm-hit, .rm-pin:focus-visible .rm-hit { fill: rgba(255, 244, 207, .35); stroke: #fff4cf; stroke-width: 2.5; stroke-dasharray: none; }
.rm-site.aimed .rm-hit { fill: rgba(217, 105, 74, .3); stroke: #d9694a; stroke-width: 2.5; stroke-dasharray: none; }
.rm-arrow-back { stroke: #fbf4e4; stroke-opacity: .8; stroke-width: 6; }
.rm-arrow { stroke: #1f7a74; stroke-width: 3; }
.rm-arrow.attack, .rm-head.attack path { stroke: #9c3522; }
.rm-head path { fill: #1f7a74; stroke: #1f7a74; stroke-width: 1; }
.rm-head.attack path { fill: #9c3522; }
.rm-count circle { fill: #fbf4e4; stroke: #1f7a74; stroke-width: 2; }
.worldmap .rm-count text { font-family: var(--label); font-weight: 700; font-size: 11px; stroke: none; }
@media (prefers-reduced-motion: no-preference) { .rm-site.target .rm-hit { animation: pulse 1.6s ease-in-out infinite; } }

.legend .rm-key-star { transform: rotate(45deg); }
.rm-key-badge { display: inline-block; min-width: 1.1rem; margin-inline-end: .32rem; padding: 0 .2rem; text-align: center; font-size: .8rem; color: var(--ink); background: #fbf4e4; border: 1px solid #2a1f14; border-radius: 3px; }
.legend .rm-key-ring, .legend .rm-key-siege { width: .85rem; height: .85rem; background: none; border-radius: 50%; border: 2px solid #2a1f14; }
.legend .rm-key-siege { border: 2px dashed #9c3522; }
.legend .rm-key-lane { width: 1.1rem; height: 0; border: 0; border-top: 2px dashed #1f6474; border-radius: 0; }
.rm-swatch { display: inline-block; width: .7rem; height: .7rem; margin-inline-end: .4rem; transform: rotate(45deg); border: 1px solid rgba(0, 0, 0, .35); }

/* Feld unter der Karte, dunkel wie .mapinfo */
.realm-info .realm-hint { margin: .45rem 0 0; font-size: .93rem; color: var(--paper-200); }
.realm-info .realm-hint span { display: inline; }
.realm-info .good { color: var(--teal-soft); }
.realm-info .bad { color: var(--ember-soft); }
.realm-route { margin: .5rem 0 .2rem; font-weight: 700; color: var(--gold-300); }
.realm-pick { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.mapinfo .realm-siege { margin-top: .3rem; color: var(--ember-soft); }
.forge li { align-items: flex-start; }
.forge .realm-hint { font-size: .9rem; color: var(--ink-soft); }
.realm-pick .small[aria-pressed="true"] { color: #2a1c08; background: var(--gold-300); border-color: var(--gold-700); font-weight: 700; }

/* Reiter „Heer“ auf dem hellen Pult */
.realm-desk h4 { margin: 1rem 0 .35rem; font-family: var(--label); font-weight: 700; font-size: .98rem; color: var(--lapis-800); }
.realm-desk .small { color: var(--ink); background: var(--paper-50); border-color: var(--paper-300); min-height: 36px; }
.realm-desk .small:hover:not(:disabled) { border-color: var(--gold-700); background: #fff; }
.realm-status { font-family: var(--label); font-weight: 500; font-size: .95rem; color: var(--ink-soft); }
.realm-status b { color: var(--lapis-800); }
.realm-desk .realm-hint { font-size: .93rem; color: var(--ink-soft); }
.realm-list { list-style: none; margin: 0; padding: 0; }
.realm-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .3rem 0; border-bottom: 1px solid var(--paper-300); }
.realm-list.rows li { padding: 0; }
.realm-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .1rem .8rem; width: 100%; min-height: 42px; padding: .35rem .2rem; text-align: start; color: var(--ink); background: none; border: 0; }
.realm-row:hover:not(:disabled) { background: rgba(255, 255, 255, .55); }
.realm-row:disabled { opacity: .6; }
.realm-row b { display: inline-flex; align-items: center; font-weight: 700; color: var(--lapis-800); }
.realm-row span { font-size: .9rem; color: var(--ink-soft); }
.realm-row.front span { color: var(--rubric); }

/* Kriegsnachrichten im Bericht */
.realm-news { margin: .6rem 0 1rem; }
.realm-news h3 { font-family: var(--label); font-weight: 700; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--rubric); margin: 0 0 .35rem; }
.realm-news ul { list-style: none; margin: 0; padding: 0; }
.realm-news li { padding: .15rem 0 .15rem .7rem; margin-bottom: .25rem; border-inline-start: 3px solid var(--paper-300); }
.realm-news li.good { border-color: #2f9e95; }
.realm-news li.bad { border-color: var(--rubric); }

/* Vorschau für die Wahl der Welt */
.th-sea { fill: #1f6474; }
.th-land { fill: #cdb98e; stroke: #4d3b24; stroke-width: 3; }
.th-own { fill: #e8c877; stroke: #4d3b24; stroke-width: 3; }
.th-river { fill: none; stroke: #1f6474; stroke-width: 9; stroke-linecap: round; }
.th-city { fill: var(--rubric); stroke: #fbf4e4; stroke-width: 5; }

@media (min-width: 980px) {
  /* Legende und Auswahl liegen auf der Karte, damit sie die ganze Höhe des Fensters nutzen kann. */
  .atlas-wrap { position: relative; }
  .map-key, .map-card { position: absolute; z-index: 3; overflow-y: auto; }
  .map-key { top: 3.5rem; inset-inline-end: .6rem; width: min(310px, calc(100% - 1.2rem)); max-height: calc(100% - 4.1rem); }
  .map-card { bottom: .6rem; inset-inline-start: .6rem; width: min(440px, calc(100% - 1.2rem)); max-height: calc(100% - 4.1rem); border-radius: 8px; }
  .map-card .mapinfo { background: rgba(11, 21, 36, .93); border-color: var(--line-strong); box-shadow: 0 6px 18px rgba(2, 6, 14, .45); font-size: .94rem; }
  .map-card .mapinfo strong { font-size: 1.2rem; }
}
@media (min-width: 980px) and (max-width: 1300px) { .worldmap { --ls: 1.3; } }
@media (min-width: 1700px) { .worldmap { --ls: .8; } }
@media (max-width: 979px) {
  .worldmap { --ls: 1.15; }
  /* Ohne Karte auch keine Legende. */
  .board[data-pane="pult"] .map-key, .board[data-pane="pult"] .map-card { display: none; }
  .atlas-wrap { display: flex; flex-direction: column; gap: .75rem; }
}
@media (max-width: 640px) {
  .worldmap { --ls: 1.55; }
  .map-label { font-size: calc(16px * var(--k) * var(--ls)); letter-spacing: 0; }
  .worldmap .map-land { letter-spacing: .08em; }
  /* Hoch gehaltene Handys: Knöpfe unter die Karte, damit sie nichts verdecken.
     Aus der Ferne zählen hier nur Reiche und Großstädte, der Rest erscheint beim Zoomen. */
  .scene.atlas { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem .6rem; overflow: visible; aspect-ratio: auto; border: 0; background: none; box-shadow: none; line-height: 1.4; }
  .scene.atlas > svg { position: relative; inset: auto; flex: 1 0 100%; height: auto; aspect-ratio: 8 / 5; border: 1px solid var(--line-strong); border-radius: 8px; }
  .map-tools { position: static; order: 3; }
  .map-tools .tool { background: rgba(255, 255, 255, .05); }
  .worldmap[data-zoom="fern"] .compass, .worldmap[data-zoom="fern"] .map-prov, .worldmap[data-zoom="fern"] .map-exit { display: none; }
}
