/* Unicornlines brand styling for inReach Hub.
   Derived from the Unicornlines Brand Kit v1.0 (single source of truth):
   black canvas, gold accent, the rainbow signature stripe, and the
   Exo 2 / Inter / JetBrains Mono type stack. Fonts are self-hosted (no
   third-party font CDN) for privacy and performance. */

/* ---------------------------------------------------------------- Fonts -- */

@font-face {
  font-family: "Exo 2";
  src: url("../fonts/Exo2.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------- Tokens -- */

:root {
  /* Primary palette */
  --ul-black: #000000;
  --ul-white: #ffffff;
  --ul-gold: #c9a84c;
  --ul-gold-bright: #e0c061;
  --ul-silver: #a8a9ad;

  /* Surfaces (Black as canvas; dark greys for elevation) */
  --ul-bg: #000000;
  --ul-surface: #0d0d0d;
  --ul-surface-2: #161616;
  --ul-border: rgba(255, 255, 255, 0.12);
  --ul-border-strong: rgba(255, 255, 255, 0.22);

  /* Text */
  --ul-text: #ffffff;
  --ul-muted: rgba(255, 255, 255, 0.7);
  --ul-faint: rgba(255, 255, 255, 0.5);

  /* Pride palette */
  --ul-red: #e41e26;
  --ul-orange: #f78d1e;
  --ul-yellow: #fdee0a;
  --ul-green: #0d8241;
  --ul-blue: #3f5eab;
  --ul-purple: #732983;

  /* Semantic (derived from the palette per the kit) */
  --ul-link: var(--ul-gold);
  --ul-success: #2bb673; /* lightened Pride Green for AA text on black */
  --ul-warning: var(--ul-orange);
  --ul-error: #ff5a60; /* lightened Pride Red for AA text on black */

  --ul-rainbow: linear-gradient(
    to right,
    var(--ul-red),
    var(--ul-orange),
    var(--ul-yellow),
    var(--ul-green),
    var(--ul-blue),
    var(--ul-purple)
  );

  /* Type */
  --font-display: "Exo 2", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  /* Spacing (8px system) */
  --sp-1: 0.5rem;
  --sp-2: 1rem;
  --sp-3: 1.5rem;
  --sp-4: 2rem;
  --sp-6: 3rem;
  --sp-8: 4rem;

  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 64rem;
}

/* ----------------------------------------------------------------- Base -- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ul-bg);
  color: var(--ul-text);
  font-family: var(--font-body);
  font-size: 1.0625rem; /* 17px — comfortable body size (16–18px best practice) */
  font-weight: 400;
  line-height: 1.6; /* generous leading for readability (1.5–1.6) */
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--ul-white);
  text-wrap: balance;
  margin: 0 0 var(--sp-1);
}

/* Vertical rhythm: a heading binds to the content that follows it, so the
   space above it is larger than the space below. First children reset. */
h2 {
  margin-top: var(--sp-4);
}
h3 {
  margin-top: var(--sp-3);
}
:where(main) > :first-child,
.page-head > :first-child,
.card > :first-child {
  margin-top: 0;
}

/* Modular scale (~1.2, minor third) tuned for a dense app UI rather than a
   marketing hero: calmer headings, larger body, tight heading leading. */
h1 {
  font-size: 1.875rem; /* 30px */
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.5rem; /* 24px */
  font-weight: 700;
  line-height: 1.25;
}
h3 {
  font-size: 1.25rem; /* 20px */
  font-weight: 600;
  line-height: 1.3;
}
h4 {
  font-size: 1.0625rem; /* 17px */
  font-weight: 600;
  line-height: 1.4;
}

p {
  margin: 0 0 var(--sp-2);
  max-width: 66ch; /* ideal measure ~66 characters (Bringhurst) */
}

a {
  color: var(--ul-link);
  text-decoration: none;
}
a:hover {
  color: var(--ul-gold-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

small {
  font-size: 0.875rem;
}

code,
kbd,
pre {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

:focus-visible {
  outline: 2px solid var(--ul-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------- Layout -- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--ul-black);
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.site-header .brand img {
  height: 40px;
  width: auto;
  display: block;
}
.site-header .brand:hover {
  text-decoration: none;
}
.brand-sub {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ul-muted);
  padding-left: var(--sp-1);
  margin-left: 0.25rem;
  border-left: 1px solid var(--ul-border-strong);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
}
.site-nav a,
.site-nav .navlink {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ul-muted);
  padding: var(--sp-1) 0.75rem;
  border-radius: var(--radius-sm);
}
.site-nav a:hover {
  color: var(--ul-white);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.site-nav a[aria-current="page"] {
  color: var(--ul-gold);
}

/* The rainbow signature stripe — used exactly once, between header and body. */
.rainbow-stripe {
  height: 8px;
  width: 100%;
  background: var(--ul-rainbow);
}

main.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-3);
  flex: 1 0 auto;
}

.site-footer {
  flex-shrink: 0;
  padding: var(--sp-3);
  border-top: 1px solid var(--ul-border);
  color: var(--ul-faint);
  font-size: 0.8125rem;
  text-align: center;
}
.site-footer .nsd {
  color: var(--ul-gold);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------- Typographic UI */

/* Kicker above a heading: sits tight to its title (small bottom margin) so the
   two read as one unit rather than a small label floating in space. */
.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8125rem; /* 13px */
  font-weight: 600;
  color: var(--ul-gold);
  margin: 0 0 0.35rem;
  max-width: none; /* it's a label, not body text — don't apply the 66ch measure */
}
.page-head .eyebrow + h1,
.page-head .eyebrow + h2 {
  margin-top: 0;
}

.muted {
  color: var(--ul-muted);
}
.faint {
  color: var(--ul-faint);
}

.page-head {
  margin-bottom: var(--sp-3);
}
.page-head p {
  margin: 0;
}

/* ------------------------------------------------------------- Surfaces -- */

.card {
  background: var(--ul-surface);
  border: 1px solid var(--ul-border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* ------------------------------------------------------------- Buttons --- */

.btn,
button[type="submit"],
.site-nav form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--ul-gold);
  color: var(--ul-black);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover,
button[type="submit"]:hover {
  background: var(--ul-gold-bright);
  color: var(--ul-black);
  text-decoration: none;
}

.btn-outline,
.site-nav form button {
  background: transparent;
  color: var(--ul-muted);
  border-color: var(--ul-border-strong);
}
.btn-outline:hover,
.site-nav form button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ul-white);
  border-color: var(--ul-border-strong);
}

/* --------------------------------------------------------------- Forms --- */

label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--sp-1);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ul-text);
  background: var(--ul-surface-2);
  border: 1px solid var(--ul-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.75rem;
  margin-bottom: var(--sp-1);
}
textarea {
  resize: vertical;
  min-height: 5rem;
}
input::placeholder,
textarea::placeholder {
  color: var(--ul-faint);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--ul-gold);
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.25);
}
input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--ul-gold);
}
.form-help {
  display: block;
  color: var(--ul-faint);
  font-size: 0.8125rem;
  margin: 0 0 var(--sp-2);
}
.errorlist {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-1);
  color: var(--ul-error);
  font-size: 0.875rem;
}

/* -------------------------------------------------------------- Tables --- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--sp-2);
}
th,
td {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--ul-border);
  vertical-align: middle;
}
thead th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ul-muted);
}

/* ------------------------------------------------------------ Messages --- */

.flash {
  border: 1px solid var(--ul-border-strong);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--ul-surface);
  padding: 0.75rem 1rem;
  margin-bottom: var(--sp-2);
}
.flash-success {
  border-left-color: var(--ul-success);
}
.flash-error {
  border-left-color: var(--ul-error);
}
.flash-warning {
  border-left-color: var(--ul-warning);
}
.flash-info {
  border-left-color: var(--ul-blue);
}

/* --------------------------------------------------------------- Badges -- */

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--ul-border-strong);
  color: var(--ul-muted);
}
.badge-sent {
  color: var(--ul-success);
  border-color: var(--ul-success);
}
.badge-failed {
  color: var(--ul-error);
  border-color: var(--ul-error);
}
.badge-pending {
  color: var(--ul-warning);
  border-color: var(--ul-warning);
}

/* ----------------------------------------------------------------- Map --- */

#map {
  height: 55vh;
  min-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--ul-border);
  margin-bottom: var(--sp-3);
  background: var(--ul-surface);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.stat {
  background: var(--ul-surface);
  border: 1px solid var(--ul-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  text-align: center;
}
.stat .label {
  display: block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.75rem; /* 12px floor (kit "micro") */
  font-weight: 600;
  color: var(--ul-gold);
  margin-bottom: 0.35rem;
}
.stat .value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
}

/* ------------------------------------------------------------- Ticker ---- */

.ticker {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.ticker li {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--ul-surface);
  border: 1px solid var(--ul-border);
  border-left: 3px solid var(--ul-gold);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}
.ticker .msg {
  font-size: 1.0625rem;
  line-height: 1.5;
}
.ticker time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ul-faint);
}
.ticker-media {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
}
.ticker-audio {
  width: 100%;
}
/* Plain, accent-free style for the loading / empty placeholder. */
.ticker li.muted {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--ul-muted);
}

/* ----------------------------------------------------- Profile charts ---- */

.profile-wrap {
  background: var(--ul-surface);
  border: 1px solid var(--ul-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.profile {
  display: block;
  width: 100%;
  height: auto;
}
.profile-max,
.profile-min {
  fill: var(--ul-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Dark-style the Leaflet popup/controls to fit the canvas. */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--ul-surface-2);
  color: var(--ul-text);
}
.leaflet-bar a {
  background: var(--ul-surface-2);
  color: var(--ul-text);
  border-bottom-color: var(--ul-border);
}
.leaflet-bar a:hover {
  background: var(--ul-surface);
}
.leaflet-container {
  background: #0a0a0a;
}

/* ----------------------------------------------------- SOS + status ------ */

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}
.chip {
  font-size: 0.8125rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--ul-border-strong);
  color: var(--ul-muted);
}
.chip.ok {
  color: var(--ul-success);
  border-color: var(--ul-success);
}
.chip.warn {
  color: var(--ul-warning);
  border-color: var(--ul-warning);
}
.chip.alert {
  color: var(--ul-error);
  border-color: var(--ul-error);
}
.chip.sos-on {
  background: var(--ul-red);
  border-color: var(--ul-red);
  color: #fff;
  font-weight: 700;
}

.sos-actions {
  border-left: 3px solid var(--ul-red);
}

/* ---------------------------------------------------------- Responsive --- */

@media (max-width: 40rem) {
  h1 {
    font-size: 1.625rem; /* 26px */
  }
  main.container {
    padding: var(--sp-3) var(--sp-2);
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
