:root {
  --fade: 1400ms;
  --kenburns: 28000ms;
  --drift: 22000ms;
  --ink: #fff;
  --ink-dim: rgba(255, 255, 255, 0.72);
  --ink-faint: rgba(255, 255, 255, 0.48);
  --shadow: 0 2px 24px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: "Hanken Grotesk", "Hanken Grotesk Variable", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage[hidden] { display: none; }

/* ── pre-start (iframe of umakers.dk) ───────────────────── */
#prestart {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  opacity: 1;
  transition: opacity 600ms ease, visibility 600ms ease;
}

#prestart.dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#prestart-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#prestart-start {
  position: absolute;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 26px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 250ms ease, transform 200ms ease, background 200ms ease, visibility 250ms ease;
}

#prestart.show-start #prestart-start {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#prestart-start:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: translateX(-50%) translateY(-2px);
}

.start-label { font-size: 15px; }
.start-hint {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.6;
  font-weight: 500;
}

/* ── slide stack ─────────────────────────────────────────── */
#slides {
  position: absolute;
  inset: 0;
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 700ms ease;
}

.slide.active {
  opacity: 1;
  visibility: visible;
}

.image-stack {
  position: absolute;
  inset: 0;
  background: #000;
}

.image-frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) ease;
  will-change: opacity;
}

.image-frame.current {
  opacity: 1;
  pointer-events: auto;
}

.image-frame img.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: transform;
  transform-origin: center center;
}

/* ken burns only on the visible image of the active slide */
.slide.active .image-frame.current img.bg {
  animation: kenburns var(--kenburns) ease-in-out both;
}

/* ── thumbnails (per image overlay) ──────────────────────── */
.thumbs {
  position: absolute;
  top: 11vh;
  right: 6vw;
  display: grid;
  gap: clamp(10px, 1.2vw, 20px);
  align-content: start;
  justify-items: stretch;
  pointer-events: none;
  z-index: 2;
}

.slide.active .image-frame.current .thumbs {
  pointer-events: auto;
}

.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  padding: 0;
  background: #fff;
  border: clamp(4px, 0.45vw, 7px) solid #fff;
  border-radius: 3px;
  font: inherit;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45),
              0 3px 8px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(28px) scale(0.85) rotate(var(--r, 0deg));
  transform-origin: center center;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 700ms ease,
              transform 800ms cubic-bezier(0.2, 0.85, 0.4, 1.05),
              box-shadow 280ms ease;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* formations */
.thumbs-1 {
  grid-template-columns: 1fr;
  width: clamp(240px, 28vw, 380px);
}

.thumbs-2 {
  grid-template-columns: 1fr;
  width: clamp(220px, 24vw, 340px);
}

.thumbs-3 {
  grid-template-columns: 1fr 1fr;
  width: clamp(320px, 34vw, 480px);
}
.thumbs-3 .thumb:nth-child(1) { grid-column: 1 / -1; }

.thumbs-4 {
  grid-template-columns: 1fr 1fr;
  width: clamp(300px, 30vw, 440px);
}

.thumbs-5,
.thumbs-6 {
  grid-template-columns: repeat(6, 1fr);
  width: clamp(420px, 38vw, 620px);
}

.thumbs-5 .thumb,
.thumbs-6 .thumb { grid-column: span 2; }

.thumbs-5 .thumb:nth-child(4) { grid-column: 2 / span 2; }
.thumbs-5 .thumb:nth-child(5) { grid-column: 4 / span 2; }

.slide.active .image-frame.current .thumb {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(var(--r, 0deg));
  pointer-events: auto;
  transition: opacity 700ms ease,
              transform 260ms cubic-bezier(0.2, 0.85, 0.4, 1.05),
              box-shadow 260ms ease;
}

/* clicked: scale up, straighten, lift forward */
.slide.active .image-frame.current .thumb.expanded {
  transform: translate3d(var(--tx, 0), var(--ty, 0), 0) scale(var(--s, 2.05)) rotate(0deg) !important;
  z-index: 5;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.6),
              0 6px 14px rgba(0, 0, 0, 0.6);
  transition: transform 260ms cubic-bezier(0.2, 0.85, 0.4, 1.05),
              box-shadow 260ms ease;
  transition-delay: 0ms;
}

/* clear stagger on exit so thumbs leave together */
.image-frame:not(.current) .thumb {
  transition-delay: 0ms;
}

/* polaroid-ish rotations per slot */
.thumb:nth-child(1) { --r: -3deg; }
.thumb:nth-child(2) { --r:  2.5deg; }
.thumb:nth-child(3) { --r: -2deg; }
.thumb:nth-child(4) { --r:  3deg; }
.thumb:nth-child(5) { --r: -1.5deg; }
.thumb:nth-child(6) { --r:  1.8deg; }

@keyframes kenburns {
  0%   { transform: scale(1.02) translate3d(0, 0, 0); }
  50%  { transform: scale(1.07) translate3d(-1.2%, -0.8%, 0); }
  100% { transform: scale(1.10) translate3d(0.8%, 1.0%, 0); }
}

/* subtle vignette + bottom gradient so caption is always legible */
#stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%),
    linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.25) 25%, rgba(0,0,0,0) 45%);
  z-index: 1;
}

/* ── caption (lower-left) ────────────────────────────────── */
#caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 25vh;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  padding: 0 6vw 5vh 6vw;
  pointer-events: none;
  z-index: 2;
}

.caption-inner {
  max-width: min(900px, 70vw);
  text-shadow: var(--shadow);
  animation: drift var(--drift) ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes drift {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(6px, -4px, 0); }
  100% { transform: translate3d(-4px, 3px, 0); }
}

.section {
  font-size: clamp(11px, 1vw, 14px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 0.9em;
  font-weight: 500;
}

#title {
  font-size: clamp(36px, 6.5vw, 96px);
  line-height: 1.02;
  margin: 0 0 0.35em;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#paragraph {
  font-size: clamp(15px, 1.5vw, 22px);
  line-height: 1.45;
  margin: 0;
  color: var(--ink-dim);
  max-width: 60ch;
  font-weight: 400;
}

/* fade caption text on change */
.caption-inner.swap-out { opacity: 0; transform: translateY(8px); transition: opacity 350ms ease, transform 350ms ease; }
.caption-inner.swap-in  { opacity: 1; transform: translateY(0); transition: opacity 600ms ease 100ms, transform 600ms ease 100ms; }

/* ── next-slide hint (bottom right, very small) ──────────── */
#next-hint {
  position: absolute;
  right: 2.4vw;
  bottom: 2.4vh;
  z-index: 3;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  transition: opacity 300ms ease, color 200ms ease;
  padding: 6px 8px;
  border-radius: 4px;
}

#next-hint:hover { color: var(--ink); }
#next-hint:hover .next-title { color: var(--ink); }

#next-hint.hidden { opacity: 0; pointer-events: none; }

.next-label { font-weight: 500; opacity: 0.7; }
.next-title { color: var(--ink-dim); font-weight: 600; }

/* ── image counter (top-right, very subtle) ────────────────── */
#img-counter {
  position: absolute;
  top: 2.4vh;
  right: 2.4vw;
  z-index: 2;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.28);
  pointer-events: none;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
}

/* ── progress + dots ─────────────────────────────────────── */
#progress {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: rgba(255,255,255,0.08);
  z-index: 3;
}

#progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--p, 0%);
  background: rgba(255,255,255,0.55);
  transition: width 200ms linear;
}

#dots {
  position: absolute;
  left: 50%;
  bottom: 1.6vh;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 6px;
  pointer-events: none;
}

#dots .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background 300ms ease, transform 300ms ease;
}

#dots .dot.current { background: rgba(255,255,255,0.85); transform: scale(1.4); }

/* ── slide number (bottom-right indicator, fades out) ─────── */
#slide-number {
  position: absolute;
  right: 2.4vw;
  bottom: 6.2vh;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

#slide-number .current { color: var(--ink-dim); }

#slide-number .total {
  font-size: 1em;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.15em;
}

#slide-number.show {
  opacity: 1;
}

/* ── paused badge ────────────────────────────────────────── */
#paused-badge {
  position: absolute;
  top: 2vh;
  right: 2.4vw;
  z-index: 4;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--ink-dim);
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}

body.paused #paused-badge { opacity: 1; }

/* ── overview overlay (slide list) ───────────────────────── */
#overview {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 4vw;
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease;
  pointer-events: none;
}

body.overview #overview {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overview-inner {
  width: min(1100px, 100%);
}

.overview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 14px;
  margin-bottom: 24px;
}

.overview-head h2 {
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.overview-hint {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.overview-hint kbd {
  font-size: 10px;
  margin: 0 2px;
}

#overview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.ov-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: stretch;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.ov-item:hover,
.ov-item:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.ov-item.current {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.4);
}

.ov-thumb {
  width: 96px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  background: #111;
  flex-shrink: 0;
}

.ov-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ov-num {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}
.ov-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-section {
  font-size: 12px;
  color: var(--ink-dim);
  font-weight: 400;
}

/* ── help overlay ────────────────────────────────────────── */
#help,
#about {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease;
  pointer-events: none;
}

body.help #help,
body.about #about {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.help-inner {
  font-size: 18px;
  line-height: 1.8;
}

.help-inner h2 {
  font-size: 13px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 1em;
  font-weight: 500;
}

.help-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
  gap: clamp(36px, 7vw, 110px);
  align-items: start;
}

.help-inner ul { list-style: none; padding: 0; margin: 0; }

.system-info {
  margin: 0 0 22px;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.about-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: clamp(32px, 5vw, 80px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-align: center;
  color: #fff;
  text-shadow: var(--shadow);
}

.about-title { display: block; }
.about-by {
  display: block;
  font-size: 0.35em;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

kbd {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  background: rgba(255,255,255,0.06);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  text-align: center;
}

/* ── responsive tweaks ───────────────────────────────────── */
@media (max-width: 720px) {
  #caption { padding: 0 5vw 4vh 5vw; height: 32vh; }
  .caption-inner { max-width: 90vw; }
  #title { font-size: clamp(30px, 9vw, 56px); }
  #paragraph { font-size: clamp(14px, 3.6vw, 18px); }
  #next-hint { font-size: 10px; right: 4vw; bottom: 3vh; }
  #dots { bottom: 1vh; }
}

@media (orientation: portrait) and (max-width: 720px) {
  .caption-inner { max-width: 92vw; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .slide.active .image-stack img.current { animation: none; }
  .caption-inner { animation: none; }
  .image-stack img { transition: opacity 200ms linear; }
}
