/* ============================================================
   C2 / SIM — Tactical air-strike visualization
   Aesthetic: command-and-control glass display
   ============================================================ */

:root {
  /* surfaces */
  --abyss:   #04080e;
  --bg-0:    #060d16;
  --bg-1:    #0a1623;
  --glass:   rgba(8, 20, 30, 0.62);
  --glass-2: rgba(10, 26, 38, 0.78);

  /* lines / structure */
  --line:    rgba(86, 196, 224, 0.22);
  --line-2:  rgba(86, 196, 224, 0.10);

  /* accents */
  --blue:    #3fe0d4;   /* friendly force / aircraft */
  --blue-2:  #5fb8ff;
  --mint:    #66f0c0;   /* third friendly flight */
  --red:     #ff3b46;   /* hostile / targets */
  --amber:   #ffb000;   /* warnings / weapon release */
  --green:   #5dffa0;   /* nominal / confirmed */

  /* ink */
  --ink:     #cfe9f1;
  --ink-dim: #7da4b3;
  --ink-mut: #4d6b78;

  --mono: 'Share Tech Mono', ui-monospace, monospace;
  --disp: 'Chakra Petch', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--abyss);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  height: 100dvh; /* tracks the mobile URL bar showing/hiding */
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- atmospheric FX ---------- */
.fx-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}
.fx-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 29;
  background: radial-gradient(120% 90% at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.62) 100%);
}

/* ---------- frame corner brackets ---------- */
.frame {
  position: absolute;
  width: 34px;
  height: 34px;
  z-index: 25;
  pointer-events: none;
  border: 2px solid var(--blue);
  opacity: 0.55;
  filter: drop-shadow(0 0 6px rgba(63, 224, 212, 0.5));
}
.frame--tl { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.frame--tr { top: 12px; right: 12px; border-left: 0; border-bottom: 0; }
.frame--bl { bottom: 12px; left: 12px; border-right: 0; border-top: 0; }
.frame--br { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }

/* ---------- top command bar ---------- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 30px 12px;
  background: linear-gradient(180deg, rgba(4, 10, 18, 0.92), rgba(4, 10, 18, 0));
}
.topbar__id { display: flex; align-items: center; gap: 12px; }
.topbar__id .glyph {
  font-size: 26px;
  color: var(--blue);
  filter: drop-shadow(0 0 8px rgba(63, 224, 212, 0.6));
}
.topbar__title {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 2.5px;
  font-size: 14px;
  color: var(--ink);
}
.topbar__sub {
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 1.4px;
  margin-top: 2px;
}
.topbar__sub b { color: var(--blue); }

.classbar {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 11px;
  color: var(--amber);
  padding: 6px 20px;
  background: #110b02;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-image: repeating-linear-gradient(45deg, var(--amber) 0 9px, #1a1206 9px 18px) 4;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.45);
  white-space: nowrap;
}

.topbar__clocks { display: flex; gap: 22px; }
.clock { text-align: right; }
.clock__lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--ink-mut);
}
.clock__val {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 22px;
  color: var(--blue);
  text-shadow: 0 0 12px rgba(63, 224, 212, 0.45);
  line-height: 1;
}
.clock__val--dim { color: var(--ink-dim); text-shadow: none; font-size: 18px; }

/* ---------- side panels (glass) ---------- */
.panel {
  position: absolute;
  z-index: 18;
  width: 290px;
  padding: 14px 16px 16px;
  background: linear-gradient(160deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line);
  backdrop-filter: blur(7px);
  box-shadow:
    inset 0 0 0 1px rgba(63, 224, 212, 0.05),
    0 10px 40px rgba(0, 0, 0, 0.5);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.panel--left  { left: 18px;  top: 88px; }
.panel--right { right: 18px; top: 88px; width: 320px; bottom: 118px; display: flex; flex-direction: column; }

.panel__head {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 2.5px;
  font-size: 12px;
  color: var(--ink);
  padding-bottom: 9px;
  margin-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.panel__head .bullet { color: var(--blue); margin-right: 6px; }
.panel__sub {
  font-size: 9.5px;
  letter-spacing: 2px;
  color: var(--ink-mut);
  margin: 12px 0 7px;
}

.oob { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.unit {
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--ink-mut);
  background: rgba(6, 16, 24, 0.5);
  padding: 8px 10px;
  transition: border-color 0.3s, background 0.3s;
}
.unit.is-active   { border-left-color: var(--blue); background: rgba(10, 30, 38, 0.6); }
.unit.is-attack   { border-left-color: var(--amber); }
.unit.is-rtb      { border-left-color: var(--blue-2); }
.unit.is-locked   { border-left-color: var(--amber); }
.unit.is-dead     { border-left-color: var(--red); opacity: 0.72; }

.unit__row { display: flex; align-items: center; gap: 8px; }
.unit__icon { font-size: 13px; }
.unit__icon--blue { color: var(--blue); }
.unit__icon--mint { color: var(--mint); }
.unit__icon--red  { color: var(--red); }
.unit__call {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 1.5px;
  font-size: 13px;
  flex: 1;
}
.unit__meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  color: var(--ink-dim);
  margin-top: 5px;
}
.unit__tgt b { color: var(--red); }
.unit__tele {
  font-size: 10px;
  color: var(--ink-mut);
  margin-top: 5px;
  letter-spacing: 0.5px;
}

.pill {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 1.4px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  color: var(--ink-dim);
  white-space: nowrap;
}
.pill--neutral { color: var(--ink-mut); }
.pill[data-tone="air"]   { color: var(--blue);  box-shadow: 0 0 10px rgba(63, 224, 212, 0.25); }
.pill[data-tone="atk"]   { color: var(--amber); box-shadow: 0 0 10px rgba(255, 176, 0, 0.25); }
.pill[data-tone="rtb"]   { color: var(--blue-2); }
.pill[data-tone="lock"]  { color: var(--amber); animation: blink 0.9s steps(2) infinite; }
.pill[data-tone="dead"]  { color: var(--red);  box-shadow: 0 0 10px rgba(255, 59, 70, 0.3); }
.pill[data-tone="ok"]    { color: var(--green); }

@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- event log ---------- */
.eventlog {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.eventlog::-webkit-scrollbar { width: 6px; }
.eventlog::-webkit-scrollbar-thumb { background: var(--line); }
.eventlog li {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(86, 196, 224, 0.07);
  animation: logIn 0.35s ease both;
}
.eventlog .ev-t { color: var(--ink-mut); }
.eventlog .ev-x { color: var(--ink-dim); letter-spacing: 0.3px; }
.eventlog li[data-sev="info"]  .ev-x { color: var(--blue); }
.eventlog li[data-sev="warn"]  .ev-x { color: var(--amber); }
.eventlog li[data-sev="hit"]   .ev-x { color: var(--red); font-weight: 700; }
.eventlog li[data-sev="ok"]    .ev-x { color: var(--green); }
@keyframes logIn { from { opacity: 0; transform: translateX(8px); } }

/* ---------- transport / timeline ---------- */
.transport {
  position: absolute;
  left: 18px; right: 18px; bottom: 16px;
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: linear-gradient(160deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line);
  backdrop-filter: blur(7px);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.transport__btns { display: flex; gap: 8px; }
.btn {
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  background: rgba(6, 16, 24, 0.6);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.18s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 14px rgba(63, 224, 212, 0.3); }
.btn--primary { color: var(--blue); border-color: rgba(63, 224, 212, 0.4); }
.m-toggle { display: none; } /* mobile-only panel toggles */

.timeline { flex: 1; }
.timeline__track { position: relative; height: 26px; display: flex; align-items: center; }
.scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--blue) var(--prog, 0%), rgba(86,196,224,0.16) var(--prog, 0%));
  outline: none;
  cursor: pointer;
}
.scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 4px; height: 20px;
  background: var(--blue);
  box-shadow: 0 0 12px rgba(63, 224, 212, 0.9);
  cursor: pointer;
}
.scrubber::-moz-range-thumb {
  width: 4px; height: 20px; border: 0; border-radius: 0;
  background: var(--blue); box-shadow: 0 0 12px rgba(63, 224, 212, 0.9);
}
.timeline__ticks { position: absolute; inset: 0; pointer-events: none; }
.timeline__ticks .tick {
  position: absolute;
  top: 50%;
  width: 2px; height: 11px;
  transform: translate(-50%, -50%);
  background: var(--amber);
  opacity: 0.7;
}
.timeline__ticks .tick[data-k="hit"] { background: var(--red); height: 13px; }
.timeline__labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--ink-mut);
  margin-top: 4px;
  letter-spacing: 1px;
}
.timeline__phase {
  color: var(--blue);
  font-family: var(--disp);
  letter-spacing: 2px;
  font-weight: 600;
}

.transport__speed { display: flex; gap: 4px; }
.spd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: rgba(6, 16, 24, 0.6);
  color: var(--ink-dim);
  cursor: pointer;
  transition: all 0.18s;
}
.spd:hover { color: var(--ink); }
.spd.is-active {
  color: var(--abyss);
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 700;
}

/* ---------- start gate (unlocks audio + syncs playback from t=0) ---------- */
.start {
  position: absolute;
  inset: 0;
  z-index: 38;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  background: radial-gradient(120% 100% at 50% 44%, rgba(4,10,18,0.5), rgba(4,10,18,0.92));
  backdrop-filter: blur(2px);
}
.start.is-open { display: flex; animation: aarFade 0.4s ease both; }
.start__inner { padding: 24px; max-width: 100%; min-width: 0; }
.start__title { overflow-wrap: anywhere; }
.start__play {
  width: 92px; height: 92px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border: 2px solid var(--blue);
  border-radius: 50%;
  color: var(--blue);
  font-size: 32px;
  padding-left: 6px;
  box-shadow: 0 0 26px rgba(63,224,212,0.32), inset 0 0 22px rgba(63,224,212,0.12);
  animation: startPulse 2s ease-in-out infinite;
}
@keyframes startPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 22px rgba(63,224,212,0.3), inset 0 0 20px rgba(63,224,212,0.1); }
  50%      { transform: scale(1.05); box-shadow: 0 0 42px rgba(63,224,212,0.55), inset 0 0 28px rgba(63,224,212,0.18); }
}
.start__title {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 4px;
  font-size: 22px;
  color: var(--ink);
}
.start__op { font-size: 12px; letter-spacing: 2px; color: var(--ink-dim); margin-top: 6px; }
.start__hint { font-size: 11px; letter-spacing: 1.5px; color: var(--ink-mut); margin-top: 20px; }
.start__hint b { color: var(--amber); }

/* ---------- after-action report ---------- */
.aar {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 100% at 50% 40%, rgba(4,10,18,0.72), rgba(4,10,18,0.94));
  backdrop-filter: blur(3px);
}
.aar.is-open { display: flex; animation: aarFade 0.4s ease both; }
@keyframes aarFade { from { opacity: 0; } }

.aar__card {
  width: min(560px, 100%);
  min-width: 0; /* let the flex item shrink below content width on mobile */
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 30px 22px;
  background: linear-gradient(160deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(63,224,212,0.06), 0 30px 80px rgba(0,0,0,0.6), inset 0 0 60px rgba(63,224,212,0.04);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
  animation: aarRise 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
@keyframes aarRise { from { transform: translateY(22px) scale(0.98); opacity: 0; } }

.aar__head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.aar__tag { font-size: 9px; letter-spacing: 2px; color: var(--amber); }
.aar__title {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 22px;
  margin: 8px 0 4px;
  color: var(--ink);
}
.aar__op { font-size: 12px; letter-spacing: 1.5px; color: var(--ink-dim); }
.aar__op b { color: var(--blue); }

.aar__result {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 16px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-left: 3px solid var(--green);
  background: rgba(93,255,160,0.06);
  color: var(--green);
}
.aar__result.is-partial { border-left-color: var(--amber); background: rgba(255,176,0,0.06); color: var(--amber); }

.aar__stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.aar__stat {
  border: 1px solid var(--line-2);
  padding: 10px 12px;
  background: rgba(6,16,24,0.5);
}
.aar__stat .k { font-size: 9.5px; letter-spacing: 1.5px; color: var(--ink-mut); display: block; margin-bottom: 4px; }
.aar__stat .v { font-family: var(--disp); font-weight: 700; font-size: 19px; color: var(--ink); }
.aar__stat .v small { font-size: 12px; color: var(--ink-dim); }

.aar__sub { font-size: 10px; letter-spacing: 2px; color: var(--ink-mut); margin-bottom: 8px; }
.aar__seq { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 4px; }
.aar__seq li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--red);
  background: rgba(6,16,24,0.5);
}
.aar__seq .seq-t { color: var(--ink-mut); }
.aar__seq .seq-x { color: var(--ink); }
.aar__seq .seq-by { color: var(--blue); font-size: 10px; letter-spacing: 1px; }

.aar__btns { display: flex; gap: 10px; justify-content: flex-end; }
.aar__btn {
  width: auto;
  height: auto;
  padding: 11px 18px;
  font-family: var(--disp);
  font-weight: 600;
  letter-spacing: 1.5px;
  font-size: 12px;
}
#aarRestart { color: var(--blue); border-color: rgba(63,224,212,0.4); }

@media (max-width: 600px) {
  .aar { padding: 12px; }
  .aar__card { padding: 20px 16px; overflow-x: hidden; }
  .aar__title { font-size: 16px; letter-spacing: 1.5px; }
  .aar__result { font-size: 14px; letter-spacing: 1px; }
  .aar__stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .aar__btns { flex-direction: column; gap: 8px; }
  .aar__btn { width: 100%; justify-content: center; padding: 13px; }

  .start__title { font-size: 16px; letter-spacing: 2px; }
  .start__op { font-size: 11px; }
  .start__hint { font-size: 10px; }
  .start__play { width: 80px; height: 80px; font-size: 28px; }
}

/* ---------- responsive: tablet ---------- */
@media (max-width: 1080px) {
  .panel { width: 232px; }
  .panel--right { width: 250px; }
}

/* ---------- responsive: mobile — the MAP is the hero, minimal chrome ---------- */
@media (max-width: 820px) {
  /* full-screen map; everything else floats over it */
  #map { position: absolute; inset: 0; width: 100%; height: 100%; }

  /* topbar collapses to just the hazard banner */
  .topbar { padding: 8px 10px 4px; }
  .topbar__id, .topbar__clocks { display: none; }
  .classbar {
    flex: 1 1 100%;
    text-align: center;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 5px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* order-of-battle & event log become on-demand bottom sheets */
  .panel {
    position: fixed;
    left: 8px; right: 8px; bottom: 84px;
    top: auto;
    width: auto;
    max-height: 52vh;
    overflow-y: auto;
    z-index: 22;
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.26s ease, opacity 0.26s ease;
  }
  .panel--right { display: block; }
  body.show-oob .panel--left,
  body.show-log .panel--right {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  /* controls pinned to the bottom, ALWAYS visible */
  .transport {
    left: 8px; right: 8px; bottom: 8px;
    padding: 9px 10px;
    gap: 9px;
    flex-wrap: wrap;
    z-index: 23;
  }
  .timeline { order: 3; flex: 1 1 100%; }
  .transport__btns { order: 1; }
  .transport__speed { order: 2; margin-left: auto; }
  .m-toggle { display: inline-flex; align-items: center; justify-content: center; }
  /* a toggled-open sheet highlights its button */
  body.show-oob #btnOob,
  body.show-log #btnLog { color: var(--blue); border-color: var(--blue); box-shadow: 0 0 12px rgba(63,224,212,.35); }

  .frame, .fx-vignette { display: none; }
}

@media (max-width: 400px) {
  .classbar { font-size: 8px; letter-spacing: 0.4px; }
  .spd { padding: 6px 6px; font-size: 10px; }
  /* scope the shrink to transport buttons — NOT the AAR action buttons */
  .transport .btn { width: 38px; height: 38px; font-size: 14px; }
}
