/* The split button: a green two-part button on a black page, and under it the menu of the ways to merge. */
:root {
  --page: #000000;          /* the page */
  --green: #238636;         /* the button, ready to merge */
  --purple: #8957e5;        /* the button once merged */
  --panel: #161b22;         /* the menu */
  --line: #30363d;          /* its edge */
  --ink: #e6edf3;           /* the words */
  --muted: #8b949e;         /* the explanations and the line under the button */
  --menu-w: min(340px, calc(100vw - 32px));
}

* {
  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(--ink);
  font-family: 'Hubot 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: 40px 16px 300px;
}

.split {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 18px;
}

/* the room the open menu takes, for the preview's frame */
.split__frame {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--menu-w);
  height: 300px;
  margin-left: calc(var(--menu-w) / -2);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the button in two parts */
.split__btn {
  position: relative;
  display: flex;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--green);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px -12px rgba(35, 134, 54, 0.6);
}

.split__main,
.split__caret {
  position: relative;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* the light of the hover, laid over the colour of the whole button */
.split__main::before,
.split__caret::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* only where there is a mouse: on iPhone a layer that lights up under the finger counts as a hover, and the first
   tap would only light it instead of clicking (the finger gets the press of the whole button instead) */
@media (hover: hover) {
  .split__main:not(:disabled):hover::before,
  .split__caret:not(:disabled):hover::before {
    opacity: 0.09;
  }

  .split__main:not(:disabled):active::before,
  .split__caret:not(:disabled):active::before {
    opacity: 0.16;
  }
}

.split__main {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px 0 14px;
  white-space: nowrap;
}

.split__main:disabled,
.split__caret:disabled {
  cursor: default;
}

.split__icon {
  position: relative;
  display: grid;
  width: 18px;
  height: 18px;
  flex: none;
}

.split__icon svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.split__label {
  position: relative;
  display: block;
  height: 1.3em;
  overflow: hidden;
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.005em;
  line-height: 1.3;
}

.split__word {
  display: block;
}

/* the progress of the merge, along the bottom of the action */
.split__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.65);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.split__caret {
  width: 44px;
  flex: none;
  display: grid;
  place-items: center;
  box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.28);
}

.split__caret svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the menu */
.split__menu {
  position: absolute;
  top: 54px;
  left: 50%;
  z-index: 2;
  width: var(--menu-w);
  margin-left: calc(var(--menu-w) / -2);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.4);
  transform-origin: 50% 0;
}

.split__menu[hidden] {
  display: none;
}

.split__option {
  position: relative;
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 11px 14px 12px 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.split__option + .split__option {
  margin-top: 2px;
}

@media (hover: hover) {
  .split__option:hover {
    background: rgba(177, 186, 196, 0.08);
  }
}

.split__option:focus-visible {
  outline: none;
  background: rgba(177, 186, 196, 0.12);
  box-shadow: inset 0 0 0 2px #2f81f7;
}

.split__title {
  font-size: 14px;
  font-weight: 640;
}

.split__text {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

/* one tick for the whole menu: it slides to the chosen way */
.split__tick {
  position: absolute;
  left: 18px;
  top: 0;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.split__tick svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.split__hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.split__hint span {
  display: inline-block;
}

.split__main:focus-visible,
.split__caret:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -4px;
  border-radius: 9px;
}

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