/* ==========================================================================
   i-TUL customer portal — authentication
   --------------------------------------------------------------------------
   Concept: "Signal". I-Tul builds software and connects systems, so the
   canvas is a slow-drifting field of data points over a navy bloom, with
   grain for depth and the brand lime as the single accent.
   Scoped under .auth-shell so nothing here can affect the rest of the app.
   ========================================================================== */

:root {
    --ink:        #080E1C;
    --ink-2:      #0D1730;
    --navy:       #16244C;
    --navy-lift:  #27407A;
    --lime:       #C1CD23;
    --lime-soft:  rgba(193, 205, 35, 0.16);

    --paper:      #FCFCFD;
    --paper-2:    #F3F5F9;
    --text:       #101828;
    --text-soft:  #5A6478;
    --text-faint: #98A1B3;
    --hair:       #E4E8EF;

    --font-display: 'Sora', system-ui, sans-serif;
    --font-ui:      'Instrument Sans', system-ui, sans-serif;

    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body { height: 100%; }

body.auth-shell {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.auth-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* --------------------------------------------------------------------------
   Left: the canvas
   -------------------------------------------------------------------------- */

.auth-canvas {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(32px, 4.5vw, 64px);
    background:
        radial-gradient(120% 90% at 12% 8%,  rgba(39, 64, 122, 0.55) 0%, transparent 60%),
        radial-gradient(90% 70% at 88% 92%,  rgba(193, 205, 35, 0.13) 0%, transparent 55%),
        linear-gradient(160deg, var(--ink-2) 0%, var(--ink) 55%, #050A14 100%);
    isolation: isolate;
}

/* A field of data points — software, not drafting paper. Drawn in CSS so
   there is no image to load, drifting slowly so the panel is never static. */
.auth-canvas::before {
    content: "";
    position: absolute;
    inset: -50%;
    background-image:
        radial-gradient(circle, rgba(193, 205, 35, 0.72) 1px, transparent 1.4px),
        radial-gradient(circle, rgba(198, 214, 255, 0.22) 0.8px, transparent 1.2px);
    background-size: 88px 88px, 22px 22px;
    background-position: 0 0, 11px 11px;
    mask-image: radial-gradient(68% 58% at 28% 34%, #000 0%, transparent 80%);
    -webkit-mask-image: radial-gradient(68% 58% at 28% 34%, #000 0%, transparent 80%);
    animation: gridDrift 72s linear infinite;
    z-index: -2;
}

/* Grain. The detail that keeps a gradient from reading as flat CSS. */
.auth-canvas::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.4;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}

@keyframes gridDrift {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(88px, 88px, 0); }
}

.canvas-top,
.canvas-body,
.canvas-foot { position: relative; z-index: 1; }

.canvas-mark {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.canvas-mark img { height: 42px; width: auto; }

/* Mark sits clean on the canvas - no glow behind it. */
.mark-halo {
    display: inline-flex;
    align-items: center;
}

.canvas-body { max-width: 27rem; }

.canvas-eyebrow {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lime);
    margin: 0 0 20px;
}

.canvas-heading {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.1rem, 3.4vw, 3.15rem);
    line-height: 1.06;
    letter-spacing: -0.03em;
    color: #fff;
    margin: 0;
    text-wrap: balance;
}

.canvas-heading em {
    font-style: normal;
    color: var(--lime);
}

.canvas-sub {
    margin: 22px 0 0;
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(224, 232, 246, 0.62);
    max-width: 34ch;
}

.canvas-foot {
    display: flex;
    align-items: center;
    gap: 28px;
    font-size: 0.78rem;
    color: rgba(224, 232, 246, 0.4);
}

.canvas-foot strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.32rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 3px;
}

.foot-rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(193, 205, 35, 0.4), transparent);
}

/* --------------------------------------------------------------------------
   Right: the form
   -------------------------------------------------------------------------- */

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(28px, 4vw, 56px);
    background: var(--paper);
    position: relative;
}

.auth-form-wrap {
    width: 100%;
    max-width: 388px;
}

.panel-mark {
    display: none;
    margin-bottom: 30px;
}

.panel-mark img { height: 36px; }

.auth-title {
    font-family: var(--font-display);
    font-size: 1.92rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin: 0 0 8px;
    color: var(--text);
}

.auth-lede {
    margin: 0 0 34px;
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--text-soft);
}

.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    margin-bottom: 7px;
}

.field input {
    width: 100%;
    font-family: var(--font-ui);
    font-size: 0.97rem;
    color: var(--text);
    padding: 13px 15px;
    background: #fff;
    border: 1px solid var(--hair);
    border-radius: 11px;
    transition: border-color 0.18s var(--ease),
                box-shadow 0.18s var(--ease),
                transform 0.18s var(--ease);
}

.field input::placeholder { color: var(--text-faint); }

.field input:hover { border-color: #CBD3E0; }

.field input:focus {
    outline: none;
    border-color: var(--navy-lift);
    box-shadow: 0 0 0 4px var(--lime-soft);
}

.field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field-row a {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--navy-lift);
    text-decoration: none;
    transition: color 0.16s var(--ease);
}

.field-row a:hover { color: var(--navy); text-decoration: underline; }

/* The hidden attribute has to beat display:flex or the empty error box shows. */
.auth-error[hidden] { display: none !important; }

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 0.86rem;
    line-height: 1.45;
    color: #B42318;
    background: #FEF3F2;
    border: 1px solid #FEE4E2;
    border-radius: 10px;
    padding: 11px 13px;
    margin: 0 0 18px;
    animation: errorIn 0.32s var(--ease) both;
}

.auth-error::before {
    content: "!";
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    margin-top: 1px;
    border-radius: 50%;
    background: #D92D20;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}

@keyframes errorIn {
    from { opacity: 0; transform: translateY(-5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.btn-auth {
    position: relative;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
    padding: 14px 20px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    overflow: hidden;
    background: linear-gradient(135deg, var(--navy-lift) 0%, var(--navy) 100%);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.16),
                0 8px 20px -10px rgba(22, 36, 76, 0.6);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

/* Lime sweep on hover — the accent earns its keep here. */
.btn-auth::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 25%, rgba(193, 205, 35, 0.28) 50%, transparent 75%);
    transform: translateX(-110%);
    transition: transform 0.7s var(--ease);
}

.btn-auth:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(16, 24, 40, 0.18),
                0 14px 30px -12px rgba(22, 36, 76, 0.75);
}

.btn-auth:hover::after { transform: translateX(110%); }

.btn-auth:active { transform: translateY(0); }

.btn-auth:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--lime-soft),
                0 8px 20px -10px rgba(22, 36, 76, 0.6);
}

.btn-auth[disabled] { cursor: default; }

.btn-spin {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: var(--lime);
    animation: spin 0.62s linear infinite;
    display: none;
}

.btn-auth.is-busy .btn-spin { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.auth-foot {
    margin: 26px 0 0;
    font-size: 0.8rem;
    color: var(--text-faint);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Entrance choreography — one orchestrated load, not scattered effects
   -------------------------------------------------------------------------- */

[data-rise] {
    opacity: 0;
    transform: translateY(14px);
    animation: rise 0.72s var(--ease) forwards;
}

@keyframes rise {
    to { opacity: 1; transform: translateY(0); }
}

[data-rise="1"] { animation-delay: 0.05s; }
[data-rise="2"] { animation-delay: 0.13s; }
[data-rise="3"] { animation-delay: 0.21s; }
[data-rise="4"] { animation-delay: 0.29s; }
[data-rise="5"] { animation-delay: 0.37s; }
[data-rise="6"] { animation-delay: 0.45s; }
[data-rise="7"] { animation-delay: 0.53s; }

/* Success: a lime wipe across the panel before the redirect lands. */
.auth-exit {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: linear-gradient(135deg, var(--navy) 0%, var(--ink) 100%);
    transform: scaleX(0);
    transform-origin: left center;
    pointer-events: none;
}

.auth-exit.is-on {
    animation: wipe 0.62s var(--ease) forwards;
}

.auth-exit::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: var(--lime);
    box-shadow: 0 0 22px 4px rgba(193, 205, 35, 0.65);
}

@keyframes wipe {
    to { transform: scaleX(1); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .auth-grid { grid-template-columns: 1fr; }

    .auth-canvas {
        min-height: 210px;
        padding: 26px 24px 30px;
        justify-content: flex-end;
    }

    .canvas-top,
    .canvas-foot { display: none; }

    .canvas-body { max-width: none; }

    .canvas-heading { font-size: 1.72rem; }

    .canvas-sub { display: none; }

    .panel-mark { display: block; }

    .auth-panel { padding: 34px 24px 46px; align-items: flex-start; }
}

@media (max-width: 420px) {
    .auth-title { font-size: 1.62rem; }
}

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .auth-canvas::before { animation: none; }
    [data-rise] { opacity: 1; transform: none; animation: none; }
    .auth-exit.is-on { animation: none; opacity: 0; }
    .btn-auth::after { transition: none; }
    .btn-auth:hover { transform: none; }
}

/* --------------------------------------------------------------------------
   Two-step sign in
   Email first, then password. Both inputs stay in the DOM so password
   managers keep working; only the panes swap, with a short directional
   transition so it reads as one continuous motion rather than a page load.
   -------------------------------------------------------------------------- */

.step[hidden] { display: none; }

.step.is-leaving {
    animation: stepOut 0.19s var(--ease) forwards;
}

.step.is-entering {
    animation: stepIn 0.42s var(--ease) both;
}

@keyframes stepOut {
    to { opacity: 0; transform: translateX(-14px); }
}

@keyframes stepIn {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* The address carried into step two, doubling as the way back. */
.identity-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    max-width: 100%;
    margin: 0 0 30px;
    padding: 8px 14px 8px 11px;
    font-family: var(--font-ui);
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-soft);
    background: var(--paper-2);
    border: 1px solid var(--hair);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.18s var(--ease),
                background 0.18s var(--ease),
                transform 0.18s var(--ease);
}

.identity-chip svg { flex: 0 0 auto; color: var(--text-faint); }

.identity-chip [data-identity-label] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.identity-chip .chip-change {
    flex: 0 0 auto;
    padding-left: 9px;
    margin-left: 2px;
    border-left: 1px solid var(--hair);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--navy-lift);
}

.identity-chip:hover {
    background: #fff;
    border-color: #CBD3E0;
    transform: translateY(-1px);
}

.identity-chip:focus-visible {
    outline: none;
    border-color: var(--navy-lift);
    box-shadow: 0 0 0 4px var(--lime-soft);
}

/* Arrow on the Continue button drifts forward on hover. */
.btn-arrow {
    transition: transform 0.22s var(--ease);
}

.btn-auth:hover .btn-arrow { transform: translateX(3px); }

.step[data-step="password"] .auth-title { margin-bottom: 18px; }

@media (prefers-reduced-motion: reduce) {
    .step.is-leaving,
    .step.is-entering { animation: none; }
    .identity-chip:hover { transform: none; }
    .btn-auth:hover .btn-arrow { transform: none; }
}

/* --------------------------------------------------------------------------
   Confirmation state (password reset sent)
   -------------------------------------------------------------------------- */

.success-badge {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 22px;
    border-radius: 14px;
    color: #16244C;
    background: linear-gradient(135deg, rgba(193, 205, 35, 0.30), rgba(193, 205, 35, 0.14));
    border: 1px solid rgba(193, 205, 35, 0.45);
    animation: badgeIn 0.5s var(--ease) both;
}

@keyframes badgeIn {
    from { opacity: 0; transform: scale(0.86); }
    to   { opacity: 1; transform: scale(1); }
}

.auth-note {
    margin: 0 0 28px;
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--text-faint);
}

.auth-note a { color: var(--navy-lift); font-weight: 600; text-decoration: none; }
.auth-note a:hover { text-decoration: underline; }

/* Secondary action — same shape as the primary button, quieter. */
.btn-auth-quiet {
    background: #fff;
    color: var(--navy);
    border: 1px solid var(--hair);
    box-shadow: none;
    text-decoration: none;
}

.btn-auth-quiet:hover {
    background: var(--paper-2);
    border-color: #CBD3E0;
    box-shadow: 0 6px 16px -10px rgba(22, 36, 76, 0.4);
}

.btn-auth-quiet::after { display: none; }

.text-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-weight: 500;
    text-decoration: none;
    transition: color 0.16s var(--ease);
}

.text-back:hover { color: var(--navy-lift); }

.auth-foot a { color: var(--navy-lift); font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Show / hide password
   -------------------------------------------------------------------------- */

.field-with-toggle { position: relative; }

.field-with-toggle input { padding-right: 48px; }

.reveal-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    transition: color 0.16s var(--ease), background 0.16s var(--ease);
}

.reveal-toggle:hover {
    color: var(--navy-lift);
    background: var(--paper-2);
}

.reveal-toggle:focus-visible {
    outline: none;
    color: var(--navy-lift);
    box-shadow: 0 0 0 3px var(--lime-soft);
}

/* Swap the icon to match the state: an open eye means "reveal", the struck
   through eye means "hide again". */
.reveal-toggle .icon-eye-off { display: none; }
.reveal-toggle.is-revealed .icon-eye { display: none; }
.reveal-toggle.is-revealed .icon-eye-off { display: block; }
.reveal-toggle.is-revealed { color: var(--navy-lift); }
