/* ── Pen ── */
.demo {
  display: grid;
  gap: var(--space-7);
}
.demo__item {
  display: grid;
  justify-items: center;
  gap: var(--space-7);
  margin: 0;
}

.phone {
  --white: #FFFFFF;
  --red: #D62828;
  --curve: cubic-bezier(0.14, -0.08, 0.74, 1.4); /* the original springy curve */

  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 320px;
  height: 140px;
}

/* Soft coloured glow under the bar */
.phone::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: -10px;
  left: 0;
  width: 84%;
  height: 0;
  margin: auto;
  box-shadow:
    0 0 25px 9px rgba(214, 40, 40, 0.4),
    50px 10px 25px 8px rgba(255, 255, 255, 0.5),
    -40px 8px 25px 9px rgba(243, 202, 32, 0.6);
}

/* The gooey trick: blur everything inside, then push the contrast so edges
   snap back sharp. multiply turns the white working background into the
   page's mustard while the black bar stays black. */
.phone__content {
  position: absolute;
  bottom: 0;
  width: 100%;
  overflow: hidden;
  background: #fff;
  filter: contrast(20);
  mix-blend-mode: multiply;
}
.phone__bottom {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 66px;
  background: #000;
  filter: blur(10px);
}
.indicator {
  position: absolute;
  top: -42px;
  right: 0;
  left: 0;
  width: 70px;
  height: 70px;
  margin: auto;
  border-radius: 50%;
  /* The tinted gradients survive the contrast only at the blurred edge,
     leaving a red / white glow in the notch right under the button */
  background-image:
    linear-gradient(0deg, rgb(247, 150, 150), rgba(255, 255, 255, 0)),
    linear-gradient(0deg, rgba(255, 190, 190, 0.75), rgba(255, 255, 255, 0)),
    linear-gradient(0deg, rgb(255, 255, 255), rgba(255, 255, 255, 0));
  background-size: cover;
  background-position: 0 10px;
  transition: 200ms var(--curve);
}

/* Inputs: hidden but still focusable, so the bar works with the keyboard */
.phone input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.phone label {
  position: relative;
  display: flex;
  justify-content: center;
  width: 33%;
  height: 66px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.phone label .icon {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  height: 26px;
  margin: auto;
  color: var(--white);
  font-size: 26px;
  transition: 200ms 100ms var(--curve);
}

.circle {
  position: absolute;
  top: 32px;
  right: 0;
  left: 0;
  z-index: 1;
  width: 60px;
  height: 60px;
  margin: auto;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 4px 0 0 var(--mostaza-500); /* thin mustard crescent: the button seems to float */
  transition: 200ms var(--curve);
}

/* Selected tab: icon jumps into the circle, circle + blob slide under it.
   nth-of-type keeps the rules generic, so any number of bars can share them. */
.phone input:nth-of-type(1):checked ~ label:nth-of-type(1) .icon,
.phone input:nth-of-type(2):checked ~ label:nth-of-type(2) .icon,
.phone input:nth-of-type(3):checked ~ label:nth-of-type(3) .icon {
  top: -85px;
  color: var(--red);
}
.phone input:nth-of-type(1):checked ~ .circle,
.phone input:nth-of-type(1):checked ~ .phone__content .indicator { left: -66%; }
.phone input:nth-of-type(2):checked ~ .circle,
.phone input:nth-of-type(2):checked ~ .phone__content .indicator { left: 0; }
.phone input:nth-of-type(3):checked ~ .circle,
.phone input:nth-of-type(3):checked ~ .phone__content .indicator { left: 66%; }

/* Keyboard focus ring on the icon of the focused tab */
.phone input:nth-of-type(1):focus-visible ~ label:nth-of-type(1) .icon,
.phone input:nth-of-type(2):focus-visible ~ label:nth-of-type(2) .icon,
.phone input:nth-of-type(3):focus-visible ~ label:nth-of-type(3) .icon {
  outline: 2px solid var(--white);
  outline-offset: 8px;
  border-radius: 50%;
}

/* Variant: no crescent, only the red rim in the notch */
.phone--rim .circle { box-shadow: none; }

/* Material Symbols Sharp, loaded as an external stylesheet */
.icon {
  font-family: "Material Symbols Sharp";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 1, "wght" 600, "GRAD" 0, "opsz" 24;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  width: 1em;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .indicator,
  .circle,
  .phone label .icon { transition-duration: 0ms; }
}
