/* Heart Pulse — business-district stock-pulse signage.
   The pulsing shape and ring waves live on #stage (canvas). All
   readable text — name, price, ±change, ticker, footer — is DOM,
   sized with clamp() + vmin so it stays legible across 9:16, 16:9,
   and ultra-wide.

   Color tokens: red = up (Japanese 陽線), blue = down (陰線),
   grey = flat. They are pushed in from main.js as custom properties
   on .hud whenever the primary index ticks. */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0a0d;
  color: #ffffff;
  font-family: "Helvetica Neue", "Inter", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "palt" 1;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ───────────────────────────────────────────────────────────────────
   HUD — DOM information layer.

   Layout strategy
   ───────────────
   • A position:fixed grid divides the screen into 4 rows:
       1) top status bar       (auto)
       2) primary index block  (auto)
       3) free pulse region    (1fr — canvas shows through here)
       4) satellites + ticker  (auto)
       5) foot                 (auto)
     The pulse canvas is *behind* this grid; the 1fr middle row is
     the breathing area we leave empty.
   • In landscape, primary moves to the left third and satellites
     stack on the right third; the centre column stays empty so the
     pulse takes the visual centre.
   ─────────────────────────────────────────────────────────────────── */

.hud {
  --pulse-up:   #E53935;
  --pulse-down: #1E88E5;
  --pulse-flat: #7A8290;
  --pulse:      var(--pulse-flat);
  --ink:        rgba(255, 255, 255, 0.94);
  --ink-dim:    rgba(255, 255, 255, 0.50);
  --ink-faint:  rgba(255, 255, 255, 0.18);

  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: var(--ink);
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  grid-template-columns: 1fr;
  padding: clamp(14px, 2.6vmin, 48px);
  gap: clamp(10px, 1.6vmin, 24px);
  box-sizing: border-box;
}

/* ── 1. Top status bar ─────────────────────────────────────────── */
.hud__top {
  grid-row: 1;
  display: flex; justify-content: space-between; align-items: center;
  font: 500 clamp(9px, 1.15vmin, 13px)/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.28em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.hud__status::before {
  content: "";
  display: inline-block;
  width: 0.6em; height: 0.6em; margin-right: 0.7em;
  border-radius: 50%;
  background: var(--pulse);
  vertical-align: 0.05em;
  transform: scale(var(--pulse-scale, 1));
  transition: transform 80ms ease-out;
}

/* ── 2. Primary index ──────────────────────────────────────────── */
.hud__primary {
  grid-row: 2;
  display: flex; flex-direction: column; align-items: center; gap: 0.2em;
}
.hud__label {
  display: flex; align-items: baseline; gap: clamp(8px, 1.4vmin, 18px);
  color: var(--ink-dim);
  font-size: clamp(10px, 1.3vmin, 15px);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.hud__name {
  color: var(--ink);
  letter-spacing: 0.14em;
  font-weight: 500;
}
.hud__sym {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.2em;
}
.hud__price {
  font-size: clamp(38px, 9vmin, 132px);
  font-weight: 200;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud__change {
  font-size: clamp(13px, 2.2vmin, 28px);
  font-weight: 400;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--pulse);
}

/* ── 4. Satellites ─────────────────────────────────────────────── */
.hud__satellites {
  grid-row: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.6vmin, 24px);
  border-top: 1px solid var(--ink-faint);
  padding-top: clamp(8px, 1.4vmin, 20px);
}
.sat {
  display: flex; flex-direction: column; align-items: center; gap: 0.18em;
  text-align: center;
}
.sat__name {
  font-size: clamp(9px, 1.05vmin, 12px);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.sat__price {
  font-size: clamp(16px, 2.6vmin, 30px);
  font-weight: 300;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.sat__chg {
  font-size: clamp(10px, 1.3vmin, 14px);
  font-weight: 500;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.sat[data-trend="up"]   .sat__chg { color: var(--pulse-up); }
.sat[data-trend="down"] .sat__chg { color: var(--pulse-down); }
.sat[data-trend="flat"] .sat__chg { color: var(--pulse-flat); }

/* ── Ticker — old-school horizontal tape ───────────────────────── */
.hud__ticker {
  grid-row: 5;
  position: relative;
  height: clamp(18px, 2.4vmin, 28px);
  overflow: hidden;
  border-top: 1px solid var(--ink-faint);
  padding-top: clamp(6px, 1vmin, 12px);
  color: var(--ink-dim);
  font: 500 clamp(11px, 1.4vmin, 16px)/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
.hud__ticker-track {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}
.hud__ticker-track .tk-up   { color: var(--pulse-up); }
.hud__ticker-track .tk-down { color: var(--pulse-down); }
.hud__ticker-track .tk-sep  { color: var(--ink-faint); margin: 0 1.6em; }

/* ── Foot ──────────────────────────────────────────────────────── */
.hud__foot {
  grid-row: 6;
  display: none;     /* foot collapses into ticker row spacing on small screens */
}

/* ───────────────────────────────────────────────────────────────────
   Landscape — primary moves to left third, satellites to right third,
   centre column stays clear so the pulse owns the visual middle.
   ─────────────────────────────────────────────────────────────────── */

@media (orientation: landscape) {
  .hud {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    column-gap: clamp(20px, 3vmin, 56px);
  }

  .hud__top {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .hud__primary {
    grid-row: 2;
    grid-column: 1;
    align-items: flex-start;
    align-self: center;
  }
  .hud__primary .hud__price {
    font-size: clamp(40px, 8.6vmin, 160px);
  }

  .hud__satellites {
    grid-row: 2;
    grid-column: 3;
    align-self: center;
    border-top: 0;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vmin, 32px);
  }
  .sat {
    align-items: flex-end;
    text-align: right;
  }

  .hud__ticker {
    grid-row: 3;
    grid-column: 1 / -1;
  }
}

/* ── Debug HUD (?debug=1) ──────────────────────────────────────── */
#debug-hud {
  position: fixed;
  left: 12px; bottom: 10px;
  font: 11px/1.45 ui-monospace, "SF Mono", "Courier New", Menlo, monospace;
  color: rgba(255, 255, 255, 0.55);
  white-space: pre;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.02em;
  z-index: 10;
  margin: 0;
  display: none;
}
body.debug #debug-hud { display: block; }
