/* The brass toggle switch: the Studio monitor tile of a recording app, on a black page. The switch is a plate of
   bakelite with a brass lever, drawn in 3D by the script (a shader, or a flat drawing where WebGL is missing) from the
   colours below. */
:root {
  --page: #000000;          /* the page */
  --tile: #14110e;          /* the tile */
  --tile-edge: #2a241d;     /* the thin edge round the tile */
  --ink: #f2ebe0;           /* the name */
  --muted: #8f857a;         /* the line under the name, off */
  --live: #e2b25c;          /* the line under the name, on */
  --focus: #e2b25c;         /* the ring of the keyboard's focus */

  --brass: #e8b45a;         /* the lever and the screws: polished brass */
  --nickel: #c9cdd2;        /* the bushing, the nut and the washer: nickel plate */
  --bakelite: #4a2316;      /* the plate: oxblood bakelite */
  --bakelite-deep: #1d0d08; /* the dark swirls in the bakelite */
  --paint: #efe3c6;         /* the paint in the engraved letters */
}

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

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

/* ---------------------------------------------------------------- the tile */
.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(404px, 100%);
  padding: 14px 14px 14px 24px;
  border-radius: 24px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--tile-edge), inset 0 1px 0 rgba(255, 236, 200, 0.05);
}

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

.tile__name {
  font-size: 18px;
  font-weight: 620;
  font-stretch: 92%;
  line-height: 1.2;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* the line under the name: the word is a child, so the script can slide it without losing the colour */
.tile__state {
  display: block;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 460;
  font-stretch: 100%;
  line-height: 1.3;
  color: var(--muted);
  transition: color 0.3s ease;
}

.tile__word {
  display: inline-block;
}

.tile[data-on='true'] .tile__state {
  color: var(--live);
}

/* ---------------------------------------------------------------- the switch */
/* the box is 184 by 56, the plate drawn inside it seen a little from below, the lever standing out towards you */
.toggle {
  position: relative;
  flex: none;
  width: 184px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: grab;
  /* a finger dragged across moves the lever; up and down the page still scrolls */
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.toggle.is-dragging {
  cursor: grabbing;
}

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

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

/* the plate's own shadow on the tile, under the drawing */
.toggle__drop {
  position: absolute;
  inset: 14px 4px 1px;
  border-radius: 8px;
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.7), 0 2px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.toggle__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  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;
  }

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