/* ═══════════════════════════════════════════════════════════════
   HT — Handy Talkie PTT  |  Tactical Radio UI  |  V1.5
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts already in HTML ── */

/* ── CSS Variables ───────────────────────────────────────────── */
:root {
  --neon:        #39ff14;
  --neon-dim:    #1a7a09;
  --neon-glow:   rgba(57, 255, 20, 0.4);
  --amber:       #ffb300;
  --amber-dim:   #7a5500;
  --red-hot:     #ff3d3d;
  --bg-base:     #060d06;
  --bg-panel:    #0c170c;
  --bg-card:     #101e10;
  --bg-lcd:      #0a1a08;
  --border:      #1e381e;
  --border-lit:  #2a5c2a;
  --text-main:   #c8e6c8;
  --text-dim:    #5a7a5a;
  --font-mono:   'Share Tech Mono', monospace;
  --font-ui:     'Rajdhani', sans-serif;
  --font-orb:    'Orbitron', sans-serif;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-main);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── App Shell ───────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(57,255,20,0.05) 0%, transparent 60%),
    linear-gradient(180deg, #060d06 0%, #040a04 100%);
  position: relative;
}

/* ══════════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════════ */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 23, 12, 0.9);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

/* Logo */
#logo { display: flex; align-items: center; gap: 6px; }
.logo-icon { font-size: 20px; filter: drop-shadow(0 0 6px var(--neon)); }
.logo-text {
  font-family: var(--font-orb);
  font-size: 22px;
  font-weight: 900;
  color: var(--neon);
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--neon), 0 0 20px rgba(57,255,20,0.3);
}
.logo-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-left: 2px;
  vertical-align: super;
}

/* Signal bars */
#signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 20px;
}
.bar {
  width: 5px;
  background: var(--border-lit);
  border-radius: 2px 2px 0 0;
  transition: background 0.3s;
}
.b1 { height: 6px; }
.b2 { height: 10px; }
.b3 { height: 14px; }
.b4 { height: 18px; }
.b5 { height: 20px; }
.bar.active { background: var(--neon); box-shadow: 0 0 6px var(--neon); }

/* Battery */
#battery {
  position: relative;
  width: 28px;
  height: 14px;
  border: 2px solid var(--neon);
  border-radius: 3px;
  box-shadow: 0 0 6px var(--neon-glow);
}
#battery::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 6px;
  background: var(--neon);
  border-radius: 0 2px 2px 0;
}
#battery-inner {
  position: absolute;
  left: 1px; top: 1px; bottom: 1px;
  width: 70%;
  background: linear-gradient(90deg, var(--neon), #7dff50);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--neon-glow);
}

/* ══════════════════════════════════════════════════════════════
   LCD PANEL
   ══════════════════════════════════════════════════════════════ */
#lcd-panel {
  position: relative;
  margin: 12px 16px;
  background: var(--bg-lcd);
  border: 2px solid var(--neon-dim);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow:
    0 0 0 1px rgba(57,255,20,0.1),
    0 0 20px rgba(0,0,0,0.8),
    inset 0 0 30px rgba(0,0,0,0.5);
  flex-shrink: 0;
  overflow: hidden;
}

/* CRT scanlines effect */
#lcd-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 1;
  border-radius: 8px;
}

#lcd-content { position: relative; z-index: 2; }

.lcd-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.lcd-value {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--neon);
  text-shadow: 0 0 8px var(--neon);
  letter-spacing: 2px;
}
.lcd-value.neon { font-size: 20px; }
.lcd-divider {
  color: var(--border-lit);
  margin: 0 6px;
  font-family: var(--font-mono);
}
.lcd-unit {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  margin-left: 2px;
}

#lcd-row-1, #lcd-row-2 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}
#lcd-row-3 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.lcd-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  text-shadow: 0 0 6px var(--amber);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════════
   RX / TX + WAVEFORM
   ══════════════════════════════════════════════════════════════ */
#rx-section {
  display: flex;
  align-items: center;
  margin: 0 16px 8px;
  gap: 10px;
  flex-shrink: 0;
}

#rx-indicator-wrap, #tx-indicator-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 32px;
}
#rx-label, #tx-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-dim);
}

/* LED */
.led-standby {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe57a, #c8900a);
  box-shadow: 0 0 8px rgba(255,179,0,0.6), inset 0 0 6px rgba(0,0,0,0.4);
  transition: all 0.15s ease;
}
.led-rx {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7dff50, #39ff14);
  box-shadow: 0 0 12px var(--neon), 0 0 24px var(--neon-glow), inset 0 0 6px rgba(0,0,0,0.2);
  animation: led-pulse 0.5s ease-in-out infinite alternate;
}
.led-off {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3a1a1a, #1a0808);
  box-shadow: 0 0 4px rgba(0,0,0,0.5), inset 0 0 6px rgba(0,0,0,0.6);
}
.led-tx {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff7070, #ff1a1a);
  box-shadow: 0 0 12px var(--red-hot), 0 0 24px rgba(255,61,61,0.5), inset 0 0 6px rgba(0,0,0,0.2);
  animation: led-pulse 0.3s ease-in-out infinite alternate;
}

@keyframes led-pulse {
  from { box-shadow: 0 0 8px currentColor; }
  to   { box-shadow: 0 0 20px currentColor, 0 0 40px currentColor; }
}

/* Waveform canvas */
#waveform {
  flex: 1;
  height: 44px;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
#wave-canvas { width: 100%; height: 100%; display: block; }

/* ══════════════════════════════════════════════════════════════
   PTT BUTTON
   ══════════════════════════════════════════════════════════════ */
#ptt-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 10px 0;
  gap: 12px;
}

#ptt-ring-outer {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--neon-dim) 0%,
    var(--neon) 25%,
    var(--neon-dim) 50%,
    var(--neon) 75%,
    var(--neon-dim) 100%
  );
  padding: 4px;
  box-shadow: 0 0 20px var(--neon-glow), 0 0 40px rgba(57,255,20,0.1);
  animation: ring-spin 8s linear infinite;
  transition: box-shadow 0.2s;
}
#ptt-ring-outer.transmitting {
  box-shadow: 0 0 30px var(--red-hot), 0 0 60px rgba(255,61,61,0.4);
  background: conic-gradient(
    from 0deg,
    #7a0000 0%,
    var(--red-hot) 25%,
    #7a0000 50%,
    var(--red-hot) 75%,
    #7a0000 100%
  );
  animation: ring-spin 1.5s linear infinite;
}

@keyframes ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

#ptt-ring-mid {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(12, 23, 12, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  /* Counter-rotate so inner content stays upright */
  animation: ring-spin-reverse 8s linear infinite;
}
#ptt-ring-outer.transmitting #ptt-ring-mid {
  animation: ring-spin-reverse 1.5s linear infinite;
}

@keyframes ring-spin-reverse {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

#ptt-btn {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--border-lit);
  background:
    radial-gradient(circle at 40% 35%, #1a2e1a, #0a150a),
    linear-gradient(180deg, #172017, #080e08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.1s ease;
  box-shadow:
    inset 0 4px 12px rgba(255,255,255,0.05),
    inset 0 -4px 12px rgba(0,0,0,0.5),
    0 4px 20px rgba(0,0,0,0.8);
  outline: none;
  -webkit-appearance: none;
}
#ptt-btn:active,
#ptt-btn.pressed {
  background:
    radial-gradient(circle at 40% 35%, #1a0000, #0a0000);
  border-color: var(--red-hot);
  box-shadow:
    inset 0 4px 12px rgba(0,0,0,0.6),
    inset 0 -4px 12px rgba(255,61,61,0.1),
    0 2px 10px rgba(0,0,0,0.8);
  transform: scale(0.97);
}

#ptt-icon {
  font-size: 36px;
  filter: drop-shadow(0 0 8px var(--neon));
  transition: filter 0.1s;
  pointer-events: none;
}
#ptt-btn.pressed #ptt-icon {
  filter: drop-shadow(0 0 12px var(--red-hot));
}

#ptt-text {
  font-family: var(--font-orb);
  font-size: 22px;
  font-weight: 900;
  color: var(--neon);
  letter-spacing: 4px;
  text-shadow: 0 0 10px var(--neon);
  pointer-events: none;
  transition: color 0.1s, text-shadow 0.1s;
}
#ptt-btn.pressed #ptt-text {
  color: var(--red-hot);
  text-shadow: 0 0 10px var(--red-hot);
}

#ptt-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  pointer-events: none;
}

.ptt-hint-idle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-align: center;
}
.ptt-hint-transmit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--red-hot);
  letter-spacing: 1px;
  text-align: center;
  animation: blink 0.5s step-end infinite;
}
.ptt-hint-link {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber);
  letter-spacing: 1px;
  text-align: center;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   CONTROL BUTTONS
   ══════════════════════════════════════════════════════════════ */
#controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px;
  flex-shrink: 0;
}

.ctrl-btn {
  flex: 1;
  max-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.03);
}
.ctrl-btn:hover   { border-color: var(--border-lit); background: #152015; }
.ctrl-btn:active  { transform: scale(0.95); border-color: var(--neon); }
.ctrl-btn.active-mon { border-color: var(--amber); box-shadow: 0 0 10px rgba(255,179,0,0.3); }
.ctrl-btn.active-link { border-color: var(--amber); background: #1a1500; box-shadow: 0 0 12px rgba(255,179,0,0.3); }

.ctrl-icon { font-size: 20px; }
.ctrl-label {
  font-family: var(--font-orb);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: inherit;
}

/* ══════════════════════════════════════════════════════════════
   DEVELOPER BOX
   ══════════════════════════════════════════════════════════════ */
#dev-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: rgba(6, 13, 6, 0.95);
  flex-shrink: 0;
}
.dev-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.dev-sep { color: var(--border-lit); font-size: 10px; }
#dev-name, #dev-wa {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--neon);
  text-decoration: none;
  letter-spacing: 1px;
  transition: text-shadow 0.2s;
}
#dev-name:hover { text-shadow: 0 0 8px var(--neon); }
#dev-wa:hover { text-shadow: 0 0 8px var(--neon); }

/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  backdrop-filter: blur(4px);
}
#modal-info {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 101;
  background: var(--bg-panel);
  border: 1px solid var(--border-lit);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  box-shadow: 0 -4px 40px rgba(0,0,0,0.8);
  animation: slide-up 0.3s ease;
}
@keyframes slide-up {
  from { transform: translate(-50%, 100%); }
  to   { transform: translate(-50%, 0); }
}
.modal-box h2 {
  font-family: var(--font-orb);
  font-size: 18px;
  color: var(--neon);
  text-shadow: 0 0 8px var(--neon);
  margin-bottom: 16px;
  letter-spacing: 2px;
}
.modal-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.modal-box li {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
}
.modal-note {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.modal-note a { color: var(--neon); text-decoration: none; }
.modal-btn {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: transparent;
  border: 1px solid var(--neon);
  border-radius: 10px;
  color: var(--neon);
  font-family: var(--font-orb);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 10px var(--neon-glow);
}
.modal-btn:hover { background: rgba(57,255,20,0.1); }
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE / LANDSCAPE
   ══════════════════════════════════════════════════════════════ */
@media (max-height: 600px) {
  #lcd-panel { margin: 6px 16px; padding: 8px 16px; }
  #ptt-ring-outer { width: 160px; height: 160px; }
  #ptt-text { font-size: 18px; }
  #ptt-icon { font-size: 28px; }
}

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR HIDE
   ══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { display: none; }
