/* The pill bug switch: the Do not disturb tile of a phone's settings, on a white page. The switch is a little window
   with a pill bug in it, drawn by the script as an SVG from the colours below. */
:root {
  --page: #ffffff;          /* the page */
  --tile: #f4f2ee;          /* the tile */
  --ink: #1c1b20;           /* the name */
  --ink-on: #3b3486;        /* the name, with Do not disturb on */
  --muted: #7a7680;         /* the line under the name */
  --focus: #5b4fd6;         /* the ring of the keyboard's focus */

  --day: #f3eee5;           /* the window, off: daylight at the top */
  --day-floor: #e3dacb;     /* the window, off: the floor */
  --dusk: #34306a;          /* the window, on: dusk at the top */
  --dusk-floor: #1d1b3d;    /* the window, on: the floor */
  --moon: #e9e4ff;          /* the moon that comes out with the dusk */

  --shell-hi: #b9c0cc;      /* the shell, where it faces the light */
  --shell: #6c7381;         /* the shell */
  --shell-lo: #2d313a;      /* the shell, turned from the light */
  --rim: #eef2f8;           /* the bright edge along each plate */
  --belly: #23252c;         /* the underside */
  --leg: #3a3e48;           /* the legs and antennae on the near side */
  --leg-far: #7d828d;       /* the legs and antenna on the far side */
}

* {
  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: 'Onest Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- the tile */
.tile {
  --lit: 0;                 /* set by the script: how far the dusk has come */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(392px, 100%);
  padding: 14px 14px 14px 24px;
  border-radius: 42px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px rgba(28, 27, 32, 0.04);
}

.tile__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tile__name {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: color-mix(in srgb, var(--ink-on) calc(var(--lit) * 100%), var(--ink));
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.tile__state {
  font-size: 13.5px;
  font-weight: 420;
  line-height: 1.3;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the switch */
/* the drawing is in a box of 184 by 56: the floor at 49, the ball 21 in radius */
.bug {
  position: relative;
  flex: none;
  width: 184px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--day);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

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

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

.bug__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

/* the second drawing is only for the reduced motion: it fades in over the first */
.bug__art--alt {
  opacity: 0;
}

/* the window's glass: a soft shadow under its top edge and a thin line round it */
.bug__glass {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 2px 5px rgba(20, 18, 40, 0.14),
    inset 0 0 0 1px rgba(20, 18, 40, 0.07);
  pointer-events: none;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* narrow phones: the switch shrinks a little with the screen, the drawing with it */
@media (max-width: 360px) {
  .tile {
    padding-left: 18px;
    gap: 10px;
  }

  .bug {
    width: 160px;
    height: 48.7px;
  }
}
