/* Redesign of the public pages: landing page and login (log in, sign up, recover, set password).
   Requires css/tokens.css; loaded after tscsso.css and login-morph-v1.css and overrides them. */

/* ------------------------------------------------------------------ Shared frame */
body.tsi-redesign:is(.landing-page, .login-page-v1) {
    --public-header: 64px;
    --public-card-padding: 32px;
    --public-wordmark: 72px;
}

body.tsi-redesign:is(.landing-page, .login-page-v1) .header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 3;
}

body.tsi-redesign .header .landing-login-link {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 18px;
    border-radius: 10px;
    background: #ffffff;
    color: var(--tsi-blue-dark);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

body.tsi-redesign .header .landing-login-link:hover {
    background: var(--tsi-tint);
}

body.tsi-redesign .header .landing-login-link:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

body.tsi-redesign:is(.landing-page, .login-page-v1) #md {
    margin-top: var(--public-header);
}

/* The stage fills the space below the header; the card sits in its centre. */
body.tsi-redesign:is(.landing-page, .login-page-v1) .bc-div {
    margin-top: 0;
    height: calc(100vh - var(--public-header));
}

body.tsi-redesign:is(.landing-page, .login-page-v1) .b-div {
    overflow: visible;
}

body.tsi-redesign:is(.landing-page, .login-page-v1) .c-div {
    padding: var(--public-card-padding);
    border: 1px solid var(--tsi-line);
    border-radius: var(--tsi-radius-hero);
    background: #ffffff;
    box-shadow: var(--tsi-shadow-raised);
    font-size: 16px;
}

body.tsi-redesign:is(.landing-page, .login-page-v1) #lpl {
    display: block;
    color: var(--tsi-blue);
    font-size: var(--public-wordmark);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    white-space: nowrap;
    text-decoration: none;
}

/* ------------------------------------------------------------------ Landing page */
/* The whole card is the link; the padding moves onto the link so the card keeps its size. */
body.tsi-redesign.landing-page .c-div {
    padding: 0;
    transition: translate 0.2s ease, box-shadow 0.2s ease;
}

body.tsi-redesign.landing-page #lpl {
    padding: var(--public-card-padding);
    border-radius: var(--tsi-radius-hero);
}

body.tsi-redesign.landing-page .c-div:hover {
    translate: 0 -3px;
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.05), 0 22px 48px -14px rgba(31, 41, 51, 0.22);
}

body.tsi-redesign.landing-page #lpl:focus-visible {
    outline: 3px solid var(--tsi-blue);
    outline-offset: 4px;
}

/* ------------------------------------------------------------------ Login card */
body.tsi-redesign .login-stage-v1 {
    --login-frame-width: min(440px, calc(100vw - 32px));
    --login-frame-radius: 20px;
}

body.tsi-redesign .login-frame-v1 {
    border-radius: var(--login-frame-radius);
}

body.tsi-redesign .login-frame-v1 #lpl {
    display: none;
}

/* Intro: the card first looks exactly like the landing page card, then grows into the form. */
.login-morph-v1-pending body.tsi-redesign .login-frame-v1 #lpl {
    display: block;
}

.login-morph-v1-pending body.tsi-redesign .login-frame-v1 #lsfwdiv {
    top: var(--public-card-padding);
    width: calc(var(--login-frame-width) - 2 * var(--public-card-padding) - 2px);
}

/* On short screens the card stays 24px below the header; normally it is centred. */
.login-morph-v1-ready body.tsi-redesign .login-frame-v1 {
    top: max(50%, calc(24px - (100vh - var(--public-header)) / 4 + var(--login-frame-height, 0px) / 2));
}

/* The legal links follow 24px below the card. */
.login-morph-v1-ready body.tsi-redesign #toupp {
    top: max(
        calc(50vh + var(--public-header) / 2 + var(--login-frame-height, 0px) / 2 + 24px),
        calc(var(--public-header) + 48px + var(--login-frame-height, 0px))
    );
}

body.tsi-redesign #lsfwdiv {
    color: var(--tsi-ink);
}

body.tsi-redesign .lsf-switch {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    padding: 4px;
    border-radius: var(--tsi-radius-button);
    background: var(--tsi-tint);
}

body.tsi-redesign .lsf-switch button {
    flex: 1;
    height: 44px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--tsi-muted);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

body.tsi-redesign .lsf-switch button[aria-pressed="true"] {
    background: #ffffff;
    color: var(--tsi-ink);
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.12), 0 1px 1px rgba(31, 41, 51, 0.06);
}

body.tsi-redesign #lsfwdiv [id^="lsfwd"] {
    width: 100%;
}

/* The old inset "notch" title becomes a plain heading. */
body.tsi-redesign .login-frame-v1 .lsfHeading {
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0 0 20px;
    padding: 0;
    border-radius: 0;
    background: none;
    color: var(--tsi-ink);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-align: left;
}

body.tsi-redesign .login-frame-v1 .lsfHeading::before,
body.tsi-redesign .login-frame-v1 .lsfHeading::after {
    content: none;
}

body.tsi-redesign .login-frame-v1 .lsfHeading:focus {
    outline: none;
}

body.tsi-redesign .lsf-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

body.tsi-redesign .lsf-field label {
    color: var(--tsi-ink);
    font-size: 14px;
    font-weight: 600;
}

body.tsi-redesign .lsf-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body.tsi-redesign .lsf-link,
body.tsi-redesign .lsf-back {
    border: 0;
    background: none;
    color: var(--tsi-blue);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

/* A larger touch target without moving the label row. */
body.tsi-redesign .lsf-link {
    margin: -12px -8px;
    padding: 12px 8px;
}

body.tsi-redesign :is(.lsf-link, .lsf-back):hover {
    color: var(--tsi-blue-dark);
    text-decoration: underline;
}

body.tsi-redesign .login-frame-v1 #lsfwdiv .lsfInput {
    width: 100%;
    height: 52px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--tsi-field);
    border-radius: var(--tsi-radius-field);
    background: #ffffff;
    box-shadow: none;
    color: var(--tsi-ink);
    font-size: 16px;
}

body.tsi-redesign .login-frame-v1 #lsfwdiv .lsfInput:focus {
    border-color: var(--tsi-blue);
    outline: none;
    box-shadow: 0 0 0 4px rgba(62, 105, 148, 0.2);
}

body.tsi-redesign .login-frame-v1 #lsfwdiv .lsfInput[aria-invalid="true"] {
    border-color: var(--tsi-danger);
}

body.tsi-redesign .lsf-password {
    position: relative;
}

body.tsi-redesign .login-frame-v1 #lsfwdiv .lsf-password .lsfInput {
    padding-right: 56px;
}

body.tsi-redesign .lsf-reveal {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tsi-muted);
    cursor: pointer;
}

body.tsi-redesign .lsf-reveal:hover {
    background: var(--tsi-tint);
    color: var(--tsi-ink);
}

body.tsi-redesign :is(.lsf-reveal, .lsf-back) svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.tsi-redesign .lsf-reveal .lsf-eye-off,
body.tsi-redesign .lsf-reveal[aria-pressed="true"] .lsf-eye {
    display: none;
}

body.tsi-redesign .lsf-reveal[aria-pressed="true"] .lsf-eye-off {
    display: block;
}

body.tsi-redesign .lsf-hint {
    margin: 0;
    color: var(--tsi-muted);
    font-size: 13px;
}

/* Status and error messages sit directly above the button. */
body.tsi-redesign .login-frame-v1 .lsfinfo {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: var(--tsi-radius-field);
    background: var(--tsi-tint);
    color: var(--tsi-ink);
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
}

body.tsi-redesign .login-frame-v1 .lsfinfo[role="alert"] {
    background: var(--tsi-danger-tint);
    color: var(--tsi-danger);
}

body.tsi-redesign .login-frame-v1 .lsfinfo:focus {
    outline: none;
}

body.tsi-redesign .lsfInlineRetry {
    margin: 8px 0 0;
    padding: 6px 10px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: #ffffff;
    color: inherit;
    font-weight: 600;
}

body.tsi-redesign .login-frame-v1 .lsfButton {
    position: relative;
    display: block;
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--tsi-radius-button);
    background: var(--tsi-blue);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

body.tsi-redesign .login-frame-v1 .lsfButton:hover {
    background: var(--tsi-blue-dark);
}

/* Loading: the button is disabled and shows a small spinner instead of the GIF. */
body.tsi-redesign #lsfwdiv[aria-busy="true"] .lsfButton {
    opacity: 1;
    color: transparent;
    cursor: wait;
    background: var(--tsi-blue) var(--tsi-spinner-light) center / 22px 22px no-repeat;
}

body.tsi-redesign.login-page-v1 #dsli {
    display: none;
}

body.tsi-redesign .lsf-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 12px auto 0;
    padding: 0 8px;
}

body.tsi-redesign #lsfwd2 .lsf-back {
    display: flex;
}

body.tsi-redesign button:disabled {
    cursor: default;
}

/* ------------------------------------------------------------------ Legal links */
body.tsi-redesign #toupp {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
    color: var(--tsi-muted);
    font-size: 14px;
    font-weight: 600;
}

body.tsi-redesign #toupp a {
    padding: 10px 0;
    color: var(--tsi-muted);
}

body.tsi-redesign #toupp a:hover {
    color: var(--tsi-ink);
    text-decoration: underline;
}

body.tsi-redesign #toupp a:focus-visible {
    outline: 3px solid var(--tsi-blue);
    outline-offset: 2px;
}

body.tsi-redesign .lsfNoscript {
    color: var(--tsi-danger);
}

/* ------------------------------------------------------------------ Phones */
@media (max-width: 767px) {
    body.tsi-redesign:is(.landing-page, .login-page-v1) {
        --public-header: 60px;
        --public-card-padding: 24px;
        --public-wordmark: 40px;
    }
    body.tsi-redesign:is(.landing-page, .login-page-v1) .header {
        padding: 0 16px;
    }
}

@media (max-width: 359px) {
    body.tsi-redesign:is(.landing-page, .login-page-v1) {
        --public-wordmark: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.tsi-redesign.landing-page .c-div {
        transition: none;
    }
    body.tsi-redesign.landing-page .c-div:hover {
        translate: none;
    }
}
