/* Phase 3: Living Author House sensory layer. Scoped, silent, additive. */
:root{
  --house-motion-fast:220ms;
  --house-motion-medium:520ms;
  --house-motion-slow:14s;
  --house-reveal-distance:14px;
  --house-ambient-opacity:.34;
  --house-room-accent:214,183,114;
  --house-room-secondary:91,27,30;
}
body[data-house-sensory="ready"]{
  isolation:isolate;
}
.house-atmosphere{
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  overflow:hidden;
  opacity:var(--house-ambient-opacity);
  transition:opacity var(--house-motion-medium) ease;
}
.house-atmosphere::before,
.house-atmosphere::after,
.house-atmosphere-layer{
  content:"";
  position:absolute;
  inset:-18%;
  transform:translate3d(0,0,0);
  will-change:transform,opacity;
}
.house-atmosphere::before{
  background:
    radial-gradient(circle at 18% 18%,rgba(var(--house-room-accent),.16),transparent 31%),
    radial-gradient(circle at 84% 28%,rgba(var(--house-room-secondary),.13),transparent 36%);
  animation:houseAmbientDrift var(--house-motion-slow) ease-in-out infinite alternate;
}
.house-atmosphere::after{
  background:linear-gradient(115deg,transparent 30%,rgba(var(--house-room-accent),.055) 49%,transparent 66%);
  transform:translateX(-22%);
  animation:houseAmbientSweep 18s ease-in-out infinite;
}
.house-atmosphere-layer{
  background-image:radial-gradient(circle,rgba(247,236,214,.13) 0 1px,transparent 1.3px);
  background-size:86px 86px;
  opacity:.12;
  animation:houseAmbientFloat 24s linear infinite;
}
body[data-house-theme="guide"]{--house-room-accent:240,217,156;--house-room-secondary:76,42,30}
body[data-house-theme="portrait"]{--house-room-accent:226,197,137;--house-room-secondary:87,39,42}
body[data-house-theme="contact"]{--house-room-accent:211,184,125;--house-room-secondary:67,39,52}
body[data-house-theme="bookshop"]{--house-room-accent:233,199,124;--house-room-secondary:112,35,40}
body[data-house-theme="serial"]{--house-room-accent:239,153,75;--house-room-secondary:122,32,27}
body[data-house-theme="library"]{--house-room-accent:202,184,122;--house-room-secondary:52,48,37}
body[data-house-theme="letter"]{--house-room-accent:232,211,170;--house-room-secondary:94,48,47}
body[data-house-theme="gifts"]{--house-room-accent:230,199,145;--house-room-secondary:89,46,62}
body[data-house-theme="desk"]{--house-room-accent:238,203,125;--house-room-secondary:105,43,31}
body[data-house-theme="beyond"]{--house-room-accent:184,195,222;--house-room-secondary:78,45,98}

/* Meaningful room signatures */
body[data-house-signature="doorway-light"] .hero-panel,
body[data-house-signature="path-light"] .hero-panel{
  box-shadow:var(--shadow),0 0 0 1px rgba(var(--house-room-accent),.04),0 0 62px rgba(var(--house-room-accent),.08);
}
body[data-house-signature="doorway-light"] .start-here-primary,
body[data-house-signature="path-light"] .start-gateway .btn:first-child{
  position:relative;
  overflow:hidden;
}
body[data-house-signature="doorway-light"] .start-here-primary::after,
body[data-house-signature="path-light"] .start-gateway .btn:first-child::after{
  content:"";
  position:absolute;
  inset:-2px;
  background:linear-gradient(112deg,transparent 28%,rgba(255,248,220,.26) 48%,transparent 68%);
  transform:translateX(-125%);
  animation:houseDoorwayPass 7.5s ease-in-out 1.2s infinite;
  pointer-events:none;
}
body[data-house-signature="portrait-halo"] .author-photo-frame,
body[data-house-signature="portrait-halo"] .hero-panel{
  box-shadow:var(--shadow),0 0 70px rgba(var(--house-room-accent),.08);
}
body[data-house-signature="signal-line"] .contact-house-address{
  position:relative;
}
body[data-house-signature="signal-line"] .contact-house-address::after{
  content:"";
  display:block;
  width:min(180px,55%);
  height:1px;
  margin-top:16px;
  background:linear-gradient(90deg,rgba(var(--house-room-accent),.72),transparent);
  transform-origin:left;
  animation:houseSignal 5.6s ease-in-out infinite;
}
body[data-house-signature="cover-glint"] .book-card img,
body[data-house-signature="cover-glint"] .start-book-spotlight img{
  transition:transform var(--house-motion-medium) cubic-bezier(.2,.75,.2,1),filter var(--house-motion-medium) ease,box-shadow var(--house-motion-medium) ease;
}
body[data-house-signature="cover-glint"] .book-card:hover img,
body[data-house-signature="cover-glint"] .book-card:focus-within img,
body[data-house-signature="cover-glint"] .start-book-spotlight:hover img,
body[data-house-signature="cover-glint"] .start-book-spotlight:focus-within img{
  transform:translateY(-4px) rotateX(.8deg);
  filter:brightness(1.045) saturate(1.04);
  box-shadow:0 30px 76px rgba(0,0,0,.52),0 0 34px rgba(var(--house-room-accent),.12);
}
body[data-house-signature="ember-thread"] .divider,
body[data-house-signature="reading-progress"] .divider{
  background:linear-gradient(90deg,transparent,rgba(240,170,90,.18),rgba(240,217,156,.62),rgba(240,170,90,.18),transparent);
  background-size:180% 100%;
  animation:houseEmberLine 9s ease-in-out infinite;
}
body[data-house-signature="shelf-lamp"] .door-card,
body[data-house-signature="shelf-lamp"] .letter-room-doorway{
  transition:border-color var(--house-motion-medium) ease,box-shadow var(--house-motion-medium) ease,transform var(--house-motion-fast) ease;
}
body[data-house-signature="shelf-lamp"] .door-card:hover,
body[data-house-signature="shelf-lamp"] .door-card:focus-within,
body[data-house-signature="shelf-lamp"] .letter-room-doorway:hover,
body[data-house-signature="shelf-lamp"] .letter-room-doorway:focus-within{
  border-color:rgba(var(--house-room-accent),.46);
  box-shadow:var(--shadow),0 0 42px rgba(var(--house-room-accent),.075);
}
body[data-house-signature="paper-breath"] .paper,
body[data-house-signature="paper-breath"] .letter-room-product-card,
body[data-house-signature="paper-breath"] .hero-panel{
  background-image:
    linear-gradient(145deg,rgba(36,18,16,.88),rgba(18,9,8,.78)),
    repeating-linear-gradient(0deg,rgba(255,255,255,.014) 0 1px,transparent 1px 5px);
}
body[data-house-signature="keepsake-ribbon"] .gift,
body[data-house-signature="keepsake-ribbon"] .paper,
body[data-house-signature="keepsake-ribbon"] .card{
  position:relative;
}
body[data-house-signature="keepsake-ribbon"] .gift::after,
body[data-house-signature="keepsake-ribbon"] .paper::after,
body[data-house-signature="keepsake-ribbon"] .card::after{
  content:"";
  position:absolute;
  left:14%;
  right:14%;
  bottom:0;
  height:1px;
  background:linear-gradient(90deg,transparent,rgba(var(--house-room-accent),.5),transparent);
}
body[data-house-signature="desk-lamp"] .author-desk-card:first-of-type,
body[data-house-signature="desk-lamp"] .author-desk-spotlight{
  box-shadow:0 26px 72px rgba(0,0,0,.44),0 0 58px rgba(var(--house-room-accent),.08);
}
body[data-house-signature="distant-stars"] .house-atmosphere-layer{
  background-size:58px 58px;
  opacity:.22;
}

/* Progressive reveal. Content is never hidden before JavaScript runs. */
body[data-house-sensory="ready"] .house-sensory-reveal{
  opacity:.84;
  transform:translateY(var(--house-reveal-distance));
  filter:saturate(.94);
  transition:
    opacity var(--house-motion-medium) ease,
    transform var(--house-motion-medium) cubic-bezier(.2,.78,.25,1),
    filter var(--house-motion-medium) ease;
}
body[data-house-sensory="ready"] .house-sensory-reveal.is-house-visible{
  opacity:1;
  transform:none;
  filter:none;
}

/* Reading progress is informational, not decorative. */
.house-reading-thread{
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:3px;
  z-index:120;
  pointer-events:none;
  background:rgba(5,3,3,.28);
}
.house-reading-thread::after{
  content:"";
  display:block;
  width:var(--house-reading-progress,0%);
  height:100%;
  background:linear-gradient(90deg,rgba(180,74,42,.84),rgba(240,217,156,.96));
  box-shadow:0 0 12px rgba(239,160,80,.36);
  transition:width 120ms linear;
}

/* Comfort Mode control is placed inside the existing House Map. */
.house-comfort-panel{
  display:grid;
  gap:10px;
  margin-top:16px;
  padding-top:16px;
  border-top:1px solid rgba(214,183,114,.18);
}
.house-comfort-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}
.house-comfort-copy strong{
  display:block;
  font-family:Georgia,"Times New Roman",serif;
  color:var(--ivory,#f7ecd6);
  font-size:16px;
}
.house-comfort-copy span{
  display:block;
  margin-top:4px;
  color:var(--muted,#b7a78b);
  font-size:12px;
  line-height:1.5;
}
.house-comfort-toggle{
  flex:0 0 auto;
  min-width:86px;
  border:1px solid rgba(240,217,156,.46);
  border-radius:999px;
  padding:9px 13px;
  background:rgba(255,255,255,.04);
  color:var(--ivory,#f7ecd6);
  font:inherit;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}
.house-comfort-toggle[aria-pressed="true"]{
  background:rgba(214,183,114,.18);
  color:var(--gold2,#f0d99c);
}
.house-comfort-toggle:focus-visible{
  outline:2px solid var(--gold2,#f0d99c);
  outline-offset:3px;
}
.house-comfort-status{
  min-height:1.4em;
  color:var(--gold2,#f0d99c);
  font-size:12px;
}

/* Explicit comfort and system-reduced states. */
body[data-house-comfort="true"]{
  --house-ambient-opacity:.12;
  --house-reveal-distance:0px;
}
body[data-house-comfort="true"] .house-atmosphere::before,
body[data-house-comfort="true"] .house-atmosphere::after,
body[data-house-comfort="true"] .house-atmosphere-layer,
body[data-house-comfort="true"] .start-here-primary::after,
body[data-house-comfort="true"] .start-gateway .btn:first-child::after,
body[data-house-comfort="true"] .contact-house-address::after,
body[data-house-comfort="true"] .divider{
  animation:none!important;
}
body[data-house-comfort="true"] .house-sensory-reveal{
  opacity:1!important;
  transform:none!important;
  filter:none!important;
}
body[data-house-low-power="true"] .house-atmosphere{
  display:none;
}

@keyframes houseAmbientDrift{
  from{transform:translate3d(-1.5%,0,0) scale(1)}
  to{transform:translate3d(1.5%,-1%,0) scale(1.025)}
}
@keyframes houseAmbientSweep{
  0%,18%{transform:translateX(-28%);opacity:0}
  38%{opacity:.6}
  58%,100%{transform:translateX(28%);opacity:0}
}
@keyframes houseAmbientFloat{
  from{transform:translate3d(0,0,0)}
  to{transform:translate3d(34px,-28px,0)}
}
@keyframes houseDoorwayPass{
  0%,66%{transform:translateX(-125%);opacity:0}
  76%{opacity:.8}
  91%,100%{transform:translateX(125%);opacity:0}
}
@keyframes houseSignal{
  0%,100%{transform:scaleX(.55);opacity:.42}
  50%{transform:scaleX(1);opacity:.86}
}
@keyframes houseEmberLine{
  0%,100%{background-position:0 0;opacity:.68}
  50%{background-position:100% 0;opacity:1}
}

@media (max-width:760px){
  :root{
    --house-motion-medium:380ms;
    --house-motion-slow:20s;
    --house-reveal-distance:8px;
    --house-ambient-opacity:.22;
  }
  .house-atmosphere-layer{opacity:.075;background-size:112px 112px}
  .house-comfort-row{align-items:flex-start}
  .house-comfort-toggle{min-width:78px;padding:8px 11px}
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto!important}
  .house-atmosphere::before,
  .house-atmosphere::after,
  .house-atmosphere-layer,
  body[data-house-signature] .start-here-primary::after,
  body[data-house-signature] .start-gateway .btn:first-child::after,
  body[data-house-signature] .contact-house-address::after,
  body[data-house-signature] .divider{
    animation:none!important;
  }
  body[data-house-sensory="ready"] .house-sensory-reveal{
    opacity:1!important;
    transform:none!important;
    filter:none!important;
    transition:none!important;
  }
  .house-reading-thread::after{transition:none}
}

body[data-house-sensory="ready"] .footer{position:relative;z-index:1}
