:root {
  --room-background: #130e0a;
  --room-width: min(100vw, 560px, calc(59vh * 720 / 752));
  --floor-falloff: linear-gradient(180deg, transparent, var(--room-background) 72%);
}

@supports (height: 1svh) {
  :root { --room-width: min(100vw, 560px, calc(59svh * 720 / 752)); }
}

html[data-room="drop"] {
  color-scheme: dark;
  color: #ead9c5;
  background: var(--room-background);
}

#drop-room {
  width: min(100%, var(--editing-width, var(--room-width)));
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  font-family: system-ui, -apple-system, sans-serif;
  outline: none;
}

.installation { position: relative; }
.installation img, .bridge-installation img { display: block; width: 100%; height: auto; }

.glass-light {
  position: absolute;
  inset: 12% 18% 0;
  background: radial-gradient(ellipse at 50% 63%, #e8ab6924, transparent 63%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

html[data-room="drop"] .glass-light { animation: glass-breath 10s ease-in-out infinite; }

@keyframes glass-breath {
  0%, 100% { opacity: 0; }
  50% { opacity: .20; }
}

.back {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(5px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #ead4bb;
}

.back svg { width: 17px; }

.room-floor, .bridge-floor {
  position: relative;
  min-height: 205px;
  background: var(--floor-falloff), url('/first-drop-floor-edge.webp') top center / 100% 100%;
}

.room-floor {
  box-sizing: border-box;
  padding: clamp(17px, 3.8vw, 27px) 0
    calc(max(27px, env(safe-area-inset-bottom)) + var(--keyboard-room, 0px));
}

.floor-light {
  position: absolute;
  inset: 0 0 auto;
  height: 108px;
  background: radial-gradient(ellipse at 50% 3%, #e9a16022, transparent 72%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.lettering-space {
  position: relative;
  width: min(57vw, 300px, calc(100% - 24px));
  aspect-ratio: 240 / 57;
  margin-inline: auto;
}

.floor-lettering {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 .55px 0 #120b07) drop-shadow(0 -.18px .38px #dca97960);
}

#drop-phrase {
  fill: none;
  stroke: #c19b77;
  stroke-width: 1.08;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 250ms ease;
}

#drop-phrase[hidden] { display: none; }
#engraved-confirmation { visibility: hidden; }
#engraved-confirmation.complete { visibility: visible; }

#engraved-confirmation.complete path {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: etch var(--time) linear var(--at) forwards;
}

#engraved-confirmation.complete g { animation: illuminate 1300ms ease-out both; }
#engraved-confirmation.settled g { animation: none; stroke-opacity: .94; }
#engraved-confirmation.settled path { animation: none; stroke-dashoffset: 0; }

@keyframes etch { to { stroke-dashoffset: 0; } }

@keyframes illuminate {
  0%, 76.9% { stroke-opacity: .69; }
  87% { stroke-opacity: 1; }
  100% { stroke-opacity: .94; }
}

#first-drop-form {
  position: relative;
  width: min(340px, calc(100% - 48px));
  margin: clamp(19px, 5vw, 28px) auto 0;
  transition: opacity 250ms ease;
}

#drop-room.registered #first-drop-form,
#drop-room.registered #drop-phrase { opacity: 0; pointer-events: none; }

#drop-room.registered .glass-light { animation: none; opacity: 0; }
#drop-room.registered .floor-light { animation: warm-floor 1900ms ease-out both; }
#drop-room.settled .floor-light { animation: none; opacity: .34; }

@keyframes warm-floor {
  0%, 13% { opacity: 0; }
  31%, 84% { opacity: .6; }
  100% { opacity: .34; }
}

#drop-room.arriving .back,
#drop-room.arriving #drop-phrase,
#drop-room.arriving #first-drop-form { animation: arrive 300ms ease-out both; }
#drop-room.arriving .back { pointer-events: none; }

@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }

.email-row { display: flex; border-bottom: 1px solid #89735e; scroll-margin-block: 14px; }

#first-drop-email {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0 0 0 3px;
  font: inherit;
  font-size: 16px;
}

#first-drop-email::placeholder { opacity: 1; color: #e0cbb4; }
#first-drop-email:focus { outline: none; }
.email-row:focus-within { border-color: #cfb092; }

.email-row button {
  appearance: none;
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.email-row button:disabled { cursor: wait; opacity: .48; }
.email-row button svg { width: 18px; }

#drop-room :focus-visible { outline: 1px solid #bba184; outline-offset: 3px; }

#first-drop-privacy, #first-drop-error {
  margin: 8px 0 0;
  color: #c8b49f;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

#first-drop-privacy a { color: inherit; margin-left: .2em; text-underline-offset: .15em; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The fixed passage exists only while moving between the two document layouts. */
#passage {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  isolation: isolate;
  pointer-events: none;
  --passage-duration: 1800ms;
  --direction: normal;
}

#passage[data-direction="return"] {
  --direction: reverse;
  animation: return-entry 200ms ease both;
}
@keyframes return-entry { from { opacity: 0; } to { opacity: 1; } }
#passage[hidden] { display: none; }
html[data-passage] { overflow: hidden; }
html[data-passage] #registration-layer { z-index: 5; }
html[data-passage] #invitation { pointer-events: none; animation: invitation-withdraw 200ms ease both; }
@keyframes invitation-withdraw { to { opacity: 0; } }

.bridge-launch { background: #211e1a; }
.bridge-bronze {
  position: relative;
  width: min(100vw, calc(100vh * 719 / 1280));
  width: min(100vw, calc(100dvh * 719 / 1280));
  aspect-ratio: 719 / 1280;
  transform-origin: 50% 47%;
  animation: bronze-dolly var(--passage-duration) ease-in-out both var(--direction);
}
.bridge-bronze > img:first-child { display: block; width: 100%; height: auto; }

.bridge-floor-repair {
  position: absolute;
  left: 4.5897%;
  top: 60.78125%;
  width: 88.0389%;
  height: 18.90625%;
  animation: engraving-withdraw var(--passage-duration) ease both var(--direction);
}

.bridge-drop {
  position: absolute;
  inset: 0;
  background: var(--room-background);
  animation: open-second-room var(--passage-duration) linear both var(--direction);
}

.bridge-installation {
  width: var(--room-width);
  margin-inline: auto;
  transform-origin: 50% 16%;
  animation: glass-dolly var(--passage-duration) ease-out both var(--direction);
}

.passage-shadow, .passage-light {
  position: absolute;
  inset: 0;
}
.passage-shadow {
  background: radial-gradient(ellipse at 50% 27%, #1c110b5e 0%, #100906bd 48%, #090604f5 100%);
  animation: shadow-passage var(--passage-duration) linear both var(--direction);
}
.passage-light {
  background: radial-gradient(ellipse at 50% 13%, #f8b57342, transparent 57%);
  mix-blend-mode: screen;
  animation: light-passage var(--passage-duration) linear both var(--direction);
}

@keyframes bronze-dolly {
  0% { transform: scale(1); }
  11.1% { transform: scale(1.012); }
  47.2% { transform: scale(1.16) translateY(-.8%); }
  69.4%, 100% { transform: scale(1.26) translateY(-1.6%); }
}
@keyframes engraving-withdraw {
  0% { opacity: 0; }
  11.1% { opacity: .67; }
  47.2%, 100% { opacity: 1; }
}
@keyframes open-second-room {
  0%, 47.2% { opacity: 0; }
  69.4%, 100% { opacity: 1; }
}
@keyframes glass-dolly {
  0%, 47.2% { transform: scale(.94); }
  69.4% { transform: scale(.971); }
  100% { transform: translateY(calc(-1 * var(--departure-scroll, 0px))) scale(1); }
}
@keyframes shadow-passage {
  0%, 11.1%, 100% { opacity: 0; }
  47.2% { opacity: .56; }
  56.9% { opacity: .86; }
  69.4% { opacity: .50; }
}
@keyframes light-passage {
  0%, 100% { opacity: 0; }
  37% { opacity: .45; }
  56.9% { opacity: .72; }
  77% { opacity: .28; }
}

@media (prefers-reduced-motion: reduce) {
  #drop-room .glass-light, #drop-room.arriving .back, #drop-room.arriving #drop-phrase,
  #drop-room.arriving #first-drop-form, #drop-room.registered .floor-light { animation: none; }
  #first-drop-form, #drop-phrase { transition: none; }
  #engraved-confirmation.complete g, #engraved-confirmation.complete path { animation: none; }
  #engraved-confirmation.complete path { stroke-dashoffset: 0; }
}
