/* =========================================================
   TERRA — 3D intro film (js/intro3d.js, three.js + GSAP)
   Plays automatically on the Home page once per visit:
   plot → dream board → builder's shortcut → architect → plan
   → the house builds itself → dusk → the door opens → the hall.
   ========================================================= */
html.story-off .intro3d { display: none; }

.intro3d { position: fixed; inset: 0; z-index: 400; background: #efe4d4; overflow: hidden; transition: opacity 1.1s ease, visibility 0s linear 1.1s; }
.intro3d.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.intro3d canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
body.intro-playing { overflow: hidden; }
body.intro-playing .site-header, body.intro-playing .wa-float { opacity: 0; pointer-events: none; }

/* captions */
.intro3d__caps { position: absolute; left: 0; right: 0; top: clamp(70px, 10vh, 110px); z-index: 3; pointer-events: none; padding: 0 var(--pad); }
.intro3d__cap {
  position: absolute; left: 0; right: 0; margin: 0 auto; width: fit-content; max-width: min(860px, 92vw); text-align: center;
  padding: 18px 34px 20px; border-radius: 18px;
  background: rgba(250,246,240,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px -30px rgba(33,24,18,.45);
  opacity: 0; transform: translateY(20px); transition: opacity .7s ease, transform .8s var(--ease);
}
.intro3d__cap.on { opacity: 1; transform: none; }
.intro3d__cap small { display: block; font-family: var(--display); font-size: 11.5px; letter-spacing: .4em; text-transform: uppercase; color: var(--bronze-3); }
.intro3d__cap span { display: block; margin-top: 8px; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(23px, 2.7vw, 42px); line-height: 1.2; color: var(--brown-3); }

/* the hall (end of the film) */
.intro3d__hall { position: absolute; inset: 0; z-index: 2; opacity: 0; transition: opacity 1.2s ease; }
.intro3d__hall img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.18); transition: transform 4s cubic-bezier(.2,.7,.2,1); }
.intro3d__hall.on { opacity: 1; }
.intro3d__hall.on img { transform: scale(1.02); }
.intro3d__flash { position: absolute; inset: 0; z-index: 2; background: #fff3dc; opacity: 0; pointer-events: none; transition: opacity .7s ease; }
.intro3d__flash.on { opacity: 1; }

/* chrome: brand, stages, progress, skip */
.intro3d__brand { position: absolute; left: var(--pad); top: 24px; z-index: 3; display: flex; align-items: center; gap: 10px; color: var(--brown); }
.intro3d__brand svg { width: 26px; height: 32px; }
.intro3d__brand b { font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: .18em; }
.intro3d__brand-logo { display: block; height: 60px; width: auto; }
.intro3d__brand:has(.intro3d__brand-logo) { z-index: 7; top: 16px; padding: 6px 14px; border-radius: 14px; background: rgba(250,246,240,.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 12px 30px -18px rgba(33,24,18,.45); }
@media (max-width: 600px) { .intro3d__brand-logo { height: 46px; } }
.intro3d__stages {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 16px; padding: 10px 20px; border-radius: 999px; white-space: nowrap;
  background: rgba(250,247,242,.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(140,113,88,.3);
  font-family: var(--display); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: rgba(43,33,25,.4);
}
.intro3d__stages li { display: flex; align-items: center; gap: 8px; transition: color .4s; }
.intro3d__stages li::before { content: ""; width: 12px; height: 1px; background: currentColor; transition: width .4s, background .4s; }
.intro3d__stages li.on { color: var(--brown); }
.intro3d__stages li.on::before { width: 28px; background: var(--bronze); }
.intro3d__bar { position: absolute; left: 0; bottom: 0; z-index: 3; height: 3px; width: 100%; background: var(--grad); transform-origin: left; transform: scaleX(0); }
.intro3d__skip {
  position: absolute; right: var(--pad); top: 22px; z-index: 4; display: inline-flex; gap: 8px; align-items: center;
  padding: 10px 18px; border-radius: 999px; border: 1px solid rgba(140,113,88,.45); background: rgba(250,247,242,.85);
  font-family: var(--display); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--brown); transition: background .3s, color .3s;
}
.intro3d__skip:hover { background: var(--brown); color: var(--ivory); }

/* hero "replay the film" */
.hero__replay { display: none; margin-top: 26px; align-items: center; gap: 10px; font-family: var(--display); font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--bronze-3); }
.hero__replay b { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--bronze); display: grid; place-items: center; font-size: 10px; color: var(--brown); transition: background .3s, color .3s; }
.hero__replay:hover b { background: var(--brown); color: var(--ivory); }
html.story-off:not(.reduced) .hero__replay { display: inline-flex; }

@media (max-width: 700px) {
  .intro3d__stages { gap: 10px; padding: 8px 14px; font-size: 9px; bottom: 20px; }
  .intro3d__stages li span { display: none; }
  .intro3d__stages li.on span { display: inline; }
  .intro3d__brand b { display: none; }
  .intro3d__cap { padding: 14px 20px 16px; }
}

/* ---------- logo sting (after the film, before the homepage) ---------- */
/* ---------- room tour (after the front door opens) ---------- */
.intro3d__tour { position: absolute; inset: 0; z-index: 4; background: #fff3dc; opacity: 0; pointer-events: none; transition: opacity .9s ease; overflow: hidden; }
.intro3d__tour.on { opacity: 1; }
.intro3d__skip { z-index: 8; }
.intro3d__stages, .intro3d__bar { z-index: 5; }
.tour__slide { position: absolute; inset: 0; margin: 0; opacity: 0; transition: opacity 1s ease; overflow: hidden; }
.tour__slide.on { opacity: 1; }
.tour__slide > img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.14); transition: transform 3.4s cubic-bezier(.25,.7,.3,1); }
.tour__slide.on > img { transform: scale(1.02); }
.tour__slide::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(20,14,10,.25) 0%, transparent 30%, transparent 62%, rgba(20,14,10,.55) 100%); transition: opacity .6s; }
.tour__cap { position: absolute; left: var(--pad); bottom: clamp(70px, 11vh, 110px); z-index: 2; color: #fff8ee; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(30px, 4.4vw, 62px); line-height: 1.05; text-shadow: 0 6px 30px rgba(0,0,0,.35); opacity: 0; transform: translateY(24px); transition: opacity .8s ease .35s, transform .9s var(--ease) .35s; }
.tour__cap small { display: block; margin-bottom: 10px; font-family: var(--display); font-style: normal; font-size: clamp(10px, 1vw, 12.5px); letter-spacing: .4em; text-transform: uppercase; color: #efe2cf; }
.tour__slide.on .tour__cap { opacity: 1; transform: none; }
/* the hall: the photo is laid out like "cover" so the TV can be placed (and zoomed) exactly */
.tour__room { position: absolute; width: max(100vw, 133.334vh); height: max(75vw, 100vh); left: calc(50% - max(100vw, 133.334vh) / 2); top: calc(50% - max(75vw, 100vh) / 2); will-change: transform; }
.tour__room > img { width: 100%; height: 100%; display: block; }
.tour__tv { position: absolute; left: 38.31%; top: 39%; width: 16.56%; height: 13.83%; overflow: hidden; background: #000; box-shadow: 0 0 22px rgba(255,236,205,.35); }
.tour__tv { container-type: size; }
/* the TV switches on with the logo (same look as the full-screen end layer) */
.tv-logo { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 46%, #fdfcf9 0%, #f6f3ee 50%, #e9e4dc 100%); opacity: 0; transition: opacity .9s ease 1s; }
.tv-logo img { display: block; width: 78%; height: auto; mix-blend-mode: multiply; }
.tv-logo p { margin-top: 4%; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 6.2cqw; color: #2c221b; white-space: nowrap; }
.tour__slide--hall.on .tv-logo { opacity: 1; }
/* full-screen version, faded in as the zoom ends (keeps the logo whole on tall phone screens) */
.tour__end { position: absolute; inset: 0; z-index: 6; opacity: 0; transition: opacity .45s ease; pointer-events: none; container-type: size; }
.tour__end.on { opacity: 1; }
.tour__end .tv-logo { opacity: 1; transition: none; }
.tour__end .tv-logo img { width: min(820px, 86vw); }
.tour__end .tv-logo p { font-size: clamp(20px, 2.8vw, 36px); margin-top: clamp(14px, 2.4vw, 30px); }
.tour__tv::after { content: ""; position: absolute; inset: 0; background: linear-gradient(125deg, rgba(255,255,255,.16) 0%, transparent 38%); pointer-events: none; transition: opacity .6s; }
.is-zooming .tour__tv::after, .is-zooming .tour__slide--hall::after { opacity: 0; }
.is-zooming .tour__slide--hall .tour__cap { opacity: 0; transition-delay: 0s; }

/* half-white background with a soft glow behind the logo */
.intro3d__logo { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 46%, #fdfcf9 0%, #f6f3ee 45%, #e9e4dc 100%); opacity: 0; transition: opacity .8s ease; }
.intro3d__logo.on { opacity: 1; }
.intro3d__logo video { width: 100%; height: 100%; object-fit: contain; background: #f6f3ee; }
.tlogo { text-align: center; width: min(820px, 88vw); }
/* the logo image exactly as designed; multiply hides its white box on the half-white background */
.tlogo__img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; opacity: 0; transform: scale(1.06); filter: blur(8px); clip-path: inset(0 50% 0 50%); animation: tlogoIn 1.6s cubic-bezier(.2,.8,.2,1) .25s forwards; }
.tlogo__tag { margin-top: clamp(14px, 2.4vw, 30px); font-family: var(--serif); font-style: italic; font-weight: 500; font-size: clamp(20px, 2.8vw, 36px); letter-spacing: .02em; color: #2c221b; opacity: 0; transform: translateY(16px); animation: tlogoUp 1s var(--ease) 1.7s forwards; }
@keyframes tlogoIn { 60% { filter: blur(0); } to { opacity: 1; transform: none; filter: blur(0); clip-path: inset(0 0 0 0); } }
@keyframes tlogoUp { to { opacity: 1; transform: none; } }
body.intro-playing .intro3d__logo ~ * { pointer-events: none; }
.intro3d__logo--video { background: #000; }
.intro3d__logo--video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
