/* Lulleby: a night-sky page in the colours of the Lulleby logo (gold moon on dark blue). Dark only, on purpose:
   this is opened in a dark bedroom. */
:root {
  --bg: #0f1526;
  --bg-2: #141c31;
  --panel: #1a2340;
  --line: #2b3659;
  --ink: #f4eddc;
  --soft: #aab2c9;
  --gold: #d9a84a;
  --gold-deep: #b8862b;
  --player-h: 72px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: Nunito, ui-rounded, system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom, 0px) + 24px);
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: .5rem 0; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 800; font-size: 1.25rem; }
.brand svg { width: 28px; height: 28px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--soft); font-weight: 700; font-size: .95rem; }
.tabs a.on { background: var(--panel); color: var(--ink); }

/* layout */
#app { max-width: 1100px; margin: 0 auto; padding: 16px 16px 0; }
.loading { color: var(--soft); text-align: center; padding: 48px 0; }
.section { margin: 20px 0 28px; }
.section h2 { font-size: 1.2rem; font-weight: 800; margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; }
.section h2 small { color: var(--soft); font-weight: 600; font-size: .85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; } }
.card { display: block; min-width: 0; }
.card .art {
  aspect-ratio: 1; width: 100%; border-radius: 14px; background: var(--panel); object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.card .art.empty { display: grid; place-items: center; color: var(--gold); font-size: 2.6rem; }
.card h3 { font-size: .95rem; font-weight: 700; margin: 8px 2px 0; overflow-wrap: anywhere; }
.card small { display: block; color: var(--soft); margin: 2px 2px 0; font-size: .8rem; }

/* collection page */
.coll { display: grid; gap: 20px; }
@media (min-width: 760px) { .coll { grid-template-columns: 320px 1fr; align-items: start; } }
.hero img, .hero .empty { width: 100%; max-width: 420px; aspect-ratio: 1; border-radius: 18px; object-fit: cover; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); margin: 0 auto; }
.hero .empty { display: grid; place-items: center; background: var(--panel); color: var(--gold); font-size: 5rem; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); font-weight: 700; margin-bottom: 12px; }
.coll h1 { font-size: 1.7rem; font-weight: 800; }
.coll .desc { color: var(--soft); font-size: 1.02rem; max-width: 60ch; }
.tag { display: inline-block; background: var(--panel); color: var(--gold); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 700; margin-top: 4px; }
.cta {
  display: inline-flex; align-items: center; gap: 10px; margin: 14px 0 6px; background: var(--gold); color: #1c1708;
  border-radius: 999px; padding: 12px 22px; font-weight: 800; font-size: 1.02rem; box-shadow: 0 6px 0 var(--gold-deep);
  transition: transform .08s;
}
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--gold-deep); }
.tracks { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.tracks li { border-bottom: 1px solid var(--line); }
.tracks button {
  width: 100%; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 12px 4px;
  text-align: left;
}
.tracks button:disabled { opacity: .45; cursor: default; }
.tracks .n { width: 32px; height: 32px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; font-weight: 800; color: var(--gold); font-size: .9rem; }
.tracks li.now .n { background: var(--gold); color: #1c1708; }
.tracks .t { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.tracks .t small { display: block; color: var(--soft); font-weight: 600; font-size: .8rem; }
.tracks .d { color: var(--soft); font-variant-numeric: tabular-nums; font-size: .9rem; }
details { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--bg-2); }
details summary { cursor: pointer; padding: 12px 0; font-weight: 800; list-style: none; display: flex; justify-content: space-between; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; color: var(--gold); font-weight: 800; }
details[open] summary::after { content: "–"; }
.lyrics { padding: 0 0 14px; white-space: pre-line; max-width: 60ch; }
.lyrics h4 { margin: 12px 0 4px; color: var(--gold); font-size: .95rem; }
.credits { color: var(--soft); font-size: .9rem; margin: 10px 0 0; }
.credits b { color: var(--ink); }
.src { color: var(--soft); font-size: .8rem; margin-top: 18px; }
.src a { text-decoration: underline; text-underline-offset: 3px; }

/* player */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.player .bar {
  width: calc(100% - 150px); display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center;
  padding: 12px 0 12px 12px; text-align: left; position: relative;
}
.player .bar img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.bar-text { min-width: 0; display: grid; }
.bar-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 800; }
.bar-text small { color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-prog { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--line); }
.bar-prog i { display: block; height: 100%; width: 0; background: var(--gold); }
.bar-ctl { position: absolute; right: 8px; top: 0; height: var(--player-h); display: flex; align-items: center; gap: 2px; }
.bar-ctl button, .sheet-ctl button { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; }
.bar-ctl .big, .sheet-ctl .big { width: 52px; height: 52px; background: var(--gold); color: #1c1708; font-size: 1.3rem; }
.sheet-ctl .big { width: 72px; height: 72px; font-size: 1.8rem; }

.sheet {
  position: fixed; inset: 0; z-index: 20; background: linear-gradient(180deg, var(--bg-2), var(--bg));
  overflow: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  display: grid; justify-items: center; align-content: start; gap: 10px; text-align: center;
}
.sheet-close { justify-self: start; font-size: 1.6rem; color: var(--soft); line-height: 1; }
.sheet img { width: min(60vw, 280px); height: auto; aspect-ratio: 1; border-radius: 18px; object-fit: cover; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); background: var(--panel); }
.sheet h2 { font-size: 1.3rem; font-weight: 800; margin-top: 8px; }
.sheet p { color: var(--soft); margin: 0; }
.sheet input[type=range] { width: min(100%, 520px); accent-color: var(--gold); margin-top: 10px; }
.times { width: min(100%, 520px); display: flex; justify-content: space-between; color: var(--soft); font-variant-numeric: tabular-nums; font-size: .85rem; }
.sheet-ctl { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.sheet-ctl button:not(.big) { width: 56px; font-size: .85rem; font-weight: 800; }
.sleep { display: grid; gap: 8px; justify-items: center; margin-top: 10px; color: var(--soft); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chips button { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .85rem; }
.chips button.on { background: var(--gold); color: #1c1708; border-color: var(--gold); }
.queue { width: min(100%, 520px); margin: 16px 0 0; padding: 0; list-style: none; text-align: left; border-top: 1px solid var(--line); }
.queue li button { width: 100%; padding: 10px 4px; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.queue li.now button { color: var(--gold); font-weight: 800; }
.queue small { color: var(--soft); font-variant-numeric: tabular-nums; }

.empty-state { color: var(--soft); text-align: center; padding: 40px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* login */
.login { max-width: 360px; margin: 10vh auto 0; display: grid; gap: 12px; text-align: center; }
.login-moon { font-size: 4rem; color: var(--gold); line-height: 1; }
.login h1 { font-size: 2rem; font-weight: 800; }
.login p { color: var(--soft); margin: 0; }
.login input { font: inherit; font-size: 1.1rem; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-align: center; }
.login input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.login .cta { justify-self: center; }
.login-err { color: #e58a8a; font-weight: 700; min-height: 1.3em; }
.linkbtn { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; font-weight: 700; padding: 0; }
