/* File: css/components.css
 * Owner: Person B (Saurav)
 * AI-assisted (update): Claude, 2026-11-15 - report tables: headers no longer break mid-word, source tag stays on one line (table scrolls sideways on phones). Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - responsive pass: readable toast, scrollable report tables, dvh modal height, full-width cards on phones, safe-area padding. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted (update): Claude, 2026-11-15 - flight menu styles. Reviewed by a human: YES, Person C (Yochan).
 * AI-assisted: YES — Gemini, 2026-11-15. Reviewed by a human: YES, Person C (Yochan).
 * Sources used: none
 */
.card {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  min-height: 44px;
  padding: 12px;
  background: #12304fe0;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, background-color 0.15s ease;
}

.card:hover:not(.lkd) {
  border-color: #5ca2e8;
  background: #163a61ee;
  transform: translateY(-2px);
}

.card.sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 18px #040d1888;
}

.card img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex: none;
}

.card p {
  margin: 2px 0 4px;
}

.card small {
  color: var(--muted);
}

.card.o {
  max-width: 860px;
  align-items: center;
}

.card.o img {
  display: none;
}

.go {
  margin-top: 18px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  color: #0b2038;
  background: var(--accent);
  border: 0;
}

.go:hover:not(:disabled) {
  background: #ffd373;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.875rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chip.ok {
  border-color: var(--ok);
  color: var(--ok);
}

.chip.me {
  background: var(--line);
}

.badge-simplified {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 0 5px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #9ec0e0;
  background: #1b436b66;
  border: 1px solid #3c78b566;
  border-radius: 4px;
  vertical-align: middle;
  cursor: help;
}

.badge-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ok);
  background: #7fe3b81c;
  border: 1px solid var(--ok);
  border-radius: 999px;
  vertical-align: middle;
}

.badge-source.offline {
  color: var(--accent);
  background: #ffc8571a;
  border-color: var(--accent);
}

.weather-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 14px;
  padding: 10px 14px;
  background: #0d253fe6;
  border: 1px solid #3c78b5;
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  font-size: 0.9rem;
}

.weather-banner.offline {
  border-left-color: var(--accent);
}

#car {
  background: linear-gradient(135deg, #163a61, #0f2944);
  border-color: var(--accent);
  color: #ffe29e;
  font-weight: 600;
}

#car:hover:not(:disabled) {
  background: linear-gradient(135deg, #1f4f82, #15375c);
  border-color: #ffe29e;
}

#hp {
  background: #143658;
  border-color: #4c8fd1;
  font-weight: 600;
}

.box {
  padding: 16px 20px;
  background: #102a46fc;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 52px #020812dd;
}

/* GPU-composited smooth scrolling without heavy backdrop-filter repaints */
.modal-box {
  position: relative;
  width: min(820px, 95vw);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateZ(0);
  will-change: scroll-position;
  padding-top: 0;
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -20px 14px;
  padding: 12px 20px;
  background: #0b2038;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent);
}

.modal-close-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: #183d63;
  border: 1px solid #4c8fd1;
  border-radius: 8px;
  flex: none;
}

.modal-close-x:hover:not(:disabled) {
  background: var(--bad);
  border-color: var(--bad);
  color: #0b2038;
}

.career-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.career-stat-pill {
  padding: 8px 12px;
  background: #0b2038;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.career-stat-pill small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.career-stat-pill b {
  font-size: 1.05rem;
  color: var(--accent);
}

.career-progress {
  height: 10px;
  margin: 6px 0 14px;
  background: #08182b;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.career-progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--accent));
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ach-card {
  padding: 8px 10px;
  background: #0b2038;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
}

.ach-card.ok {
  border-color: var(--ok);
  background: #12364f;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.help-card {
  padding: 10px 12px;
  background: #0b2038;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 0.9rem;
}

.help-card p {
  margin: 0;
}

.alert-flags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.alert-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.alert-flag.bad {
  color: var(--bad);
  background: #ff856d1c;
}

.alert-flag.w {
  color: var(--accent);
  background: #ffc8571c;
}

.alert-flag.ok {
  color: var(--ok);
  background: #7fe3b81c;
}

.decision-box {
  margin: 12px 0;
  padding: 12px 14px;
  background: #0b2038;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
}

.decision-box p {
  margin: 0 0 8px;
}

.decision-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.decision-btn {
  text-align: left;
  background: #163a61;
  border-color: var(--accent);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(92vw, 560px);
  padding: 10px 16px;
  font-weight: 600;
  color: #0b2038;
  background: var(--accent);
  border-radius: 8px;
  z-index: 40;
}

#help,
#rev {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  background: #05101ef0;
  z-index: 20;
}

#help {
  z-index: 25;
}

.rt {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.88rem;
  border-collapse: collapse;
  -webkit-overflow-scrolling: touch;
}

.rt th,
.rt td {
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
  overflow-wrap: break-word;
}

.rt th {
  background: #0d243d;
  white-space: nowrap; /* headers like "Resource" and "Margin" must never break mid-word */
}

/* Source tags (e.g. SIMPLIFIED_FOR_GAMEPLAY) stay on one line so rows stay short; on phones the table
   scrolls sideways for that last column instead of chopping the tag into four lines. */
.rt td small {
  white-space: nowrap;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.bar i {
  display: block;
  min-width: 2px;
  height: 16px;
  background: var(--accent);
  border-radius: 4px;
}

.g { color: var(--ok); }
.y { color: var(--accent); }
.r { color: var(--bad); }

.code-box {
  width: 100%;
  min-height: 84px;
  margin: 8px 0;
  font-family: monospace;
  font-size: 0.875rem;
}

.card.lkd {
  opacity: 0.58;
  cursor: not-allowed;
}

.card.lkd img {
  filter: grayscale(1) brightness(0.65);
}

.lk {
  display: block;
  margin-top: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.fb {
  display: inline-block;
  margin: 4px 6px 0 0;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 10px;
}

.card small.fn {
  display: block;
  margin-top: 3px;
}

.pin {
  display: block;
  margin-top: 4px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  background: #0b2038;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}

/* Flight menu: header Menu button + a centred pause menu */
#fm-open {
  font-weight: 700;
  color: #0b2038;
  background: var(--accent);
  border-color: var(--accent);
}

#flightmenu {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(5, 16, 30, 0.78);
}

#flightmenu[hidden] {
  display: none;
}

.fm-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(380px, 92vw);
  padding: 20px 22px;
  background: #102a46;
  border: 2px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 20px 52px #020812dd;
}

.fm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.fm-label {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.fm-status {
  padding: 2px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0b2038;
  background: var(--ok);
  border-radius: 999px;
}

.fm-status.paused {
  background: var(--accent);
}

.fm-status.done {
  background: var(--muted);
}

.fm-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fm-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
}

.fm-btn kbd {
  min-width: 2.2em;
  white-space: nowrap;
  padding: 2px 10px;
  font: inherit;
  font-size: 0.8rem;
  text-align: center;
  color: var(--muted);
  background: #0b2038;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.fm-close {
  align-self: center;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  text-decoration: underline;
}

/* ---- Small screens ---- */
@media (max-width: 640px) {
  .card {
    max-width: none;
  }

  .box {
    padding: 12px 14px;
  }

  .modal-header {
    margin: 0 -14px 12px;
    padding: 10px 14px;
  }

  .rt {
    font-size: 0.8rem;
  }

  .rt th,
  .rt td {
    padding: 5px 6px;
  }

  .fm-panel {
    padding: 16px;
  }

  /* Toast sits at the top on phones so it never covers the parts tray, burn panel or Next button */
  #toast {
    top: calc(10px + env(safe-area-inset-top, 0px));
    bottom: auto;
  }
}
