/* ═══════════════════════════════════════════════════════════════════════════
   Portail de connexion — la façade se dessine, l'immeuble s'éveille, et la
   porte s'ouvre à la connexion.
   ═══════════════════════════════════════════════════════════════════════════ */

.portal {
  --night: #07090d;
  --night-2: #0e1219;
  position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden;
  color: #f5efe3; background: var(--night); isolation: isolate;
}
.portal-sky {
  position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse 55% 42% at 30% 88%, rgba(214, 160, 86, 0.22), transparent 70%),
    radial-gradient(ellipse 80% 60% at 70% 10%, rgba(64, 86, 122, 0.22), transparent 70%),
    linear-gradient(180deg, #0b0f16 0%, #0a0d13 55%, #07090d 100%);
}
.portal-sky::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
}
.portal-dust { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

.portal-stage {
  min-height: 100vh; min-height: 100svh;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: center;
  gap: clamp(1rem, 4vw, 4rem); padding: clamp(1.2rem, 4vw, 3.5rem) clamp(1.2rem, 5vw, 5rem);
  max-width: 1320px; margin: 0 auto;
}

/* ─── Façade ─────────────────────────────────────────────────────────────── */
.portal-scene { display: flex; justify-content: center; align-items: flex-end; position: relative; }
.facade {
  position: relative; height: min(80vh, 680px); aspect-ratio: 420 / 560; max-width: 100%;
  transform-origin: 50% 86.25%; will-change: transform;
}
.facade::after {
  content: ''; position: absolute; left: -20%; right: -20%; bottom: 4%; height: 12%; z-index: -1;
  background: radial-gradient(ellipse at center, rgba(222, 170, 92, 0.28), transparent 70%);
  filter: blur(6px); opacity: 0; transition: opacity 1.2s var(--ease);
}
.portal.is-ready .facade::after { opacity: 1; }
.facade-svg { width: 100%; height: 100%; overflow: visible; }

.facade-svg .draw {
  fill: none; stroke: #d8bf8f; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: facadeDraw 1.5s var(--ease) forwards; animation-delay: 0.15s;
}
.facade-svg .ground { stroke-width: 1.4; animation-duration: 1.8s; animation-delay: 0s; }
.facade-svg .win .draw { stroke-opacity: 0.9; animation-delay: calc(0.65s + var(--n) * 55ms); animation-duration: 1.1s; }
.facade-svg .balcony .draw { stroke-opacity: 0.55; animation-delay: 1.15s; animation-duration: 1s; }
.facade-svg .door .draw { animation-delay: 1.25s; }
.facade-svg .sill { stroke-opacity: 0.6; }
.facade-svg .slate { stroke-opacity: 0.22; stroke-dasharray: 1; }
.facade-svg .roof > .draw { animation-delay: 0.45s; }
@keyframes facadeDraw { to { stroke-dashoffset: 0; } }

.facade-svg .glass { opacity: 0; transition: opacity 1.1s var(--ease), filter 0.8s var(--ease); }
.facade-svg .win.is-lit .glass { opacity: 0.72; }
.facade-svg .win.is-bright .glass { opacity: 0.95; }
.facade-svg .win.is-home .glass { opacity: 1; filter: drop-shadow(0 0 5px rgba(255, 214, 140, 0.95)) drop-shadow(0 0 14px rgba(255, 190, 100, 0.6)); }

.facade-svg .leaf-fill { fill: #12161e; }
.facade-svg .knob { fill: #d8bf8f; opacity: 0; animation: fadeIn 0.6s ease 2s forwards; }
.facade-svg .door-light { opacity: 0.12; transition: opacity 0.9s var(--ease), filter 0.3s ease; }
.facade-svg .door-leaf { transform-box: fill-box; transition: transform 1.15s var(--ease-out); }
.facade-svg .door-left { transform-origin: left center; }
.facade-svg .door-right { transform-origin: right center; }
.facade-svg .door-number {
  font-family: var(--font-display); font-size: 12.5px; letter-spacing: 2.5px; fill: #e9d3a6;
  opacity: 0; animation: fadeIn 1s ease 1.9s forwards;
}
.facade-svg .lamp { fill: #ffd98f; opacity: 0; filter: drop-shadow(0 0 4px rgba(255, 210, 130, 0.9)); animation: lampOn 1.4s ease 2.1s forwards; }
@keyframes lampOn { 0% { opacity: 0; } 30% { opacity: 0.9; } 40% { opacity: 0.25; } 55% { opacity: 1; } 100% { opacity: 0.9; } }
@keyframes fadeIn { to { opacity: 1; } }

.facade.is-open .door-left  { transform: scaleX(0.1) skewY(-7deg); }
.facade.is-open .door-right { transform: scaleX(0.1) skewY(7deg); }
.facade.is-open .door-light { opacity: 1; }
.facade.is-denied .door-light { opacity: 0.85; filter: hue-rotate(-38deg) saturate(2.4) brightness(0.9); }

.facade-tag {
  position: absolute; left: 86%; top: var(--tag-top, 50%); transform: translate(0, -50%);
  display: flex; align-items: center; gap: 0.6rem; opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.facade-tag::before { content: ''; width: 34px; height: 1px; background: linear-gradient(90deg, transparent, #e9d3a6); }
.facade-tag span {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #1a1306;
  background: linear-gradient(135deg, #f3dfb4, #c9a66b); padding: 0.45rem 0.85rem; border-radius: 999px;
  box-shadow: 0 6px 24px rgba(214, 160, 86, 0.45);
}
.facade-tag.is-visible { opacity: 1; transform: translate(6px, -50%); }

/* ─── Panneau de connexion ───────────────────────────────────────────────── */
.portal-panel { display: flex; flex-direction: column; align-items: flex-start; gap: 1.6rem; max-width: 440px; width: 100%; justify-self: center; }
.portal-brand .brandmark { color: #f5efe3; }
.portal-brand .brandmark svg { width: 44px; height: 44px; }

.portal-card {
  position: relative; width: 100%;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(216, 191, 143, 0.22); border-radius: 22px;
  padding: clamp(1.6rem, 4vw, 2.4rem);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.portal-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(240, 220, 180, 0.55), transparent 35%, transparent 65%, rgba(240, 220, 180, 0.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.portal-kicker { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: #d8bf8f; margin-bottom: 0.7rem; }
.portal-card h1 { font-size: clamp(2rem, 4vw, 2.55rem); color: #fbf6ec; font-weight: 500; margin-bottom: 0.7rem; }
.portal-lead { color: rgba(245, 239, 227, 0.62); font-size: 0.92rem; margin-bottom: 1.8rem; max-width: 34ch; }

.otp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 0.2rem repeat(3, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 1.4rem; }
.otp-box:nth-child(4) { grid-column: 5; }
.otp-box {
  width: 100%; aspect-ratio: 5 / 6; text-align: center; border-radius: 12px;
  background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(216, 191, 143, 0.24);
  color: #fff7e6; font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2rem); font-weight: 600;
  caret-color: #e9d3a6; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s;
}
.otp-box:focus { outline: none; border-color: #e3c58b; background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 3px rgba(214, 170, 100, 0.22), 0 0 24px rgba(214, 170, 100, 0.18); }
.otp-box.is-filled { border-color: rgba(227, 197, 139, 0.75); }
.otp-box.pop { animation: otpPop 0.22s ease; }
@keyframes otpPop { 50% { transform: scale(1.08); } }

.portal-label { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(245, 239, 227, 0.6); margin-bottom: 0.55rem; }
.pw-field { position: relative; margin-bottom: 1.4rem; }
.pw-field input {
  width: 100%; padding: 1rem 3.1rem 1rem 1.1rem; border-radius: 12px;
  background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(216, 191, 143, 0.24);
  color: #fff7e6; font-size: 1.05rem; letter-spacing: 0.06em; transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.pw-field input:focus { outline: none; border-color: #e3c58b; background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 3px rgba(214, 170, 100, 0.22); }
.pw-toggle { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 10px; color: rgba(245, 239, 227, 0.55); display: grid; place-items: center; }
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { color: #e9d3a6; background: rgba(255, 255, 255, 0.05); }

.portal-submit {
  position: relative; overflow: hidden; width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.8rem;
  padding: 1.02rem 1.4rem; border-radius: 12px; color: #1d1508; font-weight: 800; font-size: 0.9rem; letter-spacing: 0.08em; text-transform: uppercase;
  background: linear-gradient(135deg, #f3dfb4 0%, #d4b47a 45%, #b28c55 100%);
  box-shadow: 0 14px 34px rgba(190, 145, 80, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), filter 0.25s;
}
.portal-submit:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(190, 145, 80, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.portal-submit::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: skewX(-18deg); transition: left 0.8s ease;
}
.portal-submit:hover::after { left: 130%; }
.portal-key { width: 30px; height: 15px; transition: transform 0.35s var(--ease); }
.portal-submit:hover .portal-key { transform: translateX(4px); }
.portal-submit.is-loading { pointer-events: none; filter: saturate(0.8); }
.portal-submit.is-loading .portal-key { animation: keyTurn 0.9s ease-in-out infinite; }
@keyframes keyTurn { 0%, 100% { transform: translateX(0) rotate(0); } 50% { transform: translateX(5px) rotate(-12deg); } }
.portal-submit:disabled { cursor: not-allowed; filter: grayscale(0.6) brightness(0.8); transform: none; }

.portal-msg { min-height: 1.3em; margin-top: 1rem; font-size: 0.85rem; color: #f2a99c; text-align: center; }
.portal-msg.is-info { color: rgba(245, 239, 227, 0.65); }
.portal-card.is-error { animation: cardShake 0.5s cubic-bezier(.36, .07, .19, .97); }
@keyframes cardShake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); }
}

.portal-back { font-size: 0.82rem; color: rgba(245, 239, 227, 0.45); transition: color 0.2s; }
.portal-back:hover { color: #e9d3a6; }

/* Apparition du panneau */
.portal-brand, .portal-card, .portal-back { animation: panelIn 1s var(--ease-out) both; }
.portal-brand { animation-delay: 0.5s; }
.portal-card { animation-delay: 0.75s; }
.portal-back { animation-delay: 1.1s; }
@keyframes panelIn { from { opacity: 0; transform: translateY(18px); } }

/* ─── Séquence d'entrée ──────────────────────────────────────────────────── */
.portal.is-success .portal-panel { opacity: 0; transform: translateX(20px); filter: blur(8px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease), filter 0.7s var(--ease); }
.portal.is-entering .facade {
  transform: translate(var(--enter-x, 0), var(--enter-y, 0)) scale(var(--zoom, 10));
  transition: transform 1.6s cubic-bezier(.65, 0, .85, .2);
}
.portal.is-entering .facade-tag { opacity: 0; }

.portal-veil {
  position: fixed; inset: 0; z-index: 50; background: #f7f3ec; opacity: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center; transition: opacity 0.8s var(--ease);
}
.portal.is-veiled .portal-veil { opacity: 1; pointer-events: auto; }
.portal-veil-inner { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; text-align: center; opacity: 0; transform: translateY(10px); transition: opacity 0.7s var(--ease) 0.25s, transform 0.7s var(--ease) 0.25s; }
.portal.is-veiled .portal-veil-inner { opacity: 1; transform: none; }
.portal-veil-inner svg { width: 66px; height: 66px; }
.portal-veil-inner p { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 2.8rem); color: #12151b; }
.portal-veil-inner span { font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; color: #8a6a3b; font-weight: 700; }

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .portal-stage { grid-template-columns: 1fr; align-content: start; gap: 0.6rem; padding-top: 1.2rem; }
  .facade { height: min(36svh, 330px); }
  .portal-panel { justify-self: center; align-items: stretch; }
  .portal-brand { align-self: center; }
  .portal-back { align-self: center; }
  .facade-tag { left: auto; right: 88%; flex-direction: row-reverse; }
  .facade-tag::before { background: linear-gradient(270deg, transparent, #e9d3a6); }
  .facade-tag.is-visible { transform: translate(-6px, -50%); }
}
@media (max-width: 420px) {
  .otp { gap: 0.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .facade-svg .draw { animation: none; stroke-dashoffset: 0; }
  .facade-svg .knob, .facade-svg .door-number, .facade-svg .lamp { animation: none; opacity: 0.9; }
  .portal-brand, .portal-card, .portal-back { animation: none; }
}
