/* Sonos Widget. Black and white, like the app: black on white by day, white on black by night. */

:root {
  --bg: #f2f2f7;
  --fg: #000000;
  --muted: #8a8a8e;
  --panel: #ffffff;       /* the widget */
  --fill: rgb(0 0 0 / 0.07);    /* a speaker's row */
  --button: rgb(0 0 0 / 0.1);   /* quiet buttons */
  --pill: #000000;
  --pill-fg: #ffffff;
  --lift: 0 10px 30px rgb(0 0 0 / 0.1);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --fg: #ffffff;
    --muted: #8e8e93;
    --panel: #000000;
    --fill: rgb(255 255 255 / 0.1);
    --button: rgb(255 255 255 / 0.16);
    --pill: #ffffff;
    --pill-fg: #000000;
    --lift: 0 14px 36px rgb(0 0 0 / 0.55);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); color: var(--fg); }

body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.45;
}

a { color: inherit; }

/* Home */

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  text-align: center;
}

.app-icon {
  display: block;
  width: clamp(36px, 8vw, 52px);
  height: auto;
  margin: 0 auto 12px;
  border-radius: 22.5%;
  filter: drop-shadow(0 3px 7px rgb(0 0 0 / 0.12));
}
@media (prefers-color-scheme: dark) {
  /* A black icon needs an edge on a dark page. */
  .app-icon { box-shadow: 0 0 0 1px rgb(255 255 255 / 0.2); filter: none; }
}

h1 {
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.tagline {
  margin-top: 10px;
  font-size: clamp(17px, 2.6vw, 21px);
  color: var(--muted);
  text-wrap: balance;
}

/* The stage: two speakers, and the widget that controls them */

.stage {
  flex: 1;
  width: 100%;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vh, 40px);
  padding: 24px 0 8px;
}

.speakers {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 4vw, 44px);
  width: 100%;
}

.speaker { width: min(46vw, 220px); }
.speaker svg { display: block; width: 100%; height: auto; overflow: visible; }
.speaker figcaption {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s;
}
.speaker.playing figcaption { color: var(--fg); }

.speaker .body { fill: var(--fg); }
.speaker .cone { fill: var(--fg); transform-box: fill-box; transform-origin: center; }
.speaker .wave {
  fill: none;
  stroke: var(--fg);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.25s ease;
}
/* A quiet speaker is drawn in grey, like the widget when it's away from home. */
.speaker .body, .speaker .cone { transition: fill 0.25s ease; }
.speaker:not(.playing) .body, .speaker:not(.playing) .cone { fill: color-mix(in srgb, var(--fg) 26%, var(--bg)); }

/* Sound: the rings a speaker has depend on its volume, and they ripple outward. */
.speaker.playing[data-level="1"] .wave.w1,
.speaker.playing[data-level="2"] .wave.w1,
.speaker.playing[data-level="2"] .wave.w2,
.speaker.playing[data-level="3"] .wave { animation: ripple 1.15s ease-in-out infinite; }
.speaker.playing .wave.w2 { animation-delay: 0.14s; }
.speaker.playing .wave.w3 { animation-delay: 0.28s; }
.speaker.playing .cone { animation: thump 0.575s ease-in-out infinite; }

@keyframes ripple {
  0%, 100% { opacity: 0.16; }
  30% { opacity: 1; }
}
@keyframes thump {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.16); }
}

/* A skip gives the speaker a small nudge in the direction of travel. */
.speaker.skip-forward .unit { animation: nudge-forward 0.36s ease-out; }
.speaker.skip-back .unit { animation: nudge-back 0.36s ease-out; }
@keyframes nudge-forward { 40% { transform: translateX(7px); } }
@keyframes nudge-back { 40% { transform: translateX(-7px); } }

@media (prefers-reduced-motion: reduce) {
  .speaker.playing .wave, .speaker.playing .cone, .speaker .unit { animation: none !important; }
  .speaker.playing[data-level="1"] .wave.w1,
  .speaker.playing[data-level="2"] .wave.w1,
  .speaker.playing[data-level="2"] .wave.w2,
  .speaker.playing[data-level="3"] .wave { opacity: 1; }
}

/* The widget, as it looks on the Home Screen at medium size */

.widget {
  width: min(100%, 356px);
  padding: 14px;
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--lift);
  display: grid;
  gap: 8px;
  text-align: left;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 8px;
  border-radius: 14px;
  background: var(--fill);
}

.transport, .volume { display: flex; align-items: center; gap: 5px; }

.widget button {
  appearance: none;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--button);
  color: var(--fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease;
  touch-action: manipulation;
}
.widget button:active { transform: scale(0.9); }
.widget button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.widget button svg { width: 44%; height: 44%; fill: currentColor; }
.widget button.play { width: 40px; height: 40px; background: var(--fg); color: var(--panel); }
.widget .volume button { width: 28px; height: 28px; }

.who { min-width: 0; }
.who .name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who .line {
  min-height: 1.3em;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level {
  width: 22px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.readout {
  min-height: 3em;
  max-width: 32ch;
  margin-top: 14px;
  font-size: 17px;
  font-weight: 600;
  text-wrap: balance;
}

.download {
  margin-top: 18px;
  display: inline-block;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--pill-fg);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s ease;
}
a.download:hover { transform: scale(1.04); }
a.download:active { transform: scale(0.97); }
.download.soon { opacity: 0.85; }

.footer-links {
  margin-top: 26px;
  display: flex;
  gap: 22px;
  font-size: 14px;
  color: var(--muted);
}
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--fg); }

/* "App by Jon Bobrow", the same signature as in the app */
.by-jon { display: inline-block; margin-top: 14px; color: var(--muted); transition: color 0.15s; }
.by-jon:hover { color: var(--fg); }
.by-jon svg { display: block; width: 150px; height: auto; }

.fine-print {
  margin-top: 14px;
  max-width: 44ch;
  font-size: 12px;
  color: var(--muted);
  text-wrap: balance;
}

/* Privacy and Support */

.doc {
  max-width: 640px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 16px 56px;
}
.doc .back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}
.doc .back img { width: 26px; height: 26px; border-radius: 22.5%; }
@media (prefers-color-scheme: dark) {
  .doc .back img { box-shadow: 0 0 0 1px rgb(255 255 255 / 0.2); }
}
.doc h1 { margin-top: 36px; font-size: clamp(32px, 6vw, 44px); }
.doc .updated { margin-top: 6px; color: var(--muted); font-size: 15px; }
.doc h2 { margin-top: 32px; font-size: 21px; }
.doc p, .doc li { margin-top: 10px; font-size: 17px; text-wrap: pretty; }
.doc ul, .doc ol { padding-left: 1.2em; }
.doc a:not(.back) { text-decoration: underline; text-underline-offset: 0.15em; }
.doc .fine-print { margin-top: 40px; max-width: none; font-size: 14px; }

[hidden] { display: none !important; }
