/* ==========================================================================
   EB Renewal Dashboard — sign-in page
   Composition: tagline upper-left, login card upper-right, illustration
   lower-left. Tokens and primitives come from app.css.
   ========================================================================== */

.auth-body {
  min-height: 100vh;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", Arial, sans-serif;
  /* Blush, from the brand red, rather than the app's near-white: the white input
     tiles need something to stand out against. The colour on top of it comes
     from .auth-iris below. */
  background: #fbf4f2;

  /* The one tile shadow: a tight contact line and a wide, faint lift. It is
     what separates a white tile from the card now that nothing has a border. */
  --tile-shadow: 0 1px 2px rgba(43, 22, 24, .08), 0 6px 18px rgba(43, 22, 24, .07);

  /* One height for the email input, the code tiles and the button, so the two
     steps read as one form and the title holds still when they swap. */
  --tile-h: 56px;
}

/* Full-bleed. The page itself is the surface — there is no framed panel
   floating on a backdrop, so nothing here draws a border, a radius or a
   shadow. */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;   /* mobile browser chrome; ignored where unsupported */
  display: block;
}

/* ==========================================================================
   Iridescent backdrop
   ==========================================================================
   A mother-of-pearl sheen across the whole page, built from the brand: rose from
   the red and peach from the lion's orange do most of the work, and small hints
   of champagne, lilac and pale blue are what make it read as iridescent rather
   than simply pink.

   Two layers drift against each other at different speeds, so the colour itself
   shifts the way a pearl does when it tilts. Both are oversized so their edges
   never show, and moving an already-painted layer costs the compositor nothing
   per frame. Fixed, so a stacked phone layout scrolls over it rather than
   carrying it away. Stops at the static first frame under the reduced-motion
   block in app.css. */

.auth-iris {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-iris::before,
.auth-iris::after {
  content: "";
  position: absolute;
  inset: -30%;
  will-change: transform;
}

.auth-iris::before {
  background:
    radial-gradient(38% 42% at 24% 28%, rgba(248, 198, 204, .48), transparent 72%),
    radial-gradient(36% 40% at 74% 24%, rgba(253, 214, 186, .52), transparent 72%),
    radial-gradient(40% 44% at 70% 74%, rgba(247, 202, 212, .44), transparent 72%),
    radial-gradient(34% 38% at 28% 76%, rgba(253, 220, 194, .52), transparent 72%);
  animation: iris-drift-a 32s ease-in-out infinite alternate;
}

.auth-iris::after {
  background:
    /* Wide and faint on purpose: at any real strength the blue turns the peach
       under it a muddy grey, and the lilac reads as a blob. */
    radial-gradient(32% 36% at 58% 38%, rgba(232, 218, 242, .36), transparent 72%),
    radial-gradient(30% 34% at 38% 62%, rgba(220, 232, 246, .26), transparent 72%),
    radial-gradient(28% 30% at 72% 58%, rgba(251, 236, 196, .44), transparent 72%);
  animation: iris-drift-b 23s ease-in-out infinite alternate;
}

@keyframes iris-drift-a {
  to { transform: translate(5%, -4%) rotate(8deg) scale(1.06); }
}

@keyframes iris-drift-b {
  to { transform: translate(-7%, 6%) rotate(-10deg) scale(1.1); }
}

.auth-stage {
  position: relative;
  z-index: 1;           /* above the fixed backdrop */
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* The illustration is anchored to the viewport's lower-left and bleeds off
     both edges; this is what clips it rather than growing the page. */
  overflow: hidden;

  /* Not a container — a guard. Below this the layout is genuinely edge to
     edge; past it, pinning the card to the far right of a 2560px display
     would put half a metre between the tagline and the field you type in. */
  max-width: none;
}

.auth-row {
  display: flex;
  /* Both halves are content-sized and sit together as one compact unit,
     which is itself centred in the viewport — not a fixed-width grid inside
     a wide capped container, which is what stranded the card near the
     tagline with a dead gap filling the rest of the row. The card is
     vertically centred against the left column's full height (tagline
     through the illustration), not pinned to the tagline's top line. */
  justify-content: center;
  align-items: center;
  gap: clamp(64px, 10vw, 160px);
  flex-wrap: wrap;
  padding: clamp(40px, 7vh, 88px) clamp(24px, 6vw, 64px);
}

.auth-intro { flex: 0 1 620px; }
.auth-panel { flex: 0 0 auto; }

/* ==========================================================================
   Left — tagline
   ========================================================================== */

.auth-intro {
  /* No ch-based cap here. A `ch` on this element resolves against the 15px
     body size, which crushed the 46px headline inside it to a third of the
     column and wrapped three authored lines into six. The grid column is
     already the bound; the two children set their own measure below. */
  max-width: 720px;
}

.auth-logo {
  /* The supplied mark has generous transparent padding. Size the full image
     so the visible ribbon and wordmark read at the same scale as the headline. */
  height: clamp(76px, 5.4vw, 86px);
  width: auto;
  margin-bottom: clamp(12px, 2vh, 22px);
  transform: translateX(-8%);
}

.auth-tagline {
  font-size: clamp(40px, 3.4vw, 58px);
  font-weight: 700;
  /* Tight, because the line breaks are authored — three deliberate lines,
     not a paragraph that happens to wrap. Nothing constrains the width: the
     <br>s decide where lines end, and the column decides the ceiling. */
  line-height: 1.12;
  letter-spacing: -.035em;
  color: var(--ink);
  text-wrap: balance;   /* progressive: tidies the wrap if one ever happens */
}

.auth-subtagline {
  margin-top: 24px;
  /* Measured against this element's own size, which is body-scale, so ch is
     the right unit here even though it was the wrong one on the parent. */
  max-width: 43ch;
  font-size: clamp(16px, 1.25vw, 19px);
  line-height: 1.55;
  /* ink-2 rather than ink-3: the lighter step falls short of readable contrast
     on the sheen. */
  color: var(--ink-2);
}

/* ==========================================================================
   Right — the login card
   ========================================================================== */

/* Named for what it holds; it draws nothing. The form sits directly on the page,
   and the white tiles are the only surfaces in this column. */
.login-card {
  width: clamp(320px, 26vw, 380px);
}

.login-title {
  font-size: clamp(25px, 2vw, 30px);
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
  text-align: center;
}

.login-lede {
  margin: 8px 0 26px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  text-align: center;
}

.login-card .field { margin-bottom: 14px; }

/* The input is a tile, the same object as the code boxes in the next step. */
.login-card .input {
  min-height: var(--tile-h);
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--tile-shadow);
  font-size: 16px;
  color: var(--ink);
  caret-color: var(--ink);
  transition: box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.login-card .input::placeholder { color: #a08a8c; }

.login-card .input:focus {
  outline: none;
  box-shadow: 0 0 0 1.5px var(--ink), var(--tile-shadow);
}

/* Chrome paints a saved address pale blue, which would make this the one tile on
   the page that is not white. It ignores background on an autofilled field, so
   the white is an inset shadow; the focus and error states each repeat it. */
.login-card .input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  box-shadow: inset 0 0 0 100px #fff, var(--tile-shadow);
}

.login-card .input:-webkit-autofill:focus {
  box-shadow: inset 0 0 0 100px #fff, 0 0 0 1.5px var(--ink), var(--tile-shadow);
}

.login-card .field.has-error .input:-webkit-autofill {
  box-shadow: inset 0 0 0 100px #fdeeee, 0 0 0 1.5px var(--error-600);
}

.login-card .input:disabled {
  background: #f1eeeb;
  box-shadow: none;
  -webkit-text-fill-color: currentColor;
  opacity: 1;
}

.login-card .field.has-error .input {
  background: #fdeeee;
  box-shadow: 0 0 0 1.5px var(--error-600);
}

/* One step darker than their shared colours, for the same reason as the
   subtagline: small red text has to hold up on the pinkest part of the sheen. */
.login-card .field-error { margin-top: 10px; text-align: center; color: var(--brand-700); }
.login-card .link-btn { color: var(--brand-700); }
.login-card .link-btn:hover { color: var(--brand-800); }

.login-existing-code {
  margin: 8px 0 0;
  text-align: center;
}

.login-card .login-existing-code .link-btn {
  min-height: 44px;
  padding: 12px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.login-card .login-existing-code .link-btn:hover {
  background: rgba(255, 255, 255, .52);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-card .btn { min-height: var(--tile-h); font-size: 16px; border-radius: 12px; }
/* .btn sets a display of its own, which would otherwise beat [hidden]. */
.login-card .btn[hidden] { display: none; }

.login-email {
  color: var(--ink);
  font-weight: 600;
  /* A long address must not push the card wider than its column. */
  overflow-wrap: anywhere;
}

/* Sits in the sentence, so it needs its own padding for a usable target; the
   negative margin keeps that padding out of the line's spacing. */
.login-card .login-change {
  margin: -6px -6px -6px 0;
  padding: 6px;
  font-size: inherit;
}

/* Why the previous session ended. */
.login-notice {
  margin: 0 0 22px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(250, 227, 228, .7);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--brand-800);
  text-align: center;
}

/* Development-only: SMTP is unconfigured and the code went to a file.
   Amber rather than brand red — nothing has failed, the reader just needs to
   look somewhere other than their inbox. */
.login-devnotice {
  margin: -12px 0 20px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--warn-100);
  font-size: 12px;
  line-height: 1.5;
  color: var(--warn-600);
  text-align: left;
  overflow-wrap: anywhere;
}

.login-devnotice[hidden] { display: none; }

/* Ops testing relaxation is on (OPS_LOGIN_ANY_EMAIL). Amber like the dev
   notice: not an error, but nobody should mistake this install for live. */
.login-notice.login-testmode {
  background: var(--warn-100);
  color: var(--warn-600);
}

/* --- step transition -----------------------------------------------------
   The two steps cross-fade with a few pixels of travel. auth.js toggles
   [hidden] for the semantics and .is-leaving/.is-entering for the motion. */

.login-step { animation: step-in var(--dur) var(--ease) both; }

@keyframes step-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.login-step[hidden] { display: none; }

/* ==========================================================================
   OTP tiles
   ==========================================================================
   The row has four states and each one looks different, because the row itself
   is the feedback now that there is no button:

     idle      white tiles, the focused one ringed in ink
     checking  flat grey with dimmed digits, pulsing gently
     wrong     red-tinted and shaking, then cleared for another try
     verified  the row collapses to its centre and a check mark draws itself

   auth.js holds the checking and verified states on #stepOtp as data-state,
   and wrong on the group as .has-error. */

.otp-stage { position: relative; }

.otp-group {
  display: flex;
  gap: 8px;
}

.otp-box {
  flex: 1 1 0;
  /* Both zeros matter. Without width an input still reports its default 150-odd
     pixels when the form is sized to its content, and six of those push a phone
     layout far past the edge of the screen. */
  width: 0;
  min-width: 0;
  height: var(--tile-h);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--tile-shadow);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  caret-color: var(--ink);
  text-align: center;
  /* Tabular figures so a 1 and an 8 occupy the same width and the row does
     not shimmer as it fills. */
  font-variant-numeric: tabular-nums;
  transition: box-shadow var(--dur) var(--ease),
              background-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}

/* The gap in the middle of the row: 482 913 is easier to hold in your head
   between two windows than 482913. */
.otp-box--split { margin-left: 8px; }

/* Thin and dark: it has to read as "here" on a white tile without the red that
   this row now keeps for a refused code. */
.otp-box:focus {
  outline: none;
  box-shadow: 0 0 0 1.5px var(--ink), var(--tile-shadow);
}

/* auth.js selects a box's digit on focus so typing replaces it. That is
   behaviour, not something to show: a highlight on the last digit would sit
   there all through the checking state. */
.otp-box::selection { background: transparent; color: inherit; }

/* Keep digits legible while the boxes are disabled during a request. */
.otp-box:disabled {
  opacity: 1;
  -webkit-text-fill-color: currentColor;
  cursor: default;
}

/* A digit rises into its tile. An input's text cannot be transformed on its
   own, so the rise is padding, which pushes vertically centred text down. --i
   staggers a pasted or autofilled code into a ripple across the row. */
.otp-box.is-typed {
  animation: otp-digit-in .22s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);   /* RIPPLE_STEP_MS in auth.js */
}

@keyframes otp-digit-in {
  from { padding-top: 20px; color: transparent; }
}

/* --- checking --- */

[data-state="checking"] .otp-box {
  background: #e9e6e3;
  box-shadow: none;
  color: var(--ink-3);
  animation: otp-pulse 1.1s ease-in-out infinite;
}

/* The row stays in place and breathes; a spinner would add a second object
   for the eye to go to. */
@keyframes otp-pulse {
  50% { opacity: .62; }
}

/* --- wrong --- */

.otp-group.has-error .otp-box {
  background: #fbe4e5;
  box-shadow: 0 0 0 1.5px var(--error-600);
  color: var(--brand-800);
}

/* Four pixels each way, once. Enough to register as a refusal, not enough to
   look like a toy. */
.otp-group.is-shaking { animation: shake .3s var(--ease); }

@keyframes shake {
  0%, 100%   { transform: translateX(0); }
  25%        { transform: translateX(-4px); }
  50%        { transform: translateX(4px); }
  75%        { transform: translateX(-2px); }
}

/* --- verified --- */

/* --d is the box's distance from the middle of the row, set by auth.js, so
   every tile travels to the centre and the check mark grows out of the row.
   A keyframe rather than a transition: this state follows the checking pulse,
   which animates opacity, and Chrome drops a transition on a property whose
   animation ends in the same style change, so the tiles blinked out at once. */
[data-state="verified"] .otp-box {
  animation: otp-collapse .32s var(--ease) both;
}

@keyframes otp-collapse {
  to {
    opacity: 0;
    transform: translateX(calc(var(--d, 0) * -100%)) scale(.7);
  }
}

.otp-check {
  position: absolute;
  inset: 0;
  width: 54px;
  height: 40px;
  margin: auto;
  overflow: visible;
  pointer-events: none;
}

/* pathLength="1" in the markup, so these are fractions of the stroke. */
.otp-check path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

[data-state="verified"] .otp-check path {
  stroke-dashoffset: 0;
  /* Starts as the tiles finish arriving at the centre. */
  transition: stroke-dashoffset .38s cubic-bezier(.65, 0, .35, 1) .2s;
}

/* --- what the row is doing, in words --- */

/* The reserved height stops the card jumping when a one-line message arrives. */
.otp-feedback {
  min-height: 20px;
  margin-top: 14px;
  text-align: center;
}

.otp-status {
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-2);
}

.login-card .otp-feedback .field-error { margin-top: 0; line-height: 20px; }

.otp-retry { margin-top: 12px; }

/* --- resend --- */

/* The margin makes this step exactly as tall as the email step at any tile
   height, so the title holds still when they swap. Below the row: a 14px gap and
   a 20px line, then this margin and a 20px line. Below the input: a 14px gap and
   one more tile. So this margin is one tile less 40px. */
.login-resend {
  margin-top: calc(var(--tile-h) - 40px);
  min-height: 20px;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-2);
  text-align: center;
  transition: opacity var(--dur) var(--ease);
}

/* Nothing is left to do once the code is in; visibility rather than display so
   the form does not shift under the check mark. */
[data-state="verified"] .login-resend {
  visibility: hidden;
  opacity: 0;
}

[data-state="checking"] .login-resend { opacity: .4; }

.resend-timer {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

/* ==========================================================================
   The illustration
   ==========================================================================
   Large, directly under the tagline — left edge aligned with the headline
   text, not drifted toward the card's gap. Non-interactive and out of the
   accessibility tree — it carries no information. */

.auth-scene {
  position: relative;
  left: 0;
  width: clamp(560px, 44vw, 720px);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* The card and the copy sit above it at every width. */
.auth-intro,
.auth-panel { position: relative; z-index: 1; }

.scene-halo  { fill: var(--brand-050); }

.lion-mane   { fill: var(--brand-600); }
.lion-ear    { fill: var(--brand-700); }
.lion-ear-inner,
.lion-muzzle { fill: var(--sun-100); }
.lion-face   { fill: var(--sun-300); }
.lion-nose   { fill: var(--brand-700); }
.lion-cheek  { fill: var(--brand-200); opacity: .75; }

.lion-line {
  fill: none;
  stroke: var(--brand-900);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Reading glasses — a professional touch, not a costume: thin frames, no
   lens tint, so the contented eyes still read through them. */
.lion-glasses {
  stroke: var(--brand-900);
  stroke-width: 2.4;
}

/* The calendar and shield glyphs replace the old plain sparkles — small
   enough to read as ambient decoration, specific enough to say "renewal"
   and "coverage" rather than nothing at all. */
.glyph-calendar,
.glyph-shield {
  fill: var(--surface);
  stroke: var(--brand-400);
  stroke-width: 1.6;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(74, 5, 9, .08));
}

.glyph-calendar .glyph-check,
.glyph-shield .glyph-check {
  stroke: var(--brand-500);
}

/* A soft shadow gives the white cloud edge definition against the page's
   near-white background — no stroke, since a stroke on top of overlapping
   sub-shapes used to draw seam lines across the puffs. Each cloud is now a
   single path, so the shadow reads as one silhouette. */
.scene-cloud   { fill: #fff; }
.cloud-front   {
  fill: #ffffff;
  filter: drop-shadow(0 5px 8px rgba(74, 5, 9, .10));
}
.cloud-back    { fill: var(--brand-100); }

.spark   { fill: var(--sun-500); }
.spark-3 { fill: var(--brand-200); }
.spark-4 { fill: var(--sun-300); }

/* --- drift ---------------------------------------------------------------
   Slow, small, and out of phase, so the corner is alive without asking for
   attention. Suppressed wholesale by the reduced-motion block in app.css. */

.cloud-front { animation: drift 13s ease-in-out infinite; }
.cloud-back  { animation: drift 17s ease-in-out infinite reverse; }
.scene-lion  { animation: bob   9s ease-in-out infinite; }

@keyframes drift {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(9px); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.glyph-calendar { animation: bob-small 6.5s ease-in-out infinite; }
.glyph-shield   { animation: bob-small 7.5s ease-in-out infinite 1s; }
.spark-3 { animation: twinkle 6.5s ease-in-out infinite .6s; }
.spark-4 { animation: twinkle 5s   ease-in-out infinite 1.8s; }

@keyframes bob-small {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.9); }
  50%      { opacity: 1;   transform: scale(1); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Laptops — keep both halves side by side, tighten the gap and shrink the
   illustration before giving up the composition. */
@media (min-width: 901px) {
  /* Desktop is a viewport composition. Keeping the stage and row at the
     viewport height prevents the wrapped flex content from creating a page
     taller than the screen (the source of the laptop scrollbar). */
  .auth-body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .auth-shell,
  .auth-stage {
    height: 100%;
    min-height: 0;
  }

  .auth-row {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    flex-wrap: nowrap;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .auth-row {
    gap: clamp(20px, 4vw, 48px);
    padding-inline: clamp(20px, 4vw, 40px);
  }

  /* Let the copy take the remaining width instead of forcing the card onto
     a second flex line at common laptop/browser viewport sizes. */
  .auth-intro {
    flex: 1 1 0;
    min-width: 0;
    max-width: 520px;
  }

  .auth-panel {
    flex: 0 1 380px;
    min-width: 0;
  }

  .login-card { width: 100%; }
  .auth-scene { width: clamp(320px, 36vw, 420px); }
}

@media (max-width: 900px) {
  /* Below this the two halves no longer fit side by side at a readable
     size — stack them instead of squeezing further. */
  .auth-row   { flex-direction: column; align-items: center; gap: 32px; padding: 40px 24px 0; }
  .auth-intro { flex-basis: auto; padding-top: 0; max-width: 560px; }
  /* Full width, so the form below takes its width from the screen. Left to
     shrink-wrap, the panel would size to its content and the two steps would
     come out at different widths. */
  .auth-panel { width: 100%; padding-top: 0; }

  .auth-stage {
    /* Content decides the height now. Forcing 100dvh here would strand the
       artwork below the fold on a short phone and leave a gap on a tall one. */
    min-height: 0;
    overflow: visible;
  }

  .auth-intro   { text-align: center; }
  .auth-logo    { margin: 0 auto 20px; height: clamp(58px, 18vw, 70px); transform: none; }
  .auth-tagline { font-size: clamp(26px, 6.4vw, 34px); }

  .auth-subtagline { margin: 14px auto 0; }

  .auth-scene {
    width: min(360px, 78%);
    margin: 8px auto 0;
  }

  /* The form stays compact and centred rather than stretching to the screen. */
  .login-card { width: min(100%, 380px); margin-inline: auto; }
}

@media (max-width: 420px) {
  .auth-row    { padding: 30px 18px 0; }
  .auth-body   { --tile-h: 52px; }

  /* Six boxes with an 8px gap overflow a 320px screen. Tighten both and let
     the boxes shrink; the row still fits without the page scrolling sideways. */
  .otp-group   { gap: 6px; }
  .otp-box     { font-size: 20px; }
  .otp-box--split { margin-left: 4px; }

  .auth-scene  { width: min(260px, 80%); }
}

/* Short desktop viewports — reduce whitespace and artwork before the layout
   ever needs to scroll. This also covers laptops displayed at browser zoom. */
@media (max-height: 1000px) and (min-width: 901px) {
  .auth-row {
    padding-block: clamp(20px, 4vh, 40px);
  }

  .auth-logo {
    height: clamp(68px, 5vw, 76px);
    margin-bottom: clamp(10px, 1.8vh, 18px);
  }

  .auth-tagline { font-size: clamp(34px, 3.2vw, 52px); }

  .auth-subtagline {
    margin-top: 16px;
    font-size: clamp(15px, 1.1vw, 18px);
  }

  .auth-scene {
    width: clamp(320px, 34vw, 560px);
    margin-top: 8px;
  }

  .auth-body { --tile-h: 52px; }
}
