/* The McCowan Study — Family Hub shell.
   Motion: MOTION-PROPOSAL.md (Animator). 
   E=cubic-bezier(.2,.8,.2,1) I=cubic-bezier(.2,0,0,1). No neon / glassmorphism. */

:root {
  --study-walnut: #3a2a22;
  --study-oxblood: #8b1e2d;
  --study-brass: #c4a35a;
  --study-ivory: #f7efe0;
  --study-amber: #f0c36a;
  --study-dusk: #1a2744;
  --study-ink: #1c1410;
  --study-panel: #f7efe0;
  --study-muted: #6b5a4c;
  --study-E: cubic-bezier(.2, .8, .2, 1);
  --study-I: cubic-bezier(.2, 0, 0, 1);
}

body.study-page {
  background: var(--study-dusk);
  color: var(--study-ivory);
  /* Plate is only inside .study-stage — never a full-screen tiled/stretched wallpaper */
  background-image: none;
  background-size: auto;
  background-repeat: no-repeat;
}

body.study-page header.top {
  background: rgba(26, 20, 16, .92);
  border-bottom: 1px solid rgba(196, 163, 90, .35);
}

body.study-page .study-section-nav,
#study-section-nav {
  display: none !important;
}
body.study-page .study-section-nav {
  display: none !important;
  flex-direction: row; /* override styles.css nav{flex-direction:column} at ≤1119px */
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
  align-items: center;
  padding: 10px 16px 0;
  background: rgba(26, 20, 16, .88);
  border-bottom: 1px solid rgba(196, 163, 90, .2);
  position: sticky;
  top: 0;
  z-index: 30;
}

body.study-page .study-section-nav a {
  display: inline-flex; /* never stretch full-width like mobile site nav */
  width: auto;
  color: var(--study-ivory);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

body.study-page .study-section-nav a:hover,
body.study-page .study-section-nav a:focus-visible {
  border-color: var(--study-brass);
  color: var(--study-amber);
  outline: none;
}

body.study-page .study-section-nav a[aria-current="true"] {
  background: rgba(196, 163, 90, .18);
  border-color: var(--study-brass);
  color: var(--study-amber);
}

/* Boot — skippable, under 2s */
#study-boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 100% at 50% 40%, #2a1f24 0%, #120e0c 100%);
  color: var(--study-ivory);
  transition: opacity 280ms var(--study-E), visibility 280ms;
}
#study-boot.hide { opacity: 0; visibility: hidden; pointer-events: none; }
#study-boot .boot-inner { text-align: center; padding: 24px; }
#study-boot .boot-mark {
  width: 48px; height: 48px; margin: 0 auto 14px;
  border: 3px solid rgba(247, 239, 224, .2);
  border-top-color: var(--study-brass);
  border-radius: 50%;
}
@media (prefers-reduced-motion: no-preference) {
  #study-boot .boot-mark { animation: study-spin 900ms linear infinite; }
}
@keyframes study-spin { to { transform: rotate(360deg); } }
#study-boot p { margin: 0 0 16px; letter-spacing: .04em; color: rgba(247, 239, 224, .85); }
#study-boot .btn-skip {
  background: transparent; color: var(--study-brass);
  border: 1px solid var(--study-brass); padding: 8px 16px;
  border-radius: 999px; cursor: pointer; font: inherit;
}

.study-main {
  padding: 0 0 48px;
  min-height: calc(100vh - 160px);
  /* Walnut / dusk vignette surround when the plate is letterboxed on wide screens */
  background:
    radial-gradient(120% 90% at 50% 40%, rgba(58, 42, 34, .35) 0%, rgba(12, 8, 6, .92) 70%, #0a0706 100%);
}

/* Native plate 1920×1080. Never stretch past ~1.15× (2208px). Wider viewports get a framed surround. */
.study-stage-wrap {
  --study-plate-w: 1920px;
  --study-scale-cap: 1.15;
  --study-stage-max: calc(var(--study-plate-w) * var(--study-scale-cap));
  width: min(100% - 24px, var(--study-stage-max));
  max-width: var(--study-stage-max);
  margin: 16px auto 0;
  display: flex;
  justify-content: center;
}

.study-note {
  margin: 0 0 12px; font-size: .85rem;
  color: rgba(247, 239, 224, .72); text-align: center;
}

/* Scene layer — hub controller may opacity/scale slightly for panel dim (≤1.03). No CSS blur. */
.study-stage {
  position: relative;
  width: 100%;
  max-width: var(--study-stage-max, 2208px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  /* overflow visible so v2.1 cutout scale (≈1.06) can read past the plate edge */
  overflow: visible;
  border: 1px solid rgba(196, 163, 90, .4);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  background: #1a1210;
  transform-origin: center center;
  /* Never tile or stretch as a page background */
  background-repeat: no-repeat;
  background-size: auto;
}
.study-stage.is-open {
  /* WAAPI owns open look */
}
/* legacy centered-hotspot rules removed — see clip-path hotspots below */

.study-mobile-cards { display: none; gap: 10px; margin-top: 14px; }
.study-mobile-cards button {
  width: 100%; text-align: left; padding: 14px 16px;
  border-radius: 10px; border: 1px solid rgba(196, 163, 90, .45);
  background: rgba(58, 42, 34, .9); color: var(--study-ivory);
  font: inherit; cursor: pointer;
}
.study-mobile-cards button strong {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.25rem; color: var(--study-amber);
}
.study-mobile-cards button span { font-size: .9rem; color: rgba(247, 239, 224, .75); }

/*
  Plate visibility: phone layers must NEVER paint on desktop.
  html.study-webp .study-layer-webp { display:block } is stronger than a lone
  .study-plate-phone { display:none }, so phone hides use !important.
  Phone plate: narrow ≤720 only (slot stays swappable for AD redo). Else desktop 16:9.
*/
.study-plate-phone,
html.study-webp .study-plate-phone,
html.study-webp .study-plate-phone.study-layer-webp,
html.study-no-webp .study-plate-phone {
  display: none !important;
}

@media (max-width: 720px) {
  html.js .study-stage-wrap {
    --study-plate-w: 1080px;
    --study-scale-cap: 1.15;
    --study-stage-max: calc(var(--study-plate-w) * var(--study-scale-cap)); /* ≈1242px */
    width: min(100% - 16px, var(--study-stage-max));
  }
  html.js .study-stage {
    display: block;
    aspect-ratio: 9 / 16;
    max-width: var(--study-stage-max, 1242px);
  }
  html.js .study-plate-desktop,
  html.js.study-webp .study-plate-desktop,
  html.js.study-webp .study-plate-desktop.study-layer-webp,
  html.js.study-no-webp .study-plate-desktop {
    display: none !important;
  }
  /* Phone: WebP layers OR PNG/WebP keyframe fallback — never both */
  html.js.study-webp .study-plate-phone.study-layer-fallback { display: none !important; }
  html.js.study-webp .study-plate-phone.study-layer-webp { display: block !important; }
  html.js.study-no-webp .study-plate-phone.study-layer-fallback { display: block !important; }
  html.js.study-no-webp .study-plate-phone.study-layer-webp { display: none !important; }
  html.js .study-mobile-cards { display: none !important; }
}

/* Backdrop / scrim — timed by hub controller */
#study-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 8, 6, .55);
  opacity: 0; visibility: hidden; pointer-events: none;
}
#study-backdrop.show { visibility: visible; pointer-events: auto; }

/* Panel shell — resting closed; open state positioned by JS/WAAPI */
#study-panel {
  position: fixed; z-index: 45;
  top: 0; right: 0; height: 100%;
  width: min(480px, 100vw);
  background: linear-gradient(180deg, var(--study-panel) 0%, #efe4d2 100%);
  color: var(--study-ink);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .4);
  border-left: 5px solid var(--study-brass);
  overflow-y: auto;
  padding: 1.4rem 1.4rem 2.4rem;
  visibility: hidden;
  opacity: 0;
  /* Desktop closed: ready to slide 24px */
  transform: translateX(24px);
}
#study-panel.open { visibility: visible; }

@media (max-width: 720px) {
  #study-panel {
    left: 0; right: 0; width: 100vw; height: 100%;
    border-left: none; border-top: 5px solid var(--study-brass);
    transform: translateY(32px);
    border-radius: 0;
  }
}

.study-panel-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 1rem;
}
.study-panel-bar button {
  border: 0; background: rgba(58, 42, 34, .1); color: var(--study-ink);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.1rem;
}
.study-panel-bar button:hover,
.study-panel-bar button:focus-visible {
  background: rgba(58, 42, 34, .2);
  outline: 2px solid var(--study-brass);
}

#study-panel-tag {
  text-transform: uppercase; letter-spacing: .14em;
  font-size: .72rem; font-weight: 700; color: var(--study-oxblood); margin: 0 0 .35rem;
}
#study-panel-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.85rem; line-height: 1.15; margin: 0 0 1rem; color: var(--study-ink);
}
#study-panel-body { font-size: 1rem; line-height: 1.65; color: #3c3228; }
#study-panel-body h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.25rem; margin: 1.2rem 0 .4rem;
}
#study-panel-body .study-card {
  background: rgba(58, 42, 34, .06);
  border: 1px solid rgba(58, 42, 34, .12);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 10px;
}
#study-panel-body .study-empty {
  padding: 14px; border-radius: 10px;
  background: rgba(196, 163, 90, .12); color: var(--study-muted); font-size: .95rem;
}
#study-panel-body .study-legal { margin-top: 1.2rem; font-size: .82rem; color: var(--study-muted); }

body.study-panel-open { overflow: hidden; }

/* No-JS / crawler fallback: five stacked sections */
.study-noscript {
  width: min(720px, calc(100% - 32px));
  margin: 24px auto 48px;
  color: var(--study-ivory);
}
.study-noscript section {
  margin: 0 0 28px; padding: 18px;
  border: 1px solid rgba(196, 163, 90, .35);
  border-radius: 12px; background: rgba(26, 20, 16, .55);
}
.study-noscript h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--study-amber); margin: 0 0 8px;
}
html.js .study-noscript { display: none; }
html:not(.js) .study-stage-wrap,
html:not(.js) #study-boot,
html:not(.js) #study-panel,
html:not(.js) #study-backdrop,
html:not(.js) .study-section-nav { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  #study-boot .boot-mark { animation: none; }
  .study-hotspot { transition: none; }
  #study-panel { transform: none; }
}


/* === Desktop AD plate layers + glows === */
.study-layers {
  position: absolute; inset: 0; pointer-events: none;
  overflow: hidden;
  border-radius: 12px;
  z-index: 1;
}
.study-layers .study-layer,
.study-layers picture.study-layer,
.study-layers img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  /* Contain-style: full plate visible inside the stage; walnut surround letterboxes any gap.
     Stage aspect matches the active plate (16:9 desktop / 9:16 phone), so contain fills without crop. */
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  display: block;
  filter: none; /* no CSS blur on the room art */
}
.study-layer-fallback { z-index: 0; }
.study-layer-webp { z-index: 1; display: none; }
html.study-webp .study-layer-fallback { display: none; }
html.study-webp .study-layer-webp { display: block; }
html.study-no-webp .study-layer-webp,
html.study-no-webp .study-objects { display: none !important; }

/*
  Per-object hover layers.
  v1 / missing cutout: glow only (no scale) — same as 56994a05.
  v2.1 + cutout PNG loaded (is-cutout-ready): cutout scales 1.06× from origin
  above the (unscaled) base plate; glow stays full-frame. Overflow not clipped.
  Labels live on .study-hotspot above the glow; crisp brass on dark (no yellow tint).
*/
.study-objects {
  position: absolute; inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.study-object {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: visible;
}
.study-object-src,
.study-object-glow {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important; /* no brightness/contrast wash — amber comes from the PNG */
}
.study-object-src {
  display: none; /* only shown when cutout has loaded */
  filter: none;
  transform: scale(1);
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  z-index: 1;
}
.study-object.is-cutout-ready .study-object-src { display: block; }
.study-object.is-cutout-ready { will-change: transform; }
.study-object-glow {
  display: block;
  opacity: 0;
  mix-blend-mode: screen;
  filter: none;
  z-index: 0; /* under cutout; labels sit above this whole layer */
}
@media (prefers-reduced-motion: no-preference) {
  .study-object.is-cutout-ready .study-object-src {
    transition: transform 180ms ease-out;
  }
  .study-object-glow {
    transition: opacity 180ms ease-out;
  }
}
.study-object.is-lit .study-object-glow {
  opacity: 1;
  filter: none; /* glow color comes only from the PNG + mix-blend-mode */
}
/* Scale ONLY the cutout image, and ONLY with a ready v2.1 cutout */
@media (prefers-reduced-motion: no-preference) {
  .study-object.is-cutout-ready.is-lit .study-object-src {
    transform: scale(1.06);
  }
}
@media (prefers-reduced-motion: reduce) {
  .study-object.is-cutout-ready .study-object-src,
  .study-object.is-cutout-ready.is-lit .study-object-src {
    transition: none;
    transform: none;
  }
  .study-object-glow { transition: none; }
}
/* No resting glow on any device: the art is plain at rest and glows only when
   hovered, focused, armed by a first tap, or opened (.is-lit). */

/* Labels stay hidden until the visible plate image has decoded. */
.study-hotspots:not(.is-plate-ready) .study-hotspot-label {
  visibility: hidden;
}

.study-hotspots {
  position: absolute; inset: 0;
  z-index: 5; /* above glow + cutout */
  isolation: isolate; /* keep screen-blend glow from tinting labels */
}
/* Labels from hotspots.json origins; glow is the hover cue (no rectangular fill). */
.study-stage {
  container-type: inline-size;
  container-name: study-stage;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.study-hotspot {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: var(--study-ivory);
  cursor: pointer;
  font: inherit;
  display: block;
  box-sizing: border-box;
  /* Never draw a hotspot-region rectangle (rest/hover/armed/lit/focus). */
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}
.study-hotspot span.study-hotspot-hit {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  border: 0;
  outline: none !important;
  box-shadow: none !important;
  background: transparent;
}
.study-hotspot {
  pointer-events: none; /* hits go to .study-hotspot-hit so labels aren't clip-path clipped */
}
/* Label pill only. The hit span is a sibling span and must keep its own
   inset: 0 + pointer-events: auto, so never style a bare `.study-hotspot span`. */
.study-hotspot span.study-hotspot-label {
  position: absolute;
  left: var(--label-x, 50%);
  top: var(--label-y, 50%);
  bottom: auto;
  transform: translate(-50%, -50%);
  display: block;
  pointer-events: none;
  font-size: clamp(14px, 1.2cqw, 30px);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  /* Crisp brass on solid dark — no yellow/ivory tint at rest or lit */
  color: var(--study-brass);
  background: #1a1210;
  padding: .35em .7em;
  border-radius: 999px;
  border: 1px solid rgba(196, 163, 90, .65);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .55);
  z-index: 1;
}
.study-hotspot:hover,
.study-hotspot:focus,
.study-hotspot:focus-visible,
.study-hotspot:active,
.study-hotspot.is-lit {
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  cursor: pointer;
}
.study-object,
.study-object.is-lit,
.study-object.is-cutout-ready {
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
}
.study-hotspot:hover span.study-hotspot-label,
.study-hotspot:focus-visible span.study-hotspot-label,
.study-hotspot.is-lit span.study-hotspot-label {
  color: var(--study-brass);
  background: #0c0806;
  border-color: var(--study-brass);
}
/* Keyboard focus: AA ring on the label pill only — never a hotspot rectangle. */
.study-hotspot:focus-visible span.study-hotspot-label {
  outline: 2px solid var(--study-brass);
  outline-offset: 2px;
}

.study-desktop-only { display: block; }
.study-mobile-only { display: none; }
@media (max-width: 720px) {
  .study-desktop-only { display: none; }
  .study-mobile-only { display: block; margin-top: 8px; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
