/* QTube Music — one screen, laid out like the app's full-screen player (the Stage). */

:root {
  --ink: #fff;
  --ink-2: rgb(255 255 255 / 66%);
  --ink-3: rgb(255 255 255 / 34%);
  --deep: #0b3349;
  --glass: rgb(255 255 255 / 10%);
  --glass-line: rgb(255 255 255 / 14%);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--deep);
  color: var(--ink);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* The cover's colour, washed across the whole view, as on the Stage. */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(60% 70% at 24% 46%, rgb(74 160 204 / 55%), transparent 70%),
    radial-gradient(50% 60% at 82% 18%, rgb(30 110 152 / 60%), transparent 72%),
    radial-gradient(70% 60% at 70% 100%, rgb(6 30 44 / 90%), transparent 70%),
    linear-gradient(160deg, #1a6286 0%, #0f4664 46%, #0a2f44 100%);
}

/* Fine grain so the wash never bands. */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 10%), 0 10px 30px rgb(0 0 0 / 14%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
}

/* Top bar */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 0;
}

.top-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink);
  transition: background .2s;
}

.top-right { display: flex; gap: 8px; align-items: center; }

.top-pill {
  height: 40px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s;
}

.top-btn:hover, .top-pill:hover { background: rgb(255 255 255 / 18%); }

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  height: 40px;
}

.segmented button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .25s var(--ease), color .25s;
}

.segmented button[aria-pressed="true"] {
  background: rgb(255 255 255 / 20%);
  color: var(--ink);
}

/* Cover + lyrics */
.body {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 3vh 6vw 2vh;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 6vw;
  align-items: center;
}

.art {
  justify-self: end;
  width: min(100%, 460px);
}

.art img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 28px 50px rgb(0 0 0 / 35%));
}

.title h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.15;
}

.title p {
  margin: 4px 0 0;
  font-size: 17px;
  color: var(--ink-2);
}

.lyrics-view {
  position: relative;
  height: var(--view, 21.5em);
  margin-top: 2.2em;
  font-size: clamp(24px, 2.5vw, 36px);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 72%, transparent 100%);
}

.lyrics {
  list-style: none;
  margin: 0;
  padding: 0;
  font-weight: 700;
  letter-spacing: -.012em;
  line-height: 1.2;
  transition: transform .52s var(--ease);
  will-change: transform;
}

.lyrics li {
  padding: .3em 0;
  color: var(--ink-3);
  cursor: pointer;
  transition: color .52s var(--ease), filter .52s var(--ease), opacity .52s var(--ease);
}

.lyrics li[data-d="3"], .lyrics li[data-d="4"] { filter: blur(.8px); }
.lyrics li.is-current { color: var(--ink); filter: none; opacity: 1; }
.lyrics li:hover:not(.is-current) { color: rgb(255 255 255 / 55%); }

/* Player bar */
.player {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto 14px;
  padding: 14px 40px 16px;
  border-radius: 34px;
}

.time {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.track {
  height: 4px;
  border-radius: 2px;
  background: rgb(255 255 255 / 22%);
  overflow: hidden;
}

.fill {
  display: block;
  height: 100%;
  width: 12%;
  background: rgb(255 255 255 / 88%);
  border-radius: 2px;
  transition: width .52s var(--ease);
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  margin-top: 8px;
}

.note {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}

.note.right {
  justify-self: end;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.note a, .note .link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}

.note a:hover, .note .link:hover { text-decoration: underline; }

.link {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}

.play {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #fff;
  color: var(--deep);
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
  transition: transform .2s var(--ease), box-shadow .2s;
}

.play:hover { transform: scale(1.05); box-shadow: 0 14px 36px rgb(0 0 0 / 30%); }
.play:active { transform: scale(.97); }

/* Install popover, like the app's lyrics options */
.popover {
  position: absolute;
  left: 50%;
  bottom: 150px;
  translate: -50% 0;
  width: min(440px, calc(100% - 32px));
  padding: 18px 22px 16px;
  border-radius: 22px;
  background: rgb(18 60 82 / 72%);
  z-index: 2;
}

.popover[hidden] { display: none; }

.popover h2 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.popover ol { margin: 0; padding-left: 1.2em; }
.popover li { margin: 6px 0; color: var(--ink-2); }
.popover b { color: var(--ink); font-weight: 600; }
.fine { margin: 12px 0 6px; font-size: 13px; color: var(--ink-2); }

pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(0 0 0 / 28%);
  overflow-x: auto;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
}

.foot {
  padding: 0 24px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

.foot a { color: var(--ink-2); }

:focus-visible { outline: 2px solid rgb(255 255 255 / 80%); outline-offset: 3px; }

/* Narrow windows and phones: cover above, lyrics below, as on a small Stage. */
@media (max-width: 820px) {
  .top { padding: 14px 14px 0; }
  .top-pill { padding: 0 14px; }
  .segmented button { padding: 0 12px; }

  .body {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 18px 24px 8px;
    text-align: center;
  }

  .art { justify-self: center; width: min(52vw, 230px); }
  .title h1 { font-size: 26px; }
  .lyrics-view { --view: 9.6em; margin-top: 1.2em; font-size: 22px; }
  .player { padding: 12px 22px 14px; border-radius: 28px; }
  .controls { gap: 14px; }
  .note { font-size: 12px; }
  .play { width: 64px; height: 64px; }
  .popover { bottom: 132px; }
}

@media (prefers-reduced-motion: reduce) {
  .lyrics, .lyrics li, .fill { transition: none; }
}

/* Top-bar pills can be buttons too */
button.top-pill { appearance: none; color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }

/* "Why QTube Music" dialog */
.why {
  width: min(620px, calc(100% - 32px));
  max-height: min(84svh, 760px);
  padding: 26px 30px 24px;
  border-radius: 26px;
  color: var(--ink);
  background: rgb(14 52 72 / 78%);
  overflow-y: auto;
}

.why::backdrop { background: rgb(4 20 30 / 45%); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

.why[open] { animation: why-in .32s var(--ease); }
@keyframes why-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.why h2 { margin: 0 0 10px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.why b { color: var(--ink); font-weight: 650; }
.why-lead, .why-ours { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.why-ours { padding-top: 16px; border-top: 1px solid var(--glass-line); }

.why-list { margin: 18px 0; }
.why-list dt { font-weight: 650; font-size: 15px; margin-top: 12px; }
.why-list dt:first-child { margin-top: 0; }
.why-list dd { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }

.why-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 12%);
  color: var(--ink);
  cursor: pointer;
}

.why-close:hover { background: rgb(255 255 255 / 20%); }

@media (max-width: 820px) {
  .top-right { gap: 6px; }
  .top-pill { height: 36px; font-size: 13px; padding: 0 12px; }
  .segmented { height: 36px; }
  .segmented button { font-size: 13px; padding: 0 10px; }
  .why { padding: 22px 20px 20px; }
}
@media (max-width: 520px) {
  .top-pill[href*="github"] { display: none; }
  .controls { grid-template-columns: 1fr auto 1fr; gap: 10px; }
  .note { font-size: 11.5px; }
}

/* Desktop: exactly one screen tall, like the Stage. The lyrics fill what the title leaves. */
@media (min-width: 821px) {
  .stage { height: 100svh; min-height: 600px; }
  .body { min-height: 0; height: 100%; padding: 2vh 6vw 2vh; }
  .art { width: min(100%, 460px, 52svh); }
  .text {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: 6vh;
  }
  .lyrics-view { height: auto; min-height: 0; margin-top: 3vh; }
}

/* While the dialog is open the page behind it doesn't scroll, and scrolling inside it doesn't leak out. */
html:has(dialog[open]), html.is-locked { overflow: hidden; }
.why { overscroll-behavior: contain; }

/* The install popover sits above its "How to install" link, solid enough that lyrics don't show through. */
.popover {
  left: auto;
  right: max(16px, calc(50% - 480px + 24px));
  translate: none;
  background: rgb(13 50 70 / 94%);
}
.popover pre { white-space: pre-wrap; word-break: break-all; }
@media (max-width: 820px) { .popover { right: 16px; } }
