/* =========================================
   CHAMBER PORTAL — scrollable scene + UI
========================================= */

body[data-page="chamber-portal"]{
  background: #000;
  overflow-x: hidden;
}

/* Scene wrapper becomes the "stage" */
body[data-page="chamber-portal"] .portal-scene{
  position: relative;
  width: 100%;
  background: #000;
  overflow: visible;
}

/* The actual background image (this is what makes scrolling work) */
body[data-page="chamber-portal"] .portal-bg{
  width: 100%;
  height: auto;
  display: block;
}

/* PORTAL: during bgReveal, keep the portal background visible */
body[data-page="chamber-portal"].has-bg-reveal{
  background: #000;
}

/* If you use an IMG background (recommended), keep it visible */
body[data-page="chamber-portal"].has-bg-reveal .portal-bg{
  opacity: 1 !important;
}

/* Portal veil / entrance darkness */
body[data-page="chamber-portal"] .portal-veil,
body[data-page="chamber-portal"] .entrance-darkness{
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%,
    rgba(0,0,0,0.02) 0%,
    rgba(0,0,0,0.18) 70%,
    rgba(0,0,0,0.35) 100%);
  pointer-events: none;
}

/* Portal UI overlays the scene */
body[data-page="chamber-portal"] .portal-ui{
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  z-index: 10;
  padding: 1rem 0.9rem 2.5rem;
  padding-top: 7rem;
}

.portal-title{
  font-family: "EWOAncient", serif;
  font-weight: 600;
  font-size: clamp(1.8rem, 7vw, 3.8rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0.5rem 0 5px;
  padding-bottom: 2.5rem;
  color: #e9f3ff;
  line-height: 1.08;
  max-width: 100%;
  overflow-wrap: break-word;
  text-shadow:
    0 0 2px rgba(180, 215, 255, 0.95),
    0 0 6px rgba(150, 200, 255, 0.85),
    0 0 14px rgba(120, 175, 255, 0.55),
    0 0 28px rgba(90, 140, 240, 0.35),
    0 0 50px rgba(60, 100, 220, 0.18),
    0 0 80px rgba(40, 70, 180, 0.12);
  animation: letterHalo 9s ease-in-out infinite alternate;
}

@keyframes letterHalo {
  0% {
    text-shadow:
      0 0 6px rgba(180, 215, 255, 0.85),
      0 0 16px rgba(150, 200, 255, 0.55),
      0 0 32px rgba(120, 180, 255, 0.35),
      0 0 60px rgba(90, 160, 255, 0.18);
  }
  50% {
    text-shadow:
      0 0 8px rgba(230, 235, 255, 0.95),
      0 0 22px rgba(200, 215, 255, 0.65),
      0 0 44px rgba(170, 200, 255, 0.40),
      0 0 80px rgba(140, 180, 255, 0.22);
  }
  100% {
    text-shadow:
      0 0 10px rgba(255, 220, 170, 1),
      0 0 26px rgba(255, 200, 120, 0.75),
      0 0 52px rgba(255, 180, 90, 0.45),
      0 0 90px rgba(255, 160, 60, 0.25);
  }
}

@media (prefers-reduced-motion: reduce){
  .portal-title,
  body[data-page="chamber-portal"] .portal-tile,
  body[data-page="chamber-portal"] .chamber-link{
    animation: none;
    transition: none;
  }
}

/* =========================
   CHAMBER PORTAL LINKS — Torch Glow
========================= */

body[data-page="chamber-portal"] .chamber-doors{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

body[data-page="chamber-portal"] .chamber-link{
  display: inline-block;
  font-family: "EWOAncient";
  font-size: 1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(240,210,160,0.85);
  text-decoration: none;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  max-width: 100%;
  line-height: 1.25;
  text-shadow:
    0 0 6px rgba(255,200,120,0.35),
    0 0 14px rgba(200,140,70,0.25),
    0 0 28px rgba(140,90,40,0.15);
  transition:
    color 0.35s ease,
    text-shadow 0.35s ease,
    transform 0.25s ease,
    filter 0.25s ease;
  animation: torchPulse 4.5s ease-in-out infinite;
}

/* Subtle hover "torch flare" */
body[data-page="chamber-portal"] .chamber-link:hover{
  color: rgb(255,225,170);
  text-shadow:
    0 0 8px rgba(255,220,160,0.75),
    0 0 20px rgba(255,180,100,0.55),
    0 0 45px rgba(200,120,40,0.35);
  transform: translateY(-1px);
  filter: brightness(1.15);
}

/* Soft focus glow for keyboard navigation */
body[data-page="chamber-portal"] .chamber-link:focus-visible{
  outline: none;
  color: rgb(255,235,190);
  text-shadow:
    0 0 10px rgba(255,235,190,0.9),
    0 0 26px rgba(255,190,120,0.7),
    0 0 60px rgba(200,130,60,0.45);
}

@keyframes torchPulse {
  0%, 100% {
    text-shadow:
      0 0 6px rgba(255,200,120,0.35),
      0 0 14px rgba(200,140,70,0.25),
      0 0 28px rgba(140,90,40,0.15);
  }
  50% {
    text-shadow:
      0 0 10px rgba(255,220,160,0.55),
      0 0 22px rgba(255,170,90,0.35),
      0 0 40px rgba(200,120,40,0.25);
  }
}

/* The Great Gate — Full Chamber Path */
body[data-page="chamber-portal"] .enter-btn{
  display: inline-block;
  margin-bottom: 1.2rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,225,180,0.95);
  padding: 0.6rem 1.1rem;
  border-radius: 14px;
  line-height: 1.2;
  max-width: 100%;
  text-shadow:
    0 0 10px rgba(255,230,180,0.65),
    0 0 26px rgba(255,190,120,0.45),
    0 0 60px rgba(200,130,60,0.35);
  transition:
    color 0.4s ease,
    text-shadow 0.4s ease,
    transform 0.3s ease,
    filter 0.3s ease;
}

body[data-page="chamber-portal"] .enter-btn:hover{
  color: rgb(255,240,200);
  text-shadow:
    0 0 16px rgba(255,240,200,0.95),
    0 0 42px rgba(255,200,140,0.75),
    0 0 90px rgba(200,140,70,0.55);
  transform: translateY(-2px);
  filter: brightness(1.18);
}

/* Exit link */
body[data-page="chamber-portal"] .chamber-exit{
  margin-top: 2rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(210,225,255,0.85);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(180,200,255,0.45);
  line-height: 1.2;
  max-width: 100%;
  text-shadow:
    0 0 8px rgba(180,210,255,0.35),
    0 0 22px rgba(120,160,255,0.25);
  transition:
    color 0.4s ease,
    text-shadow 0.4s ease,
    box-shadow 0.4s ease,
    transform 0.25s ease;
}

body[data-page="chamber-portal"] .chamber-exit:hover{
  color: rgb(235,245,255);
  text-shadow:
    0 0 12px rgba(210,235,255,0.9),
    0 0 30px rgba(160,200,255,0.7),
    0 0 70px rgba(120,170,255,0.45);
  box-shadow:
    0 0 12px rgba(180,210,255,0.4),
    0 0 30px rgba(140,180,255,0.3);
  transform: translateY(-1px);
}

/* Blackout overlay (shared on portal + inner pages) */
#pageBlackout.page-blackout{
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 999999;
  transition: opacity 650ms ease;
}

#pageBlackout.page-blackout.is-on{
  opacity: 1;
}

/* =========================================
   MOBILE — long portal pages
========================================= */

@media (max-width: 767px){

  /* Make the background image fill the phone screen */
  body[data-page="chamber-portal"] .portal-scene{
    min-height: 100vh;
  }

  body[data-page="chamber-portal"] .portal-bg{
    height: 100vh;
    object-fit: cover;
  }

  body[data-page="chamber-portal"] .portal-ui{
    justify-content: flex-start;
    align-items: center;
    padding-top: 32vh;
    padding-right: 1rem;
    padding-bottom: 2rem;
    padding-left: 1rem;
  }

  .portal-title{
    font-size: clamp(1.35rem, 6.8vw, 2rem);
    line-height: 1.02;
    letter-spacing: 0.08em;
    margin: 0 0 1.2rem;
    padding-bottom: 1rem;
    max-width: 92%;
  }

  body[data-page="chamber-portal"] .chamber-doors{
    width: 100%;
    gap: 0.4rem;
  }

  body[data-page="chamber-portal"] .chamber-link{
    width: min(100%, 22rem);
    padding: 0.25rem 0.3rem;
    font-size: 0.72rem;
    line-height: 1.1;
    letter-spacing: 0.05em;
  }

  body[data-page="chamber-portal"] .enter-btn{
    width: min(100%, 22rem);
    margin-bottom: 0.8rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.15;
    letter-spacing: 0.08em;
  }

  body[data-page="chamber-portal"] .chamber-exit{
    width: min(100%, 22rem);
    margin-top: 1.5rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    line-height: 1.15;
    letter-spacing: 0.08em;
    text-align: center;
  }
}

/* =========================
   TABLET / LARGER SCREENS
========================= */

@media (min-width: 768px){
  body[data-page="chamber-portal"] .portal-ui{
    padding: 1.5rem 1rem 4rem;
    padding-top: 10rem;
  }

  .portal-title{
    font-size: clamp(2.3rem, 4.5vw, 3.8rem);
    letter-spacing: 0.14em;
    padding-bottom: 5rem;
  }

  body[data-page="chamber-portal"] .chamber-link{
    font-size: 1.05rem;
    letter-spacing: 0.18em;
  }

  body[data-page="chamber-portal"] .enter-btn{
    font-size: 1.25rem;
    letter-spacing: 0.22em;
    padding: 0.55rem 1.4rem;
  }

  body[data-page="chamber-portal"] .chamber-exit{
    margin-top: 2.5rem;
    font-size: 1.1rem;
    letter-spacing: 0.22em;
    padding: 0.55rem 1.2rem;
  }
}

/* =========================
   DESKTOP ONLY — center portal text
========================= */

@media (min-width: 1024px){
  body[data-page="chamber-portal"] .portal-ui{
    justify-content: center;
    padding-top: 0;
    padding-bottom: 0;
  }
}