/* ==========================================================================
   RadUI — diegetic car-radio interface kit
   Cel-shaded hardware: flat fills, one highlight band, one shade band,
   thick ink outlines. Everything is sized in px at "design scale"
   (the reference faceplate is 1560 × 505); scale the whole .rad-unit.
   ========================================================================== */

.rad {
  /* ink + plastics */
  --rad-ink: #0f1219;
  --rad-ink-soft: #1a1d29;
  --rad-bezel: #42465f;
  --rad-bezel-hi: #565b76;
  --rad-chassis: #262c3f;
  --rad-face: #363b4e;
  --rad-face-hi: #444a60;
  --rad-face-lo: #2c3042;
  --rad-tray: #2a2e3f;
  --rad-well: #1d2030;

  /* keycaps */
  --rad-key: #41444f;
  --rad-key-hi: #575a68;
  --rad-key-lo: #2c2e39;
  --rad-key-side: #1b1d26;
  --rad-key-radius: 8px;

  /* print */
  --rad-label: #e6dccf;
  --rad-label-dim: #b8afa6;
  --rad-font: "Bahnschrift", "DIN Alternate", "DIN 2014", "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;

  /* lcd */
  --rad-lcd-bg: #321e1e;
  --rad-lcd-bg-hi: #3d2522;
  --rad-lcd-on: #ff8a2e;
  --rad-lcd-glow: rgba(255, 98, 20, .55);
  --rad-lcd-off: rgba(255, 120, 60, .045);
  --rad-legend-glow: rgba(255, 110, 40, .3);   /* faint backlight around key legends */

  /* accents */
  --rad-accent: #ec6a45;
  --rad-thumb: #d8cbc0;
  --rad-thumb-lo: #a49499;
  --rad-pill: #c9b8b0;

  font-family: var(--rad-font);
  color: var(--rad-label);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- surfaces ------------------------------------------------------ */

/* Outer bezel: the big dash-mounted frame */
.rad-bezel {
  position: relative;
  background:
    linear-gradient(180deg, var(--rad-bezel-hi) 0, var(--rad-bezel) 14px, var(--rad-bezel) calc(100% - 10px), #33374b 100%);
  border: 3px solid var(--rad-ink);
  border-radius: 26px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .10),
    0 6px 0 rgba(10, 12, 20, .55),
    0 18px 40px rgba(0, 0, 0, .35);
}

/* Chassis: the recessed body the controls sit in */
.rad-chassis {
  position: absolute;
  background: var(--rad-chassis);
  border: 3px solid var(--rad-ink);
  border-radius: 16px;
  box-shadow:
    inset 0 4px 0 rgba(0, 0, 0, .25),
    inset 0 -2px 0 rgba(255, 255, 255, .05);
}

/* Plate: a raised flat panel (behind display/knob, bottom strip) */
.rad-plate {
  position: absolute;
  background: linear-gradient(180deg, var(--rad-face-hi) 0, var(--rad-face) 6px, var(--rad-face) calc(100% - 6px), var(--rad-face-lo) 100%);
  border: 2.5px solid var(--rad-ink);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 0 rgba(0, 0, 0, .35);
}

/* Tray: shallow recess that groups keys */
.rad-tray {
  position: absolute;
  background: var(--rad-tray);
  border: 2.5px solid var(--rad-ink);
  border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .35), inset 0 -1px 0 rgba(255, 255, 255, .06), 0 1px 0 rgba(255, 255, 255, .07);
}

/* Seam: a thin engraved divider line */
.rad-seam {
  position: absolute;
  background: var(--rad-ink);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .07);
}
.rad-seam--v { width: 2px; }
.rad-seam--h { height: 2px; box-shadow: 0 1px 0 rgba(255, 255, 255, .07); }

/* ---------- keycap -------------------------------------------------------- */

.rad-key {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3em;
  box-sizing: border-box;
  min-width: 48px;
  min-height: 40px;
  padding: 0 12px 4px;
  font: 500 30px/1 var(--rad-font);
  font-stretch: semi-condensed;
  letter-spacing: .01em;
  color: var(--rad-label);
  text-shadow: 0 0 3px var(--rad-legend-glow), 0 0 10px var(--rad-legend-glow);
  background:
    linear-gradient(180deg, var(--rad-key-hi) 0, var(--rad-key) 7px, var(--rad-key) calc(100% - 9px), var(--rad-key-lo) calc(100% - 6px), var(--rad-key-side) calc(100% - 5px));
  border: 2.5px solid var(--rad-ink);
  border-radius: var(--rad-key-radius);
  box-shadow:
    inset 2px 0 0 rgba(255, 255, 255, .04),
    inset 0 2px 0 rgba(255, 255, 255, .10),
    0 2px 0 var(--rad-ink),
    0 4px 5px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform .05s, box-shadow .05s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
/* hover brightens the paint, not via filter: a filter makes a stacking context and would
   trap the lamp (.is-on::after) under a page's tint layer */
.rad-key:hover { --rad-key: #464955; --rad-key-hi: #5d606f; --rad-key-lo: #30323e; }
.rad-key:focus-visible { box-shadow: 0 0 0 3px var(--rad-accent), 0 2px 0 var(--rad-ink); }
.rad-key.is-pressed,
.rad-key:active {
  transform: translateY(3px);
  background:
    linear-gradient(180deg, var(--rad-key-lo) 0, var(--rad-key) 6px, var(--rad-key) calc(100% - 4px), var(--rad-key-side) calc(100% - 3px));
  box-shadow: inset 0 3px 2px rgba(0, 0, 0, .3), 0 0 0 var(--rad-ink);
}
.rad-key svg { width: 1.25em; height: 1.25em; overflow: visible; }
.rad-key svg, .rad-slider__icon svg { filter: drop-shadow(0 0 2px var(--rad-legend-glow)) drop-shadow(0 0 6px var(--rad-legend-glow)); }
.rad-key--lg svg { width: 1.6em; height: 1.6em; }
.rad-key--sm { font-size: 26px; }
.rad-key--lg { font-size: 34px; }

/* latched/active: a tiny lamp under the legend */
.rad-key.is-on::after {
  content: "";
  position: absolute;
  bottom: 9px; left: 50%;
  width: 14px; height: 3px; margin-left: -7px;
  border-radius: 2px;
  background: radial-gradient(ellipse 60% 70% at 50% 50%, #ffd2a6, var(--rad-lcd-on));
  box-shadow:
    0 0 2px 0 var(--rad-lcd-on),
    0 0 7px 1px var(--rad-lcd-glow),
    0 0 16px 4px rgba(255, 98, 20, .22);
}

/* segmented: keys fused into one moulding (⏻ | SET) */
.rad-seg { display: inline-flex; }
.rad-seg > .rad-key { border-radius: 0; }
.rad-seg > .rad-key + .rad-key { margin-left: -2.5px; }
.rad-seg > .rad-key:first-child { border-radius: var(--rad-key-radius) 0 0 var(--rad-key-radius); }
.rad-seg > .rad-key:last-child { border-radius: 0 var(--rad-key-radius) var(--rad-key-radius) 0; }

/* preset bar key: wide, low, legend slightly lower */
.rad-key--preset { font-size: 28px; padding-bottom: 6px; }
.rad-key--preset .rad-tick {
  position: absolute; left: 8px; top: 50%;
  width: 0; height: 0; margin-top: -6px;
  border: 4px solid transparent; border-left: 5px solid var(--rad-label-dim);
}

/* ---------- cassette slot ------------------------------------------------- */

.rad-slot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  background:
    linear-gradient(180deg, #24262f 0, #2e303d 10px, #2e303d calc(100% - 8px), #3a3d4c 100%);
  border: 3px solid var(--rad-ink);
  border-radius: 8px;
  box-shadow:
    inset 0 5px 0 rgba(0, 0, 0, .35),
    0 0 0 3px #343748,
    0 0 0 5px var(--rad-ink);
}
.rad-slot::before { /* flap lip */
  content: ""; position: absolute; left: 10px; right: 10px; top: 4px; height: 2px;
  background: rgba(255, 255, 255, .06); border-radius: 2px;
}

.rad-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 15px/1 var(--rad-font);
  color: var(--rad-label);
  letter-spacing: .02em;
}
.rad-badge__dd { display: inline-flex; gap: 2px; }
.rad-badge__dd i {
  display: block; width: 14px; height: 20px; box-sizing: border-box;
  border: 3px solid var(--rad-label);
}
.rad-badge__dd i:first-child { border-left-width: 6px; border-radius: 0 10px 10px 0; }
.rad-badge__dd i:last-child  { border-right-width: 6px; border-radius: 10px 0 0 10px; }
.rad-badge__box { border: 1.5px solid var(--rad-label); padding: 3px 6px 2px; }

/* ---------- dot-matrix display ------------------------------------------- */

.rad-lcd {
  position: relative;
  box-sizing: border-box;
  padding: 6px;
  background: var(--rad-ink);
  border-radius: 6px;
  box-shadow: 0 0 0 3px #2b2f40, 0 0 0 5px var(--rad-ink), 0 3px 0 5px rgba(255, 255, 255, .05);
}
.rad-lcd__glass {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  border-radius: 3px;
  background:
    radial-gradient(ellipse 80% 120% at 30% 40%, var(--rad-lcd-bg-hi), transparent 70%),
    var(--rad-lcd-bg);
}
/* unlit dot grid — pitch is driven by JS via --rad-pitch */
.rad-lcd__glass::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 50% 50%, var(--rad-lcd-off) 38%, transparent 42%);
  background-size: var(--rad-pitch, 3px) var(--rad-pitch, 3px);
  background-position: var(--rad-ox, 0) var(--rad-oy, 0);
}
.rad-lcd__glass canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* glass reflection */
.rad-lcd__glass::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, .06) 0, rgba(255, 255, 255, .02) 35%, transparent 36%),
    linear-gradient(0deg, rgba(0, 0, 0, .25), transparent 18%);
}

/* slim light-pipe beside the display */
.rad-pill {
  position: absolute;
  background: linear-gradient(90deg, #9c8e8b, var(--rad-pill) 45%, #e3d6cf 60%, #a59693);
  border: 2px solid var(--rad-ink);
  border-radius: 8px;
}

/* ---------- rotary knob ---------------------------------------------------
   Layers: printed scale arc › gunmetal collar › rubber cap (rotates: knurled skirt +
   pointer) › static shine (cel highlight bands that stay put while the cap turns).
   --v is the *drawn* position (sprung by JS), so the pointer overshoots and settles. */

.rad-knob {
  --v: .5;                 /* 0..1 */
  --sweep: 260deg;         /* total travel */
  --start: -100deg;        /* where 0 sits, from 12 o'clock */
  --ang: calc(var(--start) + var(--v) * var(--sweep));
  --metal: #3a3c4c;
  --metal-light: #565969;
  --metal-shade: #22242f;
  --metal-sheen: #9a9cab;
  --rubber: #2a2c39;
  --rubber-face: #30323f;
  --groove: rgba(6, 8, 14, .45);
  --ridge: rgba(255, 255, 255, .07);
  position: relative;
  width: 176px; height: 176px;
  cursor: grab;
  touch-action: none;
  outline: none;
}
.rad-knob.is-turning { cursor: grabbing; }
.rad-knob:focus-visible .rad-knob__collar { box-shadow: 0 0 0 3px var(--rad-accent); }

/* printed scale: dim groove over the whole sweep (unlit, no glow) */
.rad-knob::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  border-radius: 50%;
  background: conic-gradient(from var(--start), rgba(10, 12, 20, .22) 0 var(--sweep), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%, #000 67%, transparent 68%);
          mask: radial-gradient(circle, transparent 62%, #000 63%, #000 67%, transparent 68%);
}
/* lit segment, up to the value. The ring is cut by a mask on the pseudo-elements, and the
   glow is a filter on this wrapper, so it blurs the finished ring (filter runs before mask
   on one element, which would clip the glow). ::after is the hot core of the light pipe. */
.rad-knob__arc {
  position: absolute; inset: 0; pointer-events: none;
  filter: drop-shadow(0 0 2px var(--rad-lcd-glow)) drop-shadow(0 0 6px var(--rad-lcd-glow)) drop-shadow(0 0 14px rgba(255, 98, 20, .3));
}
.rad-knob__arc::before,
.rad-knob__arc::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from var(--start), var(--c) 0 calc(var(--v) * var(--sweep)), transparent 0);
}
.rad-knob__arc::before {
  --c: var(--rad-lcd-on);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%, #000 67%, transparent 68%);
          mask: radial-gradient(circle, transparent 62%, #000 63%, #000 67%, transparent 68%);
}
.rad-knob__arc::after {
  --c: #ffc896;
  opacity: .7;
  -webkit-mask: radial-gradient(circle, transparent 64.3%, #000 64.8%, #000 65.2%, transparent 65.7%);
          mask: radial-gradient(circle, transparent 64.3%, #000 64.8%, #000 65.2%, transparent 65.7%);
}

/* gunmetal collar: flat metal, two hard sheen wedges, cel light/shade bands */
.rad-knob__collar {
  position: absolute; inset: 11%;
  border-radius: 50%;
  background:
    conic-gradient(transparent 0 22deg, var(--metal-sheen) 22deg 34deg, transparent 34deg 306deg, var(--metal-light) 306deg 318deg, transparent 318deg),
    var(--metal);
  border: 3px solid var(--rad-ink);
  box-shadow:
    inset 3px 5px 0 var(--metal-light),
    inset 0 -6px 0 var(--metal-shade),
    0 5px 0 rgba(0, 0, 0, .45),
    -10px 12px 0 rgba(10, 12, 22, .28);
}

/* rubber cap: rotates with the value */
.rad-knob__cap {
  position: absolute; inset: 14.5%;
  border-radius: 50%;
  border: 3px solid var(--rad-ink);
  background:
    radial-gradient(closest-side, var(--rubber-face) 0 82%, rgba(8, 10, 16, .8) 82.5% 85%, var(--rubber) 85.5%);
  transform: rotate(var(--ang));
}
/* knurled skirt: one ridge per few degrees, masked to the outer band */
.rad-knob__cap::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from 1deg, var(--groove) 0 2deg, var(--ridge) 2deg 3deg, transparent 3deg 6deg);
  -webkit-mask: radial-gradient(closest-side, transparent 85%, #000 86%);
          mask: radial-gradient(closest-side, transparent 85%, #000 86%);
}
/* pointer: a cream line on the top face */
.rad-knob__cap::after {
  content: ""; position: absolute; left: 50%; top: 9%;
  width: 5px; height: 17%; margin-left: -2.5px;
  border-radius: 3px;
  background: var(--rad-label);
  box-shadow: 0 0 0 1.5px var(--rad-ink);
}
.rad-knob--plain .rad-knob__cap::after, .rad-knob--plain .rad-knob__lit { display: none; }

/* backlit pointer: a copy of the pointer in its own layer (same box and rotation as the cap),
   so a page can lift it above a darkening wash like the key legends */
.rad-knob__lit {
  position: absolute; inset: 14.5%;
  border: 3px solid transparent; border-radius: 50%;
  transform: rotate(var(--ang));
  pointer-events: none;
}
.rad-knob__lit i {
  position: absolute; left: 50%; top: 9%;
  width: 5px; height: 17%; margin-left: -2.5px;
  border-radius: 3px;
  background: var(--rad-label);
  box-shadow: 0 0 0 1.5px var(--rad-ink), 0 0 6px 1px var(--rad-legend-glow), 0 0 12px var(--rad-legend-glow);
}

/* static shine: lit from top-left, independent of rotation */
.rad-knob__shine {
  position: absolute; inset: 14.5%;
  border-radius: 50%;
  pointer-events: none;
  /* cel crescent on the top face + hard rim catch-light, both fixed to the light, not the cap */
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, .07) 0 34%, transparent 34.5%);
  box-shadow:
    inset 3px 4px 0 rgba(255, 255, 255, .09),
    inset -4px -10px 0 rgba(0, 0, 0, .3);
}

/* ---------- slider --------------------------------------------------------
   Thumb travel is sprung by JS (--v); detents via data-steps. */

.rad-slider {
  --v: .5;
  position: relative;
  display: flex; align-items: center; gap: 22px;
  box-sizing: border-box;
  padding: 0 20px 0 24px;
  background: linear-gradient(180deg, #2d3040, #333647 40%, #333647);
  border: 2.5px solid var(--rad-ink);
  border-radius: 12px;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .06);
}
.rad-slider__icon { flex: none; width: 46px; height: 46px; color: var(--rad-label); }
.rad-slider__icon svg { width: 100%; height: 100%; overflow: visible; }
.rad-slider__track {
  position: relative; flex: 1;
  height: 32px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .35) 0 5px, transparent 5px),
    #1f222d;
  border: 2.5px solid var(--rad-ink);
  border-radius: 9px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .07);
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.rad-slider__track:focus-visible { box-shadow: 0 0 0 3px var(--rad-accent); }
/* slot the thumb rides in */
.rad-slider__track::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 50%; height: 4px; margin-top: -1px;
  border-radius: 2px; background: #11131b;
}
.rad-slider__thumb {
  --groove-t: rgba(70, 52, 58, .45);
  --ridge-t: rgba(255, 255, 255, .55);
  position: absolute; top: 50%;
  left: calc(var(--v) * (100% - 44px));
  width: 44px; height: 50px;
  margin-top: -27px;
  box-sizing: border-box;
  background:
    repeating-linear-gradient(90deg, var(--groove-t) 0 2px, var(--ridge-t) 2px 3px, transparent 3px 5px) 50% 46% / 15px 46% no-repeat,
    linear-gradient(180deg, #f3ebe3 0 4px, #dccfc4 4px 54%, #c7b8ae 54% calc(100% - 8px), #8e7e87 calc(100% - 8px));
  border: 2.5px solid var(--rad-ink);
  border-radius: 6px;
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, .3),
    inset -3px 0 0 rgba(0, 0, 0, .1),
    0 4px 0 rgba(0, 0, 0, .5);
  cursor: grab;
  transition: transform .06s, box-shadow .06s;
}
.rad-slider.is-dragging .rad-slider__thumb {
  cursor: grabbing;
  transform: translateY(1.5px);
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, .3), inset -3px 0 0 rgba(0, 0, 0, .1), 0 2.5px 0 rgba(0, 0, 0, .5);
}

/* ---------- speaker grille ------------------------------------------------ */

.rad-grille {
  --hole: 11px;
  --pitch: 20px;
  position: absolute;
  background-image:
    radial-gradient(circle at center, var(--rad-ink) 0 calc(var(--hole) / 2 - .6px), transparent calc(var(--hole) / 2 + .4px)),
    radial-gradient(circle at center, var(--rad-ink) 0 calc(var(--hole) / 2 - .6px), transparent calc(var(--hole) / 2 + .4px));
  background-size: var(--pitch) calc(var(--pitch) * 1.3);
  background-position: 0 0, calc(var(--pitch) / 2) calc(var(--pitch) * .65);
  -webkit-mask: radial-gradient(ellipse 58% 64% at 50% 50%, #000 78%, transparent 92%);
          mask: radial-gradient(ellipse 58% 64% at 50% 50%, #000 78%, transparent 92%);
}

/* ---------- print / branding --------------------------------------------- */

.rad-brand { position: absolute; line-height: 1; color: var(--rad-label); }
.rad-brand b { display: block; font: 600 30px/1 var(--rad-font); letter-spacing: .02em; }
.rad-brand span { display: block; margin-top: 3px; font: 500 19px/1 var(--rad-font); letter-spacing: .02em; font-stretch: condensed; }

/* ---------- lighting ------------------------------------------------------ */

/* Warm afternoon sun raking across the unit; purely decorative */
.rad-sun {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  mix-blend-mode: soft-light;
  background:
    linear-gradient(118deg, transparent 80%, rgba(255, 196, 150, .55) 85%, rgba(255, 190, 140, .25) 93%, transparent 99%),
    radial-gradient(ellipse 14% 30% at 96% 88%, rgba(255, 190, 130, .6), transparent);
}
.rad-sun--screen { mix-blend-mode: screen; opacity: .25; }

/* ---------- icon stroke defaults ----------------------------------------- */

.rad-ico { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.rad-ico .f { fill: currentColor; stroke: none; }
