/* ============================================================================
   AFK · Web UI prototype — shared design system
   "The night shift for your codebase" — a nocturnal ground-station aesthetic.

   Colour-blind safety (a first-class constraint):
   - Palette derives from the Okabe–Ito colour-blind-safe set.
   - STATUS is never encoded by colour alone. Every state carries a distinct
     ICON (shape) + TEXT LABEL, so it reads identically under protanopia,
     deuteranopia, tritanopia and greyscale. Colour is redundant reinforcement.
   - Success = sky-blue, Failure = vermillion + ✕. Blue↔orange is the single
     most-separable pair across every type of colour-blindness.

   Performance:
   - No frameworks. One cached stylesheet. Animations are transform/opacity only
     (compositor-friendly). Motion collapses under prefers-reduced-motion.
   ========================================================================== */

/* ----- Tokens ------------------------------------------------------------ */
:root {
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Surfaces — deep night, faint blue cast */
  --void:    #07080c;
  --base:    #0b0d13;
  --panel:   #10131c;
  --raised:  #171a26;
  --overlay: #1e2231;
  --frost:   rgba(18, 22, 33, 0.72);

  /* Hairlines */
  --line:        #23283a;
  --line-bright: #333a52;
  --line-signal: rgba(78, 166, 230, 0.28);

  /* Ink */
  --ink:   #ebedf4;
  --ink-2: #a2a8bd;
  --ink-3: #6b7288;
  --ink-4: #474d61;

  /* Signal accents (Okabe–Ito derived, colour-blind safe) */
  --signal:     #4ea6e6;  /* sky blue — primary, "active / ready" */
  --signal-2:   #7cc0f0;
  --signal-dim: #2b6ea3;
  --amber:      #e8a32c;  /* orange — "running / attention" */
  --amber-dim:  #9c6d1a;
  --teal:       #2dbe9b;  /* bluish-green — "merged / done" */
  --vermillion: #ec6a45;  /* red-orange — "failed" (always with ✕) */
  --iris:       #b78be0;  /* reddish-purple — category accent */

  /* Tints */
  --signal-tint: rgba(78, 166, 230, 0.12);
  --amber-tint:  rgba(232, 163, 44, 0.12);
  --teal-tint:   rgba(45, 190, 155, 0.12);
  --verm-tint:   rgba(236, 106, 69, 0.12);
  --iris-tint:   rgba(183, 139, 224, 0.12);

  /* Radii + shadow */
  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-1: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px -14px rgba(0,0,0,0.8);
  --shadow-2: 0 24px 60px -28px rgba(0,0,0,0.85);
  --glow-signal: 0 0 0 1px var(--line-signal), 0 10px 34px -12px rgba(78,166,230,0.55);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --maxw: 1200px;
}

/* ----- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-mono);
  background: var(--base);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(78,166,230,0.32); color: #fff; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----- Atmosphere: night sky, grid, horizon glow ------------------------- */
/* A fixed, painted-once background layer. Cheap: static gradients, no JS. */
.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 620px at 50% -8%, rgba(78,166,230,0.10), transparent 60%),
    radial-gradient(900px 500px at 85% 8%, rgba(183,139,224,0.06), transparent 60%),
    linear-gradient(180deg, var(--void), var(--base) 42%, var(--base));
}
/* Faint engineering grid */
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(120,140,180,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(120,140,180,0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
}
/* Horizon glow — the light on the night horizon */
.sky::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -30vh;
  width: 150vw;
  height: 60vh;
  transform: translateX(-50%);
  background: radial-gradient(50% 100% at 50% 100%, rgba(78,166,230,0.14), transparent 70%);
  pointer-events: none;
}

/* Starfield — two tiny repeating layers, GPU-drift. Decorative only. */
.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 70% 12%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1px 1px at 42% 62%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 88% 46%, rgba(190,220,255,0.6), transparent),
    radial-gradient(1px 1px at 12% 78%, rgba(255,255,255,0.45), transparent),
    radial-gradient(1px 1px at 60% 82%, rgba(255,255,255,0.4), transparent);
  background-repeat: no-repeat;
  animation: drift 120s linear infinite;
}
@keyframes drift { to { transform: translate3d(0, -40px, 0); } }

/* ----- Layout helpers ---------------------------------------------------- */
.wrap { width: min(100% - 40px, var(--maxw)); margin-inline: auto; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--signal-2);
  font-weight: 600;
}
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.mono { font-family: var(--font-mono); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.02; letter-spacing: -0.02em; }

/* ----- Wordmark + beacon mark -------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: 11px; }
.beacon {
  width: 26px; height: 26px; flex: none;
  position: relative;
  display: grid; place-items: center;
}
.beacon svg { width: 26px; height: 26px; overflow: visible; }
.beacon .wave { transform-origin: center; }
.beacon .w1 { animation: beacon 2.6s var(--ease-in-out) infinite; }
.beacon .w2 { animation: beacon 2.6s var(--ease-in-out) infinite 0.55s; }
.beacon .w3 { animation: beacon 2.6s var(--ease-in-out) infinite 1.1s; }
@keyframes beacon {
  0%   { opacity: 0.9; transform: scale(0.35); }
  70%  { opacity: 0;   transform: scale(1); }
  100% { opacity: 0;   transform: scale(1); }
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.wordmark b { color: var(--signal); font-weight: 800; }

/* ----- Buttons ----------------------------------------------------------- */
.btn {
  --bg: var(--raised);
  --bd: var(--line-bright);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  padding: 11px 18px;
  border-radius: var(--r);
  background: var(--bg);
  border: 1px solid var(--bd);
  color: var(--ink);
  transition: transform 0.18s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.25s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); border-color: var(--signal); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }
.btn--primary {
  --bg: linear-gradient(180deg, #59aeea, var(--signal));
  --bd: transparent;
  color: #04121e;
  font-weight: 700;
  box-shadow: var(--glow-signal);
}
.btn--primary:hover { box-shadow: 0 0 0 1px var(--signal-2), 0 16px 40px -12px rgba(78,166,230,0.7); border-color: transparent; }
.btn--ghost { --bg: transparent; --bd: var(--line); }
.btn--sm { padding: 8px 13px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn--lg { padding: 14px 24px; font-size: 15px; }
.btn--block { width: 100%; }

/* ----- Panels / cards ---------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 40%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.panel-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-h h3 { font-size: 14px; letter-spacing: 0.01em; font-family: var(--font-mono); font-weight: 700; text-transform: uppercase; }
.panel-h .eyebrow { color: var(--ink-3); }

/* ----- Status system (colour + ICON + LABEL = colour-blind safe) --------- */
/* Each status renders a shape-distinct glyph AND a text label. */
.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  padding: 4px 9px 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--bd, var(--line-bright));
  background: var(--bg, transparent);
  color: var(--fg, var(--ink-2));
  text-transform: uppercase;
  white-space: nowrap;
}
.status .glyph { width: 13px; height: 13px; flex: none; display: grid; place-items: center; }
.status .glyph svg { width: 13px; height: 13px; }

.status.is-queued   { --fg: var(--ink-2);    --bd: var(--line-bright); --bg: rgba(255,255,255,0.03); }
.status.is-running  { --fg: var(--amber);     --bd: var(--amber-dim);   --bg: var(--amber-tint); }
.status.is-review   { --fg: var(--signal-2);  --bd: var(--signal-dim);  --bg: var(--signal-tint); }
.status.is-merged   { --fg: var(--teal);      --bd: #1f6f5c;            --bg: var(--teal-tint); }
.status.is-failed   { --fg: var(--vermillion);--bd: #a5432c;            --bg: var(--verm-tint); }
.status.is-abstained{ --fg: var(--ink-3);     --bd: var(--line-bright); --bg: transparent; }

/* Running glyph spins; motion is itself a redundant cue for "in progress". */
.status.is-running .glyph svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Signal dot (live indicator) --------------------------------------- */
.pulse { position: relative; width: 8px; height: 8px; flex: none; }
.pulse i {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--c, var(--signal));
}
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--c, var(--signal));
  animation: ping 1.8s var(--ease-in-out) infinite;
}
@keyframes ping { 0% { transform: scale(1); opacity: 0.55; } 80%,100% { transform: scale(3); opacity: 0; } }

/* ----- Meter / gauge (guardrails) ---------------------------------------- */
.meter { display: grid; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.meter-top b { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }
.meter-track {
  height: 7px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden; position: relative;
  border: 1px solid var(--line);
}
.meter-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--signal-dim), var(--signal));
  transition: width 0.8s var(--ease);
}
.meter-fill.warn { background: linear-gradient(90deg, var(--amber-dim), var(--amber)); }
.meter-fill.hot  { background: linear-gradient(90deg, #a5432c, var(--vermillion)); }

/* ----- Chips / tags ------------------------------------------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-bright); color: var(--ink-2);
  background: rgba(255,255,255,0.02);
}
.kbd {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--line-bright); border-bottom-width: 2px;
  background: var(--raised); color: var(--ink-2);
}

/* ----- Divider ----------------------------------------------------------- */
.hr { height: 1px; background: var(--line); border: 0; }

/* ----- Scrollbar --------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-bright) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

/* ----- Entrance animation (staggered reveal) ----------------------------- */
.rise { opacity: 0; transform: translateY(14px); animation: rise 0.7s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .stars, .beacon .wave, .status.is-running .glyph svg, .pulse::after { animation: none !important; }
  .rise { animation: none; opacity: 1; transform: none; }
  .btn:hover { transform: none; }
}

/* ----- Accessibility utility -------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--signal); color: #04121e; font-weight: 700;
  padding: 10px 16px; border-radius: 10px; transition: top 0.2s;
}
.skip-link:focus { top: 12px; }
