/* Portal login/register — 3-circle intro → split card (teal brand). */
:root, html[data-theme="dark"] {
  --ap-bg: #030a0d;
  --ap-glow: rgba(0, 190, 179, 0.16);
  --ap-text: #f3fffe;
  --ap-mut: #7f979c;
  --ap-field: #121f24;
  --ap-field2: #18282e;
  --ap-line: rgba(0, 190, 179, 0.22);
  --ap-teal: #00beb3;
  --ap-btn: linear-gradient(90deg, #00a89f, #19dccf);
  --ap-btn-text: #03201e;
  --ap-card: #0a1418;
  --ap-side: #071014;
  --ap-err: #ffb4b4;
  --ap-err-bg: rgba(255, 123, 123, 0.1);
}
html[data-theme="light"] {
  --ap-bg: #dfe9e8;
  --ap-glow: rgba(0, 168, 159, 0.14);
  --ap-text: #142226;
  --ap-mut: #5a7277;
  --ap-field: #f7fafb;
  --ap-field2: #ffffff;
  --ap-line: rgba(20, 34, 38, 0.1);
  --ap-teal: #00a89f;
  --ap-btn: linear-gradient(90deg, #00a89f, #19dccf);
  --ap-btn-text: #03201e;
  --ap-card: #ffffff;
  --ap-side: #0a1214;
  --ap-err: #b42318;
  --ap-err-bg: rgba(180, 35, 24, 0.08);
}

.ap-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background: var(--ap-bg);
  color: var(--ap-text);
  position: relative;
  overflow: hidden;
  font-family: Vazirmatn, Tahoma, sans-serif;
}
.ap-wrap::before {
  content: "";
  position: absolute;
  inset: auto 0 -40% 0;
  height: 70%;
  background: radial-gradient(ellipse at 50% 100%, var(--ap-glow), transparent 65%);
  pointer-events: none;
}

/* —— Intro: Farayand logo reveal (no circles) —— */
.ap-intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
  pointer-events: none;
}
.ap-intro-stage {
  position: relative;
  width: min(420px, 78vw);
  display: grid;
  place-items: center;
}
.ap-intro-glow {
  position: absolute;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 190, 179, 0.35), transparent 68%);
  filter: blur(18px);
  opacity: 0;
  transform: scale(0.6);
}
.ap-intro-logo {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: auto;
  opacity: 0;
  transform: translateY(28px) scale(0.82);
  filter: blur(12px) drop-shadow(0 20px 50px rgba(0, 190, 179, 0.2));
}
.ap-js.ap-logo .ap-intro-glow {
  opacity: 1;
  transform: scale(1.15);
  transition: opacity 0.9s ease, transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ap-js.ap-logo .ap-intro-logo {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0) drop-shadow(0 18px 40px rgba(0, 190, 179, 0.35));
  transition:
    opacity 0.7s ease,
    transform 1.05s cubic-bezier(0.16, 1, 0.3, 1),
    filter 1s ease;
}
.ap-js.ap-settle .ap-intro-logo {
  transform: translateY(-6px) scale(0.92);
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1), filter 1s ease, opacity 0.6s ease;
}
.ap-js.ap-done .ap-intro {
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

/* —— Card —— */
.ap-card {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  background: var(--ap-card);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--ap-line), 0 40px 100px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(28px) scale(0.98);
  pointer-events: none;
  min-height: 560px;
}
.ap-js.ap-open .ap-card {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity 0.7s ease, transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ap-side {
  position: relative;
  min-height: 560px;
  background: #05080a;
  overflow: hidden;
  color: #fff;
}
.ap-side-brand {
  position: absolute;
  top: 22px;
  inset-inline-start: 22px;
  z-index: 4;
}
.ap-side-logo {
  width: min(168px, 52%);
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45));
}
.ap-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.7s ease, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.ap-slide.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 1;
}
.ap-slide picture {
  position: absolute;
  inset: 0;
  display: block;
}
.ap-slide img,
.ap-slide picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ap-slide-empty {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(0, 190, 179, 0.22), transparent 50%),
    linear-gradient(160deg, #0a1519, #030a0d 60%, #07131a);
}
.ap-slide-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.15) 45%, rgba(0, 0, 0, 0.72) 100%);
  pointer-events: none;
}
.ap-slide-cap {
  position: absolute;
  inset-inline-start: 22px;
  bottom: 72px;
  z-index: 2;
  max-width: 80%;
  display: grid;
  gap: 6px;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.ap-slide-cap strong {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.4;
}
.ap-slide-cap span {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.7;
}
.ap-slide-nav {
  position: absolute;
  inset-inline-end: 18px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  gap: 10px;
}
.ap-slide-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  transition: 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
@media (hover: hover) and (pointer: fine) { .ap-slide-btn:hover {
  background: rgba(0, 190, 179, 0.85);
  border-color: transparent;
  transform: translateY(-1px);
} }
.ap-slide-dots {
  position: absolute;
  inset-inline-start: 22px;
  bottom: 28px;
  z-index: 3;
  display: flex;
  gap: 7px;
}
.ap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
}
.ap-dot.is-on { background: #fff; box-shadow: 0 0 0 3px rgba(0, 190, 179, 0.35); }

.ap-form {
  padding: 36px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  direction: rtl;
  text-align: right;
}
.ap-form h1 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; }
.ap-lead { margin: 0 0 18px; color: var(--ap-mut); font-size: 0.9rem; line-height: 1.8; }
.ap-msg {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ap-err-bg);
  color: var(--ap-err);
  font-size: 0.88rem;
  line-height: 1.6;
}
.ap-msg:empty { display: none; }
.ap-field { display: grid; gap: 6px; margin-bottom: 12px; }
.ap-field label { font-size: 0.82rem; color: var(--ap-mut); font-weight: 600; }
.ap-field input {
  display: block;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--ap-field), var(--ap-field2));
  color: var(--ap-text);
  font: inherit;
  outline: none;
  box-shadow: inset 0 0 0 1px var(--ap-line);
  transition: 0.2s;
  box-sizing: border-box;
}
.ap-field input:focus { box-shadow: 0 0 0 1px var(--ap-teal), 0 0 16px rgba(0, 190, 179, 0.22); }
html[data-theme="light"] .ap-form { background: #fff; }
html[data-theme="light"] .ap-field input { background: #fff; }
.ap-pw {
  position: relative;
  display: block;
  width: 100%;
}
.ap-pw input {
  width: 100%;
  padding-inline-start: 44px;
  box-sizing: border-box;
}
.ap-pw button {
  position: absolute;
  inset-inline-start: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ap-mut);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.ap-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 6px;
}
.ap-btn, .ap-btn-soft {
  height: 48px;
  border-radius: 10px;
  border: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: 0.25s;
  white-space: nowrap;
}
.ap-btn { background: var(--ap-btn); color: var(--ap-btn-text); }
@media (hover: hover) and (pointer: fine) { .ap-btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0, 190, 179, 0.28); } }
.ap-btn-soft {
  background: transparent;
  color: var(--ap-teal);
  box-shadow: inset 0 0 0 1px var(--ap-line);
}
@media (hover: hover) and (pointer: fine) { .ap-btn-soft:hover { background: rgba(0, 190, 179, 0.08); } }
.ap-btn.is-busy { pointer-events: none; color: transparent; position: relative; }
.ap-btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(3, 32, 30, 0.25);
  border-top-color: #03201e;
  animation: apSpinBtn 0.7s linear infinite;
}
@keyframes apSpinBtn { to { transform: rotate(360deg); } }

.ap-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 14px;
}
html[data-theme="light"] .ap-modes { background: rgba(0, 120, 110, 0.08); }
.ap-modes button {
  border: 0;
  background: transparent;
  color: var(--ap-mut);
  font: inherit;
  font-weight: 700;
  padding: 0.65rem 0.4rem;
  border-radius: 9px;
  cursor: pointer;
}
.ap-modes button.is-on { background: var(--ap-teal); color: #03201e; }

.ap-panels { position: relative; }
.ap-panel { display: none; }
.ap-panel.is-on { display: block; animation: apIn 0.35s ease; }
@keyframes apIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ap-foot {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--ap-mut);
}
.ap-foot a { color: var(--ap-teal); font-weight: 700; text-decoration: none; }
.ap-register-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 190, 179, 0.1);
  box-shadow: inset 0 0 0 1px var(--ap-line);
}
.ap-register-cta strong { color: var(--ap-text); font-size: 0.92rem; }
.ap-register-cta span { color: var(--ap-mut); font-size: 0.8rem; display: block; margin-top: 2px; }

/* OTP modal */
.ap-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 10, 13, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
  direction: rtl;
}
.ap-modal[hidden] { display: none; }
.ap-modal.open { opacity: 1; }
.ap-modal-card {
  width: 380px;
  max-width: 100%;
  padding: 28px 22px 22px;
  border-radius: 18px;
  background: var(--ap-card);
  box-shadow: 0 0 0 1px var(--ap-line), 0 30px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
  transform: translateY(18px);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.ap-modal.open .ap-modal-card { transform: none; }
.ap-boxes { display: flex; justify-content: center; gap: 8px; direction: ltr; margin: 14px 0; }
.ap-box {
  width: 48px;
  height: 56px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ap-field), var(--ap-field2));
  color: var(--ap-text);
  font: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  outline: none;
}
.ap-box:focus { box-shadow: 0 0 0 1px var(--ap-teal), 0 0 14px rgba(0, 190, 179, 0.25); }

@media (max-width: 860px) {
  .ap-card { grid-template-columns: 1fr; min-height: 0; }
  .ap-side { min-height: 260px; }
  .ap-slide-cap { bottom: 64px; }
  .ap-form { padding: 22px; }
  .ap-actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-js .ap-intro-logo, .ap-js .ap-intro-glow, .ap-js.ap-open .ap-card { opacity: 1; transform: none; filter: none; transition: none; }
  .ap-intro { display: none; }
}
