/* The ribbon microphone button: the head of an old ribbon microphone lying on its side, on a black page. The
   grille, the ribbon and the light on them are drawn by the script on a canvas; the chrome body, the ON AIR lamp and
   the bakelite plate with the word are here, with all the colours. */
:root {
  --page: #000000;          /* the page */
  --chrome-hi: #fbf9f3;     /* the chrome body: its brightest light */
  --chrome: #a8a49b;        /* its middle tone */
  --chrome-lo: #3a3834;     /* its darkest band */
  --cavity: #0c0b0a;        /* inside the grille, behind the ribbon */
  --bar: #e9e5dc;           /* the grille's bars */
  --ribbon: #d7cfbf;        /* the corrugated ribbon */
  --plate: #17130f;         /* the bakelite plate */
  --letters: #f2e7cf;       /* the word on the plate */
  --glass: #2c0d0a;         /* the ON AIR glass, unlit */
  --glass-dim: #64241c;     /* the letters on the unlit glass */
  --lamp: #ff4b31;          /* the ON AIR glass, lit */
  --lamp-deep: #c3170c;     /* its edges, lit */
  --filament: #ffb066;      /* the last warm glow as the lamp goes out */
  --focus: #f2e7cf;         /* the ring of the keyboard focus */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--letters);
  font-family: 'Anybody Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.mic-wrap {
  position: relative;
}

/* ---------------------------------------------------------------- the chrome body */
/* the lamp sits in the left end; the plate sits in the middle of what is left, with as much grille on either side */
.mic {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr auto 1fr;
  align-items: center;
  width: min(336px, calc(100vw - 32px));
  height: 60px;
  padding: 0 0 0 14px;
  border: 0;
  border-radius: 999px;
  /* chrome: a bright sky at the top, a dark band of floor round the middle, a light bounce at the bottom */
  background:
    linear-gradient(180deg,
      var(--chrome-hi) 0%,
      var(--chrome) 22%,
      var(--chrome-lo) 52%,
      var(--chrome) 80%,
      var(--chrome-hi) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 30px -18px rgba(255, 255, 255, 0.14);
  color: var(--letters);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.mic:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .mic:focus-visible {
  outline: none;
}

/* the grille, the ribbon behind it and the light on the bars: the script draws them */
.mic__grille {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--cavity);
}

/* the depth of the grille: it sits a little inside the chrome */
.mic__shade {
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  box-shadow:
    inset 0 4px 6px rgba(0, 0, 0, 0.75),
    inset 0 -2px 3px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the ON AIR lamp */
.mic__lamp {
  position: relative;
  grid-column: 1;
  display: grid;
  place-items: center;
  width: 48px;
  height: 26px;
  border-radius: 6px;
  background: var(--glass);
  /* the chrome bezel, and the glass a hair below it */
  box-shadow:
    0 0 0 1.5px #121110,
    0 0 0 3px #bdb9b0,
    0 0 0 3.6px #4a4741,
    inset 0 2px 3px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

/* the glass lit from behind: red, hotter in the middle where the bulb is */
.mic__glass {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.mic__glass--lit {
  background:
    radial-gradient(ellipse 60% 75% at 50% 55%, #ffc2a3 0%, var(--lamp) 45%, var(--lamp-deep) 100%);
}

/* the filament cooling down: a short amber afterglow */
.mic__glass--warm {
  background:
    radial-gradient(ellipse 55% 70% at 50% 55%, var(--filament) 0%, #8a2a12 70%, var(--glass) 100%);
}

/* a reflection on the glass, lit or not */
.mic__lamp::after {
  content: '';
  position: absolute;
  inset: 1px 3px auto;
  height: 8px;
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.mic__onair {
  position: relative;
  grid-area: 1 / 1;
  font-size: 10px;
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
}

.mic__onair--dim {
  color: var(--glass-dim);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6);
}

.mic__onair--lit {
  color: #fff6e6;
  text-shadow: 0 0 4px rgba(255, 200, 170, 0.9), 0 0 1px #fff;
  opacity: 0;
}

/* ---------------------------------------------------------------- the bakelite plate */
.mic__plate {
  position: relative;
  grid-column: 3;
  display: grid;
  place-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #2a241d 0%, var(--plate) 55%, #0d0b09 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 1.5px #0b0a09,
    0 0 0 3px #c9c5bc,
    0 0 0 3.6px #45423d,
    0 3px 6px 2px rgba(0, 0, 0, 0.7);
}

.mic__word {
  display: inline-flex;
  justify-content: center;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 92%;
  letter-spacing: 0.005em;
  line-height: 1;
  white-space: nowrap;
  color: var(--letters);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.8);
}

/* each letter on its own, so it can swell while it is said */
.mic__letter {
  display: inline-block;
  overflow: hidden;
  font-variation-settings: 'wght' var(--w, 620), 'wdth' var(--s, 92);
  /* room for the tops and tails of the letters, inside the box that can shrink to nothing */
  padding: 3px 0 4px;
  margin: -3px 0 -4px;
}
