/* Front door: logo entrance on Deep Pine, then the sign-in panel. Desktop: logo slides left, panel from the right. Phone: logo rises, panel comes up as a sheet. */

html.gating body { background: var(--pine); overflow: hidden; }
html.gating body > :not(.gate) { visibility: hidden; }

.gate {
  --panel-w: min(500px, 42vw);
  --cream-a: rgba(246, 243, 236, 0.72);
  position: fixed; inset: 0; z-index: 200;
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(23, 114, 69, 0.35), transparent 60%),
    radial-gradient(90% 70% at 90% 100%, rgba(14, 77, 46, 0.55), transparent 70%),
    var(--pine);
  color: var(--cream);
  overflow: hidden;
  clip-path: ellipse(150% 150% at 50% 0%);
  transition: opacity 0.6s var(--ease-out), clip-path 0.9s var(--ease-io);
}

/* ---------- Brand ---------- */
.gate-brand {
  position: absolute; left: 50%; top: 46%;
  width: min(440px, 80vw);
  transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 18px; text-align: center;
  transition: left 0.95s var(--ease-glide), top 0.95s var(--ease-glide), transform 0.95s var(--ease-glide);
}
.gate-mark-wrap {
  position: relative; display: grid; place-items: center; width: 88px; height: 88px;
  translate: calc(var(--px, 0) * -18px) calc(var(--py, 0) * -12px);
  transition: translate 0.9s var(--ease-out);
}
/* A low sun behind the leaf: a warm glow that breathes, and slow turning rays. */
.gate-mark-wrap::before {
  content: ""; position: absolute; inset: -110px; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(243, 211, 107, 0.42), rgba(243, 211, 107, 0.12) 55%, transparent);
  animation: gateBreathe 5s ease-in-out infinite alternate;
}
.gate-rays {
  position: absolute; inset: -190px; z-index: -1; border-radius: 50%;
  background: repeating-conic-gradient(rgba(243, 211, 107, 0.14) 0 3deg, transparent 3deg 14deg);
  -webkit-mask: radial-gradient(closest-side, #000 25%, transparent 92%);
  mask: radial-gradient(closest-side, #000 25%, transparent 92%);
  animation: gateTurn 90s linear infinite;
}
.gate-mark { position: relative; width: 88px; height: 88px; border-radius: 26px 7px 26px 7px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); }
.gate-shine { position: absolute; inset: 0; border-radius: 26px 7px 26px 7px; overflow: hidden; pointer-events: none; }
.gate-shine::after {
  content: ""; position: absolute; inset: -20% -60%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.6) 50%, transparent 60%);
  translate: -100% 0;
}
.gate-word { width: 100%; height: auto; fill: var(--cream); overflow: visible; }
.gate-word path { transform-box: fill-box; transform-origin: 50% 100%; }
.gate-word-fallback { font-family: var(--display); font-size: 64px; color: var(--cream); background: none; }
.gate-tagline { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: 0.04em; color: var(--gold); margin: 0; }
.gate-pitch { margin: 0; max-width: 34ch; color: var(--cream-a); font-size: 16px; line-height: 1.5; opacity: 0; transform: translateY(8px); transition: opacity 0.6s 0.35s, transform 0.6s 0.35s var(--ease-out); }

/* ---------- Field curves ---------- */
.gate-field {
  position: absolute; left: -20px; bottom: 0; width: calc(100% + 40px); max-width: none; height: 22vh;
  translate: calc(var(--px, 0) * 14px) 0; transition: translate 0.9s var(--ease-out);
}
.gf-row { fill: none; stroke: var(--mint); stroke-opacity: 0.45; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 1; }

/* Pollen in the evening light. */
.gate-motes { position: absolute; inset: 0; pointer-events: none; animation: gateFade 2s 1s both; }
.gate-motes span {
  position: absolute; left: var(--x); bottom: 8vh; width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 10px rgba(243, 211, 107, 0.8); opacity: 0;
  animation: gateMote var(--t) var(--d) linear infinite;
}
.gf-gold { fill: var(--gold); }
.gf-green { fill: var(--leaf); }
.gf-mint { fill: var(--mint); }

/* ---------- Intro (first visit of the session) ---------- */
.gate.is-intro .gate-mark { animation: gateMark 1s var(--ease-out) both; }
.gate.is-intro .gate-mark-wrap::before { animation: gateDawn 1.6s var(--ease-out) both, gateBreathe 5s 1.6s ease-in-out infinite alternate; }
.gate.is-intro .gate-rays { animation: gateFade 1.8s 0.5s var(--ease-out) both, gateTurn 90s linear infinite; }
.gate.is-intro .gate-shine::after { animation: gateShine 0.9s 0.95s var(--ease-io) both; }
.gate.is-intro .gf-row { animation: gateFurrow 1.2s calc(0.7s + var(--k, 0) * 90ms) var(--ease-out) both; }
.gate.is-intro .gate-word path { animation: gateLetter 0.7s calc(0.35s + var(--i, 0) * 70ms) var(--ease-out) both; }
.gate.is-intro .gate-tagline { animation: gateFade 0.6s 0.95s var(--ease-out) both; }
.gate.is-intro .gate-field path { animation: gateRise 1.1s var(--ease-out) both; }
.gate.is-intro .gf-green { animation-delay: 0.12s; }
.gate.is-intro .gf-mint { animation-delay: 0.24s; }

/* The leaf grows out of its stem corner, bottom left. */
@keyframes gateMark {
  from { opacity: 0; transform: translateY(24px) scale(0.6); clip-path: circle(0% at 0% 100%); }
  40% { opacity: 1; }
  to { opacity: 1; transform: none; clip-path: circle(142% at 0% 100%); }
}
@keyframes gateDawn { from { opacity: 0; scale: 0.2; translate: 0 60px; } to { opacity: 1; scale: 1; translate: 0 0; } }
@keyframes gateBreathe { from { scale: 1; opacity: 0.85; } to { scale: 1.12; opacity: 1; } }
@keyframes gateTurn { to { rotate: 360deg; } }
@keyframes gateShine { from { translate: -100% 0; } to { translate: 100% 0; } }
@keyframes gateFurrow { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes gateMote {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 0.8; }
  80% { opacity: 0.45; }
  100% { transform: translate(var(--dx), -70vh); opacity: 0; }
}
/* When the panel lands, its contents follow it in, one after another. */
.gate.is-arriving .gate-card > * { animation: gateFade 0.6s calc(0.3s + var(--k, 0) * 60ms) var(--ease-out) backwards; }
@keyframes gateLetter { from { opacity: 0; transform: translateY(55%) scaleY(1.15); } to { opacity: 1; transform: none; } }
@keyframes gateFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes gateRise { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- Panel ---------- */
.gate-panel {
  position: absolute; z-index: 2;
  background: var(--cream); color: var(--ink);
  overflow-y: auto; overscroll-behavior: contain;
  transition: transform 0.85s var(--ease-sheet), opacity 0.5s var(--ease-out);
}
.gate-card { display: grid; gap: 14px; width: 100%; max-width: 380px; margin: 0 auto; }
.gate-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gate-title { font-family: var(--display); font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
.gate-notice { margin: 0; padding: 10px 12px; border: 1px solid #bfe0cb; border-radius: 12px; background: var(--mint-tint); color: var(--pine); font-size: 13.5px; line-height: 1.4; }
.gate-legal-btn { justify-self: center; font-size: 13px; color: var(--muted); }
.account-del-btn { grid-column: 1 / -1; justify-self: start; color: var(--risk); font-size: 13px; }
.account-del-btn:hover { border-color: var(--risk); background: var(--risk-tint); }

.gate-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: var(--sunken); position: relative; }
.gate-tab {
  min-height: 44px; border: 0; border-radius: 999px; background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: background 0.3s var(--ease-out), color 0.3s, box-shadow 0.3s;
}
.gate-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 35, 26, 0.14); }

.gate-form { display: grid; gap: 14px; }
.gate-field-row { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
.gate-field-row input {
  width: 100%; min-height: 50px; padding: 0 14px;
  border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  font: inherit; font-weight: 400; font-size: 17px; color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gate-field-row input:focus { outline: none; border-color: var(--leaf); box-shadow: 0 0 0 4px var(--mint-tint); }
.gate-pw { position: relative; display: block; }
.gate-pw input { padding-right: 52px; }
.gate-eye { position: absolute; right: 3px; top: 3px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.gate-eye[aria-pressed="true"] { color: var(--leaf); }
.gate-hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.gate-error { margin: 0; min-height: 1.2em; color: var(--risk); font-weight: 600; font-size: 15px; }
.gate-error:empty { min-height: 0; }
.gate-submit { min-height: 52px; font-size: 17px; position: relative; }
.gate-submit.busy span { opacity: 0; }
.gate-submit.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px;
  border-radius: 50%; border: 2.5px solid rgba(246, 243, 236, 0.4); border-top-color: var(--cream);
  animation: gateSpin 0.8s linear infinite;
}
@keyframes gateSpin { to { transform: rotate(360deg); } }

.gate-or { height: 1px; background: var(--line); margin: 2px 0; }
.gate-demo { min-height: 48px; }
.gate-note { margin: -6px 0 0; color: var(--muted); font-size: 14px; text-align: center; }
.gate-langs { display: flex; justify-content: center; gap: 4px; }
.gate-langs button { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.gate-langs button.active { color: var(--emerald); background: var(--mint-tint); }

.gate-shake { animation: gateShake 0.42s var(--ease-out); }
@keyframes gateShake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.gate-swap { animation: gateSwap 0.36s var(--ease-out); }
@keyframes gateSwap { from { opacity: 0.4; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.gate-card.is-welcome .gate-form, .gate-card.is-welcome .gate-tabs { opacity: 0.4; pointer-events: none; transition: opacity 0.3s; }

/* Phone and tablet: the panel is a sheet under the logo. */
@media (max-width: 899px) {
  .gate-panel {
    left: 0; right: 0; bottom: 0; max-height: 78dvh;
    padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
  }
  .gate.is-ready .gate-panel { transform: none; }
  .gate.is-ready .gate-brand { top: max(84px, 11dvh); transform: translate(-50%, -50%) scale(0.62); }
  .gate.is-ready .gate-pitch { display: none; }
  .gate-title { font-size: 24px; }
}

/* Desktop: logo glides to the middle of the left side, panel slides in from the right. */
@media (min-width: 900px) {
  .gate-panel {
    top: 0; right: 0; bottom: 0; width: var(--panel-w);
    display: grid; align-items: center;
    padding: 48px clamp(28px, 4vw, 64px);
    border-radius: 40px 0 0 40px;
    transform: translateX(104%);
    box-shadow: -30px 0 80px rgba(0, 0, 0, 0.28);
  }
  .gate.is-ready .gate-panel { transform: none; }
  .gate.is-ready .gate-brand { left: calc((100% - var(--panel-w)) / 2); }
  .gate.is-ready .gate-pitch { opacity: 1; transform: none; }
  .gate-field { height: 26vh; }
}

/* Signing in lifts the evening away like a hill rolling up off the app. */
.gate.is-leaving { clip-path: ellipse(150% 0% at 50% 0%); opacity: 0; pointer-events: none; }
.gate.is-leaving .gate-brand { opacity: 0; transition: opacity 0.4s; }
.gate.no-intro .gate-brand, .gate.no-intro .gate-panel { transition-duration: 0.5s; }

@media (prefers-reduced-motion: reduce) {
  .gate, .gate *, .gate *::before, .gate *::after { animation: none !important; transition: none !important; }
  .gate-motes, .gate-rays, .gate-shine { display: none; }
}

/* ---------- Account block in Ajustes ---------- */
.account {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 14px; margin-bottom: 18px; border-radius: var(--leaf-r-sm, 18px 5px 18px 5px);
  background: var(--sunken);
}
.account-avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--emerald); color: var(--cream); font-family: var(--display); font-weight: 700; font-size: 19px;
}
.account-avatar.is-guest { background: var(--mint-tint); color: var(--emerald); }
.account-who { display: grid; min-width: 0; }
.account-who strong, .account-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who small { color: var(--muted); font-size: 14px; }
.account-note { grid-column: 1 / -1; margin: 0; }
.account .btn .ic { width: 18px; height: 18px; }
@media (max-width: 420px) {
  .account { grid-template-columns: auto 1fr; }
  .account > .btn { grid-column: 1 / -1; }
}
.gate [hidden] { display: none !important; }
