/* Handheld radio. Uses only tokens from theme.css. Escrowed; theme.css is the customer surface.
   No backdrop-filter anywhere: it renders as a black box in some FiveM NUI builds. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: clamp(11px, 1.25vh, 18px); }

body {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

.ico {
  width: 1.15rem; height: 1.15rem;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Positioning ── */
#wrap, #toasts, #hud { position: fixed; }
body[data-position="bottom-right"] #wrap { right: 2rem; bottom: 2rem; }
body[data-position="bottom-left"]  #wrap { left: 2rem;  bottom: 2rem; }
body[data-position="top-right"]    #wrap { right: 2rem; top: 7.5rem; }
body[data-position="top-left"]     #wrap { left: 2rem;  top: 7.5rem; }
body[data-position="center"]       #wrap { left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* Toasts sit on the edge away from the radio, and below the HUD when it's in the same corner. */
#toasts { top: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 0.6rem; z-index: 5; }
body[data-hud="top-right"] #toasts { top: 5rem; }
body[data-position^="top"] #toasts { top: auto; bottom: 2rem; }
body[data-position$="left"] #toasts { right: auto; left: 2rem; }

body[data-hud="bottom-left"]  #hud { left: 1.5rem;  bottom: 1.5rem; }
body[data-hud="bottom-right"] #hud { right: 1.5rem; bottom: 1.5rem; }
body[data-hud="top-left"]     #hud { left: 1.5rem;  top: 1.5rem; }
body[data-hud="top-right"]    #hud { right: 1.5rem; top: 1.5rem; }

/* ── HUD strip ── */
.hud {
  display: flex; align-items: center; gap: 0.6rem;
  height: 2.4rem; padding: 0 0.9rem;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.hud .ico { color: var(--accent); }
.hud-freq { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); letter-spacing: 0.02em; }
.hud-talk { display: flex; align-items: center; gap: 0.4rem; color: var(--text-primary); max-width: 16rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hud-talk:empty { display: none; }
.hud-talk::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--success); animation: pulse 1.5s ease-in-out infinite; }
.hud.tx .hud-talk::before { background: var(--danger-solid); }
.hud.nosignal { color: var(--text-muted); }
.hud.nosignal .ico { color: var(--danger); }

.pill {
  display: inline-flex; align-items: center;
  height: 1.4rem; padding: 0 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.15em; text-transform: uppercase;
  /* --pill / --pill-soft / --pill-line are set from JS per frequency range (no color-mix in older NUI builds) */
  color: var(--pill, var(--accent));
  background: var(--pill-soft, var(--accent-soft));
  border: 1px solid var(--pill-line, rgba(168, 85, 247, 0.3));
}
.pill:empty { display: none; }

/* ── Device ── */
.device {
  position: relative;
  width: 15.5rem;
  padding: 1rem 1rem 1.2rem;
  border-radius: 1.4rem 1.4rem 1.8rem 1.8rem;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 30%),
    linear-gradient(175deg, var(--shell-hi) 0%, var(--shell-mid) 45%, var(--shell-lo) 100%);
  box-shadow:
    inset 0 2px 0 var(--shell-edge),
    inset 0 -6px 10px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(0, 0, 0, 0.4),
    0 12px 22px rgba(0, 0, 0, 0.55);
  animation: rise var(--dur-med) var(--ease);
}
.antenna {
  position: absolute; left: 1.6rem; bottom: calc(100% - 0.4rem);
  width: 1.2rem; height: 5.5rem;
  border-radius: 0.6rem 0.6rem 0.2rem 0.2rem;
  background: linear-gradient(90deg, #0c0b10, #2a2733 45%, #0c0b10);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  z-index: -1;
}

.top-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.7rem; }
.brand { flex: 1; display: flex; align-items: baseline; gap: 0.5rem; }
.wordmark { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text-primary); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5); }
.model { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.4em; color: rgba(255, 255, 255, 0.5); }

.round {
  width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--key-hi), var(--key-lo));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: var(--key-label);
}
.round:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.power.on { color: var(--success); }
.panic { background: radial-gradient(circle at 35% 30%, #f05252, #8f1d1d); color: #fff; }
.close { width: 1.8rem; height: 1.8rem; }
.close .ico { width: 0.95rem; height: 0.95rem; }

.led { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #241f2c; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); }
.led.on { background: var(--success); box-shadow: 0 0 8px 2px rgba(34, 197, 94, 0.6); }
.led.rx { background: var(--accent-hover); box-shadow: 0 0 8px 2px var(--lcd-glow); }
.led.tx { background: #ff3b3b; box-shadow: 0 0 8px 2px rgba(255, 59, 59, 0.75); }

.grille {
  height: 2.4rem; margin: 0 0.4rem 0.8rem;
  border-radius: 0.6rem;
  background:
    radial-gradient(circle, rgba(0, 0, 0, 0.75) 0.18rem, transparent 0.2rem) 0 0 / 0.65rem 0.65rem,
    linear-gradient(var(--shell-lo), var(--shell-mid));
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* ── LCD ── */
.bezel {
  padding: 0.45rem;
  border-radius: 0.8rem;
  background: var(--lcd-bezel);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.12);
  margin-bottom: 0.9rem;
}
.lcd {
  position: relative;
  height: 9rem;
  padding: 0.55rem 0.7rem 0.45rem;
  border-radius: 0.4rem;
  background: radial-gradient(ellipse at 50% 30%, #17121f, var(--lcd-bg));
  font-family: var(--font-lcd);
  color: var(--lcd-ink);
  text-shadow: 0 0 6px var(--lcd-glow);
  overflow: hidden;
  transition: opacity var(--dur-med) var(--ease);
}
.lcd.off { color: transparent; text-shadow: none; }
.lcd.off > * { opacity: 0; }
.lcd-strip { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--strip, transparent); }
.lcd-status { display: flex; align-items: center; gap: 0.6rem; font-size: 1.05rem; line-height: 1; }
.lcd-status #lcd-vol { margin-left: auto; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 0.8rem; }
.bars i { display: block; width: 3px; background: var(--lcd-ink); box-shadow: 0 0 4px var(--lcd-glow); }
.bars i:nth-child(1) { height: 25%; } .bars i:nth-child(2) { height: 50%; }
.bars i:nth-child(3) { height: 75%; } .bars i:nth-child(4) { height: 100%; }
.bars.none i { background: var(--lcd-dim); box-shadow: none; }
.lcd-freq { font-size: 3.4rem; line-height: 1; margin-top: 0.4rem; letter-spacing: 0.04em; white-space: nowrap; }
.cursor { animation: blink 1s steps(2, jump-none) infinite; }
.lcd-freq.dim { color: var(--lcd-dim); text-shadow: none; }
.lcd-label { font-size: 1.3rem; line-height: 1; margin-top: 0.15rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcd-label.alert { animation: blink 1s steps(2, jump-none) infinite; }
.lcd-presets { position: absolute; left: 0.7rem; right: 0.7rem; bottom: 0.4rem; display: flex; gap: 0.6rem; font-size: 1rem; }
.lcd-presets span { color: var(--lcd-dim); text-shadow: none; }
.lcd-presets span.set { color: var(--lcd-ink); text-shadow: 0 0 6px var(--lcd-glow); }
.lcd-presets span.active { text-decoration: underline; }

/* LCD menu: title, up to four rows, a key hint at the bottom. */
.lcd-menu { position: absolute; left: 0.7rem; right: 0.7rem; top: 1.7rem; bottom: 0.4rem; display: flex; flex-direction: column; }
.lcd-menu-title { font-size: 1.15rem; line-height: 1.1; letter-spacing: 0.1em; text-transform: uppercase; border-bottom: 1px solid var(--lcd-dim); padding-bottom: 0.15rem; }
.lcd-menu-rows { flex: 1; overflow: hidden; padding-top: 0.15rem; }
.lcd-row { display: flex; gap: 0.4rem; font-size: 1.15rem; line-height: 1.12; white-space: nowrap; }
.lcd-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; }
.lcd-row .value { text-transform: uppercase; }
.lcd-row.sel { background: var(--lcd-ink); color: var(--lcd-bg); text-shadow: none; padding: 0 0.2rem; margin: 0 -0.2rem; }
.lcd-row.dim { color: var(--lcd-dim); text-shadow: none; }
.lcd-entry { font-size: 1.7rem; line-height: 1.2; padding-top: 0.3rem; white-space: nowrap; overflow: hidden; }
.lcd-menu-foot { font-size: 0.9rem; line-height: 1; color: var(--lcd-dim); text-shadow: none; letter-spacing: 0.05em; text-transform: uppercase; }

/* ── Keys ── */
.controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; margin-bottom: 0.5rem; }
.presets { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.presets:empty { display: none; }
.presets .key { flex: 1; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }

.key {
  height: 2.35rem;
  border-radius: 0.55rem;
  background: linear-gradient(var(--key-hi), var(--key-lo));
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--key-label);
  font-weight: 600; font-size: 1rem;
  transition: transform 60ms linear;
}
.key.small { height: 2rem; font-size: 0.66rem; letter-spacing: 0.04em; }
.key:hover { color: #fff; }
.key:active, .key.pressed { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.key.menu { color: var(--accent-hover); }
.key.menu.on { background: linear-gradient(var(--accent-strong), var(--accent-dark)); color: var(--on-accent); }
.key.enter {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-dark));
  color: var(--on-accent);
  letter-spacing: 0.15em; font-size: 0.85rem;
}
.key.preset { font-family: var(--font-mono); font-size: 0.8rem; }
.key.preset.set { color: var(--accent-hover); }
.key.holding { box-shadow: 0 0 0 2px var(--accent), 0 2px 0 rgba(0, 0, 0, 0.65); }

/* ── Toasts ── */
.toast {
  max-width: 22rem;
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem; color: var(--text-primary);
  animation: slide var(--dur-med) var(--ease);
}
.toast.error { border-left-color: var(--danger); }
.toast.panic { border-left-color: var(--danger-solid); background: #2a0d12; font-weight: 600; animation: slide var(--dur-med) var(--ease), urgent 1.2s ease-in-out infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes urgent { 0%, 100% { box-shadow: var(--shadow-md), 0 0 0 0 rgba(229, 62, 62, 0); } 50% { box-shadow: var(--shadow-md), 0 0 0 3px rgba(229, 62, 62, 0.45); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
