:root {
  --ink: #1d2330;
  --muted: #6c7385;
  --soft: #f1f2f5;
  --line: #e3e5ea;
  --surface: rgba(255, 255, 255, 0.94);
  /* What leads on: start, continue, buy. Red is kept for stopping and for "too loud". */
  --accent: #0d827b;
  --accent-dark: #09665f;
  --accent-soft: #e1f2f0;
  --danger: #e5484d;
  --danger-dark: #c93a3f;
  --danger-soft: #fde8e8;
  --gold: #f5c243;
  --quiet: #34c36b;
  --loud: var(--danger);
  /* How high the scene is where it does not fill the screen, see "Phones held upright". */
  --stage: 100%;
  --shadow: 0 6px 22px rgba(10, 12, 20, 0.22), 0 1px 3px rgba(10, 12, 20, 0.14);
  --edge: clamp(10px, 1.5vw, 20px);
  /* How far the floating controls keep from each rim. Tablets and phones use strips there
     themselves: status bar, home indicator, Safari's own button for leaving full screen. */
  --top: calc(var(--edge) + max(env(safe-area-inset-top, 0px), env(fullscreen-inset-top, 0px)));
  --right: calc(var(--edge) + env(safe-area-inset-right, 0px));
  --bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
  --left: calc(var(--edge) + env(safe-area-inset-left, 0px));
  --font: 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: ui-rounded, 'Arial Rounded MT Bold', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* Whatever a browser shows around the page (Safari tints its bars with this colour) is as
   dark as the scenes. */
html {
  height: 100%;
  /* Exactly what a phone shows between its own bars, however they come and go. */
  height: 100dvh;
  background: #0b0d14;
  /* No zooming by double tap: the page always fills the screen exactly. */
  touch-action: manipulation;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: #0b0d14;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- The scene and what floats on it ------------------------------------------------ */

/* The scene fills whatever the window offers; the 3D camera adapts to the shape. */
.scene {
  position: fixed;
  inset: 0;
}

.corner {
  position: fixed;
  z-index: 3;
}

.corner--tl {
  top: var(--top);
  left: var(--left);
}

.corner--tr {
  top: var(--top);
  right: var(--right);
}

.corner--bl {
  bottom: var(--bottom);
  left: var(--left);
}

.corner--br {
  right: var(--right);
  bottom: var(--bottom);
}

/* Everything but the level meter steps aside in full screen, see main.js. */
.chrome {
  transition: opacity 0.3s ease;
}

.is-bare .chrome {
  opacity: 0;
  pointer-events: none;
}

.is-bare {
  cursor: none;
}

.pill,
.level,
.dock,
.round {
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.pill svg {
  width: 26px;
  height: 26px;
  margin-left: -4px;
  stroke: none;
}

.pill strong {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pill span {
  color: var(--muted);
}

.round {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
}

.round:hover {
  background: #fff;
}

.round--flat {
  width: 36px;
  height: 36px;
  background: var(--soft);
  box-shadow: none;
}

.round--flat:hover {
  background: var(--line);
}

.dock {
  position: fixed;
  z-index: 3;
  bottom: var(--bottom);
  left: 50%;
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.dock__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px 0 12px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.dock__btn:hover {
  background: rgba(29, 35, 48, 0.07);
}

.dock__btn[aria-expanded='true'] {
  color: #fff;
  background: var(--ink);
}

/* The sound of a theme, on or off: the loudspeaker shows which. */
.dock__btn--sound[aria-pressed='true'] .sound__off,
.dock__btn--sound[aria-pressed='false'] .sound__on {
  display: none;
}

.dock__btn--sound[aria-pressed='false'] {
  color: var(--muted);
}

/* The level meter: a row of little bars; those beyond the limit are tinted red. */
.level {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px 0 13px;
  border-radius: 999px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.2s ease;
}

.level.is-loud {
  color: var(--loud);
}

.level__bars {
  display: flex;
  align-items: center;
  gap: 3px;
}

.level__bars i {
  width: 5px;
  border-radius: 3px;
  background: rgba(29, 35, 48, 0.14);
  transition: background 0.12s ease;
}

.level__bars i.is-over {
  background: rgba(229, 72, 77, 0.24);
}

.level__bars i.is-on {
  background: var(--quiet);
}

.level__bars i.is-over.is-on {
  background: var(--loud);
}

.banner {
  position: fixed;
  z-index: 2;
  top: var(--top);
  left: 50%;
  max-width: min(92%, 100% - 420px);
  padding: 0.45em 1.1em;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: clamp(15px, 1.9vw, 30px);
  font-weight: 700;
  text-align: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.banner.is-loud {
  color: #fff;
  background: var(--loud);
}

/* ---- Theme picker ------------------------------------------------------------------- */

.popover {
  position: fixed;
  z-index: 6;
  bottom: calc(var(--bottom) + 62px);
  left: 50%;
  max-width: calc(100vw - 2 * var(--edge));
  padding: 10px;
  border-radius: 26px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  animation: rise 0.18s ease;
}

/* The cards stand in a row that scrolls sideways: by swiping, with the wheel of a mouse,
   by dragging, and with the arrows at both ends (see main.js). */
.themes-box {
  position: relative;
}

.themes {
  position: relative;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.themes::-webkit-scrollbar {
  display: none;
}

.themes.is-dragged {
  cursor: grabbing;
  user-select: none;
}

.themes__arrow {
  position: absolute;
  z-index: 2;
  /* In the middle of the pictures, not of the cards with their names. */
  top: calc(50% - 15px);
  background: #fff;
  transform: translateY(-50%);
}

.themes__arrow svg {
  stroke-width: 2.6;
}

.themes__arrow--back {
  left: -2px;
}

.themes__arrow--on {
  right: -2px;
}

/* Fingers swipe; arrows are for a mouse. */
@media (hover: none), (pointer: coarse) {
  .themes__arrow {
    display: none;
  }
}

.theme {
  flex: none;
  width: min(210px, 40vw);
  padding: 6px 6px 8px;
  border: 0;
  border-radius: 18px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme:hover {
  background: var(--soft);
}

.theme[aria-checked='true'] {
  color: #fff;
  background: var(--ink);
}

.theme__preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  margin-bottom: 7px;
  overflow: hidden;
  border-radius: 13px;
  background: #161922;
}

.theme__image {
  display: block;
  width: 100%;
  height: 100%;
}

/* A theme that has not been unlocked yet wears its price. */
.theme__lock {
  position: absolute;
  z-index: 1;
  top: 7px;
  right: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 9px 0 7px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 4px rgba(10, 12, 20, 0.25);
}

.theme__lock svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.6;
}

.theme.is-locked .theme__preview img {
  filter: saturate(0.75) brightness(0.92);
}

/* ---- Cards: start, pause, end ------------------------------------------------------- */

.overlay {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px 16px 84px;
  background: rgba(10, 12, 20, 0.5);
}

.overlay--home,
.overlay--end {
  background: rgba(10, 12, 20, 0.28);
}

.card {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: min(420px, 100%);
  padding: 30px 32px 32px;
  border-radius: 32px;
  text-align: center;
  background: #fff;
  box-shadow: 0 24px 60px rgba(10, 12, 20, 0.4);
  animation: rise 0.25s ease;
}

.card h1,
.card h2 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.1;
}

.card p {
  color: var(--muted);
}

.card p:empty {
  display: none;
}

.card .card__big {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.card__actions .btn {
  height: 56px;
  padding: 0 26px;
  font-size: 17px;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ---- The shop's offer ---------------------------------------------------------------- */

.overlay--offer {
  z-index: 10;
  padding-bottom: 16px;
}

.offer {
  position: relative;
  gap: 0;
  width: min(400px, 100%);
  max-height: 100%;
  padding: 0;
  overflow: hidden auto;
  text-align: left;
}

.offer__close {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.offer__art {
  width: 100%;
  height: 132px;
  background: linear-gradient(120deg, #f6d6d0, #c9e3ea 55%, #bfe3d2);
  background-position: center;
  background-size: cover;
}

.offer__body {
  display: grid;
  gap: 12px;
  justify-items: stretch;
  width: 100%;
  padding: 20px 24px 22px;
}

.offer h2 {
  font-size: 26px;
}

.offer .note {
  text-align: center;
}

.plan {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  background: var(--accent-soft);
}

.card .plan__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.plan__head strong {
  font-family: var(--font-display);
  font-size: 18px;
}

.plan__head b {
  font-family: var(--font-display);
  font-size: 22px;
}

.plan__list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  font-weight: 600;
  list-style: none;
}

.plan__list li {
  padding-left: 26px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230d827b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    left center / 18px no-repeat;
}

.plan .btn--primary {
  height: 50px;
  font-size: 18px;
}

/* Signing in, inside the offer: see ../js/authform.js. */
.auth {
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.auth__field {
  display: grid;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.auth__field input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
}

.auth__field input:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
  outline-offset: 0;
}

.auth__tip {
  font-size: 12.5px;
  font-weight: 500;
}

.auth__error {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  color: var(--danger-dark);
  background: var(--danger-soft);
}

.card .auth__error {
  color: var(--danger-dark);
}

.auth .btn--primary {
  height: 50px;
  font-size: 18px;
}

.auth .hint--plain {
  justify-self: center;
  font-size: 14px;
}

.auth__turn {
  font-size: 14px;
  text-align: center;
}

.auth--sent {
  justify-items: center;
  padding: 6px 0;
  text-align: center;
}

.auth--sent strong {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
}

/* The address somebody is signed in with may be long. */
.row__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.btn {
  color: inherit;
  text-decoration: none;
}

.row .btn {
  flex: none;
  white-space: nowrap;
}

#offerDone {
  justify-items: center;
  padding: 26px 24px 30px;
  text-align: center;
}

.offer__check {
  width: 56px;
  height: 56px;
  padding: 12px;
  border-radius: 50%;
  stroke: #fff;
  stroke-width: 3;
  background: var(--quiet);
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 10px;
  }
}

/* ---- Settings drawer ---------------------------------------------------------------- */

/* Scrim and drawer stay in the page while closed, so that they can glide in and out. */
.scrim {
  position: fixed;
  z-index: 7;
  inset: 0;
  background: rgba(10, 12, 20, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  z-index: 8;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  width: min(372px, calc(100vw - 24px));
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(10, 12, 20, 0.4);
  overflow: hidden;
  /* Out of sight to the right, shadow and all. */
  transform: translateX(calc(100% + 60px));
  visibility: hidden;
  transition: transform 0.34s cubic-bezier(0.22, 0.9, 0.3, 1), visibility 0s linear 0.34s;
}

.drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.34s cubic-bezier(0.22, 0.9, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .drawer.is-open,
  .scrim {
    transition: none;
  }
}

.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px 22px;
}

.drawer__head h2 {
  font-family: var(--font-display);
  font-size: 22px;
}

.drawer__body {
  display: grid;
  gap: 24px;
  align-content: start;
  padding: 6px 22px 24px;
  overflow-y: auto;
}

.drawer section {
  display: grid;
  gap: 10px;
}

.drawer h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.drawer h3.split {
  display: flex;
  justify-content: space-between;
}

.drawer h3 output {
  color: var(--ink);
}

.note {
  font-size: 13.5px;
  color: var(--muted);
}

.note:empty {
  display: none;
}

.error {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  text-align: left;
  color: var(--danger-dark);
  background: var(--danger-soft);
}

.card .error {
  color: var(--danger-dark);
}

.rows {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.rows:disabled {
  opacity: 0.45;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  font-weight: 600;
}

/* ---- Controls ----------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  background: var(--soft);
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn:hover {
  background: var(--line);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.btn[aria-pressed='true'] {
  color: #fff;
  background: var(--ink);
}

.btn--wide {
  width: 100%;
}

.btn--primary {
  height: 56px;
  padding: 0 34px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-dark);
}

/* Ending, cancelling, throwing away. */
.btn--danger {
  color: var(--danger-dark);
  background: var(--danger-soft);
}

.btn--danger:hover {
  background: #fbd5d5;
}

/* A quiet line of text that can be clicked: what more there is to have. */
.hint {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--accent-soft);
  transition: background 0.15s ease;
}

.hint:hover {
  background: #cfe9e5;
}

.hint--wide {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 9px 12px;
}

.hint--plain {
  justify-self: start;
  padding: 0;
  color: var(--muted);
  background: none;
  text-decoration: underline;
}

.hint--plain:hover {
  color: var(--ink);
  background: none;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--soft);
}

.stepper button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0 0 2px;
  border: 0;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  background: #fff;
  box-shadow: 0 1px 3px rgba(10, 12, 20, 0.16);
}

.stepper button:active {
  transform: scale(0.94);
}

.stepper label {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 76px;
  padding: 0 6px;
  font-size: 14px;
  color: var(--muted);
}

.stepper input {
  width: 3.2ch;
  padding: 0;
  border: 0;
  font-size: 17px;
  font-weight: 700;
  text-align: right;
  color: var(--ink);
  background: transparent;
  appearance: textfield;
  -moz-appearance: textfield;
}

/* A number without a unit behind it stands in the middle. */
.stepper input:only-child {
  text-align: center;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.stepper--big {
  padding: 5px;
}

.stepper--big button {
  width: 42px;
  height: 42px;
  font-size: 24px;
}

.stepper--big label {
  min-width: 116px;
  font-size: 17px;
}

.stepper--big input {
  font-size: 26px;
}

/* A choice between a few named options. */
.segments {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--soft);
}

.segments button {
  min-height: 36px;
  padding: 4px 6px;
  border: 0;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.15;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.segments button:hover {
  background: rgba(29, 35, 48, 0.07);
}

.segments button[aria-checked='true'] {
  color: #fff;
  background: var(--ink);
}

/* A choice between colour schemes: each one shows three of its colours. */
.swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.swatches button {
  height: 40px;
  min-width: 0;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 14px;
  background: linear-gradient(100deg, var(--a) 0 34%, var(--b) 34% 67%, var(--c) 67%);
  box-shadow: 0 0 0 2px var(--line);
  transition: box-shadow 0.15s ease;
}

.swatches button[aria-checked='true'] {
  box-shadow: 0 0 0 2.5px var(--ink);
}

.select {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 14px;
  border: 0;
  border-radius: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  background: var(--soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d2330' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E")
    right 12px center / 18px no-repeat;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* A slider with a few steps; `--fill` (0..1) is set from main.js. */
.slider {
  --thumb: 24px;
  --fill: 0.5;
  display: block;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    var(--ink) calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fill)),
    var(--line) 0
  );
}

.slider::-webkit-slider-thumb {
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc(4px - var(--thumb) / 2);
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px var(--ink), 0 2px 5px rgba(10, 12, 20, 0.3);
  -webkit-appearance: none;
}

.slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
}

.slider::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--ink);
}

.slider::-moz-range-thumb {
  width: calc(var(--thumb) - 4px);
  height: calc(var(--thumb) - 4px);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
}

/* A row with a switch at its end. */
.toggle {
  position: relative;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle i {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--line);
  transition: background 0.15s ease;
}

.toggle i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(10, 12, 20, 0.3);
  transition: transform 0.15s ease;
}

.toggle input:checked + i {
  background: var(--quiet);
}

.toggle input:checked + i::after {
  transform: translateX(18px);
}

.toggle input:focus-visible + i {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* The parts of the microphone block keep the same distance as everything else. */
#micOn,
#micOff {
  display: grid;
  gap: 10px;
}

/* The level with a draggable limit. */
.meter {
  --level: 0;
  --thumb: 12px;
  position: relative;
  height: 34px;
}

.meter__track {
  position: absolute;
  inset: 10px 0;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  /* Same geometry as the range thumb, so bar and limit line up exactly. */
  width: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--level));
  border-radius: 999px;
  background: var(--quiet);
  transition: background 0.2s ease;
}

.meter.is-loud .meter__fill {
  background: var(--loud);
}

.meter__limit {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
  appearance: none;
  -webkit-appearance: none;
}

.meter__limit::-webkit-slider-runnable-track {
  height: 34px;
  background: transparent;
}

.meter__limit::-webkit-slider-thumb {
  width: var(--thumb);
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--ink), 0 2px 5px rgba(10, 12, 20, 0.3);
  -webkit-appearance: none;
}

.meter__limit::-moz-range-track {
  height: 34px;
  background: transparent;
}

.meter__limit::-moz-range-thumb {
  width: calc(var(--thumb) - 4px);
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fff;
}

.meter__legend {
  display: flex;
  justify-content: space-between;
  margin-top: -14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

/* ---- Small windows ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .banner {
    top: calc(var(--top) + 54px);
    max-width: 92%;
  }
}

@media (max-width: 620px) {
  .dock__btn {
    gap: 0;
    padding: 0 12px;
    font-size: 0;
  }

  .level__bars i:nth-child(even) {
    display: none;
  }

  .drawer {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  }
}

/* Low windows, such as a phone held sideways: the cards take less room. */
@media (max-height: 500px) {
  .overlay {
    padding: 8px 16px 64px;
  }

  .card {
    gap: 10px;
    padding: 16px 28px 18px;
    border-radius: 26px;
  }

  .card h1,
  .card h2 {
    font-size: 26px;
  }

  .btn--primary,
  .card__actions .btn {
    height: 46px;
    font-size: 17px;
  }

  .offer__art {
    display: none;
  }
}

/* ---- Phones held upright -------------------------------------------------------------- */

/* The scenes are wide. On an upright phone the scene takes the top of the screen, as wide
   as the screen is, and everything else has the room below it to itself: nothing has to
   float on a picture that small. All of it fits the screen, nothing scrolls. */
@media (orientation: portrait) and (max-width: 700px) {
  :root {
    --stage: calc(75vw + env(safe-area-inset-top, 0px));
  }

  body {
    background: #ecf2f1;
  }

  .scene {
    bottom: auto;
    height: var(--stage);
  }

  .corner--tl,
  .corner--tr {
    top: calc(var(--stage) + 12px);
  }

  .pill,
  .level,
  .dock,
  .round {
    background: #fff;
    box-shadow: 0 2px 10px rgba(60, 50, 110, 0.12);
  }

  .banner {
    top: calc(var(--stage) + 70px);
    width: calc(100% - 2 * var(--edge));
    max-width: none;
    padding: 0.6em 1em;
    border-radius: 22px;
    font-size: 17px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(60, 50, 110, 0.12);
  }

  /* The level meter sits in the middle, above the row of buttons. */
  .level.corner--bl {
    bottom: calc(var(--bottom) + 62px);
    left: 50%;
    transform: translateX(-50%);
  }

  .level__bars i:nth-child(even) {
    display: block;
  }

  /* Start and end leave the scene alone; a pause dims it. */
  .overlay {
    padding: calc(var(--stage) + 12px) 14px 72px;
  }

  .overlay--home,
  .overlay--end {
    background: none;
  }

  .overlay--offer {
    padding: 14px;
  }

  .card {
    padding: 22px 24px 24px;
    box-shadow: 0 10px 30px rgba(60, 50, 110, 0.16);
  }

  .offer {
    padding: 0;
  }

  .popover {
    width: calc(100vw - 2 * var(--edge));
  }

  .themes {
    scroll-snap-type: x mandatory;
  }

  .theme {
    width: 62vw;
    scroll-snap-align: center;
  }
}
