:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --fg: #f5f1ea;
  --muted: rgba(245, 241, 234, 0.7);
  --glass: rgba(0, 0, 0, 0.45);
  /* How long each photo stays up, and how long the crossfade takes. */
  --slide-time: 6s;
  --fade: 1.2s;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-serif, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: none;
}

.stage.is-active,
.stage.is-empty {
  cursor: default;
}

/* ---- Slides ---------------------------------------------------------------- */

.slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: opacity var(--fade) ease;
  /* Own GPU layer: the blurred backdrop is drawn once, and the fade only changes opacity. */
  will-change: opacity;
}

.slide.in {
  opacity: 1;
}

/* The same photo, blurred, fills the space around portrait or odd-shaped shots. */
.backdrop {
  position: absolute;
  inset: -5%;
  width: 110%;
  height: 110%;
  object-fit: cover;
  filter: blur(40px) brightness(0.5) saturate(1.2);
}

.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---- Title ----------------------------------------------------------------- */

.title {
  position: absolute;
  inset: 0 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 56px
    max(24px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
  pointer-events: none;
}

h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: 0.03em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}

/* ---- Controls -------------------------------------------------------------- */

.controls {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stage.is-active .controls,
.controls:focus-within {
  opacity: 1;
}

.is-empty .controls,
.is-single .controls {
  display: none;
}

button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glass);
  color: var(--fg);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background 0.2s ease;
}

button:hover {
  background: rgba(0, 0, 0, 0.65);
}

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

button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-play,
.is-paused .icon-pause {
  display: none;
}

.is-paused .icon-play {
  display: block;
}

/* ---- Progress bar (also the slideshow's timer; see slideshow.js) ----------- */

.progress {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
}

.progress span {
  display: block;
  height: 100%;
  background: var(--fg);
  opacity: 0.7;
  transform: scaleX(0);
  transform-origin: left;
}

.progress span.run {
  animation: fill var(--slide-time) linear forwards;
}

.is-paused .progress span.run {
  animation-play-state: paused;
}

.is-empty .progress {
  display: none;
}

@keyframes fill {
  to {
    transform: scaleX(1);
  }
}

/* ---- Empty state and 404 --------------------------------------------------- */

.empty,
.not-found {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

.empty[hidden] {
  display: none;
}

.not-found h1 {
  color: var(--fg);
}

.not-found a {
  color: var(--fg);
}

@media (prefers-reduced-motion: reduce) {
  .slide {
    transition-duration: 0.2s;
  }
}
