/* Pagetna auth screens (sessions, registrations, passwords).
   Split layout: focused form panel + brand/story panel from 1024px.
   Spec: design-system/pagetna/MASTER.md §4 "Auth". Scoped to .pg. */

.pg.pg-auth-page { background: var(--pg-surface); }
/* grid_demo.css styles every bare <main>; the auth shell owns the full viewport. */
.pg.pg-auth-page > main { max-width: none; margin: 0; padding: 0; }
/* application.css styles bare inputs with a 0,4,1 selector; restore pg-input inside auth. */
.pg .pg-auth input.pg-input:not([type=checkbox]):not([type=radio]) { min-height: var(--pg-control); padding: 10px 14px; border: 1px solid var(--pg-line-strong); border-radius: var(--pg-radius-md); color: var(--pg-ink); font-size: var(--pg-text-base); transition: border-color var(--pg-dur) var(--pg-ease), box-shadow var(--pg-dur) var(--pg-ease); }
.pg .pg-auth input.pg-input:not([type=checkbox]):not([type=radio]):hover { border-color: var(--pg-subtle); }
.pg .pg-auth input.pg-input:not([type=checkbox]):not([type=radio]):focus { border-color: var(--pg-primary); box-shadow: 0 0 0 4px var(--pg-primary-soft); }
.pg .pg-auth input.pg-input[aria-invalid=true]:not([type=checkbox]):not([type=radio]) { border-color: var(--pg-danger); }

.pg .pg-auth { display: grid; min-height: 100dvh; background: var(--pg-gradient-soft), var(--pg-surface); }

/* ---------- Form panel ---------- */
.pg .pg-auth__panel { display: flex; flex-direction: column; min-width: 0; padding: var(--pg-space-4) var(--pg-gutter) var(--pg-space-5); }
.pg .pg-auth__top { display: flex; align-items: center; justify-content: space-between; gap: var(--pg-space-4); }
.pg .pg-auth__brand { display: inline-flex; align-items: center; min-height: var(--pg-control); border-radius: var(--pg-radius-sm); }
.pg .pg-auth__brand .brand-logo { width: auto; height: 30px; }
.pg .pg-auth__lang { padding-inline: var(--pg-space-3); color: var(--pg-muted); }
.pg .pg-auth__lang:hover { color: var(--pg-ink); }

.pg .pg-auth__body { display: flex; flex-direction: column; gap: var(--pg-space-6); width: 100%; max-width: 420px; margin: var(--pg-space-10) auto var(--pg-space-12); }
.pg .pg-auth__intro { display: flex; flex-direction: column; gap: var(--pg-space-2); }
.pg .pg-auth__title { font-size: var(--pg-text-3xl); font-weight: var(--pg-weight-extrabold); line-height: 1.08; letter-spacing: -.04em; }
/* The form arrives in a short stagger (CSS only, so it never waits on JS). */
.pg .pg-auth__body > * { animation: pg-rise 700ms var(--pg-ease-out) backwards; }
.pg .pg-auth__body > :nth-child(2) { animation-delay: 70ms; }
.pg .pg-auth__body > :nth-child(3) { animation-delay: 140ms; }
.pg .pg-auth__body > :nth-child(n+4) { animation-delay: 210ms; }
@media (prefers-reduced-motion: reduce) { .pg .pg-auth__body > *, .pg .pg-auth__story * { animation: none; } }
html[dir=rtl] .pg .pg-auth__title { letter-spacing: 0; }
.pg .pg-auth__lead { color: var(--pg-muted); font-size: var(--pg-text-lg); line-height: var(--pg-leading); }
.pg .pg-auth__icon { display: grid; place-items: center; width: 56px; height: 56px; margin-block-end: var(--pg-space-2); border-radius: var(--pg-radius-lg); background: var(--pg-gradient); color: var(--pg-on-primary); box-shadow: var(--pg-shadow-primary); }
.pg .pg-auth__back { align-self: flex-start; margin-block-end: calc(-1 * var(--pg-space-2)); }

.pg .pg-auth__form { display: flex; flex-direction: column; gap: var(--pg-space-5); }
.pg .pg-auth__form > .pg-btn { margin-block-start: var(--pg-space-1); }
.pg .pg-auth__label-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--pg-space-1) var(--pg-space-4); }
.pg .pg-auth__aside-link { display: inline-flex; align-items: center; min-height: 24px; font-size: var(--pg-text-sm); }
.pg .pg-auth__switch { padding-block-start: var(--pg-space-5); border-block-start: 1px solid var(--pg-line); color: var(--pg-muted); font-size: var(--pg-text-md); text-align: center; }
.pg .pg-auth__switch .pg-link { display: inline-flex; align-items: center; min-height: 32px; }
.pg .pg-auth__fineprint { display: flex; align-items: flex-start; gap: var(--pg-space-2); color: var(--pg-subtle); font-size: var(--pg-text-sm); line-height: 1.5; }
.pg .pg-auth__fineprint .pg-icon { margin-block-start: 2px; }
.pg .pg-auth__error-list { margin: var(--pg-space-1) 0 0; padding-inline-start: var(--pg-space-5); }
.pg .pg-auth .pg-callout p { margin: 0; }
/* Rails wraps an invalid model field in div.field_with_errors; it must not become a layout box inside a field or an input group. */
.pg .pg-auth .field_with_errors { display: contents; }
.pg .pg-auth .pg-input-group.pg-password .field_with_errors > input.pg-input:not([type=checkbox]):not([type=radio]) { border: 0; box-shadow: none; }
.pg .pg-auth .pg-callout > :is(div, p) { min-width: 0; overflow-wrap: anywhere; }
.pg .pg-auth .pg-callout--danger { border-radius: var(--pg-radius-lg); }
.pg .pg-auth__error-list li + li { margin-block-start: 2px; }
.pg .pg-auth .pg-error { overflow-wrap: anywhere; }

.pg .pg-auth__proof { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--pg-space-2) var(--pg-space-4); color: var(--pg-muted); font-size: var(--pg-text-sm); }
.pg .pg-auth__proof li { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding-inline: var(--pg-space-3); border: 1px solid var(--pg-line); border-radius: var(--pg-radius-full); background: var(--pg-surface); box-shadow: var(--pg-shadow-xs); }
.pg .pg-auth__proof .pg-icon { color: var(--pg-success); }

/* Account type cards */
.pg .pg-auth__types legend { margin-block-end: var(--pg-space-2); }
.pg .pg-auth__type-grid { display: grid; gap: var(--pg-space-3); }
.pg .pg-auth__type { align-items: center; padding: var(--pg-space-3) var(--pg-space-4); }
.pg .pg-auth__type > input[type=radio] { margin: 0; }
.pg .pg-auth__type-icon { display: grid; flex: none; place-items: center; width: 40px; height: 40px; border-radius: var(--pg-radius-md); background: var(--pg-surface-2); color: var(--pg-muted); transition: background-color var(--pg-dur) var(--pg-ease), color var(--pg-dur) var(--pg-ease), box-shadow var(--pg-dur) var(--pg-ease); }
.pg .pg-auth__type:has(input:checked) .pg-auth__type-icon { background: var(--pg-gradient); color: var(--pg-on-primary); box-shadow: var(--pg-shadow-primary); }

/* Password reveal (password_visibility_controller) */
.pg .pg-password .pg-input { flex: 1; }
.pg .pg-auth .pg-input-group.pg-password > input.pg-input:not([type=checkbox]):not([type=radio]) { border: 0; box-shadow: none; }
.pg .pg-password__toggle { display: grid; flex: none; place-items: center; width: var(--pg-control); margin: 0; padding: 0; border: 0; border-start-end-radius: var(--pg-radius-md); border-end-end-radius: var(--pg-radius-md); background: transparent; color: var(--pg-subtle); cursor: pointer; transition: color var(--pg-dur) var(--pg-ease), background-color var(--pg-dur) var(--pg-ease); }
.pg .pg-password__toggle:hover { background: var(--pg-surface-2); color: var(--pg-ink); }
.pg .pg-password__toggle:focus-visible { outline-offset: -2px; }
.pg .pg-password__toggle .pg-icon { width: 18px; height: 18px; }
.pg .pg-password .pg-password__hide, .pg .pg-password.is-revealed .pg-password__show { display: none; }
.pg .pg-password.is-revealed .pg-password__hide { display: block; }
.pg .pg-password:has(.pg-input[aria-invalid=true]) { border-color: var(--pg-danger); }

.pg .pg-auth__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--pg-space-2) var(--pg-space-4); margin-block-start: auto; color: var(--pg-subtle); font-size: var(--pg-text-sm); }
.pg .pg-auth__legal { display: flex; gap: var(--pg-space-1); }
.pg .pg-auth__legal a { display: inline-flex; align-items: center; min-height: 32px; padding-inline: var(--pg-space-2); border-radius: var(--pg-radius-xs); color: var(--pg-muted); }
.pg .pg-auth__legal a:hover { color: var(--pg-ink); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Story panel (≥1024px) ---------- */
.pg .pg-auth__story { display: none; }

@media (min-width: 480px) {
  .pg .pg-auth__type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pg .pg-auth__type { flex-direction: column; align-items: flex-start; gap: var(--pg-space-2); padding: var(--pg-space-4); }
  .pg .pg-auth__type > input[type=radio] { position: absolute; inset-block-start: var(--pg-space-4); inset-inline-end: var(--pg-space-4); }
}

@media (min-width: 768px) {
  .pg .pg-auth__panel { padding: var(--pg-space-6) var(--pg-space-10) var(--pg-space-6); }
  .pg .pg-auth__body { margin-block: auto; padding-block: var(--pg-space-12); }
  .pg .pg-auth__title { font-size: clamp(var(--pg-text-4xl), 3.2vw, 2.75rem); }
}

@media (min-width: 1024px) {
  .pg .pg-auth { grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); }
  .pg .pg-auth__panel { position: sticky; inset-block-start: 0; max-height: 100dvh; overflow-y: auto; padding-inline: var(--pg-space-12); }
  .pg .pg-auth__proof { display: none; }
  /* The story is a midnight stage (pg-band pg-night) set into the page like a framed window. */
  .pg .pg-auth__story { display: flex; align-items: center; min-height: calc(100dvh - 2 * var(--pg-space-4)); margin: var(--pg-space-4); margin-inline-start: 0; padding: var(--pg-space-8) var(--pg-space-10); }
  .pg .pg-auth__story-inner { position: relative; display: flex; flex-direction: column; gap: var(--pg-space-5); width: 100%; max-width: 560px; margin-inline: auto; }
  .pg .pg-auth__story-inner > * { animation: pg-rise 800ms var(--pg-ease-out) backwards; }
  .pg .pg-auth__story-inner > :nth-child(2) { animation-delay: 80ms; }
  .pg .pg-auth__story-inner > :nth-child(3) { animation-delay: 160ms; }
  .pg .pg-auth__story-inner > :nth-child(4) { animation-delay: 240ms; }
  .pg .pg-auth__story-inner > :nth-child(5) { animation-delay: 320ms; }
  .pg .pg-auth__story-eyebrow { display: inline-flex; align-items: center; gap: var(--pg-space-2); align-self: flex-start; min-height: 32px; padding: 0 var(--pg-space-3); border: 1px solid var(--pg-night-line-strong); border-radius: var(--pg-radius-full); background: var(--pg-night-glass); color: var(--pg-ink); font-size: var(--pg-text-sm); font-weight: var(--pg-weight-semibold); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .pg .pg-auth__story-eyebrow .pg-icon { color: var(--pg-gold); }
  .pg .pg-auth__story-title { color: var(--pg-ink); font-size: var(--pg-text-4xl); font-weight: var(--pg-weight-extrabold); line-height: 1.06; letter-spacing: -.04em; }
  html[dir=rtl] .pg .pg-auth__story-title { letter-spacing: 0; line-height: 1.3; }
  .pg .pg-auth__story-lead { max-width: 48ch; color: var(--pg-muted); font-size: var(--pg-text-lg); line-height: 1.6; }

  /* Product preview (decorative): a light window floating on the stage */
  .pg .pg-auth__preview { position: relative; margin-block: var(--pg-space-4) var(--pg-space-2); padding-block-end: var(--pg-space-5); }
  .pg .pg-auth__browser { overflow: hidden; border: 1px solid var(--pg-night-line-strong); border-radius: var(--pg-radius-lg); background: var(--pg-surface); box-shadow: 0 40px 80px -32px color-mix(in srgb, var(--pg-night-3) 90%, transparent); animation: pg-float 6s ease-in-out 1s 20 alternate; }
  .pg .pg-auth__browser-bar { display: flex; align-items: center; gap: 6px; min-height: 36px; padding-inline: var(--pg-space-3); border-block-end: 1px solid var(--pg-line); background: var(--pg-surface-2); }
  .pg .pg-auth__browser-bar span { width: 9px; height: 9px; border-radius: 50%; background: var(--pg-line-strong); }
  .pg .pg-auth__browser-bar em { flex: 1; max-width: 260px; margin-inline: auto; padding: 2px var(--pg-space-3); border-radius: var(--pg-radius-full); background: var(--pg-surface); color: var(--pg-subtle); font-family: var(--pg-font); font-size: var(--pg-text-xs); font-style: normal; text-align: center; }
  .pg .pg-auth__mock { display: flex; flex-direction: column; gap: var(--pg-space-4); padding: var(--pg-space-4) var(--pg-space-5) var(--pg-space-5); }
  .pg .pg-auth__mock b, .pg .pg-auth__mock i { display: block; border-radius: var(--pg-radius-full); background: var(--pg-surface-3); }
  .pg .pg-auth__mock-nav { display: flex; align-items: center; gap: var(--pg-space-3); }
  .pg .pg-auth__mock-nav b { width: 36px; height: 6px; }
  .pg .pg-auth__mock-nav .pg-auth__mock-logo { width: 22px; height: 22px; margin-inline-end: auto; border-radius: var(--pg-radius-xs); background: var(--pg-gradient); }
  .pg .pg-auth__mock-lang { padding: 2px var(--pg-space-2); border: 1px solid var(--pg-line); border-radius: var(--pg-radius-full); color: var(--pg-muted); font-size: var(--pg-text-xs); font-weight: var(--pg-weight-semibold); }
  .pg .pg-auth__mock-hero { display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: var(--pg-space-5); padding: var(--pg-space-4) var(--pg-space-5); border-radius: var(--pg-radius-md); background: var(--pg-primary-soft); }
  .pg .pg-auth__mock-copy { display: flex; flex-direction: column; gap: var(--pg-space-2); }
  .pg .pg-auth__mock-copy b { height: 10px; width: 70%; background: var(--pg-primary-line); }
  .pg .pg-auth__mock-copy b.is-wide { width: 100%; height: 14px; background: var(--pg-ink); opacity: .85; }
  .pg .pg-auth__mock-cta { width: 88px; height: 24px; margin-block-start: var(--pg-space-2); border-radius: var(--pg-radius-xs); background: var(--pg-gradient); }
  .pg .pg-auth__mock-art { aspect-ratio: 16 / 10; border-radius: var(--pg-radius-sm); background: linear-gradient(160deg, var(--pg-primary-soft-2), var(--pg-primary-line)); }
  .pg .pg-auth__mock-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--pg-space-3); }
  .pg .pg-auth__mock-cards i { height: 40px; border-radius: var(--pg-radius-sm); background: var(--pg-surface-2); border: 1px solid var(--pg-line); }
  .pg .pg-auth__float { position: absolute; display: flex; align-items: center; gap: var(--pg-space-3); border-radius: var(--pg-radius-lg); background: var(--pg-surface); color: var(--pg-ink); box-shadow: var(--pg-shadow-lg); animation: pg-rise 800ms var(--pg-ease-out) 500ms backwards, pg-float 5s ease-in-out 1.4s 24 alternate; }
  .pg .pg-auth__float--toast { inset-block-end: 0; inset-inline-start: calc(-1 * var(--pg-space-6)); max-width: 300px; padding: var(--pg-space-3) var(--pg-space-4); }
  .pg .pg-auth__float--toast strong { display: block; font-size: var(--pg-text-md); line-height: 1.35; }
  .pg .pg-auth__float--toast small { display: block; color: var(--pg-muted); font-size: var(--pg-text-xs); line-height: 1.45; }
  .pg .pg-auth__float-icon { display: grid; flex: none; place-items: center; width: 32px; height: 32px; border-radius: var(--pg-radius-sm); background: var(--pg-success-soft); color: var(--pg-success); }
  .pg .pg-auth__float--badge { inset-block-start: -16px; inset-inline-end: calc(-1 * var(--pg-space-5)); min-height: 36px; padding: 0 var(--pg-space-3); border-radius: var(--pg-radius-full); color: var(--pg-primary-hover); font-size: var(--pg-text-sm); font-weight: var(--pg-weight-semibold); animation-delay: 650ms, 2s; }

  .pg .pg-auth__benefits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--pg-space-3); }
  .pg .pg-auth__benefits li { display: flex; flex-direction: column; gap: var(--pg-space-3); padding: var(--pg-space-4); border: 1px solid var(--pg-night-line); border-radius: var(--pg-radius-lg); background: var(--pg-night-glass); color: var(--pg-muted); font-size: var(--pg-text-sm); line-height: 1.55; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  .pg .pg-auth__benefits strong { display: block; margin-block-end: 2px; color: var(--pg-ink); font-size: var(--pg-text-md); }
  .pg .pg-auth__benefit-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--pg-radius-md); background: var(--pg-primary-soft); color: var(--pg-halo); }
}

@media (min-width: 1280px) {
  .pg .pg-auth__story { padding-inline: var(--pg-space-16); }
  .pg .pg-auth__story-title { font-size: clamp(var(--pg-text-4xl), 3.4vw, 3.25rem); }
}
