:root {
  color-scheme: light;
  --cream: #fff8f1;
  --peach: #f4b8a8;
  --coral: #de7668;
  --butter: #f5dc9e;
  --ink: #342a28;
  --muted: #746863;
  --glass: rgb(255 248 241 / 88%);
  --line: rgb(255 255 255 / 46%);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
}

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

html,
body {
  min-width: 20rem;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #181210;
  font-family: var(--sans);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  color: inherit;
  font: inherit;
}

.invitation {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  color: white;
  background: #2e211d;
}

.film-grain {
  position: absolute;
  z-index: 4;
  inset: -50%;
  pointer-events: none;
  opacity: 0.12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  animation: grain 1s steps(2) infinite;
}

.topbar {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: max(1rem, env(safe-area-inset-top)) max(1.15rem, env(safe-area-inset-right)) 0 max(1.15rem, env(safe-area-inset-left));
}

.wordmark,
.details-jump {
  position: relative;
  z-index: 2;
  border: 0;
  color: white;
  text-decoration: none;
  text-shadow: 0 1px 16px rgb(28 18 15 / 35%);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.08rem;
  letter-spacing: 0.12em;
}

.wordmark span {
  font-family: var(--sans);
  font-size: 0.57rem;
  letter-spacing: 0.23em;
  opacity: 0.74;
}

.details-jump {
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  background: transparent;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.details-jump span {
  display: inline-block;
  margin-left: 0.25rem;
  transition: transform 260ms ease;
}

.details-jump:hover span,
.details-jump:focus-visible span {
  transform: translate(0.2rem, 0.2rem);
}

.story-stage,
.story-frame,
.story-frame::after {
  position: absolute;
  inset: 0;
}

.story-frame {
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.story-frame::after {
  z-index: 1;
  content: "";
  background:
    linear-gradient(180deg, rgb(24 14 12 / 45%) 0%, transparent 27%),
    linear-gradient(0deg, rgb(30 18 15 / 74%) 0%, transparent 52%);
}

.story-frame.is-active {
  pointer-events: auto;
  opacity: 1;
}

.story-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--position, 50% 50%);
  transform: scale(1.045);
  transition: transform 6s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-frame.is-active img {
  transform: scale(1);
}

.story-caption {
  position: absolute;
  z-index: 2;
  left: max(1.35rem, env(safe-area-inset-left));
  bottom: calc(7.6rem + env(safe-area-inset-bottom));
  width: min(33rem, calc(100% - 2.7rem));
  color: white;
  text-align: left;
  transform: translateY(1rem);
  opacity: 0;
  transition:
    transform 680ms 260ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 680ms 260ms ease;
}

.story-frame.is-active .story-caption {
  transform: translateY(0);
  opacity: 1;
}

.story-caption .chapter {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 0.8rem;
  font-size: 0.69rem;
  letter-spacing: 0.22em;
}

.story-caption .chapter::before {
  width: 1.75rem;
  height: 1px;
  content: "";
  background: var(--peach);
}

.story-caption h2 {
  max-width: 12ch;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.35rem, 11vw, 5.5rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.story-caption p:last-child {
  max-width: 27rem;
  margin: 1rem 0 0;
  font-size: clamp(0.88rem, 3.6vw, 1.06rem);
  line-height: 1.8;
  letter-spacing: 0.08em;
  text-wrap: pretty;
}

.player-controls {
  position: absolute;
  z-index: 20;
  right: max(1.15rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1.15rem, env(safe-area-inset-left));
}

.timeline {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0.34rem;
}

.timeline button {
  position: relative;
  height: 1.5rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.timeline button::before,
.timeline button::after {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  content: "";
  transform: translateY(-50%);
}

.timeline button::before {
  background: rgb(255 255 255 / 36%);
}

.timeline button::after {
  background: white;
  transform: translateY(-50%) scaleX(0);
  transform-origin: left center;
}

.timeline button.is-complete::after {
  transform: translateY(-50%) scaleX(1);
}

.timeline button.is-current::after {
  animation: progress 5.2s linear forwards;
}

.invitation.is-paused .timeline button.is-current::after {
  animation-play-state: paused;
}

.control-row {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

.play-toggle {
  min-width: 3.2rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.play-toggle[hidden] {
  display: none;
}

.scene-count {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

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

.gesture-hint {
  margin: 0 0 0 auto;
  opacity: 0.72;
}

.tap-zone {
  position: absolute;
  z-index: 8;
  top: 12%;
  bottom: 16%;
  width: 22%;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.tap-zone--previous {
  left: 0;
}

.tap-zone--next {
  right: 0;
}

.event-card {
  position: absolute;
  z-index: 16;
  right: max(1rem, env(safe-area-inset-right));
  bottom: calc(6.6rem + env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  max-width: 34rem;
  max-height: calc(100dvh - 9.5rem);
  padding: clamp(1.25rem, 5vw, 2rem);
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 58%);
  border-radius: 1.35rem;
  color: var(--ink);
  background: var(--glass);
  box-shadow: 0 1.6rem 5rem rgb(38 21 16 / 22%);
  backdrop-filter: blur(20px) saturate(120%);
  text-align: left;
  animation: card-in 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.event-card[hidden] {
  display: none;
}

.event-card .eyebrow {
  margin: 0 0 0.6rem;
  color: var(--coral);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.event-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 7vw, 2.75rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.event-meta {
  display: grid;
  gap: 0.7rem;
  margin: 1.25rem 0;
  padding: 1rem 0;
  border-block: 1px solid rgb(52 42 40 / 13%);
}

.event-meta div {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  align-items: baseline;
  gap: 0.75rem;
}

.event-meta span {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

.event-meta strong {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.55;
}

.event-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.event-actions a,
.event-actions button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  font-size: 0.82rem;
  text-decoration: none;
  cursor: pointer;
}

.primary-action {
  border: 1px solid var(--coral);
  color: white;
  background: var(--coral);
}

.secondary-action {
  border: 1px solid rgb(52 42 40 / 20%);
  background: transparent;
}

.invitation.is-final .story-caption {
  opacity: 0;
}

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

@keyframes progress {
  to { transform: translateY(-50%) scaleX(1); }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(1.5rem) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes grain {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2%, -2%, 0); }
  50% { transform: translate3d(-2%, 1%, 0); }
  75% { transform: translate3d(1%, 2%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@media (min-width: 48rem) {
  .topbar {
    padding: 1.8rem 2.2rem 0;
  }

  .story-caption {
    left: 7vw;
    bottom: 9rem;
  }

  .player-controls {
    right: 2.2rem;
    bottom: 1.7rem;
    left: 2.2rem;
  }

  .event-card {
    right: auto;
    bottom: 7.6rem;
    left: 7vw;
    width: 31rem;
    max-height: calc(100dvh - 12rem);
  }
}

@media (max-height: 43rem) {
  .story-caption {
    bottom: 6.5rem;
  }

  .story-caption h2 {
    font-size: clamp(2rem, 8vw, 3.6rem);
  }

  .story-caption p:last-child {
    margin-top: 0.55rem;
  }

  .event-card {
    bottom: 5.5rem;
    max-height: calc(100dvh - 7.5rem);
  }

  .event-meta {
    margin: 0.75rem 0;
    padding: 0.7rem 0;
  }
}

@media (max-width: 30rem) {
  .event-card {
    padding: 1.1rem;
    border-radius: 1.1rem;
  }

  .event-card h1 {
    font-size: 1.48rem;
    line-height: 1.22;
  }

  .event-meta {
    gap: 0.35rem;
    margin: 0.75rem 0;
    padding: 0.65rem 0;
  }

  .event-actions a,
  .event-actions button {
    min-height: 2.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .film-grain {
    animation: none;
  }
}
