/*
 * Identity: sign-up and sign-in, the recovery code, the profile, the account's
 * cards, and pairing.
 */


/* --- forms ------------------------------------------------------------------ */

.stack input {
    padding: 0 .65rem;
}

.code {
    max-width: 26rem;
    padding: .9rem 1rem;
    font-family: var(--mono);
    font-size: 1.15rem;
    letter-spacing: .06em;
    word-break: break-all;
    border: 1px solid var(--muted);
    border-radius: var(--radius);
}


/* --- sign-up and sign-in ---------------------------------------------------- */

main.entry {
    max-width: 30rem;
    padding-top: 3.5rem;

    h1 {
        margin: 0 0 .35rem;
    }

    .lede {
        margin: 0;
    }

    hr {
        width: 100%;
        margin: 0;
        border: 0;
        border-top: 1px solid var(--edge);
    }
}

.handle-row {
    display: flex;
    gap: .5rem;

    .at {
        display: inline-flex;
        align-items: center;
        padding: 0 .65rem;
        font-family: var(--mono);
        color: var(--muted);
        background: var(--inset);
        border: 1px solid var(--edge);
        border-radius: var(--radius);
    }

    input {
        flex: 1;
        min-width: 0;
        font-family: var(--mono);
        letter-spacing: .02em;
    }

    .suggest {
        flex: none;
        width: 40px;
        padding: 0;
        color: var(--muted);

        svg {
            width: 18px;
            height: 18px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
        }
    }
}

button.wide,
a.button.wide {
    width: 100%;
    height: 44px;
}

button .icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* The recovery code under the passkey button, for a device without one. */
.entry .fallback {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .9rem;
    background: var(--inset);
    border: 1px solid var(--edge);
    border-radius: var(--radius);

    input {
        font-family: var(--mono);
        letter-spacing: .02em;
    }
}

.copyable.large {
    height: auto;
    padding: .6rem .6rem .6rem 1rem;

    .code {
        flex: 1;
        margin: 0;
        padding: 0;
        border: 0;
        font-size: 1.15rem;
    }
}


/* --- profile and account pages ---------------------------------------------- */

/* One card per concern, each with its heading and, where it has one, its action. */
.cards {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--card);
    border: 1px solid var(--edge);
    border-radius: var(--radius);

    > header {
        display: flex;
        align-items: center;
        gap: .75rem;
        flex-wrap: wrap;

        > div {
            display: flex;
            flex-direction: column;
            gap: 2px;
            flex: 1;
            min-width: 14rem;
        }
    }

    h2 {
        margin: 0;
        font-size: 1.05rem;
    }

    label,
    fieldset {
        display: flex;
        flex-direction: column;
        gap: .35rem;
        margin: 0;
        padding: 0;
        border: 0;
    }

    input[type=text],
    textarea {
        width: 100%;
    }

    textarea {
        padding: .6rem .75rem;
        font: inherit;
        color: var(--text);
        background: var(--inset);
        border: 1px solid var(--edge);
        border-radius: var(--radius);
        resize: vertical;
    }

    .hint {
        margin: 0;
        font-size: .8rem;
    }
}

.two-up {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
}

.field {
    font-weight: 600;
    font-size: .9rem;
}

.optional {
    margin-left: .4rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--faint);
}

.colours {
    display: flex;
    gap: .75rem;
}

/* A radio drawn as its colour; the ring marks the chosen one. */
.swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--colour);
    cursor: pointer;

    input {
        appearance: none;
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 50%;
        cursor: pointer;

        &:checked {
            box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #ffffff;
        }

        &:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 4px;
        }
    }
}

.card .handle {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    font-family: var(--mono);
    color: var(--muted);

    input {
        max-width: 18rem;
        font-family: var(--mono);
        letter-spacing: .02em;
    }
}

/* --- the picture ----------------------------------------------------------- */

main.profile > .picture {
    margin-bottom: 1.25rem;
}

.picture form {
    margin: 0;
}

.cropper {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: flex-start;

    .stage {
        position: relative;
        flex: 1;
        min-width: 14rem;
        max-width: 26rem;
        line-height: 0;
        user-select: none;

        /* Clips the square's dimming shadow to the picture. */
        overflow: hidden;

        img {
            width: 100%;
            height: auto;
        }
    }

    /* What is outside the square is dimmed by the square's own shadow. */
    .square {
        position: absolute;
        box-sizing: border-box;
        border: 2px solid #ffffff;
        box-shadow: 0 0 0 9999px rgb(0 0 0 / .55);
        cursor: move;
        touch-action: none;
    }

    .resize {
        position: absolute;
        right: 2px;
        bottom: 2px;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #ffffff;
        cursor: nwse-resize;
    }

    .preview {
        display: flex;
        flex-direction: column;
        gap: .75rem;

        canvas {
            width: 96px;
            height: 96px;
            border-radius: 50%;
            background: var(--inset);
        }
    }
}

.controls.end {
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .two-up {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* --- pairing ---------------------------------------------------------------- */

/* The page's own parts only, by `>`: the account head above them keeps its own
   spacing, as it has on every account page. */
main.pair {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;

    > .account-head {
        margin-bottom: 0;
    }

    > .lede {
        margin: 0;
    }
}

/* On a computer the code leads and opening the app here is pointless; on a phone,
   the other way round. */
.pair .here {
    display: none;
}

.pair .offer {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2rem;
}

.pair .scan {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    width: 240px;

    canvas {
        border-radius: var(--radius);
    }
}

.pair .expiry {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .8rem;
    color: var(--muted);

    .when {
        display: flex;
        gap: .4rem;

        a {
            margin-left: auto;
            color: var(--muted);
        }
    }

    .remaining {
        font-family: var(--mono);
        color: var(--text);
    }

    .bar {
        height: 3px;
        border-radius: 2px;
        background: var(--track);
        overflow: hidden;

        > div {
            height: 100%;
            background: var(--accent);
        }
    }
}

.pair .steps {
    flex: 1;
    min-width: 16rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;

    ol {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    li {
        display: flex;
        gap: .75rem;

        > span:last-child {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }
    }

    .number {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: none;
        width: 26px;
        height: 26px;
        border-radius: 50%;
        font-size: .8rem;
        font-weight: 700;
        background: var(--track);
    }

    summary {
        cursor: pointer;
        font-weight: 600;
    }
}

.pair .manual {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .5rem .75rem;
    margin: .75rem 0 .5rem;
}

.copyable {
    display: flex;
    align-items: center;
    gap: .5rem;
    height: 40px;
    padding: 0 6px 0 12px;
    font-family: var(--mono);
    letter-spacing: .06em;
    background: var(--inset);
    border: 1px solid var(--edge);
    border-radius: var(--radius);

    span {
        flex: 1;
        overflow-wrap: anywhere;
    }

    button {
        font-family: var(--font);
        letter-spacing: normal;
    }
}

.pair .status {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .75rem .9rem;
    font-size: .9rem;
    border: 1px solid var(--edge);
    border-radius: var(--radius);

    .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--warn);
    }

    .hint {
        margin-left: auto;
    }

    &.paired {
        background: rgb(48 209 88 / .08);
        border-color: rgb(48 209 88 / .4);

        .dot {
            background: var(--ok);
        }
    }

    &.expired .dot {
        background: var(--faint);
    }
}

@media (max-width: 640px) {
    .pair .here {
        display: flex;
    }

    .pair .here .button {
        height: 48px;
    }

    .pair .scan canvas {
        display: none;
    }
}


/* --- account cards ---------------------------------------------------------- */

.card .rows {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;

    li {
        display: flex;
        align-items: center;
        gap: .75rem;
        min-height: 52px;
        border-top: 1px solid var(--edge);
    }

    .glyph {
        display: flex;
        color: var(--muted);

        svg {
            width: 18px;
            height: 18px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
        }
    }

    .text {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-width: 0;
        flex: 1;
    }

    .title {
        display: flex;
        align-items: center;
        gap: .5rem;
        font-weight: 600;
        overflow-wrap: anywhere;

        .badge {
            flex: none;
            white-space: nowrap;
        }
    }

    form {
        margin: 0;
    }
}

.card header form {
    margin: 0;
}

.card.danger {
    border-color: rgb(255 0 53 / .35);

    h2 {
        color: var(--accent);
    }
}

/* A single checkbox with its label beside it rather than above. */
.card label.check {
    flex-direction: row;
    align-items: center;
    gap: .6rem;
}
