/* The shortcut tooltip whose keys press down: a dark formatting toolbar on a black page, and one tooltip of smoked
   glass over it, with the shortcut drawn as raised keys. A warm light follows the button the tooltip speaks for:
   it tints the glass from behind and catches the top edge of the toolbar. */
:root {
  --page: #000000;          /* the page */
  --bar-top: #1a1a1f;       /* the toolbar, at the top */
  --bar-bottom: #111114;    /* the toolbar, at the bottom */
  --ink: #f2f1f4;           /* the words */
  --icon: #a9a8b2;          /* the drawings of the buttons at rest */
  --accent: #ffb35c;        /* the warm light: the halo, the flash, the buttons left on */
  --cap-top: #3d3c45;       /* the keys, at the top of their face */
  --cap-bottom: #2a2930;    /* the keys, at the bottom of their face */
  --cap-side: #0b0b0e;      /* the side of the keys, seen under their face */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

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

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

/* the toolbar and the room over it where the tooltip lives */
.kit {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  padding: 74px 14px 22px;
}

/* the warm light behind the glass, moved by the same spring as the tooltip */
.kit__halo {
  position: absolute;
  left: 0;
  top: 0;
  width: 190px;
  height: 120px;
  margin: -60px 0 0 -95px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent), color-mix(in srgb, var(--accent) 10%, transparent) 55%, transparent);
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

/* ---------------------------------------------------------------- the toolbar */
.bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: 17px;
  background: linear-gradient(180deg, var(--bar-top), var(--bar-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 22px 40px -18px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(0, 0, 0, 0.9);
}

/* the lit edge stays inside the toolbar's rounded box */
.bar__clip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* the top edge catching the warm light over the button the tooltip speaks for */
.bar__edge {
  position: absolute;
  left: 0;
  top: 0;
  width: 96px;
  height: 1px;
  margin-left: -48px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 80%, #fff), transparent);
  opacity: 0;
  pointer-events: none;
}

.tool {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.tool.is-hover,
.tool.is-tip {
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

@media (hover: hover) {
  .tool:hover {
    background: rgba(255, 255, 255, 0.055);
    color: var(--ink);
  }
}

.tool[aria-pressed='true'] {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--accent);
}

.tool:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 1px;
}

/* GSAP moves the drawing; its children are for the CSS */
.tool__icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

.tool__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the flash when the shortcut is pressed for real */
.tool__flash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--accent) 16%, transparent) 70%, transparent);
  opacity: 0;
  pointer-events: none;
}

.tool__ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 1.5px var(--accent);
  opacity: 0;
  pointer-events: none;
}

.bar__split {
  flex: none;
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: rgba(255, 255, 255, 0.08);
}

/* ---------------------------------------------------------------- the tooltip */
/* placed by the script */
.tip {
  position: absolute;
  left: 0;
  top: 10px;
  z-index: 2;
  pointer-events: none;
}

/* shown and hidden here, with a little scale from its tail */
.tip__in {
  position: relative;
  opacity: 0;
  transform-origin: 50% 100%;
}

.tip__body {
  position: relative;
  height: 42px;
  border-radius: 13px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, rgba(44, 43, 51, 0.62), rgba(24, 24, 29, 0.74));
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 18px 36px -14px rgba(0, 0, 0, 0.9);
}

/* a soft sheen that drifts over the glass as it glides */
.tip__body::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.05) 48%, transparent 60%);
  background-size: 260% 100%;
  background-position: var(--sheen, 80%) 0;
  pointer-events: none;
}

.tip__tail {
  position: absolute;
  left: 0;
  top: 41.5px;
  width: 16px;
  height: 8px;
  margin-left: -8px;
  overflow: visible;
}

.tip__tail-fill {
  fill: rgba(25, 25, 30, 0.86);
}

.tip__tail-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

/* one line of the tooltip: the name and the keys; the old one rolls away while the new one rolls in */
.tip__row {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 9px 0 14px;
  white-space: nowrap;
}

.tip__name {
  display: inline-flex;
  overflow: hidden;
  height: 20px;
  font-size: 13.5px;
  font-weight: 560;
  font-stretch: 104%;
  line-height: 20px;
  letter-spacing: 0.005em;
}

.tip__name span {
  display: inline-block;
}

.tip__keys {
  display: flex;
  gap: 4px;
}

/* GSAP shows and hides the key; its cap is moved by the CSS, through --p (pressed) and --lit (lit by a real press) */
.key {
  display: block;
}

.cap {
  --p: 0;
  --lit: 0;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6.5px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--cap-top), var(--cap-bottom));
  color: #ecebf0;
  font-size: 11.5px;
  font-weight: 640;
  line-height: 1;
  transform: translateY(calc(var(--p) * 1.4px));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, calc(0.17 - var(--p) * 0.07)),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 calc(2.4px - var(--p) * 1.4px) 0 var(--cap-side),
    0 calc(4px - var(--p) * 2.2px) calc(6px - var(--p) * 3px) rgba(0, 0, 0, 0.6);
}

/* the warm rim when the key is pressed for real */
.cap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
  opacity: var(--lit);
  pointer-events: none;
}

/* the face darkens a hair as it goes down */
.cap::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #000;
  opacity: calc(var(--p) * 0.14);
  pointer-events: none;
}

.cap svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cap__word {
  font-size: 10.5px;
  letter-spacing: 0.02em;
}

@media (max-width: 380px) {
  .kit {
    padding: 72px 6px 18px;
  }

  .tool {
    width: 42px;
    height: 42px;
  }
}

/* with reduced motion the keys do not move: only their shade and their shadow tell they are down */
.is-reduced .cap {
  transform: none;
}
