/*!
 * static/css/register.css - agent:registration
 *
 * The public sign-up page (/register) and nothing else. Loaded by
 * templates/register.php AFTER main.css, so it only adds what the design system
 * does not already provide: .acher-card, .acher-input, .acher-btn-primary,
 * .acher-label and .alert come from main.css and are never re-implemented here.
 *
 * NOT ONE HEX LITERAL IN THIS FILE. Every colour, radius, space, font and glow is
 * an ACHER token from :root in main.css, so a palette change lands here for free
 * and a stray brand colour cannot creep in.
 *
 * Everything is namespaced under .reg-* (and the page's own .page-register body
 * class) so it cannot leak into templates/login.php, which styles itself with
 * .auth-* in its own page-scoped <style> block.
 *
 * Restrained on purpose: matrix green is an accent. Exactly one thing glows - the
 * submit button on hover - plus the drifting backdrop, which is the only motion on
 * the page and is switched off under prefers-reduced-motion.
 */

/* =========================================================================
   1. Page shell - the form, and the reason to fill it in, side by side
   ========================================================================= */

.reg-wrap {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 27rem) minmax(0, 23rem);
    align-items: start;
    justify-content: center;
    gap: var(--space-10);
    padding: var(--space-12) var(--space-5);
    overflow: hidden;
}

/* Drifting green wash behind the card. Purely decorative and pointer-transparent,
   so it can never eat a click meant for the form. */
.reg-backdrop {
    position: absolute;
    inset: -25%;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(34rem 34rem at 22% 18%, rgba(var(--acher-primary-rgb), 0.09), transparent 62%),
        radial-gradient(30rem 30rem at 78% 30%, rgba(var(--acher-primary-rgb), 0.05), transparent 60%),
        radial-gradient(32rem 32rem at 50% 92%, rgba(var(--acher-primary-rgb), 0.06), transparent 64%);
    filter: blur(30px);
    opacity: 0.85;
    animation: reg-drift 24s ease-in-out infinite alternate;
}

@keyframes reg-drift {
    0%   { transform: translate3d(-3%, -2%, 0) scale(1); }
    50%  { transform: translate3d(2%, 3%, 0) scale(1.05); }
    100% { transform: translate3d(4%, -3%, 0) scale(1.02); }
}

/* =========================================================================
   2. The card
   ========================================================================= */

.reg-card {
    position: relative;
    z-index: 1;
    padding: var(--space-8) var(--space-7) var(--space-7);
}

.reg-brand {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--acher-primary);
}

.reg-title {
    margin: 0 0 var(--space-2);
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 400;
    line-height: var(--lh-tight);
    letter-spacing: 0.04em;
    color: var(--acher-text);
}

.reg-subtitle {
    margin: 0 0 var(--space-6);
    font-size: var(--fs-sm);
    line-height: var(--lh-base);
    color: var(--acher-dim);
}

/* main.css gives .alert a display value, so [hidden] has to be promoted. */
.reg-alert {
    margin-bottom: var(--space-5);
    border-color: rgba(var(--acher-danger-rgb), 0.45);
    border-left-width: 3px;
    background: var(--tint-danger);
    color: var(--acher-text);
    font-size: var(--fs-sm);
    line-height: var(--lh-base);
}

.reg-alert[hidden] {
    display: none !important;
}

/* =========================================================================
   3. Fields
   ========================================================================= */

.reg-field {
    margin-bottom: var(--space-5);
}

.reg-field .acher-label {
    display: block;
    margin-bottom: var(--space-2);
}

.reg-hint {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-xs);
    line-height: var(--lh-snug);
    color: var(--acher-muted);
}

/* ---- password + reveal toggle ------------------------------------------- */

.reg-password-box {
    position: relative;
    display: block;
}

.reg-password-box .acher-input {
    padding-right: 3rem;
}

.reg-reveal {
    position: absolute;
    top: 50%;
    right: var(--space-1);
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--acher-muted);
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
}

.reg-reveal:hover,
.reg-reveal:focus-visible {
    color: var(--acher-primary);
    background: rgba(var(--acher-primary-rgb), 0.08);
}

.reg-reveal svg {
    display: block;
    width: 1.1rem;
    height: 1.1rem;
    pointer-events: none;
}

/* aria-pressed is the single source of truth for which icon shows. */
.reg-reveal .icon-eye-off,
.reg-reveal[aria-pressed="true"] .icon-eye {
    display: none;
}

.reg-reveal[aria-pressed="true"] .icon-eye-off {
    display: block;
}

/* ---- live requirement checklist ----------------------------------------- */

.reg-rules {
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--space-1);
}

.reg-rules li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-xs);
    line-height: var(--lh-snug);
    color: var(--acher-muted);
    transition: color var(--transition);
}

.reg-rule-mark {
    position: relative;
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    border: 1px solid var(--acher-border-strong);
    border-radius: var(--radius-sm);
    background: var(--acher-bg-deep);
    transition: border-color var(--transition), background-color var(--transition);
}

/* The tick is drawn, not a glyph, so it needs no font and no image. */
.reg-rule-mark::after {
    content: "";
    position: absolute;
    top: 0.06rem;
    left: 0.22rem;
    width: 0.26rem;
    height: 0.5rem;
    border: solid var(--acher-primary-deep);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0.4);
    opacity: 0;
    transition: opacity var(--transition), transform var(--transition);
}

.reg-rules li.is-met {
    color: var(--acher-primary-soft);
}

.reg-rules li.is-met .reg-rule-mark {
    border-color: var(--acher-primary);
    background: var(--acher-primary);
}

.reg-rules li.is-met .reg-rule-mark::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

/* =========================================================================
   4. Cloudflare Turnstile
   ========================================================================= */

/* These rules only ever match when Turnstile is switched ON: with it off the
   template emits neither the container nor the notice, so they are inert. */
.reg-turnstile .cf-turnstile {
    display: block;
    min-height: 4.2rem;         /* reserve the widget height so nothing jumps */
    max-width: 100%;
    overflow-x: auto;           /* the "flexible" size still has a 300px floor */
}

.reg-turnstile .cf-turnstile iframe {
    max-width: 100%;
}

/* Plain-CSS "it never loaded" notice.

   :empty is true until Cloudflare's api.js injects its iframe into the container,
   so this covers every reason the widget can be missing - a content blocker, an
   offline visitor, JavaScript switched off, or a CSP that stopped allowing
   challenges.cloudflare.com. turnstile_widget() emits the div with no whitespace
   inside precisely so :empty stays reliable.

   display:none is the DEFAULT and the :empty rule promotes it to block, so once the
   widget has rendered the notice occupies no space at all.

   The animation is a 3 second TIMER, not motion - nothing moves, the notice merely
   stops being transparent - so a slow download is not reported as a failure. It is
   left in place under prefers-reduced-motion on purpose: suppressing it there would
   hide the explanation from exactly the people most likely to be on a hardened
   browser. */
.reg-turnstile-fallback {
    display: none;
    margin: var(--space-2) 0 0;
    padding: var(--space-3);
    border: 1px solid var(--acher-border-strong);
    border-left: 3px solid var(--acher-warning);
    border-radius: var(--radius-sm);
    background: var(--acher-surface-2);
    color: var(--acher-dim);
    font-size: var(--fs-xs);
    line-height: var(--lh-base);
    opacity: 0;
}

.reg-turnstile .cf-turnstile:empty + .reg-turnstile-fallback {
    display: block;
    animation: reg-turnstile-reveal 0.01s linear 3s forwards;
}

@keyframes reg-turnstile-reveal {
    to { opacity: 1; }
}

/* =========================================================================
   5. Submit + small print
   ========================================================================= */

#register-submit {
    margin-top: var(--space-2);
}

#register-submit[disabled],
#register-submit[aria-busy="true"] {
    opacity: 0.65;
    cursor: progress;
}

.reg-terms {
    margin: var(--space-4) 0 0;
    font-size: var(--fs-xs);
    line-height: var(--lh-base);
    color: var(--acher-muted);
}

/* =========================================================================
   6. The "why bother" column
   ========================================================================= */

.reg-aside {
    position: relative;
    z-index: 1;
    padding-top: var(--space-4);
}

.reg-aside-title {
    margin: 0 0 var(--space-4);
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--acher-text);
}

.reg-perks {
    margin: 0 0 var(--space-6);
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--space-4);
}

.reg-perks li {
    position: relative;
    padding-left: var(--space-5);
    font-size: var(--fs-sm);
    line-height: var(--lh-base);
    color: var(--acher-dim);
}

.reg-perks li::before {
    content: "";
    position: absolute;
    top: 0.55em;
    left: 0;
    width: 0.4rem;
    height: 0.4rem;
    border-radius: var(--radius-pill);
    background: var(--acher-primary);
    box-shadow: var(--acher-glow-sm);
}

.reg-perks strong {
    display: block;
    font-weight: 600;
    color: var(--acher-text);
}

.reg-signin,
.reg-back {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-sm);
    color: var(--acher-dim);
}

.reg-signin a,
.reg-back a {
    color: var(--acher-primary);
    text-decoration: none;
}

.reg-signin a:hover,
.reg-signin a:focus-visible,
.reg-back a:hover,
.reg-back a:focus-visible {
    text-decoration: underline;
}

.reg-noscript {
    position: relative;
    z-index: 1;
    grid-column: 1 / -1;
    display: block;
    max-width: 50rem;
    margin: var(--space-4) auto 0;
    font-size: var(--fs-xs);
    line-height: var(--lh-base);
    color: var(--acher-dim);
    text-align: center;
}

/* =========================================================================
   7. Responsive - one column below the two-column breakpoint
   ========================================================================= */

@media (max-width: 62rem) {
    .reg-wrap {
        grid-template-columns: minmax(0, 27rem);
        gap: var(--space-8);
        padding: var(--space-8) var(--space-4);
    }

    .reg-aside {
        padding-top: 0;
    }
}

@media (max-width: 30rem) {
    .reg-card {
        padding: var(--space-6) var(--space-5);
    }
}

/* =========================================================================
   8. Reduced motion - the backdrop is the only thing that moves
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .reg-backdrop {
        animation: none;
    }

    .reg-rule-mark,
    .reg-rule-mark::after,
    .reg-reveal,
    .reg-rules li {
        transition: none;
    }
}
