/**
 * Aegis Intel v15.4.2 — Premium Visual Identity (MackSims LLC)
 * Soft tactical intelligence layer on command-ui-v1541.css — visual polish only.
 */

/* ——— Design tokens ——— */
:root {
  --premium-ivory: #f5f3ee;
  --premium-slate: #e8e4dc;
  --premium-glass: rgba(255, 255, 255, 0.74);
  --premium-glass-strong: rgba(255, 255, 255, 0.88);
  --premium-border: rgba(221, 214, 203, 0.62);
  --premium-shadow-card: 0 1px 2px rgba(15, 23, 41, 0.03), 0 8px 24px rgba(15, 23, 41, 0.05);
  --premium-shadow-header: 0 2px 12px rgba(15, 23, 41, 0.06);
  --premium-btn-height: 44px;
  --premium-accent-bar: linear-gradient(90deg, var(--primary) 0%, var(--accent-cyan) 100%);
}

/* ——— 1. Background — warm ivory/slate, radial gradient, faint grid ——— */
html {
  background-color: var(--premium-slate);
  background-image:
    radial-gradient(ellipse 110% 75% at 12% -8%, rgba(26, 122, 98, 0.1), transparent 45%),
    radial-gradient(ellipse 85% 55% at 88% 2%, rgba(13, 142, 168, 0.07), transparent 40%),
    radial-gradient(ellipse 70% 45% at 50% 105%, rgba(21, 34, 56, 0.05), transparent 55%),
    linear-gradient(180deg, var(--premium-ivory) 0%, #ebe8e1 50%, var(--premium-slate) 100%);
}

html::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(200, 194, 184, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 194, 184, 0.14) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.28;
  mask-image: radial-gradient(ellipse 85% 65% at 50% 25%, black 15%, transparent 72%);
}

body,
#app,
.app-shell,
.app-main,
.app-view {
  background: transparent;
}

/* ——— 2. App shell — framed center column ——— */
.app-shell.cmd-shell {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  width: min(720px, 100%);
  padding: 10px 14px 0;
}

@media (min-width: 768px) {
  .app-shell.cmd-shell {
    padding: 14px 20px 0;
    border-left: 1px solid var(--premium-border);
    border-right: 1px solid var(--premium-border);
    box-shadow: 0 0 48px rgba(15, 23, 41, 0.04);
  }
}

/* ——— 3. Header — integrated glass, identity ——— */
.cmd-shell .topbar::before {
  background: rgba(245, 243, 238, 0.9);
  border-bottom: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow-header);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.cmd-shell .brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(145deg, #ffffff 0%, var(--accent-soft) 55%, #d4ebe4 100%);
  border: 1px solid rgba(26, 122, 98, 0.18);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(26, 122, 98, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cmd-shell .brand > div > span:first-child {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.cmd-shell .beta-badge {
  font-size: 0.56rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff 0%, var(--accent-soft) 100%);
  border: 1px solid rgba(26, 122, 98, 0.2);
  color: var(--primary);
  letter-spacing: 0.02em;
}

/* ——— 4. Home mission card — premium typography ——— */
.cmd-mission-card {
  position: relative;
  background: var(--premium-glass);
  border: 1px solid var(--premium-border);
  border-radius: 16px;
  padding: 16px 16px 14px;
  box-shadow: var(--premium-shadow-card);
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  overflow: hidden;
}

.cmd-mission-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--premium-accent-bar);
  opacity: 0.85;
}

.cmd-mission-card h1 {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.18;
}

.cmd-mission-body {
  font-size: 0.86rem;
  line-height: 1.5;
}

.cmd-status-row .pill {
  font-size: 0.63rem;
  font-weight: 650;
  padding: 4px 9px;
  border-radius: 99px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.cmd-status-row .pill.info {
  background: linear-gradient(180deg, #f0f7ff 0%, var(--info-bg) 100%);
}

.cmd-status-row .pill.good {
  background: linear-gradient(180deg, #f4fdf8 0%, var(--good-bg) 100%);
}

/* ——— 5. Buttons — consistent height, gradients, states ——— */
.cmd-shell .btn {
  min-height: var(--premium-btn-height);
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.cmd-shell .btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.cmd-action-row .btn {
  min-height: var(--premium-btn-height);
  border-radius: 12px;
}

.cmd-action-row .btn.primary {
  background: linear-gradient(180deg, #229a7c 0%, var(--primary) 55%, #156b56 100%);
  border: 1px solid rgba(21, 107, 86, 0.35);
  box-shadow: 0 2px 8px rgba(26, 122, 98, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: #fff;
}

.cmd-action-row .btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #27a888 0%, #1b856c 55%, #187a62 100%);
  box-shadow: 0 4px 12px rgba(26, 122, 98, 0.28);
}

.cmd-action-row .btn.primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(26, 122, 98, 0.2);
}

.cmd-action-row .btn.good {
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-soft) 100%);
  border: 1px solid var(--premium-border);
  color: var(--good);
  box-shadow: 0 1px 4px rgba(15, 23, 41, 0.04);
}

.cmd-action-row .btn.good:hover:not(:disabled) {
  background: linear-gradient(180deg, #fff 0%, var(--good-bg) 100%);
  border-color: rgba(6, 118, 71, 0.25);
}

.cmd-shell .btn.ghost {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--premium-border);
}

.cmd-shell .btn.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.85);
}

/* ——— 6. Stat cards — instrument-style, accent top border ——— */
.cmd-stat {
  position: relative;
  text-align: center;
  padding: 9px 4px 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, var(--surface-soft) 100%);
  border: 1px solid var(--premium-border);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 1px 3px rgba(15, 23, 41, 0.03);
  overflow: hidden;
}

.cmd-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--premium-accent-bar);
  opacity: 0.55;
  border-radius: 0 0 2px 2px;
}

.cmd-stat b {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.02em;
}

.cmd-stat span {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ——— 7. Summary / next-action cards — softer glass ——— */
.cmd-next-card,
.cmd-shell .panel,
.cmd-shell .card,
.cmd-shell .hero-card,
.cmd-shell .view-intro {
  background: var(--premium-glass);
  border: 1px solid var(--premium-border);
  border-radius: 14px;
  box-shadow: var(--premium-shadow-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cmd-next-card {
  padding: 13px 15px;
}

.cmd-onboarding-card {
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgba(228, 243, 238, 0.35) 0%, var(--premium-glass) 18%);
}

/* ——— 8. Bottom nav — premium active indicator, safe-area ——— */
.cmd-shell .app-bottom-nav {
  max-width: min(720px, 100%);
  padding: 5px 8px calc(5px + env(safe-area-inset-bottom, 0px));
  background: rgba(245, 243, 238, 0.94);
  border-top: 1px solid var(--premium-border);
  box-shadow: 0 -6px 20px rgba(15, 23, 41, 0.05);
  backdrop-filter: blur(16px) saturate(1.08);
  -webkit-backdrop-filter: blur(16px) saturate(1.08);
  min-height: 54px;
}

.cmd-shell .app-nav-btn {
  position: relative;
  min-height: 46px;
  border-radius: 11px;
  transition: background 0.15s ease, color 0.15s ease;
}

.cmd-shell .app-nav-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.cmd-shell .app-nav-btn.is-active {
  background: rgba(26, 122, 98, 0.11);
  color: var(--primary);
}

.cmd-shell .app-nav-btn.is-active::after {
  display: block;
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--premium-accent-bar);
  box-shadow: 0 0 6px rgba(26, 122, 98, 0.35);
}

.cmd-shell .app-nav-label {
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.01em;
}

/* ——— 9. Dossier — align borders/shadows only ——— */
.aegis-dossier-backdrop {
  background: rgba(15, 23, 41, 0.38);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.aegis-dossier-panel {
  border: 1px solid var(--premium-border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--premium-glass-strong) 0%, #f8f6f2 100%);
  box-shadow: 0 16px 48px rgba(15, 23, 41, 0.14), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
}

#aegis-dossier-root .aegis-dossier-section {
  border: 1px solid var(--premium-border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.5);
}

/* ——— Build mismatch banner ——— */
.cmd-shell .build-mismatch-banner {
  border: 1px solid rgba(181, 71, 8, 0.25);
  box-shadow: var(--premium-shadow-card);
}

/* ——— 10. Accessibility — reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  html::before {
    display: none;
  }

  .cmd-shell .btn,
  .cmd-shell .app-nav-btn,
  .cmd-mission-card,
  .cmd-stat,
  .cmd-next-card {
    transition: none;
  }

  .cmd-action-row .btn.primary:active:not(:disabled) {
    transform: none;
  }
}

/* ——— Tablet / desktop refinements ——— */
@media (min-width: 768px) {
  .cmd-mission-card h1 {
    font-size: 1.42rem;
  }

  .cmd-mission-card {
    padding: 18px 20px 16px;
    border-radius: 18px;
  }
}

@media (max-width: 389px) {
  .cmd-stat b {
    font-size: 1rem;
  }
}
