@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
}

@font-face {
  font-family: 'Fraunces';
  src: url('fonts/fraunces-italic-latin.woff2') format('woff2');
  font-style: italic;
  font-weight: 300 500;
  font-display: swap;
}

:root {
  /* --deep and --glow follow the scene (set from app.js): darkest and lightest palette colours. */
  --deep: #1a1c3a;
  --glow: #ffd9b5;
  --ink: rgb(247 243 255 / 0.95);
  --ink-soft: rgb(247 243 255 / 0.66);
  --line: rgb(255 255 255 / 0.14);
  --glass: color-mix(in srgb, var(--deep) 42%, transparent);
  --gutter: max(16px, env(safe-area-inset-left));
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  background-color: var(--deep);
  color: var(--ink);
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 100;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color 2s var(--ease);
}

html[data-idle='true'] body {
  cursor: none;
}

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

button {
  cursor: pointer;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The picture: rendered small, stretched to the screen. */
.sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Intro: the word sits in the sky and dissolves into it when the music starts. */
.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.25rem;
  padding: 24px var(--gutter);
  text-align: center;
  transition: opacity 1.8s var(--ease), filter 1.8s var(--ease), visibility 0s linear 1.8s;
}

html:not([data-state='intro']) .intro {
  opacity: 0;
  filter: blur(14px);
  visibility: hidden;
}

.wordmark {
  margin: 0;
  font-weight: 300;
  font-size: clamp(6rem, 26vw, 14rem);
  line-height: 0.85;
  letter-spacing: -0.035em;
  font-variation-settings: 'SOFT' 100, 'opsz' 144, 'wght' 300;
  text-shadow: 0 0 60px color-mix(in srgb, var(--glow) 35%, transparent);
  transition: letter-spacing 1.8s var(--ease);
  animation: breathe 9s ease-in-out infinite;
}

html:not([data-state='intro']) .wordmark {
  letter-spacing: 0.25em;
}

@keyframes breathe {
  50% {
    font-variation-settings: 'SOFT' 100, 'opsz' 144, 'wght' 390;
  }
}

.lede {
  margin: 0;
  max-width: 30ch;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: balance;
}

.begin {
  margin-top: 0.75rem;
  min-width: 10rem;
  padding: 0.85rem 2.4rem;
  border: 1px solid color-mix(in srgb, var(--glow) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--glow) 14%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 1.125rem;
  letter-spacing: 0.02em;
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.begin:hover {
  background: color-mix(in srgb, var(--glow) 24%, transparent);
}

.begin:disabled {
  opacity: 0.6;
  cursor: progress;
}

.notice {
  min-height: 1.5em;
  margin: 0;
  max-width: 34ch;
  font-size: 0.95rem;
  color: var(--ink);
}

/* Controls that fade away while the music plays. */
.chrome {
  transition: opacity 0.9s var(--ease), visibility 0s linear 0s;
}

html[data-state='intro'] .chrome,
html[data-idle='true'] .chrome {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s var(--ease), visibility 0s linear 0.9s;
}

.now {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: var(--gutter);
  margin: 0;
  text-shadow: 0 1px 18px rgb(0 0 0 / 0.35);
}

.now-scene {
  margin: 0;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.1;
}

.now-key {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.corner {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.3s var(--ease), color 0.3s var(--ease);
}

.icon-btn[aria-pressed='true'] {
  border-color: color-mix(in srgb, var(--glow) 70%, transparent);
  color: var(--glow);
}

.icon-btn[hidden] {
  display: none;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Dock: one rounded bar on wide screens, two rows on a phone. */
.dock {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  translate: -50% 0;
  width: min(880px, calc(100% - 2 * var(--gutter)));
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 12px 18px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

.play {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glow);
  color: var(--deep);
  transition: background-color 2s var(--ease), transform 0.2s var(--ease);
}

.play:active {
  transform: scale(0.95);
}

.play svg {
  width: 24px;
  height: 24px;
  stroke-width: 2;
}

.play .icon-play {
  fill: currentColor;
  stroke-width: 1.5;
}

.play .icon-play,
html[data-state='paused'] .play .icon-pause {
  display: none;
}

html[data-state='paused'] .play .icon-play {
  display: block;
}

.moods-wrap {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}

.moods {
  display: flex;
  gap: 6px;
}

.mood {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  transition: border-color 0.3s var(--ease);
}

.mood[aria-checked='true'] {
  border-color: var(--ink);
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--c3) 0%, var(--c2) 35%, var(--c1) 70%, var(--c0) 100%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.15);
  transition: transform 0.3s var(--ease);
}

.mood:hover .swatch {
  transform: scale(1.12);
}

.mood[data-mood='drift'] .swatch {
  background: conic-gradient(from 200deg, var(--drift));
}

.mood-caption {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.volume {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
}

.volume input {
  width: 130px;
  height: 28px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.volume input::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill, 75%), var(--line) var(--fill, 75%));
}

.volume input::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill, 75%), var(--line) var(--fill, 75%));
}

.volume input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6.5px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.volume input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.sleep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.3s var(--ease);
}

.sleep[data-active='true'] {
  color: var(--glow);
}

.sleep:hover {
  color: var(--ink);
}

@media (max-width: 720px) {
  .dock {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      'moods moods moods'
      'play volume sleep';
    gap: 12px 14px;
    padding: 14px 16px 12px;
    border-radius: 26px;
  }

  .moods-wrap {
    grid-area: moods;
  }

  .play {
    grid-area: play;
    width: 50px;
    height: 50px;
  }

  .volume {
    grid-area: volume;
    min-width: 0;
  }

  .volume input {
    width: 100%;
    min-width: 0;
  }

  .sleep {
    grid-area: sleep;
  }
}

@media (max-width: 400px) {
  .moods {
    gap: 2px;
  }

  .mood {
    width: 34px;
    height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark {
    animation: none;
  }

  .intro,
  .wordmark,
  .chrome {
    transition-duration: 0.01s;
  }
}
