/* Authentication screens. Light page + white card (Figma 319:822). Logical properties: flips with dir. */
body.auth-page {
  --a-navy: #191f6a;      /* logo indigo, 13:1 on white */
  --a-violet: #4a27a8;    /* logo violet, 9:1 on white */
  --a-muted: #5d667a;      /* 5.6:1 on white */
  --a-border: #cfd5e3;
  --a-surface: #f7f8fc;
  --a-error: #b3261e;      /* 6.5:1 on white */
  background: radial-gradient(1200px 600px at 0% 0%, #f3e6ee 0%, transparent 60%), #ececf5;
  color: var(--a-navy);
}
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--gutter); max-inline-size: 640px; margin-inline: auto; inline-size: 100%; }
.lang-mini { position: absolute; inset-block-start: 14px; inset-inline-end: 14px; display: flex; gap: 4px; margin: 0; padding: 3px; background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--radius-pill); }
.lang-mini__btn {
  min-inline-size: 34px; block-size: 28px; padding: 0 8px; font: inherit; font-size: 0.75rem; font-weight: 600; line-height: 1;
  color: var(--a-muted); background: transparent; border: 0; border-radius: var(--radius-pill); cursor: pointer;
}
.lang-mini__btn:hover { color: var(--a-navy); }
.lang-mini__btn[aria-current='true'] { background: #fff; color: var(--a-violet); box-shadow: 0 1px 3px rgb(25 31 106 / 16%); cursor: default; }
.auth-pane { flex: 1 0 auto; display: flex; flex-direction: column; min-inline-size: 0; }
.auth-brand { display: none; }
.auth-main { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; padding: var(--space-2) var(--gutter) var(--space-4); }
.auth-card {
  inline-size: 100%; max-inline-size: 540px; background: #fff; border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-3) var(--space-4); box-shadow: 0 20px 60px rgb(16 35 68 / 10%); text-align: start; position: relative;
}
@media (min-width: 600px) { .auth-card { padding: var(--space-4) 50px; } }
.auth-card__bar { display: block; inline-size: 76px; block-size: 3px; margin: 22px auto var(--space-2); /* clears the language switch */ border-radius: 3px; background: linear-gradient(90deg, #5737d9, #ee2682 55%, #19dbf7); }
.auth-card__crumb { margin: 0; text-align: center; font-size: var(--fs-sm); font-weight: 600; color: #b8235f; } /* logo pink, darkened to 5.6:1 */
.auth-card__title { margin: var(--space-1) 0; text-align: center; font-size: clamp(1.6rem, 5vw, 2.1rem); font-weight: 600; line-height: 1.25; }
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .auth-card__title { background: linear-gradient(90deg, #191f6a, #4a27a8 60%, #651fa9); -webkit-background-clip: text; background-clip: text; color: transparent; }
}
.auth-card__lead { margin: 0 0 var(--space-3); text-align: center; color: var(--a-muted); }
.auth-foot { margin-block: var(--space-3) 0; font-size: var(--fs-sm); color: var(--a-muted); text-align: center; }

.field { margin-block-end: var(--space-2); }
.field > label, .field > legend { display: block; margin-block-end: 6px; font-weight: 600; font-size: 0.9rem; padding: 0; }
.input {
  inline-size: 100%; min-block-size: 52px; padding: 0 var(--space-2); font: inherit; color: var(--a-navy);
  background: #fff; border: 1px solid var(--a-border); border-radius: var(--radius-control);
}
.input::placeholder { color: #8a93a6; }
.input[aria-invalid='true'] { border-color: var(--a-error); }
.input--code { text-align: center; letter-spacing: 0.4em; font-size: 1.4rem; }
.field-error { margin: 6px 0 0; color: var(--a-error); font-size: var(--fs-sm); }
.field-error[hidden] { display: none; }
.alert { margin: 0 0 var(--space-2); padding: 12px var(--space-2); border-radius: var(--radius-control); font-size: 0.9rem; }
.alert--ok { background: #e8f5ee; color: #14532d; }

.phone { display: flex; gap: var(--space-1); }
.phone .input { flex: 1 1 auto; min-inline-size: 0; }
/* The number is typed left-to-right, but the empty-field hint follows the page language. */
[dir='rtl'] .phone .input:placeholder-shown { direction: rtl; }
.phone__country {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--space-2); min-block-size: 52px;
  background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--radius-control);
  color: var(--a-navy); text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
/* The number stays left-to-right (digits, "+"), but sits on the right on Arabic pages. */
[dir='rtl'] .phone .input { text-align: right; }
.flag { inline-size: 20px; block-size: 14px; flex: 0 0 auto; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
span.flag { display: inline-block; background: var(--a-border); }
.pw { position: relative; }
.pw .input { padding-inline-end: 52px; }
.pw__toggle { position: absolute; inset-block: 0; inset-inline-end: 0; inline-size: 52px; display: grid; place-items: center; background: none; border: 0; color: #392a64; cursor: pointer; }
.pw__toggle[hidden] { display: none; }
.js .pw__toggle { display: grid; }
.link-row { margin: 0 0 var(--space-2); font-size: 0.9rem; font-weight: 600; }
.auth-card a { color: var(--a-violet); text-underline-offset: 3px; }
.field--check { display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: start; font-size: 0.85rem; }
.field--check input { inline-size: 22px; block-size: 22px; margin: 2px 0 0; accent-color: #ca486c; }
.field--check label { margin: 0; font-weight: 400; }
.field--check .field-error { grid-column: 2; }
.channel { border: 0; padding: 0; margin-inline: 0; }
.channel label { display: inline-flex; gap: 8px; align-items: center; margin-inline-end: var(--space-3); font-weight: 400; min-block-size: 44px; }

.btn { display: flex; align-items: center; justify-content: center; inline-size: 100%; min-block-size: 52px; padding: 0 var(--space-2); font: inherit; font-weight: 600; border-radius: var(--radius-control); border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn--primary { background: #ca486c; color: #fff; }
.btn--primary:hover { background: #b23a5d; }
.btn--primary:disabled, .btn--primary[aria-disabled='true'] { background: #e9b5c2; cursor: not-allowed; }
.btn--ghost { background: #fff; color: var(--a-navy); border-color: var(--a-border); }
.auth-card a.btn--primary { color: #fff; }
.btn--link { background: none; color: var(--a-violet); inline-size: auto; margin-inline: auto; min-block-size: 44px; text-decoration: underline; }
.btn--link:disabled { color: var(--a-muted); text-decoration: none; cursor: default; }
.resend { margin-block-start: var(--space-1); }
.or { display: flex; align-items: center; gap: var(--space-1); margin: var(--space-2) 0; color: var(--a-muted); font-size: var(--fs-sm); }
.or::before, .or::after { content: ''; flex: 1; border-block-start: 1px solid var(--a-border); }
.social { display: grid; gap: var(--space-1); }
.social__icon { inline-size: 20px; block-size: 20px; flex: none; }
.btn--social { gap: 10px; }
.switch { margin: var(--space-3) 0 0; text-align: center; font-weight: 600; font-size: 0.9rem; }

.countries { border: 0; padding: 0; margin: 0 0 var(--space-2); display: grid; gap: var(--space-1); }
.country { display: flex; gap: 12px; align-items: center; min-block-size: 52px; padding: 0 var(--space-2); border: 1px solid var(--a-border); border-radius: var(--radius-control); cursor: pointer; }
.country:has(input:checked) { border-color: #ca486c; background: #fdf3f6; }
.country input { accent-color: #ca486c; inline-size: 20px; block-size: 20px; }
.country__name { flex: 1 1 auto; }
.country[hidden] { display: none; }
.countries { max-block-size: min(60vh, 520px); overflow-y: auto; padding: 2px; }
.country-search[hidden], .country-empty[hidden] { display: none; }
.country-empty { margin: 0 0 var(--space-2); color: var(--a-muted); text-align: center; }
.terms-list { padding-inline-start: 1.2rem; margin: 0 0 var(--space-3); color: var(--a-navy); }
.terms-list li { margin-block-end: var(--space-1); }
body.auth-page :focus-visible { outline: 3px solid var(--a-violet); outline-offset: 2px; }

/* Terms box: each dashboard policy is a link that opens in a modal (partials/terms). */
.terms-policy { color: var(--a-violet); font-weight: 600; text-decoration: none; }
.terms-policy:hover, .terms-policy:focus-visible { text-decoration: underline; }
.policy-modal {
  inline-size: min(720px, calc(100vw - 24px)); block-size: min(86vh, 900px); max-block-size: none; max-inline-size: none;
  padding: 0; border: 0; border-radius: 20px; background: #fff; color: var(--a-navy);
  box-shadow: 0 24px 64px rgba(16, 35, 68, 0.25);
}
.policy-modal[open] { display: flex; flex-direction: column; }
.policy-modal::backdrop { background: rgba(16, 35, 68, 0.55); }
.policy-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-block-end: 1px solid var(--a-border); }
.policy-modal__title { margin: 0; font-size: 1.05rem; }
.policy-modal__x { display: inline-flex; align-items: center; justify-content: center; inline-size: 44px; block-size: 44px; border: 0; border-radius: 50%; background: #f2f3f8; color: var(--a-navy); cursor: pointer; }
.policy-modal__x:hover { background: #e6e8f1; }
.policy-modal__frame { flex: 1; inline-size: 100%; border: 0; background: #fff; }
.policy-modal__foot { padding: 12px 18px; border-block-start: 1px solid var(--a-border); }
@media (max-width: 600px) {
  .policy-modal { inline-size: 100vw; block-size: 100dvh; max-block-size: 100dvh; border-radius: 0; }
}

/* ---------- Large screens: form on one half, animated brand panel on the other ---------- */
@media (min-width: 1024px) {
  body.auth-page { flex-direction: row; align-items: stretch; }
  .auth-pane { flex: 1 1 50%; }
  .auth-top { max-inline-size: 520px; }
  .auth-top { display: none; } /* the panel shows the logo; the language switch is in the card */
  .auth-main { padding-block-start: var(--space-4); }
  .auth-main { justify-content: center; padding-block: var(--space-1) var(--space-3); }
  .auth-card { max-inline-size: 460px; padding: var(--space-3) 36px; box-shadow: 0 14px 40px rgb(25 31 106 / 8%); }
  .auth-card__title { font-size: 1.7rem; }
  .auth-card__lead { margin-block-end: var(--space-2); font-size: 0.95rem; }
  .field { margin-block-end: 14px; }
  .input, .phone__country, .btn { min-block-size: 46px; }
  .field > label, .field > legend { font-size: 0.85rem; }

  .auth-brand {
    flex: 1 1 50%; position: sticky; inset-block-start: 0; block-size: 100vh; block-size: 100dvh; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: var(--space-2);
    padding: var(--space-3) var(--space-4); text-align: center; color: #fff; isolation: isolate;
    /* The dragon is sized by the screen height too, so the spinning ring (which reaches above it) is never clipped
       on a normal laptop screen at 100% zoom. */
    --mark: clamp(120px, min(18vw, 26vh), 250px);
    background: radial-gradient(120% 90% at 50% 40%, #1e0f4a 0%, #0b0a35 55%, #060020 100%);
  }
  .auth-brand__title { margin: clamp(8px, 3vh, var(--space-3)) 0 0; max-inline-size: 22ch; font-size: clamp(1.5rem, 2.2vw, 2rem); font-weight: 600; line-height: 1.35; }
  .auth-brand__text { margin: 0; max-inline-size: 36ch; color: #c5cbe6; }

  /* Slow, blurred colour fields taken from the logo: violet, cyan, pink, amber. */
  .auth-brand__aurora { position: absolute; inset: 0; z-index: -1; filter: blur(70px); opacity: 0.55; }
  .auth-brand__aurora span { position: absolute; border-radius: 50%; animation: aurora 18s ease-in-out infinite alternate; }
  .auth-brand__aurora span:nth-child(1) { inline-size: 46%; aspect-ratio: 1; inset-block-start: 8%; inset-inline-start: 6%; background: #5737d9; }
  .auth-brand__aurora span:nth-child(2) { inline-size: 40%; aspect-ratio: 1; inset-block-end: 6%; inset-inline-end: 4%; background: #05acfd; animation-duration: 22s; animation-delay: -6s; }
  .auth-brand__aurora span:nth-child(3) { inline-size: 30%; aspect-ratio: 1; inset-block-end: 22%; inset-inline-start: 14%; background: #ee2682; opacity: 0.7; animation-duration: 26s; animation-delay: -12s; }
  .auth-brand__aurora span:nth-child(4) { inline-size: 16%; aspect-ratio: 1; inset-block-start: 20%; inset-inline-end: 18%; background: #fcbb48; opacity: 0.45; animation-duration: 20s; animation-delay: -3s; }

  .brand-anim { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-decoration: none; border-radius: 24px;
    margin-block-start: calc(var(--mark) * 0.32); }   /* room for the part of the ring above the dragon */
  .brand-anim__mark { position: relative; inline-size: var(--mark); block-size: auto; overflow: visible; animation: float 6s ease-in-out 1.6s infinite; }
  .brand-anim__word { inline-size: clamp(90px, min(12vw, 17vh), 170px); block-size: auto; overflow: visible; }
  .brand-anim__halo, .brand-anim__ring { position: absolute; inset-block-start: 50%; inset-inline-start: 50%; translate: -50% -62%; border-radius: 50%; pointer-events: none; }
  [dir='rtl'] .brand-anim__halo, [dir='rtl'] .brand-anim__ring { translate: 50% -62%; }
  /* A light halo so the dark indigo parts of the dragon stay visible on the dark panel. */
  .brand-anim__halo { inline-size: 130%; aspect-ratio: 1; background: radial-gradient(circle, rgb(150 190 255 / 38%) 0%, rgb(87 55 217 / 18%) 40%, transparent 68%); animation: halo 5s ease-in-out infinite; }
  .brand-anim__ring {
    inline-size: 150%; aspect-ratio: 1; padding: 2px;
    background: conic-gradient(from 0deg, transparent 0 55%, #19dbf7 70%, #ee2682 85%, #fcbb48 95%, transparent);
    -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    opacity: 0.8; animation: spin 9s linear infinite;
  }

  /* Entrance: the dragon's pieces gather in, then the word rises letter by letter. */
  .brand-anim__mark path { transform-box: fill-box; transform-origin: center; animation: piece-in 0.7s cubic-bezier(.2,.8,.2,1) both; }
  .brand-anim__mark path:nth-child(6n+1) { animation-delay: 0.05s; }
  .brand-anim__mark path:nth-child(6n+2) { animation-delay: 0.2s; }
  .brand-anim__mark path:nth-child(6n+3) { animation-delay: 0.35s; }
  .brand-anim__mark path:nth-child(6n+4) { animation-delay: 0.5s; }
  .brand-anim__mark path:nth-child(6n+5) { animation-delay: 0.65s; }
  .brand-anim__mark path:nth-child(6n)   { animation-delay: 0.8s; }
  .brand-anim__word path { animation: letter-in 0.6s cubic-bezier(.2,.8,.2,1) both; }
  .brand-anim__word path:nth-child(1) { animation-delay: 1.0s; }
  .brand-anim__word path:nth-child(2) { animation-delay: 1.12s; }
  .brand-anim__word path:nth-child(3) { animation-delay: 1.24s; }
  .brand-anim__word path:nth-child(4) { animation-delay: 1.36s; }
  .auth-brand__title, .auth-brand__text { animation: letter-in 0.8s ease-out 1.4s both; }
  .auth-brand__text { animation-delay: 1.6s; }
  .brand-anim:focus-visible { outline: 3px solid #19dbf7; outline-offset: 8px; }
}

@keyframes piece-in { from { opacity: 0; transform: scale(0.4) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes letter-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes halo { 0%, 100% { opacity: 0.75; scale: 1; } 50% { opacity: 1; scale: 1.08; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes aurora { 0% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8%, -6%) scale(1.15); } 100% { transform: translate(-6%, 8%) scale(0.95); } }

@media (prefers-reduced-motion: reduce) {
  .auth-brand *, .auth-brand *::before, .auth-brand *::after { animation: none !important; }
}

/* In-page country dropdown next to the phone field (partials/phone + auth.js). */
.phone { position: relative; }
.phone__caret { flex: none; color: var(--a-muted); transition: rotate 0.15s; }
.phone__country[aria-expanded='true'] { border-color: var(--a-violet); }
.phone__country[aria-expanded='true'] .phone__caret { rotate: 180deg; }
.cpick {
  position: absolute; z-index: 20; inset-inline: 0; inset-block-start: calc(100% + 6px);
  padding: 10px; background: #fff; border: 1px solid var(--a-border); border-radius: 16px;
  box-shadow: 0 18px 44px rgb(25 31 106 / 18%); animation: cpick-in 0.14s ease-out;
}
.cpick[hidden] { display: none; }
.cpick__search { min-block-size: 44px; margin-block-end: 8px; }
.cpick__list { position: relative; list-style: none; margin: 0; padding: 0; max-block-size: min(46vh, 320px); overflow-y: auto; overscroll-behavior: contain; scroll-padding-block: 8px; }
.cpick__opt { display: flex; align-items: center; gap: 12px; min-block-size: 44px; padding: 0 12px; border-radius: 10px; cursor: pointer; color: var(--a-navy); }
.cpick__opt[hidden] { display: none; }
.cpick__name { flex: 1 1 auto; }
.cpick__dial { color: var(--a-muted); font-size: 0.9rem; }
.cpick__opt:hover, .cpick__opt.is-active { background: #f2f0fb; }
.cpick__opt[aria-selected='true'] { background: #fdf3f6; font-weight: 600; }
.cpick__opt[aria-selected='true'] .cpick__dial { color: #b8235f; }
.cpick__empty { margin: 8px 0 4px; text-align: center; color: var(--a-muted); font-size: 0.9rem; }
.cpick__empty[hidden] { display: none; }
@keyframes cpick-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cpick { animation: none; } }
