/* The button under a cover: a metal plate on a black page, a red button in a striped ring, and a tinted glass cover
   hinged at its top edge. The cover turns in 3D round the hinge; the script sets its angle. */
:root {
  --page: #000000;          /* the page */
  --plate: #222429;         /* the metal plate */
  --text: #9a9aa3;          /* the words engraved on it */
  --stripe: #ffcf1a;        /* the yellow of the ring round the button */
  --red: #e8361c;           /* the button */
  --red-side: #8e1b0b;      /* its side */
  --green: #22c56f;         /* the button once it is live */
  --green-side: #0f6b3a;
  --glass: #ff5a3c;         /* the tint of the glass cover */
}

* {
  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: #ececf0;
  font-family: 'Martian Mono Variable', ui-monospace, monospace;
  -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: 96px 16px 56px;
  /* the plate lies tilted back like a device on a desk: the script tilts it, the depth is here */
  perspective: 1000px;
  perspective-origin: 50% 35%;
}

/* ---------------------------------------------------------------- the plate */
.console {
  position: relative;
  width: min(280px, calc(100vw - 48px));
  padding: 20px 20px 22px;
  border-radius: 30px;
  background: linear-gradient(170deg, color-mix(in srgb, var(--plate) 86%, #fff), var(--plate) 40%, color-mix(in srgb, var(--plate) 70%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 30px 60px -30px rgba(255, 255, 255, 0.08);
  display: grid;
  justify-items: center;
  gap: 20px;
  transform-style: preserve-3d;
}

.console__head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.console__status {
  margin: 14px 0 0;
  min-height: 1.4em;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: center;
}

.console__status span {
  display: inline-block;
}

/* ---------------------------------------------------------------- the well and the button */
.well {
  position: relative;
  width: 176px;
  height: 176px;
  margin-top: 6px;
  transform-style: preserve-3d;
}

.well__ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--stripe) 0 9deg, #17181b 9deg 18deg);
  -webkit-mask: radial-gradient(circle, transparent 74px, #000 75px, #000 87px, transparent 88px);
  mask: radial-gradient(circle, transparent 74px, #000 75px, #000 87px, transparent 88px);
}

.well__hole {
  position: absolute;
  inset: 13px;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #0d0d10, #1a1b1f);
  box-shadow: inset 0 8px 16px rgba(0, 0, 0, 0.75), inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.well__arc {
  position: absolute;
  inset: 18px;
  pointer-events: none;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  overflow: visible;
}

.well__arc circle {
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transform: rotate(-90deg);
  transform-origin: 70px 70px;
  /* hidden until it fills: empty, its round end would still show as a speck */
  opacity: 0;
}

/* the button: the element is its side, the face sits 8 pixels higher and comes down when pressed */
.big {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 116px;
  height: 116px;
  margin: -54px 0 0 -58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--red-side);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.55);
  color: #fff;
  font: inherit;
  /* the hand presses the flat area above it (.hit--big); the button itself is for the keys and screen readers */
  pointer-events: none;
  transition: background-color 0.4s ease;
  -webkit-tap-highlight-color: transparent;
  /* a hair in front of the plate: in the 3D of the tilted plate, Safari otherwise can give the touch to the well
     that lies on the same plane under it */
  transform: translateZ(1px);
}

.big__top {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, color-mix(in srgb, var(--red) 70%, #fff), var(--red) 55%, color-mix(in srgb, var(--red) 82%, #000));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), inset 0 -3px 8px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* the green face lies on top of the red one and shows when the deploy is live */
.big__top::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, color-mix(in srgb, var(--green) 65%, #fff), var(--green) 55%, color-mix(in srgb, var(--green) 80%, #000));
  opacity: 0;
  transition: opacity 0.4s ease;
}

.big__top::after {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
}

.console.is-live .big {
  background: var(--green-side);
}

.console.is-live .big__top::before {
  opacity: 1;
}

.big__show {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  overflow: hidden;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}

.big__show > * {
  grid-area: 1 / 1;
}

.big__show svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the cover */
/* the box only gives the depth: the cover inside turns round its top edge */
.lid {
  position: absolute;
  left: -12px;
  right: -12px;
  top: -12px;
  height: 200px;
  transform-style: preserve-3d;
  /* in front of the button even when shut: on the same plane Safari may give the touch to what lies underneath */
  transform: translateZ(2px);
  pointer-events: none;
}

.lid__cover {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  /* like the button: the hand goes to the flat area above it (.hit--lid) */
  pointer-events: none;
}

.lid__glass {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 26px;
  border: 1.5px solid color-mix(in srgb, var(--glass) 55%, #fff);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04) 45%, color-mix(in srgb, var(--glass) 14%, transparent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -6px 0 color-mix(in srgb, var(--glass) 26%, transparent), 0 12px 26px rgba(0, 0, 0, 0.45);
}

/* the reflection that slides across the glass as it turns: the script moves it */
.lid__shine {
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(112deg, transparent 38%, rgba(255, 255, 255, 0.2) 45%, rgba(255, 255, 255, 0.05) 50%, transparent 56%);
}

.lid__tab {
  position: absolute;
  left: 50%;
  bottom: -17px;
  width: 64px;
  height: 18px;
  margin-left: -32px;
  display: grid;
  place-items: center;
  border-radius: 0 0 10px 10px;
  background: color-mix(in srgb, var(--glass) 70%, #000);
  color: rgba(255, 255, 255, 0.85);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform-style: preserve-3d;
}

/* the word on the tab reads only from the front: from behind, with the cover up, it would read backwards */
.lid__tab span {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.lid__cover:focus-visible .lid__glass,
.big:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

/* ---------------------------------------------------------------- where the hand goes */
.hits {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  pointer-events: none;
}

.hit {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.hit--lid {
  cursor: grab;
}

.hit--lid.is-held {
  cursor: grabbing;
}

.hit--big {
  border-radius: 50%;
  cursor: pointer;
}

.hit--big.is-off {
  pointer-events: none;
}

html[data-using='pointer'] .lid__cover:focus-visible .lid__glass,
html[data-using='pointer'] .big:focus-visible {
  outline: none;
}
