/* ============================================================
   Media Organizer — Login
   Editorial cinema archive. Modern · Sharp · Confident.
   Tokens come from tokens.css; theme toggle reuses .theme-toggle
   from main.css. This file owns only the login-specific layout.
   ============================================================ */

/* Defensive `hidden` reset — class selectors below set non-`none`
   `display` values (e.g. `.login-page`, `.login-card`), which would
   otherwise win over the UA `[hidden]{display:none}`. Required so
   `el.hidden = true` toggles work for any future JS state-machine
   on this page. Pattern from ENGINEERING.md tab-CSS notes. */
[hidden] { display: none !important; }

/* ---------- Page shell ---------- */

.login-page {
  min-height: 100dvh;
  background-color: var(--surface-page);
}

/* Skip-link: visually hidden until focused, then docks top-left */
.skip-link {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: 100;
  padding: var(--space-2xs) var(--space-sm);
  background-color: var(--surface-1);
  color: var(--text-strong);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-md)));
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
  outline: none;
  transform: translateY(0);
  box-shadow: var(--focus-ring);
}

.login-shell {
  min-height: 100dvh;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--shell-pad-y) var(--shell-pad-x);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-xl);
}

.login-shell__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

/* ---------- Logo lockup (mirrors header logo, sized down) ---------- */

.login-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-strong);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-snug);
  font-size: var(--text-md);
  text-decoration: none;
}

.login-logo__mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.login-logo__wordmark {
  font-feature-settings: "ss01", "cv01";
}

.login-logo__highlight {
  color: var(--text-muted);
  font-weight: var(--weight-regular);
}

/* ---------- Main column ---------- */

.login-main {
  display: grid;
  place-items: center;
  padding-block: clamp(var(--space-xl), 8vh, var(--space-4xl));
}

/* Editorial single column, ~420px max. No card chrome — whitespace
   does the framing. The eyebrow / title / lede / form stack reads as
   one continuous editorial block; the eye comes in via the eyebrow
   rule on the left and walks down. */
.login-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  text-align: left;
}

/* ---------- Editorial heading group ---------- */

/* Eyebrow doubles as a tiny editorial rule via a left ::before — a
   single hairline that lifts the section without resorting to the
   banned border-left accent stripe. The pseudo-element is 24px wide
   sitting INLINE with the text, not framing the card. */
.login-eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-display);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.login-title {
  margin: 0;
  font-family: var(--font-display);
  /* Fluid title size — at 360px we land near text-xl, at 720px+ we
     hit the full text-2xl. Keeps the editorial weight on desktop
     without crowding the phone column. */
  font-size: clamp(var(--text-xl), 1.6rem + 1.2vw, var(--text-2xl));
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text-strong);
  max-width: 14ch;
}

.login-lede {
  margin: 0 0 var(--space-md) 0;
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-regular);
  line-height: var(--leading-base);
  color: var(--text-muted);
  max-width: 38ch;
}

/* ---------- Form ---------- */

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Visually-hidden username shim that password managers can still see */
.login-username-shim {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-snug);
  color: var(--text-strong);
}

.field__control {
  position: relative;
  display: flex;
  align-items: stretch;
}

.field__input {
  flex: 1;
  width: 100%;
  min-height: 48px;
  background-color: var(--surface-1);
  border: 1px solid var(--border-base);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-size: var(--text-base);
  letter-spacing: var(--tracking-snug);
  padding: var(--space-sm) calc(44px + var(--space-xs)) var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  outline: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.field__input::placeholder {
  color: var(--text-subtle);
}

.field__input:hover {
  border-color: var(--border-strong);
}

.field__input:focus,
.field__input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent);
}

.field__input:autofill,
.field__input:-webkit-autofill {
  -webkit-text-fill-color: var(--text-strong);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-1) inset;
  caret-color: var(--text-strong);
}

.field__hint {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  letter-spacing: var(--tracking-snug);
  min-height: 1em; /* hold space for live-status messages */
}

.field__hint--status[data-state="match"] {
  color: var(--success);
}

.field__hint--status[data-state="mismatch"] {
  color: var(--danger);
}

/* ---------- Password show/hide toggle ---------- */

.pwd-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-2xs);
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.pwd-toggle:hover {
  color: var(--text-base);
}

.pwd-toggle:focus-visible {
  outline: none;
  color: var(--text-base);
  box-shadow: var(--focus-ring);
}

.pwd-toggle__icon {
  width: 18px;
  height: 18px;
}

.pwd-toggle__icon--hide {
  display: none;
}

.pwd-toggle[aria-pressed="true"] .pwd-toggle__icon--show {
  display: none;
}

.pwd-toggle[aria-pressed="true"] .pwd-toggle__icon--hide {
  display: block;
}

/* ---------- Remember me ---------- */

/* Native checkbox + label, restrained editorial vibe. ≥44×44 touch
   target met by the label's vertical padding on phone breakpoints. */
.login-remember {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) 0;
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--text-base);
  letter-spacing: var(--tracking-snug);
}

.login-remember__input {
  /* Use the system accent colour for the check tick so theme + OS
     accent stay consistent. width/height keeps the box visible
     without dwarfing the label text. */
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.login-remember__input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.login-remember__text {
  line-height: 1.4;
}

@media (max-width: 480px) {
  /* Phone: bump the touch target without enlarging visible text. */
  .login-remember {
    min-height: 44px;
  }
}

/* ---------- Submit button ---------- */

.login-submit {
  margin-top: var(--space-xs);
  min-height: 48px;
  padding: var(--space-sm) var(--space-lg);
  background-color: var(--accent);
  color: var(--accent-on);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-snug);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.login-submit:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.login-submit:active {
  background-color: var(--accent-pressed);
  border-color: var(--accent-pressed);
}

.login-submit:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Alerts ---------- */

.login-alert {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-base);
  border: 1px solid var(--border-subtle);
  background-color: var(--surface-1);
  color: var(--text-strong);
}

.login-alert--error {
  border-color: color-mix(in oklch, var(--danger) 35%, var(--border-subtle));
  background-color: color-mix(in oklch, var(--danger) 10%, var(--surface-1));
  color: var(--text-strong);
}

.login-alert--success {
  border-color: color-mix(in oklch, var(--success) 35%, var(--border-subtle));
  background-color: color-mix(in oklch, var(--success) 10%, var(--surface-1));
  color: var(--text-strong);
}

/* ---------- Footer ---------- */

.login-footer {
  text-align: left;
  font-size: var(--text-xs);
  color: var(--text-subtle);
  letter-spacing: var(--tracking-wide);
}

.login-footer p {
  margin: 0;
}

/* ---------- Quiet entrance + shake on auth failure (motion-safe) ---------- */

@media (prefers-reduced-motion: no-preference) {
  /* Editorial fade-in on first paint. 280ms with a slight 6px lift —
     reads as the page settling, not as "entrance choreography". */
  .login-card {
    animation: login-enter 280ms var(--ease-out) both;
  }

  @keyframes login-enter {
    from { opacity: 0; transform: translate3d(0, 6px, 0); }
    to   { opacity: 1; transform: translate3d(0, 0,   0); }
  }

  .login-card--shake {
    /* On auth failure the shake overrides the entrance — the shake
       keyframes carry their own transform, so we don't need to
       coordinate timings. */
    animation: login-shake 320ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  }

  @keyframes login-shake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    20%      { transform: translate3d(-4px, 0, 0); }
    40%      { transform: translate3d(3px, 0, 0); }
    60%      { transform: translate3d(-2px, 0, 0); }
    80%      { transform: translate3d(1px, 0, 0); }
  }
}

/* ---------- Phone breakpoint ---------- */

@media (max-width: 640px) {
  .login-shell {
    gap: var(--space-lg);
  }

  .login-main {
    padding-block: var(--space-lg);
    place-items: start center;
  }

  .login-title {
    font-size: var(--text-xl);
    max-width: none;
  }

  .login-lede {
    font-size: var(--text-base);
  }

  .login-logo__wordmark {
    /* Wordmark stays full on phones — Polish diacritics need the room */
    font-size: var(--text-base);
  }
}

/* ---------- Tiny phone ---------- */

@media (max-width: 380px) {
  .login-logo__highlight {
    display: none;
  }
}
