/* train-map.css: the Live train map widget (cms/widgets/train_map.py). Rail colours are fixed (they mean railroads);
   frames, buttons and text follow the theme (--p primary, --i ink, --s surface, --radius). */
.tw-train-map { --tm-ink: var(--i, #1A1A1A); --tm-surf: var(--s, #fff); --tm-line: color-mix(in srgb, var(--tm-ink) 14%, transparent);
  --tm-soft: color-mix(in srgb, var(--tm-ink) 5%, var(--tm-surf)); --tm-muted: color-mix(in srgb, var(--tm-ink) 62%, var(--tm-surf));
  --tm-head: var(--p, #1C2B3A); --tm-red: #B11226; --tm-green: #2E6B4F; --tm-gold: #C4A35A; }
.tw-train-map .tm-intro { margin-bottom: 18px; }
.tw-train-map .tm-intro p { max-width: 760px; }
.tw-train-map .tm-outer { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.tm-live { position: relative; background: #E9EEF1; border-radius: var(--radius, 10px); overflow: hidden; border: 1px solid var(--tm-line);
  box-shadow: 0 18px 40px -30px rgba(0,0,0,.45); color: var(--tm-ink); font-size: 16px; line-height: 1.45; }
.tm-live .lv-mapwrap { position: relative; min-height: 0; }
.tm-live .lv-map { position: absolute; inset: 0; }
.tm-compact { height: var(--tm-h, 460px); }
.tm-compact .lv-mapwrap { position: absolute; inset: 0; }
.tm-badge { position: absolute; left: 10px; bottom: 10px; z-index: 3; margin: 0; background: rgba(19,32,44,.9); color: #fff; padding: 7px 12px; border-radius: 6px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.live-full.tm-live { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: var(--tm-h, calc(100vh - 140px)); min-height: 480px; }
.tm-live .live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #3FBF7F; flex: none; animation: tm-pulse 2s infinite; }
@keyframes tm-pulse { 0% { box-shadow: 0 0 0 0 rgba(63,191,127,.7); } 70% { box-shadow: 0 0 0 8px rgba(63,191,127,0); } 100% { box-shadow: 0 0 0 0 rgba(63,191,127,0); } }
.tm-live .lv-side { display: flex; flex-direction: column; min-height: 0; background: var(--tm-surf); border-right: 1px solid var(--tm-line); }
.tm-live .lv-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tm-live .lv-head { padding: 14px 16px 10px; background: var(--tm-head); color: #EEF1F4; }
.tm-live .lv-title { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 1.45rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: #fff; }
.tm-live .lv-sum { margin: 0; font-size: .95rem; }
.tm-live .lv-sum b { color: #fff; }
.tm-live .lv-updated { font-size: .82rem; opacity: .75; }
.tm-live .lv-ops { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 4px; }
.tm-live .lv-op { display: inline-flex; align-items: center; gap: 6px; font: 700 .82rem/1 inherit; font-family: inherit; padding: 7px 9px; border-radius: 4px; border: 1px solid var(--tm-line); background: var(--tm-soft); color: var(--tm-muted); cursor: pointer; }
.tm-live .lv-op i { width: 11px; height: 11px; border-radius: 50%; opacity: .35; }
.tm-live .lv-op span { font-weight: 400; }
.tm-live .lv-op.on { color: var(--tm-ink); background: var(--tm-surf); border-color: color-mix(in srgb, var(--tm-ink) 30%, transparent); }
.tm-live .lv-op.on i { opacity: 1; }
.tm-live .lv-op.down span { color: var(--tm-red); }
.tm-live .lv-tools { padding: 8px 12px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--tm-line); }
.tm-live .lv-q { font: inherit; padding: 9px 11px; border: 2px solid var(--tm-line); border-radius: 4px; background: var(--tm-soft); color: var(--tm-ink); width: 100%; box-sizing: border-box; }
.tm-live .lv-q:focus { border-color: var(--p, #1C2B3A); outline: none; background: var(--tm-surf); }
.tm-live .lv-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .88rem; color: var(--tm-muted); }
.tm-live .lv-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tm-live .lv-hide { position: absolute; left: -9999px; }
.tm-live .lv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.tm-live .lv-list li button { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--tm-line); padding: 9px 12px; font: inherit; color: inherit; cursor: pointer; }
.tm-live .lv-list li button:hover, .tm-live .lv-list li button[aria-current] { background: var(--tm-soft); }
.tm-live .lv-list i { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.08); }
.tm-live .lv-t { flex: 1; min-width: 0; }
.tm-live .lv-t b { display: block; font-size: .98rem; line-height: 1.2; }
.tm-live .lv-t small { display: block; color: var(--tm-muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-live .lv-d { font-size: .76rem; font-weight: 700; padding: 4px 6px; border-radius: 3px; background: #EEE; color: #555; white-space: nowrap; }
.tm-live .ok { color: var(--tm-green); } .tm-live .lv-d.ok { background: #E3F0E8; }
.tm-live .warn { color: #8A5A00; } .tm-live .lv-d.warn { background: #FBF0D5; }
.tm-live .bad { color: var(--tm-red); } .tm-live .lv-d.bad { background: #FBE6E8; }
.tm-live .lv-empty { padding: 16px; color: var(--tm-muted); }
.tm-live .lv-detail { display: none; overflow-y: auto; flex: 1; min-height: 0; padding: 12px 16px 22px; }
.tm-live.lv-has-detail .lv-detail { display: block; }
.tm-live.lv-has-detail .lv-list, .tm-live.lv-has-detail .lv-tools, .tm-live.lv-has-detail .lv-ops { display: none; }
.tm-live .lv-back { background: none; border: 0; padding: 4px 0; font: inherit; font-weight: 700; color: var(--p, #234A6E); cursor: pointer; }
.tm-live .lv-opname { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tm-muted); }
.tm-live .lv-opname i { width: 11px; height: 11px; border-radius: 50%; }
.tm-live .lv-detail h2 { font-size: 1.5rem; margin: 0 0 4px; }
.tm-live .lv-route { font-weight: 700; margin: 0 0 10px; }
.tm-live .lv-warn { background: #FBF0D5; border-left: 4px solid var(--tm-gold); padding: 8px 10px; font-size: .92rem; }
.tm-live .lv-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 16px; font-size: .95rem; }
.tm-live .lv-kv dt { color: var(--tm-muted); }
.tm-live .lv-kv dd { margin: 0; font-weight: 700; }
.tm-live .lv-alerts p { background: #FBECEE; border-left: 4px solid var(--tm-red); padding: 8px 10px; font-size: .9rem; margin: 0 0 8px; }
.tm-live .lv-detail h3 { font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.tm-live .lv-stops { list-style: none; margin: 0 0 16px 6px; padding: 0 0 0 18px; border-left: 3px solid var(--tm-line); }
.tm-live .lv-stops li { position: relative; padding: 5px 0 7px 6px; display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.tm-live .lv-stops li::before { content: ""; position: absolute; left: -27px; top: 9px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 3px solid #8B8D86; }
.tm-live .lv-stops li.done { color: #8B8D86; }
.tm-live .lv-stops li.done::before { background: #8B8D86; }
.tm-live .lv-stops li.cur { font-weight: 700; }
.tm-live .lv-stops li.cur::before { border-color: var(--tm-gold); background: var(--tm-gold); box-shadow: 0 0 0 4px rgba(196,163,90,.3); }
.tm-live .lv-sn small { color: #8B8D86; font-weight: 400; }
.tm-live .lv-st { white-space: nowrap; text-align: right; }
.tm-live .lv-st em { font-style: normal; font-weight: 700; }
.tm-live .small { font-size: .85rem; color: var(--tm-muted); }
.tm-live .lv-note { padding: 9px 12px; font-size: .82rem; color: var(--tm-muted); border-top: 1px solid var(--tm-line); background: var(--tm-soft); margin: 0; }
.tm-live .lv-banner { position: absolute; left: 50%; transform: translateX(-50%); top: 10px; z-index: 3; width: max-content; max-width: min(620px, calc(100% - 110px)); background: rgba(19,32,44,.92); color: #F0ECE2; font-size: .84rem; line-height: 1.35; padding: 8px 12px; border-radius: 4px; border-left: 4px solid var(--tm-red); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.tm-compact .lv-banner { max-width: calc(100% - 20px); font-size: .78rem; }
.tm-live .lv-mapbtns { position: absolute; left: 10px; bottom: 34px; z-index: 3; display: flex; gap: 6px; }
.tm-live .lv-mapbtns button { font: inherit; font-size: .86rem; font-weight: 700; padding: 8px 11px; border-radius: 4px; border: 1px solid #B8B3A6; background: #fff; color: #1A1A1A; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.tm-live .lv-mapbtns button[aria-pressed="true"] { background: #1C2B3A; border-color: #1C2B3A; color: #fff; }
.tm-live .lv-fallback { display: none; position: absolute; inset: 0; place-content: center; text-align: center; padding: 24px; color: #555; z-index: 2; background: #E9EEF1; }
.tm-live.lv-failed .lv-fallback { display: grid; }
.tm-live .lv-tabs { display: none; }
.tm-live .lv-pop ul { margin: 6px 0 0; padding-left: 1.1em; font-size: .9rem; }
.tm-live .lv-pop em { font-style: normal; font-weight: 700; }
.tm-live .maplibregl-popup-content { font: 15px/1.4 system-ui, sans-serif; color: #1A1A1A; border-radius: 8px; padding: 12px 14px; }
@media (max-width: 900px) {
  .live-full.tm-live { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: calc(100vh - 120px); height: calc(100dvh - 120px); }
  .live-full.tm-live[data-view="list"] { grid-template-rows: minmax(0, 1fr); }
  .tm-live .lv-tabs { display: flex; gap: 6px; padding: 8px 10px; background: var(--tm-soft); border-bottom: 1px solid var(--tm-line); }
  .tm-live .lv-tabs button { flex: 1; font: inherit; font-weight: 700; padding: 8px; border-radius: 4px; border: 2px solid var(--tm-head); background: var(--tm-surf); color: var(--tm-ink); }
  .tm-live .lv-tabs button[aria-pressed="true"] { background: var(--tm-head); color: #fff; }
  .live-full.tm-live[data-view="map"] .lv-body { display: none; }
  .live-full.tm-live[data-view="list"] .lv-mapwrap { display: none; }
  .live-full.tm-live[data-view="map"].lv-has-detail .lv-body { display: flex; max-height: 42vh; }
  .tm-live .lv-side { border-right: 0; }
  .tm-live .lv-head { padding: 9px 12px; }
  .tm-live .lv-title { font-size: 1.2rem; }
  .tm-live .lv-banner { max-width: calc(100% - 64px); left: 10px; transform: none; }
  .tw-train-map .tm-outer { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) { .tm-live .live-dot { animation: none; } }
