/* The COS sign-in page shared with FSM and Wholesale Engine (BE-4021): one centered card on a page-wide scene of
   the product being signed in to. A port of their x-layouts.auth, x-auth.product-picker and x-auth.sso-buttons,
   with the Tailwind and Flux classes they use written out here. The scenes move only transform and opacity, of
   small HTML layers, with no SMIL, blur or filter, which a browser would repaint on every frame. */

:root {
    --cos-green: oklch(0.72 0.14 160);
    --cos-mint: oklch(0.91 0.05 160);
    --cos-teal: oklch(0.50 0.10 190);
    --cos-ink: oklch(0.14 0.020 260);
    --cos-zinc-50: oklch(0.98 0.004 180);
    --cos-zinc-100: oklch(0.96 0.006 190);
    --cos-zinc-200: oklch(0.92 0.008 200);
    --cos-zinc-400: oklch(0.70 0.015 230);
    --cos-zinc-500: oklch(0.55 0.018 245);
    --cos-zinc-600: oklch(0.45 0.020 250);
    --cos-zinc-700: oklch(0.35 0.022 255);
    --cos-zinc-800: oklch(0.26 0.025 258);
    --cos-zinc-900: oklch(0.22 0.028 260);

    --card: #fff;
    --card-text: var(--cos-zinc-900);
    --card-muted: var(--cos-zinc-500);
    --card-line: var(--cos-zinc-200);
    --control: #fff;
    --control-hover: var(--cos-zinc-50);
    --segment-track: var(--cos-zinc-100);
    --segment-on: #fff;
    --primary: var(--cos-zinc-800);
    --primary-text: #fff;
    --danger-bg: oklch(0.97 0.02 25);
    --danger-text: oklch(0.50 0.19 25);
}

@media (prefers-color-scheme: dark) {
    :root {
        --card: var(--cos-zinc-900);
        --card-text: #fff;
        --card-muted: var(--cos-zinc-400);
        --card-line: color-mix(in oklab, #fff 12%, transparent);
        --control: color-mix(in oklab, #fff 6%, transparent);
        --control-hover: color-mix(in oklab, #fff 10%, transparent);
        --segment-track: color-mix(in oklab, #fff 8%, transparent);
        --segment-on: var(--cos-zinc-700);
        --primary: #fff;
        --primary-text: var(--cos-zinc-900);
        --danger-bg: color-mix(in oklab, oklch(0.60 0.19 25) 18%, transparent);
        --danger-text: oklch(0.80 0.11 25);
    }
}

* { box-sizing: border-box; }

.cos-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

body.cos-sign-in {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--cos-ink);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--card-text);
}

/* ---- The scenes ---- */

@keyframes cos-spin { to { transform: rotate(360deg); } }
@keyframes cos-scan { from { transform: rotate(-70deg); } to { transform: rotate(70deg); } }
@keyframes cos-ping {
    0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
    2% { opacity: .9; }
    14% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(2.8); opacity: 0; }
}
@keyframes cos-glint { 0%, 14%, 100% { opacity: .08; } 5% { opacity: .7; } }
.cos-spin { animation: cos-spin var(--duration) linear infinite; }
.cos-scan { animation: cos-scan var(--duration) linear infinite alternate; }
.cos-ping { animation: cos-ping var(--duration) ease-out infinite var(--delay); }
.cos-glint { animation: cos-glint var(--duration) ease-in-out infinite var(--delay); }
@media (prefers-reduced-motion: reduce) {
    .cos-scenes * { animation: none !important; }
    .cos-ping { opacity: 0; }
}

/* Moving parts are small HTML layers over a scene's SVG, never shapes animated inside it: a browser repaints an
   SVG whose content moves, on the main thread, while a small layer that only changes transform or opacity is
   moved by the compositor. A layer stage has the scene's 1600 x 1000 shape; --u is one SVG unit. Each layer rests
   invisible, or at its SVG look, so reduced motion (animation: none) shows the still map. */
.cos-layers {
    position: absolute;
    inset: 0;
    container-type: inline-size;
}
.cos-layers > * {
    --u: calc(100cqw / 1600);
    position: absolute;
    left: 0;
    top: 0;
}

/* Enterprise: a link that lights in turn. Placed at its first site and turned towards the second; the round caps
   reach one unit past both ends, as the SVG stroke did. */
.cos-en-link {
    height: calc(2 * var(--u));
    margin: calc(-1 * var(--u)) 0 0 calc(-1 * var(--u));
    transform-origin: var(--u) 50%;
    border-radius: 9999px;
    background: var(--cos-mint);
    opacity: .08;
    will-change: opacity;
}

/* FSM: the road driven so far is a bar per street, growing from its corner as the technician drives it, in a
   route that fades as a whole (so the overlaps at the corners do not show). */
.cos-fsm-route { opacity: 0; will-change: opacity; }
.cos-fsm-route > i {
    position: absolute;
    height: calc(3 * var(--u));
    margin: calc(-1.5 * var(--u)) 0 0 calc(-1.5 * var(--u));
    transform-origin: calc(1.5 * var(--u)) 50%;
    border-radius: 9999px;
    background: var(--cos-green);
    will-change: transform;
}
.cos-fsm-done, .cos-fsm-ripple, .cos-fsm-technician { border-radius: 9999px; opacity: 0; }
.cos-fsm-done {
    width: calc(14 * var(--u));
    height: calc(14 * var(--u));
    margin: calc(-7 * var(--u)) 0 0 calc(-7 * var(--u));
    background: var(--cos-green);
    will-change: opacity;
}
/* A ring of radius 14 scaled from 7 to 26, as the SVG ripple's r went. */
.cos-fsm-ripple {
    width: calc(28 * var(--u));
    height: calc(28 * var(--u));
    margin: calc(-14 * var(--u)) 0 0 calc(-14 * var(--u));
    border: calc(2 * var(--u)) solid var(--cos-mint);
    will-change: transform, opacity;
}
.cos-fsm-technician {
    width: calc(36 * var(--u));
    height: calc(36 * var(--u));
    margin: calc(-18 * var(--u)) 0 0 calc(-18 * var(--u));
    background: radial-gradient(circle closest-side,
        var(--cos-green) calc(3.5 * var(--u)), #fff calc(3.5 * var(--u)) calc(7 * var(--u)),
        color-mix(in oklab, var(--cos-green) 20%, transparent) calc(7 * var(--u)));
    will-change: transform, opacity;
}

/* Wholesale Engine: the light running along a fiber, 6% of its length, with a faint wider glow under it. The
   layer's transform carries it along the curve; it rests hidden. */
.cos-we-pulse {
    height: calc(2 * var(--u));
    margin-top: calc(-1 * var(--u));
    transform-origin: 0 50%;
    opacity: 0;
    will-change: transform, opacity;
}
.cos-we-pulse::before, .cos-we-pulse::after {
    content: "";
    position: absolute;
    border-radius: 9999px;
}
.cos-we-pulse::before { inset: calc(-2.5 * var(--u)); background: var(--cos-green); opacity: .3; }
.cos-we-pulse::after { inset: 0 calc(-1 * var(--u)); background: var(--cos-mint); }
/* The feeder's light is one 3-unit stroke, with no glow. */
.cos-we-pulse--feeder { height: calc(3 * var(--u)); margin-top: calc(-1.5 * var(--u)); }
.cos-we-pulse--feeder::before { content: none; }
.cos-we-pulse--feeder::after { inset: 0 calc(-1.5 * var(--u)); }

/* A hidden scene holds still (Login.cshtml pauses its SMIL). */
.cos-scene[data-hidden] * { animation-play-state: paused !important; }

.cos-fill-green { fill: var(--cos-green); }
.cos-fill-mint { fill: var(--cos-mint); }
.cos-fill-ink { fill: var(--cos-ink); }
.cos-stroke-green { stroke: var(--cos-green); }
.cos-stroke-mint { stroke: var(--cos-mint); }
.cos-stroke-teal { stroke: var(--cos-teal); }

/* The scene covers the page at 16:10 and crops to any other shape, so a scene can place HTML layers by percentage
   over its 1600 x 1000 SVG. */
.cos-scenes {
    pointer-events: none;
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: var(--cos-ink);
    container-type: size;
    contain: strict;
}
.cos-scenes__stage {
    position: absolute;
    top: 50%;
    left: 50%;
    width: max(100cqw, 160cqh);
    height: max(100cqh, 62.5cqw);
    transform: translate(-50%, -50%);
}
.cos-scene {
    position: absolute;
    inset: 0;
    opacity: 1;
    transition: opacity .7s, visibility .7s;
}
.cos-scene[data-hidden] { opacity: 0; visibility: hidden; }

/* A darker field behind the card and at the edges keeps the card legible and the scene's motion at the edges of
   the eye. */
.cos-scenes__veil {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 40% 55% at center, color-mix(in oklab, var(--cos-ink) 70%, transparent), transparent),
        radial-gradient(ellipse at center, transparent 60%, color-mix(in oklab, var(--cos-ink) 75%, transparent));
}

.cos-fill { position: absolute; inset: 0; width: 100%; height: 100%; }

.cos-be-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 115%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    container-type: inline-size;
}
/* A subscriber: a small dot turned about the stage's center at angle --a and distance --r. It rests at its angle
   when motion is reduced. */
@keyframes cos-orbit {
    from { transform: rotate(var(--a)) translateY(calc(-1 * var(--r))); }
    to { transform: rotate(calc(var(--a) + 360deg)) translateY(calc(-1 * var(--r))); }
}
.cos-be-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--s);
    height: var(--s);
    margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
    border-radius: 9999px;
    background: var(--cos-mint);
    transform: rotate(var(--a)) translateY(calc(-1 * var(--r)));
    animation: cos-orbit var(--duration) linear infinite;
}
.cos-be-dot--green { background: var(--cos-green); }
/* The sweep is only the stage's top-left quarter, turned about its corner at the center. The visible wedge spans
   -40deg..0deg, which lies inside that quarter. A stage-sized turning layer made Firefox repaint the whole screen
   every frame (3-5% CPU at rest); a quarter-sized one invalidates only what the wedge crosses. */
.cos-be-sweep {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 50%;
    border-top-left-radius: 100%;
    transform-origin: 100% 100%;
    background: conic-gradient(from -40deg at 100% 100%, transparent, color-mix(in oklab, var(--cos-green) 20%, transparent) 40deg, transparent 40.3deg);
}
.cos-be-hand {
    position: absolute;
    top: 10.8%;
    left: 100%;
    width: 1px;
    height: 89.2%;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, color-mix(in oklab, var(--cos-mint) 60%, transparent), transparent);
}

/* The beam is only the box around its wedge (-12deg..12deg, 1150 units long), turned about its bottom center, the
   origin at (800, 1080). Like the Business Engine sweep, a turning layer twice the stage's size made Firefox repaint
   the whole screen every frame. The box's top corners reach about 25 units past the beam's length, where the wedge
   has faded to under 2%. */
.cos-pr-beam {
    position: absolute;
    top: -7%;
    left: 35%;
    width: 30%;
    height: 115%;
    transform-origin: 50% 100%;
    will-change: transform;
    background: conic-gradient(from -12deg at 50% 100%, transparent, color-mix(in oklab, var(--cos-green) 22%, transparent) 12deg, transparent 24deg);
}
.cos-pr-beam-edge {
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
    background: linear-gradient(to top, transparent, color-mix(in oklab, var(--cos-mint) 40%, transparent));
}
.cos-pr-ping {
    position: absolute;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: 2px solid var(--cos-mint);
    opacity: 0;
}

/* ---- The card ---- */

/* The card's top sits where a centered card's would, so a choice that changes the card's height grows it downward
   and nothing jumps. The card holds a password form, so it starts higher. */
.cos-sign-in__main {
    position: relative;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: max(2.5rem, calc(50dvh - 22rem)) 1rem 2.5rem;
}

.cos-card {
    width: 100%;
    min-width: 0;
    max-width: 28rem;
    padding: 1.5rem;
    border-radius: .75rem;
    background: var(--card);
    color: var(--card-text);
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / .4);
}
.cos-card--wide { max-width: 36rem; }
@media (min-width: 640px) { .cos-card { padding: 2rem; } }

.cos-card__head { display: flex; align-items: center; gap: .75rem; }
.cos-card__name { min-width: 0; }
.cos-card__logo { width: 2.75rem; height: 2.75rem; flex-shrink: 0; border-radius: .75rem; }
.cos-card__title {
    margin: 0;
    font-family: Cairo, Inter, system-ui, sans-serif;
    font-size: 1.5rem;
    line-height: 1.25;
    font-weight: 700;
}
.cos-card__organization {
    margin: 0;
    overflow: hidden;
    font-size: .875rem;
    color: var(--card-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cos-card__body { display: flex; flex-direction: column; gap: 2rem; margin-top: 2rem; }

.cos-badge {
    display: inline-flex;
    align-items: center;
    padding: .125rem .375rem;
    border-radius: .375rem;
    font-size: .75rem;
    font-weight: 500;
    line-height: 1rem;
    white-space: nowrap;
}
.cos-badge--environment { margin-inline-start: auto; }
.cos-badge--green { background: oklch(0.96 0.04 160); color: oklch(0.45 0.10 160); }
.cos-badge--amber { background: oklch(0.96 0.05 85); color: oklch(0.50 0.11 70); }
.cos-badge--zinc { background: var(--cos-zinc-100); color: var(--cos-zinc-600); }
@media (prefers-color-scheme: dark) {
    .cos-badge--green { background: color-mix(in oklab, var(--cos-green) 20%, transparent); color: var(--cos-mint); }
    .cos-badge--amber { background: color-mix(in oklab, oklch(0.80 0.15 80) 20%, transparent); color: oklch(0.88 0.12 85); }
    .cos-badge--zinc { background: color-mix(in oklab, #fff 10%, transparent); color: var(--cos-zinc-200); }
}

/* The product picker: segments do not wrap; on a screen too narrow for all of them it scrolls sideways inside the
   card instead of widening the page. */
.cos-picker { margin: 0 -.25rem; padding: 0 .25rem; overflow-x: auto; scrollbar-width: none; }
.cos-picker__track {
    display: flex;
    width: max-content;
    min-width: 100%;
    gap: 2px;
    padding: 3px;
    border: 0;
    margin: 0;
    border-radius: .625rem;
    background: var(--segment-track);
}
.cos-picker__segment { position: relative; flex: 1; }
.cos-picker__segment input { position: absolute; opacity: 0; pointer-events: none; }
.cos-picker__segment label {
    display: block;
    padding: .4375rem .75rem;
    border-radius: .5rem;
    font-size: .875rem;
    font-weight: 500;
    text-align: center;
    color: var(--card-muted);
    white-space: nowrap;
    cursor: pointer;
}
.cos-picker--small .cos-picker__segment label { padding: .3125rem .5rem; font-size: .8125rem; }
.cos-picker__segment input:checked + label { background: var(--segment-on); color: var(--card-text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.cos-picker__segment input:focus-visible + label { outline: 2px solid var(--cos-green); outline-offset: 1px; }

.cos-callout {
    margin: 0;
    padding: .75rem 1rem;
    border-radius: .5rem;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: .875rem;
}

.cos-sso { display: flex; flex-direction: column; gap: .75rem; }
.cos-sso__button {
    position: relative;
    display: flex;
    width: 100%;
    height: 3rem;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    border: 1px solid var(--card-line);
    border-radius: .5rem;
    background: var(--control);
    color: var(--card-text);
    font: inherit;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.cos-sso__button:hover { background: var(--control-hover); color: var(--card-text); }
.cos-sso__button:focus-visible { outline: 2px solid var(--cos-green); outline-offset: 2px; }
.cos-sso__button svg, .cos-sso__button img { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.cos-sso__last { position: absolute; inset-inline-end: .75rem; top: 50%; transform: translateY(-50%); }
.cos-sso__last[hidden] { display: none; }
/* Three columns keep the label centred while there is room, and push it aside rather than under the badge when there is not. */
.cos-sso__button--provider { display: grid; grid-template-columns: 1fr auto 1fr; padding-inline: .75rem; }
.cos-sso__label { grid-column: 2; display: inline-flex; align-items: center; gap: .625rem; white-space: nowrap; }
.cos-sso__button--provider .cos-sso__last { grid-column: 3; justify-self: end; position: static; transform: none; margin-inline-start: .5rem; }

.cos-separator { display: flex; align-items: center; gap: .75rem; color: var(--card-muted); font-size: .875rem; }
.cos-separator::before, .cos-separator::after { content: ""; flex: 1; height: 1px; background: var(--card-line); }
.cos-rule { height: 1px; background: var(--card-line); }

.cos-password { display: flex; flex-direction: column; gap: 1.5rem; }
.cos-password[hidden] { display: none; }
.cos-form { display: flex; flex-direction: column; gap: 1.25rem; }
.cos-field { display: flex; flex-direction: column; gap: .75rem; }
.cos-field label { font-size: .875rem; font-weight: 500; }
.cos-field input {
    width: 100%;
    height: 2.5rem;
    padding: 0 .75rem;
    border: 1px solid var(--card-line);
    border-radius: .5rem;
    background: var(--control);
    color: var(--card-text);
    font: inherit;
    font-size: 1rem;
}
.cos-field input:focus { outline: 2px solid var(--cos-green); outline-offset: 0; border-color: transparent; }
.cos-link { align-self: flex-end; color: var(--card-muted); font-size: .875rem; }
.cos-link:hover { color: var(--card-text); }

.cos-submit {
    width: 100%;
    height: 2.5rem;
    border: 0;
    border-radius: .5rem;
    background: var(--primary);
    color: var(--primary-text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}
.cos-submit:disabled { opacity: .7; cursor: progress; }

/* Signing in: a spinner on the clicked button until the next page arrives. */
.cos-submit[aria-busy="true"] { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; cursor: progress; }
.cos-sso__button[aria-busy="true"] { cursor: progress; }
.cos-sso__button[aria-busy="true"] .cos-sso__last { display: none; }
.cos-submit[aria-busy="true"]::before,
.cos-sso__button[aria-busy="true"]::after {
    content: "";
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 9999px;
    animation: cos-spin .7s linear infinite;
}
.cos-sso__button[aria-busy="true"]::after { position: absolute; inset-inline-end: .875rem; top: 50%; margin-top: -.5rem; }

.cos-help { display: flex; flex-direction: column; gap: 1rem; }
.cos-help p { margin: 0; color: var(--card-muted); font-size: .875rem; text-align: center; }

.cos-footer { color: var(--cos-zinc-400); font-size: .875rem; text-align: center; }
.cos-footer p { margin: 0; }
.cos-footer a { color: var(--cos-zinc-400); }
