:root {
  --screen: #000000;
  --ink: #f2f2f0;
  --ink-dim: #8e8e8a;
  --credit-font: 'EB Garamond', Garamond, 'Times New Roman', serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--screen);
  color: var(--ink);
  font-family: var(--credit-font);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

/* ---------- opening fade-in from black ---------- */

body.fading-in .back-link,
body.fading-in .progress,
body.fading-in .controls {
  opacity: 0;
  transition: opacity 2s ease;
}

body.fading-in.faded-in .back-link,
body.fading-in.faded-in .progress,
body.fading-in.faded-in .controls {
  opacity: 1;
}

/* ---------- clickable progress bar ---------- */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 14px; /* generous hit area; the visible bar is the thin fill */
  cursor: pointer;
  outline: none;
}

.progress::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(242, 242, 240, 0.15);
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left center;
}

.progress:hover::before,
.progress:hover .progress-fill {
  height: 5px;
}

.progress:focus-visible::before {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- one card per frame ---------- */

.credits-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.credits-reel {
  position: absolute;
  inset: 0;
}

/* every card (title, each credit, final) is stacked full-screen; only the
   active one is visible */
.title-card,
.final-card,
.credits-list li {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.title-card.active,
.final-card.active,
.credits-list li.active {
  opacity: 1;
}

.title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(22px, 2.6vw, 34px);
  letter-spacing: 0.02em;
}

.roll-button,
.control-button {
  font-family: inherit;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(242, 242, 240, 0.4);
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.3s ease, opacity 0.6s ease;
}

.roll-button:hover,
.control-button:hover,
.roll-button:focus-visible,
.control-button:focus-visible {
  border-color: var(--ink);
  outline: none;
}

body.rolling .roll-button {
  opacity: 0;
  pointer-events: none;
}

.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.credits-list li {
  gap: 14px;
}

.credits-list li > * {
  max-width: 760px;
}

.credit-name {
  margin: 0;
  font-weight: 400;
  font-size: clamp(20px, 1.9vw, 26px);
  font-variant-caps: small-caps;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-wrap: balance;
}

.credit-for {
  margin: 0;
  max-width: 560px;
  font-weight: 400;
  font-size: clamp(16px, 1.3vw, 19px);
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
  text-wrap: balance;
}

/* several names: shared reason on the left, one name per row on the right */
.credits-list li.credit-group {
  flex-direction: row;
  align-items: center;
  gap: 40px;
}

.credits-list li.credit-group > * {
  flex: 1 1 0;
  max-width: 380px;
}

.credit-group .credit-for {
  text-align: right;
}

.credit-names {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.credit-names .credit-name {
  display: block;
}

.credit-group.many .credit-name {
  font-size: clamp(17px, 1.5vw, 21px);
  line-height: 1.3;
}

.final-text {
  margin: 0;
  font-weight: 400;
  font-size: clamp(20px, 2.2vw, 28px);
  letter-spacing: 0.02em;
}

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

.back-link {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 10;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.3s ease;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
}

.controls {
  position: fixed;
  left: 28px;
  bottom: 28px;
  z-index: 10;
  display: flex;
  gap: 12px;
}

.control-button[hidden] {
  display: none;
}

.player {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  width: 240px;
  aspect-ratio: 16 / 9;
  opacity: 0.55;
  transition: opacity 0.3s ease;
  }

.player:hover,
.player:focus-within {
  opacity: 1;
}

  .player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  .player {
  right: 16px;
  bottom: 16px;
  width: 200px;
  }
  
  .controls {
  left: 16px;
  bottom: 140px;
  }

  .credits-list li.credit-group {
    gap: 20px;
    padding: 0 16px;
  }
}

/* ---------- reduced motion: a still, scrollable list ---------- */

@media (prefers-reduced-motion: reduce) {
  body {
    overflow: auto;
  }

  .credits-viewport,
  .credits-reel {
    position: static;
    overflow: visible;
  }

  .credits-reel {
    padding: 96px 0 160px;
  }

  .title-card,
  .final-card,
  .credits-list li {
    position: static;
    opacity: 1;
    transition: none;
    padding: 44px 24px;
  }

  .roll-button {
    display: none;
  }
}
