:root {
  color-scheme: dark;
  --paper: #f4e7ca;
  --muted: #c0c0b3;
  --background: #141a16;
  --serif: Georgia, "Times New Roman", serif;
  --edge: clamp(24px, 4vw, 64px);
  --floor-inset: max(28px, 4.2svh, env(safe-area-inset-bottom));
  --lighting-duration: 1000ms;
  font-family: var(--serif);
  color: var(--paper);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; min-width: 280px; overflow: hidden; overscroll-behavior: none; }
body { background: var(--background); transition: background-color var(--lighting-duration) ease; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--paper); outline-offset: 7px; }
::selection { color: #141a16; background: #e7d5ad; }

.den {
  position: relative;
  isolation: isolate;
  min-height: 480px;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  background: var(--background);
  transition: background-color var(--lighting-duration) ease;
}

.den::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  background: linear-gradient(to top, #07100dec 0%, #07100db0 13%, #07100d42 31%, transparent 50%);
  pointer-events: none;
}

.welcome {
  position: absolute;
  z-index: 3;
  left: max(var(--edge), env(safe-area-inset-left));
  bottom: var(--floor-inset);
  width: min(720px, calc(100% - var(--edge) * 2 - 140px));
  text-shadow: 0 2px 24px #0008;
  pointer-events: none;
}
h1 { margin: 0; font-weight: 700; font-size: clamp(52px, 6.6vw, 96px); letter-spacing: -.055em; line-height: 1; }
.invitation { margin: 16px 0 0; font-size: clamp(20px, 1.7vw, 26px); letter-spacing: -.035em; line-height: 1.3; }
.description { margin: 7px 0 0; color: var(--muted); font-size: clamp(16px, 1.25vw, 20px); letter-spacing: -.02em; line-height: 1.4; max-width: 27em; }

.room { position: absolute; z-index: 0; inset: 0; margin: 0; overflow: hidden; container-type: size; }
.room-plane {
  position: absolute;
  top: 0;
  right: 0;
  width: max(100vw, 150vh);
  width: max(100vw, 150svh);
  height: max(100vh, 66.666667vw);
  height: max(100svh, 66.666667vw);
}
@supports (width: 1cqw) {
  .room-plane { width: max(100cqw, 150cqh); height: max(100cqh, 66.666667cqw); }
}
.room-image {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  opacity: 0;
  transition: opacity var(--lighting-duration) ease;
  pointer-events: none;
  user-select: none;
}
.room-image:not([src]) { visibility: hidden; }
.room-image.is-active { opacity: 1; }

.fire-motion {
  display: block;
  position: absolute;
  z-index: 1;
  left: 37.760417%;
  top: 38.085938%;
  width: 11.067708%;
  height: 16.601563%;
  overflow: hidden;
  clip-path: polygon(10% 10%, 96% 10%, 100% 20%, 100% 94%, 0 94%, 0 20%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 81%, transparent 94%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 81%, transparent 94%);
  pointer-events: none;
  transition: opacity var(--lighting-duration) ease;
}
html[data-lighting="lamp"] .fire-motion,
html[data-lighting="off"] .fire-motion { opacity: 0; }

.mug-steam {
  position: absolute;
  z-index: 1;
  left: 84.114583%;
  top: 37.109375%;
  width: 5.208333%;
  height: 11.71875%;
  overflow: visible;
  pointer-events: none;
  transition: opacity var(--lighting-duration) ease;
}
.steam-wisp { opacity: 0; transform-origin: 40px 120px; animation: steam-rise 5.2s ease-in-out infinite; }
.steam-wisp--one { animation-delay: -1.6s; }
.steam-wisp--two { animation-name: steam-rise-right; animation-duration: 6.1s; animation-delay: -3.8s; }
.steam-wisp--three { animation-duration: 4.7s; animation-delay: -.2s; }
@keyframes steam-rise {
  0% { opacity: 0; transform: translate(0, 5px) scaleX(.7); }
  18% { opacity: .34; }
  52% { opacity: .29; }
  100% { opacity: 0; transform: translate(-6px, -46px) scaleX(1.3); }
}
@keyframes steam-rise-right {
  0% { opacity: 0; transform: translate(0, 5px) scaleX(.65); }
  22% { opacity: .3; }
  55% { opacity: .25; }
  100% { opacity: 0; transform: translate(8px, -53px) scaleX(1.4); }
}
html[data-lighting="fire"] .mug-steam { opacity: .7; }
html[data-lighting="off"] .mug-steam { opacity: .45; }
html[data-motion="paused"] .steam-wisp { animation-play-state: paused; }
.room-plane[data-scene-ready="false"] .fire-motion,
.room-plane[data-scene-ready="false"] .mug-steam { visibility: hidden; }

.light-switch {
  position: absolute;
  z-index: 2;
  padding: 0;
  border: 0;
  outline: 0;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  touch-action: manipulation;
}
.light-switch--fire { left: 36.6%; top: 38.9%; width: 14.5%; height: 21.3%; }
.light-switch--lamp { left: 87.6%; top: 31.9%; width: 10.6%; height: 22.6%; }
.light-switch:focus-visible { outline: 0; }
.light-switch:focus-visible::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 7px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 5px #0008;
}

.footer {
  position: absolute;
  z-index: 4;
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: var(--floor-inset);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 18px;
  line-height: 1.4;
}
.chat { display: inline-flex; align-items: center; gap: 24px; flex-shrink: 0; border-radius: 50px; }
.chat-label { font-size: 18px; }
.chat-bubble {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: #10181368;
  backdrop-filter: blur(6px);
  transition: background-color 200ms ease, color 200ms ease, transform 200ms ease;
}
.chat-bubble svg { width: 29px; height: 29px; }
.chat:hover .chat-bubble, .chat:focus-visible .chat-bubble { color: #171d19; background: var(--paper); transform: translateY(-3px); }
.chat:hover .chat-label { color: #fff7e5; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html[data-lighting="off"] { --background: #0c1217; --muted: #b5bbb9; }
html[data-lighting="lamp"] { --background: #111713; }
html[data-lighting="fire"] { --background: #141915; }

@media (min-aspect-ratio: 19/10) {
  .room-plane { width: 150svh; height: 100svh; }
  @supports (width: 1cqw) {
    .room-plane { width: 150cqh; height: 100cqh; }
  }
}

/* Copy rests over the foreground; no header, sidebar or footer panel. */
@media (max-width: 1024px), (max-aspect-ratio: 29/20), (hover: none) and (pointer: coarse) {
  :root {
    --edge: clamp(20px, 5vw, 36px);
    --floor-inset: max(24px, env(safe-area-inset-bottom));
  }
  .den {
    min-height: 0;
  }
  .welcome {
    right: max(var(--edge), env(safe-area-inset-right));
    width: auto;
  }
  h1 { font-size: clamp(38px, 12.5vw, 68px); }
  .invitation { margin: 11px 0 0; font-size: clamp(17px, 4.4vw, 22px); }
  .description { margin: 6px 0 0; font-size: clamp(14.5px, 3.8vw, 17px); max-width: min(27em, calc(100% - 72px)); }
  .chat { gap: 0; }
  .chat-label { display: none; }
  .chat-bubble { width: 48px; height: 48px; background: #101813a8; }
  .chat-bubble svg { width: 23px; height: 23px; }

  @media (orientation: portrait) {
    .den { min-height: 0; }
    .den::after {
      background:
        linear-gradient(to top, #07100df7 0%, #07100dc7 16%, #07100d70 32%, transparent 57%),
        linear-gradient(to bottom, #07100d82 0%, transparent 20%);
    }
    .room-plane {
      top: 0;
      right: auto;
      left: 0;
      width: 150svh;
      height: 100svh;
      transform: translate3d(var(--room-pan-x, 0px), 0, 0);
      -webkit-mask-image: none;
      mask-image: none;
      will-change: transform;
    }
    @supports (width: 1cqw) {
      .room-plane { width: 150cqh; height: 100cqh; }
    }
    .room { touch-action: pan-y; cursor: grab; }
    .room.is-dragging { cursor: grabbing; }
    .room.is-dragging .room-plane { transition: none; }
    .welcome { bottom: var(--floor-inset); }
  }

  @media (orientation: portrait) and (max-height: 620px) {
    :root { --floor-inset: max(18px, env(safe-area-inset-bottom)); }
    h1 { font-size: 36px; }
    .invitation { margin-top: 8px; }
    .description { margin-top: 4px; font-size: 14px; line-height: 1.35; }
  }

  @media (orientation: landscape) {
    :root { --edge: clamp(20px, 4vw, 44px); }
    .welcome { width: min(560px, calc(100% - var(--edge) * 2 - 64px)); }
    h1 { font-size: clamp(38px, 5.5vw, 72px); }
    .invitation { font-size: clamp(17px, 2vw, 22px); }
    .description { font-size: clamp(14.5px, 1.65vw, 18px); max-width: 27em; }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    :root { --floor-inset: max(20px, env(safe-area-inset-bottom)); }
    .welcome { width: min(460px, calc(100% - var(--edge) * 2 - 64px)); }
    h1 { font-size: clamp(36px, 5.3vw, 50px); }
    .invitation { margin-top: 9px; }
  }
}

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