/* ══════════════════════════════════════════════════════════════════════════
 * auth.css — sign in, and the two screens either side of it.
 *
 * WHY THIS LOOKS NOTHING LIKE THE REST OF THE APP, ON PURPOSE.
 *
 * The owner's brief, verbatim: "TEMA JE MERAH GOLD JUST UNTUK PERKARA RASMI
 * DALAM APPS TU. BAHAGIAN LAIN MACAM BUTTON KE BACKGROUND KE APA KE BOLEH JE
 * LAIN-LAIN." Red and gold are the OFFICIAL register — the member card, the
 * points hero, the header bar, anything that stands in for the company. Sign in
 * is not that. It is the front door, it is seen once per device, and it is the
 * only screen in the app with no data on it, so it is the one place that can
 * carry atmosphere instead of information.
 *
 * The previous version was a white card with a hairline border on flat cream,
 * with the page title in a bar above it. That is a 2010 form layout. It read as
 * a settings dialog, not as the way into a membership.
 *
 * WHAT MAKES IT READ AS NOW, and none of it is decoration for its own sake:
 *   - a full-bleed AURORA background, three offset radial fields that overlap
 *     into colours none of them contain, rather than one flat fill
 *   - real GRAIN over the top. Large smooth gradients band badly on cheap
 *     phone panels; a fine noise layer breaks the banding up, and it is the
 *     single cheapest thing that stops a gradient looking like a 2012 CSS demo
 *   - a GLASS card, because there is now something behind it worth blurring
 *   - display-scale type, generous space, and one confident button
 *
 * COLOUR. Plum and indigo carry the field; the brand red is the accent that
 * ties it back — a warm bloom bottom-right and the submit button. Gold appears
 * once, as a hairline over the card. That is the licence used as given: the
 * official colours still sign the screen, they just no longer have to paint all
 * of it.
 *
 * PERFORMANCE. The aurora, the grain and the glass are static paints — no
 * compositor work after first paint, which matters because this is the screen a
 * member meets on a cold start with an empty cache. The ONE looping animation in
 * this file is the three waiting dots on wait.php, and it is a transform, so it
 * stays on the compositor and never touches layout.
 * ══════════════════════════════════════════════════════════════════════════ */

.m-shell.is-auth {
  /* Its own world: no 520px card shell, no tab bar padding, no page background
   * inherited from the app. */
  max-width: none;
  min-height: 100dvh;          /* dvh, not vh — vh is wrong under a mobile URL bar */
  padding: 0;
  background: none;
  /* ONE centring context, not two rows.
   *
   * This was `grid-template-rows: 1fr auto`, which centred the card inside row 1
   * and then put the footer in row 2 BELOW it — so the card was centred against
   * the space left over, not against the page. With the footer at 58px that read
   * as 46px high; before the .m-top fix in layout.php it was 140px LOW, which is
   * what the owner saw and reported. Centring against the viewport is what he
   * asked for, so the footer is taken out of the flow instead of competing with
   * the card for vertical space. */
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;          /* keeps the ::before/::after fields off the app */
  overflow: hidden;
}

/* ── The aurora ───────────────────────────────────────────────────────────
 * Three fields, deliberately larger than the viewport and centred outside it,
 * so a phone sees the INSIDE of each bloom rather than a visible circle edge. */
/* ── The moving aurora ────────────────────────────────────────────────────
 * The owner asked for this background to be alive — "background dia bergerak2",
 * pretty rather than a static image. He was explicit that the page is otherwise
 * "dah modern", so this is motion added to a finished design, not a redesign.
 *
 * TWO LAYERS, AND THE SPLIT IS THE WHOLE TRICK. The base wash now lives on the
 * shell itself; ::before carries ONLY the three blooms and is oversized by 30%
 * on every side. Animating a transform on an `inset: 0` layer drags its edges
 * inward and shows a hard line where the paint runs out — the oversize is what
 * gives the motion room to happen off-screen.
 *
 * TRANSFORM ONLY, and the resting state is the correct one. A past version of
 * this codebase shipped a splash that stayed invisible forever because its
 * entrance animation never fired, so nothing here may depend on an animation
 * running: with motion off this is exactly the static aurora it was before.
 *
 * The three fields sit on ONE layer, so one transform moves them together. That
 * still reads as alive rather than as a sliding sheet, because they are placed
 * asymmetrically (12%/-8%, 108%/8%, 78%/112%) — a slow rotation sweeps them
 * across the viewport at different rates and none of the three edges is ever
 * visible. Keyframing the radial-gradient colour stops instead was rejected:
 * most browsers cannot interpolate them and it repaints the whole layer.
 *
 * 48s, and deliberately slow enough to be noticed only if you look for it. A
 * sign-in screen that visibly churns reads as a loading state. */
.m-shell.is-auth {
  background: linear-gradient(168deg, #1A1130 0%, #140E24 48%, #0E0A19 100%);
}
.m-shell.is-auth::before {
  content: "";
  position: absolute;
  inset: -30%;
  z-index: -2;
  will-change: transform;
  background:
    radial-gradient(115% 85% at 12% -8%,  #4C1D5B 0%, transparent 62%),
    radial-gradient(95% 70% at 108% 8%,   #1E2A6B 0%, transparent 58%),
    radial-gradient(120% 90% at 78% 112%, #B3241C 0%, transparent 60%);
}
@media (prefers-reduced-motion: no-preference) {
  .m-shell.is-auth::before {
    animation: mAuroraDrift 48s cubic-bezier(.45,0,.55,1) infinite;
  }
}
/* Returns to its exact start, so the loop has no visible seam. Scale stays
 * above 1 throughout: dipping below it would pull the oversized layer back
 * toward the viewport edge and risk exposing the corner it exists to hide. */
@keyframes mAuroraDrift {
  0%   { transform: rotate(0deg)    translate3d(0, 0, 0)        scale(1.04) }
  25%  { transform: rotate(2.2deg)  translate3d(-2.5%, 1.5%, 0) scale(1.09) }
  50%  { transform: rotate(0.4deg)  translate3d(2%, -2%, 0)     scale(1.06) }
  75%  { transform: rotate(-1.8deg) translate3d(1.5%, 2.5%, 0)  scale(1.10) }
  100% { transform: rotate(0deg)    translate3d(0, 0, 0)        scale(1.04) }
}

/* ── The grain ────────────────────────────────────────────────────────────
 * feTurbulence in a data URI, so it costs one paint and zero requests, and it
 * still works with no network at all — which matters, because this is the
 * screen a member reaches before anything else has loaded. */
.m-shell.is-auth::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.m-auth {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 32px 20px 20px;
  max-width: 440px;
  margin-inline: auto;
  width: 100%;
}

.m-auth-brand { display: flex; align-items: center; gap: 11px; }

.m-auth-h {
  margin: 6px 0 0;
  font-family: var(--fd);
  /* Display scale, and it FITS: clamp keeps it off two lines on a 320px phone
   * without needing a media query. */
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.025em;
  color: #fff;
  text-wrap: balance;
}
.m-auth-sub {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: rgb(255 255 255 / .66);
  max-width: 34ch;
  text-wrap: pretty;
}

/* ── The glass card ───────────────────────────────────────────────────────
 * The translucent background is the FALLBACK and must stay readable on its
 * own: where backdrop-filter is unsupported the card still has to be a card,
 * not a faint smear over an aurora. */
.m-authcard {
  position: relative;
  margin-top: 6px;
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: rgb(255 255 255 / .10);
  border: 1px solid rgb(255 255 255 / .16);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .22),
    0 20px 44px -20px rgb(0 0 0 / .65);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .m-authcard {
    background: rgb(255 255 255 / .07);
    -webkit-backdrop-filter: saturate(150%) blur(22px);
    backdrop-filter: saturate(150%) blur(22px);
  }
}
/* The one gold moment on the screen: a hairline along the top edge, brightest
 * in the middle, which is what reads as light catching a real surface. */
.m-authcard::before {
  content: "";
  position: absolute;
  inset-inline: 22px;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--wood), transparent);
}

/* ── Fields ───────────────────────────────────────────────────────────────── */
.m-auth-label {
  display: block;
  margin: 12px 0 6px;
  font-family: var(--fd);
  font-size: 12px; font-weight: 600;
  color: rgb(255 255 255 / .70);
}
.m-auth-label:first-of-type { margin-top: 0; }

.m-auth-in {
  width: 100%;
  max-width: 100%;
  min-width: 0;                       /* a <select> will not shrink without it */
  padding: 13px 14px;
  /* 16px exactly: anything smaller and iOS Safari zooms the page on focus. */
  font-size: 16px;
  font-family: var(--fb);
  color: #fff;
  background: rgb(255 255 255 / .08);
  border: 1px solid rgb(255 255 255 / .18);
  border-radius: 14px;
  appearance: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.m-auth-in::placeholder { color: rgb(255 255 255 / .38); }
.m-auth-in:focus-visible {
  outline: none;
  border-color: rgb(255 255 255 / .42);
  background: rgb(255 255 255 / .12);
  box-shadow: 0 0 0 4px rgb(255 255 255 / .10);
}
.m-auth-in:disabled { opacity: .55; }
/* The native dropdown list is drawn by the OS in its own colours, so the
 * options must be legible there and not inherit this card's white-on-glass. */
.m-auth-in option { color: #14101F; background: #fff; }

.m-auth-sel { position: relative; }
.m-auth-sel::after {
  content: "";
  position: absolute;
  right: 15px; top: 50%;
  width: 8px; height: 8px;
  margin-top: -5px;
  border-right: 2px solid rgb(255 255 255 / .55);
  border-bottom: 2px solid rgb(255 255 255 / .55);
  transform: rotate(45deg);
  pointer-events: none;
}

/* ── Submit ───────────────────────────────────────────────────────────────
 * The brand red, but lit: a gradient plus a coloured glow, so it reads as the
 * one thing on the screen you are meant to press. */
.m-auth-btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px;
  border: 0;
  border-radius: 16px;
  color: #fff;
  cursor: pointer;
  font-family: var(--fd);
  font-size: 15px; font-weight: 600;
  letter-spacing: 0;
  background: linear-gradient(135deg, #D8433B 0%, #B3241C 55%, #8A1A14 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .26),
    0 10px 26px -8px rgb(179 36 28 / .75);
  transition: transform .13s ease, box-shadow .2s ease, opacity .2s ease;
}
.m-auth-btn:not(:disabled):active {
  transform: translateY(1px) scale(.99);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .26), 0 5px 14px -6px rgb(179 36 28 / .7);
}
.m-auth-btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

/* ── Error ────────────────────────────────────────────────────────────────
 * Still never colour alone: an icon and words carry it, exactly as in the app.
 * On this dark field the tint has to be light enough to read, so it is a warm
 * wash rather than the app's maroon-on-cream. */
.m-auth-err {
  display: flex; gap: 9px; align-items: flex-start;
  margin-top: 14px; padding: 12px 13px;
  font-size: 13px; line-height: 1.5;
  border-radius: 14px;
  color: #FFD9D5;
  background: rgb(179 36 28 / .22);
  border: 1px solid rgb(255 138 128 / .38);
}
.m-auth-err svg { flex: 0 0 auto; margin-top: 1px; }
.m-auth-err a { color: #fff; font-weight: 600; text-decoration: underline; }

/* ── Foot ─────────────────────────────────────────────────────────────────── */
/* Pinned to the bottom rather than sitting in a grid row, so it cannot take
 * vertical space away from the card above it — see the centring note on
 * .m-shell.is-auth. On a short screen the card wins the middle and this line is
 * the thing that overlaps, which is the right way round: it is a footnote. */
.m-auth-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 20px calc(18px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 11.5px;
  color: rgb(255 255 255 / .38);
  pointer-events: none;
}

/* ── Motion. Transform and opacity only, and none of it load-bearing ─────── */
@media (prefers-reduced-motion: no-preference) {
  .m-auth-brand { animation: mAuthUp .5s cubic-bezier(.2,.8,.2,1) both; }
  .m-auth-h     { animation: mAuthUp .5s cubic-bezier(.2,.8,.2,1) .06s both; }
  .m-auth-sub   { animation: mAuthUp .5s cubic-bezier(.2,.8,.2,1) .10s both; }
  .m-authcard   { animation: mAuthUp .55s cubic-bezier(.2,.8,.2,1) .14s both; }
}
/* Transform ONLY. An earlier version of this app animated opacity from 0 with
 * fill-mode:both and the content stayed invisible wherever the animation never
 * ran — on the sign-in screen that would be an app nobody can get into. */
@keyframes mAuthUp { from { transform: translateY(12px); } to { transform: none; } }

/* ── Wide screens ─────────────────────────────────────────────────────────
 * Opened on a desktop during development and by staff. The aurora fills the
 * window and the column stays a column — a 440px form stretched across 1400px
 * is the other way to look unfinished. */
@media (min-width: 640px) {
  .m-auth { padding-top: 8vh; }
}

/* ── Waiting on WhatsApp ──────────────────────────────────────────────────
 * The one loop on these screens, and it earns its place: wait.php is polling
 * for a tap that happens in another app, so the member needs to see that we are
 * still listening. Scale only — the compositor handles it, and nothing depends
 * on the animation having run. */
.m-auth-wait { display: flex; justify-content: center; gap: 8px; padding: 4px 0 14px; }
.m-auth-wait span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: rgb(255 255 255 / .55);
}
@media (prefers-reduced-motion: no-preference) {
  .m-auth-wait span { animation: mAuthPulse 1.3s ease-in-out infinite; }
  .m-auth-wait span:nth-child(2) { animation-delay: .18s; }
  .m-auth-wait span:nth-child(3) { animation-delay: .36s; }
}
@keyframes mAuthPulse {
  0%, 60%, 100% { transform: scale(.72); }
  30%           { transform: scale(1.12); }
}

/* ── The official V-mark ──────────────────────────────────────────────────
 * The source file is a solid-white square with the red circle inset a few
 * px — not transparent — so a plain height + width:auto would float that
 * white square edge on the aurora like a sticker. Forcing equal width/height
 * plus a 50% radius clips the square down to the circle itself; the glow
 * matches the buttons, which is what ties it to the screen. */
/* THE RING IS NOW EXPLICIT.
 *
 * The mark used to be img/logo-mark.png, the owner's logo on an opaque white
 * square, and border-radius:50% turned that square's corners into a white ring
 * around the disc. It looked right, but its width was whatever padding happened
 * to be in the artwork. The mark is now cropped to the disc and alpha-masked
 * (img/logo-v-*.png), so the ring is a 5px spread here instead: the same on
 * every screen, and it survives the artwork being recropped.
 *
 * The ring is not decoration on this screen. The background is a dark aurora
 * and the logo is a deep red disc; without a light edge the mark loses its
 * outline against it. */
.m-auth-logo {
  display: block;
  height: 72px;
  width: 72px;
  border-radius: 50%;
  box-shadow:
    0 0 0 5px #fff,
    inset 0 1px 0 rgb(255 255 255 / .25),
    0 8px 22px -6px rgb(255 65 54 / .55);
}

/* ══ THE 6-DIGIT CODE ══════════════════════════════════════════════════════
 *
 * Six boxes drawn as decorative spans with ONE real input lying transparent on
 * top. Not six inputs: that version is the obvious build and the cashier
 * project already abandoned it in login.php, because each box becomes its own
 * form control and autofill cannot fill across them. Here the cost would be
 * the one-time-code suggestion Android and iOS raise straight from the
 * WhatsApp notification, which is the single biggest convenience an OTP screen
 * can offer.
 *
 * COLOURS COME FROM THIS APP, not from the reference. login.php's version sits
 * on a white admin page and uses #f9fafb cells with a green filled state. This
 * screen is a dark aurora with a glass card over it, so the cells are
 * translucent white and the filled state is the brand red - green would be the
 * only green pixel in the app and would read as a different product.
 */
.m-code-label{display:block;margin:2px 0 8px;text-align:center;
              font-family:var(--fd);font-size:11px;font-weight:600;
              letter-spacing:.08em;text-transform:uppercase;
              color:rgba(255,255,255,.72)}

.m-code-wrap{position:relative;margin-bottom:14px}
.m-code-cells{display:flex;gap:7px;pointer-events:none}

.m-code-cell{flex:1;min-width:0;height:52px;border-radius:13px;
             display:flex;align-items:center;justify-content:center;
             font-family:var(--fd);font-size:21px;font-weight:700;
             font-variant-numeric:tabular-nums;
             color:#fff;
             background:rgba(255,255,255,.07);
             border:1.5px solid rgba(255,255,255,.20);
             box-shadow:inset 0 1px 0 rgba(255,255,255,.10);
             transition:border-color .16s ease, background .16s ease,
                        box-shadow .16s ease, transform .16s cubic-bezier(.32,.72,0,1)}

/* Filled: brand red, and a hair of lift. The member can see at a glance how
 * many digits have landed, which is the whole reason the owner asked for boxes
 * ("kurang human error"). */
.m-code-cell.is-filled{background:rgba(214,52,42,.26);
                       border-color:rgba(233,103,96,.72);
                       box-shadow:inset 0 1px 0 rgba(255,255,255,.16),
                                  0 2px 8px rgba(0,0,0,.22)}

/* Active: the box the next digit will go into. A ring rather than a colour
 * change, so it reads as a cursor and not as a seventh state. */
.m-code-cell.is-active{border-color:#fff;background:rgba(255,255,255,.14);
                       box-shadow:0 0 0 3.5px rgba(214,52,42,.34),
                                  inset 0 1px 0 rgba(255,255,255,.18);
                       transform:translateY(-1px)}

/* THE REAL INPUT, invisible and exactly over the cells.
 *
 * color and caret-color transparent, and text-indent off-screen: the value has
 * to be IN this field for autofill and for x-model, but every pixel of it is
 * drawn by the spans underneath. Without the indent, the browser's own
 * rendering of the digits shows through and doubles them.
 *
 * font-size:16px is not cosmetic - iOS Safari zooms the whole page in when a
 * focused input is under 16px, and on this screen that zoom cannot be undone
 * by the member. */
.m-code-wrap input{position:absolute;inset:0;width:100%;height:52px;
                   border:0;outline:none;background:transparent;
                   color:transparent;caret-color:transparent;
                   font-size:16px;text-indent:-9999px;
                   -webkit-tap-highlight-color:transparent}
.m-code-wrap input:disabled{cursor:not-allowed}

/* Chrome paints its own yellow over an autofilled field. It would sit as an
 * opaque block on top of the cells, so it is pushed off with an absurd
 * transition delay - the standard trick, because background-color cannot be
 * overridden on :-webkit-autofill directly. */
.m-code-wrap input:-webkit-autofill,
.m-code-wrap input:-webkit-autofill:hover,
.m-code-wrap input:-webkit-autofill:focus{
  -webkit-text-fill-color:transparent !important;
  transition:background-color 600000s 0s, color 600000s 0s}

/* Locked out: the cells go flat and grey so the disabled input is visibly
 * disabled. Without this the member keeps tapping a live-looking box. */
.m-code-wrap input:disabled ~ .m-code-cells .m-code-cell,
.m-code-wrap:has(input:disabled) .m-code-cell{opacity:.55}

/* The dots demoted. They mattered when a tap on another device was the only
 * way through; now they only say "a till could still verify you". */
.m-auth-wait.is-small{margin:2px 0 12px;transform:scale(.72);opacity:.7}

/* Send again, now secondary to Verify. */
.m-auth-link{display:flex;align-items:center;justify-content:center;
             width:100%;min-height:44px;margin-top:9px;padding:9px 0;
             background:none;border:0;cursor:pointer;
             font-family:var(--fd);font-size:12.5px;font-weight:600;
             color:rgba(255,255,255,.78);
             -webkit-tap-highlight-color:transparent}
.m-auth-link:disabled{opacity:.5;cursor:not-allowed}

@media (prefers-reduced-motion:reduce){
  .m-code-cell{transition:none}
  .m-code-cell.is-active{transform:none}
}
