/* ============================================================
   XSD User Gateway — shared theme  (Design-system Pass 2)
   Re-skinned to match the TAK Admin Portal (Pass 1):
   IBM Plex (self-hosted), dark canvas, operational green +
   interactive blue, TAK reticle + command-grid atmosphere.
   Class names and the legacy CSS-variable names are preserved
   so landing.js / reset-password.js / dashboard.js / device.js
   keep working unchanged. Mobile-first throughout.
   ============================================================ */

/* ---- Self-hosted fonts (no CDN — safe for hardened deploys) ---- */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Variable.ttf") format("truetype-variations");
  font-weight: 100 700; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/IBMPlexMono-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
  /* ---- Pass 1 base tokens (admin-portal values) ---- */
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #232d3a;
  --border: #2c3848;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #3fb950;     /* operational green */
  --accent-2: #2f81f7;   /* interactive blue */
  --warn: #d29922;       /* caution amber */
  --danger: #f85149;     /* fault red */
  --code: #8fe6a0;       /* mono data green */

  /* ---- Legacy gateway aliases → Pass 1 (do NOT rename in HTML/JS) ----
     Kept so any remaining references resolve to the new palette. */
  --accent-amber: var(--accent-2);
  --accent-orange: var(--accent-2);
  --accent-blue: var(--accent-2);
  --brand-red: var(--danger);

  --bg-grid-opacity: 0.6;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --page-pad: max(16px, var(--safe-left));
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding:
    var(--safe-top)
    max(var(--page-pad), var(--safe-right))
    var(--safe-bottom)
    max(var(--page-pad), var(--safe-left));
}

/* Subtle green command wash + fixed command-grid graticule behind everything */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse 120% 80% at 62% 18%, rgba(63, 185, 80, 0.07), transparent 60%),
    var(--bg);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  opacity: var(--bg-grid-opacity);
  background-image: url("assets/command-grid.svg");
  background-size: cover;
  background-position: center;
  pointer-events: none;
}
.device-phone body::after { opacity: 0.4; }

@media (prefers-reduced-motion: reduce) {
  .typewriter::after { animation: none !important; }
  .card { animation: none !important; }
}

a {
  color: var(--accent-2);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 120ms cubic-bezier(.2,0,0,1);
}
a:hover { color: #79b8ff; }

code, .mono {
  font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  font-size: 0.9em;
  color: var(--code);
}

/* ---- Header / brand ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 20px;
  flex-wrap: wrap;
}
.site-header .brand { display: flex; align-items: center; gap: 12px; }
.site-header img.logo { height: 40px; width: auto; }
.device-phone .site-header img.logo { height: 34px; }
.site-header h1 {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.site-header .tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.container { width: 100%; max-width: 960px; margin: 0 auto; }

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: 28px; }
.hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #f4f8fb;
}
.hero .typewriter {
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(0.8rem, 2.5vw, 0.95rem);
  color: var(--accent);
  min-height: 1.5em;
  letter-spacing: 0.06em;
}

/* ---- Cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  animation: fadeIn 0.5s ease both;
}
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.16s; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.card p { margin: 0 0 12px; color: var(--text); }
.muted { color: var(--muted); font-size: 14px; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px; /* ≥16px prevents iOS zoom-on-focus */
  font-family: inherit;
  transition: border-color 120ms cubic-bezier(.2,0,0,1), box-shadow 120ms cubic-bezier(.2,0,0,1);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.15);
}
input::placeholder { color: #5b6675; }

/* ---- Buttons ---- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent-2);
  color: #fff;
  margin-top: 14px;
  text-decoration: none;
  transition: opacity 120ms cubic-bezier(.2,0,0,1);
}
button.secondary, .btn.secondary {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
button.block, .btn.block { width: 100%; }
button:hover, .btn:hover { opacity: 0.88; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Banners (Pass 1 soft signal fills) ---- */
.banner {
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid;
  word-wrap: break-word;
}
.banner.error { background: rgba(248, 81, 73, 0.13); border-color: rgba(248, 81, 73, 0.35); color: var(--danger); }
.banner.ok    { background: rgba(63, 185, 80, 0.15); border-color: rgba(63, 185, 80, 0.35); color: var(--accent); }

.hidden { display: none !important; }

.login-wrap { max-width: 420px; margin: 0 auto; }
.turnstile-slot { margin: 12px 0; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .login-wrap { padding: 0 8px; }
}

/* ---- Enrollment grid (dashboard) ---- */
.enroll-grid { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 1024px) {
  .enroll-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}
.enroll-card { order: 1; }
.platform-ios .enroll-atak { order: 2; }
.platform-ios .enroll-itak { order: 1; }
.platform-android .enroll-atak { order: 1; }
.platform-android .enroll-itak { order: 2; }

.qr-wrap { text-align: center; margin: 12px 0; }
.qr-wrap img {
  max-width: 100%;
  width: 280px;
  height: auto;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

details summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--accent-2);
  font-weight: 500;
}
.device-phone details .detail-body { font-size: 14px; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions button { margin-top: 0; padding: 9px 14px; font-size: 13px; }

.footer-note {
  text-align: center;
  margin-top: 32px;
  font-size: 12px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
}

/* ---- CloudTAK map help ---- */
.map-help { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.map-help summary { cursor: pointer; color: var(--accent-2); font-size: 14px; font-weight: 600; }
.map-help-body { margin-top: 12px; }
.map-help-body ol { margin: 8px 0 12px; padding-left: 1.25rem; }
.map-reset-cmd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--code);
  overflow-x: auto;
  margin: 0 0 10px;
  white-space: pre-wrap;
  word-break: break-all;
}
.map-help-note { margin: 10px 0 0; font-size: 13px; }
.map-help kbd {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* ============================================================
   Absorbed inline styles  (previously style="…" in the HTML)
   ============================================================ */
/* landing: small field hint under the username input */
.field-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
/* landing: "Forgot password?" line under the password field */
.form-links { margin-top: 8px; font-size: 13px; }
/* extra separation before the "Request access" card / back-links */
.card--gap { margin-top: 24px; }
.form-foot { margin-top: 16px; }
/* spacing between stacked request-access disclosures + their forms */
.card details + details { margin-top: 12px; }
.card details > form { margin-top: 12px; }

/* dashboard: device-conditional visibility (moved out of inline <style>) */
.device-phone .device-desktop-info { display: none; }
.device-desktop .device-phone-only summary,
.device-tablet .device-phone-only summary { display: none; }
.device-desktop .device-phone-only .detail-body,
.device-tablet .device-phone-only .detail-body { display: block; }
.device-desktop .device-phone-only,
.device-tablet .device-phone-only { border: none; }

/* ============================================================
   PHASE 1 polish — takuser login + home.tak.xsd.us landing
   ============================================================ */
.site-header--center { justify-content: center; }
.brand--stack { flex-direction: column; align-items: center; text-align: center; }
.logo-lockup { width: auto; max-width: min(168px, 70vw); height: auto; }
.link-grid { display: grid; gap: 10px; margin-top: 12px; }
.detail-list { margin: 12px 0 0; padding: 0; }
.detail-list div {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.detail-list div:last-child { border-bottom: none; }
.detail-list dt { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.detail-list dd { margin: 0; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; color: var(--code); }
.footer-note a { color: var(--accent-2); }
