/* The House — opening sequence, letter, map/guide and HUD. Everything here sits above the three.js canvas. */
:root{
  --ink:#2a1a10; --ink-soft:#5b4331; --cream:#efe6d2; --parch:#e9dcbd; --parch-deep:#d3bf94; --brass:#c9a35a; --night:#0d0a08;
  --serif:"Cormorant Garamond","Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  --hand:"Mrs Saint Delafield","Snell Roundhand","Apple Chancery",cursive;
}
body.intro-on #hud, body.intro-on #bar, body.intro-on #tip, body.intro-on #load,
body.play #hud, body.play #bar, body.play #tip, body.play #load,
body.cine #hud, body.cine #bar, body.cine #tip, body.cine #load{display:none !important}

#intro{position:fixed;inset:0;z-index:50;background:var(--night);overflow:hidden;transition:opacity .8s ease, visibility 0s linear .8s, background 2.4s ease}
#intro.gone{opacity:0;visibility:hidden;pointer-events:none}
/* behind the letter is the real front door: a screenshot (#still) until the house has loaded, then the live view itself.
   The opening layer is black while the signature is written and clears to show the door. */
#intro.envelope, #intro.letter, #intro.map, #intro.opening{background:rgba(13,10,8,0)}
#intro.envelope::before, #intro.letter::before, #intro.map::before{content:"";position:absolute;inset:0;background:radial-gradient(120% 100% at 50% 45%, rgba(0,0,0,.18) 30%, rgba(0,0,0,.62) 100%);pointer-events:none}
#intro.opening #letter, #intro.opening #sig{opacity:0 !important;transition:opacity .6s ease !important}
#motes{position:absolute;inset:0;pointer-events:none;opacity:0;transition:opacity 3s}
#intro.envelope #motes, #intro.letter #motes, #intro.map #motes{opacity:1}
#motes i{position:absolute;width:var(--s);height:var(--s);border-radius:50%;background:rgba(255,224,170,.55);filter:blur(.6px);animation:mote linear infinite}
@keyframes mote{0%{transform:translate(0,0);opacity:0}15%{opacity:.8}50%{transform:translate(26px,-48px)}85%{opacity:.6}100%{transform:translate(-14px,-110px);opacity:0}}

/* film dressing above everything: grain, vignette, letterbox bars, fade-to-black for cuts, title card */
#film{position:fixed;inset:0;z-index:70;pointer-events:none}
#grain{position:absolute;inset:-100px;opacity:.07;animation:grain 1.1s steps(6) infinite;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)'/%3E%3C/svg%3E")}
@keyframes grain{0%{transform:translate(0,0)}20%{transform:translate(-40px,22px)}40%{transform:translate(30px,-50px)}60%{transform:translate(-62px,-18px)}80%{transform:translate(48px,40px)}100%{transform:translate(0,0)}}
#vig{position:absolute;inset:0;background:radial-gradient(120% 100% at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.5) 100%);opacity:1;transition:opacity 2s}
body.play #vig{opacity:0} body.play #grain{opacity:.035}
#film .bar{position:absolute;left:0;right:0;height:max(0px, calc((100vh - 100vw / 2.39) / 2));min-height:7vh;background:#000;transition:transform 1.8s cubic-bezier(.6,.02,.2,1)}
#film .bar.t{top:0} #film .bar.b{bottom:0}
#film .bar{display:none}   /* no letterbox: the signature and the walk in play full frame */
body.play #film .bar.t, body.reading #film .bar.t{transform:translateY(-101%)} body.play #film .bar.b, body.reading #film .bar.b{transform:translateY(101%)}
#fade{position:absolute;inset:0;background:#000;opacity:0;transition:opacity .5s ease} #fade.on{opacity:1}
#title{position:absolute;left:0;right:0;bottom:16vh;text-align:center;color:var(--cream);opacity:0;transform:translateY(8px);transition:opacity 1.6s ease, transform 2.4s ease;text-shadow:0 2px 24px rgba(0,0,0,.9)}
#title.on{opacity:1;transform:none}
#title i{display:block;font:italic 500 clamp(40px,6vw,84px)/1 var(--serif);letter-spacing:.02em}
#title span{display:block;margin-top:14px;font:600 13px/1 var(--serif);letter-spacing:.42em;text-transform:uppercase;opacity:.8}
body.cine #hudbox{opacity:0 !important;pointer-events:none !important}

/* signature */
#sig{position:absolute;left:50%;top:46%;width:min(880px,88vw);transform:translate(-50%,-50%);transform-origin:50% 50%;color:var(--cream);
  transition:transform 1.5s cubic-bezier(.6,.02,.2,1), color 1.2s ease .2s, opacity .6s ease;will-change:transform}
#sig svg{display:block;width:100%;height:auto;overflow:visible;filter:drop-shadow(0 0 22px rgba(239,230,210,.22));}
#sig.landed svg{filter:none}
@keyframes push{from{transform:scale(.94)}to{transform:scale(1.03)}}
#sig .ink{fill:currentColor} #sig .swash{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round}
#sig.landed{color:var(--ink)}
#waiting{position:absolute;left:0;right:0;bottom:21vh;text-align:center;font:italic 500 16px/1 var(--serif);letter-spacing:.06em;color:rgba(239,230,210,.5);opacity:0;transition:opacity 1s}
#intro.signing #waiting{opacity:1}

/* parchment */
.parch{position:relative;color:var(--ink);font-family:var(--serif);
  background:
    radial-gradient(60% 40% at 18% 12%, rgba(120,84,40,.14), rgba(0,0,0,0) 70%),
    radial-gradient(50% 45% at 86% 88%, rgba(110,72,30,.18), rgba(0,0,0,0) 70%),
    radial-gradient(120% 120% at 50% 50%, rgba(0,0,0,0) 62%, rgba(92,60,24,.30) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.035 .9' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='320' height='320' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(175deg, #efe3c6, var(--parch) 45%, var(--parch-deep));
  box-shadow:0 1px 0 rgba(255,255,255,.35) inset, 0 30px 70px rgba(0,0,0,.65), 0 6px 14px rgba(0,0,0,.45);border-radius:3px}
.parch::after{content:"";position:absolute;inset:0;pointer-events:none;border-radius:3px;box-shadow:inset 0 0 38px rgba(96,62,24,.35)}

#letter{position:absolute;left:50%;top:50%;width:min(600px,90vw);max-height:88vh;padding:54px 58px 40px;box-sizing:border-box;
  transform:translate(-50%,-46%) rotate(-1.1deg);opacity:0;pointer-events:none;transition:opacity 1.4s ease .35s, transform 1.6s cubic-bezier(.2,.7,.2,1) .2s}
#intro.letter #letter{opacity:1;transform:translate(-50%,-50%) rotate(-1.1deg);pointer-events:auto}
#intro.map #letter{opacity:0;transform:translate(-50%,-53%) rotate(-1.1deg);pointer-events:none;transition-delay:0s}
#letter .pin{position:absolute;left:50%;top:14px;width:16px;height:16px;margin-left:-8px;border-radius:50%;
  background:radial-gradient(circle at 35% 30%, #f6dc9a, var(--brass) 45%, #6d5222 100%);box-shadow:0 3px 5px rgba(0,0,0,.5)}
#letter h1{font:italic 500 34px/1.1 var(--serif);margin:0 0 18px;letter-spacing:.01em}
#letter p{font:500 19px/1.55 var(--serif);margin:0 0 14px;color:#33210f;text-wrap:pretty}
#letter .yours{margin:22px 0 0;font-style:italic}
#sigslot{height:92px;margin:2px 0 6px -6px;width:min(330px,70%)}
#letter .ps{font:italic 500 16px/1.5 var(--serif);color:var(--ink-soft);margin-top:4px}
.row{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-top:22px}

/* buttons: engraved brass plates on parchment */
.btn{font:600 14px/1 var(--serif);letter-spacing:.16em;text-transform:uppercase;color:var(--ink);background:rgba(42,26,16,.04);
  border:1px solid rgba(42,26,16,.55);border-radius:2px;padding:13px 20px 12px;cursor:pointer;transition:background .25s, color .25s, border-color .25s, transform .12s}
.btn:hover{background:var(--ink);color:var(--parch);border-color:var(--ink)} .btn:active{transform:translateY(1px)}
.btn.primary{background:var(--ink);color:var(--parch)} .btn.primary:hover{background:#4a2c18}
.btn[disabled]{cursor:default;background:rgba(42,26,16,.06);color:rgba(42,26,16,.55);border-color:rgba(42,26,16,.3)}
.btn:focus-visible, .area:focus-visible, #hudmap:focus-visible, #hudsnd:focus-visible{outline:2px solid var(--brass);outline-offset:3px}
.btn .bar{display:block;height:2px;margin:8px -4px -4px;background:rgba(42,26,16,.18);overflow:hidden} .btn .bar i{display:block;height:100%;width:0;background:var(--ink-soft);transition:width .4s}

/* the map / guide (used in the opening and from the HUD) */
#guide{position:fixed;inset:0;z-index:60;display:grid;place-items:center;background:rgba(8,6,4,.0);visibility:hidden;opacity:0;transition:opacity .5s ease, visibility 0s linear .5s, background .5s}
#guide.open{visibility:visible;opacity:1;transition-delay:0s;background:rgba(8,6,4,.55)}
#intro.map ~ #guide.open{background:transparent}
#sheet{width:min(1040px,94vw);max-height:92vh;overflow:auto;padding:34px 40px 30px;box-sizing:border-box;transform:translateY(14px) rotate(.5deg);transition:transform .7s cubic-bezier(.2,.7,.2,1)}
#guide.open #sheet{transform:translateY(0) rotate(.5deg)}
#sheet header{display:flex;align-items:baseline;justify-content:space-between;gap:16px;border-bottom:0;padding-bottom:10px;margin-bottom:14px}     /* no rule under the title (2026-12-03) */
#sheet h2{font:italic 500 30px/1 var(--serif);margin:0} #sheet .count{font:600 13px/1 var(--serif);letter-spacing:.16em;text-transform:uppercase;color:var(--ink-soft)}
#plan{display:block;width:100%;height:auto} #floors{display:none}
#plan .wall{fill:none;stroke:var(--ink);stroke-width:1.5;stroke-linejoin:round;stroke-linecap:round} #plan .thin{fill:none;stroke:var(--ink);stroke-width:.6;stroke-linecap:round}
#plan .dash{stroke-dasharray:2.2 2} #plan .solid{fill:rgba(42,26,16,.5);stroke:var(--ink);stroke-width:.8} #plan .wash{fill:rgba(96,120,60,.16);stroke:none}
#plan text{font-family:var(--serif);fill:var(--ink)} #plan .lbl{font-size:7.6px;font-style:italic;font-weight:600;text-anchor:middle;pointer-events:none}
#plan .cap{font-size:4.6px;letter-spacing:.22em;text-transform:uppercase;fill:var(--ink-soft);text-anchor:middle;pointer-events:none}
#plan .area{fill:rgba(42,26,16,0);stroke:none;cursor:pointer;transition:fill .25s} #plan .area:hover, #plan .area.sel{fill:rgba(150,96,36,.20)}
#plan .tick{font-size:8px;fill:#7a3b12;pointer-events:none;opacity:0;transition:opacity .4s} #plan .tick.on{opacity:1}
#plan .here{fill:#8b2f1a;opacity:0} #plan .here.on{opacity:1}
#note{display:grid;grid-template-columns:1fr auto;gap:14px 24px;align-items:end;margin-top:10px;min-height:74px}
#note h3{font:italic 600 24px/1.1 var(--serif);margin:0 0 6px} #note p{font:500 17px/1.45 var(--serif);margin:0;color:#33210f;max-width:62ch}
#keys{font:500 13.5px/1.5 var(--serif);letter-spacing:.06em;color:var(--ink-soft);margin-top:12px;border-top:1px solid rgba(42,26,16,.25);padding-top:10px}
#keys b{font-weight:600;color:var(--ink);letter-spacing:.12em}
/* in the house the key is one quiet line; before going in (the map on the welcome screen) it is the point of the page: big, one per line */
#keys h3{display:none} #keys span + span::before{content:'\00a0·\00a0 '}
body.intro-on #guide .tick, body.intro-on #guide #note, body.intro-on #guide .count{display:none}
body.intro-on #guide #plan .area{pointer-events:none}
body.intro-on #keys{border-top:1px solid rgba(42,26,16,.3);margin-top:.8em;padding-top:.7em;display:grid;grid-template-columns:repeat(3,auto);justify-content:center;gap:.55em 2.6em;font:500 1.08em/1.35 var(--serif);letter-spacing:.02em;color:var(--ink);text-align:left}
body.intro-on #keys h3{display:block;grid-column:1/-1;margin:0 0 .15em;font:italic 600 1.7em/1.1 var(--serif);letter-spacing:.01em;text-align:center;margin-bottom:.3em}
/* the map comes first: the plan keeps its full size, centred on the paper; the controls take what is left below */
@media (min-width:720px){ body.intro-on #sheet.parch{justify-content:center} body.intro-on #plan{flex:0 0 auto;width:100%;margin:.2em 0 0} body.intro-on #sheet header{margin-bottom:.2em} }
body.intro-on #keys span::before{content:none}
/* keys as little engraved keycaps; gestures (drag, scroll, click, tap, pinch) in bold small capitals */
#keys kbd{display:inline-block;min-width:1.45em;box-sizing:border-box;margin:0 .18em 0 0;padding:.2em .38em .14em;font:700 .78em/1.1 var(--serif);letter-spacing:.06em;text-transform:uppercase;text-align:center;color:var(--ink);
  background:linear-gradient(rgba(255,248,230,.55),rgba(150,110,60,.12));border:1px solid rgba(42,26,16,.55);border-radius:3px;box-shadow:0 1.5px 0 rgba(42,26,16,.45);vertical-align:.08em}
#keys kbd + kbd{margin-left:-.02em} #keys kbd:last-of-type{margin-right:.4em}
body.intro-on #keys span{display:flex;align-items:baseline;flex-wrap:nowrap;white-space:nowrap;gap:0 .1em}
body.intro-on #keys b{font-weight:700;font-size:.8em;letter-spacing:.18em;text-transform:uppercase;margin-right:.5em;color:var(--ink)}

/* HUD (after entering) */
#hudbox{position:fixed;right:18px;bottom:18px;z-index:40;display:flex;gap:10px;align-items:flex-end;opacity:0;transform:translateY(10px);pointer-events:none;transition:opacity 1.2s ease 1.4s, transform 1.2s ease 1.4s}
body.play #hudbox{opacity:1;transform:none;pointer-events:auto}
/* the horn on the load screen too (2026-12-02), in the same corner as inside, so it never moves; the map button hidden until inside */
body.intro-on:not(.cine) #hudbox{opacity:1;transform:none;pointer-events:auto;z-index:75;transition-delay:.6s}
body.intro-on #hudmap{display:none}
@media (max-width:719px){ #again{max-width:calc(100vw - 150px);margin-left:auto;margin-right:auto;text-wrap:balance} }   /* clear of the horn in the corner */
#hudmap{display:grid;grid-template-columns:auto auto;gap:2px 10px;align-items:center;text-align:left;cursor:pointer;color:var(--ink);padding:10px 14px 10px 10px;border:0;border-radius:3px;font-family:var(--serif);
  background:linear-gradient(170deg,#efe3c6,#d9c79c);box-shadow:0 10px 26px rgba(0,0,0,.55), inset 0 0 14px rgba(96,62,24,.35);transition:transform .2s}
#hudmap:hover{transform:translateY(-2px) rotate(-.6deg)}
#hudmap svg{grid-row:1 / span 2;width:38px;height:38px} #hudmap b{font:600 13px/1 var(--serif);letter-spacing:.18em;text-transform:uppercase} #hudmap span{font:italic 500 14px/1 var(--serif);color:var(--ink-soft)}
#hudsnd{width:54px;height:54px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center;transition:transform .35s cubic-bezier(.2,.7,.2,1)}
#hudsnd:hover{transform:translateY(-2px) rotate(-3deg)}
#hudsnd .horn{width:100%;height:100%;background:center / contain no-repeat;filter:drop-shadow(0 3px 4px rgba(0,0,0,.6))}
#hudsnd .horn.on{background-image:url("assets/ui/sound_on.png")} #hudsnd .horn.off{background-image:url("assets/ui/sound_off.png")}
#hint{position:fixed;left:50%;bottom:26px;z-index:40;transform:translateX(-50%);font:italic 500 17px/1 var(--serif);letter-spacing:.05em;color:rgba(239,230,210,.85);text-shadow:0 1px 8px rgba(0,0,0,.9);opacity:0;transition:opacity 1.2s;pointer-events:none}
#hint.on{opacity:1}

@media (max-width:640px){ #sheet{padding:24px 18px} #note{grid-template-columns:1fr} }
@media (prefers-reduced-motion:reduce){ #sig, #letter, #sheet, #door, #intro{transition-duration:.01s !important} }

/* the arrival still: the hall as the doors open, shown until the live house is ready behind it */
#still{position:fixed;inset:0;z-index:45;background:#0d0a08 url("assets/arrival.jpg") center / cover no-repeat;transition:opacity 1.4s ease, visibility 0s linear 1.4s}
#still.dissolve{opacity:0;visibility:hidden;transition:opacity 2.4s cubic-bezier(.4,0,.3,1), visibility 0s linear 2.4s}
#still.gone{opacity:0;visibility:hidden}




/* ------------------------------------------------------------------ the supplied artwork: envelope and seal, letter sheet, map sheet */
/* the letter arrives sealed: the envelope sits where the letter will, and breaking the seal opens it */
#envelope{position:absolute;left:50%;top:52%;width:min(560px,88vw);aspect-ratio:1774 / 887;padding:0;border:0;border-radius:0;cursor:pointer;
  background:url("assets/ui/envelope.webp") center / 100% 100% no-repeat;filter:drop-shadow(0 26px 34px rgba(0,0,0,.7));
  transform:translate(-50%,-42%) rotate(-2deg) scale(.96);opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity 1.2s ease .3s, transform 1.5s cubic-bezier(.2,.7,.2,1) .2s, visibility 0s linear 1.6s}
#intro.envelope #envelope{opacity:1;visibility:visible;pointer-events:auto;transform:translate(-50%,-50%) rotate(-2deg);transition-delay:.3s,.2s,0s}
#intro.envelope #envelope:hover{transform:translate(-50%,-51%) rotate(-1.2deg) scale(1.015);transition:transform .5s cubic-bezier(.2,.7,.2,1)}
#envelope:focus-visible{outline:2px solid var(--brass);outline-offset:6px}
#envelope .seal{position:absolute;left:50.1%;top:53.9%;width:24%;aspect-ratio:1;transform:translate(-50%,-50%);
  background:url("assets/ui/seal.webp") center / auto 100% no-repeat;transition:transform .7s cubic-bezier(.3,1.5,.5,1), opacity .5s ease .15s;animation:sealglow 3.2s ease-in-out infinite}
@keyframes sealglow{0%,100%{filter:drop-shadow(0 0 0 rgba(255,214,140,0))}50%{filter:drop-shadow(0 0 12px rgba(255,214,140,.55))}}
#intro:not(.envelope) #envelope{transform:translate(-50%,-40%) rotate(-4deg) scale(1.04);transition:opacity .7s ease .1s, transform 1.1s ease, visibility 0s linear .9s}
#intro:not(.envelope):not(.signing) #envelope .seal{transform:translate(-50%,-50%) scale(1.5) rotate(14deg);opacity:0;animation:none}
#envhint{position:absolute;left:50%;top:calc(52% + min(140px,22vw) + 34px);transform:translateX(-50%);white-space:nowrap;font:italic 500 clamp(22px,2.1vw,30px)/1 var(--serif);letter-spacing:.06em;
  color:rgba(239,230,210,.82);text-shadow:0 1px 10px rgba(0,0,0,.9);opacity:0;transition:opacity .6s;pointer-events:none}
#intro.envelope #envhint{opacity:1;transition:opacity 1.4s ease 1.6s}
#sig{pointer-events:none}
#intro.envelope #sig{opacity:0;visibility:hidden;transition:opacity .9s ease, transform 1.5s cubic-bezier(.6,.02,.2,1)}
#intro.letter #sig{transition:transform .01s, color .01s, opacity .3s ease .9s}

/* the letter: the portrait sheet. Everything inside is sized from the sheet's width, so it always fits the paper */
#letter.parch{--w:min(700px,94vw,68vh);width:var(--w);height:calc(var(--w) * 1.25);max-height:none;font-size:calc(var(--w) / 30.5);padding:calc(var(--w) * .12) calc(var(--w) * .115) calc(var(--w) * .1) calc(var(--w) * .12);
  background:none;box-shadow:none;border-radius:0;filter:none;display:flex;flex-direction:column}
/* the paper and its shadow are a layer BEHIND the writing: with the shadow filter on the letter itself, the browser dropped
   bands of the text at large window sizes */
#letter.parch::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;background:url("assets/ui/parchment_letter.webp") center / 100% 100% no-repeat;filter:drop-shadow(0 28px 40px rgba(0,0,0,.7))}
#letter.parch::after, #letter .pin{display:none}
#letter h1{font-size:1.6em;margin:0 0 .45em} #letter p{font-size:1em;line-height:1.42;margin:0 0 .55em} #letter .yours{margin:.35em 0 0}
/* the signature is written on the sheet itself, in line with the text above it */
#sigslot{font:400 2.1em/1 'Mrs Saint Delafield','Snell Roundhand','Apple Chancery',cursive;color:var(--ink);margin:.5em 0 .05em;white-space:nowrap;height:auto;width:auto}
#sig{display:none !important}
#sigtitle{font:600 .62em/1 var(--serif);letter-spacing:.22em;text-transform:uppercase;color:var(--ink-soft);margin:.8em 0 0 .15em}   /* clear of the signature's loops, which hang below its line */
#letter .row{margin-top:auto;gap:.6em} #letter .btn{font-size:.7em;padding:.85em 1.15em .8em}

/* the map: the landscape sheet with the engraved border; the plan sits inside the border */
@media (min-width:720px){
  #sheet.parch{--mw:min(1120px,96vw,124vh);width:var(--mw);height:calc(var(--mw) / 1.5);max-height:none;overflow:visible;font-size:calc(var(--mw) / 64);padding:calc(var(--mw) * .103) calc(var(--mw) * .125) calc(var(--mw) * .104) calc(var(--mw) * .125);
    background:url("assets/ui/parchment_map.webp") center / 100% 100% no-repeat;box-shadow:none;border-radius:0;filter:drop-shadow(0 30px 44px rgba(0,0,0,.7));display:flex;flex-direction:column}
  #sheet.parch::after{display:none}
  #sheet header{flex-direction:column;align-items:center;gap:.35em;padding-bottom:.45em;margin:0 16% .4em} #sheet h2{font-size:1.7em} #sheet .count{font-size:.7em}
  #plan{flex:1 1 auto;min-height:0;width:94%;margin:0 3%;height:auto}
  #note{margin:.4em 5% 0;min-height:4.2em;gap:.6em 1.4em} #note h3{font-size:1.36em;margin-bottom:.25em} #note p{font-size:.98em;line-height:1.4}
  #sheet .btn{font-size:.74em;padding:.85em 1.2em .8em}
  #keys{font-size:.74em;margin:.6em 9% 0;padding-top:.5em;text-align:center;border-top-color:rgba(120,84,30,.35)}
}
/* the HUD map button wears the seal */
#hudmap .sealicon{grid-row:1 / span 2;width:46px;height:46px;background:url("assets/ui/seal.webp") center / auto 100% no-repeat;filter:drop-shadow(0 2px 3px rgba(0,0,0,.45))}
#hudmap{background:url("assets/ui/parchment_letter.webp") center / 180% 180%;box-shadow:0 10px 26px rgba(0,0,0,.55);padding:8px 16px 8px 8px}

@media (min-width:1000px){
  #letter.parch{--w:min(700px,94vw,68vh);padding:calc(var(--w) * .12) calc(var(--w) * .115) calc(var(--w) * .1) calc(var(--w) * .12)}
  #envelope{width:min(500px,36vw)}
}

/* the map lies behind the letter, askew to the right (a click brings it forward); with the map in front, the letter lies behind it */
#guide.peek{visibility:visible;opacity:1;z-index:48;background:transparent;pointer-events:none;transition:opacity .9s ease .5s}
#guide.peek #sheet, #guide.peek #sheet.parch{transform:translate(13%,2%) rotate(6deg) scale(.8);filter:drop-shadow(0 22px 34px rgba(0,0,0,.7)) brightness(.8)}
#intro.map #letter{opacity:1;transform:translate(-72%,-50%) rotate(-6deg) scale(.8);pointer-events:none}
@media (min-width:1000px){   /* room to show a good third of the letter: the map sits a little right, the letter well left */
  #intro.map #letter{transform:translate(-97%,-50%) rotate(-6deg) scale(.8)}
  #intro.map ~ #guide.open #sheet{transform:translate(4%,0) rotate(.5deg)}
}
/* the sheet that is behind is treated the same whichever it is: smaller, tilted, dimmed; and both swap at the same pace */
#intro.map #letter.parch::before{filter:drop-shadow(0 22px 34px rgba(0,0,0,.7)) brightness(.8)}
#intro.map #letter > *{opacity:.8}
#intro.swapped #letter{transition:transform .7s cubic-bezier(.2,.7,.2,1), opacity .5s ease}
#intro.swapped #letter > *, #letter.parch::before{transition:opacity .5s ease, filter .5s ease}
#intro.map ~ #guide.open{background:transparent}

/* the beacon: a small breathing brass light with slow rings, marking something that can be clicked */
.beacon{position:absolute;width:60px;height:60px;margin:-30px 0 0 -30px;border-radius:50%;pointer-events:none;opacity:0;transition:opacity 1.4s ease}
/* the same indicator as inside the house (hunt.js): no dot, two warm rings that widen and fade, half a beat apart, with a soft glow */
.beacon.on{opacity:1}
.beacon::before,.beacon::after{content:"";position:absolute;inset:0;border-radius:50%;border:3px solid rgba(255,236,185,1);opacity:0;
  box-shadow:0 0 10px 2px rgba(255,190,100,.9), inset 0 0 8px 2px rgba(255,190,100,.6), 0 0 3px rgba(40,20,5,.6)}     /* a touch stronger than the rings inside: the wax is bright */
.beacon.on::before,.beacon.on::after{animation:beacon-ring 2.8s cubic-bezier(.25,.7,.35,1) infinite} .beacon.on::after{animation-delay:1.4s}
@keyframes beacon-breathe{0%,100%{opacity:1}}
@keyframes beacon-ring{0%{transform:scale(.17);opacity:1}60%{opacity:.75}100%{transform:scale(1);opacity:0}}
@media (prefers-reduced-motion:reduce){ .beacon.on,.beacon.on::before,.beacon.on::after{animation:none} }

/* the way in: one control below both sheets. The sheets sit a little high to leave it room. */
#letter.parch{top:46%}
#intro.map ~ #guide.open, #guide.peek{padding-bottom:8vh;box-sizing:border-box}
#enterbar{position:fixed;left:0;right:0;top:min(calc(46vh + min(700px,94vw,68vh) * .625 + 20px), calc(100vh - 62px));   /* just under the letter's bottom edge */
  z-index:70;display:flex;justify-content:center;pointer-events:none;opacity:0;visibility:hidden;transition:opacity .8s ease, visibility 0s linear .8s}
/* shown only once the map has been looked at (.swapped): first the letter, then the map, then the way in */
#intro.swapped.letter ~ #enterbar, #intro.swapped.map ~ #enterbar{opacity:1;visibility:visible;transition:opacity 1.2s ease 1.2s}
#enterbar{flex-direction:column;align-items:center}
#again{pointer-events:auto;margin:.9em 0 0;font:italic 500 15px/1.4 var(--serif);color:rgba(239,230,210,.72);text-align:center;text-shadow:0 1px 6px rgba(0,0,0,.8)}
#enterrow{display:flex;gap:14px;justify-content:center}
/* while the house loads there is one thing at the foot: the loading bar. "Start over" joins "Carry on" once the house is ready (2026-12-03) */
#enterrow:not(.ready) #b-again{display:none} #enterrow.ready #b-again{animation:again-in .6s ease both}
@keyframes again-in{from{opacity:0}to{opacity:1}}
/* "Start over": the same size as the way in, quieter (no glow, a fainter edge) so "Carry on" stays the one to press */
#b-again{pointer-events:auto;font:600 clamp(12px,1.7vh,15px)/1 var(--serif);letter-spacing:.3em;text-transform:uppercase;color:rgba(239,230,210,.82);background:rgba(13,10,8,.5);
  border:1px solid rgba(201,163,90,.45);border-radius:2px;padding:1.05em 2.2em 1em 2.5em;cursor:pointer;backdrop-filter:blur(3px);transition:background .3s,color .3s,border-color .3s}
#b-again:hover{background:var(--brass);border-color:var(--brass);color:var(--night)} #b-again.sure:hover{background:#c9614a;border-color:#c9614a;color:#fff} #b-again.sure{border-color:#c9614a;color:#f0c2b4}
#b-again:focus-visible{outline:2px solid var(--brass);outline-offset:4px}
#b-enter{pointer-events:auto;font:600 clamp(12px,1.7vh,15px)/1 var(--serif);letter-spacing:.3em;text-transform:uppercase;color:var(--cream);background:rgba(13,10,8,.62);
  border:1px solid rgba(201,163,90,.9);border-radius:2px;padding:1.05em 2.2em 1em 2.5em;cursor:pointer;backdrop-filter:blur(3px);transition:background .3s, color .3s, box-shadow .6s, border-color .6s}
#b-enter[disabled]{cursor:default;color:rgba(239,230,210,.55);border-color:rgba(201,163,90,.35);letter-spacing:.2em}
#b-enter .bar{display:block;height:1px;margin:.8em 0 -.2em;background:rgba(201,163,90,.2);overflow:hidden} #b-enter .bar i{display:block;height:100%;width:0;background:var(--brass);transition:width .4s}
#b-enter:not([disabled]){animation:enter-glow 2.8s ease-in-out infinite}
#b-enter:not([disabled]):hover{background:var(--brass);color:var(--night)}
#b-enter:focus-visible{outline:2px solid var(--brass);outline-offset:4px}
/* narrow screens: the map is hidden behind the letter, so the letter gets a "See the map" button where "Come in" will be */
#b-map{display:none}
@media (max-width:719px){
  #intro.letter:not(.swapped) ~ #enterbar{opacity:1;visibility:visible;transition:opacity 1.2s ease 1.2s}
  #intro:not(.swapped) ~ #enterbar #b-enter,#intro:not(.swapped) ~ #enterbar #b-again{display:none}
  #enterrow{gap:10px} #enterrow.ready:has(#b-again){width:calc(100vw - 28px);max-width:420px} #enterrow.ready:has(#b-again) #b-enter,#enterrow #b-again{flex:1 1 0;padding:1.05em .6em 1em .9em;letter-spacing:.2em;font-size:13px}
  #intro:not(.swapped) ~ #enterbar #b-map{display:block;pointer-events:auto;font:600 13px/1 var(--serif);letter-spacing:.3em;text-transform:uppercase;color:var(--cream);background:rgba(13,10,8,.62);
    border:1px solid rgba(201,163,90,.9);border-radius:2px;padding:1.05em 2.2em 1em 2.5em;cursor:pointer;backdrop-filter:blur(3px)}
  #intro > .beacon{display:none}
  /* the map on its own tall sheet (assets/ui/map_parchment_tall.webp): the content sits inside its inked border */
  #sheet.parch{background:url("assets/ui/map_parchment_tall.webp") center / 100% 100% no-repeat;border-radius:0;box-shadow:0 26px 50px rgba(0,0,0,.6);padding:12% 9% 9%}
  #sheet.parch::after{display:none}
  /* the map on a phone before going in: room kept at the foot for "Come in" (and the welcome-back line), the sheet fitted above it */
  #intro.map ~ #guide.open{padding:max(10px,env(safe-area-inset-top)) 0 calc(78px + env(safe-area-inset-bottom));box-sizing:border-box}
  body:has(#again) #intro.map ~ #guide.open{padding-bottom:calc(122px + env(safe-area-inset-bottom))}
  #intro.map ~ #guide.open #sheet.parch{max-height:100%;overflow:auto;scrollbar-width:none}
  #sheet.parch{padding:10% 8% 8%} #sheet h2{font-size:26px} #sheet header{margin-bottom:8px;padding-bottom:8px}
  #note{margin-top:6px;min-height:0;gap:4px} #note h3{font-size:20px;margin:0 0 3px} #note p{font-size:15px;line-height:1.35}
  #keys{font-size:12px;line-height:1.4;margin-top:8px;padding-top:7px}
  /* the two floors as one switch, under the plan, in the map's own button style (.btn): a thin ink edge, square corners; the floor
     shown is filled in ink, the other lightly tinted on hover (filled, it would look chosen); no rule above the key below it */
  #floors{display:flex;justify-content:center;gap:0;margin:10px auto 4px;width:max-content;border:1px solid rgba(42,26,16,.55);border-radius:2px;overflow:hidden}
  #floors button{font:600 13px/1 var(--serif);letter-spacing:.16em;text-transform:uppercase;color:var(--ink);background:rgba(42,26,16,.04);border:0;border-radius:0;padding:12px 18px 11px;cursor:pointer;transition:background .25s,color .25s}
  #floors button + button{border-left:1px solid rgba(42,26,16,.55)}
  #floors button:not(.on):hover,#floors button:not(.on):active{background:rgba(42,26,16,.14)}
  #floors button.on{color:var(--parch);background:var(--ink);cursor:default}
  #keys,body.intro-on #keys{border-top:0}
  #envhint{font-size:24px;letter-spacing:.08em}
  /* a bigger letter: nearly the full width, a little taller than on a desk, so the text can be read without squinting */
  /* ...and fitted into the space above the buttons at the foot (2026-12-03: "See the map" overlapped its lower edge); --bar is the
     height the buttons take, with the welcome-back line under them when there is one */
  #intro{--bar:calc(70px + env(safe-area-inset-bottom))} body:has(#again) #intro{--bar:calc(118px + env(safe-area-inset-bottom))}
  #letter.parch{top:calc((100svh - var(--bar)) / 2 + 4px)}
  #letter.parch{--w:min(96vw,52vh);--w:min(96vw,52svh,calc((100svh - var(--bar) - 30px) / 1.5));height:calc(var(--w) * 1.5);font-size:calc(var(--w) / 23.5);padding:calc(var(--w) * .13) calc(var(--w) * .1) calc(var(--w) * .1) calc(var(--w) * .11)}
  /* pinned to the bottom of what is actually visible: on phones 100vh reaches behind the browser's own toolbar */
  #enterbar{top:auto;bottom:calc(14px + env(safe-area-inset-bottom))}
  #hint{bottom:calc(86px + env(safe-area-inset-bottom));white-space:nowrap;font-size:15px}     /* above the horn, clear of the key box at the top */
}
@keyframes enter-glow{0%,100%{box-shadow:0 0 0 0 rgba(255,196,110,0), 0 0 10px 0 rgba(255,186,96,.18)}50%{box-shadow:0 0 0 5px rgba(255,196,110,.10), 0 0 26px 6px rgba(255,186,96,.42)}}
@media (prefers-reduced-motion:reduce){ #b-enter:not([disabled]){animation:none;box-shadow:0 0 18px 3px rgba(255,186,96,.35)} }

/* the same light on the centre of the wax seal, a few seconds after the envelope arrives */
#envelope .seal .beacon{left:50%;top:50%}
/* (an animation, not a transition: the page starts in this state, so a transition would never run and the light would be there from the start) */
#intro.envelope #envelope .seal .beacon{animation:beacon-in 1.4s ease 4.2s both}
@keyframes beacon-in{from{opacity:0}to{opacity:1}}
#intro.envelope #envelope .seal .beacon::before, #intro.envelope #envelope .seal .beacon::after{animation:beacon-ring 2.8s cubic-bezier(.2,.6,.3,1) 4.2s infinite}
#intro.envelope #envelope .seal .beacon::after{animation-delay:5.6s}

/* the broken key, outlined in faint ink at the foot of the letter */
#keyghost{position:absolute;left:50%;bottom:10.5%;width:38%;height:auto;transform:translateX(-50%) rotate(-1.2deg);opacity:.5;pointer-events:none;mix-blend-mode:multiply}

/* the letter's signature is a pen signature (assets/ui/signature.png), not type */
#sigslot{font-size:1em;margin:.9em 0 0 -.3em;line-height:0}
#sigslot img{display:block;width:min(19em,80%);height:auto;mix-blend-mode:multiply;opacity:.92}
#sigtitle{margin:.55em 0 0 .15em}
/* the map: the rest of the house's block, where the plan shows no room */
#plan .void{fill:url(#hatch);color:var(--ink);opacity:.34;stroke:var(--ink);stroke-width:.5;stroke-dasharray:1.6 1.6;stroke-linejoin:round}
@media (max-width:719px) and (max-height:600px){ #intro.map ~ #guide.open #keys{display:none} }
@media (max-width:719px){ body.intro-on #keys{grid-template-columns:1fr;font-size:16px;gap:.35em;margin:12px 6% 0;text-align:left} body.intro-on #keys h3{font-size:19px} body.intro-on #keys b{min-width:4.2em} }   /* a very short screen: the walking line inside the house teaches the controls */
