@font-face {
  font-family: 'Fraunces';
  src: url('/media/public/fraunces-soft-regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Fraunces';
  src: url('/media/public/fraunces-soft-bold.woff2') format('woff2');
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('/media/public/atkinson-next.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --cream: #FFF8F0;
  --ink: #332B35;
  --blush: #F3D1DC;
  --peach: #F4C7A5;
  --lavender: #D9D0EE;
  --mint: #C9E1D1;
  --berry: #8B2F50;
  --gold: #D8A94E;
  --motion-fast: 180ms;
  --motion-fade: 420ms;
  --motion-enter: 560ms;
  --motion-journey: 900ms;
  --ease-cute: cubic-bezier(.22, 1, .36, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 4%, rgba(243, 209, 220, .65), transparent 25rem),
    radial-gradient(circle at 92% 26%, rgba(217, 208, 238, .58), transparent 24rem),
    linear-gradient(180deg, var(--cream), #fffdf9 54%, var(--cream));
}

a {
  color: var(--berry);
  text-underline-offset: .2em;
}

.skip-link {
  position: fixed;
  inset: .5rem auto auto .5rem;
  z-index: 20;
  padding: .7rem 1rem;
  background: var(--ink);
  color: var(--cream);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

main {
  width: 100%;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(3rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.chapter,
.play-section,
.love-letter {
  position: relative;
  width: min(100%, 62rem);
  margin-inline: auto;
  padding: clamp(2.25rem, 5vw, 4rem) clamp(.75rem, 4vw, 2.5rem);
  border-inline-start: 2px solid rgba(139, 47, 80, .22);
}

.chapter::before {
  content: '♥';
  position: absolute;
  inset: 2.4rem auto auto -.48rem;
  color: var(--gold);
  font-size: .75rem;
  line-height: 1;
  pointer-events: none;
}

.story-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  width: min(100%, 68rem);
  min-height: min(42rem, calc(100dvh - 2rem));
  margin-inline: auto;
  padding: clamp(.75rem, 2vw, 2rem);
}

.eyebrow,
.date,
.speaker {
  font-weight: 700;
  letter-spacing: .045em;
}

.eyebrow,
.date {
  color: var(--berry);
  text-transform: uppercase;
  font-size: .82rem;
}

h1,
h2,
h3 {
  margin: 0 0 .5rem;
  color: var(--ink);
  font-family: 'Fraunces', Georgia, serif;
  line-height: 1.08;
  text-wrap: balance;
}

h1 {
  font-size: clamp(3rem, 14vw, 6.6rem);
}

@keyframes title-flourish {
  0% { opacity: .25; transform: scale(.94); }
  60% { opacity: 1; transform: scale(1.018); }
  100% { opacity: 1; transform: none; }
}

@keyframes hero-sparkle {
  0%, 100% { opacity: .38; transform: translate3d(0, .35rem, 0) rotate(-2deg); }
  50% { opacity: .9; transform: translate3d(0, -.35rem, 0) rotate(2deg); }
}

@keyframes hero-photo-settle {
  from { transform: rotate(-1deg) scale(.97); }
  to { transform: rotate(1deg) scale(1); }
}

@keyframes sticker-pulse {
  0%, 100% { opacity: .82; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.09) rotate(3deg); }
}

@keyframes sticker-found {
  0% { transform: scale(1); }
  55% { transform: scale(1.22) rotate(4deg); }
  100% { transform: scale(1); }
}

@keyframes card-reveal {
  0%, 100% { transform: none; }
  45% { transform: translateY(-2px) scale(.92) rotateY(12deg); }
}

@keyframes letter-open {
  from { opacity: 0; transform: translateY(.75rem) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes controls-open {
  from { opacity: 0; transform: translateX(.5rem) scale(.96); }
  to { opacity: 1; transform: none; }
}

html.animations-ready .reveal {
  opacity: 0;
  transform: translate3d(0, 1.25rem, 0) scale(.985);
  transition:
    opacity var(--motion-fade) ease-out var(--reveal-delay, 0ms),
    transform var(--motion-enter) var(--ease-cute) var(--reveal-delay, 0ms);
}

html.animations-ready .reveal-left {
  transform: translate3d(-1.75rem, .35rem, 0) rotate(-.35deg);
}

html.animations-ready .reveal-right {
  transform: translate3d(1.75rem, .35rem, 0) rotate(.35deg);
}

html.animations-ready .speech-bubble.reply.reveal-right {
  --reveal-delay: 80ms;
}

html.animations-ready .panel-grid > figure.reveal:nth-child(odd) {
  transform: translate3d(-1.75rem, .35rem, 0) rotate(-.35deg);
}

html.animations-ready .panel-grid > figure.reveal:nth-child(even) {
  transform: translate3d(1.75rem, .35rem, 0) rotate(.35deg);
}

html.animations-ready .reveal.is-visible {
  opacity: 1;
  transform: none;
}

html.animations-ready .panel-grid > figure.reveal.is-visible {
  transform: none;
}

html.animations-ready .hero-copy.is-visible h1 {
  animation: title-flourish var(--motion-enter) .14s both var(--ease-cute);
}

html.animations-ready .story-header::after {
  content: '✦  ♥  ✦';
  position: absolute;
  inset: 1rem 0 auto;
  color: var(--gold);
  font-size: clamp(1rem, 4vw, 1.5rem);
  letter-spacing: .45em;
  pointer-events: none;
  animation: hero-sparkle 2.4s .5s ease-in-out 2 both;
}

html.animations-ready .hero-photo-settle {
  animation: hero-photo-settle var(--motion-enter) both var(--ease-cute);
}

html.animations-ready figure.is-visible .sticker:not([aria-disabled='true']) {
  animation: sticker-pulse 1.4s var(--ease-cute) 3;
}

html.animations-ready .sticker:hover,
html.animations-ready .sticker:focus-visible {
  animation: none;
}

html.animations-ready .sticker.just-found {
  animation: sticker-found 320ms var(--ease-cute);
}

h2 {
  font-size: clamp(2rem, 8vw, 3.8rem);
}

h3 {
  font-size: clamp(1.3rem, 5vw, 2rem);
}

p {
  margin-block: .65rem;
  max-width: 66ch;
}

.lede {
  font-size: clamp(1.05rem, 4vw, 1.35rem);
}

.music-player {
  position: fixed;
  z-index: 10;
  inset: auto max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) auto;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: .5rem;
}

.music-controls {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .35rem;
  border: 1px solid rgba(255, 248, 240, .38);
  border-radius: 999px;
  background: rgba(51, 43, 53, .94);
  box-shadow: 0 10px 30px rgba(51, 43, 53, .22);
}

#music-launcher {
  width: 52px;
  height: 52px;
  padding: 0;
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(51, 43, 53, .2);
  font-size: 1.35rem;
}

#music-launcher:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 2px;
  box-shadow: 0 0 0 8px var(--berry);
}

.music-controls button {
  min-width: 46px;
  min-height: 46px;
  padding: .45rem;
  border-color: var(--cream);
  color: var(--ink);
  background: var(--cream);
}

button,
input[type='range'] {
  accent-color: var(--berry);
}

button {
  min-width: 44px;
  min-height: 44px;
  border: 2px solid var(--berry);
  border-radius: 999px;
  padding: .65rem 1rem;
  color: var(--cream);
  background: var(--berry);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button[disabled] {
  cursor: not-allowed;
  opacity: .58;
}

button:not(:disabled):not([aria-disabled='true']):active {
  transform: scale(.97);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--cream);
  outline-offset: 2px;
  box-shadow: 0 0 0 8px var(--berry);
}

input[type='range'] {
  width: min(13rem, 62vw);
  min-height: 44px;
}

#music-status {
  min-height: 1px;
}

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

.panel-grid {
  display: grid;
  gap: .75rem;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 1.25rem;
}

figure {
  min-width: 0;
  margin: 0;
}

picture,
img,
video {
  display: block;
  width: 100%;
  max-width: 100%;
}

picture,
.media-frame {
  overflow: hidden;
  border-radius: 1rem;
  aspect-ratio: var(--ratio, 3 / 4);
  background: linear-gradient(135deg, var(--blush), var(--lavender));
}

.hero-figure {
  transform: rotate(1deg);
}

.hero-figure figcaption {
  max-width: 34rem;
}

img,
video {
  height: auto;
}

.media-frame > video,
.media-frame > img,
picture > img {
  height: 100%;
  object-fit: cover;
}

.ratio-wide {
  --ratio: 16 / 9;
}

.ratio-event {
  --ratio: 3 / 2;
}

.ratio-four-three {
  --ratio: 4 / 3;
}

.ratio-couple {
  --ratio: 960 / 494;
}

.ratio-square {
  --ratio: 1;
}

.ratio-portrait {
  --ratio: 9 / 16;
}

.ratio-standard {
  --ratio: 3 / 4;
}

figcaption {
  padding: .5rem .1rem 0;
  color: var(--ink);
}

.chapter-doodle {
  display: grid;
  width: 3.25rem;
  min-height: 2.25rem;
  margin: .55rem 1rem -1rem auto;
  place-items: center;
  border: 2px solid currentcolor;
  border-radius: 45% 55% 48% 52%;
  color: var(--berry);
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -.08em;
  opacity: .72;
  pointer-events: none;
  transform: rotate(5deg);
}

.doodle-samosa,
.doodle-style {
  margin-right: auto;
  margin-left: 1rem;
  transform: rotate(-6deg);
}

.doodle-samosa {
  border: 0;
  color: var(--gold);
  font-size: 2.5rem;
  line-height: .8;
  text-shadow: 1px 2px 0 var(--berry);
}

.doodle-cafe {
  border-color: var(--gold);
  font-size: 1.45rem;
}

.doodle-style {
  color: #9a5970;
  background: linear-gradient(135deg, transparent 50%, rgba(216, 169, 78, .24) 50%);
}

.doodle-teaching {
  color: #4f775f;
}

.media-fallback {
  display: block;
  margin-top: .35rem;
  color: var(--berry);
  font-weight: 700;
}

.media-unavailable .media-frame,
.media-unavailable picture {
  display: grid;
  min-height: 12rem;
  place-items: center;
}

.speech-row {
  display: grid;
  gap: .65rem;
  margin: .85rem 0;
}

.speech-bubble {
  position: relative;
  max-width: 33rem;
  margin: 0;
  padding: .85rem 1rem;
  border-radius: 1.2rem 1.2rem 1.2rem .25rem;
  background: var(--blush);
  box-shadow: 0 5px 14px rgba(51, 43, 53, .08);
}

.speech-bubble.reply {
  justify-self: end;
  border-radius: 1.2rem 1.2rem .25rem 1.2rem;
  background: var(--mint);
}

.speaker {
  display: block;
  color: var(--berry);
}

.sticker {
  float: right;
  margin: .5rem;
  padding: .45rem;
  border-color: var(--gold);
  color: var(--ink);
  background: var(--peach);
  font-size: 1.25rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
  margin: 1rem 0;
}

.memory-card {
  aspect-ratio: 1;
  border-radius: .9rem;
  padding: .25rem;
  color: var(--cream);
  background: var(--berry);
  font-size: clamp(1.1rem, 7vw, 2rem);
  transition: transform var(--motion-fast) var(--ease-cute);
}

.memory-card.card-reveal {
  animation: card-reveal 360ms var(--ease-cute);
}

.memory-card[aria-pressed='true'] {
  color: var(--ink);
  background: var(--peach);
  transform: translateY(-.12rem);
}

.memory-card[aria-disabled='true'] {
  border-color: var(--gold);
  color: var(--ink);
  background: var(--mint);
  opacity: 1;
}

.sticker[aria-disabled='true'] {
  border-color: var(--berry);
  background: var(--mint);
}

#memory-status,
#sticker-status,
#train-status {
  min-height: 1.6em;
  color: var(--berry);
  font-weight: 700;
}

.train-game {
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid var(--berry);
  border-radius: 1rem;
  background: rgba(255, 255, 255, .58);
}

.train-motion {
  --train-progress: 0;
  position: relative;
  container-type: inline-size;
  overflow: hidden;
  height: 3.2rem;
  margin-bottom: .75rem;
  border-bottom: .25rem dashed var(--berry);
}

#train-engine {
  position: absolute;
  inset-block-end: .15rem;
  inset-inline-start: 0;
  transform: translateX(calc((100cqi - 3rem) * var(--train-progress)));
  font-size: 2rem;
  opacity: 1;
  transition:
    transform var(--motion-journey) var(--ease-cute),
    opacity var(--motion-fade) ease-out;
}

html.animations-ready .train-motion.reveal:not(.is-visible) #train-engine {
  opacity: .25;
  transform: translateX(0);
}

html.animations-ready .train-motion.reveal.is-visible #train-engine {
  opacity: 1;
  transform: translateX(calc((100cqi - 3rem) * var(--train-progress)));
}

#train-progress {
  display: block;
  width: 100%;
  height: 1.25rem;
  margin-top: .4rem;
  accent-color: var(--berry);
}

.train-static {
  margin-bottom: .35rem;
}

.love-letter {
  border-block-start: 2px solid var(--gold);
  text-align: center;
}

.love-letter:not([hidden]) {
  animation: letter-open var(--motion-enter) var(--ease-cute);
}

#music-controls:not([hidden]) {
  animation: controls-open var(--motion-fast) var(--ease-cute);
}

[hidden] {
  display: none !important;
}

@media (min-width: 48rem) {
  .story-header {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  }

  h1 {
    font-size: clamp(3rem, 6.5vw, 5.25rem);
  }

  .panel-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .panel-grid > figure:nth-child(4n + 1),
  .panel-grid > figure:nth-child(4n + 4) {
    grid-column: span 7;
  }

  .panel-grid > figure:nth-child(4n + 2),
  .panel-grid > figure:nth-child(4n + 3) {
    grid-column: span 5;
  }

  .chapter:nth-of-type(even) .panel-grid > figure:nth-child(4n + 1),
  .chapter:nth-of-type(even) .panel-grid > figure:nth-child(4n + 4) {
    grid-column: span 5;
  }

  .chapter:nth-of-type(even) .panel-grid > figure:nth-child(4n + 2),
  .chapter:nth-of-type(even) .panel-grid > figure:nth-child(4n + 3) {
    grid-column: span 7;
  }

  .panel-grid .feature {
    grid-column: 1 / -1;
    width: min(100%, 48rem);
    justify-self: center;
  }
}

@media (max-width: 47.99rem) {
  .story-header {
    min-height: auto;
    align-content: start;
    gap: 1rem;
    padding: .75rem .5rem 1.5rem;
  }

  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-grid > figure,
  .chapter:nth-of-type(even) .panel-grid > figure {
    grid-column: auto;
  }

  .panel-grid > figure.feature,
  .panel-grid > figure:has(.ratio-wide, .ratio-event, .ratio-couple, video),
  .chapter:nth-of-type(even) .panel-grid > figure.feature,
  .chapter:nth-of-type(even) .panel-grid > figure:has(.ratio-wide, .ratio-event, .ratio-couple, video) {
    grid-column: 1 / -1;
  }

  .panel-grid > figure:last-child:nth-child(odd):has(.ratio-portrait) {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 15rem);
  }

  figcaption {
    font-size: .9rem;
    line-height: 1.4;
  }

  .sticker {
    display: block;
    float: none;
    margin: .5rem 0 0 auto;
  }

  .chapter,
  .play-section,
  .love-letter {
    width: 100%;
    padding: 2rem clamp(.75rem, 4vw, 1rem);
  }
}

@media (max-width: 320px) {
  main {
    padding-inline: max(.65rem, env(safe-area-inset-left));
  }

  .chapter,
  .play-section,
  .love-letter {
    padding: 1.5rem .75rem;
  }

  .music-player {
    inset-inline: max(.65rem, env(safe-area-inset-left));
    justify-content: flex-start;
  }

  .music-controls {
    flex-wrap: wrap;
    gap: 0;
    max-width: calc(100vw - 5rem);
    padding: .2rem;
  }
}

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

  .train-motion {
    display: none;
  }

  .memory-card[aria-pressed='true'] {
    transform: none;
  }

  html.animations-ready .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  html.animations-ready .story-header::after,
  html.animations-ready .hero-copy h1,
  html.animations-ready .hero-photo-settle,
  html.animations-ready .sticker,
  #music-controls:not([hidden]),
  .love-letter:not([hidden]),
  .memory-card.card-reveal,
  .sticker.just-found {
    animation: none !important;
  }

  #train-engine {
    opacity: 1 !important;
    transition: none !important;
  }
}
