/* Base */
:root {
  --ink: #000;   /* black */
  --paper: #fff; /* white */
}
* { box-sizing: border-box; }
/* Our id selectors set display:flex, which would otherwise beat the UA
   [hidden]{display:none} rule on specificity. Restore hidden semantics. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Open Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
    "Helvetica Neue", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

/* --- Login shell --- */
#login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}
#login h1 { font-weight: 700; letter-spacing: 0.02em; }
#unlock-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
#password {
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  text-align: center;
  background: var(--paper);
  color: var(--ink);
}
#unlock-form button {
  padding: 0.55rem 1.4rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}
#unlock-form button:hover { opacity: 0.85; }
#error { color: #c0392b; margin: 0; }

/* --- Device gate: laptop-only message --- */
#device-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  z-index: 1000;
  text-align: center;
  padding: 2rem;
}
.gate-card { max-width: 22rem; }

/* --- Slide engine --- */
#app { min-height: 100vh; }
.stage {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  /* keep slide content clear of the fixed nav bar at the bottom */
  padding-bottom: 4.5rem;
}
.slide {
  width: 100%;
  max-width: 60rem;
  padding: 2rem;
  margin: 0 auto;
  text-align: center;
}
.nav {
  position: fixed;
  bottom: 1rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 1rem;
  z-index: 20; /* above the DVD bouncer */
}
.nav button {
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.nav button:disabled { opacity: 0.35; cursor: not-allowed; }

/* --- Task 5: birthday hero slide (2000s WordArt vibe) --- */
.slide-hero .hero-text {
  position: relative;
  z-index: 2; /* above the balloons drifting behind it */
  font-size: clamp(2.5rem, 9vw, 6rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.1;
  margin: 0 0 2rem;
  /* chunky retro text shadow */
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
}
.slide-hero .hero-char {
  display: inline-block;
  /* rainbow bounce, staggered per letter via inline animation-delay */
  animation: hero-bounce 1.2s ease-in-out infinite alternate,
    hero-rainbow 6s linear infinite;
}
@keyframes hero-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-0.18em); }
}
@keyframes hero-rainbow {
  0%   { color: #e53935; }
  20%  { color: #fb8c00; }
  40%  { color: #fdd835; }
  60%  { color: #43a047; }
  80%  { color: #1e88e5; }
  100% { color: #8e24aa; }
}
/* the cycling name — keep it on its own line so length changes don't reflow */
.slide-hero .hero-name {
  display: inline-block;
  white-space: nowrap;
}
/* Collage: media slots pinned around the hero. The hero fills the viewport so
   the `%` positions spread across the whole page; the text stays centered.
   Photos sit still (slight tilt); gifs wobble. */
.slide-hero {
  position: relative;
  max-width: none;
  width: 100%;
  min-height: calc(100vh - 5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hero-slot {
  position: absolute;
  border: 2px dashed rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.02);
  z-index: 1;
}
.hero-slot img {
  /* fill the slot instead of letterboxing inside it — at this size the empty
     bars around a portrait photo were more visible than the photo */
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.5);
}
/* four corner slots now, so they can afford to be big */
.hero-photo { width: 14rem; height: 14rem; }
.hero-gif { width: 13rem; height: 13rem; }
.hero-gif { animation: hero-spin 8s ease-in-out infinite alternate; }
@keyframes hero-spin {
  from { transform: rotate(-3deg); }
  to { transform: rotate(3deg); }
}
/* scatter positions — corners for photos, edges for gifs */
.pos-tl { top: 4%;  left: 3%;  transform: rotate(-6deg); }
.pos-tr { top: 5%;  right: 3%; transform: rotate(5deg); }
.pos-bl { bottom: 7%; left: 4%;  transform: rotate(4deg); }
.pos-br { bottom: 7%; right: 4%; transform: rotate(-5deg); }
.pos-ml { top: 42%; left: 1%; }
.pos-mr { top: 44%; right: 1%; }
.pos-tc { top: 2%; left: calc(50% - 4rem); }

/* --- Task 19: hero balloons ---
   Two nested animations so they do not fight over `transform`: the outer lane
   rises, the inner body sways. Both are CSS, so the compositor owns them and
   no JS runs while she sits on this slide. */
.hero-balloon {
  position: absolute;
  bottom: -30vh;
  z-index: 0; /* behind the collage slots (1) and the hero text (2) */
  pointer-events: none;
  animation-name: balloon-rise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.hero-balloon-body {
  position: relative;
  aspect-ratio: 5 / 6;
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  opacity: 0.5;
  animation-name: balloon-sway;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}
/* the string */
.hero-balloon-body::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 2.2rem;
  background: rgba(0, 0, 0, 0.25);
}
@keyframes balloon-rise {
  from { transform: translateY(0); }
  to { transform: translateY(-135vh); }
}
@keyframes balloon-sway {
  from { transform: translateX(-1.1rem) rotate(-5deg); }
  to { transform: translateX(1.1rem) rotate(5deg); }
}

/* DVD-logo bouncer: full-viewport drift, JS drives transform. Fixed so it
   floats over the whole page; pointer-transparent so nav stays clickable. */
.hero-dvd {
  /* smaller than the corner slots: it crosses the whole screen */
  width: 9rem;
  height: 9rem;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
  animation: none; /* JS owns the transform; no wobble */
}

/* --- Task 9: instructions slide --- */
.slide-instructions .instructions-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 1.5rem;
}
.instructions-steps {
  list-style: decimal;
  margin: 0 auto;
  padding: 0 0 0 1.5rem;
  max-width: 32rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.instructions-step {
  font-size: 1.05rem;
  line-height: 1.5;
}

/* --- Task 6: quiz slides --- */
.slide-quiz .quiz-prompt {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 2rem;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 32rem;
  margin: 0 auto;
}
.quiz-option {
  padding: 0.8rem 1rem;
  font-size: 1.05rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.quiz-option:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
/* wrong pick: grayed out + not clickable, others stay live */
.quiz-option.wrong {
  opacity: 0.4;
  background: #ddd;
  color: #888;
  border-color: #bbb;
  cursor: not-allowed;
  text-decoration: line-through;
}
.quiz-option.correct {
  background: #43a047;
  color: #fff;
  border-color: #2e7d32;
}
.quiz-option:disabled { cursor: not-allowed; }

/* Optional per-question image. Only rendered when the question sets `image`,
   so the slide keeps its usual layout when it is omitted. */
.quiz-image {
  max-width: 32rem;
  margin: 0 auto 1.5rem;
}
.quiz-image img {
  display: block;
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
}

/* Optional small note under the options. */
.quiz-footnote {
  max-width: 32rem;
  margin: 1.25rem auto 0;
  font-size: 0.85rem;
  line-height: 1.4;
  opacity: 0.7;
  font-style: italic;
}

/* --- Task 10: interlude slide (breather between questions) ---
   Text column plus a row of media slots styled like the hero collage: dashed
   placeholders that show alt text until the user drops files in public/assets/. */
.slide-interlude .interlude-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 1.5rem;
}
.interlude-text {
  max-width: 36rem;
  margin: 0 auto;
}
.interlude-line {
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 0.9rem;
}
.interlude-gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1.75rem auto 0;
  max-width: 44rem;
}
.interlude-slot {
  width: 11rem;
  height: 11rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px dashed rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
}
/* alternate tilt so the row reads like the hero collage, not a grid */
.interlude-slot:nth-child(odd) { transform: rotate(-3deg); }
.interlude-slot:nth-child(even) { transform: rotate(3deg); }
.interlude-slot img {
  max-width: 100%;
  max-height: 100%;
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.5);
  padding: 0.25rem;
}

/* --- Task 7 + 12: playlist "present" slide ---
   Two playlists as columns (auto-fit so a narrow window stacks them without a
   dedicated breakpoint), each with cover art, a name and its own track list.
   Every song carries its own youtube / yandex links. */
.slide-playlist .playlist-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  /* clear of the intro: a gap under the line-height reads as one text block */
  margin: 0 0 1.5rem;
}
.playlist-intro {
  max-width: 34rem;
  margin: 0 auto 1rem;
  font-size: 1rem;
  line-height: 1.55;
  opacity: 0.8;
}
.playlist-intro:last-of-type { margin-bottom: 0; }
/* short centered divider — the space around it is the point, the line just
   marks where the explaining stops and the present starts */
.playlist-rule {
  width: 5rem;
  height: 0;
  margin: 2.25rem auto 2.5rem;
  border: 0;
  border-top: 2px solid var(--ink);
  opacity: 0.25;
}
.playlist-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 2rem;
  align-items: start;
  max-width: 46rem;
  margin: 0 auto;
}
.playlist-cover {
  width: 12rem;
  height: 12rem;
  margin: 0 auto 0.9rem;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
}
.playlist-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.5);
  padding: 0.25rem;
}
.playlist-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
}
.playlist {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.playlist-column {
  display: flex;
  flex-direction: column;
}
.playlist-column .playlist { max-width: none; }
/* every row is a copy button — song name over artist */
.playlist-track { display: flex; }
.playlist-track-row {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.7rem 2.2rem; /* room for the copied badge without shifting the text */
  font: inherit;
  text-align: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.playlist-track-title {
  font-size: 1.02rem;
  line-height: 1.3;
}
.playlist-track-artist {
  font-size: 0.82rem;
  line-height: 1.25;
  color: #6b6b6b;
  transition: color 0.15s;
}
.playlist-track-row:hover { background: var(--ink); color: var(--paper); }
/* gray on white would vanish on the inverted background */
.playlist-track-row:hover .playlist-track-artist { color: rgba(255, 255, 255, 0.7); }
/* confirmation sits in the padding, so nothing moves when it appears */
.playlist-track-row.is-copied { background: var(--ink); color: var(--paper); }
.playlist-track-row.is-copied .playlist-track-artist { color: rgba(255, 255, 255, 0.7); }
.playlist-track-row.is-copied::after {
  content: "copied!";
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}
.playlist-copy {
  margin: 0 auto 1rem;
  padding: 0.45rem 1.1rem;
  font: inherit;
  font-size: 0.9rem;
  border: 2px dashed var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.playlist-copy:hover { background: var(--ink); color: var(--paper); }



/* --- Task 14: confetti canvas ---
   Over everything except the lightbox, and click-through so the nav underneath
   stays usable while it falls. */
.confetti {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  pointer-events: none;
}

/* --- Task 11: image lightbox ---
   Full-viewport overlay above the nav (z-index 20) and the DVD bouncer.
   `hidden` wins over display:flex thanks to the global [hidden] rule up top. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
  animation: fade-in 0.18s ease-out both;
}
.lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
/* only slots whose image actually loaded get the affordance */
.expandable { cursor: zoom-in; }
.expandable:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* CSS backup for the JS gate: hide login on phone-sized screens.
   Keep the 768px breakpoint in sync with MOBILE_MAX in app.js. */
@media (max-width: 768px) {
  #login, #app { display: none !important; }
}

/* --- Task 8: slide transitions ---
   The engine toggles the `hidden` attribute, so a slide goes display:none ->
   visible; the keyframes replay each time it is shown. The hero is fade-only:
   a transform on it would make its position:fixed DVD bouncer relative to the
   slide instead of the viewport. */
.slide:not([hidden]) {
  animation: slide-in 0.35s ease-out both;
}
.slide-instructions:not([hidden]),
.slide-interlude:not([hidden]),
.slide-quiz:not([hidden]),
.slide-playlist:not([hidden]) {
  animation: slide-in-up 0.35s ease-out both;
}
@keyframes slide-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide-in-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
/* body background changes per slide — ease it instead of snapping */
body { transition: background-color 0.35s ease; }

/* --- Task 8: responsive ---
   The device gate blocks <= 768px, so these breakpoints cover tablets and
   small laptops: shrink the collage so it never crowds the hero text, and let
   the slide use more of the width. */
@media (max-width: 1024px) {
  .slide { padding: 1.5rem 1rem; }
  .hero-photo { width: 10rem; height: 10rem; }
  .hero-gif { width: 9rem; height: 9rem; }
  .hero-dvd { width: 7rem; height: 7rem; }
  .slide-hero .hero-text { font-size: clamp(2rem, 8vw, 4rem); }
  /* the 32rem cap already shrinks on its own — just tighten the spacing */
  .slide-instructions .instructions-title { margin-bottom: 1.25rem; }
  .slide-interlude .interlude-title { margin-bottom: 1.25rem; }
  .interlude-slot { width: 8.5rem; height: 8.5rem; }
  .interlude-gallery { gap: 0.75rem; margin-top: 1.25rem; }
  .slide-quiz .quiz-prompt { margin-bottom: 1.25rem; }
  .quiz-image { margin-bottom: 1rem; }
  .quiz-image img { max-height: 32vh; }
  .slide-playlist .playlist-title { margin-bottom: 1rem; }
  .playlist-columns { gap: 1.25rem; }
  .playlist-cover { width: 9rem; height: 9rem; }
  .pos-tc { left: calc(50% - 3rem); }
}
/* short windows: the collage has no vertical room, so drop the mid-edge slots */
@media (max-height: 620px) {
  .pos-ml, .pos-mr { display: none; }
  .slide-hero { min-height: calc(100vh - 4rem); }
  /* the present slide is the tallest one — keep its copy button reachable */
  .playlist-cover { width: 8rem; height: 8rem; margin-bottom: 0.6rem; }
  .slide-playlist .playlist-title { margin-bottom: 0.9rem; }
  .playlist-intro { margin-bottom: 0.55rem; }
  .playlist-rule { margin: 1.1rem auto 1.25rem; }
}

/* Motion is decoration — honor the OS setting and cut it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* the rule above only freezes them, which would park seven balloons in a row
     across the hero — drop them instead */
  .hero-balloon { display: none; }
}
