/* Bespoke storybook composition in coral pencil, cream and powder blue. */
:root {
  color-scheme: light;
  --paper: #cee4ec;
  --paper-light: #dbecf0;
  --paper-edge: #bdd8e3;
  --ivory: #fbf3e3;
  --blush: #f1d3c6;
  --ink: #8b3833;
  --ink-soft: #754541;
  --rule: #a0524b80;
  --rule-faint: #a0524b38;
  --shadow: #38596e28;
  --sky: #233454b8;
  --blue: #34567d6b;
  --snow-blue: #46648525;
  --star: #ffedcb;
  --lamp-spill: #f8c27343;
  --rabbit-paper: #f6ecdb;
  --hamster-paper: #f9ead5;
  --font: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --hand: 'Segoe Print', 'Bradley Hand', 'Apple Chancery', var(--font);
  --scene-ratio: 1105 / 1347;
  --dusk: 1.65s;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at 48% 37%, var(--paper-light), var(--paper) 67%, var(--paper-edge) 140%);
  font-family: var(--font);
}
body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: '';
  background: url('assets/paper.svg');
  mix-blend-mode: multiply;
  opacity: .20;
}
button { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.world {
  --globe-width: min(594px, calc((100svh - 133px) * .82), calc(100vw - 63px));
  position: relative;
  display: grid;
  grid-template-areas: 'scene' 'controls';
  align-content: center;
  justify-items: center;
  gap: 18px;
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px 15px;
  overflow: hidden;
}
.scene { grid-area: scene; position: relative; width: max(194px, var(--globe-width)); aspect-ratio: var(--scene-ratio); margin: 0; container-type: inline-size; }
.contact-shadow {
  position: absolute;
  inset: auto 5% -1.6%;
  height: 4%;
  background: radial-gradient(ellipse, var(--shadow), transparent 70%);
  filter: blur(3px);
  pointer-events: none;
}
.globe {
  --tilt: 0deg;
  --slide: 0px;
  position: absolute;
  inset: 0;
  transform: translateX(var(--slide)) rotate(var(--tilt));
  transform-origin: 50% 96%;
  user-select: none;
  -webkit-user-select: none;
  container-type: inline-size;
}
.globe-art, .night-art, .night-art img, .night-sky, .stars, .snow, .still-snow, .glass-touch {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.in-glass { clip-path: url('#glass'); }
.night-art, .night-sky, .stars, .lamplight { opacity: 0; transition: opacity var(--dusk) ease-in-out; }
.night-art img { filter: brightness(.73) saturate(.73); }
.night-sky { background: linear-gradient(173deg, var(--sky) 5%, var(--blue) 47%, var(--snow-blue) 78%); }
.stars { fill: var(--star); }
.lamplight { position: absolute; left: 62.986%; top: 45.286%; width: 15.023%; height: 13.660%; pointer-events: none; }
.lamplight::before { content: ''; position: absolute; inset: 22% -25% -38%; background: radial-gradient(ellipse at 49% 55%, var(--lamp-spill), transparent 72%); }
.lamplight img { position: relative; display: block; width: 100%; height: 100%; }
[data-light='night'] :is(.night-art, .night-sky) { opacity: 1; }
[data-light='night'] .stars { opacity: .88; transition-delay: .25s; }
[data-light='night'] .lamplight { opacity: .94; }

.companion {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: end center;
  width: max(var(--animal-width), 44px);
  height: max(var(--animal-height), 44px);
  transform: translateX(-50%);
  border: 0;
  border-radius: 42%;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.companion.rabbit { --animal-width: 11%; --animal-height: 13.9%; --eye-ink: var(--rabbit-paper); left: 4.3%; bottom: 3.4%; }
.companion.hamster { --animal-width: 9%; --animal-height: 9.3%; --eye-ink: var(--hamster-paper); left: 95%; bottom: 2.8%; }
.animal-art { display: block; position: absolute; bottom: 0; height: min(100%, 17cqw); transform-origin: 50% 97%; pointer-events: none; }
.animal-art img { display: block; height: 100%; }
.hamster .animal-art { height: min(100%, 11.2cqw); }
.animal-ground { position: absolute; left: -4%; right: -8%; bottom: -7%; height: 19%; background: radial-gradient(ellipse, var(--shadow), transparent 72%); pointer-events: none; }
.blink { position: absolute; display: block; width: 9%; height: 5.8%; border-radius: 50%; background: var(--eye-ink); opacity: 0; }
.blink::after { position: absolute; content: ''; inset: 44% 14% 25%; border-top: 1px solid var(--ink-soft); border-radius: 50%; transform: rotate(-9deg); }
.rabbit .blink { left: 71%; top: 45.1%; }
.hamster .blink { left: 27.1%; top: 30.7%; }

.snow, .still-snow { z-index: 3; }
.still-snow {
  opacity: 0;
  background:
    radial-gradient(circle at 39% 26%, var(--ivory) 0 1px, transparent 1.6px),
    radial-gradient(circle at 54% 16%, var(--ivory) 0 1px, transparent 1.5px),
    radial-gradient(circle at 58% 39%, var(--ivory) 0 1.2px, transparent 1.9px),
    radial-gradient(circle at 78% 32%, var(--ivory) 0 1.2px, transparent 1.9px),
    radial-gradient(circle at 28% 40%, var(--ivory) 0 1px, transparent 1.7px),
    radial-gradient(circle at 33% 56%, var(--ivory) 0 1.1px, transparent 1.8px);
}
.glass-touch { z-index: 4; pointer-events: auto; cursor: grab; touch-action: none; }
.glass-touch:active { cursor: grabbing; }
.hotspot, .plaque { position: absolute; z-index: 5; border: 0; cursor: pointer; touch-action: manipulation; }
.hotspot { width: max(11%, 44px); height: max(9%, 44px); padding: 0; background: none; border-radius: 50%; transform: translate(-50%, -50%); }
.hotspot.window { top: 52.2%; left: 70.7%; }
.hotspot:focus-visible { box-shadow: 0 0 0 3px var(--ivory); outline-offset: 1px; }
.plaque {
  top: 87.8%;
  left: 49%;
  width: 29%;
  min-height: 44px;
  transform: translate(-50%, -50%);
  padding: 0;
  background: none;
  border-radius: 45%;
  font-size: clamp(14px, 4.35cqw, 24px);
  font-style: italic;
  line-height: 1;
  white-space: nowrap;
}

.controls { grid-area: controls; z-index: 2; display: grid; justify-items: center; gap: 3px; }
.hint { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.15; font-style: italic; transition: opacity .7s ease, visibility .7s; }
.hint.dismissed { opacity: 0; visibility: hidden; }
.tools { display: flex; align-items: center; gap: 11px; }
.tool-rule { height: 17px; width: 1px; background: var(--rule); }
.tool { display: inline-flex; align-items: center; min-height: 44px; gap: 7px; padding: 3px 6px; border: 0; border-radius: 3px; background: none; color: var(--ink-soft); cursor: pointer; touch-action: manipulation; font-size: 15px; }
.dial { display: grid; width: 31px; height: 31px; place-items: center; border: 1px solid var(--rule); border-radius: 46% 52% 47% 51%; transition: background-color .25s ease; }
.dial svg { grid-area: 1 / 1; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
.dial .sun, [data-light='night'] .dial .moon { opacity: 0; }
[data-light='night'] .dial .sun { opacity: 1; }
.dial .sun, .dial .moon { transition: opacity .35s ease; }
.tool[aria-pressed='true'] .dial { background: var(--ivory); }
@media (hover: hover) {
  .tool:hover .dial { background: var(--ivory); }
  .plaque:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
}

.note {
  width: min(328px, calc(100vw - 42px));
  max-height: calc(100svh - 32px);
  margin: auto;
  padding: 24px 23px 29px;
  border: 1px solid var(--rule);
  outline: 1px solid var(--rule-faint);
  outline-offset: -7px;
  background: radial-gradient(ellipse at 50% 0%, var(--ivory) 45%, var(--blush));
  color: var(--ink);
  text-align: center;
  box-shadow: 0 12px 36px var(--shadow);
}
.note[open] { animation: unfold .36s cubic-bezier(.22,.72,.25,1) both; }
.note::backdrop { background: var(--shadow); }
.note-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; padding: 12px; border: 0; background: transparent; cursor: pointer; }
.note-close svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; }
.note-sprig { display: block; margin: 0 auto 10px; transform: rotate(-12deg); }
.note p { margin: 0; font-family: var(--hand); font-size: 17px; line-height: 1.7; }
.note .signature { margin-top: 15px; font-size: 16px; }
@keyframes unfold { from { opacity: 0; transform: translateY(7px) rotate(-1deg); } to { opacity: 1; transform: none; } }

@media (max-width: 650px) {
  .world { --globe-width: min(440px, calc(100vw - 47px), calc((100svh - 121px) * .82)); gap: 16px; }
}
@media (orientation: landscape) and (max-height: 535px) {
  .world {
    --globe-width: min(calc((100svh - 34px) * .82), 56vw);
    grid-template-areas: 'scene controls';
    grid-template-columns: auto auto;
    justify-content: center;
    align-items: center;
    column-gap: clamp(40px, 8vw, 90px);
    padding: 15px 26px;
  }
  .scene { align-self: center; width: max(146px, var(--globe-width)); }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dusk: .35s; }
  .still-snow { opacity: .55; }
  .note[open] { animation: none; }
  .stars { transition-delay: 0s !important; }
  .hint { transition-duration: .25s; }
}
