/* ============================================================
   TOPMANIDMB Design System — hud.css
   ชุดคอมโพเนนต์ HUD (ขับด้วยโทเคนจาก theme.css ทั้งหมด)
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--thai); background: var(--bg); color: var(--ink);
  overflow-x: hidden; -webkit-font-smoothing: antialiased; min-height: 100svh;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: inherit; }
button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 3px;
}

/* ---------- บรรยากาศ (atmosphere) ---------- */
.nebula { position: fixed; inset: 0; z-index: -2; pointer-events: none; background: var(--bg-grad); opacity: var(--neb-op); }
.starfield { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--star-op); transition: opacity .4s; }
.starfield span { position: absolute; border-radius: 50%; background: #cfe6ff; opacity: var(--o);
  box-shadow: 0 0 4px #9fd0ff; animation: tw linear infinite alternate; }
@keyframes tw { from { opacity: calc(var(--o) * .25) } to { opacity: var(--o) } }
.scanline { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: var(--scan-op); mix-blend-mode: overlay;
  background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(0,0,0,.18) 2px 3px); transition: opacity .4s; }

/* ---------- โครง ---------- */
.app { position: relative; z-index: 0; min-height: 100svh; display: flex; flex-direction: column; }
.wrap { position: relative; z-index: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 clamp(18px,5vw,56px); flex: 1; }

/* ---------- HUD bar ---------- */
.hud { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px clamp(18px,5vw,56px); border-bottom: 1px solid var(--line); background: var(--hud-bg); backdrop-filter: blur(12px); }
.hud-brand { display: flex; align-items: center; gap: 12px; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; font-family: var(--hud-font); font-weight: 700; font-size: 22px;
  color: var(--solid-ink); background: var(--solid-bg); box-shadow: 0 0 18px rgba(255,203,45,.35), inset 0 1px 0 rgba(255,255,255,.6); flex: none; }
.bword { font-family: var(--hud-font); font-weight: 700; font-size: 18px; letter-spacing: .22em; color: var(--ink); }
.btag { font-family: var(--hud-font); font-weight: 500; font-size: 10.5px; letter-spacing: .42em; color: var(--cyan2); }
.hud-status { display: flex; align-items: center; gap: 9px; font-family: var(--hud-font); font-weight: 500; font-size: 12.5px; letter-spacing: .14em; color: var(--muted); }
.status-text { white-space: nowrap; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--status-success); box-shadow: 0 0 10px var(--status-success); animation: bl 1.6s infinite; }
.clock { font-variant-numeric: tabular-nums; color: var(--accent-text); margin-left: 4px; }
@keyframes bl { 50% { opacity: .3 } }
/* ปุ่มสลับธีม */
.theme-btn { min-height: 44px; font-family: var(--hud-font); font-weight: 600; font-size: 13px; letter-spacing: .06em; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 12px; transition: .2s; display: inline-flex; align-items: center; gap: 6px; }
.theme-btn:hover { border-color: var(--cyan); color: var(--cyan2); }

@media (max-width: 640px) {
  .hud { align-items: flex-start; flex-wrap: wrap; gap: 10px 14px; padding: 12px 24px 13px; }
  .hud-brand { min-width: 0; flex: 1 1 100%; padding-right: 54px; }
  .bword { font-size: 16px; letter-spacing: .18em; }
  .btag { font-size: 9.5px; letter-spacing: .34em; }
  .hud-status { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; font-size: 11.5px; letter-spacing: .1em; }
  .status-text { overflow: hidden; text-overflow: ellipsis; }
  .clock { display: none; }
  .theme-btn { position: absolute; top: 9px; right: 20px; z-index: 2; flex: none; width: 44px; height: 44px; justify-content: center;
    padding: 0; border-radius: 8px; background: var(--hud-bg); border-color: var(--border-strong);
    box-shadow: 0 0 18px rgba(255,203,45,.16), inset 0 1px 0 rgba(255,255,255,.12);
    font-size: 0; letter-spacing: 0; }
  .theme-btn::before { content: "◐"; display: block; font-size: 19px; line-height: 1; color: var(--gold); text-shadow: 0 0 10px rgba(255,203,45,.7); }
  .theme-btn span { display: none; }
}

/* ---------- hero + emblem + shine ---------- */
.hero { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: center; padding: clamp(26px,5vw,60px) 0 30px; }
.emblem-stage { order: -1; display: grid; place-items: center; perspective: 1100px; padding: 6px; }
.emblem-tilt { transition: transform .2s cubic-bezier(.22,1,.36,1); will-change: transform; }
.emblem { width: min(78vw,340px); height: auto; filter: var(--emblem-shadow); }
.eyebrow { display: inline-block; font-family: var(--hud-font); font-weight: 600; font-size: 12.5px; letter-spacing: .24em; color: var(--accent-text); text-transform: uppercase; }
h1, .h1 { font-family: var(--display); font-weight: 600; font-size: clamp(33px,8vw,62px); line-height: 1.08; letter-spacing: 0; margin: 16px 0; color: var(--ink); }
:root[data-theme="ivory"] h1, :root[data-theme="ivory"] .h1 { line-height: 1.22; }
:root[data-theme="official"] h1, :root[data-theme="official"] .h1 { line-height: 1.24; }
.grad { background: var(--shine); background-size: 200% auto; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: shine 6s linear infinite; }
@keyframes shine { to { background-position: 200% center } }
.lead { font-size: clamp(14px,1.5vw,17px); line-height: 1.8; color: var(--muted); max-width: 34em; margin-bottom: 28px; }
.hero-cta { display: flex; gap: 13px; flex-wrap: wrap; }
.btn-solid, .btn-ghost { min-height: 44px; font-family: var(--hud-font); font-weight: 600; font-size: 15px; letter-spacing: .04em; padding: 12px 26px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; transition: transform .25s, box-shadow .3s; }
.btn-solid { color: var(--solid-ink); background: var(--solid-bg); box-shadow: var(--solid-glow); }
.btn-ghost { color: var(--ink); border: 1px solid var(--line); }
.btn-solid:hover { transform: translateY(-2px); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan2); transform: translateY(-2px); }
@media (min-width: 880px) {
  .hero { grid-template-columns: 1.05fr .95fr; gap: 40px; padding-top: 48px; }
  .emblem-stage { order: 1; } .emblem { width: min(40vw,420px); }
}

/* ---------- stat cards (มุมวงเล็บ) ---------- */
.stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-top: 8px; }
@media (min-width: 880px) { .stats { grid-template-columns: repeat(4,1fr); gap: 18px; } }
.stat-card { position: relative; padding: 20px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .85; }
.stat-card .c { position: absolute; width: 9px; height: 9px; border: 1.5px solid var(--accent); opacity: .6; }
.c.tl { top: 6px; left: 6px; border-right: 0; border-bottom: 0; } .c.tr { top: 6px; right: 6px; border-left: 0; border-bottom: 0; }
.c.bl { bottom: 6px; left: 6px; border-right: 0; border-top: 0; } .c.br { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }
.stat-val { font-family: var(--hud-font); font-weight: 700; font-size: clamp(26px,4vw,38px); line-height: 1; color: var(--stat-num); font-variant-numeric: tabular-nums; }
.stat-val .suffix { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat-label { margin-top: 8px; font-size: 13.5px; color: var(--ink); }
.stat-sub { margin-top: 2px; font-size: 11.5px; color: var(--faint); }

/* ---------- panel · tabs · bars ---------- */
.panel { margin: 34px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-bg); padding: clamp(18px,3vw,28px); backdrop-filter: blur(6px); }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.panel-title { font-family: var(--hud-font); font-weight: 600; font-size: 15px; letter-spacing: .16em; color: var(--accent-text); }
.tabs { display: flex; gap: 6px; background: var(--input-bg); padding: 4px; border-radius: 6px; border: 1px solid var(--line); flex-wrap: wrap; }
.tab { min-height: 44px; font-family: var(--thai); font-weight: 500; font-size: 13.5px; padding: 8px 18px; border-radius: 4px; color: var(--muted); transition: .25s; }
.tab.on { color: var(--solid-ink); background: var(--solid-bg); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 15px; }
.bar-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; font-size: 14px; }
.bar-k { color: var(--ink); } .bar-v { font-family: var(--hud-font); font-weight: 600; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.bar-track { height: 9px; background: rgba(127,150,190,.14); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 6px; transition: width 1.1s cubic-bezier(.22,1,.36,1); }

/* ---------- info strips ---------- */
.verify-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 10px; padding: 11px 16px; border-radius: 12px;
  background: rgba(91,184,245,.07); border: 1px solid var(--line-2); font-size: 13px; color: var(--muted); line-height: 1.5; }
.verify-bar b { color: var(--ink); font-weight: 600; }
.vchk { flex: 0 0 auto; font-weight: 700; font-size: 12.5px; color: #2f8a52; background: rgba(92,214,160,.14); border: 1px solid rgba(92,214,160,.4); padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.ctx-bar { margin: 0 0 18px; padding: 10px 16px; border-radius: 12px; background: rgba(255,203,45,.06); border: 1px dashed rgba(169,133,47,.35); font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.ctx-bar b { color: var(--accent-text); font-weight: 600; }

.demo-note { min-height: 24px; margin-top: 10px; color: var(--text-secondary); font-size: 12.5px; }

/* ---------- footer ---------- */
.foot { margin-top: 30px; border-top: 1px solid var(--line); padding: 24px clamp(18px,5vw,56px); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--faint); }
.fmark { font-family: var(--hud-font); font-weight: 700; letter-spacing: .18em; color: var(--ink); }
.flink { color: var(--cyan2); text-decoration: none; font-family: var(--hud-font); font-weight: 500; letter-spacing: .06em; transition: color .25s; }
.flink:hover { color: var(--gold2); }

/* ---------- style-guide extras ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill,minmax(120px,1fr)); gap: 12px; }
.sw { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sw .chipc { height: 54px; }
.sw .lbl { padding: 7px 9px; font: 500 11.5px var(--hud-font); letter-spacing: .04em; color: var(--muted); }
.sw .lbl b { display: block; color: var(--ink); font-size: 12.5px; letter-spacing: 0; font-family: var(--thai); }
.sg-h { font-family: var(--hud-font); font-weight: 600; font-size: 12.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan2); margin: 40px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.demo-badge { display: inline-flex; align-items: center; min-height: 28px; margin: -4px 0 12px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 999px;
  color: var(--accent-text); background: var(--panel-bg); font: 600 11px var(--hud-font); letter-spacing: .08em; }

@media (max-width: 640px) {
  :root[data-theme="ivory"] h1, :root[data-theme="ivory"] .h1 { line-height: 1.32; }
  :root[data-theme="official"] h1, :root[data-theme="official"] .h1 { line-height: 1.34; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

html[data-static="1"] *, html[data-static="1"] *::before, html[data-static="1"] *::after {
  animation: none !important;
  transition: none !important;
}
