:root {
  --amber: #e8a462;
  --amber-warm: #ff9d4d;
  --cream: #fbe9d2;
  --ink: #1a1108;
  --glass: rgba(30, 18, 10, 0.55);
  --glass-border: rgba(255, 210, 160, 0.18);
}

* { box-sizing: border-box; }

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

body {
  font-family: "Poppins", sans-serif;
  color: var(--cream);
  background: #1a0f08;
  position: relative;
  width: 100vw;
  height: 100vh;
  /* iOS Safari's address bar makes 100vh taller than what's actually
     visible, which was pushing the player off-screen — dvh tracks the
     real visible viewport instead. */
  height: 100dvh;
}

/* ---------- background ---------- */

.bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(90% 60% at 50% 0%, rgba(40, 20, 8, 0.4) 0%, rgba(40, 20, 8, 0) 40%),
    url("assets/bg.jpg");
  background-size: cover;
  background-position: center 38%;
  background-repeat: no-repeat;
  filter: saturate(1.05) contrast(1.02);
  transition: filter 0.7s ease;
}

body.dim-mode .bg {
  filter: saturate(0.8) contrast(1.08) brightness(0.5);
}

/* Warm placeholder scene until assets/bg.jpg is dropped in — evokes a
   lamp-lit room in reds/ambers so the page still looks intentional. */
.bg.no-photo {
  background-image:
    radial-gradient(60% 45% at 50% 4%, rgba(255, 205, 140, 0.55) 0%, rgba(255, 205, 140, 0) 60%),
    radial-gradient(140% 100% at 50% 100%, #2a1508 0%, #150a05 60%),
    linear-gradient(160deg, #3a1f10 0%, #1c0f08 55%, #120a06 100%);
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(5,2,1,0.75) 0%, rgba(5,2,1,0) 26%),
    linear-gradient(to bottom, rgba(5,2,1,0.55) 0%, rgba(5,2,1,0) 22%),
    radial-gradient(140% 90% at 50% 50%, rgba(0,0,0,0) 55%, rgba(5,2,1,0.4) 100%);
  pointer-events: none;
  transition: opacity 0.7s ease;
}

body.dim-mode .vignette { opacity: 1.4; }

/* ---------- fairy lights & candle bloom ---------- */

.lights {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.light-dot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: radial-gradient(circle, rgba(255,230,170,0.95) 0%, rgba(255,190,110,0.55) 45%, rgba(255,180,90,0) 75%);
  box-shadow: 0 0 7px 2px rgba(255, 200, 120, 0.35);
  opacity: 0.55;
  animation: twinkle 3.6s ease-in-out infinite;
  animation-delay: var(--d, 0s);
  animation-play-state: paused;
}

.light-dot.candle {
  width: 13px;
  height: 13px;
  box-shadow: 0 0 12px 4px rgba(255, 190, 110, 0.4);
}

body.is-playing .light-dot {
  animation-play-state: running;
}

body.dim-mode .light-dot {
  box-shadow: 0 0 12px 5px rgba(255, 200, 120, 0.55);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.85); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- top chrome ---------- */

.top-left {
  position: absolute;
  top: 18px;
  left: 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 5;
}

.clock {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(251, 233, 210, 0.75);
  font-weight: 400;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: rgba(251, 233, 210, 0.75);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  transition: opacity 0.4s ease;
}
.online-badge.hidden {
  opacity: 0;
  pointer-events: none;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fdc8c;
  box-shadow: 0 0 6px 1px rgba(111, 220, 140, 0.7);
  animation: online-pulse 2.2s ease-in-out infinite;
}

@keyframes online-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.top-right {
  position: absolute;
  top: 18px;
  right: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
}

.corner-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  background: none;
  border: none;
  color: var(--cream);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 5px rgba(0,0,0,0.55);
  opacity: 0.92;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.corner-link:hover { opacity: 1; transform: translateY(-1px); }
.corner-link .ext { opacity: 0.6; }

.mode-toggle {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #ffd699;
  cursor: pointer;
  filter: drop-shadow(0 1px 5px rgba(0,0,0,0.55));
  opacity: 0.92;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.3s ease;
}
.mode-toggle:hover { opacity: 1; transform: translateY(-1px); }
.mode-toggle:active { transform: translateY(-1px) scale(0.94); }

body.dim-mode .mode-toggle { color: #b9c3e0; }

/* ---------- hero title ---------- */

.hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  z-index: 3;
  pointer-events: none;
  padding-top: clamp(28px, 6vh, 68px);
}

.title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.title-hi {
  font-family: "Martel", "Poppins", serif;
  font-weight: 900;
  font-size: clamp(56px, 11vw, 128px);
  line-height: 1;
  color: #fff6ea;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 18px 60px rgba(255, 150, 60, 0.25);
  letter-spacing: 0.01em;
}


/* ---------- player ---------- */

.player {
  position: absolute;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px 14px 14px;
  border-radius: 30px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  box-shadow: 0 20px 50px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
  width: min(600px, 92vw);
  opacity: 0;
  transform: translateX(-50%) translateY(14px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.player.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.player-art {
  width: 60px;
  height: 60px;
  flex: none;
  border-radius: 16px;
  overflow: hidden;
  background: #3a2513;
  position: relative;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.player-art img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: transparent;
  opacity: 0;
  transition: opacity 0.35s ease;
  /* YouTube auto-generated thumbnails often bake in black letterbox bars
     around the actual art — zoom past them so the square reads clean. */
  transform: scale(1.32);
}

.art-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(circle at 50% 50%, #5a3419 0%, #2a1608 70%);
}


.player-body {
  flex: 1;
  min-width: 0;
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 6px;
}

.track-title {
  font-size: 14.5px;
  font-weight: 600;
  color: #fff8ee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 12px;
  font-weight: 300;
  color: rgba(251, 233, 210, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.player-progress {
  margin-top: 9px;
}

.progress-track {
  position: relative;
  height: 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.progress-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
}

.progress-fill {
  position: absolute;
  left: 0;
  height: 3px;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #ffb066, #ff8a3d);
}

.progress-knob {
  position: absolute;
  left: 0%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff3e4;
  box-shadow: 0 0 0 2px rgba(255, 138, 61, 0.5);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.progress-track:hover .progress-knob { opacity: 1; }

.player-time {
  margin-top: 5px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: rgba(251, 233, 210, 0.5);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.ctrl-btn {
  border: none;
  background: transparent;
  color: rgba(251, 233, 210, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.ctrl-btn:hover { color: #fff; background: rgba(255,255,255,0.08); }
.ctrl-btn:active { transform: scale(0.92); }

.ctrl-btn.play {
  width: 42px;
  height: 42px;
  background: #fff8ee;
  color: #241407;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.ctrl-btn.play:hover { background: #fff; color: #241407; }
.ctrl-btn.play svg { position: relative; left: 1px; }
#iconPause { left: 0; }

.yt-host {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  bottom: 0;
  left: 0;
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .player {
    /* Sit higher than the very bottom edge — clearer of the home
       indicator and easier to reach than hugging the screen edge. */
    bottom: calc(12vh + env(safe-area-inset-bottom));
    padding: 8px 14px 8px 8px;
    gap: 10px;
  }
  .track-artist { display: none; }
  .corner-link span { display: none; }
}
