/*
 * verify.blockstream.com (Genuine Check), dark rebrand.
 * Source: Figma "Verify" section + designer handoff.
 *
 * The page is a single layout; which parts are visible is driven by
 * <body data-state="..."> (setState() in js/jade.js). Every element that
 * belongs to a screen carries data-for="state1 state2 ...".
 */

/* ---- Fonts (self-hosted, latin subset; SIL OFL, see fonts/*-OFL.txt) ----- */
/* Manrope is a variable font: one file covers weights 400 and 500 */
@font-face {
    font-family: Manrope;
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url("../fonts/manrope-latin.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/jetbrains-mono-latin-400.woff2") format("woff2");
}

/* ---- Tokens (Blockstream Design System, Color = Dark) ------------------ */
:root {
    --color-bg-canvas: #121e29;
    --color-text-primary: #fff;
    --color-text-secondary: #c5d0dd;
    --color-action-primary: #0066cd;
    --color-action-primary-text: #fff;
    --color-bg-glass: rgba(255, 255, 255, 0.08);
    --color-border-outline: #fff;

    --font-family-content: Manrope, system-ui, sans-serif;
    --font-family-ui: "JetBrains Mono", ui-monospace, monospace;

    --size-h1: 56px;
    --size-p1: 22px;
    --size-p2: 18px;
    --size-ui1: 16px;

    --button-padding-x: 40px;
    --button-padding-y: 17px;
}

@media (max-width: 1180px) {
    :root {
        --size-h1: 44px;
        --size-p1: 20px;
    }
}

@media (max-width: 900px) {
    :root {
        --size-h1: 32px;
        --size-p1: 18px;
        --size-p2: 16px;
    }
}

/* ---- Base --------------------------------------------------------------- */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--color-bg-canvas);
    color: var(--color-text-primary);
    font-family: var(--font-family-content);
    -webkit-font-smoothing: antialiased;
}

main {
    min-height: 100vh;
    overflow-x: clip;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
}

.layout {
    width: 100%;
    max-width: 1280px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

/* ---- Copy column -------------------------------------------------------- */
.copy {
    flex: 0 1 600px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.logo {
    align-self: flex-start;
}

.logo img {
    display: block;
    width: 200px;
    height: auto;
}

h1 {
    margin: 0;
    font-weight: 500;
    font-size: var(--size-h1);
    line-height: 1.4;
    letter-spacing: -0.01em;
}

h1 em {
    font-style: normal;
    color: var(--color-action-primary);
}

.sub {
    margin: 0;
    font-size: var(--size-p1);
    line-height: 1.55;
    color: var(--color-text-secondary);
}

.note {
    margin: 0;
    font-size: var(--size-p2);
    line-height: 1.55;
    color: var(--color-text-secondary);
}

/* error reason: only takes space when there is one */
.note:empty {
    display: none;
}

/* ---- Actions row (Figma "CTA"): padding-top 16, buttons 20 apart --------- */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 16px;
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 0;
    height: 56px;
    padding: var(--button-padding-y) var(--button-padding-x);
    font: 400 var(--size-ui1) / 1.4 var(--font-family-ui);
    color: var(--color-action-primary-text);
    background: var(--color-action-primary);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: filter 0.15s ease;
}

.btn:hover {
    filter: brightness(1.12);
}

.btn:focus-visible,
.logo:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.btn.outline {
    background: var(--color-bg-glass);
    box-shadow: inset 0 0 0 1px var(--color-border-outline);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Spinner: 36px, a single 270deg arc, 1.3 stroke, no track */
.spinner {
    display: block;
    width: 36px;
    height: 36px;
    margin-top: 16px;
}

.spinner circle {
    fill: none;
    stroke: var(--color-action-primary);
    stroke-width: 1.3;
    stroke-dasharray: 81.8 200; /* 270deg of r 17.35 */
    transform-origin: 50% 50%;
    animation: spin 1s linear infinite;
}

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

/* ---- Art column: 640 x 600 box ------------------------------------------ */
.art {
    position: relative;
    flex: 0 1 640px;
    min-width: 0;
    aspect-ratio: 640 / 600;
}

.slot {
    position: absolute;
    inset: 0;
}

/* animated state art: <object> so the SVG's own script runs */
.slot object,
.slot object > img {
    display: block;
    width: 100%;
    height: 100%;
}

/* Landing art: render 560 wide on the art box's right edge, rings (10%)
   centred on the render */
.slot .rings {
    position: absolute;
    left: 56.25%;
    top: 50%;
    width: 118.25%;
    transform: translate(-50%, -50%);
    opacity: 0.1;
    pointer-events: none;
    user-select: none;
}

.slot .render {
    position: absolute;
    right: 0;
    top: 50%;
    width: 87.5%;
    transform: translateY(-50%);
}

/* ---- Screen switching ---------------------------------------------------- */
.state {
    flex-direction: column;
    gap: 24px;
}

.state,
.actions > [data-for] {
    animation: state-in 0.28s ease both;
}

[data-for] {
    display: none;
}

body[data-state="landing"] [data-for~="landing"],
body[data-state="unsupported"] [data-for~="unsupported"],
body[data-state="connecting"] [data-for~="connecting"],
body[data-state="authenticating"] [data-for~="authenticating"],
body[data-state="genuine"] [data-for~="genuine"],
body[data-state="not-genuine"] [data-for~="not-genuine"],
body[data-state="error"] [data-for~="error"],
body[data-state="canceled"] [data-for~="canceled"],
body[data-state="disconnected"] [data-for~="disconnected"] {
    display: flex;
}

/* the landing art slot holds absolutely positioned images */
body[data-state="landing"] .slot[data-for~="landing"],
body[data-state="unsupported"] .slot[data-for~="unsupported"] {
    display: block;
}

@keyframes state-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ---- Small screens: art stacks above the copy --------------------------- */
@media (max-width: 900px) {
    main {
        align-items: flex-start;
        padding: 40px 16px 120px;
    }

    .layout {
        flex-direction: column-reverse;
        gap: 24px;
    }

    .art {
        width: 100%;
        max-width: 480px;
        flex: 0 0 auto;
        margin: 0 auto;
    }

    .copy {
        width: 100%;
        flex: 0 0 auto;
    }

    .logo img {
        width: 160px;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .state,
    .actions > [data-for] {
        animation: none;
    }

    .spinner circle {
        animation: none;
    }
}
