@import url('./birthdayInteractions.css');
@font-face{font-family:"Instrument Sans";src:url('./fonts/sans.ttf') format('truetype');font-weight:400 700;font-display:swap}
@font-face{font-family:"Barlow Condensed";src:url('./fonts/barlow-condensed-semibold.ttf') format('truetype');font-style:normal;font-weight:600;font-display:swap}
@font-face{font-family:"Spectral";src:url('./fonts/spectral-medium-italic.ttf') format('truetype');font-style:italic;font-weight:500;font-display:swap}
@font-face{font-family:"IBM Plex Mono";src:url('./fonts/mono.ttf') format('truetype');font-weight:400;font-display:swap}

:root{
  color-scheme:dark;
  --paper:#f5f1df;
  --gold:#ffdf8b;
  --ink:#192923;
  --edge:clamp(22px,2.65vw,58px);
  --mono:"IBM Plex Mono",monospace;
  --sans:"Instrument Sans",Arial,sans-serif;
  --display:"Barlow Condensed","Arial Narrow",sans-serif;
  --voice:500 italic 1rem/1.25 "Spectral",Georgia,serif;
  font-family:var(--sans);
  color:var(--paper);background:#1e2924;
}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;overflow:hidden}
button,a{font:inherit;color:inherit}
button{cursor:pointer}
button:focus-visible,a:focus-visible,summary:focus-visible{outline:2px solid currentColor;outline-offset:4px}
[hidden]{display:none!important}
#world-canvas{display:block;touch-action:none;cursor:grab}
/* Returning to the first hall goes dark, then lets it gather again. */
#lap-blackout{position:fixed;inset:0;z-index:7;background:#000;opacity:0;pointer-events:none;transition:opacity .62s ease-out}
#lap-blackout.is-on{opacity:1;transition:opacity .26s linear}
@media (prefers-reduced-motion:reduce){#lap-blackout{transition:none}}
/* Every arrival through the portal opens on black with these two lines, in the story's own voice. */
#lap-note{
  position:fixed;inset:0;z-index:7;margin:0;padding:24px;display:grid;place-content:center;gap:.3em;
  color:#fff8e5;text-align:center;text-shadow:0 1px 3px #000,0 0 14px #000;
  font:700 clamp(26px,2.7vw,46px)/1.22 "Gaegu",var(--sans);
  pointer-events:none;user-select:none;-webkit-user-select:none;
  opacity:0;transition:opacity .7s ease-out;
}
#lap-note span{display:block}
#lap-note.is-on{opacity:1;transition:opacity .5s ease-out .3s}
#world-canvas:active{cursor:grabbing}
#world-canvas:focus{outline:none}
body[data-ready="true"] #world-canvas{cursor:none}
#caption,#status,#retry{position:fixed;z-index:2}
#caption{inset:0;z-index:3;pointer-events:none}
.chapter-title{
  position:absolute;left:var(--edge);bottom:max(env(safe-area-inset-bottom),clamp(22px,4vh,54px));
  max-width:calc(100% - var(--edge)*2);isolation:isolate;
}
.chapter-title::before{
  content:"";position:absolute;z-index:-1;inset:-42% -22% -78% calc(-1 * var(--edge));pointer-events:none;
  background:radial-gradient(ellipse at 27% 64%,#17221d5c,transparent 71%);
}
.chapter-title h1{
  margin:0;color:#fff8e5;font:700 clamp(44px,4.2vw,82px)/.98 "Gaegu",var(--sans);letter-spacing:-.025em;
  text-shadow:0 1px 3px #17231e99,0 2px 10px #1927205c;
}
/* The field guide opens from a little envelope: hovering flips its flap up and
   lifts the letter, and a click slides a card out of the envelope mouth and
   grows it into the guide. */
@property --envelope-progress{
  syntax:"<number>";
  inherits:true;
  initial-value:0;
}
#envelope{
  position:absolute;right:var(--edge);bottom:max(env(safe-area-inset-bottom),clamp(22px,4vh,54px));
  width:clamp(96px,8.2vw,128px);aspect-ratio:900 / 540;padding:0;border:0;background:none;pointer-events:auto;cursor:pointer;
  line-height:0;touch-action:manipulation;user-select:none;-webkit-user-select:none;
  transform:rotate(3deg);transition:transform .18s ease-out;
}
#envelope .paper-assembly{
  --envelope-progress:0;
  --turn:clamp(0,calc(var(--envelope-progress) / .62),1);
  --rise:clamp(0,calc((var(--envelope-progress) - .45) / .55),1);
  transition:--envelope-progress 900ms cubic-bezier(.35,.04,.28,1);
  filter:drop-shadow(0 6px 10px #0b15184d);
}
#envelope:hover .paper-assembly,#envelope:focus-visible .paper-assembly,#envelope.is-open .paper-assembly{--envelope-progress:1}
#envelope .paper-assembly,#envelope .lining,#envelope .pocket,#envelope .heart,#envelope .face,#envelope .face img,#envelope .fold{
  position:absolute;inset:0;display:block;width:100%;height:100%;pointer-events:none;
}
/* The front of the pocket masks the lower half of the letter. */
#envelope .letter-well{position:absolute;inset:0;clip-path:inset(-70% 3% 4%);pointer-events:none}
#envelope .letter{
  display:block;position:absolute;left:11%;top:calc(8% - 40% * var(--rise));width:78%;height:auto;
  filter:url(#envelope-letter-tint);transform:rotate(calc(-2.7deg * var(--rise)));transform-origin:50% 80%;pointer-events:none;
}
#envelope .hinge{
  position:absolute;inset:0 0 auto;display:block;aspect-ratio:900 / 305;
  perspective:1000px;perspective-origin:50% 0;pointer-events:none;
}
#envelope .fold{transform-style:preserve-3d;transform-origin:50% 0;transform:rotateX(calc(166deg * var(--turn)))}
#envelope .face{backface-visibility:hidden;-webkit-backface-visibility:hidden}
#envelope .outer{transform:translateZ(.1px)}
#envelope .inner{transform:rotateY(180deg) translateZ(.1px)}
#envelope .inner img{transform:scaleX(-1)}
/* The open flap extends the hover target without moving the pocket. */
#envelope::before{content:"";position:absolute;inset:-61% -2% 99%;clip-path:polygon(0 100%,48% 0,53% 0,100% 100%);pointer-events:none}
#envelope:hover::before,#envelope.is-open::before{pointer-events:auto}
#envelope:hover{transform:rotate(1deg) translateY(-3px)}
#envelope:active{transform:rotate(3deg) translateY(1px)}
#envelope:focus-visible{outline:3px dashed var(--gold);outline-offset:6px;border-radius:12px}
#envelope.is-open{transform:rotate(-1deg) translateY(3px) scale(.96)}
body:has(dialog[open]) #envelope{visibility:hidden}
@media (prefers-reduced-motion:reduce){#envelope .paper-assembly{transition:none}}
/* A hand-drawn sound switch sits in the top-right corner: cream ink on the
   scene itself, with no card behind it. */
#sound-toggle{
  position:fixed;z-index:4;top:max(env(safe-area-inset-top),var(--edge));right:var(--edge);
  display:inline-flex;align-items:center;gap:.42em;min-height:44px;padding:5px 8px 6px 4px;
  border:0;background:none;color:#fff8e5;
  font:700 clamp(19px,1.4vw,23px)/1 "Gaegu",var(--sans);
  text-shadow:0 1px 3px #17231e,0 1px 7px #192720d9;
  transition:transform .16s ease-out,color .16s ease-out;
}
#sound-toggle:hover{color:#fff0c9;transform:translateY(-2px)}
#sound-toggle:active{transform:translateY(1px)}
#sound-toggle:focus-visible{outline:3px dashed var(--gold);outline-offset:5px;border-radius:12px}
#sound-toggle svg{width:1.45em;height:1.45em;flex:none;overflow:visible;filter:drop-shadow(0 1px 2px #17231e)}
#sound-toggle svg path{fill:none;stroke:currentColor;stroke-width:3.6;stroke-linecap:round;stroke-linejoin:round}
#sound-toggle .sound-body{fill:currentColor;stroke-width:2.6}
#sound-toggle[aria-pressed="true"] .sound-cross,
#sound-toggle[aria-pressed="false"] .sound-waves{display:none}
/* The shader panel opens below the switch instead of covering it. */
body .lil-gui.autoPlace{top:calc(max(env(safe-area-inset-top),var(--edge)) + 60px)}
#music-cue{
  position:absolute;bottom:100%;left:0;min-height:32px;padding:0 .15em;
  border:0;background:none;color:#fff8e5;pointer-events:auto;
  font:700 clamp(19px,1.45vw,24px)/1.2 "Gaegu",var(--sans);
  text-shadow:0 1px 3px #17231e,0 1px 7px #192720d9;
}
.folio,.sr-only{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.story-conversation{
  position:absolute;top:clamp(88px,17vh,176px);left:50%;transform:translateX(-50%);
  width:min(32rem,62vw);display:flex;flex-direction:column;gap:.5rem;text-shadow:none;
}
.story-sheet{
  margin:0;align-self:center;width:max-content;max-width:min(22rem,83%);padding:.34em .72em .39em;
  border:none;border-radius:15px;background:#fffcf6;color:#2a3c3c;
  box-shadow:0 2px 7px #273a371c;font:400 clamp(22px,1.65vw,29px)/1.08 "Gaegu",var(--sans);
  text-align:left;text-wrap:pretty;overflow-wrap:anywhere;
}
.story-sheet[data-speaker="me"]{align-self:flex-start}
.story-sheet[data-speaker="eve"]{align-self:flex-end;background:#eff7f3;color:#263f40}
.story-sheet[data-speaker-name]:not([data-speaker-name=""])::before{
  content:attr(data-speaker-name);display:block;width:fit-content;margin:0 0 .16em;
  font:700 clamp(16px,1.05vw,19px)/1 "Gaegu",var(--sans);color:#765341;
}
.story-sheet[data-speaker="eve"]::before{color:#385e55}
.story-sheet:empty{display:none}
/* Whoever spoke first keeps the upper row while it fades, so the reply
   always reads underneath it. */
.story-conversation .birthday-message{
  position:absolute;top:0;bottom:auto;left:50%;right:auto;transform:translateX(-50%);
  z-index:1;display:flex;align-items:center;gap:.5em;max-width:100%;
}
.story-conversation .birthday-message img{width:2.15em;height:1.75em;border-radius:4px}
body:has(dialog[open]) .story-conversation{visibility:hidden}
kbd{font:400 .82em/1 var(--mono);font-variant-numeric:tabular-nums}
#manual .guide-chapters{margin:0 0 10px;border-block:2px dashed #dcc894;padding:6px 0}
#manual .guide-chapters summary{cursor:pointer;font:700 1.2rem/1.15 "Gaegu","Bradley Hand","Segoe Print",cursive;width:fit-content}
#manual #chapters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px 12px;padding-top:7px}
#manual .chapter{
  display:flex;gap:.5em;align-items:center;border:0;text-align:left;background:transparent;
  padding:3px 6px;border-radius:9px 12px 8px 13px/12px 8px 13px 9px;color:#2b3a33;
  font:400 1.04rem/1.15 "Gaegu","Bradley Hand","Segoe Print",cursive;
}
#manual .chapter::before{
  content:attr(data-number);display:inline-grid;place-items:center;min-width:2em;padding:.06em .3em;
  border:2px solid #2b3a33;border-radius:50% 46% 52% 48%/48% 52% 46% 50%;
  background:#f4c53d;color:#2b3a33;font:700 .84em/1.1 "Gaegu","Bradley Hand","Segoe Print",cursive;
}
#manual .chapter:nth-child(3n+2)::before{background:#ef8fb1}
#manual .chapter:nth-child(3n)::before{background:#6fc3a2}
#manual .chapter[aria-current="step"]{font-weight:700;background:#fff}
#manual .chapter:hover,#manual .chapter:focus-visible{background:#fff}
#status,#retry{top:50%;left:50%;transform:translate(-50%,-50%);padding:8px 13px;background:#192822ee;color:var(--paper);font:400 .85rem/1.4 var(--mono)}
#retry{margin-top:46px;border:1px solid var(--gold)}
[data-ready] #status:not(.loading){display:none}

dialog{max-width:calc(100vw - 48px);max-height:calc(100dvh - 64px);overflow:auto;overscroll-behavior:contain}
dialog::backdrop{background:rgba(9,21,18,.46)}
#manual[open]::backdrop{animation:card-backdrop .5s ease-out both}
@keyframes card-backdrop{from{background:rgba(9,21,18,0)}to{background:rgba(9,21,18,.46)}}
#memory-inspect{color:var(--ink);background:#e9e6d1;border:1px solid #b7ba9d;border-top:3px solid #d4b859;box-shadow:0 18px 90px #0b15184d;color-scheme:light}
/* The field guide is a child's birthday card: cream card stock, pencil
   outlines, crayon colours and Gaegu handwriting throughout. */
#manual{
  width:min(560px,92vw);max-height:calc(100dvh - 32px);
  padding:30px clamp(24px,2.8vw,40px) 14px;
  color:#2b3a33;background:url('./resources/ui/bunting.svg') top center/200px 34px repeat-x,#fff8e4;
  border:3px solid #2b3a33;border-radius:26px 30px 24px 32px/30px 24px 32px 26px;
  outline:2px dashed #e7cf9c;outline-offset:-10px;
  box-shadow:0 22px 60px #0b151866;color-scheme:light;
  font-family:"Gaegu","Bradley Hand","Segoe Print",cursive;
  transform:rotate(-.4deg);
}
.guide-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.guide-head h2,#memory-name{margin:0;font:600 clamp(34px,3.3vw,55px)/.96 var(--display);text-transform:uppercase;letter-spacing:-.018em}
#manual .guide-head h2{
  font:700 clamp(34px,3.1vw,48px)/.95 "Gaegu","Bradley Hand","Segoe Print",cursive;
  text-transform:none;letter-spacing:0;color:#2b3a33;
  transform:rotate(-1.6deg);transform-origin:left bottom;
}
#manual .guide-head h2::after{
  content:"";display:block;width:min(100%,6.2em);height:8px;margin-top:.08em;
  background:url('./resources/ui/swash.svg') left center/100% 100% no-repeat;
}
.guide-intro{margin:15px 0 18px;font:var(--voice);font-size:1.13rem;color:#31453b}
#manual .guide-intro{margin:10px 0 12px;font:400 1.08rem/1.26 "Gaegu","Bradley Hand","Segoe Print",cursive;color:#3c5145}
.close-link,#memory-close{border:0;background:transparent;text-decoration:underline;text-underline-offset:4px;font:400 .875rem/1.25 var(--mono);padding:4px 0}
#manual .close-link{
  border:2.5px solid #2b3a33;border-radius:120px 12px 110px 12px/12px 110px 12px 120px;
  background:#fff;color:#2b3a33;font:700 1.06rem/1 "Gaegu","Bradley Hand","Segoe Print",cursive;
  padding:7px 14px 8px;text-decoration:none;box-shadow:0 2px 0 #14201b26;transform:rotate(1.6deg);
}
#manual .close-link:hover{background:#f4c53d}
#manual dl{margin:0;display:grid;grid-template-columns:1fr auto}
#manual dt,#manual dd{margin:0;border-bottom:2px dashed #e6d5ab;padding:1px 0;line-height:1.18;font-family:"Gaegu","Bradley Hand","Segoe Print",cursive}
#manual dt{font-size:1.06rem}
#manual dd{text-align:right;font-size:1rem;color:#4f6356}
#manual kbd{
  display:inline-block;min-width:1.55em;text-align:center;border:2px solid #2b3a33;
  border-radius:7px 9px 6px 10px/9px 6px 10px 7px;padding:.02em .28em .1em;
  background:#fff;box-shadow:0 2px 0 #14201b2e;font:700 .86em/1.1 "Gaegu","Bradley Hand","Segoe Print",cursive;
}
.guide-note{font-size:.94rem;line-height:1.4;color:#384d40;margin:15px 0}
#manual .guide-note{
  position:relative;margin:10px 0;padding:8px 12px 9px 52px;
  border:2px dashed #dcc894;border-radius:14px 18px 12px 20px/18px 12px 20px 14px;background:#fff;
  font:400 1.04rem/1.3 "Gaegu","Bradley Hand","Segoe Print",cursive;color:#3c5145;
}
#manual .guide-note::before{
  content:"";position:absolute;left:12px;top:50%;width:30px;height:23px;
  transform:translateY(-50%) rotate(-6deg);
  background:url('./resources/ui/boat.svg') center/contain no-repeat;
}
.guide-links{padding-top:10px;border-top:1px solid #78857494;display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}
.guide-links button{font-size:.875rem;font-weight:600;text-decoration:underline;text-underline-offset:4px}
.guide-links button{border:0;padding:5px 0;background:transparent}
#manual .guide-links{padding-top:9px;border-top:2px dashed #dcc894;gap:10px}
#manual .guide-links button{
  border:2.5px solid #2b3a33;border-radius:120px 12px 110px 12px/12px 110px 12px 120px;
  background:#fff;color:#2b3a33;font:700 1.02rem/1 "Gaegu","Bradley Hand","Segoe Print",cursive;
  padding:7px 13px 8px;text-decoration:none;box-shadow:0 2px 0 #14201b26;
}
#manual .guide-links button:hover{background:#f4c53d}
#pocket-slot{color:#475d4e;font:400 1rem/1.3 var(--sans);margin:0 0 14px}
#manual #pocket-slot{
  margin:0 0 12px;padding:6px 11px;border:2px dashed #f0914a;
  border-radius:12px 16px 10px 18px/16px 10px 18px 12px;background:#fff;
  color:#2b3a33;font:700 1.06rem/1.25 "Gaegu","Bradley Hand","Segoe Print",cursive;
}
#memory-close:hover{color:#836320}

#point-reticle,#point-coordinates{position:fixed;left:0;top:0;z-index:2;pointer-events:none}
#point-reticle::before,#point-reticle::after{content:"";position:absolute;background:#f7f4e6e6;box-shadow:0 0 2px #081011}
#point-reticle::before{width:9px;height:1px;left:-4.5px;top:-.5px}
#point-reticle::after{width:1px;height:9px;left:-.5px;top:-4.5px}
#point-coordinates{color:#fff9de;white-space:pre;font:400 .75rem/1.2 var(--mono);text-shadow:0 1px 3px #060e0b,0 0 3px #060e0b}
.lil-gui{z-index:6}

#memory-marker{
  position:fixed;z-index:3;width:20px;height:20px;transform:translate(-50%,-50%);padding:0;
  border:0;background:none;overflow:visible;color:#fffaf0;
}
.memory-label{
  position:absolute;display:flex;align-items:center;left:50%;bottom:calc(50% + 5px);min-height:32px;
  padding:2px 5px;isolation:isolate;white-space:nowrap;
  font:700 clamp(19px,1.4vw,25px)/1.08 "Gaegu",var(--sans);
  text-shadow:0 1px 2px #172520,0 0 5px #253c38,0 1px 10px #243a32;
}
.memory-label::before{
  content:"";position:absolute;z-index:-1;inset:0 -6px;
  background:radial-gradient(ellipse at center,#1f342c64,transparent 73%);pointer-events:none;
}
#memory-marker[data-side="left"] .memory-label{left:auto;right:50%}
#memory-marker:focus-visible{outline:none}
#memory-marker:hover .memory-verb{color:#fff0c9}
#memory-marker:active .memory-verb{color:#ffe5af}
#memory-marker:focus-visible .memory-label{outline:2px solid currentColor;outline-offset:2px;border-radius:4px}
#memory-inspect{padding:0;width:min(466px,88vw)}
.memory-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 24px}
#memory-place{font:400 .75rem/1.2 var(--mono);color:#415747;text-transform:uppercase;letter-spacing:.06em}
.memory-plate{background:radial-gradient(ellipse at 50% 80%,#2b4237,#172c25 85%);position:relative;overflow:hidden;line-height:0}
#memory-study{width:100%;height:auto;aspect-ratio:640/340;display:block;cursor:grab;touch-action:none}
#memory-study:active{cursor:grabbing}
.memory-turn{position:absolute;right:12px;bottom:9px;pointer-events:none;color:#d7dec7;font:400 .75rem/1.25 var(--mono);text-shadow:0 1px 3px #10251d}
.memory-copy{padding:20px 24px 24px}
#memory-name{font-size:clamp(32px,2.9vw,48px);line-height:.96}
#memory-text{font:var(--voice);font-size:1.14rem;margin:.68em 0 .8em;color:#31483a}
#memory-action{border:1px solid var(--ink);padding:8px 14px;background:#22392b;color:#fff4c9;font:500 .9rem/1.1 var(--sans)}
#memory-action:hover{background:#394c37}
#memory-action:focus-visible{outline-color:#233b29}
body.hidden-ui :is(#caption,#memory-marker){visibility:hidden}
body[data-opening="waiting"] #caption{visibility:hidden}
@media(max-height:680px){
  .story-conversation{top:clamp(58px,14vh,94px)}
  #manual{padding-top:36px;padding-bottom:12px}
  #manual dt,#manual dd{padding-block:1px}
  .guide-intro,.guide-note{margin-block:10px}
}
@media(max-width:850px){
  .story-conversation{width:min(30rem,82vw)}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}

#opening-invite{
  position:absolute;left:50%;bottom:21%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 38px);
  min-height:44px;padding:4px 11px;border:0;background:transparent;color:#fff8e5;
  text-shadow:0 1px 3px #101826,0 0 8px #101826;
  font:700 clamp(20px,1.8vw,26px)/1.15 "Gaegu",var(--sans);pointer-events:auto;
}
body:has(dialog[open]) #opening-invite{visibility:hidden}
#opening-invite:not([data-sound="tap"]) .with-sound,
body[data-opening="sparse"]:has(#opening-invite[data-sound="tap"]) #music-cue{display:none}
.touch-copy,#manual .touch-guide{display:none}
@media (pointer:coarse){
  .mouse-copy,#manual .mouse-guide{display:none}
  .touch-copy{display:inline}
  #manual .touch-guide{display:grid;grid-template-columns:minmax(0,.95fr) minmax(0,1.18fr)}
  #manual .touch-guide :is(dt,dd){padding-block:10px}
  #manual .close-link,#manual .chapter,#manual .guide-links button,#manual summary{min-height:44px;align-content:center}
  #point-coordinates,#point-reticle{display:none}
}
