/* Regionale Einsatzzentrale V1 (Auftrag 026 CP4) — Bunker-Lageschirm, KEINE Dashboard-Optik. */

/* 045 §13: Das eigene Regionspanel gibt es nicht mehr — die Karte sitzt als Modul in der
   Station „Lage“. Die alten Panelregeln würden dort das GANZE Panel treffen (auch die
   Modulspalte) und hätten den Innenabstand des Schirms mitgenommen. Layout: css/lage.css. */
.tabpanel[data-panel="lage"] .lage-karte .region { height: 100%; }

.region {
  --rg-line: #4a86a8;
  --rg-warn: #e2892f;
  --rg-threat: #16303f;
  display: flex; flex-direction: column; height: 100%;
  color: #cfe4ef; font-family: 'Antonio', 'Oswald', system-ui, sans-serif;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(40,70,90,.20), transparent 60%),
    linear-gradient(180deg, #0a141c, #060b11);
  border: 1px solid rgba(90,150,190,.16);
}
.region.tone-tense    { --rg-threat: #2a2f18; --rg-warn: #d0b23a; }
.region.tone-critical { --rg-threat: #3a2410; --rg-warn: #e2892f; }
.region.tone-invasion { --rg-threat: #45180f; --rg-warn: #ef6a3a; }
.region.tone-crisis   { --rg-threat: #4d0f10; --rg-warn: #ff4d4d; animation: rg-crisis 2.4s ease-in-out infinite; }
@keyframes rg-crisis { 0%,100% { box-shadow: inset 0 0 0 rgba(255,60,60,0); } 50% { box-shadow: inset 0 0 90px rgba(255,60,60,.16); } }

/* ---- Lagekopf (Instrumenten-Schiene, kein KPI-Raster) ---- */
.region-head {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid rgba(90,150,190,.20);
  background: linear-gradient(180deg, rgba(18,32,43,.9), rgba(10,18,26,.9));
}
.rh-id { display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: 2px; color: #9fd0e6; white-space: nowrap; }
.rh-id .rh-mark { color: var(--rg-warn); }
.rh-act1 { font-size: 11px; letter-spacing: 1.5px; color: #6fd6a0; border: 1px solid rgba(111,214,160,.5); border-radius: 3px; padding: 1px 7px; }
.rh-grid { display: flex; gap: 18px; flex-wrap: wrap; }
.rh-cell { display: flex; flex-direction: column; line-height: 1.1; }
.rh-lab { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #6f93a6; }
.rh-val { font-size: 19px; color: #dff0f8; }
.rh-cell.warn .rh-val { color: var(--rg-warn); }
.rh-threat { min-width: 190px; }
.rh-threat-top { display: flex; justify-content: space-between; align-items: baseline; }
.rh-threat-lvl { font-size: 15px; color: var(--rg-warn); letter-spacing: 1px; }
.rh-threat-bar { height: 8px; margin-top: 4px; background: rgba(90,150,190,.14); border: 1px solid rgba(90,150,190,.25); border-radius: 2px; overflow: hidden; }
.rh-threat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3a86a8, var(--rg-warn)); transition: width .4s ease; }
.rh-crisis { display: inline-block; margin-top: 5px; font-size: 12px; letter-spacing: 1px; color: #ff5a5a; }
.rh-crisis.rh-lost { font-weight: 800; color: #fff; background: #b3121b; border-radius: 3px; padding: 2px 8px; letter-spacing: 1.5px; }
.rh-actions .kz-btn { min-height: 44px; }

/* ---- Karte + Detail ---- */
.region-body { display: grid; grid-template-columns: 1fr 320px; flex: 1; min-height: 0; }
.region-stage { position: relative; overflow: hidden; touch-action: none; background: #05090e; }
.region-map { width: 100%; height: 100%; display: block; cursor: grab; }
.region-map:active { cursor: grabbing; }
.region-mapctl { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.kz-btn--icon { min-width: 44px; min-height: 44px; font-size: 18px; }
.rg-threatglow { pointer-events: none; }

/* Funk-/Ortungslinien */
.rg-link { stroke: rgba(74,134,168,.28); stroke-width: 1.5; stroke-dasharray: 4 6; animation: rg-flow 3.5s linear infinite; }
.rg-link[data-state="verfügbar"], .rg-link[data-state="dringend"] { stroke: rgba(226,137,47,.42); }
.rg-link[data-state="abgeschlossen"] { stroke: rgba(90,200,140,.28); }
@keyframes rg-flow { to { stroke-dashoffset: -40; } }

/* Knoten — Form + Ring + Symbol + Anim + Text je Zustand (nicht nur Farbe) */
.rg-node { cursor: pointer; }
.rg-node:focus { outline: none; }
.rg-node:focus .rg-ring { stroke-width: 3; }
.rg-halo { fill: transparent; opacity: .0; }
.rg-ring { fill: rgba(8,16,22,.55); stroke: #4a86a8; stroke-width: 2; }
.rg-core { fill: #16323f; stroke: #8fd0e6; stroke-width: 1.5; }
.rg-sym { fill: #dff0f8; font-family: system-ui, sans-serif; }
.rg-label { fill: #cfe4ef; font-size: 15px; letter-spacing: 1px; }
.rg-sub { fill: #7fa6ba; font-size: 11px; letter-spacing: .5px; }

.rg-base .rg-ring { stroke: #9fd0e6; }
.rg-base .rg-core { fill: #1d3d4c; stroke: #bfe6f6; }

.rg-verfügbar .rg-ring { stroke: var(--rg-warn); }
.rg-verfügbar .rg-halo { fill: var(--rg-warn); opacity: .12; animation: rg-breathe 2.6s ease-in-out infinite; }
.rg-verfügbar .rg-core { fill: #3a2a12; stroke: var(--rg-warn); }

.rg-dringend .rg-ring { stroke: #ff6a3a; stroke-width: 3; }
.rg-dringend .rg-halo { fill: #ff6a3a; opacity: .18; animation: rg-pulse 1.3s ease-in-out infinite; }
.rg-dringend .rg-core { fill: #3d1810; stroke: #ff8a5a; }
.rg-dringend .rg-sub { fill: #ff8a5a; }

.rg-aktiv .rg-ring { stroke: #57c8ff; stroke-dasharray: 3 3; animation: rg-spin 8s linear infinite; transform-origin: center; }
.rg-aktiv .rg-halo { fill: #57c8ff; opacity: .14; }

.rg-abgeschlossen .rg-ring { stroke: #4fbf87; }
.rg-abgeschlossen .rg-core { fill: #13351f; stroke: #6fd6a0; }
.rg-abgeschlossen .rg-sub { fill: #6fd6a0; }

.rg-fehlgeschlagen .rg-ring { stroke: #c0555a; stroke-dasharray: 2 4; }
.rg-fehlgeschlagen .rg-core { fill: #34181a; stroke: #d67a7f; }

.rg-gesperrt { opacity: .5; }
.rg-gesperrt .rg-ring { stroke: #5a6a72; stroke-dasharray: 5 5; }
.rg-gesperrt .rg-core { fill: #12202b; stroke: #5a6a72; }
.rg-gesperrt .rg-sub { fill: #6a7c86; }

.rg-node.sel .rg-ring { stroke-width: 4; }
.rg-node.sel .rg-halo { opacity: .28; }

.rg-future { opacity: .8; }
.rg-future-ring { fill: rgba(10,18,26,.4); stroke: #5f7f92; stroke-dasharray: 2 5; }
.rg-future .rg-sub { fill: #6a8a9c; font-style: italic; }

/* 027 CP2: Teunz „Analyse läuft" — Signalimpuls, deutlich sichtbarer als ein stiller Zukunftskontakt */
.rg-analyzing { opacity: 1; }
.rg-analyzing .rg-future-ring { stroke: #57c8ff; stroke-dasharray: 3 3; }
.rg-analyzing .rg-sym { fill: #9fe0ff; }
.rg-analyzing .rg-sub { fill: #8fd0e6; font-style: normal; }
.rg-analyzing-sub { fill: #57c8ff !important; letter-spacing: 1px; }
.rg-analyzing-pulse { fill: #57c8ff; opacity: .14; transform-origin: center; animation: rg-analyzing-ping 1.8s ease-out infinite; }
@keyframes rg-analyzing-ping { 0% { opacity: .24; transform: scale(.7); } 70% { opacity: 0; transform: scale(1.5); } 100% { opacity: 0; transform: scale(1.5); } }
.rd-optional { color: #8fbcd2; font-style: italic; }

@keyframes rg-pulse { 0%,100% { opacity: .10; transform: scale(1); } 50% { opacity: .26; transform: scale(1.12); } }
@keyframes rg-breathe { 0%,100% { opacity: .08; } 50% { opacity: .18; } }
@keyframes rg-spin { to { transform: rotate(360deg); } }

/* ---- Missionsdetail ---- */
.region-detail {
  border-left: 1px solid rgba(90,150,190,.20); padding: 14px; overflow: auto;
  background: linear-gradient(180deg, rgba(14,26,35,.92), rgba(8,14,20,.92));
}
.rd-empty { color: #6f93a6; text-align: center; padding: 30px 8px; }
.rd-empty-mark { font-size: 40px; opacity: .4; }
.rd-head { display: flex; flex-direction: column; gap: 3px; border-bottom: 1px solid rgba(90,150,190,.18); padding-bottom: 8px; margin-bottom: 8px; }
.rd-head h3 { margin: 0; font-size: 20px; color: #dff0f8; letter-spacing: 1px; }
.rd-place { font-size: 12px; color: #7fa6ba; letter-spacing: 1px; text-transform: uppercase; }
.rd-state { align-self: flex-start; margin-top: 3px; font-size: 12px; padding: 2px 8px; border: 1px solid var(--rg-warn); color: var(--rg-warn); border-radius: 3px; }
.rd-state.rd-dringend { color: #ff8a5a; border-color: #ff8a5a; }
.rd-state.rd-abgeschlossen { color: #6fd6a0; border-color: #6fd6a0; }
.rd-state.rd-gesperrt { color: #6a7c86; border-color: #6a7c86; }
.rd-grid { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.rd-kv { display: flex; justify-content: space-between; font-size: 13px; }
.rd-k { color: #6f93a6; } .rd-v { color: #dff0f8; }
.rd-sec { margin: 10px 0; }
.rd-sec h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: #8fbcd2; }
.rd-sec ul { margin: 0; padding-left: 16px; }
.rd-sec li { font-size: 13px; color: #c4dae6; margin: 2px 0; }
.rd-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.rd-actions .kz-btn { min-height: 44px; }

/* Hover-Kurzinfo (Desktop) */
.region-tip { position: fixed; z-index: 60; transform: translate(-50%, -100%); background: rgba(10,18,26,.96);
  border: 1px solid rgba(143,208,230,.4); color: #dff0f8; font-size: 12px; padding: 4px 8px; border-radius: 3px; pointer-events: none; white-space: nowrap; }

/* Bottom-Sheet-Backdrop (nur Hochformat aktiv; Desktop/Quer: nie sichtbar). */
.rd-backdrop { display: none; }

/* ---- Zwischenfall-Alarm im Lagekopf (026 CP5) ---- */
.rh-incident-alert {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px; cursor: pointer;
  background: linear-gradient(180deg, rgba(80,30,16,.9), rgba(50,18,10,.9));
  border: 1px solid #e2892f; border-radius: 4px; color: #ffd9a8; font-family: inherit;
  animation: rg-alertpulse 1.6s ease-in-out infinite;
}
.rh-incident-alert:hover { border-color: #ffb060; }
.rhi-icon { font-size: 18px; color: #ff9a3a; }
.rhi-txt { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.rhi-txt b { font-size: 10px; letter-spacing: 1.5px; color: #ff9a3a; }
.rhi-txt span { font-size: 13px; color: #ffe6c8; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rhi-days { font-size: 15px; color: #ffd9a8; border: 1px solid rgba(226,137,47,.5); border-radius: 3px; padding: 1px 6px; }
@keyframes rg-alertpulse { 0%,100% { box-shadow: 0 0 0 rgba(226,137,47,0); } 50% { box-shadow: 0 0 16px rgba(226,137,47,.45); } }

/* ---- Zwischenfall-Overlay ---- */
.ri-overlay {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(4,8,12,.74); backdrop-filter: blur(2px); padding: 20px;
}
.ri-card {
  width: min(560px, 94%); max-height: 92%; overflow: auto;
  background: linear-gradient(180deg, #14232f, #0b141d);
  border: 1px solid #e2892f; border-radius: 6px; padding: 18px 20px;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.ri-head { border-bottom: 1px solid rgba(226,137,47,.3); padding-bottom: 8px; margin-bottom: 10px; }
.ri-tag { font-size: 11px; letter-spacing: 2px; color: #ff9a3a; }
.ri-head h3 { margin: 4px 0 2px; font-size: 22px; color: #ffe6c8; letter-spacing: .5px; }
.ri-place { font-size: 12px; color: #9ab0bd; letter-spacing: 1px; text-transform: uppercase; }
.ri-text { font-size: 14px; line-height: 1.5; color: #cfe0ea; margin: 0 0 14px; }
.ri-options { display: flex; flex-direction: column; gap: 8px; }
.ri-opt {
  display: flex; flex-direction: column; gap: 3px; min-height: 44px; padding: 9px 12px; cursor: pointer; text-align: left;
  background: rgba(30,52,66,.7); border: 1px solid rgba(143,208,230,.35); border-radius: 4px; color: #dff0f8; font-family: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.ri-opt:hover:not(:disabled) { border-color: #8fd0e6; background: rgba(40,66,82,.85); }
.ri-opt-label { font-size: 15px; color: #eaf6fc; }
.ri-opt-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }
.ri-cost { color: #9ab0bd; }
.ri-eff { color: #cfe0ea; } .ri-eff.pos { color: #6fd6a0; } .ri-eff.neg { color: #ff8a5a; }
.ri-opt--disabled, .ri-opt:disabled { opacity: .5; cursor: not-allowed; border-style: dashed; }
.ri-opt-warn { font-size: 11px; color: #ff8a5a; }
.ri-ignore { margin: 12px 0 0; font-size: 12px; font-style: italic; color: #9ab0bd; border-top: 1px dashed rgba(90,150,190,.2); padding-top: 8px; }
.ri-cardactions { display: flex; justify-content: flex-end; margin-top: 12px; }
.ri-cardactions .kz-btn { min-height: 44px; }

/* ---- Touch allgemein (jede Ausrichtung): größere Zielflächen, kompaktere Labels ---- */
@media (pointer: coarse) {
  .rh-grid { gap: 12px; }
  .rg-label { font-size: 17px; } .rg-sub { font-size: 13px; }
  .rhi-txt span { max-width: 130px; }
  .ri-card { width: 96%; }
}
/* ---- QUERFORMAT-Tablet behält 2 Spalten (Karte groß + Detail feste Mindestbreite) ---- */
@media (orientation: landscape) and (max-width: 1200px) {
  .region-body { grid-template-columns: 1fr 300px; }
}
/* ---- HOCHFORMAT: eine Spalte (Karte primär) + Missionsdetail als BOTTOM-SHEET ---- */
@media (orientation: portrait) {
  /* Lagekopf umbrechen, damit „Nächster Tag" NIE angeschnitten wird: Titel oben, Werte links, Aktion rechts, Bedrohungsbalken unten */
  .region-head { grid-template-columns: 1fr auto; grid-auto-rows: auto; gap: 8px 12px; align-items: start; }
  .rh-id { grid-column: 1 / -1; }
  .rh-grid { grid-column: 1; grid-row: 2; }
  .rh-actions { grid-column: 2; grid-row: 2; justify-self: end; align-self: start; flex-wrap: wrap; justify-content: flex-end; }
  .rh-threat { grid-column: 1 / -1; grid-row: 3; min-width: 0; }
  .region-body { grid-template-columns: 1fr; position: relative; }
  .region-detail.rd-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
    max-height: 82%; padding: 0; border-left: none; border-top: 2px solid var(--rg-warn);
    display: flex; flex-direction: column; overflow: hidden;   /* Sheet = Kopf(Greifleiste)/Scrollteil/Aktionsfuß */
    transform: translateY(103%); transition: transform .28s ease;
    box-shadow: 0 -14px 44px rgba(0,0,0,.62);
  }
  .region-detail.rd-sheet.open { transform: translateY(0); }
  .region-detail.rd-sheet::before {   /* Greifleiste als Sheet-Affordanz */
    content: ''; flex: 0 0 auto; display: block; width: 46px; height: 4px; border-radius: 3px;
    background: rgba(143,208,230,.55); margin: 6px auto 6px;
  }
  /* 027 CP0 3.2: Inhalt intern scrollbar; Aktionsfuß dauerhaft sichtbar, verdeckt keinen Text. */
  .region-detail.rd-sheet .rd-scroll {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 14px 10px; overscroll-behavior: contain;
  }
  .region-detail.rd-sheet .rd-actions {
    flex: 0 0 auto; margin-top: 0; flex-direction: row; gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(14,26,35,.98), rgba(8,14,20,.995));
    border-top: 1px solid rgba(90,150,190,.24); box-shadow: 0 -6px 18px rgba(0,0,0,.42);
  }
  .region-detail.rd-sheet .rd-actions .kz-btn { flex: 1 1 auto; min-height: 46px; }
  .region-detail.rd-sheet .rd-actions .rd-start { flex: 2 1 auto; }
  .rd-backdrop { display: block; position: absolute; inset: 0; z-index: 29; background: rgba(3,7,11,.58);
    opacity: 0; pointer-events: none; transition: opacity .28s ease; }
  .rd-backdrop.open { opacity: 1; pointer-events: auto; }
}
/* ---- Sehr schmal (Handy, auch quer): eine Spalte + Sheet-Verhalten ---- */
@media (max-width: 620px) {
  .region-body { grid-template-columns: 1fr; position: relative; }
  .region-detail.rd-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 82%;
    padding: 0; display: flex; flex-direction: column; overflow: hidden;
    border-left: none; border-top: 2px solid var(--rg-warn); transform: translateY(103%); transition: transform .28s ease; }
  .region-detail.rd-sheet.open { transform: translateY(0); }
  .region-detail.rd-sheet::before { content: ''; flex: 0 0 auto; display: block; width: 46px; height: 4px;
    border-radius: 3px; background: rgba(143,208,230,.55); margin: 6px auto 6px; }
  .region-detail.rd-sheet .rd-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto;
    -webkit-overflow-scrolling: touch; padding: 0 14px 10px; overscroll-behavior: contain; }
  .region-detail.rd-sheet .rd-actions { flex: 0 0 auto; margin-top: 0; flex-direction: row; gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(14,26,35,.98), rgba(8,14,20,.995));
    border-top: 1px solid rgba(90,150,190,.24); box-shadow: 0 -6px 18px rgba(0,0,0,.42); }
  .region-detail.rd-sheet .rd-actions .kz-btn { flex: 1 1 auto; min-height: 46px; }
  .region-detail.rd-sheet .rd-actions .rd-start { flex: 2 1 auto; }
  .rd-backdrop { display: block; position: absolute; inset: 0; z-index: 29; background: rgba(3,7,11,.58); opacity: 0; pointer-events: none; transition: opacity .28s; }
  .rd-backdrop.open { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .region.tone-crisis, .rg-link, .rg-verfügbar .rg-halo, .rg-dringend .rg-halo, .rg-aktiv .rg-ring, .rh-incident-alert, .rg-analyzing-pulse { animation: none !important; }
}
