:root {
  color-scheme: dark;
  --serif: "Huninn", "PingFang SC", sans-serif;
  --text: "Huninn", "PingFang SC", sans-serif;
  --accent: #cd8061;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--paper, #2a231e);
  color: var(--snow, #f2fdff);
  font-family: var(--text);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.55;
  letter-spacing: -0.011em;
  touch-action: none;
}

.figure,
.stage,
.shaft {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.figure {
  z-index: 0;
}

.stage {
  z-index: 1;
  pointer-events: auto;
}

.stage.is-dragging {
  cursor: grabbing;
}

.shaft {
  z-index: 4;
}

.world {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.spiral {
  position: absolute;
  inset: 0;
}

.dates {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.date {
  position: static;
  pointer-events: none;
}

.date {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--moonlight) 55%, transparent);
  font-family: var(--text);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.45;
  transform: translate(-50%, -50%);
  transition: color 0.45s ease, opacity 0.45s ease;
}

.date time {
  display: block;
  opacity: 0;
  transform: translate(var(--ox, 0px), var(--oy, -1.15rem));
  transition: opacity 0.45s ease;
}

.date__dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--moonlight) 70%, var(--slate));
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px var(--ink);
}

.date.is-active {
  color: var(--snow);
  font-family: var(--serif);
  font-size: 1.8rem;
  letter-spacing: 0.04em;
  opacity: 1;
  z-index: 2;
}

.date.is-active time {
  opacity: 1;
}

.date.is-active .date__dot {
  background: var(--gold);
  box-shadow:
    0 0 0 4px var(--ink),
    0 0 14px var(--gold);
}

.date:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
}

.traveler {
  position: absolute;
  z-index: 1;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hint {
  position: absolute;
  left: 1.05rem;
  bottom: calc(1.05rem + 2.9rem);
  margin: 0;
  color: var(--saffron);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transition: opacity 0.6s ease;
}

.hint.is-gone {
  opacity: 0;
}

.music {
  position: fixed;
  bottom: 1.05rem;
  left: 1.05rem;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--saffron) 72%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper) 62%, transparent);
  color: var(--saffron);
  cursor: pointer;
}

.music svg {
  width: 0.72rem;
  height: 0.72rem;
  fill: currentColor;
}

.music__pause {
  display: none;
}

.music.is-on {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 80%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--gold) 32%, transparent);
}

.music.is-on .music__play {
  display: none;
}

.music.is-on .music__pause {
  display: block;
}

.story {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 61.8%;
  padding: 7vh 5vw 6vh 4vw;
  perspective: 1400px;
}

.copy .rule {
  display: block;
  width: 2.4rem;
  height: 2px;
  margin-bottom: 0.85rem;
  border-radius: 999px;
  background: var(--accent);
}

.eyebrow,
.count {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.eyebrow {
  color: var(--saffron);
}

h1 {
  margin: 0.3rem 0 0.65rem;
  max-width: 14em;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.85rem, 3vw, 2.7rem);
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.body {
  max-width: 36rem;
  margin: 0;
  color: var(--moonlight);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.8;
  white-space: pre-line;
}

.photo {
  flex: 0 1 auto;
  width: max-content;
  max-width: 100%;
  margin: 1.35rem 2.4rem 1.6rem 0;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
}

.photo.is-cycling {
  cursor: pointer;
}

.pile {
  position: relative;
  width: 100%;
}

.card {
  position: relative;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: none;
  box-shadow: none;
  transform-origin: 50% 60%;
}

.card.is-front {
  position: relative;
  width: max-content;
  max-width: 100%;
  height: auto;
}

.card.is-back {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card__photo {
  display: block;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
  object-fit: contain;
}

.card.is-front .card__photo {
  position: relative;
  width: auto;
  height: auto;
  max-width: min(100%, 42vw);
  max-height: 52vh;
}

.card.is-back .card__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.count {
  margin-top: 0.75rem;
  text-align: right;
  color: color-mix(in srgb, var(--moonlight) 72%, transparent);
}

.count span {
  color: var(--gold);
}

html.is-portrait .story {
  right: 0;
  bottom: auto;
  left: 0;
  width: auto;
  height: 76%;
  justify-content: flex-start;
  padding: 1.15rem 1.1rem 0.45rem;
  overflow: hidden;
}

html.is-portrait .copy {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  pointer-events: auto;
}

html.is-portrait h1 {
  flex: 0 0 auto;
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.28rem, 5.6vw, 1.7rem);
  line-height: 1.28;
}

html.is-portrait .body {
  flex: 0 1 auto;
  max-height: 18vh;
  min-height: 0;
  overflow-y: auto;
  pointer-events: auto;
  font-size: 0.95rem;
  line-height: 1.55;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--saffron) 70%, transparent) transparent;
}

html.is-portrait .photo {
  flex: 0 1 auto;
  align-self: flex-start;
  width: max-content;
  max-width: 100%;
  height: auto;
  min-height: 0;
  margin: 1.15rem 1.5rem 0 0;
}

html.is-portrait .pile {
  width: max-content;
  max-width: 100%;
  height: auto;
}

html.is-portrait .card.is-front {
  width: max-content;
  max-width: 100%;
  height: auto;
}

html.is-portrait .card.is-front .card__photo {
  max-width: calc((100vw - 2.8rem) * 0.9);
  max-height: 41.4vh;
}

html.is-portrait .count {
  flex: 0 0 auto;
  margin-top: 0.3rem;
}

html.is-portrait .hint {
  left: 50%;
  bottom: 2.4vh;
  transform: translateX(-50%);
}

@media (prefers-reduced-motion: reduce) {
  .date,
  .hint {
    transition: none;
  }
}
