/* =========================================================
   The house
   A split threshold between the two lines. Each half is a single
   link; hovering widens it, choosing one sweeps it across the screen
   (house.js) before the browser follows the link.
   ========================================================= */

body.house {
  min-height: 100svh;
  overflow: hidden;
  background: #0b0a09;
  color: #f4ead8;
}

.house-stage {
  position: relative;
  isolation: isolate;
  height: 100svh;
  overflow: hidden;
}

/* ---------------------------------------------------------
   Doors
   --------------------------------------------------------- */
.house-doors {
  display: flex;
  width: 100%;
  height: 100%;
}

.house-door {
  --pad: clamp(1.5rem, 4.2vw, 4.25rem);
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  transition: flex-grow 1s var(--ease-out);
}

.house-door:focus-visible {
  outline: none;
}

.house-door:focus-visible .house-door__cta {
  outline: 1px solid currentColor;
  outline-offset: 8px;
}

.house-door--pi { background: #f6f4f1; color: var(--ink); }

.house-door--runic {
  background: #0b0a09;
  color: #f4ead8;
  box-shadow: inset 1px 0 0 rgba(198, 163, 106, 0.55);
}

.house-door__media {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  transition: filter 0.9s var(--ease-out);
}

.house-door__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
  transition: transform 2.6s var(--ease-out);
}

.house-door--pi .house-door__media img { object-position: 62% 50%; }
.house-door--runic .house-door__media img { object-position: 50% 40%; }

.house-door__veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.house-door--pi .house-door__veil {
  background:
    linear-gradient(0deg, rgba(246, 244, 241, 0.96) 0%, rgba(246, 244, 241, 0.82) 24%, rgba(246, 244, 241, 0.12) 62%, rgba(246, 244, 241, 0) 100%),
    linear-gradient(90deg, rgba(246, 244, 241, 0.35), rgba(246, 244, 241, 0) 55%);
}

.house-door--runic .house-door__veil {
  background:
    linear-gradient(0deg, rgba(8, 7, 6, 0.96) 0%, rgba(8, 7, 6, 0.8) 26%, rgba(8, 7, 6, 0.28) 62%, rgba(8, 7, 6, 0.5) 100%),
    radial-gradient(120% 80% at 50% 0%, rgba(8, 7, 6, 0) 40%, rgba(8, 7, 6, 0.55) 100%);
}

/* Roman numeral in the top corner of each half */
.house-door__index {
  position: absolute;
  top: clamp(1.1rem, 3.2vh, 2rem);
  left: var(--pad);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-inscribed);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.75;
}

.house-door__index i {
  width: 1.75rem;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.house-door--pi .house-door__index { font-family: var(--font-mono); font-weight: 400; letter-spacing: 0.18em; }
.house-door--runic .house-door__index { color: #e4d0a4; }

.house-door__body {
  display: grid;
  justify-items: start;
  gap: clamp(0.7rem, 1.6vh, 1.1rem);
  max-width: 30rem;
}

.house-door__eyebrow {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.house-door--pi .house-door__eyebrow { font-family: var(--font-mono); color: var(--text-2); letter-spacing: 0.18em; }
.house-door--runic .house-door__eyebrow { font-family: var(--font-inscribed); color: #c6a36a; }

.house-door__name {
  display: block;
  line-height: 0.95;
  white-space: nowrap;
}

.house-door__name--pi {
  display: inline-flex;
  align-items: center;
  gap: 0.18em;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 4.6vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  color: var(--ink);
}

.house-door__name--pi i {
  font-style: normal;
  font-weight: 400;
  color: var(--text-2);
}

.house-door__dot {
  flex: none;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.12em;
  border-radius: 50%;
  background: var(--grad-iris);
  box-shadow: inset 0 0 0 1px rgba(16, 19, 28, 0.08);
}

.house-door__name--runic {
  font-family: var(--font-inscribed);
  font-size: clamp(3rem, 7.4vw, 7.2rem);
  font-weight: 500;
  letter-spacing: 0.16em;
  margin-right: -0.16em;
  text-transform: uppercase;
  color: #e9d6aa;
  background: linear-gradient(180deg, #f7ead0 0%, #e4cc98 48%, #b8904f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.house-door__line {
  max-width: 34ch;
  font-size: clamp(0.92rem, 1.05vw, 1.02rem);
  line-height: 1.6;
}

.house-door--pi .house-door__line { color: var(--text-2); }

.house-door--runic .house-door__line {
  font-family: var(--font-serif);
  font-size: clamp(1.08rem, 1.3vw, 1.24rem);
  line-height: 1.5;
  color: #d9cbb0;
}

.house-door__cta {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  margin-top: clamp(0.4rem, 1.4vh, 1rem);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.house-door--runic .house-door__cta {
  font-family: var(--font-inscribed);
  font-weight: 500;
  color: #e4d0a4;
}

.house-door__rule {
  position: relative;
  width: 2.75rem;
  height: 1px;
  background: currentColor;
  transition: width 0.7s var(--ease-out);
}

.house-door__rule::after {
  content: '';
  position: absolute;
  right: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: rotate(45deg);
}

/* ---------------------------------------------------------
   Hover / focus: the chosen half widens, the other recedes
   --------------------------------------------------------- */
@media (hover: hover) and (pointer: fine) {
  .house-door:hover,
  .house-door:focus-visible { flex-grow: 1.42; }

  .house-door:hover .house-door__media img,
  .house-door:focus-visible .house-door__media img { transform: scale(1.1); }

  .house-door:hover .house-door__rule,
  .house-door:focus-visible .house-door__rule { width: 4.75rem; }

  .house-doors:has(.house-door:hover) .house-door:not(:hover) .house-door__media,
  .house-doors:has(.house-door:focus-visible) .house-door:not(:focus-visible) .house-door__media {
    filter: saturate(0.4) brightness(0.72);
  }
}

/* ---------------------------------------------------------
   Arrival
   --------------------------------------------------------- */
@keyframes houseImage {
  from { opacity: 0; transform: scale(1.12); }
}

@keyframes houseRise {
  from { opacity: 0; transform: translateY(18px); }
}

@keyframes houseFade {
  from { opacity: 0; }
}

/* Fill mode is backwards only: every keyframe ends on the element's own
   value, so hover and leave transitions are never pinned by a finished animation. */
.house-door__media { animation: houseImage 1.8s var(--ease-out) backwards; animation-delay: var(--lag, 0s); }
.house-door--runic { --lag: 0.12s; }

.house-door__body > * { animation: houseRise 1.1s var(--ease-out) backwards; }
.house-door__body > :nth-child(1) { animation-delay: calc(0.35s + var(--lag, 0s)); }
.house-door__body > :nth-child(2) { animation-delay: calc(0.45s + var(--lag, 0s)); }
.house-door__body > :nth-child(3) { animation-delay: calc(0.58s + var(--lag, 0s)); }
.house-door__body > :nth-child(4) { animation-delay: calc(0.7s + var(--lag, 0s)); }

.house-door__index { animation: houseFade 1.4s 0.6s var(--ease-out) backwards; }

/* ---------------------------------------------------------
   Leaving (set by house.js just before navigation)
   --------------------------------------------------------- */
.house-stage.is-leaving .house-door { transition-duration: 0.8s; }
.house-stage.is-leaving .house-door.is-chosen { flex-grow: 14; }
.house-stage.is-leaving .house-door:not(.is-chosen) .house-door__body,
.house-stage.is-leaving .house-door:not(.is-chosen) .house-door__index { opacity: 0; transition: opacity 0.3s; }
.house-stage.is-leaving .house-door.is-chosen .house-door__body {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.45s 0.25s, transform 0.6s 0.2s var(--ease-out);
}

/* ---------------------------------------------------------
   Small screens and portrait: stack the two halves
   --------------------------------------------------------- */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  .house-doors { flex-direction: column; }

  .house-door {
    --pad: clamp(1.25rem, 6vw, 2.25rem);
    padding-bottom: var(--pad);
  }

  .house-door--runic {
    box-shadow: inset 0 1px 0 rgba(198, 163, 106, 0.55);
    padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom));
  }

  .house-door__index { top: var(--pad); }
  .house-door--pi .house-door__index { top: max(var(--pad), env(safe-area-inset-top)); }

  .house-door__body { gap: 0.55rem; }
  .house-door__name--pi { font-size: clamp(2rem, 9.5vw, 3rem); }
  .house-door__name--runic { font-size: clamp(2.6rem, 13vw, 4rem); }
  .house-door__line { max-width: 32ch; font-size: 0.88rem; }
  .house-door--runic .house-door__line { font-size: 1.04rem; }
  .house-door__cta { margin-top: 0.25rem; }

  .house-door--runic .house-door__veil {
    background:
      linear-gradient(0deg, rgba(8, 7, 6, 0.97) 0%, rgba(8, 7, 6, 0.88) 38%, rgba(8, 7, 6, 0.35) 72%, rgba(8, 7, 6, 0.55) 100%);
  }
}

@media (max-height: 560px) and (max-width: 760px) {
  .house-door__line { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .house-door,
  .house-door__media,
  .house-door__media img,
  .house-door__rule { transition: none; }

  .house-door__media,
  .house-door__body > *,
  .house-door__index { animation: none; }
}
