@font-face {
  font-family: "Instrument Serif";
  src: url("assets/instrument-serif.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("assets/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fff3f0;
  --ink: #381d29;
  --wine: #722342;
  --rose-ink: #843855;
  --soft-ink: #654a52;
  --rule: #ddbdc4;
  --light: #fff9f4;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  --viewport: 100vh;
  --edge: clamp(16px, 4.9vw, 78px);
  --header-pad: clamp(5px, 1.05vh, 12px);
  --scene-pad: clamp(7px, 2vh, 24px);
  --art-height: min(66vh, 660px);
  --headline: clamp(2.8rem, min(6.2vw, 9vh), 6.1rem);
  --question: clamp(2.35rem, min(5.4vw, 8.15vh), 5.35rem);
}

@supports (height: 100dvh) {
  :root {
    --viewport: 100dvh;
    --header-pad: clamp(5px, 1.05dvh, 12px);
    --scene-pad: clamp(7px, 2dvh, 24px);
    --art-height: min(66dvh, 660px);
    --headline: clamp(2.8rem, min(6.2vw, 9dvh), 6.1rem);
    --question: clamp(2.35rem, min(5.4vw, 8.15dvh), 5.35rem);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow-x: clip;
}

body {
  min-inline-size: 0;
  min-block-size: var(--viewport);
  margin: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem / 1.5 var(--sans);
}

body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: clamp(68px, 13vw, 205px);
  aspect-ratio: 1;
  opacity: .51;
  background: center / contain no-repeat;
  pointer-events: none;
}

body::before {
  inset: auto auto max(14px, env(safe-area-inset-bottom)) -32px;
  background-image: url("assets/edge-left.webp");
}

body::after {
  inset: 55px -25px auto auto;
  background-image: url("assets/edge-right.webp");
}

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

button {
  font: inherit;
}

button:not(:disabled), a {
  cursor: pointer;
}

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

.visually-hidden, .sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.site-header {
  z-index: 5;
  width: min(1320px, calc(100% - var(--edge) * 2));
  margin-inline: auto;
  padding-block: max(var(--header-pad), env(safe-area-inset-top)) var(--header-pad);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  column-gap: 10px;
  row-gap: 0;
  border-bottom: 1px solid var(--rule);
}

.site-identity {
  display: inline-flex;
  align-items: center;
  gap: clamp(5px, 1vw, 10px);
  min-width: 0;
  margin-block: 3px;
  white-space: nowrap;
  font: 400 clamp(1.56rem, 2.5vw, 2.125rem) / 1 var(--serif);
  letter-spacing: -.012em;
}

.site-identity img {
  width: clamp(17px, 2.1vw, 25px);
  height: 26px;
  object-fit: contain;
}

.identity-period {
  color: var(--rose-ink);
}

body:has(#scene[data-welcome-phase="bloom"]) .site-identity > span {
  visibility: hidden;
}

.site-actions {
  min-width: 0;
  margin-inline-start: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 3px clamp(6px, 1.3vw, 16px);
}

.language-picker {
  position: relative;
  max-width: 100%;
}

.site-language-select,
.site-sound-toggle,
[data-action="welcome-sound"] {
  min-height: 38px;
  max-inline-size: 100%;
  padding: 5px 9px;
  background-color: transparent;
  color: var(--wine);
  border: 1px solid transparent;
  border-radius: 3px;
  font: 650 .875rem / 1.22 var(--sans);
  touch-action: manipulation;
}

.site-music-toggle {
  inline-size: 40px;
  block-size: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: #fff7f4a8;
  color: var(--wine);
  font: 650 1.35rem / 1 var(--sans);
  touch-action: manipulation;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.site-music-toggle:hover {
  background: #f7dce5;
}

.site-music-toggle[aria-pressed="true"] {
  background: var(--wine);
  border-color: var(--wine);
  color: var(--light);
}

.site-music-toggle:active {
  transform: scale(.93);
}

.site-language-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: #ddbdc4a0;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.site-language-select:hover,
.site-language-select[aria-expanded="true"],
.site-sound-toggle:hover,
[data-action="welcome-sound"]:hover {
  background-color: #f7dce580;
  border-color: var(--rule);
}

.language-chevron {
  flex: 0 0 5px;
  width: 5px;
  height: 5px;
  margin: -2px 2px 1px 0;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 170ms ease;
}

.site-language-select[aria-expanded="true"] .language-chevron {
  transform: translateY(2px) rotate(225deg);
}

.language-menu {
  position: absolute;
  z-index: 8;
  inset-block-start: calc(100% + 5px);
  inset-inline-end: 0;
  width: min(218px, calc(100vw - var(--edge) * 2));
  max-block-size: calc(var(--viewport) - 58px);
  overflow: auto;
  margin: 0;
  padding: 5px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff7f4;
  box-shadow: 0 12px 24px #5221361a;
  transform-origin: top right;
  animation: language-menu-in 190ms cubic-bezier(.2, .75, .32, 1) both;
}

@keyframes language-menu-in {
  from { opacity: 0; transform: translateY(-5px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.language-option {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  text-align: start;
  font: 600 .875rem / 1.2 var(--sans);
  overflow-wrap: anywhere;
}

.language-option:hover, .language-option:focus-visible {
  outline-offset: -2px;
  background: #f7e1e7;
}

.language-option[aria-checked="true"] {
  color: var(--wine);
  background: #efd1df;
}

.site-main {
  min-inline-size: 0;
  flex: 1 0 auto;
  width: min(1200px, calc(100% - var(--edge) * 2));
  margin-inline: auto;
  padding-block: var(--scene-pad) max(var(--scene-pad), env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
}

.scene-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: clamp(20px, 5.2vw, 82px);
  align-items: center;
}

.scene-art {
  position: relative;
  min-width: 0;
  height: var(--art-height);
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  margin: 0;
  isolation: isolate;
}

.scene-art-image {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  object-fit: contain;
  object-position: center;
}

.scene-layout--thanks .scene-art-image {
  animation: card-open 800ms ease-out both;
}

.scene-layout--thanks .scene-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/cover.webp") center / contain no-repeat;
  animation: cover-open 620ms ease-in-out both;
  pointer-events: none;
}

@keyframes card-open {
  0%, 24% { opacity: 0; transform: translateY(8px) scale(.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cover-open {
  0% { opacity: 1; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.025) rotate(-2deg); }
}

.scene-layout--welcome {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: clamp(3px, 1.05dvh, 13px);
}

.scene-layout--welcome .scene-copy {
  text-align: center;
}

.scene-layout--welcome h1 {
  max-width: none;
  font-size: clamp(2.65rem, min(8vw, 8.9dvh), 6.1rem);
}

.welcome-copy {
  animation: welcome-message 560ms ease-out both;
}

@keyframes welcome-message {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-layout--welcome .choices {
  max-width: none;
  justify-content: center;
  margin-top: clamp(6px, 1.4dvh, 16px);
}

.welcome-prelude {
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  column-gap: 14px;
}

.welcome-prelude .scene-status {
  flex-basis: 100%;
}

.scene-art--welcome {
  width: min(100%, 580px);
  height: min(70dvh, calc(var(--viewport) - 184px), 790px);
  min-height: 80px;
  padding: 0;
}

.scene-art--welcome video, .scene-art--welcome img {
  background: transparent;
}

#scene[data-welcome-phase="bloom"] .scene-art--welcome img {
  animation: bloom-in 3.7s cubic-bezier(.2, .75, .25, 1) both;
}

.scene-copy {
  min-width: 0;
  position: relative;
  overflow-wrap: anywhere;
}

.scene-copy h1 {
  max-width: 16ch;
  margin: 0;
  color: var(--ink);
  font: 400 var(--headline) / .95 var(--serif);
  letter-spacing: -.024em;
  text-wrap: balance;
}

.scene-copy h1:focus {
  outline: none;
}

.scene-layout--intro h1 span, .scene-layout--intro h1 em {
  display: block;
}

.scene-copy h1 em {
  color: var(--wine);
}

.scene-layout--genes h1, .scene-layout--quiz h1, .scene-layout--thanks h1,
.scene-layout--stamp h1, .scene-layout--invite h1, .scene-layout--wishes h1 {
  font-size: var(--question);
}

.scene-layout--stamp h1 {
  color: var(--wine);
  transform-origin: left center;
  animation: stamp-in 400ms ease-out both;
}

@keyframes stamp-in {
  0% { opacity: 0; transform: scale(1.09) rotate(-2deg); }
  55% { opacity: 1; transform: scale(.99) rotate(-2deg); }
  100% { opacity: 1; transform: scale(1) rotate(-2deg); }
}

.scene-kicker {
  margin: 0 0 clamp(5px, 1.4dvh, 14px);
  color: var(--rose-ink);
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .065em;
}

.scene-subtitle, .scene-status {
  max-width: 40ch;
  margin: clamp(7px, 2dvh, 20px) 0 0;
  color: var(--soft-ink);
  font-size: 1rem;
}

.scene-status {
  margin-top: 7px;
}

.scene-status:empty {
  margin: 0;
  min-height: 0;
}

.scene-text-action {
  min-height: 40px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--wine);
  text-underline-offset: .22em;
  text-decoration: underline;
  text-decoration-color: #ab6d83;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.25;
}

.scene-text-action:hover {
  text-decoration-color: currentColor;
}

.choices {
  max-width: 420px;
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: clamp(6px, 1.25dvh, 12px);
  margin-top: clamp(10px, 2.6dvh, 28px);
}

.choices--intro {
  min-height: 46px;
  align-content: start;
  align-items: center;
}

.choices--intro .button {
  min-width: min(126px, calc((100% - 10px) / 2));
}

.choices--grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(42%, 8rem)), 1fr));
}

.choices--grid .button, .choices--grid .button span {
  min-inline-size: 0;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.choices--grid .scene-text-action {
  grid-column: 1 / -1;
  justify-self: center;
}

.choices--stack {
  align-items: center;
}

.choices--only-yes {
  justify-content: center;
}

.button {
  min-height: clamp(44px, 5.9dvh, 54px);
  min-width: 116px;
  max-width: 100%;
  padding: clamp(6px, 1.15dvh, 11px) clamp(9px, 2vw, 23px);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  color: var(--light);
  border: 0;
  border-radius: 3px;
  background: transparent url("assets/button-wine.webp") center / 100% 100% no-repeat;
  text-align: center;
  line-height: 1.18;
  font-size: .975rem;
  font-weight: 700;
  transform-origin: center;
  touch-action: manipulation;
  transition: filter 160ms ease-out;
}

.button--no {
  color: var(--ink);
  background-image: url("assets/button-blush.webp");
}

.button:hover:not(:disabled) {
  filter: brightness(1.09);
}

.button--no:hover:not(:disabled) {
  filter: brightness(.97);
}

.button:disabled {
  cursor: default;
}

.button-slot {
  display: inline-grid;
  align-items: center;
}

.moving-answer {
  z-index: 7;
}

.answer-fragment {
  pointer-events: none;
}

.scene-layout--letter h1 {
  font-size: var(--question);
}

.letter-body, .wish-lines {
  max-width: 46ch;
  margin-top: clamp(8px, 1.9dvh, 20px);
  color: var(--soft-ink);
}

.letter-body p, .wish-lines p {
  margin: 0 0 clamp(5px, 1.2dvh, 12px);
}

.letter-body p:last-child, .wish-lines p:last-child {
  margin-bottom: 0;
}

.letter-body strong {
  color: var(--wine);
  font-weight: 700;
}

.scene-layout--wishes .scene-art-image {
  transform-origin: 50% 65%;
  animation: bloom-in 2400ms cubic-bezier(.2, .75, .25, 1) both;
}

@keyframes bloom-in {
  from { opacity: .35; transform: scale(.86) rotate(-3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.scene-layout--clip {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  position: relative;
  isolation: isolate;
}

.scene-art--clip {
  grid-area: 1 / 1;
  height: auto;
  width: min(100%, 40rem, calc((var(--viewport) - 95px) * 1.45));
  aspect-ratio: 1.45;
  padding: 4px;
  border: 1px solid var(--rule);
}

.scene-art--clip:has(video) {
  width: min(100%, 420px, calc((var(--viewport) - 92px) * .5625));
  aspect-ratio: 9 / 16;
}

.scene-art--clip .scene-art-image {
  object-fit: cover;
  background: #f6dfe1;
}

.scene-art--clip video.scene-art-image {
  object-fit: contain;
  background: #251a21;
}

.scene-copy--clip {
  grid-area: 1 / 1;
  position: static;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.clip-controls {
  position: absolute;
  inset: auto 2px 0 auto;
  z-index: 3;
  padding: 4px;
  pointer-events: auto;
}

.clip-action {
  min-height: 36px;
  padding: 5px 8px;
  background: #fff3f0df;
  border-radius: 3px;
  font-size: .8rem;
}

.clip-action[data-action="clip-play"] {
  position: absolute;
  top: 50%;
  left: 50%;
  min-height: 44px;
  padding: 8px 20px;
  background-color: var(--wine);
  color: var(--light);
  box-shadow: 0 2px 12px #381d2944;
  text-decoration: none;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.clip-controls:has([data-action="clip-play"]) {
  inset: 0;
  pointer-events: none;
}

.clip-controls:has([data-action="clip-play"]) .clip-action {
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .clip-action[data-action="clip-skip"] {
    opacity: .78;
    transition: opacity 160ms ease;
  }

  .scene-layout--clip:hover .clip-action[data-action="clip-skip"],
  .clip-action[data-action="clip-skip"]:focus-visible {
    opacity: 1;
  }
}

.petals {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.petal {
  position: absolute;
  inline-size: min(30px, 6dvh);
  block-size: min(38px, 7.5dvh);
  object-fit: contain;
  pointer-events: none;
}

.letter-petal {
  top: 49%;
  left: 60%;
  width: clamp(18px, 3.2vw, 38px);
}

@media (orientation: portrait), (max-width: 519px) {
  :root {
    --edge: clamp(14px, 5.2vw, 54px);
    --headline: clamp(2.5rem, min(10.6vw, 8.3dvh), 5.7rem);
    --question: clamp(2.1rem, min(9.4vw, 7.2dvh), 4.95rem);
    --art-height: min(28dvh, 360px);
  }

  .site-main {
    max-width: 650px;
  }

  .scene-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(8px, 2.55dvh, 22px);
  }

  .scene-layout--welcome {
    gap: clamp(3px, 1.05dvh, 13px);
  }

  .scene-layout--welcome h1 {
    font-size: clamp(2.65rem, min(11vw, 8.9dvh), 5.6rem);
  }

  .scene-art--welcome {
    width: min(calc(100vw - 12px), calc(100% + var(--edge) * 1.45), 580px);
    height: min(72dvh, calc(var(--viewport) - 176px), 790px);
  }

  .scene-layout--letter .scene-art,
  .scene-layout--wishes .scene-art,
  .scene-layout--genes .scene-art {
    height: min(19dvh, 260px);
  }

  .scene-layout--clip {
    gap: 0;
  }

  .scene-copy {
    justify-self: center;
    width: min(100%, 42rem);
  }

  .scene-copy--clip {
    width: 100%;
  }

  body::before, body::after {
    width: clamp(60px, 16vw, 150px);
    opacity: .35;
  }

  body::before {
    left: -24px;
  }

  body::after {
    right: -17px;
  }
}

@media (orientation: portrait) and (max-height: 740px), (max-width: 370px) {
  .site-language-select, .site-sound-toggle {
    font-size: .8125rem;
    min-height: 36px;
  }

  .letter-body, .wish-lines, .scene-subtitle, .scene-status {
    font-size: .9375rem;
    line-height: 1.38;
  }

  .scene-layout--letter .scene-art,
  .scene-layout--wishes .scene-art,
  .scene-layout--genes .scene-art {
    height: min(16dvh, 150px);
  }
}

@media (max-width: 370px) {
  .site-header {
    column-gap: 6px;
  }

  .site-identity {
    font-size: 1.45rem;
  }

  .site-actions {
    column-gap: 4px;
  }

  [data-language-current] {
    max-inline-size: 9.5ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 370px) and (max-height: 530px) and (orientation: portrait) {
  .scene-layout--letter {
    gap: 8px;
  }

  .scene-layout--letter .scene-art {
    height: min(12dvh, 60px);
  }

  .scene-layout--letter .choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-layout--letter .choices .button,
  .scene-layout--letter .choices .button span {
    min-inline-size: 0;
  }
}

@media (min-width: 520px) and (max-height: 530px) and (orientation: landscape) {
  :root {
    --edge: clamp(14px, 4.4vw, 36px);
    --headline: clamp(2.3rem, 9.9dvh, 4.7rem);
    --question: clamp(1.95rem, 8.5dvh, 4.3rem);
    --art-height: min(66dvh, 340px);
  }

  .scene-layout {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1fr);
    gap: clamp(10px, 3.4vw, 34px);
  }

  .scene-layout--welcome {
    grid-template-columns: minmax(0, .85fr) minmax(0, 1fr);
    max-width: 850px;
    width: 100%;
    justify-self: center;
  }

  .scene-art--welcome {
    height: min(76dvh, calc(var(--viewport) - 75px), 500px);
  }

  .scene-layout--welcome h1 {
    font-size: clamp(2.45rem, 12dvh, 5.2rem);
  }

  .scene-layout--clip {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .letter-body, .wish-lines, .scene-subtitle, .scene-status {
    font-size: .9375rem;
    line-height: 1.32;
  }
}

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