/* The share page (docs/06-sharing.md §2.2): one dark screen, usable with one
   hand on an iPhone, centred on a wide screen. The colours are the apps'
   (docs/02-screen-sketches.md), copied by hand because the page shares no
   code with them: the ground #111113, the player bar #1A1A1D, text #F2F1EE,
   quiet text #9E9DA4, the accent fill #2F5BEA with white on it, accent text
   and progress #7C9BFF, the tint under the playing row 16% of #7C9BFF, and
   #F0A35E for a song that cannot play. */

:root {
  color-scheme: dark;
  --ground: #111113;
  --bar: #1a1a1d;
  --line: #26262b;
  --text: #f2f1ee;
  --quiet: #9e9da4;
  --fill: #2f5bea;
  --accent: #7c9bff;
  --tint: rgba(124, 155, 255, 0.16);
  --warn: #f0a35e;
  --player-height: 148px;
  --gutter: 20px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  display: block;
}

/* The page */

.share {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) var(--gutter) calc(40px + env(safe-area-inset-bottom));
}

.share.has-player {
  padding-bottom: calc(var(--player-height) + 24px + env(safe-area-inset-bottom));
}

.head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cover {
  width: min(60vw, 240px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--bar);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  object-fit: cover;
}

.name {
  margin: 20px 0 4px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta {
  margin: 0;
  color: var(--quiet);
  font-size: 14px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 24px;
  margin: 20px 0 8px;
  width: 100%;
}

.play-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px 0 16px;
  border-radius: 22px;
  background: var(--fill);
  color: #fff;
  font-weight: 600;
}

.play-all .icon {
  width: 20px;
  height: 20px;
}

.play-all .icon-pause,
.is-playing .play-all .icon-play {
  display: none;
}

.is-playing .play-all .icon-pause {
  display: block;
}

/* "Original quality": a switch with the bytes it costs beside it */

.original {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.original-text {
  font-size: 15px;
}

.original-size {
  font-size: 12px;
  color: var(--quiet);
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 14px;
  background: #3a3a40;
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
  flex: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.switch:checked {
  background: var(--fill);
}

.switch:checked::after {
  transform: translateX(18px);
}

/* The tracks */

.tracks {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.track {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}

.row {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 4px;
  text-align: left;
  border-radius: 8px;
}

.row:active {
  background: var(--tint);
}

.num {
  flex: none;
  width: 24px;
  text-align: right;
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.names {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist {
  color: var(--quiet);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dur {
  flex: none;
  color: var(--quiet);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.track.playing {
  background: var(--tint);
}

.track.playing .num,
.track.playing .title {
  color: var(--accent);
}

.track.failed .title {
  color: var(--warn);
}

.download {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 56px;
  padding: 0 4px;
  color: var(--accent);
  text-decoration: none;
  border-radius: 8px;
}

.download:active {
  background: var(--tint);
}

.download small {
  font-size: 11px;
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.foot {
  margin-top: 28px;
  text-align: center;
  color: var(--quiet);
  font-size: 12px;
  letter-spacing: 0.04em;
}

/* The player, fixed to the bottom while something has played */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--bar);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

.player-inner {
  max-width: 640px;
  margin: 0 auto;
}

.now {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now.warn {
  color: var(--warn);
  font-weight: 500;
}

/* What is playing: "Original quality (WAV, 51 MB)" / "Light copy (AAC, 6.2 MB)" */
.source {
  margin: 0;
  font-size: 12px;
  color: var(--quiet);
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-height: 1.4em;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.time {
  flex: none;
  min-width: 40px;
  color: var(--quiet);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.time:last-child {
  text-align: right;
}

/* The position bar: a 44px band drawn by hand and driven by Pointer Events
   (page.js), not an <input type="range">. Safari's range input takes a tap
   only after a threshold and follows the finger late (the owner's finding on
   2026-10-20); a band of our own moves the moment the finger lands, anywhere
   on its 44px, and follows without a threshold. The line is 4px in the
   middle; --p is the position as a percentage, set by the script. */

.seek {
  --p: 0%;
  position: relative;
  flex: 1 1 auto;
  height: 44px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  outline-offset: -2px;
}

.seek:focus-visible {
  outline: 2px solid var(--accent);
}

.seek-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: #3a3a40;
}

.seek-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--p);
  border-radius: 2px;
  background: var(--accent);
}

.seek-thumb {
  position: absolute;
  top: 50%;
  left: var(--p);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  transition: transform 0.12s;
}

.seek.scrubbing .seek-thumb {
  transform: translate(-50%, -50%) scale(1.25);
}

/* While the browser fetches the new position, the number dims for a moment */
.player.seeking .time:first-child {
  opacity: 0.45;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  margin-top: 2px;
}

.transport button {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.transport button:active {
  background: var(--tint);
}

.transport .prev .icon,
.transport .next .icon {
  width: 28px;
  height: 28px;
}

/* The round play/pause is white whatever the accent (docs/02) */
.toggle {
  background: #fff;
  color: #111;
}

.toggle:active {
  background: #ddd !important;
}

.toggle .icon {
  width: 26px;
  height: 26px;
}

.toggle .icon-pause,
.is-playing .toggle .icon-play {
  display: none;
}

.is-playing .toggle .icon-pause {
  display: block;
}

/* The one page for an expired or unknown link */

.gone {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px var(--gutter);
  text-align: center;
}

.gone-text {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.gone .foot {
  margin: 0;
}

@media (min-width: 700px) {
  .cover {
    width: 260px;
  }
  .name {
    font-size: 30px;
  }
}
