/* The rendered auth pages (ADR-05): login, signup and the password-reset flow.

   Tokens are NOT here — they live in tokens.css, which registration/base.html loads first and
   which the landing page loads too. This file is only what the .auth-card screens themselves
   need. Anything below that is a value rather than a rule belongs there, and in DESIGN.md
   before that. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  background: var(--clubi-bg);
  color: var(--clubi-ink);
  font-family: var(--clubi-font-text);
  font-size: 1rem;
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-text);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  padding: var(--space-6);
  background: var(--clubi-surface);
  border: 1px solid var(--clubi-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-paper);
}

/* The logotype is hand-drawn lettering, never type (DESIGN.md 4.6 and 5.4).
   Painted as a mask rather than an <img>: the SVG fills with currentColor, which an external
   <img> cannot inherit, and masking keeps one file covering all three brandbook variants.
   --logo-src comes from the template, which is what knows the hashed {% static %} URL. */
.auth-brand {
  display: block;
  width: 128px; /* above the 96px minimum of DESIGN.md 5.3 */
  aspect-ratio: 553 / 259; /* the logo's own 2.14 ratio (DESIGN.md 5.1) — never distort */
  margin-bottom: var(--space-5);
  background-color: var(--clubi-ink-brand);
  -webkit-mask: var(--logo-src) center / contain no-repeat;
  mask: var(--logo-src) center / contain no-repeat;
}

.auth-card h1 {
  margin: 0 0 var(--space-2);
  font-family: var(--clubi-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  color: var(--clubi-ink-brand);
}

.auth-lead {
  margin: 0 0 var(--space-5);
  color: var(--clubi-ink-muted);
}

.auth-form p {
  margin: 0 0 var(--space-4);
}

label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--clubi-line-strong);
  border-radius: var(--radius-sm);
  background: var(--clubi-surface-sunken);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--clubi-focus);
  outline-offset: 2px;
}

.helptext {
  display: block;
  margin: var(--space-2) 0 0;
  color: var(--clubi-ink-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* Django puts the password rules in a <ul> inside <span class="helptext">, but <ul> is not
   phrasing content, so the HTML parser hoists it out — it lands as a sibling of the <p>, and a
   descendant selector never matches it. Style it where it actually ends up. */
.auth-form > ul {
  margin: -0.5rem 0 var(--space-4);
  padding-left: var(--space-4);
  color: var(--clubi-ink-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.auth-form > ul li + li {
  margin-top: var(--space-2);
}

/* Never signal state by colour alone (DESIGN.md 3.3): danger sits close to the brand wine in
   lightness, so the error list keeps its marker and its wording. */
.errorlist {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
  border-left: 3px solid var(--clubi-danger);
  border-radius: var(--radius-sm);
  background: #fbeeea;
  color: var(--clubi-danger);
  font-size: 0.875rem;
}

.button {
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--clubi-action);
  color: var(--clubi-action-ink);
  font-family: var(--clubi-font-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: var(--tracking-text);
  cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease);
}

.button:hover {
  background: var(--clubi-action-hover);
}

.button:active {
  background: var(--clubi-action-active);
}

.auth-links {
  margin: var(--space-5) 0 0;
  font-size: 0.875rem;
  color: var(--clubi-ink-muted);
}

.auth-links a {
  color: var(--clubi-ink-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}

/* =========================================================================== showreel layer
   DESIGN.md E-31: the frame around the card takes the showreel's language — the wine checker
   (E-27), two die-cut stickers in the corners of the screen (E-28), the hard wine shadow under
   the card (E-24), the marca-texto on the heading (E-23) and a rise on entry (E-26). The form
   itself — fields, labels, errors, button, links — is exactly what it was. No text sits on the
   checker: everything readable is on the cream card (DESIGN.md 7). */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(var(--space-5));
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0) rotate(-30deg);
  }
}

@keyframes sweep {
  from {
    transform: skewX(-6deg) scaleX(0);
  }
}

body {
  background-color: var(--clubi-bg-invert);
  background-image: conic-gradient(
    var(--clubi-wine-checker) 25%,
    transparent 0 50%,
    var(--clubi-wine-checker) 0 75%,
    transparent 0
  );
  background-size: var(--checker-size) var(--checker-size);
}

.auth-card {
  position: relative;
  z-index: 1;
  border-color: var(--clubi-line-strong);
  box-shadow: var(--shadow-hard-invert);
  animation: rise var(--motion-enter) var(--motion-ease-out) both;
}

.auth-card h1 {
  font-size: var(--text-xl);
}

/* The tint, not full yellow: the card is cream, and 3.2 forbids yellow on cream (E-23). */
.auth-card h1 .hl {
  position: relative;
  z-index: 0;
  padding-inline: 0.08em;
}

.auth-card h1 .hl::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 12% -0.1em -4% -0.08em;
  background: var(--clubi-tint-yellow);
  transform: skewX(-6deg);
  transform-origin: 0 50%;
  animation: sweep 450ms var(--motion-ease-out) 350ms both;
}

/* Two stickers, fixed to the corners of the screen rather than the card, so they never cover a
   field. On wine, which is what the die-cut cream outline is for (6.1). */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  background: center / contain no-repeat;
  pointer-events: none;
  animation: pop 500ms var(--motion-ease-pop) 300ms both;
}

body::before {
  top: var(--space-6);
  right: max(var(--space-4), 6vw);
  width: clamp(4rem, 12vw, 7rem);
  aspect-ratio: 382 / 384;
  background-image: url("../brand/stickers/estrela.1ac4e50da05a.png");
  transform: rotate(8deg);
}

body::after {
  bottom: var(--space-6);
  left: max(var(--space-4), 6vw);
  width: clamp(4rem, 11vw, 6rem);
  aspect-ratio: 417 / 336;
  background-image: url("../brand/stickers/balao.00fbb924085f.png");
  transform: rotate(-8deg);
  animation-delay: 420ms;
}

/* On a phone the card fills the width and the corners are where the stickers would sit, so they
   step behind the card's edge instead of over it. */
@media (max-width: 479px) {
  body::before {
    top: var(--space-2);
    right: var(--space-2);
  }

  body::after {
    bottom: var(--space-2);
    left: var(--space-2);
  }
}

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

  body::before,
  body::after,
  .auth-card h1 .hl::before {
    transform: none;
  }
}

/* =========================================================================== keys (E-32)
   The button as a pressable stamp: Clash on the label, the hard shadow of the "Leitura terminada."
   stamp under it (E-24/E-25), rising on hover where there is a mouse and landing on its own shadow
   when pressed. --key-color is the one thing a variant changes — orange under wine, the strong
   line under an outlined button, the deep wine under yellow on a wine ground (each a pair 3.2
   already measures). Only transform and box-shadow move. */

.button {
  --key-color: var(--clubi-accent);
  font-family: var(--clubi-font-display);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  box-shadow: var(--key-offset) 0 0 var(--key-color);
  transition:
    background var(--motion-base) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease);
}

@media (hover: hover) {
  .button:not([disabled]):hover {
    transform: translate(var(--key-lift));
    box-shadow: var(--key-offset-lift) 0 0 var(--key-color);
  }
}

.button:not([disabled]):active {
  transform: translate(var(--key-press));
  box-shadow: 0 0 0 0 var(--key-color);
}

.button[disabled] {
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .button:not([disabled]):hover,
  .button:not([disabled]):active {
    transform: none;
  }
}
