/* ── Marine VHF Radio Widget ─────────────────────────────────
   Center-console-mounted marine VHF look (ICOM IC-M510 / Standard
   Horizon GX1400 inspired). Landscape chassis, dual right-side knobs,
   hard-key strip, brushed-metal bezel.
   No autoplay. Keyboard + ARIA accessible. Respects reduced motion.
   ──────────────────────────────────────────────────────────── */

.vhf-radio {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  font-family: 'Inter', system-ui, sans-serif;
  --vhf-bezel-1: #2c2e32;
  --vhf-bezel-2: #18191c;
  --vhf-bezel-3: #0a0b0c;
  --vhf-face:    #141518;
  --vhf-screw:   #2a2b2e;
  --vhf-lcd-bg:  #0c1e16;
  --vhf-lcd-fg:  #9dff7c;
  --vhf-lcd-dim: #2a4a32;
  --vhf-led-off: #4a1a1a;
  --vhf-led-on:  #41ff66;
  --vhf-led-amber:#e8a022;
  --vhf-gold:    #c8972a;
  --vhf-key-bg:  #1f2125;
  --vhf-key-fg:  #c8c9cc;
  --vhf-key-red: #b53030;
}

.vhf-radio[hidden] { display: none; }

/* ── Collapsed FAB ── */
.vhf-radio[data-collapsed="true"] .vhf-radio-chassis { display: none; }
.vhf-radio[data-collapsed="false"] .vhf-radio-fab-wrap { display: none; }

.vhf-radio-fab-wrap {
  position: relative;
  width: 120px;
  height: 120px;
}

.vhf-radio-fab {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.55));
  overflow: hidden;
}
.vhf-radio-fab picture,
.vhf-radio-fab img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.vhf-radio-fab:focus-visible {
  outline: 3px solid var(--vhf-gold);
  outline-offset: 3px;
}

/* Chevron-up hint at top of FAB */
.vhf-fab-chevron {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 7px solid rgba(255,255,255,.85);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.6));
  pointer-events: none;
  opacity: .85;
}

/* Interactive power toggle overlaid on the porthole image's toggle artwork.
   Sits at ~55% from top, centered horizontally. ~65% of FAB width. */
.vhf-fab-toggle {
  position: absolute;
  top: 55%; left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  height: 26%;
  max-height: 32px;
  border-radius: 999px;
  border: 1.5px solid rgba(0,0,0,.55);
  background: #15171b;
  padding: 0;
  cursor: pointer;
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,.7),
    0 1px 0 rgba(255,255,255,.08);
  transition: background-color .18s ease;
  z-index: 2;
}
.vhf-fab-toggle:focus-visible {
  outline: 2px solid var(--vhf-gold);
  outline-offset: 2px;
}
.vhf-fab-toggle[aria-checked="true"] {
  background: var(--vhf-led-on);
  border-color: rgba(0,0,0,.6);
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,.45),
    0 0 8px rgba(65,255,102,.5);
}
.vhf-fab-toggle-thumb {
  position: absolute;
  top: 50%; left: 6%;
  transform: translateY(-50%);
  width: 38%;
  height: 78%;
  border-radius: 50%;
  background: linear-gradient(180deg, #f4f4f5 0%, #b8b9bd 100%);
  box-shadow:
    0 1px 2px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.7),
    inset 0 -1px 1px rgba(0,0,0,.25);
  transition: left .22s cubic-bezier(.3,.1,.3,1);
  pointer-events: none;
}
.vhf-fab-toggle[aria-checked="true"] .vhf-fab-toggle-thumb {
  left: 56%;
}
@media (prefers-reduced-motion: reduce) {
  .vhf-fab-toggle,
  .vhf-fab-toggle-thumb { transition: none; }
}

/* Mobile: 96px FAB */
@media (max-width: 600px) {
  .vhf-radio-fab-wrap { width: 96px; height: 96px; }
}

/* ── Chassis: landscape, dash-mounted center-console look ── */
.vhf-radio-chassis {
  width: 380px;
  /* Outer brushed bezel */
  background:
    linear-gradient(180deg, #34363a 0%, #1d1e21 8%, #1a1b1e 92%, #0a0b0c 100%);
  border: 1px solid #000;
  border-radius: 10px;
  padding: 16px 18px 14px;
  position: relative;
  box-shadow:
    0 14px 36px rgba(0,0,0,.65),
    0 2px 0 rgba(255,255,255,.04) inset,
    0 -3px 8px rgba(0,0,0,.6) inset,
    /* Dash recess shadow - looks mounted */
    0 0 0 4px rgba(0,0,0,.45),
    0 22px 40px -10px rgba(0,0,0,.7);
  display: grid;
  grid-template-columns: 1fr 110px;
  grid-template-rows: auto auto;
  gap: 12px 14px;
  /* Brushed-metal horizontal striations */
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,.012) 0,
      rgba(255,255,255,.012) 1px,
      transparent 1px,
      transparent 2px
    ),
    linear-gradient(180deg, #34363a 0%, #1d1e21 8%, #1a1b1e 92%, #0a0b0c 100%);
}

/* Corner screws (cosmetic, mounted look) */
.vhf-radio-chassis::before,
.vhf-radio-chassis::after,
.vhf-radio-chassis > .vhf-screw-tl,
.vhf-radio-chassis > .vhf-screw-tr {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #4a4b4f 0%, #1a1b1e 60%, #000 100%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.15),
    inset 0 -1px 1px rgba(0,0,0,.7),
    0 1px 1px rgba(0,0,0,.5);
  pointer-events: none;
}
/* Phillips-head slot via inner pseudo */
.vhf-radio-chassis::before {
  content: "";
  bottom: 6px; left: 6px;
}
.vhf-radio-chassis::after {
  content: "";
  bottom: 6px; right: 6px;
}
.vhf-screw-tl { top: 6px; left: 6px; }
.vhf-screw-tr { top: 6px; right: 6px; }

/* ── LCD Display (large, left-side, dominant) ── */
.vhf-display {
  grid-column: 1;
  grid-row: 1;
  background:
    linear-gradient(180deg, #0a1812 0%, #0e221a 50%, #0a1812 100%);
  border: 2px solid #050a07;
  border-radius: 4px;
  padding: 10px 12px 8px;
  color: var(--vhf-lcd-fg);
  text-shadow: 0 0 4px rgba(157,255,124,.55);
  box-shadow:
    inset 0 2px 5px rgba(0,0,0,.85),
    inset 0 0 18px rgba(0,0,0,.5),
    0 1px 0 rgba(255,255,255,.04);
  min-height: 84px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;
  column-gap: 12px;
  row-gap: 4px;
  position: relative;
  overflow: hidden;
  font-family: 'Courier New', ui-monospace, monospace;
}
/* LCD scanlines + faint vignette */
.vhf-display::after {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,.10) 0,
      rgba(0,0,0,.10) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.35) 100%);
  pointer-events: none;
}

/* Top-row LCD status icons (cosmetic but they sell the look) */
.vhf-display-status {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  gap: 10px;
  font-size: 8px;
  letter-spacing: .14em;
  font-weight: 700;
  opacity: .35;
}
.vhf-display-status span { transition: opacity .15s, color .15s; }
.vhf-display-status .on {
  opacity: 1;
  color: var(--vhf-lcd-fg);
  text-shadow: 0 0 5px rgba(157,255,124,.7);
}

/* Big segmented-style channel number, left column */
.vhf-display-channel {
  grid-column: 1;
  grid-row: 2;
  font-family: 'Courier New', ui-monospace, monospace;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1;
  align-self: center;
  /* Faint "off-segment" ghosting */
  text-shadow:
    0 0 4px rgba(157,255,124,.6),
    0 0 1px rgba(157,255,124,.4);
  white-space: nowrap;
}

/* Right column: scrolling label + attribution */
.vhf-display-text {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
}
.vhf-display-label {
  font-size: 10px;
  letter-spacing: .12em;
  line-height: 1.2;
  font-weight: 700;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vhf-display-attr {
  font-size: 8px;
  opacity: .6;
  letter-spacing: .12em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bottom-row of LCD: signal bars + brand */
.vhf-display-foot {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  justify-content: space-between;
  align-items: end;
  font-size: 7px;
  letter-spacing: .15em;
  opacity: .55;
  font-weight: 700;
}
.vhf-display-bars {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  height: 8px;
}
.vhf-display-bars i {
  width: 3px;
  background: var(--vhf-lcd-dim);
  border-radius: 1px;
}
.vhf-display-bars i:nth-child(1) { height: 25%; }
.vhf-display-bars i:nth-child(2) { height: 50%; }
.vhf-display-bars i:nth-child(3) { height: 75%; }
.vhf-display-bars i:nth-child(4) { height: 100%; }
.vhf-radio-chassis[data-state="playing"] .vhf-display-bars i {
  background: var(--vhf-lcd-fg);
  box-shadow: 0 0 3px rgba(157,255,124,.6);
}

/* Squelch flicker */
@media (prefers-reduced-motion: no-preference) {
  .vhf-radio-chassis[data-tuning="true"] .vhf-display {
    animation: vhf-flicker .12s steps(2) 3;
  }
  @keyframes vhf-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; filter: brightness(.55); }
  }
}

/* ── Knob stack (right column) ── */
.vhf-knobs {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 18px; /* extra space so VOLUME/CHANNEL labels don't collide */
  align-items: center;
  justify-items: center;
  padding-top: 2px;
}
.vhf-knob {
  position: relative;
  border: none;
  cursor: grab;
  padding: 0;
  /* Concentric ring + knurled rim */
  background:
    radial-gradient(circle at 50% 50%, #3a3d42 0%, #25272b 55%, #0d0e10 100%);
  box-shadow:
    0 4px 8px rgba(0,0,0,.7),
    inset 0 1px 0 rgba(255,255,255,.14),
    inset 0 -3px 5px rgba(0,0,0,.7),
    /* Outer ring */
    0 0 0 2px #0a0b0c,
    0 0 0 3px #2a2c30;
  border-radius: 50%;
  color: var(--vhf-gold);
  display: grid;
  place-items: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.vhf-knob:active { cursor: grabbing; }
.vhf-knob-rotor {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  transition: transform .14s cubic-bezier(.3,.1,.3,1);
  /* Knurled tick texture around rim */
  background:
    repeating-conic-gradient(
      from 0deg,
      rgba(255,255,255,.06) 0deg,
      rgba(255,255,255,.06) 2deg,
      transparent 2deg,
      transparent 9deg
    );
  mask: radial-gradient(circle, transparent 60%, #000 62%, #000 92%, transparent 94%);
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 62%, #000 92%, transparent 94%);
}
.vhf-knob-rotor::after {
  /* Pointer dimple/tick on the knob face */
  content: "";
  position: absolute;
  top: 6%; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 24%;
  background: linear-gradient(180deg, var(--vhf-gold), #8c6717);
  border-radius: 2px;
  box-shadow: 0 0 3px rgba(232,184,75,.5), inset 0 0 1px rgba(0,0,0,.6);
}
.vhf-knob-inner {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #54575c 0%, #25272b 55%, #0d0e10 100%);
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,.10),
    inset 0 -3px 4px rgba(0,0,0,.6),
    0 1px 0 rgba(0,0,0,.5);
  pointer-events: none;
}
.vhf-knob-label {
  position: absolute;
  bottom: -15px; left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: .22em;
  color: var(--vhf-gold);
  text-transform: uppercase;
  white-space: nowrap;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 0 -1px 0 rgba(0,0,0,.7), 0 0 4px rgba(200,151,42,.25);
  opacity: .85;
}
.vhf-knob:focus-visible {
  outline: 2px solid var(--vhf-gold);
  outline-offset: 4px;
}
.vhf-knob--volume  { width: 48px; height: 48px; }
.vhf-knob--channel { width: 48px; height: 48px; }

@media (prefers-reduced-motion: reduce) {
  .vhf-knob-rotor { transition: none; }
}

/* ── Hard-key strip (bottom row, spans full width) ── */
.vhf-keys {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding-top: 2px;
}
.vhf-key {
  border: 1px solid #000;
  background: linear-gradient(180deg, #2c2e32 0%, #15161a 100%);
  color: var(--vhf-key-fg);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 -1px 2px rgba(0,0,0,.55),
    0 1px 1px rgba(0,0,0,.45);
  line-height: 1;
  text-align: center;
}
.vhf-key:active {
  background: linear-gradient(180deg, #15161a 0%, #2c2e32 100%);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.7);
}
.vhf-key:focus-visible {
  outline: 2px solid var(--vhf-gold);
  outline-offset: 2px;
}
.vhf-key--priority {
  color: #fff;
  background: linear-gradient(180deg, #b53030 0%, #6a1818 100%);
  border-color: #2a0606;
}
.vhf-key--priority:active {
  background: linear-gradient(180deg, #6a1818 0%, #b53030 100%);
}

/* Power = also a hard key, gold */
.vhf-key--power {
  background: linear-gradient(180deg, #c8972a 0%, #8c6717 100%);
  color: #1a1c20;
  border-color: #000;
}
.vhf-key--power:active {
  background: linear-gradient(180deg, #8c6717 0%, #c8972a 100%);
}

/* Power LED dot inline on power key */
.vhf-key--power::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--vhf-led-off);
  margin-right: 5px;
  vertical-align: middle;
  box-shadow: inset 0 0 2px rgba(0,0,0,.6);
}
.vhf-radio-chassis[data-state="playing"] .vhf-key--power::before {
  background: var(--vhf-led-on);
  box-shadow: 0 0 5px var(--vhf-led-on);
}
.vhf-radio-chassis[data-state="on"] .vhf-key--power::before,
.vhf-radio-chassis[data-state="paused"] .vhf-key--power::before {
  background: var(--vhf-led-amber);
  box-shadow: 0 0 4px var(--vhf-led-amber);
}

/* ── Brand badge ── */
.vhf-brand {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: .3em;
  color: #888a8e;
  text-transform: uppercase;
  font-weight: 700;
  text-shadow: 0 -1px 0 rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.04);
  pointer-events: none;
}
.vhf-brand b { color: var(--vhf-gold); font-weight: 700; }

/* ── Speaker grille (small slats on left edge, below LCD) ── */
.vhf-grille {
  display: none; /* hidden in landscape layout; vents implied by chassis */
}

/* ── DIM (LCD backlight off) - functional, toggled by DIM hard-key ── */
.vhf-radio-chassis[data-dim="true"] .vhf-display {
  filter: brightness(.32) saturate(.8);
}
.vhf-radio-chassis[data-dim="true"] .vhf-display .vhf-display-channel,
.vhf-radio-chassis[data-dim="true"] .vhf-display .vhf-display-label,
.vhf-radio-chassis[data-dim="true"] .vhf-display .vhf-display-attr,
.vhf-radio-chassis[data-dim="true"] .vhf-display .vhf-display-status .on {
  text-shadow: none;
}
.vhf-radio-chassis[data-dim="true"] .vhf-display-bars i {
  box-shadow: none;
}
.vhf-key--dim[aria-pressed="true"],
.vhf-key--scan[aria-pressed="true"] {
  background: linear-gradient(180deg, #15161a 0%, #2c2e32 100%);
  color: var(--vhf-gold);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,.75),
    0 0 0 1px rgba(200,151,42,.35);
}
.vhf-key--scan[aria-pressed="true"] {
  animation: vhf-scan-blink 1.2s steps(2, jump-none) infinite;
}
@keyframes vhf-scan-blink {
  0%, 100% { color: var(--vhf-gold); }
  50% { color: #f0c860; }
}
@media (prefers-reduced-motion: reduce) {
  .vhf-key--scan[aria-pressed="true"] { animation: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .vhf-radio-chassis[data-dim="true"] .vhf-display,
  .vhf-radio-chassis .vhf-display {
    transition: filter .25s ease;
  }
}

/* ── Close (collapse) button (top-right, near corner screw) ── */
.vhf-collapse {
  position: absolute;
  top: 4px; right: 22px;
  width: 16px; height: 16px;
  border: none;
  background: transparent;
  color: #6a6c70;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  border-radius: 3px;
}
.vhf-collapse:hover,
.vhf-collapse:focus-visible {
  color: var(--vhf-gold);
  outline: none;
  background: rgba(200,151,42,.12);
}

/* ── Screen-reader only ── */
.vhf-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Mobile: shrink to fit 375px viewport ── */
@media (max-width: 600px) {
  .vhf-radio { right: 10px; bottom: 10px; }
  .vhf-radio-chassis {
    width: 320px;
    padding: 14px 14px 12px;
    grid-template-columns: 1fr 96px;
    gap: 10px 10px;
  }
  .vhf-display-channel { font-size: 24px; }
  .vhf-knob--volume,
  .vhf-knob--channel { width: 44px; height: 44px; }
  .vhf-key { font-size: 8px; padding: 5px 3px; }
}

/* Honor reduced motion */
@media (prefers-reduced-motion: reduce) {
  .vhf-radio-chassis[data-tuning="true"] .vhf-display {
    animation: none;
  }
}
