/* The Lookout League: every block has its heroes. */

@font-face { font-family: "Chakra Petch"; font-weight: 500; font-display: swap; src: url("/fonts/chakra-petch-500.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 600; font-display: swap; src: url("/fonts/chakra-petch-600.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-weight: 700; font-display: swap; src: url("/fonts/chakra-petch-700.woff2") format("woff2"); }

:root {
  --bg: #04060d;
  --panel: rgba(9, 13, 27, 0.68);
  --line: rgba(130, 160, 255, 0.12);
  --line-strong: rgba(130, 160, 255, 0.24);
  --text: #eaf1fb;
  --soft: #c3cde0;
  --muted: #8f9bb3;
  --faint: #5b6680;
  --cyan: #46e0ff;
  --violet: #8b7bff;
  --green: #3fe0a0;
  --amber: #ffb547;
  --red: #ff3d55;
  --accent: var(--cyan);
  --radius: 22px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Chakra Petch", var(--sans);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

body[data-status="calm"] { --accent: var(--green); }
body[data-status="heads-up"] { --accent: var(--amber); }
body[data-status="alarm"],
body[data-status="moved"] { --accent: var(--red); }
body[data-status="off"] { --accent: var(--muted); }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(70, 224, 255, 0.13), transparent 70%),
    radial-gradient(800px 520px at 100% -4%, rgba(139, 123, 255, 0.14), transparent 70%),
    radial-gradient(1200px 700px at 50% 120%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    linear-gradient(180deg, #050816 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--sans);
}

button, input { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- particles ---- */

.particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px 40px;
}

/* ---- brand ---- */

.emblem { display: block; flex: none; overflow: visible; }
.emblem .emblem-shield { fill: none; stroke: url(#ll-edge); stroke-width: 3.6; stroke-linejoin: round; }
.emblem .emblem-star { fill: var(--cyan); }
.emblem .emblem-mask { fill: url(#ll-edge); }
.emblem { filter: drop-shadow(0 0 10px rgba(70, 224, 255, 0.35)); }

.wordmark { display: flex; flex-direction: column; min-width: 0; }
.wordmark-the {
  font: 600 10px/1 var(--display);
  letter-spacing: 0.5em;
  color: var(--cyan);
  text-transform: uppercase;
}
.wordmark-name {
  margin: 3px 0 0;
  font: 700 21px/1.05 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  background: linear-gradient(100deg, #ffffff 0%, #bff3ff 45%, #b8afff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  margin: 5px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; text-decoration: none; color: inherit; }
.brand .emblem { width: 44px; height: 44px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }

.link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  font: 600 11px/1 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.link i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.link[data-ok="true"] i { background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 2.4s ease-in-out infinite; }

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  font: 600 14px/1 var(--display);
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, transform 120ms, box-shadow 160ms;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.07); border-color: rgba(160, 190, 255, 0.45); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, .link-button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn-small { height: 34px; padding: 0 14px; font-size: 12.5px; }
.btn-primary {
  border: 0;
  background: linear-gradient(100deg, var(--cyan), var(--violet));
  color: #050816;
  box-shadow: 0 8px 30px rgba(70, 224, 255, 0.25);
}
.btn-primary:hover { background: linear-gradient(100deg, #7ae9ff, #a79bff); box-shadow: 0 10px 40px rgba(139, 123, 255, 0.35); }
.btn-alarm { background: #fff; border-color: #fff; color: #b0001b; height: 46px; padding: 0 22px; font-size: 15px; }
.btn-alarm:hover { background: #ffe3e7; border-color: #ffe3e7; }
#sound[aria-pressed="true"] { border-color: color-mix(in srgb, var(--green) 55%, transparent); color: var(--green); }

.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--cyan);
  cursor: pointer;
  font-size: inherit;
}
.link-button:hover { text-decoration: underline; }

/* ---- layout ---- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 370px) minmax(0, 1fr);
  grid-template-areas:
    "status map"
    "stats map"
    "log log";
}

.card {
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(140deg, rgba(70, 224, 255, 0.38), rgba(139, 123, 255, 0.16) 40%, rgba(130, 160, 255, 0.08) 70%, rgba(70, 224, 255, 0.22)) border-box;
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
/* HUD corner ticks */
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid color-mix(in srgb, var(--accent) 70%, transparent);
  pointer-events: none;
  z-index: 2;
  transition: border-color 400ms;
}
.card::before { top: 10px; left: 10px; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 6px; }
.card::after { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 6px; }

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font: 600 11px/1 var(--display);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}
.card-title::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transform: rotate(45deg);
  transition: background 400ms, box-shadow 400ms;
}

.status-card { grid-area: status; padding: 24px 24px 22px; text-align: center; }
.status-card .card-title { justify-content: center; }
.map-card { grid-area: map; min-height: 540px; overflow: hidden; }
.stats { grid-area: stats; padding-top: 18px; }
.stats .card-title { padding: 0 22px; margin-bottom: 6px; }
.log-card { grid-area: log; padding: 20px 22px; }

body[data-status="alarm"] .status-card,
body[data-status="moved"] .status-card {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 45%, transparent), 0 24px 90px color-mix(in srgb, var(--red) 28%, transparent);
}

/* ---- status ring ---- */

.ring { position: relative; width: 224px; height: 224px; margin: 6px auto 0; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ring circle { fill: none; }
.ring-track { stroke: var(--line-strong); stroke-width: 2; }
.ring-ticks {
  stroke: var(--accent);
  stroke-width: 6;
  stroke-dasharray: 1.5 9;
  opacity: 0.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 40s linear infinite;
  transition: stroke 400ms;
}
.ring-orbit {
  stroke: var(--violet);
  stroke-width: 1;
  stroke-dasharray: 30 240;
  opacity: 0.8;
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 7s linear infinite reverse;
}
.ring-main {
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 0 8px var(--accent));
  transition: stroke 400ms;
}
.ring-sweep {
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 34%, transparent), transparent 28%);
  animation: spin 4.5s linear infinite;
  opacity: 0.55;
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.status-word {
  max-width: 150px;
  font: 700 31px/1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: color 400ms;
}
.item-name { font: 600 11px/1 var(--display); letter-spacing: 0.34em; text-transform: uppercase; color: var(--muted); }

.status-detail { margin: 18px auto 18px; max-width: 30ch; min-height: 3em; color: var(--soft); font-size: 15px; }
.status-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

body[data-status="alarm"] .ring,
body.testing .ring { animation: throb 1s ease-in-out infinite; }
body[data-status="alarm"] .status-word,
body.testing .status-word { animation: flash 1s steps(2, start) infinite; }
body[data-status="alarm"] .ring-sweep { animation-duration: 1.2s; opacity: 0.85; }
body[data-status="off"] .ring-sweep,
body[data-status="off"] .ring-orbit { display: none; }
body[data-status="off"] .ring-ticks { animation-play-state: paused; opacity: 0.2; }
body[data-status="off"] .ring-main { filter: none; opacity: 0.5; }

/* ---- alarm overlay and banner ---- */

.alarm-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  opacity: 0;
  transition: opacity 300ms;
}
body[data-status="alarm"] .alarm-veil,
body.testing .alarm-veil {
  opacity: 1;
  animation: veil 1s ease-in-out infinite;
}

.alarm-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  background: linear-gradient(90deg, #d4001f, #ff3d55);
  color: #fff;
  box-shadow: 0 10px 40px rgba(255, 30, 60, 0.45);
}
body[data-status="alarm"] .alarm-banner { display: flex; }
.alarm-banner-text { display: flex; flex-direction: column; min-width: 0; }
.alarm-banner strong { font: 700 18px/1.2 var(--display); letter-spacing: 0.08em; text-transform: uppercase; }
.alarm-banner span { font-size: 14px; opacity: 0.92; }

/* ---- map ---- */

#map { position: absolute; inset: 0; background: #070b16; border-radius: inherit; }
.leaflet-container { font-family: var(--sans); background: #070b16; }
/* Turns the light OpenStreetMap tiles into a dark, slightly blue night map. */
.leaflet-tile-pane { filter: invert(1) hue-rotate(195deg) brightness(0.78) contrast(0.95) saturate(0.45); }
.leaflet-control-attribution { background: rgba(4, 6, 13, 0.72) !important; color: var(--faint) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: rgba(9, 13, 27, 0.9) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-bar { border: 1px solid var(--line-strong) !important; box-shadow: none !important; }

.map-label {
  position: absolute;
  top: 16px;
  left: 64px;
  z-index: 500;
  margin: 0;
}
.map-chips { position: absolute; top: 14px; right: 14px; z-index: 500; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(4, 6, 13, 0.78);
  border: 1px solid var(--line-strong);
  font: 600 11.5px/1.2 var(--display);
  letter-spacing: 0.06em;
  color: var(--muted);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.chip-live { color: var(--cyan); }
.chip-live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--cyan); vertical-align: 1px; animation: blink 1s ease-in-out infinite; }

.map-empty {
  position: absolute;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  color: var(--faint);
  font: 600 13px/1.4 var(--display);
  letter-spacing: 0.08em;
  background: radial-gradient(circle at center, rgba(70, 224, 255, 0.06), transparent 60%);
}
.map-empty[hidden] { display: none; }

.pin span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.pin-current span {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent), 0 0 22px var(--accent);
}
.pin-current::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ping 2s ease-out infinite;
}
.pin-armed span { border: 2px solid var(--violet); background: rgba(139, 123, 255, 0.2); box-shadow: 0 0 14px rgba(139, 123, 255, 0.6); }

/* ---- stats ---- */

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; }
.stat { padding: 13px 22px; display: flex; flex-direction: column; gap: 3px; min-width: 0; border-top: 1px solid var(--line); }
.stat:nth-child(2) { border-right: 1px solid var(--line); }
.stat:first-child { border-top: 0; }
.stat-wide { grid-column: 1 / -1; }
.stat-label { font: 600 10.5px/1.3 var(--display); letter-spacing: 0.18em; text-transform: uppercase; color: var(--faint); }
.stat-value { font-size: 15px; color: var(--text); overflow-wrap: anywhere; }
.stat-big { font: 700 32px/1.1 var(--display); letter-spacing: 0.01em; color: var(--accent); transition: color 400ms; }
.stat-note { font-size: 12px; color: var(--muted); }
.stat-note:empty { display: none; }

/* ---- lookout log ---- */

.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.log li {
  display: grid;
  grid-template-columns: 92px 10px 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--soft);
}
.log li:first-child { border-top: 0; }
.log time { grid-column: 1; grid-row: 1; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.log li::before { content: ""; grid-column: 2; grid-row: 1; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); align-self: center; }
.log li > span { grid-column: 3; grid-row: 1; }
.log .log-ok::before { background: var(--green); }
.log .log-warn::before { background: var(--amber); }
.log .log-alarm::before { background: var(--red); box-shadow: 0 0 8px var(--red); }
.log .log-alarm > span { color: #ffd0d6; font-weight: 600; }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-top: 24px;
  font-size: 12px;
  color: var(--faint);
}
.footer form { margin: 0; }
.footer-logout { display: none; }
.footer-brand { width: 100%; text-align: center; margin-top: 10px; font: 600 11px/1.4 var(--display); letter-spacing: 0.22em; text-transform: uppercase; color: var(--faint); }

/* ---- login ---- */

.login-page { display: grid; place-items: center; padding: 28px 16px; }
.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.login-hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 26px; }
.login-emblem { position: relative; width: 112px; height: 112px; margin-bottom: 18px; display: grid; place-items: center; }
.login-emblem .emblem { width: 76px; height: 76px; filter: drop-shadow(0 0 18px rgba(70, 224, 255, 0.45)); }
.login-emblem::before,
.login-emblem::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed rgba(70, 224, 255, 0.35);
  animation: spin 22s linear infinite;
}
.login-emblem::after {
  inset: 10px;
  border: 1px solid transparent;
  border-top-color: rgba(139, 123, 255, 0.8);
  border-right-color: rgba(139, 123, 255, 0.25);
  animation-duration: 3.5s;
}
.login-hero .wordmark { align-items: center; }
.login-hero .wordmark-the { font-size: 12px; }
.login-hero .wordmark-name { font-size: clamp(30px, 9vw, 42px); letter-spacing: 0.06em; white-space: normal; }
.login-hero .tagline { margin-top: 12px; font-size: 16px; color: var(--soft); }

.login-card { padding: 28px 26px 26px; text-align: left; }
.login-card .card-title { margin-bottom: 8px; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-error { margin: -6px 0 16px; color: #ff8a9a; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
  height: 50px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.35);
  font-size: 16px;
  letter-spacing: 0.04em;
}
.login-form input::placeholder { color: var(--faint); }
.login-form .btn { height: 50px; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase; }
.login-foot { margin-top: 22px; font-size: 12px; color: var(--faint); }

/* ---- motion ---- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0.35; } }
@keyframes throb { 50% { transform: scale(1.04); } }
@keyframes flash { 50% { opacity: 0.35; } }
@keyframes ping { from { transform: scale(0.5); opacity: 0.9; } to { transform: scale(1.6); opacity: 0; } }
@keyframes veil {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 40, 70, 0); background: rgba(255, 30, 60, 0.02); }
  50% { box-shadow: inset 0 0 160px 40px rgba(255, 40, 70, 0.55); background: rgba(255, 30, 60, 0.1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  body[data-status="alarm"] .alarm-veil { opacity: 1; box-shadow: inset 0 0 120px 30px rgba(255, 40, 70, 0.5); }
}

/* ---- tablets and phones ---- */

@media (max-width: 860px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "status" "map" "stats" "log";
  }
  .map-card { min-height: 340px; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .topbar .tagline { margin-top: 4px; font-size: 11px; letter-spacing: 0.02em; }
  .topbar-logout { display: none; }
  .footer-logout { display: block; }
  .brand { gap: 10px; }
  .brand .emblem { width: 36px; height: 36px; }
  .wordmark-the { font-size: 8.5px; letter-spacing: 0.42em; }
  .wordmark-name { font-size: 15.5px; letter-spacing: 0.05em; }
  .link span { display: none; }
  .link { padding: 0 4px; height: 34px; }
  .ring { width: 196px; height: 196px; }
  .status-word { font-size: 26px; max-width: 130px; }
  .stat { padding: 12px 18px; }
  .stats .card-title { padding: 0 18px; }
  .stat-big { font-size: 27px; }
  .log li { grid-template-columns: 70px 10px 1fr; }
  .alarm-banner { padding-left: 16px; padding-right: 16px; }
  .alarm-banner strong { font-size: 16px; }
  .map-label { left: 58px; }
}
