/* SPDX-License-Identifier: AGPL-3.0-only */
/* ==========================================================================
 * Angel HUD skin  (the "relocation notice" look, applied to the whole dashboard)
 *
 *   html[data-hud="on"]   the HUD skin (default)
 *   html[data-hud="off"]  the classic Aurora look: nothing in this file applies
 *
 * Loaded LAST, after Aurora. Purely additive and scoped: it only restyles the
 * surface (colour, borders, type, glow) and never changes layout or behaviour.
 * Big containers are never clipped (dropdowns/menus live inside them); only
 * small leaf controls get cut corners. All motion stops for reduced-motion
 * users and on small screens.
 * ========================================================================== */

/* --- always-on: the switch itself (visible in both modes) ------------------- */
.hud-toggle {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(241, 212, 138, 0.4);
  background: rgba(10, 8, 16, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #f1d48a;
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  transition: box-shadow 0.2s, background 0.2s;
}
.hud-toggle:hover,
.hud-toggle:focus-visible {
  outline: none;
  background: rgba(241, 212, 138, 0.14);
  box-shadow: 0 0 16px rgba(241, 212, 138, 0.35);
}
.hud-toggle i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a7288;
}
html[data-hud="on"] .hud-toggle i {
  background: #ff3b57;
  box-shadow: 0 0 8px #ff3b57;
}
.hud-scan,
.hud-beam {
  display: none;
}

/* ==========================================================================
 * HUD ON
 * ========================================================================== */
html[data-hud="on"] {
  --hud-cyan: #f1d48a;
  --hud-cyan-soft: rgba(241, 212, 138, 0.55);
  --hud-cyan-line: rgba(241, 212, 138, 0.2);
  --hud-gold: #d6b25e;
  --hud-gold-hi: #f1d48a;
  --hud-crimson: #c4182e;
  --hud-crimson-hi: #ff3b57;
  --hud-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --hud-panel: rgba(14, 10, 22, 0.74);
}

/* --- atmosphere: perspective grid floor + scanlines + sweeping beam --------- */
html[data-hud="on"]::before {
  content: "";
  position: fixed;
  left: -25%;
  right: -25%;
  bottom: -8vh;
  height: 62vh;
  z-index: var(--ka-z-embers, -1);
  pointer-events: none;
  opacity: 0.85;
  transform: perspective(520px) rotateX(64deg);
  transform-origin: 50% 100%;
  background-image:
    repeating-linear-gradient(90deg, rgba(214, 178, 94, 0.32) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(196, 24, 46, 0.42) 0 1px, transparent 1px 64px);
  -webkit-mask-image: linear-gradient(to top, #000 12%, transparent 90%);
  mask-image: linear-gradient(to top, #000 12%, transparent 90%);
}
html[data-hud="on"] .hud-scan {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.55;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px);
}

/* --- panels: HUD frame with gold corner brackets (background layers only) -- */
html[data-hud="on"] body.kurumi .ka-card,
html[data-hud="on"] body.kurumi .ka-stat,
html[data-hud="on"] body.kurumi .card {
  --_b: var(--hud-gold);
  border-color: rgba(214, 178, 94, 0.34);
  border-radius: 4px;
  background-color: var(--hud-panel);
  background-image:
    linear-gradient(var(--_b), var(--_b)), linear-gradient(var(--_b), var(--_b)),
    linear-gradient(var(--_b), var(--_b)), linear-gradient(var(--_b), var(--_b)),
    linear-gradient(var(--_b), var(--_b)), linear-gradient(var(--_b), var(--_b)),
    linear-gradient(var(--_b), var(--_b)), linear-gradient(var(--_b), var(--_b)),
    var(--ka-grad-surface, none);
  background-repeat: no-repeat;
  background-size:
    16px 2px, 2px 16px, 16px 2px, 2px 16px,
    16px 2px, 2px 16px, 16px 2px, 2px 16px,
    auto;
  background-position:
    0 0, 0 0, 100% 0, 100% 0,
    0 100%, 0 100%, 100% 100%, 100% 100%,
    0 0;
}
html[data-hud="on"] body.kurumi .ka-card:hover,
html[data-hud="on"] body.kurumi .ka-stat:hover,
html[data-hud="on"] body.kurumi .card:hover {
  border-color: rgba(241, 212, 138, 0.5);
  box-shadow: 0 0 0 1px rgba(241, 212, 138, 0.12), 0 14px 40px -14px rgba(241, 212, 138, 0.28), var(--ka-shadow-md, none);
}
html[data-hud="on"] body.kurumi .ka-card--gold {
  --_b: var(--hud-gold-hi);
}

html[data-hud="on"] body.kurumi .ka-hero {
  border-color: rgba(214, 178, 94, 0.4);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(241, 212, 138, 0.08), 0 30px 80px -30px rgba(196, 24, 46, 0.35);
}

/* --- type: tracked mono labels, gradient page titles ----------------------- */
html[data-hud="on"] body.kurumi .ka-eyebrow,
html[data-hud="on"] body.kurumi .kurumi-megapanel__title,
html[data-hud="on"] body.kurumi .ka-stat__label,
html[data-hud="on"] body.kurumi .ka-tag,
html[data-hud="on"] body.kurumi .ka-pill {
  font-family: var(--hud-mono);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 600;
}
html[data-hud="on"] body.kurumi .ka-eyebrow {
  color: var(--hud-cyan);
}
html[data-hud="on"] body.kurumi .ka-eyebrow::before {
  content: "> ";
  opacity: 0.8;
}
html[data-hud="on"] body.kurumi h1:not(.ka-hero__title-plain) {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  background: linear-gradient(95deg, var(--hud-gold-hi), var(--hud-gold) 40%, var(--hud-crimson-hi));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
}
html[data-hud="on"] body.kurumi h1 em,
html[data-hud="on"] body.kurumi h1 i {
  font-style: normal;
  -webkit-text-fill-color: transparent;
}
html[data-hud="on"] body.kurumi h2,
html[data-hud="on"] body.kurumi h3 {
  letter-spacing: 0.04em;
}

/* --- buttons: cut-corner glow (leaf elements only) ------------------------- */
html[data-hud="on"] body.kurumi .ka-btn,
html[data-hud="on"] body.kurumi .btn,
html[data-hud="on"] body.kurumi .kurumi-btn-primary {
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
  transition: filter 0.2s, transform 0.2s, background-color 0.2s;
}
html[data-hud="on"] body.kurumi .ka-btn:not(.ka-btn--ghost):not(.ka-btn--icon),
html[data-hud="on"] body.kurumi .kurumi-btn-primary {
  background-image: linear-gradient(95deg, var(--hud-crimson), var(--hud-crimson-hi) 62%, #ff7a59);
  border-color: transparent;
  color: #fff;
}
html[data-hud="on"] body.kurumi .ka-btn--gold {
  background-image: linear-gradient(95deg, #a98030, var(--hud-gold) 50%, var(--hud-gold-hi));
  color: #1a1206;
}
html[data-hud="on"] body.kurumi .ka-btn--ghost {
  background-image: none;
  background-color: rgba(241, 212, 138, 0.06);
  border-color: rgba(241, 212, 138, 0.5);
  color: var(--hud-cyan);
}
html[data-hud="on"] body.kurumi .ka-btn:hover,
html[data-hud="on"] body.kurumi .kurumi-btn-primary:hover {
  filter: brightness(1.14) drop-shadow(0 6px 18px rgba(196, 24, 46, 0.4));
  transform: translateY(-1px);
}
html[data-hud="on"] body.kurumi .ka-btn--ghost:hover {
  background-color: rgba(241, 212, 138, 0.16);
  filter: none;
}
html[data-hud="on"] body.kurumi .ka-btn:focus-visible,
html[data-hud="on"] body.kurumi .btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--hud-cyan);
}

/* --- badges / chips -------------------------------------------------------- */
html[data-hud="on"] body.kurumi .ka-pill,
html[data-hud="on"] body.kurumi .ka-tag,
html[data-hud="on"] body.kurumi .badge {
  border-radius: 0;
  font-family: var(--hud-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

/* --- tables ---------------------------------------------------------------- */
html[data-hud="on"] body.kurumi table thead th,
html[data-hud="on"] body.kurumi .ka-table thead th {
  font-family: var(--hud-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--hud-cyan);
  border-bottom: 1px solid var(--hud-cyan-line);
}
html[data-hud="on"] body.kurumi table tbody tr:hover > * {
  background-color: rgba(241, 212, 138, 0.045);
}

/* --- form fields: cyan focus glow ----------------------------------------- */
html[data-hud="on"] body.kurumi .form-control,
html[data-hud="on"] body.kurumi .form-select,
html[data-hud="on"] body.kurumi input[type="text"],
html[data-hud="on"] body.kurumi input[type="search"],
html[data-hud="on"] body.kurumi input[type="number"],
html[data-hud="on"] body.kurumi textarea,
html[data-hud="on"] body.kurumi select {
  border-radius: 2px;
  border-color: rgba(214, 178, 94, 0.28);
}
html[data-hud="on"] body.kurumi .form-control:focus,
html[data-hud="on"] body.kurumi .form-select:focus,
html[data-hud="on"] body.kurumi input:focus,
html[data-hud="on"] body.kurumi textarea:focus,
html[data-hud="on"] body.kurumi select:focus {
  border-color: var(--hud-cyan);
  box-shadow: 0 0 0 1px rgba(241, 212, 138, 0.4), 0 0 18px rgba(241, 212, 138, 0.18);
  outline: none;
}

/* --- masthead: gold hairline + cyan active marker -------------------------- */
html[data-hud="on"] body.kurumi .kurumi-masthead__bar {
  border-bottom: 1px solid rgba(214, 178, 94, 0.32);
  box-shadow: 0 1px 0 rgba(241, 212, 138, 0.1), 0 10px 40px -18px rgba(0, 0, 0, 0.8);
}
html[data-hud="on"] body.kurumi .kurumi-megabtn[aria-expanded="true"],
html[data-hud="on"] body.kurumi .kurumi-megabtn.is-active {
  color: var(--hud-cyan);
}
html[data-hud="on"] body.kurumi .kurumi-megapanel,
html[data-hud="on"] body.kurumi .kurumi-menu {
  border: 1px solid rgba(214, 178, 94, 0.4);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(241, 212, 138, 0.08), 0 24px 60px -18px rgba(0, 0, 0, 0.85);
}
html[data-hud="on"] body.kurumi .kurumi-megalink:hover,
html[data-hud="on"] body.kurumi .kurumi-menu__item:hover {
  background: rgba(241, 212, 138, 0.07);
}

/* --- links, selection, scrollbars ----------------------------------------- */
html[data-hud="on"] ::selection {
  background: rgba(241, 212, 138, 0.28);
  color: #fff;
}
html[data-hud="on"] {
  scrollbar-color: rgba(214, 178, 94, 0.5) rgba(10, 8, 16, 0.6);
}

/* ==========================================================================
 * Calm down: reduced motion and small screens
 * ========================================================================== */
@media (max-width: 720px) {
  html[data-hud="on"]::before {
    opacity: 0.45;
    height: 46vh;
  }
  .hud-toggle {
    left: 10px;
    bottom: 10px;
  }
}

/* ==========================================================================
 * Lite mode: the big slow background animations stay off while HUD is on
 * ========================================================================== */
html[data-hud="on"] body.kurumi::after,
html[data-hud="on"] .ka-embers {
  animation: none !important;
}
html[data-hud="on"] .ka-embers {
  display: none !important;
}

/* ==========================================================================
 * Boot terminal (typed once, then still)
 * ========================================================================== */
.hud-term {
  display: none;
}
html[data-hud="on"] .hud-term {
  display: block;
  margin: 1.1rem 0 0;
  padding: 0.75rem 0.95rem;
  max-width: 34rem;
  border: 1px solid rgba(214, 178, 94, 0.3);
  border-left: 3px solid var(--hud-crimson-hi);
  background: rgba(0, 0, 0, 0.4);
  font: 500 12.5px/1.75 var(--hud-mono);
  color: var(--hud-gold-hi);
}
.hud-term__line {
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  width: 0;
  animation: hud-type 0.8s steps(var(--n, 30), end) forwards;
  animation-delay: calc(var(--i, 0) * 0.85s + 0.2s);
}
.hud-term--static .hud-term__line {
  animation: none;
  width: auto;
}
.hud-term__line b { font-weight: 600; }
.hud-term__line .ok { color: #7dffb2; }
.hud-term__line .warn { color: var(--hud-gold); }
.hud-term__line .bad { color: var(--hud-crimson-hi); }
.hud-term__line .dim { color: rgba(241, 212, 138, 0.55); }
.hud-term__cur {
  display: inline-block;
  width: 7px;
  height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--hud-gold-hi);
  animation: hud-blink 1s steps(1) infinite;
}
@keyframes hud-type {
  from { width: 0; }
  to { width: calc(var(--n, 30) * 1ch); }
}
@keyframes hud-blink {
  50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-term__line { animation: none; width: auto; }
  .hud-term__cur { animation: none; }
}
