:root {
  --serif: ui-serif, 'New York', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --warm: #f3c9a0;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: var(--sans);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Сцена и слайды ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; background: #000; }

.slide { position: absolute; inset: 0; overflow: hidden; background: #000; will-change: opacity, transform; }

.slide .bg {
  position: absolute; inset: -8%;
  width: 116%; height: 116%;
  object-fit: cover;
  filter: blur(28px) brightness(0.55) saturate(1.2);
  transform: scale(1.1);
}

.slide .fg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  will-change: transform;
  transform-origin: 50% 50%;
}
.slide.contain .fg { object-fit: contain; }
.slide:not(.contain) .bg { display: none; }

.slide video.fg { background: transparent; }

/* мягкая виньетка, чтобы кадр выглядел «киношно» */
.slide::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
}

/* ---------- Заголовок главы ---------- */
#chapter {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 0 28px calc(env(safe-area-inset-bottom) + 16vh);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent 55%);
  z-index: 5;
}
#chapter h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 10vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}
#chapter p {
  margin: 12px 0 0;
  font-size: clamp(14px, 4vw, 20px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--warm);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

/* ---------- Панель управления (по касанию) ---------- */
#hud {
  position: fixed; inset: 0;
  z-index: 10;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px calc(env(safe-area-inset-bottom) + 22px);
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 22%, transparent 70%, rgba(0, 0, 0, 0.55));
  transition: opacity 0.35s ease;
}
#hud.fade { opacity: 0; }
#hud[hidden] { display: none; }

#hud-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

#hud-mid { display: flex; align-items: center; justify-content: center; gap: 28px; }
#hud-bottom { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#btn-style[hidden] { display: none; }
#hud-hint { margin: 0; text-align: center; font-size: 14px; color: rgba(255, 255, 255, 0.7); }

.pill {
  border: 0; border-radius: 999px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}

.round {
  width: 64px; height: 64px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  display: grid; place-items: center;
}
.round.big { width: 88px; height: 88px; background: rgba(255, 255, 255, 0.26); }
.round svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.round.big svg { width: 38px; height: 38px; fill: #fff; stroke: none; }
.pill svg { width: 20px; height: 20px; fill: #fff; }

/* ---------- Главная: список альбомов ---------- */
#home {
  position: fixed; inset: 0; z-index: 20;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 40px) 18px calc(env(safe-area-inset-bottom) + 30px);
  background:
    radial-gradient(120% 60% at 20% 0%, rgba(246, 176, 122, 0.3), transparent 60%),
    radial-gradient(120% 60% at 90% 100%, rgba(184, 69, 107, 0.4), transparent 60%),
    #120c10;
  transition: opacity 0.7s ease;
}
#home.gone { opacity: 0; pointer-events: none; }
.home-head { text-align: center; margin: 0 auto 26px; max-width: 520px; }
.heart {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: url('/icons/icon-512.png') center / cover;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(184, 69, 107, 0.5);
}
#home h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(34px, 10vw, 52px); line-height: 1.05; }
#home-sub { margin: 10px 0 0; color: rgba(255, 255, 255, 0.7); font-size: 17px; min-height: 1.4em; }
#home-note { max-width: 520px; margin: 26px auto 0; text-align: center; font-size: 14px; line-height: 1.45; color: rgba(255, 255, 255, 0.55); }

#album-list { display: grid; gap: 16px; max-width: 560px; margin: 0 auto; }
.album-card {
  position: relative; display: block; width: 100%;
  aspect-ratio: 4 / 3;
  border: 0; border-radius: 22px; overflow: hidden; padding: 0;
  background: linear-gradient(135deg, #3a2430, #24161d);
  text-align: left;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, opacity 0.3s ease;
}
.album-card:active { transform: scale(0.98); }
.album-card:disabled { cursor: default; }
.album-card:focus-visible { outline: 3px solid #f3a6a0; outline-offset: 3px; }
.cover-box { position: absolute; inset: 0; }
.cover { width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.06); transition: opacity 0.8s ease, transform 6s ease-out; }
.cover.in { opacity: 1; transform: scale(1); }
.card-text {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 50px 84px 18px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
}
.card-title { font-family: var(--serif); font-size: clamp(24px, 7vw, 32px); line-height: 1.1; color: #fff; }
.card-info { font-size: 15px; color: rgba(255, 255, 255, 0.8); }
.card-info b { color: var(--warm); font-weight: 600; }
.card-play {
  position: absolute; right: 18px; bottom: 18px;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #ffe2c4, #f3a6a0);
  color: #2a1218;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.card-play svg { width: 22px; height: 22px; fill: currentColor; margin-left: 3px; }
.album-card:disabled .card-play { opacity: 0.35; }

#hud-date { font-family: var(--serif); font-size: 18px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.pill svg { width: 20px; height: 20px; }

/* ---------- Загрузка ---------- */
#loading {
  position: fixed; inset: 0; z-index: 2;
  background: #120c10;
  display: grid; place-items: center;
  transition: opacity 0.8s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.loading-bg {
  position: absolute; inset: -10%; width: 120%; height: 120%;
  object-fit: cover;
  filter: blur(36px) brightness(0.45) saturate(1.2);
}
.loading-title {
  position: absolute; left: 24px; right: 24px; top: calc(50% + 52px);
  margin: 0; text-align: center;
  font-family: var(--serif); font-size: clamp(24px, 7vw, 34px);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

#spinner {
  position: fixed; left: 50%; top: 50%; z-index: 4;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
#spinner.on { opacity: 1; transform: scale(1); }
#spinner span {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #ffe2c4;
  border-right-color: #f3a6a0;
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .slide .fg { will-change: auto; }
}
