/* =====================================================================
   صفحات الحساب (الدخول / إنشاء حساب / نسيت كلمة المرور)
   لوحة مقسومة: رسمة متحركة على ورق غامق + فورم بخانات جدول لوحة.
   الكلاسات بتبلش بـ au-   (التفاعل: assets/js/auth.js)
   ===================================================================== */

.au {
  --au-err: #b4442f;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  background: var(--dh-paper);
}
@media (min-width: 1024px) {
  .au { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
}

/* ---------- نص الرسمة (غامق) ---------- */
.au-art {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  padding: 1.25rem clamp(1.25rem, 4vw, 3.5rem) 1.5rem;
  color: #fff;
  background-color: var(--dh-ink);
  background-image: radial-gradient(70% 60% at 50% 45%, rgba(217, 169, 63, 0.1), transparent 70%);
}
@media (min-width: 1024px) {
  .au-art { position: sticky; top: 0; height: 100vh; height: 100svh; padding-block: 1.75rem; }
}
.au-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(217, 235, 235, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 235, 235, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(217, 235, 235, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 235, 235, 0.025) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
  background-position: center;
}
/* ومضة ذهبية لما ينجح الطلب */
.au-art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 55%, rgba(255, 244, 214, 0.9), rgba(242, 210, 127, 0.35) 40%, transparent 70%);
  opacity: 0;
}
.au.is-open .au-art::after { animation: au-flash 1.6s ease 0.9s both; }

.au-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.au-logo img { height: 3rem; width: auto; filter: brightness(0) invert(1); }
.au-logo:focus-visible,
.au-back:focus-visible { outline: 2px solid var(--dh-gold); outline-offset: 4px; }
.au-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(217, 235, 235, 0.2);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(217, 235, 235, 0.8);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.au-back svg { width: 1rem; height: 1rem; transform: rotate(180deg); }
.au-back:hover { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(217, 235, 235, 0.35); }

.au-fig {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding-block: 1rem;
}
.au-fig figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, 25rem);
  margin-top: 0.5rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(217, 235, 235, 0.16);
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(217, 235, 235, 0.55);
}
.au-fig figcaption b { font-family: var(--dh-mono); font-weight: 500; color: var(--dh-gold-light); }

.au-copy { max-width: 30rem; }
.au-copy h2 {
  margin-top: 1rem;
  font-size: clamp(1.7rem, 1.1rem + 2vw, 2.7rem);
  font-weight: 900;
  line-height: 1.2;
}
.au-copy h2 em {
  font-style: normal;
  color: transparent;
  background: linear-gradient(135deg, var(--dh-gold-light), var(--dh-gold));
  -webkit-background-clip: text;
  background-clip: text;
}
.au-copy p {
  margin-top: 0.75rem;
  font-size: 1.02rem;
  line-height: 1.85;
  color: rgba(217, 235, 235, 0.72);
}
.au-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 2rem;
  margin-top: 1.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(217, 235, 235, 0.14);
  font-size: 0.75rem;
  color: rgba(217, 235, 235, 0.55);
}
.au-meta b { margin-inline-start: 0.4rem; font-family: var(--dh-mono); font-weight: 500; color: #fff; }

@media (max-width: 1023px) {
  .au-fig { padding-block: 0.5rem 0; }
  .au-fig .au-svg { max-height: 27svh; width: auto; max-width: 100%; }
  .au-fig figcaption { display: none; }
  .au-copy { text-align: center; margin-inline: auto; }
  .au-copy h2 { font-size: clamp(1.5rem, 5.5vw, 2rem); margin-top: 0.6rem; }
  .au-copy p, .au-meta { display: none; }
}

/* ---------- الرسمة ---------- */
.au-svg {
  direction: ltr;
  display: block;
  width: min(100%, 25rem);
  height: auto;
  max-height: min(54vh, calc(100vh - 25rem));
  min-height: 9rem;
  overflow: visible;
}
@media (min-width: 1024px) and (max-height: 760px) {
  .au-copy p { display: none; }
  .au-meta { margin-top: 1rem; }
  .au-svg { max-height: calc(100vh - 21rem); }
}
.au-svg .l {
  fill: none;
  stroke: rgba(217, 235, 235, 0.82);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s var(--dh-ease-io) var(--d, 0s), stroke 0.5s ease, fill 0.8s ease;
}
.au-svg .w { stroke: #e3f0f0; stroke-width: 2; }
.au-svg .t { stroke: rgba(217, 235, 235, 0.42); stroke-width: 0.9; }
.au-svg .g { stroke: var(--dh-gold-light); }
.au-svg .gh {
  fill: none;
  stroke: rgba(217, 235, 235, 0.16);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.au-svg text { font-family: Cairo, sans-serif; font-size: 11px; font-weight: 600; fill: rgba(217, 235, 235, 0.7); opacity: 0; transition: opacity 0.8s ease var(--d, 1.2s); }
.au-svg text.g { fill: var(--dh-gold-light); }
.au-svg text.m { font-family: var(--dh-mono); font-size: 10px; font-weight: 500; }
.au-svg .au-sign { font-family: Cairo, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: 3px; fill: var(--dh-gold-light); }
.au.is-in .au-svg > .l,
.au.is-in .au-svg > g:not([data-stage]) .l,
.au.is-in .au-svg [data-stage].is-on .l { stroke-dashoffset: 0; }
.au.is-in .au-svg > text,
.au.is-in .au-svg > g:not([data-stage]) text,
.au.is-in .au-svg [data-stage].is-on text { opacity: 1; }

/* الدخول: الباب */
.au-light,
.au-floorlight { opacity: 0; transition: opacity 1s ease 0.35s; }
.au.is-open .au-light { opacity: 1; }
.au.is-open .au-floorlight { opacity: 0.8; }
.au-leaf { transform-box: view-box; transition: transform 1.3s var(--dh-ease-io) 0.1s; }
.au-leaf--l { transform-origin: 120px 255px; }
.au-leaf--r { transform-origin: 240px 255px; }
.au.is-open .au-leaf--l { transform: scaleX(0.16) skewY(-12deg); }
.au.is-open .au-leaf--r { transform: scaleX(0.16) skewY(12deg); }
.au-svg .au-handle { transition: stroke 0.4s ease, filter 0.4s ease; }
.au.is-armed .au-svg .au-handle { stroke: var(--dh-gold-light); stroke-width: 2.4; filter: drop-shadow(0 0 4px rgba(242, 210, 127, 0.9)); }

/* إنشاء حساب: الشبابيك بتضوي لما يكتمل المبنى */
.au-svg .au-win { fill: rgba(242, 210, 127, 0); }
.au.is-open .au-svg .au-win { fill: rgba(242, 210, 127, 0.35); }
.au-stamp { opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(1.6) rotate(-12deg); transition: opacity 0.3s ease, transform 0.5s var(--dh-ease); }
.au.is-open .au-stamp { opacity: 1; transform: rotate(-12deg); transition-delay: 0.4s; }
.au-stamp circle { fill: none; stroke: var(--dh-gold-light); stroke-width: 1.5; }
.au-stamp text { opacity: 1; fill: var(--dh-gold-light); font-weight: 800; font-size: 11px; }

/* نسيت كلمة المرور: المفتاح بيدخل والقفل بينفتح */
.au-key { transform-box: view-box; transition: transform 1.1s var(--dh-ease-io); }
.au.is-open .au-key { transform: translate(10px, -108px); }
.au-shackle { transform-box: view-box; transition: transform 0.7s var(--dh-ease) 1s; }
.au.is-open .au-shackle { transform: translateY(-26px); }

/* ---------- نص الفورم ---------- */
.au-form {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(2.25rem, 6vw, 4rem) clamp(1.25rem, 5vw, 4rem);
}
.au-card {
  position: relative;
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  background: rgba(255, 255, 255, 0.85);
}
/* علامات زوايا متل علامات القص على اللوحة */
.au-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  --m: var(--dh-gold-600);
  background:
    linear-gradient(var(--m), var(--m)) top right / 18px 1px,
    linear-gradient(var(--m), var(--m)) top right / 1px 18px,
    linear-gradient(var(--m), var(--m)) top left / 18px 1px,
    linear-gradient(var(--m), var(--m)) top left / 1px 18px,
    linear-gradient(var(--m), var(--m)) bottom right / 18px 1px,
    linear-gradient(var(--m), var(--m)) bottom right / 1px 18px,
    linear-gradient(var(--m), var(--m)) bottom left / 18px 1px,
    linear-gradient(var(--m), var(--m)) bottom left / 1px 18px;
  background-repeat: no-repeat;
}
.au-card .ds-tag { margin-bottom: 1.25rem; }
.au-card h1 {
  font-size: clamp(1.9rem, 1.4rem + 1.5vw, 2.5rem);
  font-weight: 900;
  line-height: 1.2;
  color: var(--dh-teal);
}
.au-sub { margin-top: 0.5rem; font-size: 1rem; line-height: 1.8; color: var(--dh-muted); }

.au-fields { display: grid; gap: 1.15rem; margin-top: 2rem; }
.au-field label,
.au-field .au-lbl {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--dh-text);
}
.au-field label a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dh-gold-600);
  transition: color 0.3s ease;
}
.au-field label a:hover { color: var(--dh-teal); }
.au-field label a:focus-visible { outline: 2px solid var(--dh-gold); outline-offset: 2px; }

.au-input {
  position: relative;
  display: flex;
  align-items: stretch;
  height: 3.4rem;
  border: 1px solid var(--dh-line-2);
  background: var(--dh-paper);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.au-ico {
  display: grid;
  place-items: center;
  width: 3.2rem;
  flex-shrink: 0;
  border-inline-end: 1px solid var(--dh-line-2);
  color: var(--dh-teal);
}
.au-ico svg { width: 1.15rem; height: 1.15rem; }
.au-input input {
  flex: 1;
  min-width: 0;
  padding-inline: 1rem;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--dh-text);
}
.au-input input[dir="ltr"] { text-align: left; }
.au-input input::placeholder { color: rgba(90, 107, 107, 0.6); font-weight: 500; }
.au-input:focus-within {
  border-color: var(--dh-teal);
  box-shadow: inset 0 -2px 0 var(--dh-gold), 0 14px 30px -22px rgba(20, 57, 57, 0.6);
}
.au-ok {
  display: grid;
  place-items: center;
  width: 2.4rem;
  flex-shrink: 0;
  color: var(--dh-gold-600);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.4s var(--dh-ease);
}
.au-ok svg { width: 1.05rem; height: 1.05rem; }
.au-field.is-valid .au-ok { opacity: 1; transform: none; }
.au-eye {
  display: grid;
  place-items: center;
  width: 3rem;
  flex-shrink: 0;
  color: var(--dh-muted);
  transition: color 0.3s ease;
}
.au-eye:hover,
.au-eye[aria-pressed="true"] { color: var(--dh-teal); }
.au-eye:focus-visible { outline: 2px solid var(--dh-gold); outline-offset: -4px; }
.au-eye svg { width: 1.15rem; height: 1.15rem; }
.au-eye .off { display: none; }
.au-eye[aria-pressed="true"] .on { display: none; }
.au-eye[aria-pressed="true"] .off { display: block; }

.au-field.is-invalid .au-input { border-color: var(--au-err); box-shadow: inset 0 -2px 0 var(--au-err); }
.au-field.is-invalid .au-ico { color: var(--au-err); }
.au-err,
.au-caps {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--au-err);
}
.au-err:empty { display: none; }
.au-caps { color: var(--dh-gold-600); }
.au-caps[hidden] { display: none; }

/* ---------- قوة كلمة السر: جسر بينحني إذا ضعيفة ---------- */
.au-load {
  --load: var(--dh-line-2);
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  align-items: center;
  gap: 0.25rem 0.9rem;
  margin-top: 0.7rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--dh-line-2);
  background: rgba(241, 247, 247, 0.6);
}
.au-load[data-score="1"] { --load: var(--au-err); }
.au-load[data-score="2"] { --load: var(--dh-gold-600); }
.au-load[data-score="3"] { --load: var(--dh-teal-600); }
.au-load[data-score="4"] { --load: var(--dh-teal); }
.au-beam { direction: ltr; width: 100%; height: auto; overflow: visible; }
.au-beam .sup { fill: none; stroke: var(--dh-teal); stroke-width: 1.2; }
.au-beam .gl { stroke: var(--dh-line-2); stroke-width: 1; }
.au-beam .beam {
  fill: none;
  stroke: var(--load);
  stroke-width: 3;
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 0 14px;
  transform: scaleY(var(--sag, 1));
  transition: transform 0.6s var(--dh-ease), stroke 0.4s ease;
}
.au-beam .arw { fill: none; stroke: var(--load); stroke-width: 1.2; transition: stroke 0.4s ease, opacity 0.4s ease; }
.au-load[data-score="4"] .au-beam .arw { opacity: 0.35; }
.au-load__txt { display: grid; gap: 0.05rem; }
.au-load__txt span { font-size: 0.72rem; font-weight: 600; color: var(--dh-muted); }
.au-load__txt b { font-size: 0.92rem; font-weight: 800; color: var(--load); transition: color 0.4s ease; }
.au-hints {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dh-muted);
}
.au-hints li { display: flex; align-items: center; gap: 0.3rem; transition: color 0.3s ease; }
.au-hints li::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border: 1px solid currentColor;
  transition: background-color 0.3s ease;
}
.au-hints li.is-ok { color: var(--dh-teal); }
.au-hints li.is-ok::before { background: var(--dh-gold); border-color: var(--dh-gold); }

/* ---------- الإرسال ---------- */
.au-terms { margin-top: 1.1rem; font-size: 0.8rem; line-height: 1.8; color: var(--dh-muted); }
.au-terms b { color: var(--dh-teal); font-weight: 700; }
.au-submit { width: 100%; margin-top: 1.6rem; height: 3.5rem; }
.au-submit .au-spin { display: none; width: 1.2rem; height: 1.2rem; }
.au-submit.is-loading { pointer-events: none; }
.au-submit.is-loading .au-spin { display: block; animation: au-rot 0.9s linear infinite; }
.au-submit.is-loading .au-arrow { display: none; }
.au-status {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
  color: var(--dh-teal);
}
.au-status:empty { display: none; }
.au-status small { display: block; font-size: 0.75rem; font-weight: 500; color: var(--dh-muted); }

.au-switch {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--dh-line);
  text-align: center;
  font-size: 0.92rem;
  color: var(--dh-muted);
}
.au-switch a {
  position: relative;
  font-weight: 800;
  color: var(--dh-teal);
}
.au-switch a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -2px;
  height: 1px;
  background: var(--dh-gold);
  transform: scaleX(0.3);
  transform-origin: right;
  transition: transform 0.4s var(--dh-ease);
}
.au-switch a:hover::after { transform: none; }
.au-switch a:focus-visible { outline: 2px solid var(--dh-gold); outline-offset: 3px; }

/* حالة النجاح (نسيت كلمة المرور) */
.au-done { display: none; text-align: center; }
.au-done svg { width: 4.5rem; height: 4.5rem; margin: 0 auto 1rem; color: var(--dh-gold-600); }
.au-done h2 { font-size: 1.6rem; font-weight: 900; color: var(--dh-teal); }
.au-done p { margin-top: 0.6rem; line-height: 1.85; color: var(--dh-muted); }
.au-done p b { color: var(--dh-text); unicode-bidi: plaintext; }
.au-done .ds-btn { width: 100%; margin-top: 1.5rem; }
.au-resend { margin-top: 0.9rem; font-size: 0.85rem; font-weight: 700; color: var(--dh-teal); }
.au-resend:disabled { color: var(--dh-muted); cursor: default; }
.au.is-sent .au-done { display: block; animation: au-rise 0.7s var(--dh-ease) both; }
.au.is-sent .au-formwrap { display: none; }

/* دخول الفورم */
.au-formwrap > * { animation: au-rise 0.8s var(--dh-ease) both; }
.au-formwrap > :nth-child(2) { animation-delay: 0.08s; }
.au-formwrap > :nth-child(3) { animation-delay: 0.16s; }
.au-formwrap > :nth-child(4) { animation-delay: 0.24s; }
.au-shake { animation: au-shake 0.45s ease; }

@keyframes au-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes au-rot { to { transform: rotate(360deg); } }
@keyframes au-shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
@keyframes au-flash { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .au-svg .l { transition: none; stroke-dashoffset: 0; }
  .au-svg [data-stage]:not(.is-on) .l { stroke-dashoffset: 1; }
  .au-svg text { transition: none; opacity: 1; }
  .au-svg [data-stage]:not(.is-on) text { opacity: 0; }
  .au-leaf, .au-key, .au-shackle, .au-light, .au-floorlight, .au-stamp, .au-beam .beam { transition: none; }
  .au-formwrap > *, .au.is-sent .au-done, .au-shake { animation: none; }
  .au.is-open .au-art::after { animation: none; }
}
