/* ============================================================
   WARPLAN — Replay Analysis Dashboard
   Extends warcal.css patterns (VT323 console + green-bar paper).
   ============================================================ */

/* ── Global utility ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── CSS variables: team colours + webapp tokens ────────────────────────── */
:root {
  /* These are used by both warplan.js inline styles and ef-* table classes */
  --team0:    #4ea8de;
  --team0-bg: rgba(78, 168, 222, 0.12);
  --team1:    #e06050;
  --team1-bg: rgba(224, 96, 80, 0.12);

  /* generic text/border tokens so copied modules work without a separate stylesheet */
  --text:       var(--ink-black);
  --text-muted: #888;
  --surface:    var(--paper-white);
  --border:     #bbb;
}

/* ── Page layout (mirrors page-warcal) ──────────────────────────────────── */

body.page-warplan {
  --binder-image: url("../src/empty.png");
  overflow-y: auto;
  overflow-x: auto;
}

.warplan-main {
  margin-top: 0;
  padding: 56px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: 'VT323', monospace;
  text-transform: uppercase;
}

/* ── Loader console extras (base comes from .warcal-console) ────────────── */

/* Console header: title + help button on same row */
.warplan-console .console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.how-to-btn {
  font-size: 0.9rem;
  height: 28px;
  padding: 0 10px;
  flex-shrink: 0;
}

/* ── How-To Popover ─────────────────────────────────────────────────────── */

.warplan-howto-popover {
  width: min(560px, calc(100vw - 24px));
  transform: rotate(-0.3deg);
}

.warplan-howto-popover .howto-body {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #1a1a1a;
  position: relative;
  z-index: 1;
}

.warplan-howto-popover .howto-path {
  margin: 8px 0;
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.07);
  border-left: 3px solid #555;
  font-size: 12px;
  word-break: break-all;
}

.warplan-console {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  z-index: 10;
}

/* Two-column drop-zone row + gemini key row below */
.warplan-input-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 12px;
}

/* ── Drop zones ─────────────────────────────────────────────────────────── */

.warplan-drop-zone {
  flex: 1 1 300px;
  min-height: 80px;
  border: 2px dashed #888;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
}

.warplan-drop-zone:hover,
.warplan-drop-zone.dragover {
  border-color: #444;
  background: rgba(255, 255, 255, 0.14);
}

.warplan-drop-zone.loaded {
  border-color: #00aa44;
  background: rgba(0, 170, 68, 0.06);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  text-align: center;
  pointer-events: none;
}

.drop-zone-label {
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: #444;
}

.drop-zone-hint {
  font-size: 0.85rem;
  color: #888;
}

.drop-zone-status {
  font-size: 0.9rem;
  color: #2a2a2a;
  letter-spacing: 1px;
}

.status-ok  { color: #00aa44; }
.status-err { color: #cc2200; }

/* Session status: console-style dark box when a message is present */
#session-status:not(:empty) {
  display: inline-block;
  background: #111;
  border: 1px solid #444;
  padding: 1px 8px;
  font-size: 0.78rem;
  letter-spacing: 1px;
  color: #ccc;
}
#session-status.status-ok:not(:empty)  { color: #7eff8c; }
#session-status.status-err:not(:empty) { color: #ff6644; }

/* ── Gemini key row ─────────────────────────────────────────────────────── */

.warplan-gemini-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #999;
  margin-top: 4px;
}

.console-label-text {
  font-family: 'VT323', monospace;
  font-size: 1rem;
  color: #444;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* ── Action row: run button + progress ──────────────────────────────────── */

.warplan-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #999;
}

.push-button-large {
  font-size: 1.3rem;
  padding: 0 24px;
  height: 42px;
}

.push-button-large:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.warplan-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.progress-bar-track {
  flex: 0 0 auto;
  width: 50%;
  max-width: 300px;
  height: 14px;
  background: #888;
  border: 2px solid #666;
  border-top-color: #999;
  border-left-color: #999;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(to right, #00aa44, #00cc55);
  transition: width 0.25s ease;
  box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.3);
}

.warplan-error {
  width: 100%;
  margin-top: 8px;
  color: #cc2200;
  font-size: 0.95rem;
  letter-spacing: 1px;
  padding: 6px 0;
}

/* ── Session snapshot row ───────────────────────────────────────────────── */

.warplan-session-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #999;
  margin-top: 8px;
}

.session-paste-input {
  flex: 1 1 260px;
  min-width: 180px;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

/* ── Results wrapper ────────────────────────────────────────────────────── */

#warplan-results {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  margin-top: -2px;          /* slight overlap with console bottom */
}

/* ── Match banner ───────────────────────────────────────────────────────── */

.warplan-match-banner {
  background-color: #333;
  border: 2px solid #aaa;
  border-top: none;
  color: #e0e0e0;
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  letter-spacing: 1.5px;
  padding: 8px 16px;
}

.match-banner-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.match-info-piece  { white-space: nowrap; }
.match-info-sep    { color: #888; }
.match-info-player { font-weight: 700; white-space: nowrap; }

/* ── Tab navigation ─────────────────────────────────────────────────────── */

.warplan-tab-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background-color: var(--panel-grey);
  background-image: linear-gradient(to bottom, var(--panel-grey), #8e8e8e);
  border: 2px solid var(--panel-border);
  border-top: none;
  border-bottom: none;
  padding: 8px 16px;
  box-sizing: border-box;
}

.warplan-tab-btn {
  font-size: 1rem;
  height: 32px;
  padding: 0 16px;
}

.warplan-tab-btn.active {
  background-color: var(--ink-black);
  color: var(--green-bar);
  border-color: var(--ink-black);
  border-bottom-color: var(--ink-black);
  border-right-color: var(--ink-black);
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */

.warplan-tab-panel {
  width: 100%;
}

/* ── Analytics scrubber bar ─────────────────────────────────────────────── */

.analytics-scrubber-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 10px 16px;
  background-color: var(--panel-grey);
  background-image: linear-gradient(to bottom, var(--panel-grey), #8e8e8e);
  border: 2px solid var(--panel-border);
  border-top: none;
  box-sizing: border-box;
  width: 100%;
  /* Hidden until analysis is ready */
}

.scrubber-play-btn {
  font-size: 1rem;
  height: 32px;
  padding: 0 14px;
  flex-shrink: 0;
  white-space: nowrap;
}

.scrubber-time-label {
  font-family: 'VT323', monospace;
  font-size: 1.05rem;
  color: var(--ink-black);
  letter-spacing: 1.5px;
  white-space: nowrap;
  min-width: 42px;
  text-align: right;
}

.scrubber-time-end {
  text-align: left;
  opacity: 0.65;
}

.scrubber-slider {
  flex: 1 1 200px;
  min-width: 120px;
  height: 6px;
  cursor: pointer;
  accent-color: var(--ink-black);
  /* Skeuomorphic track overrides where supported */
  -webkit-appearance: none;
  appearance: none;
  background: #888;
  border: 2px solid #666;
  border-top-color: #999;
  border-left-color: #999;
  border-radius: 0;
  outline: none;
}

.scrubber-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 22px;
  background: linear-gradient(to bottom, #e8e0c8, #b8b090);
  border: 2px solid #555;
  border-bottom-color: #999;
  border-right-color: #999;
  cursor: pointer;
}

.scrubber-slider::-moz-range-thumb {
  width: 14px;
  height: 22px;
  background: linear-gradient(to bottom, #e8e0c8, #b8b090);
  border: 2px solid #555;
  border-bottom-color: #999;
  border-right-color: #999;
  cursor: pointer;
  border-radius: 0;
}

/* ── Live roster table (inside analytics tab) ────────────────────────────── */

#analytics-roster-outer {
  margin-top: 0;
  border-top: none;
}

#analytics-roster:empty {
  display: none;
}

#analytics-roster-outer:has(#analytics-roster:empty) {
  display: none;
}

#analytics-roster {
  padding: 0 60px 16px;
}

.roster-table {
  min-width: 0;
  width: 100%;
}

.roster-table td {
  background: transparent !important;
  padding: 3px 10px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.roster-count {
  font-family: 'VT323', monospace;
  font-size: 0.95rem;
  color: #555;
  letter-spacing: 0.5px;
  margin-left: 3px;
}

.roster-total {
  font-family: 'VT323', monospace;
  font-size: 0.9rem;
  font-weight: normal;
  color: #777;
  letter-spacing: 0.5px;
}

/* ── Digital game-time clock ─────────────────────────────────────────────── */

@font-face {
  /* Fallback: we use VT323 + letter-spacing trick for 7-seg feel.
     A true digital-7 font can be dropped in here as a custom font-face
     by placing digital-7.woff2 in src/ and updating the src URL.           */
  font-family: 'Digital7Fallback';
  src: local('Courier New');
}

.warplan-clock {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  background: #0a0e06;
  border: 3px solid #2a2e24;
  box-shadow:
    inset 0 0 18px rgba(0, 0, 0, 0.85),
    0 4px 20px rgba(0, 0, 0, 0.6),
    0 0 0 1px #444;
  padding: 10px 20px 8px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  /* Prevent text selection while playing */
  user-select: none;
  pointer-events: none;
}

.clock-label {
  font-family: 'VT323', monospace;
  font-size: 0.75rem;
  letter-spacing: 3px;
  color: #3a5c2a;
  text-transform: uppercase;
}

.clock-digits {
  font-family: 'VT323', monospace;
  font-size: 3.6rem;
  line-height: 1;
  letter-spacing: 6px;
  color: #7fdb5a;
  text-shadow:
    0 0 6px rgba(127, 219, 90, 0.85),
    0 0 14px rgba(127, 219, 90, 0.45),
    0 0 30px rgba(127, 219, 90, 0.2);
  /* Simulate dim "ghost" segments by layering a faint copy */
  position: relative;
}

/* Ghost segments overlay using ::before */
.clock-digits::before {
  content: attr(data-ghost);
  position: absolute;
  inset: 0;
  color: #1a2e10;
  text-shadow: none;
  pointer-events: none;
  /* Will be populated via JS if desired; harmless if not set */
}

/* ── Analytics: chart sections ──────────────────────────────────────────── */

.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-family: 'VT323', monospace;
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--ink-black);
  padding: 10px 0 14px;
  border-bottom: 1px solid #ccc;
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.legend-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-swatch {
  display: inline-block;
  width: 28px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-sep {
  color: #aaa;
  margin: 0 4px;
}

.chart-section {
  margin-bottom: 32px;
}

.chart-title {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  letter-spacing: 3px;
  color: var(--ink-black);
  margin-bottom: 6px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
}
.chart-title[title] { cursor: help; }

.chart-host {
  width: 100%;
  overflow-x: auto;
}

/* SVG chart element styles (applied via class selectors inside SVG) */
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}

/* Using CSS classes for SVG children */
svg .chart-grid {
  stroke: rgba(0, 0, 0, 0.10);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

svg .chart-grid-v {
  stroke: rgba(0, 0, 0, 0.07);
  stroke-width: 1;
}

svg .chart-axis {
  stroke: #888;
  stroke-width: 1.5;
}

svg .chart-y-label {
  font-size: 11px;
  font-family: 'VT323', monospace;
  fill: #888;
  dominant-baseline: middle;
  text-anchor: end;
}

svg .chart-x-label {
  font-size: 11px;
  font-family: 'VT323', monospace;
  fill: #888;
  text-anchor: middle;
}

svg .chart-axis-label {
  font-size: 12px;
  font-family: 'VT323', monospace;
  fill: #666;
  text-anchor: middle;
  letter-spacing: 1.5px;
}

/* ── Chart hover tooltip ─────────────────────────────────────────────────── */
.chart-tip {
  position: fixed;
  z-index: 9999;
  background: #1a1a1a;
  color: #f0f0f0;
  font-family: 'VT323', monospace;
  font-size: 15px;
  letter-spacing: 1px;
  padding: 4px 10px 3px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.chart-tip.hidden { display: none; }

/* ── Event feed table (ef-* classes, shared by event timetable) ─────────── */

.ef-section-title {
  font-family: 'VT323', monospace;
  font-size: 1.3rem;
  letter-spacing: 3px;
  color: var(--ink-black);
  padding: 14px 0 6px;
  margin: 0;
  text-transform: uppercase;
}

.ef-deploy-title { color: #2266aa; }
.ef-battle-title { color: #333;    }

.ef-kill-note {
  font-size: 0.85rem;
  color: #888;
  letter-spacing: 1px;
  font-family: 'VT323', monospace;
}

.ef-wrapper {
  overflow-x: auto;
  margin-bottom: 24px;
}

.ef-player-banner {
  font-family: 'VT323', monospace;
  font-size: 1.05rem;
  letter-spacing: 1.5px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border-left: 3px solid currentColor;
  margin-bottom: 4px;
  margin-top: 12px;
}

.ef-table {
  min-width: 600px;
}

.ef-player-header {
  letter-spacing: 2px;
  padding: 6px 10px;
  font-size: 1rem;
  text-align: center;
}

.ef-sub {
  font-size: 0.85rem;
  font-weight: normal;
  color: #555;
  padding: 2px 10px;
  border-bottom: 1px solid #ddd;
}

.ef-time-hdr {
  font-size: 0.85rem;
  font-weight: normal;
  padding: 2px 10px;
  border-bottom: 1px solid #ddd;
}

.ef-time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #555;
  padding: 4px 10px;
  min-width: 50px;
}

.ef-time-remaining {
  display: block;
}

.ef-replay-time {
  display: block;
  color: #999;
  font-size: 0.8em;
}

.ef-active-unit {
  padding: 4px 10px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ef-transport-cell {
  /* color: #666; */
  padding: 4px 10px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ef-buy-unit  { background: rgba(78, 168, 222, 0.06); }
.ef-kill-unit { background: rgba(224, 96, 80, 0.08);  }

.ef-buy-icon      { color: #2266aa; margin-right: 5px; font-size: 0.75rem; }
.ef-kill-icon     { color: #aa2200; margin-right: 5px; font-size: 0.85rem; }
.ef-transport-sep { color: #888; margin: 0 5px; font-size: 0.8rem; font-weight: bold; }

/* Veterancy glyphs */
.vet-glyph        { margin-left: 4px; font-size: 0.7rem; letter-spacing: -1px; vertical-align: baseline; }
.vet-0            { color: #777; }
.vet-1            { color: #a8a060; }
.vet-2            { color: #c0a030; }
.vet-3            { color: #d4a017; }

/* Row backgrounds */
tr.ef-kill td { opacity: 0.88; }

.ef-empty {
  padding: 16px 10px;
  color: #888;
  font-size: 1rem;
  text-align: center;
}

/* Deployment table total row */
.deploy-total-row {
  font-weight: bold;
  border-top: 2px solid #bbb;
  background: var(--green-bar);
}

.deploy-total-row td { padding: 6px 10px; }

/* Align numeric columns in deploy table */
.td-S, .td-Lhard, .td-Lsoft, .td-Lair, .td-I {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Results tab: responsive paper (no fixed 1080px min-width) ──────────── */

#tab-results .paper-outer {
  min-width: 0;
  max-width: 100%;
  margin-top: 0;
}

#tab-results .paper-container {
  min-width: 0;
}

/* Results tab: margin between the two paper sections */
#results-events .paper-outer {
  margin-top: 24px !important;
}

/* Scrollable inner wrapper — table overflows here, not through the paper */
.ef-table-scroll {
  overflow-x: auto;
  margin-bottom: 8px;
}

/* Suppress the 5×green-bar row striping on results tables */
.ef-no-stripe {
  table-layout: auto;
}

.ef-no-stripe tbody tr {
  background-color: transparent !important;
  height: auto;
}

.ef-no-stripe tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.04) !important;
}

/* Player banner inside the paper — give a subtle team-tinted background */
.ef-player-banner {
  border-radius: 2px;
}
