/* ==========================================================================
   PotterHead — Pantalla de acceso de la portada
   Castillo de fondo a la izquierda, panel de acceso a la derecha.
   Se carga solo en la portada (ver inc/login-gate.php).
   ========================================================================== */

/* ---------- Cabecera: transparente sobre la pantalla de acceso ---------- */
body.ph-home .hm-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  transition: background .4s ease, border-color .4s ease, box-shadow .4s ease;
}
body.ph-home:not(.ph-past-gate) .hm-header {
  background: linear-gradient(180deg, rgba(4,5,14,.82) 0%, rgba(4,5,14,0) 100%);
  border-bottom-color: transparent;
}
body.ph-home .hm-logo-text,
body.ph-home .hm-nav a { text-shadow: 0 1px 10px rgba(0,0,0,.9); }

#houses { scroll-margin-top: 64px; }

/* ---------- Contenedor ---------- */
.ph-gate {
  --ph-gold: #e2b653;
  --ph-gold-hi: #fff3c9;
  --ph-parch: #f1e3c3;
  --ph-ink: #05070f;
  --ph-accent: #e2b653;
  --ph-accent-line: rgba(226,182,83,.6);
  --ph-accent-glow: rgba(226,182,83,.35);

  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, min(460px, 36vw));
  grid-template-rows: 1fr auto;
  column-gap: clamp(1rem, 4vw, 4rem);
  padding: 5.5rem clamp(1rem, 6vw, 6rem) 1.5rem clamp(1rem, 4vw, 3rem);
  color: var(--ph-parch);
  background: var(--ph-ink);
}

/* Colores de casa (selección de personaje) */
.ph-gate[data-house="gryffindor"] { --ph-accent: #d3333c; --ph-accent-line: rgba(211,51,60,.75); --ph-accent-glow: rgba(190,30,40,.40); }
.ph-gate[data-house="ravenclaw"]  { --ph-accent: #5b86e6; --ph-accent-line: rgba(91,134,230,.75); --ph-accent-glow: rgba(60,100,210,.38); }
.ph-gate[data-house="hufflepuff"] { --ph-accent: #ecb939; --ph-accent-line: rgba(236,185,57,.75); --ph-accent-glow: rgba(236,185,57,.34); }
.ph-gate[data-house="slytherin"]  { --ph-accent: #38b06a; --ph-accent-line: rgba(56,176,106,.75); --ph-accent-glow: rgba(40,150,90,.38); }

/* ---------- Capas de fondo ---------- */
.ph-gate__sky,
.ph-gate__tint,
.ph-gate__fog,
.ph-gate__embers,
.ph-gate__vignette { position: absolute; pointer-events: none; }

.ph-gate__sky {
  inset: -2%;
  z-index: -5;
  background: #060810 url('../images/hogwarts-bg.avif') 30% 50% / cover no-repeat;
  transform-origin: 30% 45%;
  animation: phSky 48s ease-in-out infinite alternate;
}
@keyframes phSky {
  from { transform: scale(1); }
  to   { transform: scale(1.07) translate3d(-.8%, 0, 0); }
}

.ph-gate__tint {
  inset: 0;
  z-index: -4;
  opacity: 0;
  transition: opacity 1.4s ease;
  background: radial-gradient(70% 80% at 80% 55%, var(--ph-accent-glow), transparent 70%);
}
.ph-gate[data-state="char"] .ph-gate__tint { opacity: 1; }

.ph-gate__fog {
  left: -30%;
  width: 160%;
  height: 38%;
  bottom: 6%;
  z-index: -3;
  opacity: .9;
  background:
    radial-gradient(50% 60% at 30% 60%, rgba(150,170,220,.16), transparent 70%),
    radial-gradient(45% 55% at 72% 50%, rgba(150,170,220,.12), transparent 70%);
  filter: blur(18px);
  animation: phFog 60s linear infinite alternate;
  will-change: transform;
}
.ph-gate__fog--b {
  bottom: 22%;
  height: 30%;
  opacity: .6;
  animation-duration: 85s;
  animation-direction: alternate-reverse;
}
@keyframes phFog {
  from { transform: translate3d(-6%, 0, 0); }
  to   { transform: translate3d(6%, 0, 0); }
}

.ph-gate__embers { inset: 0; width: 100%; height: 100%; z-index: -2; }

.ph-gate__vignette {
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(5,7,15,0) 0%, rgba(5,7,15,0) 38%, rgba(5,7,15,.55) 76%, rgba(5,7,15,.82) 100%),
    linear-gradient(180deg, rgba(5,7,15,.55) 0%, rgba(5,7,15,0) 22%, rgba(5,7,15,0) 72%, #060810 100%),
    radial-gradient(120% 90% at 35% 45%, transparent 55%, rgba(2,3,8,.7) 100%);
}

/* Cortina de entrada (de negro a escena) y destello al iniciar sesión */
.ph-gate::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #000;
  pointer-events: none;
  animation: phCurtain 1.8s ease-out .1s forwards;
}
@keyframes phCurtain {
  0%   { opacity: 1; visibility: visible; }
  99%  { opacity: 0; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}
.ph-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 78% 55%, rgba(255,244,205,.95), rgba(255,230,160,.35) 35%, transparent 65%);
}
.ph-gate.ph-flash::before { animation: phFlash 1s ease-out; }
@keyframes phFlash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Columna principal ---------- */
.ph-gate__main {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2rem;
  min-width: 0;
}

.ph-brand {
  text-align: center;
  animation: phRise 1.3s cubic-bezier(.2,.7,.2,1) .7s both;
}
@keyframes phRise {
  from { opacity: 0; transform: translate3d(0, 18px, 0); }
  to   { opacity: 1; transform: none; }
}

.ph-gate .ph-title {
  margin: 0;
  font-family: var(--font-magic);
  font-weight: 900;
  font-size: clamp(2.6rem, 5.2vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: .02em;
  color: transparent;
  background: linear-gradient(180deg, #fff3c9 0%, #f0c040 42%, #9a6b12 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 3px 0 rgba(60,30,0,.55)) drop-shadow(0 8px 22px rgba(0,0,0,.85));
}

.ph-gate .ph-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  margin: .8rem 0 0;
  color: rgba(226,182,83,.85);
}
.ph-rule::before,
.ph-rule::after {
  content: '';
  width: 64px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(226,182,83,.85));
}
.ph-rule::after { transform: scaleX(-1); }

.ph-gate .ph-subtitle {
  margin: .7rem 0 0;
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  line-height: 1.4;
  color: rgba(241,227,195,.92);
  text-shadow: 0 2px 14px rgba(0,0,0,.95);
}

/* ---------- Panel ---------- */
.ph-panel {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: 2.6rem 2rem 1.6rem;
  border: 1px solid var(--ph-accent-line);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(14,18,38,.84), rgba(6,8,18,.92));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow:
    0 0 0 4px rgba(5,7,15,.6),
    0 0 0 5px rgba(226,182,83,.22),
    0 30px 80px rgba(0,0,0,.75),
    inset 0 0 44px var(--ph-accent-glow);
  transition: border-color .8s ease, box-shadow .8s ease;
  animation: phRise 1.2s cubic-bezier(.2,.7,.2,1) 1.1s both;
}

.ph-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0 solid var(--ph-gold);
  opacity: .85;
  pointer-events: none;
}
.ph-corner--tl { top: 7px;    left: 7px;    border-top-width: 2px;    border-left-width: 2px; }
.ph-corner--tr { top: 7px;    right: 7px;   border-top-width: 2px;    border-right-width: 2px; }
.ph-corner--bl { bottom: 7px; left: 7px;    border-bottom-width: 2px; border-left-width: 2px; }
.ph-corner--br { bottom: 7px; right: 7px;   border-bottom-width: 2px; border-right-width: 2px; }

/* Sello de lacre */
.ph-seal {
  position: absolute;
  top: -27px;
  left: 50%;
  width: 54px;
  height: 54px;
  margin-left: -27px;
  z-index: 5;
  display: grid;
  place-items: center;
  border-radius: 48% 52% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 35% 30%, #d1303a 0%, #8a0d16 55%, #4d060b 100%);
  box-shadow: 0 6px 18px rgba(0,0,0,.7), inset 0 -3px 6px rgba(0,0,0,.45), inset 0 2px 3px rgba(255,150,150,.35);
}
.ph-seal span {
  font-family: var(--font-magic);
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1;
  color: #f4dc9a;
  text-shadow: 0 1px 0 rgba(0,0,0,.6);
}

/* ---------- Formulario ---------- */
.ph-login { display: flex; flex-direction: column; gap: 1.1rem; }

.ph-field { display: flex; flex-direction: column; gap: .35rem; }
.ph-field label {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: rgba(241,227,195,.85);
}
.ph-field__wrap { position: relative; }

.ph-gate input[type="text"],
.ph-gate input[type="password"] {
  width: 100%;
  padding: .8rem .95rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ph-parch);
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(226,182,83,.32);
  border-radius: 4px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6);
  transition: border-color .2s, box-shadow .2s;
}
.ph-gate input[type="password"] { padding-right: 3rem; }
.ph-gate input[type="text"]:focus,
.ph-gate input[type="password"]:focus {
  outline: none;
  border-color: var(--ph-gold);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6), 0 0 0 3px rgba(226,182,83,.22);
}

.ph-peek {
  position: absolute;
  top: 50%;
  right: .35rem;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: rgba(241,227,195,.6);
  background: none;
  border: 0;
  border-radius: 4px;
}
.ph-peek svg { width: 22px; height: 22px; }
.ph-peek:hover { color: var(--ph-gold-hi); }
.ph-peek[aria-pressed="true"] { color: var(--ph-gold); }

.ph-check {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.05rem;
  color: rgba(241,227,195,.85);
  width: fit-content;
}
.ph-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(226,182,83,.5);
  border-radius: 3px;
  display: grid;
  place-content: center;
}
.ph-check input::before {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--ph-gold);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  transform: scale(0);
  transition: transform .15s ease-out;
}
.ph-check input:checked::before { transform: scale(1); }

.ph-msg {
  margin: 0;
  padding: .6rem .8rem;
  font-size: 1rem;
  line-height: 1.4;
  color: #ffd9d6;
  background: rgba(130,12,20,.4);
  border: 1px solid rgba(220,70,70,.6);
  border-radius: 4px;
}
.ph-msg[hidden] { display: none; }

/* Botón principal */
.ph-gate .ph-enter {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  padding: .95rem 1rem;
  text-align: center;
  text-decoration: none;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .05em;
  color: #fbe7a6;
  background: linear-gradient(180deg, #8a141c 0%, #55090f 100%);
  border: 1px solid var(--ph-gold);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 6px 18px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,200,160,.25);
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  transition: box-shadow .25s ease, filter .25s ease, transform .1s ease;
}
.ph-enter::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,235,170,.35), transparent);
  transform: skewX(-18deg);
  transition: left .7s ease;
}
.ph-enter:hover,
.ph-enter:focus-visible {
  filter: brightness(1.18);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 6px 22px rgba(0,0,0,.6), 0 0 26px rgba(226,182,83,.4), inset 0 1px 0 rgba(255,200,160,.3);
}
.ph-enter:hover::after,
.ph-enter:focus-visible::after { left: 130%; }
.ph-enter:active { transform: translateY(1px); }

.ph-forgot,
.ph-char__links a {
  align-self: center;
  font-size: 1rem;
  color: rgba(241,227,195,.7);
  text-decoration: underline;
  text-decoration-color: rgba(226,182,83,.4);
  text-underline-offset: 3px;
  transition: color .2s;
}
.ph-forgot:hover,
.ph-char__links a:hover { color: var(--ph-gold-hi); }

/* Foco visible en todo el bloque */
.ph-gate a:focus-visible,
.ph-gate button:focus-visible,
.ph-gate .ph-check input:focus-visible {
  outline: 2px solid var(--ph-gold-hi);
  outline-offset: 2px;
}

/* ---------- Pantalla de carga ---------- */
.ph-busy {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(180deg, #0b1024, #060810);
  border-radius: inherit;
}
.ph-panel.is-busy .ph-busy { display: flex; }

.ph-busy__orb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(226,182,83,.2);
  border-top-color: var(--ph-gold);
  animation: phSpin 1s linear infinite;
}
.ph-busy__orb::after {
  content: '';
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3c9, #f0c040 60%, transparent 72%);
  box-shadow: 0 0 20px rgba(240,192,64,.8);
  animation: phPulse 1.4s ease-in-out infinite;
}
@keyframes phSpin  { to { transform: rotate(360deg); } }
@keyframes phPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.ph-busy__text {
  margin: 0;
  min-height: 2.8em;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.4;
  color: var(--ph-parch);
}
.ph-bar {
  width: 100%;
  max-width: 260px;
  height: 7px;
  overflow: hidden;
  background: rgba(0,0,0,.7);
  border: 1px solid rgba(226,182,83,.5);
  border-radius: 4px;
}
.ph-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #8f6414, #f0c040, #fff3c9);
  box-shadow: 0 0 10px rgba(240,192,64,.6);
  transition: width .7s ease-out;
}

/* ---------- Estados ---------- */
.ph-gate[data-state="login"] .ph-char { display: none; }
.ph-gate[data-state="char"]  .ph-login { display: none; }
.ph-gate[data-state="char"]  .ph-menu__register { display: none; }

/* ---------- Selección de personaje ---------- */
.ph-char {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .35rem;
  text-align: center;
}
.ph-gate[data-state="char"] .ph-char { animation: phChar .9s cubic-bezier(.2,.7,.2,1) both; }
@keyframes phChar {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.ph-char__crest {
  align-self: center;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  margin-bottom: .6rem;
  font-size: 2.9rem;
  line-height: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.08), rgba(0,0,0,.55) 70%);
  border: 2px solid var(--ph-accent);
  box-shadow: 0 0 0 5px rgba(5,7,15,.7), 0 0 38px var(--ph-accent-glow), inset 0 0 24px var(--ph-accent-glow);
  transition: border-color .8s, box-shadow .8s;
}
.ph-gate[data-state="char"] .ph-char__crest { animation: phCrest 1s cubic-bezier(.2,1.4,.4,1) .15s both; }
@keyframes phCrest {
  from { opacity: 0; transform: scale(.5); }
  to   { opacity: 1; transform: none; }
}

.ph-char__hello { margin: 0; font-size: 1.05rem; color: rgba(241,227,195,.7); }
.ph-gate .ph-char__name {
  margin: 0;
  font-family: var(--font-magic);
  font-weight: 700;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  line-height: 1.2;
  color: #f4d98e;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0,0,0,.8);
}
.ph-char__house {
  margin: .25rem 0 0;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ph-accent);
  filter: brightness(1.25);
}
.ph-char__meta { margin: 0 0 1rem; font-size: 1rem; font-style: italic; color: rgba(241,227,195,.6); }

.ph-gate .ph-hat {
  display: block;
  margin-top: .6rem;
  padding: .7rem 1rem;
  text-align: center;
  text-decoration: none;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: .95rem;
  color: #f0d58a;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(226,182,83,.45);
  border-radius: 4px;
  transition: border-color .2s, box-shadow .2s, color .2s;
}
.ph-hat:hover { color: var(--ph-gold-hi); border-color: var(--ph-gold); box-shadow: 0 0 18px rgba(226,182,83,.25); }
.ph-hat[hidden] { display: none; }

.ph-char__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem 1.6rem;
  margin-top: 1.1rem;
}

/* ---------- Pie: accesos rápidos, aviso legal y versión ---------- */
.ph-gate__foot {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 2.5rem;
  animation: phFade 1.2s ease 1.8s both;
}
@keyframes phFade { from { opacity: 0; } to { opacity: 1; } }

.ph-menu {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  width: min(250px, 100%);
  flex-shrink: 0;
}
.ph-menu a {
  display: block;
  padding: .7rem 1rem;
  text-align: center;
  text-decoration: none;
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .03em;
  color: #f0d58a;
  background: linear-gradient(180deg, rgba(24,28,50,.88), rgba(8,10,22,.92));
  border: 1px solid rgba(226,182,83,.4);
  border-radius: 4px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  transition: border-color .2s, box-shadow .2s, color .2s;
}
.ph-menu a:hover,
.ph-menu a:focus-visible {
  color: var(--ph-gold-hi);
  border-color: var(--ph-gold);
  box-shadow: 0 0 18px rgba(226,182,83,.28);
}

.ph-legal,
.ph-ver {
  margin: 0;
  font-size: .9rem;
  line-height: 1.4;
  color: rgba(241,227,195,.5);
  text-shadow: 0 1px 8px rgba(0,0,0,.9);
}
.ph-legal { flex: 1; text-align: center; }
.ph-ver { flex-shrink: 0; text-align: right; }

/* Sacudida cuando falla el acceso */
.ph-panel.ph-shake { animation: phShake .45s ease; }
@keyframes phShake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ---------- Móvil y tablet ---------- */
@media (max-width: 900px) {
  .ph-gate {
    grid-template-columns: 1fr;
    padding: 5rem 1rem 1.25rem;
    column-gap: 0;
  }
  .ph-gate__sky {
    bottom: auto;
    height: 100vh;
    height: 100svh;
    background-position: 24% 50%;
  }
  .ph-gate__vignette {
    background:
      linear-gradient(180deg, rgba(5,7,15,.7) 0%, rgba(5,7,15,0) 24%, rgba(5,7,15,0) 34%, rgba(5,7,15,.82) 62%, #060810 100%),
      radial-gradient(120% 90% at 35% 40%, transparent 55%, rgba(2,3,8,.6) 100%);
  }
  .ph-gate__main {
    grid-column: 1;
    align-self: stretch;
    justify-content: space-between;
    gap: 1.6rem;
    min-height: calc(100vh - 11rem);
    min-height: calc(100svh - 11rem);
  }
  .ph-gate__foot {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-top: 1.6rem;
  }
  .ph-menu { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .ph-menu a { flex: 1 1 150px; }
  .ph-legal, .ph-ver { text-align: center; }
  .ph-panel { max-width: 440px; padding: 2.2rem 1.25rem 1.2rem; }
  .ph-login { gap: .85rem; }
  .ph-gate .ph-title { font-size: clamp(2.3rem, 11vw, 3.2rem); }
  .ph-gate .ph-subtitle { font-size: 1.05rem; }
  .ph-menu a { padding: .65rem .8rem; font-size: .85rem; }
}

@media (max-width: 900px) and (max-height: 640px) {
  .ph-gate__main { min-height: 0; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .ph-gate *,
  .ph-gate *::before,
  .ph-gate *::after { animation: none !important; transition: none !important; }
  .ph-gate::after { display: none; }
  .ph-gate__embers { display: none; }
  .ph-busy__orb { animation: phSpin 2.4s linear infinite !important; }
}
