/* ─────────────────────────────────────────────────────────────────────────────
   Shams Al-Duha — sign-in page
   The photograph fills the screen; a sunlit glass card sits on its open,
   bright side. Glimpses of the platform drift over the scene with the pointer.
   ───────────────────────────────────────────────────────────────────────────── */

@property --auth-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@layer sections {
  .auth { min-height: 100svh; background: var(--bg); }

  /* ── Top bar ───────────────────────────────────────────────────────────── */
  .auth-top {
    position: fixed;
    z-index: 30;
    inset: var(--s-3) var(--gutter) auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    height: 4.25rem;
    padding-inline: var(--s-3);
    border-radius: var(--r-pill);
    background: rgb(255 255 255 / 0.5);
    border: 1px solid rgb(255 255 255 / 0.8);
    box-shadow: var(--shadow-inset), 0 12px 30px -20px rgb(120 32 20 / 0.3);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    margin-inline: auto;
    max-width: 1200px;
  }
  .auth-top .brand__logo { width: 2.75rem; height: 2.75rem; }
  .auth-top .brand__name { font-size: 1.3rem; }

  /* ── Stage ─────────────────────────────────────────────────────────────── */
  .auth-stage {
    position: relative;
    isolation: isolate;
    min-height: 100svh;
    display: grid;
    align-items: center;
  }
  /* Fixed, so a tall card never zooms the photograph. */
  .auth-stage__media { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
  .auth-stage__layer { position: absolute; inset: -16px; }
  .auth-stage__layer img { width: 100%; height: 100%; object-fit: cover; object-position: 28% 40%; }
  .auth-stage__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(closest-side at 76% 48%, rgb(255 251 246 / 0.66), rgb(255 251 246 / 0.2) 70%, transparent),
      linear-gradient(to left, rgb(255 251 246 / 0.5), rgb(255 251 246 / 0.25) 38%, transparent 58%);
  }

  .auth-stage__inner {
    display: grid;
    justify-items: start;
    align-content: center;
    gap: var(--s-5);
    min-height: 100svh;
    padding-block: calc(4.25rem + var(--s-12)) var(--s-8);
    padding-inline: clamp(var(--gutter), 7vw, 10rem) var(--gutter);
  }

  /* ── The card ──────────────────────────────────────────────────────────── */
  .auth-card {
    position: relative;
    width: min(100%, 30rem);
    display: grid;
    gap: var(--s-5);
    padding: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
    border-radius: var(--r-xl);
    background: linear-gradient(160deg, rgb(255 255 255 / 0.86), rgb(255 250 244 / 0.7));
    box-shadow:
      var(--shadow-inset),
      0 40px 90px -40px rgb(120 32 20 / 0.45),
      0 10px 24px -14px rgb(120 32 20 / 0.18);
    backdrop-filter: saturate(170%) blur(22px);
    -webkit-backdrop-filter: saturate(170%) blur(22px);
  }
  /* A slow red-and-gold light travelling around the edge. */
  .auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 1.5px;
    border-radius: inherit;
    background: conic-gradient(from var(--auth-angle), rgb(255 255 255 / 0.9), rgb(247 209 74 / 0.95) 12%, rgb(215 20 31 / 0.85) 22%, rgb(255 255 255 / 0.9) 34%, rgb(255 255 255 / 0.9) 60%, rgb(247 209 74 / 0.7) 78%, rgb(255 255 255 / 0.9));
    -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    animation: auth-orbit 9s linear infinite;
    pointer-events: none;
  }
  @keyframes auth-orbit { to { --auth-angle: 360deg; } }

  .auth-card__rays {
    position: absolute;
    top: -9rem;
    left: 50%;
    width: 24rem;
    aspect-ratio: 1;
    translate: -50% 0;
    z-index: -1;
    background: repeating-conic-gradient(from 0deg, rgb(247 209 74 / 0.28) 0deg 5deg, transparent 5deg 15deg);
    -webkit-mask: radial-gradient(closest-side, #000 18%, transparent 68%);
    mask: radial-gradient(closest-side, #000 18%, transparent 68%);
    animation: rays-spin 70s linear infinite;
    pointer-events: none;
  }
  /* Keep the rays inside the card's rounded shape. */
  .auth-card { overflow: hidden; }

  .auth-card__head { display: grid; justify-items: center; gap: var(--s-2); text-align: center; }
  .auth-card__seal {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: var(--s-1);
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 0 0 1px var(--red-border), 0 0 0 7px rgb(255 255 255 / 0.7), 0 0 0 8px var(--gold-border), var(--shadow-md);
  }
  .auth-card__seal img { width: 3.45rem; height: 3.45rem; border-radius: 50%; }
  .auth-card__head .eyebrow::after {
    content: "";
    width: 1.6rem;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--red), var(--gold));
  }
  .auth-card__title { font-size: clamp(1.9rem, 1.45rem + 1.4vw, 2.45rem); line-height: 1.25; }
  .auth-card__title .highlight::before { animation: highlight-draw 0.9s var(--ease-out) 0.7s both; }
  .auth-card__lead { color: var(--ink-2); font-size: var(--fs-small); line-height: 1.8; max-width: 26rem; }

  /* ── Form ──────────────────────────────────────────────────────────────── */
  .auth-form { display: grid; gap: var(--s-3); }

  /* Role switch: a pill glides to the chosen account type. */
  .role-switch {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-1);
    margin: 0;
    padding: 0.3rem;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: rgb(251 242 231 / 0.8);
    min-width: 0;
  }
  .role-switch__pill {
    position: absolute;
    top: 0.3rem;
    bottom: 0.3rem;
    left: 0;
    width: var(--role-w, 0);
    translate: var(--role-x, 0) 0;
    border-radius: var(--r-pill);
    background: var(--white);
    box-shadow: 0 0 0 1px var(--red-border), var(--shadow-sm);
    opacity: var(--role-o, 0);
    transition: translate var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out), opacity var(--dur-fast) linear;
  }
  .role-switch__pill.is-instant { transition: none; }
  .role-switch__option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 2.6rem;
    padding-inline: var(--s-2);
    border-radius: var(--r-pill);
    color: var(--ink-2);
    font-size: var(--fs-small);
    font-weight: 500;
    cursor: pointer;
    transition: color var(--dur-fast) linear;
    white-space: nowrap;
  }
  .role-switch__option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
  .role-switch__option svg { width: 1.1rem; height: 1.1rem; flex: none; transition: transform var(--dur-base) var(--ease-out); }
  .role-switch__option:hover { color: var(--ink); }
  .role-switch__option:has(input:checked) { color: var(--red-strong); }
  .role-switch__option:has(input:checked) svg { transform: scale(1.12); }
  .role-switch__option:has(input:focus-visible) { outline: 2px solid var(--red); outline-offset: 2px; }
  @media (max-width: 460px) {
    .role-switch__option { flex-direction: column; gap: 2px; min-height: 3.2rem; font-size: var(--fs-caption); }
    .role-switch { border-radius: var(--r-md); }
    .role-switch__pill { border-radius: 18px; }
  }

  /* Quick links to preview the three dashboards */
  .auth-demo { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-2); margin-top: var(--s-4); font-size: var(--fs-caption); color: var(--ink-2); }
  .auth-demo__label { width: 100%; text-align: center; }
  .auth-demo a { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.1rem; padding: 0 var(--s-3); border-radius: var(--r-pill); border: 1px solid var(--gold-border); background: var(--gold-soft); color: var(--gold-deep); font-weight: 600; transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) linear; }
  .auth-demo a:hover { transform: translateY(-2px); border-color: var(--red-border); color: var(--red-strong); }
  .auth-demo svg { width: 1rem; height: 1rem; }
  /* Without the pill (no JS), the chosen option carries the surface itself. */
  .role-switch:not(.has-pill) .role-switch__option:has(input:checked) { background: var(--white); box-shadow: 0 0 0 1px var(--red-border); }

  /* Floating-label fields */
  .field { position: relative; display: grid; }
  .field__input {
    width: 100%;
    min-height: 3.5rem;
    padding-block: 1.3rem 0.4rem;
    padding-inline: 3.1rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    background: rgb(255 255 255 / 0.82);
    color: var(--ink);
    font-size: var(--fs-body);
    line-height: 1.4;
    transition: border-color var(--dur-fast) linear, box-shadow var(--dur-base) var(--ease-out), background-color var(--dur-base) linear;
  }
  .field__input--password { padding-inline-end: 3.25rem; }
  .field__input::placeholder { color: transparent; }
  .field__input:hover { border-color: var(--red-border); }
  .field__input:focus-visible {
    outline: none;
    border-color: var(--red);
    background: var(--white);
    box-shadow: 0 0 0 4px rgb(215 20 31 / 0.1), 0 0 0 1px var(--red);
  }
  .field__icon {
    position: absolute;
    top: 1.75rem;
    inset-inline-start: 1rem;
    translate: 0 -50%;
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    color: var(--ink-2);
    pointer-events: none;
    transition: color var(--dur-fast) linear;
  }
  .field__icon svg { width: 100%; height: 100%; }
  .field:focus-within .field__icon { color: var(--red); }
  .field__label {
    position: absolute;
    top: 1.75rem;
    inset-inline-start: 3.1rem;
    translate: 0 -50%;
    color: var(--ink-2);
    font-size: var(--fs-body);
    pointer-events: none;
    transform-origin: right center;
    transition: top var(--dur-base) var(--ease-out), font-size var(--dur-base) var(--ease-out), color var(--dur-fast) linear;
    white-space: nowrap;
  }
  .field__input:focus-visible + .field__label,
  .field__input:not(:placeholder-shown) + .field__label {
    top: 0.95rem;
    font-size: var(--fs-caption);
    color: var(--red-strong);
  }
  .field__input:not(:focus-visible):not(:placeholder-shown) + .field__label { color: var(--ink-2); }

  .field__toggle {
    position: absolute;
    top: 1.75rem;
    inset-inline-end: 0.5rem;
    translate: 0 -50%;
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    color: var(--ink-2);
    transition: color var(--dur-fast) linear, background-color var(--dur-fast) linear;
  }
  .field__toggle:hover { color: var(--red-strong); background: var(--red-soft); }
  .field__toggle svg { width: 1.25rem; height: 1.25rem; grid-area: 1 / 1; }
  .field__toggle-hide, .field__toggle[aria-pressed="true"] .field__toggle-show { display: none; }
  .field__toggle[aria-pressed="true"] .field__toggle-hide { display: block; }

  .field__hint,
  .field__error {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-top: var(--s-2);
    padding-inline: var(--s-2);
    font-size: var(--fs-caption);
    line-height: 1.5;
  }
  .field__hint { color: var(--gold-deep); }
  .field__error { color: var(--red-strong); animation: error-in 0.4s var(--ease-out); }
  .field__error svg { width: 1rem; height: 1rem; flex: none; }
  .field.is-invalid .field__input { border-color: var(--red); background: var(--red-mist); }
  .field.is-invalid .field__icon { color: var(--red); }
  @keyframes error-in { from { opacity: 0; translate: 0 -4px; } }

  .auth-form__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2) var(--s-4);
    font-size: var(--fs-small);
  }

  /* Custom checkbox */
  .check { position: relative; display: inline-flex; align-items: center; gap: var(--s-2); color: var(--ink-2); cursor: pointer; }
  .check input { position: absolute; opacity: 0; width: 1.35rem; height: 1.35rem; margin: 0; cursor: pointer; }
  .check__box {
    display: grid;
    place-items: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 0.45rem;
    border: 1.5px solid var(--line-strong);
    background: var(--white);
    color: var(--white);
    transition: background-color var(--dur-fast) linear, border-color var(--dur-fast) linear, transform var(--dur-base) var(--ease-out);
  }
  .check__box svg { width: 0.85rem; height: 0.85rem; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset var(--dur-base) var(--ease-out); }
  .check input:checked + .check__box { background: var(--red-strong); border-color: var(--red-strong); }
  .check input:checked + .check__box svg { stroke-dashoffset: 0; }
  .check input:focus-visible + .check__box { outline: 2px solid var(--red); outline-offset: 2px; }
  .check:active .check__box { transform: scale(0.9); }

  /* Submit */
  .auth-form__submit {
    width: 100%;
    min-height: 3.35rem;
    margin-top: var(--s-1);
    font-size: 1.08rem;
  }
  .auth-form__submit-label { display: inline-flex; align-items: center; gap: var(--s-2); transition: opacity var(--dur-fast) linear; }
  .auth-form__spinner {
    position: absolute;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    border: 2.5px solid rgb(255 255 255 / 0.35);
    border-top-color: var(--white);
    opacity: 0;
    transition: opacity var(--dur-fast) linear;
  }
  .auth-form__submit.is-loading { pointer-events: none; }
  .auth-form__submit.is-loading .auth-form__submit-label { opacity: 0; }
  .auth-form__submit.is-loading .auth-form__spinner { opacity: 1; animation: spin 0.8s linear infinite; }
  @keyframes spin { to { rotate: 360deg; } }

  .auth-form__status {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-sm);
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    color: var(--ink);
    font-size: var(--fs-small);
    line-height: 1.7;
    animation: error-in 0.5s var(--ease-out);
  }
  .auth-form__status svg { width: 1.2rem; height: 1.2rem; flex: none; margin-top: 0.2rem; color: var(--gold-deep); }

  .auth-card.is-shaking { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
  @keyframes shake {
    10%, 90% { translate: -1px 0; }
    20%, 80% { translate: 3px 0; }
    30%, 50%, 70% { translate: -6px 0; }
    40%, 60% { translate: 6px 0; }
  }

  .auth-divider {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--ink-2);
    font-size: var(--fs-caption);
  }
  .auth-divider::before,
  .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to left, transparent, var(--line-strong));
  }
  .auth-divider::after { background: linear-gradient(to right, transparent, var(--line-strong)); }

  .auth-form__alt { width: 100%; min-height: 3rem; }
  .auth-form__wa { color: #1B9A4E; }

  .auth-card__trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    margin-top: calc(var(--s-2) * -1);
    color: var(--ink-2);
    font-size: var(--fs-caption);
  }
  .auth-card__trust svg { width: 1rem; height: 1rem; color: var(--gold-deep); }

  .auth-foot {
    width: min(100%, 30rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-1) var(--s-3);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-pill);
    background: rgb(255 255 255 / 0.72);
    border: 1px solid rgb(255 255 255 / 0.85);
    box-shadow: var(--shadow-sm);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    color: var(--ink-2);
    font-size: var(--fs-caption);
    text-align: center;
  }
  .auth-foot a { color: var(--red-strong); font-weight: 500; }
  .auth-foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

  /* ── Platform glimpses ─────────────────────────────────────────────────── */
  .auth-glimpse {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-5) var(--s-3) var(--s-3);
    border-radius: var(--r-lg);
    color: var(--ink);
    font-size: var(--fs-small);
    font-weight: 500;
    pointer-events: none;
    animation: enter-pop 1s var(--ease-out) backwards, float-bob 7s ease-in-out infinite;
  }
  .auth-glimpse--notice   { left: 37vw; top: 17vh; animation-delay: 0.6s, 1.6s; }
  .auth-glimpse--progress { left: 2.5vw; bottom: 9vh; animation-delay: 0.85s, 2.2s; }
  .auth-glimpse--present  { left: 20vw; top: 12vh; padding: var(--s-2) var(--s-4) var(--s-2) var(--s-2); border-radius: var(--r-pill); animation-delay: 1.1s, 0.8s; }

  .auth-glimpse__icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--r-sm);
    background: linear-gradient(160deg, var(--red), var(--red-deeper));
    color: var(--white);
    box-shadow: var(--shadow-red);
  }
  .auth-glimpse__icon svg { width: 1.3rem; height: 1.3rem; }
  .auth-glimpse__text { display: grid; line-height: 1.45; }
  .auth-glimpse__text strong { font-family: var(--font-display); font-size: 1.05rem; }
  .auth-glimpse__text span { color: var(--ink-2); font-size: var(--fs-caption); font-weight: 400; }
  .auth-glimpse__check {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #1FA855;
    color: var(--white);
  }
  .auth-glimpse__check svg { width: 1rem; height: 1rem; }

  .auth-ring { position: relative; display: grid; place-items: center; width: 3.25rem; height: 3.25rem; }
  .auth-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; rotate: -90deg; }
  .auth-ring circle { fill: none; stroke-width: 4.5; }
  .auth-ring__track { stroke: rgb(215 20 31 / 0.12); }
  .auth-ring__bar {
    stroke: var(--red);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: calc(100 - var(--value, 0));
    animation: ring-fill 1.6s var(--ease-out) 1s backwards;
  }
  @keyframes ring-fill { from { stroke-dashoffset: 100; } }
  .auth-ring .num { font-size: 0.75rem; font-weight: 600; color: var(--red-strong); }

  @keyframes float-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-7px); }
  }

  /* ── Responsive ────────────────────────────────────────────────────────── */
  @media (max-width: 1100px) {
    .auth-glimpse { display: none; }
    .auth-stage { align-items: start; }
    .auth-stage__media { position: relative; inset: auto; grid-row: 1; aspect-ratio: 16 / 9; max-height: 62svh; width: 100%; }
    .auth-stage { min-height: 0; }
    .auth-stage__layer { inset: 0; }
    .auth-stage__layer img { object-position: 22% 40%; }
    .auth-stage__media::after { background: linear-gradient(to bottom, rgb(255 251 246 / 0.3), transparent 30%, transparent 55%, var(--bg)); }
    .auth-stage__inner {
      grid-row: 2;
      min-height: 0;
      justify-items: center;
      margin-top: clamp(-9rem, -12vw, -3rem);
      padding-block: 0 var(--s-8);
      padding-inline: var(--gutter);
    }
  }
  @media (max-width: 560px) {
    .auth-top { height: 3.75rem; inset-inline: var(--s-3); }
    .auth-top .brand__logo { width: 2.4rem; height: 2.4rem; }
    .auth-top .brand__name { font-size: 1.15rem; }
    .auth-top__back { padding-inline: var(--s-3); }
    .auth-stage__media { aspect-ratio: 4 / 3; }
    .auth-stage__layer img { object-position: 18% 45%; }
    .auth-card { border-radius: var(--r-lg); }
    .role-switch__option { gap: var(--s-1); font-size: var(--fs-caption); }
    .role-switch__option svg { width: 1rem; height: 1rem; }
  }
  @media (max-width: 380px) {
    .auth-top__back { font-size: 0; gap: 0; width: 2.6rem; padding: 0; }
    .auth-top__back .btn__icon { width: 1.2rem; height: 1.2rem; }
  }
}

@layer motion {
  @media (prefers-reduced-motion: reduce) {
    .auth-card::before, .auth-card__rays, .auth-glimpse, .auth-ring__bar,
    .auth-card__title .highlight::before, .auth-card.is-shaking, .field__error, .auth-form__status { animation: none; }
    .role-switch__pill, .field__input, .field__label, .check__box, .check__box svg { transition-duration: 0.01ms; }
    .auth-form__submit.is-loading .auth-form__spinner { animation-duration: 2s; }
  }
}
