/* ============================================================================
   advent.css — the ADVENT HUB (site/twelve-days/index.html)
   The "Twelve Days of Westhaven" street: twelve paper-cut houses at night,
   one lighting per day. Links theme.css read-only; owns only this page.

   All palette/type/texture tokens come from theme.css. Nothing here redefines
   a shared token or a shared component class. The house geometry is inline SVG
   generated by advent.js; this file styles its states (locked / today / open).

   Sections:
     1. Header + the cold countdown
     2. Intro band
     3. The street: scroll container, edge fades, pan affordances
     4. The scene: base SVG element styling
     5. House states: locked / today (pulse + ajar) / open, glow, teaser, porch
     6. The letter modal (unfolding, cream paper, torn edge)
     7. The refusal toast
     8. Footer
     9. Reduced motion + responsive
   ========================================================================== */

/* ---------------------------------------------------------------------------
   1. HEADER + COUNTDOWN
   --------------------------------------------------------------------------- */
.advent-header {
  position: fixed; inset: 0 0 auto 0; z-index: var(--z-header);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding: clamp(0.7rem, 1.8vw, 1.2rem) var(--space-5);
  background: color-mix(in srgb, var(--navy-deep) 84%, transparent);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
}
.advent-header .brand {
  font-family: var(--font-display); font-weight: 300;
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  font-size: var(--fs-500); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.advent-header .brand b { font-weight: 600; color: var(--gold); }

/* the countdown: a patient display face. No red, no bounce, no bold urgency. */
.countdown {
  display: flex; align-items: baseline; gap: 0.6em;
  margin: 0; text-align: center;
  color: var(--ink-faint);
  font-family: var(--font-display);
  letter-spacing: var(--tracking-mid);
  text-transform: uppercase;
}
.countdown__label { font-size: var(--fs-100); color: var(--ink-faint); }
.countdown__time {
  font-family: var(--font-mono);
  font-size: var(--fs-300);
  letter-spacing: 0.08em;
  color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
  text-transform: none;
}
.countdown.is-complete .countdown__label { color: var(--ink-soft); }
.countdown.is-complete .countdown__time { display: none; }

.advent-back {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-mid); font-size: var(--fs-200);
  color: var(--ink-soft); text-decoration: none; white-space: nowrap;
  transition: color var(--dur-1);
}
.advent-back:hover, .advent-back:focus-visible { color: var(--gold); }

/* ---------------------------------------------------------------------------
   2. INTRO BAND
   --------------------------------------------------------------------------- */
.advent-intro {
  position: relative; z-index: var(--z-content);
  padding: calc(4.2rem + 1vw) var(--space-4) var(--space-3);
}
.advent-intro__title { margin: 0.1em auto 0; }
.advent-intro__lede { margin: var(--space-3) auto 0; color: var(--ink-soft); }
@media (max-height: 760px) {
  /* short laptops: keep the street above the fold */
  .advent-intro__title { font-size: var(--fs-800); }
  .advent-intro__lede { font-size: var(--fs-400); }
}

/* ---------------------------------------------------------------------------
   3. THE STREET (scroll container + pan affordances)
   --------------------------------------------------------------------------- */
.street-wrap {
  position: relative; z-index: var(--z-content);
  width: 100%;
  margin-top: var(--space-3);
}
/* left / right edge fades: a hint that the street runs on past the viewport */
.street-wrap::before,
.street-wrap::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: clamp(28px, 6vw, 84px);
  z-index: 3; pointer-events: none;
}
.street-wrap::before { left: 0;  background: linear-gradient(90deg, var(--navy-deep), transparent); }
.street-wrap::after  { right: 0; background: linear-gradient(270deg, var(--navy-deep), transparent); }

.street {
  /* a pannable horizontal strip: capped so tall / portrait viewports don't
     inflate the scene into a wall of sky. */
  height: clamp(360px, 56vh, 560px);
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  /* momentum scroll on touch; the scrollbar stays subtle */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cream-20) transparent;
}
.street.is-grabbing { cursor: grabbing; }
.street:focus-visible { outline: none; }
.street::-webkit-scrollbar { height: 8px; }
.street::-webkit-scrollbar-track { background: transparent; }
.street::-webkit-scrollbar-thumb { background: var(--cream-10); border-radius: 4px; }
.street::-webkit-scrollbar-thumb:hover { background: var(--cream-20); }

/* the scene scales to the container height; its width falls out of the viewBox
   aspect ratio, so it is wider than the viewport and scrolls horizontally. */
.street__scene {
  height: 100%;
  width: auto;
  display: block;
  /* keep it from being squeezed by flex/inline sizing */
  max-width: none;
  /* Width normally falls out of height x aspect ratio. On wide + short screens
     the height cap shrinks that derived width below the viewport, killing the
     pan runway. Floor it so the strip is always wider than the viewport: an
     absolute minimum plus a viewport-relative one that guarantees overflow. */
  min-width: max(2200px, 118vw);
}

/* a soft "drag to explore" hint that fades on first interaction */
.street__hint {
  position: absolute; left: 50%; bottom: var(--space-3); transform: translateX(-50%);
  z-index: 4; margin: 0; pointer-events: none;
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-caps); font-size: var(--fs-100);
  color: var(--ink-faint);
  background: color-mix(in srgb, var(--navy-black) 70%, transparent);
  padding: 0.5em 1em; border-radius: 999px;
  transition: opacity var(--dur-2) var(--ease-cold);
}
.street-wrap.is-panned .street__hint { opacity: 0; }

.street__noscript {
  padding: var(--space-5); text-align: center; color: var(--ink-soft);
}
.street__aside {
  position: relative; z-index: var(--z-content);
  margin-top: var(--space-5); padding: 0 var(--space-4) var(--space-7);
  color: var(--ink-faint); font-size: var(--fs-300); font-style: italic;
}

/* one-time nudge shown when the street is first panned to its right end */
.street__tour-note {
  position: relative; z-index: var(--z-content);
  margin: var(--space-3) auto 0; max-width: 44ch; text-align: center;
  color: var(--ink-faint); font-size: var(--fs-300); font-style: italic;
  letter-spacing: var(--tracking-mid);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-cold), transform var(--dur-2) var(--ease-cold);
}
.street__tour-note.is-shown { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .street__tour-note { transition: none; }
}

/* ---------------------------------------------------------------------------
   4. THE SCENE: base SVG element styling
   (elements are emitted by advent.js with these class names)
   --------------------------------------------------------------------------- */
.sky-haze   { fill: url(#skyHaze); }
.moon       { fill: var(--cream); }
.moon-glow  { fill: url(#moonGlow); }
.hill-far   { fill: #0a121e; }
.hill-mid   { fill: #0b1420; }
.hill-near  { fill: #0c1626; }
.ground     { fill: url(#groundGrad); }
.ground-line{ stroke: rgba(242,237,226,0.16); stroke-width: 2; fill: none; }

.tree   { stroke: #070b12; stroke-width: 3.4; stroke-linecap: round; fill: none; }
.tree-cap { fill: rgba(242,237,226,0.55); }
.fence  { fill: #090d15; }
.fence-cap { fill: rgba(242,237,226,0.45); }

/* the lonely trailer at the end of the road: never numbered, never unlocks.
   It reads as a small single-wide on a hill: arched roof, panel seams, a door,
   a stovepipe with a wisp of smoke, one dim dirty-gold window, and a moonlight
   rim on the roof and the hill crest. Never as bright as a lit house. */
.trailer-body { fill: #0d141e; }
.trailer-door { fill: #05090f; }
.trailer-knob { fill: rgba(232,221,196,0.30); }
.trailer-pipe { fill: #05090f; }
.trailer-seam { fill: none; stroke: #05090f; stroke-width: 1.6; stroke-linecap: round; }
.trailer-win  { fill: #8a6326; opacity: 0.92; }   /* muted dirty gold, ~55% of a lit house window */
.trailer-winglow { fill: url(#winGlow); opacity: 0.34; }   /* faint halo, far dimmer than a house */
.trailer-hill { fill: #0b1422; }
.trailer-rim  { fill: none; stroke: rgba(232,221,196,0.44); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.trailer-smoke { fill: none; stroke: rgba(232,221,196,0.16); stroke-width: 2.4;
  stroke-linecap: round; transform-box: fill-box; transform-origin: bottom center;
  animation: trailer-smoke 7s ease-in-out infinite; will-change: opacity, transform; }
@keyframes trailer-smoke {
  0%, 100% { opacity: 0.10; transform: translateX(0) scaleY(1); }
  50%      { opacity: 0.20; transform: translateX(1.5px) scaleY(1.05); }
}

/* ---------------------------------------------------------------------------
   5. HOUSE STATES
   Every house is a <g class="house" data-day="N"> with these children.
   Default appearance = LOCKED (dark). Modifier classes light it.
   --------------------------------------------------------------------------- */
.house__body   { fill: #0a0f18; }
.house__roof   { fill: #070b12; }
.house__trim   { fill: #0c1220; }
.house__cap    { fill: none; stroke: rgba(242,237,226,0.5); stroke-width: 2.4; stroke-linecap: round; }
.house__door   { fill: #0b1119; transform-box: fill-box; transform-origin: left bottom; }
.house__doorlight { fill: url(#doorGlow); opacity: 0; transition: opacity var(--dur-2) var(--ease-cold); }

.house__window {
  fill: #0e1723; stroke: #05090f; stroke-width: 1;
  transition: fill var(--dur-2) var(--ease-cold), stroke var(--dur-2);
}
.house__winglow { fill: url(#winGlow); opacity: 0; transition: opacity var(--dur-2) var(--ease-cold); }
.house__glow    { fill: url(#groundGlow); opacity: 0; transition: opacity var(--dur-3) var(--ease-cold); }

/* the porch light bulb under the eave: dim when off */
.house__porch { fill: #241a0d; }

/* the faint interior silhouette (teaser), only meaningful when locked */
.house__teaser { fill: rgba(226,161,61,0.72); opacity: 0; transition: opacity var(--dur-2) var(--ease-cold); }

/* the warm sliver of light through a TODAY door left ajar (revealed as the door swings) */
.house__doorajar {
  fill: #f2c877; opacity: 0;
  transition: opacity var(--dur-2) var(--ease-cold);
}

/* smoke + special bits stay quiet until lit */
.house__smoke { fill: none; stroke: rgba(232,221,196,0.12); stroke-width: 3; stroke-linecap: round; }
.house__led   { fill: var(--moss); opacity: 0.85; }
.house__bell  { fill: #0d1220; }

/* the transparent hit target over each house */
.house__hit { fill: #000; opacity: 0; pointer-events: all; }
.house--locked .house__hit { cursor: pointer; }
.house--open  .house__hit,
.house--today .house__hit { cursor: pointer; }
/* keyboard focus ring (SVG can't use outline reliably; use a drawn frame) */
.house__frame {
  fill: none; stroke: var(--gold); stroke-width: 2; opacity: 0;
  stroke-dasharray: 5 5; rx: 4;
  transition: opacity var(--dur-1);
}
.house:focus-within .house__frame { opacity: 0.8; }

/* -- LOCKED (default) shows the teaser on hover / keyboard focus -- */
.house--locked:hover .house__teaser,
.house--locked:focus-within .house__teaser { opacity: 0.9; }
.house--locked:hover .house__window,
.house--locked:focus-within .house__window { fill: #14202f; }

/* -- OPEN (past days): lit steady -- */
.house--open .house__window { fill: var(--gold); stroke: #7c5a20; }
.house--open .house__winglow { opacity: 0.5; }
.house--open .house__glow    { opacity: 0.62; }
.house--open .house__porch   { fill: var(--gold); }
.house--open .house__led     { opacity: 1; }
.house--open .house__smoke   { stroke: rgba(232,221,196,0.2); }

/* -- TODAY: warm-lit, gentle pulse, door slightly ajar -- */
.house--today .house__window { fill: var(--gold); stroke: #7c5a20; }
.house--today .house__winglow { opacity: 0.62; }
.house--today .house__glow    { opacity: 0.78; }
.house--today .house__porch   { fill: var(--gold); }
.house--today .house__led     { opacity: 1; }
.house--today .house__doorlight { opacity: 0.85; }
.house--today .house__doorajar { opacity: 0.95; }
.house--today .house__door    { transform: rotate(-7deg); }   /* ajar (a state, kept under reduced motion) */
.house--today .house__smoke   { stroke: rgba(232,221,196,0.24); }

/* the pulse lives on a wrapper group so it doesn't fight the window fill transition */
.house--today .house__lit {
  transform-box: fill-box; transform-origin: center;
  animation: house-pulse 3.6s var(--ease-drift) infinite;
}
@keyframes house-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.72; }
}

/* the mailbox number + the locked-only date */
.house__mailpost { fill: #0c1220; }
.house__mailbox  { fill: #10192a; stroke: #05090f; stroke-width: 1; }
.house__num {
  fill: var(--cream-dim); font-family: var(--font-display); font-weight: 600;
  font-size: 17px; letter-spacing: 0.5px; text-anchor: middle;
}
.house--open .house__num, .house--today .house__num { fill: var(--gold); }
.house__maildate {
  fill: var(--ink-faint); font-family: var(--font-display); font-weight: 400;
  font-size: 10px; letter-spacing: 1px; text-anchor: middle; text-transform: uppercase;
}
.house--open .house__maildate, .house--today .house__maildate { opacity: 0; }

/* the porch flicker fired once by advent.js on a locked click */
.house__porch.is-flickering { animation: porch-flicker 0.52s steps(1, end) 1; }
@keyframes porch-flicker {
  0%   { fill: var(--gold); }
  18%  { fill: #241a0d; }
  34%  { fill: var(--gold); }
  52%  { fill: #241a0d; }
  70%  { fill: var(--gold); }
  100% { fill: #241a0d; }
}

/* ---------------------------------------------------------------------------
   6. THE LETTER MODAL (unfolding, cream paper, torn top)
   --------------------------------------------------------------------------- */
.letter {
  border: none; padding: 0; background: transparent;
  width: min(560px, 92vw); max-height: 88vh;
  color: #241d12;
  overflow: visible;
}
.letter::backdrop {
  background: rgba(5, 8, 14, 0.62);
  backdrop-filter: blur(2px);
}
.letter[open] { animation: letter-unfold 0.5s var(--ease-cold); transform-origin: top center; }
@keyframes letter-unfold {
  0%   { opacity: 0; transform: perspective(1100px) rotateX(-82deg) translateY(-8px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: perspective(1100px) rotateX(0deg) translateY(0); }
}
.letter__paper {
  position: relative;
  background: linear-gradient(178deg, #efe7d3 0%, #e6dabf 62%, #ddceac 100%);
  color: #2a2214;
  border-radius: 3px;
  padding: clamp(1.5rem, 2rem + 2vw, 2.6rem);
  padding-top: clamp(1.9rem, 2.2rem + 2vw, 2.9rem);
  box-shadow: var(--shadow-3), inset 0 0 0 1px rgba(120, 96, 52, 0.25);
  max-height: 88vh; overflow-y: auto;
}
/* the torn top edge, cut into the cream paper */
.letter__torn {
  position: absolute; left: 0; right: 0; top: -1px; height: 16px;
  background: #efe7d3;
  -webkit-mask-image: var(--torn-mask); mask-image: var(--torn-mask);
  -webkit-mask-size: 180px 100%; mask-size: 180px 100%;
  -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
  transform: scaleY(-1);
}
.letter__close {
  position: absolute; top: 0.5rem; right: 0.7rem;
  width: 2rem; height: 2rem; line-height: 1;
  font-size: 1.6rem; color: #6b5a3a;
  display: grid; place-items: center; border-radius: 50%;
  transition: color var(--dur-1), background-color var(--dur-1);
}
.letter__close:hover, .letter__close:focus-visible { color: #2a2214; background: rgba(120, 96, 52, 0.16); }

.letter__eyebrow {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); font-size: var(--fs-200);
  color: #8a6d3c; display: flex; gap: 0.5em; align-items: baseline; margin: 0;
}
.letter__sep { opacity: 0.6; }
.letter__title {
  font-family: var(--font-display); font-weight: 400;
  text-transform: uppercase; letter-spacing: var(--tracking-mid);
  font-size: var(--fs-800); line-height: var(--lh-snug); color: #241b0e;
  margin: 0.35em 0 0.15em;
}
.letter__format { font-family: var(--font-body); font-style: italic; color: #6f5a35; margin: 0; }
.letter__rule {
  height: 1px; margin: var(--space-4) 0;
  background: repeating-linear-gradient(90deg, rgba(120,96,52,0.5) 0 6px, transparent 6px 12px);
}
.letter__desc {
  font-family: var(--font-body); color: #33291a; line-height: var(--lh-body);
  font-size: var(--fs-500); max-width: none; margin: 0;
}
.letter__cta { margin-top: var(--space-5); }
.letter__note {
  margin-top: var(--space-4); font-size: var(--fs-200); color: #8a7550;
  font-style: italic; max-width: none;
}

/* ---------------------------------------------------------------------------
   7. THE REFUSAL TOAST (locked-house one-liner)
   --------------------------------------------------------------------------- */
.refusal {
  position: fixed; z-index: calc(var(--z-tooltip) + 5);
  max-width: 15rem;
  padding: 0.55em 0.85em;
  font-family: var(--font-body); font-style: italic; font-size: var(--fs-200);
  line-height: 1.4; color: var(--cream);
  background: rgba(8, 14, 23, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  pointer-events: none;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur-1) var(--ease-drift), transform var(--dur-1) var(--ease-drift);
}
.refusal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------------------------------------------------------------------------
   8. FOOTER
   --------------------------------------------------------------------------- */
.advent-footer {
  position: relative; z-index: var(--z-content);
  border-top: 1px solid var(--line-soft);
  background: var(--navy-black);
  padding: var(--space-7) var(--space-5) var(--space-6);
  min-height: 180px; overflow: hidden;
}
.advent-footer .footer__row {
  display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: center;
  justify-content: space-between; position: relative; z-index: var(--z-content);
}
.advent-footer .footer__meta {
  font-size: var(--fs-200); color: var(--ink-faint); display: flex; align-items: center; gap: 0.6em;
}
.advent-footer .footer__links { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.advent-footer .footer__links a {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: var(--tracking-mid); font-size: var(--fs-100);
  color: var(--ink-soft); text-decoration: none;
}
.advent-footer .footer__links a:hover { color: var(--gold); }
.advent-footer .footer__ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--line-soft), transparent);
}

/* ---------------------------------------------------------------------------
   item 4b: street christmas decoration (paper-cut, competitive Westhaven cheer)
   --------------------------------------------------------------------------- */
.hl-wire { fill: none; stroke: rgba(232,221,196,0.22); stroke-width: 1.4; }
.hl-bulb { transform-box: fill-box; transform-origin: center;
  animation: hl-twinkle 4.2s var(--ease-drift) infinite; will-change: opacity; }
.hl-bulb:nth-of-type(2n)   { animation-delay: -1.2s; }
.hl-bulb:nth-of-type(3n)   { animation-delay: -2.6s; }
.hl-bulb:nth-of-type(4n+1) { animation-delay: -3.4s; }
@keyframes hl-twinkle { 0%, 100% { opacity: 1; } 48% { opacity: 0.5; } 62% { opacity: 0.92; } }
.hw-ring  { fill: none; stroke: var(--moss); stroke-width: 3; }
.hw-berry { fill: var(--crimson); }
.hw-bow   { fill: var(--crimson); }

/* the one yard inflatable Santa */
.inf-shadow { fill: rgba(0,0,0,0.4); }
.inf-body   { fill: var(--crimson); }
.inf-trim   { fill: var(--snow); }
.inf-face   { fill: var(--cream); }
.inf-belt   { fill: #1a1510; }
.inf-buckle { fill: var(--gold); }

/* ---------------------------------------------------------------------------
   item 13: the trailer stays bare, but it is clickable, and Grant rises
   --------------------------------------------------------------------------- */
.trailer-hit { fill: #000; opacity: 0; cursor: pointer; pointer-events: all; }
.trailer-hit:focus-visible { outline: none; }
.trailer-group:focus-within .trailer-hit { outline: none; }
.grant-cutout { pointer-events: none; filter: brightness(0.9); }
/* at rest he sits fully below the crest (hidden by the front hill + ground clip);
   .is-risen lifts him so head, shoulders, and most of the coat tower over the
   hill beside the trailer (he is six-foot-four; the reveal should read big),
   while waist-down stays masked behind the front hill. */
.trailer-grant { transform: translateY(95px); transition: transform 0.7s var(--ease-cold);
  will-change: transform; }
.trailer-grant.is-risen { transform: translateY(0); }

/* ---------------------------------------------------------------------------
   9. REDUCED MOTION + RESPONSIVE
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hl-bulb { animation: none; opacity: 1; }
  .trailer-smoke { animation: none; opacity: 0.16; }
  .trailer-grant { transition: none; }
  /* no pulse, no flicker, no unfold. The scene stays lit and legible, static.
     (theme.css already zeroes animation/transition durations; these make the
     lit / ajar STATES explicit so nothing depends on a transition to appear.) */
  .house--today .house__lit { animation: none; opacity: 1; }
  .house__porch.is-flickering { animation: none; }
  .letter[open] { animation: none; }
  .street__hint { transition: none; }
}

@media (max-width: 760px) {
  .advent-header { flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding-block: 0.6rem; }
  .countdown { order: 3; flex-basis: 100%; justify-content: center; }
  .advent-intro { padding-top: calc(5.8rem + 2vw); }
}
@media (max-width: 420px) {
  .countdown__label { display: none; }
  .countdown::before {
    content: "Next house:"; font-size: var(--fs-100); color: var(--ink-faint);
    letter-spacing: var(--tracking-mid);
  }
}
