/* ==========================================================================
   Gratienne — the couple's panel: signing in

   On one side a photograph of what the couple bought, square and unframed.
   On the other the words and the form, set on
   the page itself, with no box around them: one column, hairline fields, six
   sockets for the code and a button that is a line. Tokens are site.css's.
   ========================================================================== */

/* ---------------------------------------------------------------- 1. Stage */

.signin {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 25rem);
    align-items: center;
    gap: clamp(3rem, 8vw, 8rem);
    width: 100%;
    max-width: 82rem;
    /* The first screen under the header, with the object and the words centred in it. */
    min-height: calc(100svh - var(--header));
    margin: 0 auto;
    padding: clamp(1.5rem, 3svh, 2.5rem) var(--gutter);
}

/* The panel's header is sticky and already stands in the flow, so the page's own header room (pages.css) would push the
   sign-in a header's height further down. */
.page:has(> .signin) {
    padding-top: 0;
}

/* -------------------------------------------------------- 2. The photograph */

/* A photograph of what the couple bought, square as every picture of the house, as tall as the first screen allows
   (the owner's decision of 2026-11-25: a photograph, no model). */
.signin__art {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(24rem, calc(100svh - var(--header) - 6rem), 40rem);
}

.signin__photo {
    display: block;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--stage);
}

/* ------------------------------------------------------------ 3. The words */

.signin__panel {
    display: grid;
    gap: 2.4rem;
}

.signin__head {
    display: grid;
    gap: 1.2rem;
}

.signin__title {
    font-family: var(--display);
    font-weight: var(--weight-display);
    font-size: var(--type-title);
    line-height: 1.02;
    letter-spacing: var(--display-tracking);
    text-wrap: balance;
}

.signin__lead {
    max-width: 23rem;
    font-family: var(--serif);
    font-size: var(--type-lede);
    line-height: 1.6;
    color: var(--ink-soft);
    text-wrap: pretty;
}

/* Where the code went, as the address on an envelope. */
.signin__address {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 1.4rem;
    padding-top: 0.2rem;
}

.signin__mailbox {
    font-family: var(--serif);
    font-size: var(--type-lede);
    overflow-wrap: anywhere;
}

/* A word from the house, set as a note in the margin: a gold hairline and the sentence in Garamond, no filled box. */
.signin .signin__notice {
    margin: 0;
    padding: 0.15rem 0 0.15rem 1.1rem;
    border-left: 1px solid var(--gold);
    background: none;
    font-family: var(--serif);
    font-size: var(--type-body);
    letter-spacing: 0;
    line-height: 1.55;
}

    .signin .signin__notice.notice--error {
        border-left-color: var(--error);
        color: var(--error);
    }

        .signin .signin__notice.notice--error::before {
            content: none;
        }

/* ---------------------------------------------------------- 4. The form */

.signin__form {
    display: grid;
    gap: 2.2rem;
}

.signin__field {
    gap: var(--label-gap);
}

    .signin__field .field__hint {
        font-size: var(--type-body);
    }

.signin .signin__field > .signin__label {
    font-family: var(--sans);
    font-weight: var(--sans-weight);
    font-size: var(--caps-size);
    letter-spacing: var(--caps-tracking);
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* The address is written on a line: a hairline of ink, and over it the gold drawn from the left while the field is
   being written in. */
.signin__rule {
    position: relative;
    display: block;
}

    .signin__rule::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 1px;
        background: var(--gold);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.8s var(--slow);
        pointer-events: none;
    }

    .signin__rule:focus-within::after {
        transform: none;
    }

/* Written with the element and the page's class: the house's field rule (.field input:not(…):not(…)) weighs as much. */
.signin .signin__field input.signin__input {
    width: 100%;
    min-height: 2.9rem;
    padding: var(--field-air) 0 0.5rem;
    border: 0;
    border-bottom: 1px solid var(--ink);
    border-radius: 0;
    background: transparent;
    font-family: var(--serif);
    font-size: var(--type-heading);
    color: var(--ink);
}

    .signin__field .signin__input:focus {
        outline: none;
        border-color: var(--ink);
    }

    .signin__input:-webkit-autofill {
        -webkit-box-shadow: 0 0 0 100px var(--ground) inset;
        -webkit-text-fill-color: var(--ink);
    }

.signin__check {
    font-size: var(--type-body);
}

/* The button is a hairline frame: the words and an arrow; the gold rises through it and the arrow steps forward. */
.signin__send {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    width: 100%;
    min-height: 3.6rem;
    padding: 0 1.5rem;
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    font-family: var(--sans);
    font-weight: var(--sans-weight);
    font-size: var(--caps-size);
    letter-spacing: var(--caps-tracking);
    text-transform: uppercase;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.5s var(--slow);
}

    .signin__send::before {
        content: '';
        position: absolute;
        inset: 0;
        z-index: -1;
        background: rgba(var(--gold-rgb), 0.18);
        transform: translateY(101%);
        transition: transform 0.6s var(--slow);
    }

    .signin__send:hover::before,
    .signin__send:focus-visible::before {
        transform: none;
    }

    .signin__send:hover {
        border-color: var(--gold);
    }

    .signin__send:active {
        transform: scale(0.99);
    }

    .signin__send:disabled {
        cursor: default;
    }

.signin__arrow {
    flex: none;
    width: 2.75rem;
    height: 0.75rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    overflow: visible;
    transition: transform 0.6s var(--slow);
}

    .signin__send:hover .signin__arrow,
    .signin__send:focus-visible .signin__arrow {
        transform: translateX(0.4rem);
    }

    /* Sent and waiting for the next page: the arrow travels on and comes back, quietly. */
    .signin__send:disabled .signin__arrow {
        animation: signin-travel 1.4s var(--slow) infinite;
    }

@keyframes signin-travel {
    0% { transform: none; opacity: 1; }
    55% { transform: translateX(0.9rem); opacity: 0; }
    56% { transform: translateX(-0.6rem); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

.signin__note {
    margin-top: -0.6rem;
    font-size: var(--type-body);
    color: var(--ink-soft);
}

/* A second way, never a second button: small capitals on a hairline. */
.signin__quiet {
    display: inline;
    min-height: 0;
    padding: 0 0 0.2rem;
    border: 0;
    background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
    color: var(--ink);
    font-family: var(--sans);
    font-weight: var(--sans-weight);
    font-size: var(--caps-size);
    letter-spacing: var(--caps-tracking);
    text-transform: uppercase;
    cursor: pointer;
    transition: background-size 0.5s var(--slow);
}

    .signin__quiet:hover {
        background-image: linear-gradient(var(--gold), var(--gold));
        animation: hairline 0.6s var(--slow);
    }

.signin__resend {
    display: grid;
    gap: 0.8rem;
    justify-items: start;
    padding-top: 1.8rem;
    border-top: 1px solid var(--rule);
    font-size: var(--type-body);
    color: var(--ink-soft);
}

    .signin__resend form {
        margin: 0;
    }

/* ---------------------------------------------------------- 5. The code */

/* Without the script the field is a plain line of digits; with it the digits are set in six sockets and the field lies
   over them, unseen, still taking every key, the paste and the mailbox's autofill. The digits are sized for the six
   sockets, outside the reading scale. */
.otp {
    position: relative;
    width: 100%;
}

.otp__slots {
    display: none;
}

.signin .signin__field input.otp__input {
    width: 100%;
    min-height: 3.6rem;
    padding: 0.4rem 0;
    border: 0;
    border-bottom: 1px solid var(--ink);
    border-radius: 0;
    background: transparent;
    font-family: var(--display);
    font-size: 1.7rem;
    letter-spacing: 0.5em;
    font-variant-numeric: lining-nums tabular-nums;
    color: var(--ink);
}

    .signin__field .otp__input:focus {
        outline: none;
        border-color: var(--gold);
    }

.otp.is-live .otp__slots {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: clamp(0.45rem, 1.8vw, 0.75rem);
}

.signin .signin__field .otp.is-live input.otp__input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    /* 16px keeps a phone from zooming into the field. */
    font-size: 16px;
    letter-spacing: 0;
    color: transparent;
    -webkit-text-fill-color: transparent;
    caret-color: transparent;
    cursor: text;
}

    .otp.is-live .otp__input::selection {
        background: transparent;
    }

    /* The field itself is unseen, so its focus is drawn on the sockets: darker lines and the gold one waiting. */
    .otp.is-live .otp__input:focus-visible {
        outline: none;
    }

.otp.is-live:focus-within .otp__slot:not(.is-filled, .is-current) {
    border-bottom-color: var(--ink-soft);
}

/* A socket is a line to write a digit on, as the address is: paper above, one hairline under it. */
.otp__slot {
    position: relative;
    display: grid;
    place-items: center;
    height: 4.2rem;
    border-bottom: 1px solid var(--rule);
    font-family: var(--display);
    font-size: 2.2rem;
    line-height: 1;
    font-variant-numeric: lining-nums;
    transition: border-color 0.5s var(--slow);
}

    .otp__slot.is-filled {
        border-bottom-color: var(--ink);
    }

    .otp__slot.is-current {
        border-bottom-color: var(--gold);
    }

        /* The caret lives in the socket that waits for the next digit. */
        .otp__slot.is-current::after {
            content: '';
            position: absolute;
            left: 50%;
            top: 28%;
            width: 1px;
            height: 44%;
            background: var(--gold);
            animation: signin-caret 1.1s steps(2, jump-none) infinite;
        }

.otp__digit {
    display: block;
    animation: signin-digit 0.5s var(--slow);
}

/* Six digits: the gold runs across the sockets once, left to right, as the code leaves. */
.otp.is-complete .otp__slot {
    border-bottom-color: var(--gold);
}

    .otp.is-complete .otp__slot:nth-child(2) { transition-delay: 45ms; }
    .otp.is-complete .otp__slot:nth-child(3) { transition-delay: 90ms; }
    .otp.is-complete .otp__slot:nth-child(4) { transition-delay: 135ms; }
    .otp.is-complete .otp__slot:nth-child(5) { transition-delay: 180ms; }
    .otp.is-complete .otp__slot:nth-child(6) { transition-delay: 225ms; }

/* A code refused — by the server or before sending — draws the lines in ink, doubled, until it is typed again. */
.otp.is-refused .otp__slot,
.otp:has(.otp__input[aria-invalid="true"]) .otp__slot {
    border-bottom-color: var(--ink);
    box-shadow: inset 0 -1px 0 var(--ink);
}

@keyframes signin-caret {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes signin-digit {
    from { opacity: 0; transform: translateY(0.35rem); }
}

/* -------------------------------------------------------- 6. Narrow screens */

/* The words first and the invitation beside the title's column falls away: on a narrow screen the envelope stands
   small above the words, so the form is reached without scrolling past a picture. */
@media (max-width: 899px) {
    .signin {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        align-items: start;
        gap: 1.5rem;
        min-height: 0;
        padding-top: 1rem;
        padding-bottom: 4rem;
    }

    .signin__art {
        width: 100%;
        height: clamp(13rem, 34svh, 18rem);
    }

    .signin__panel {
        width: 100%;
        max-width: 30rem;
    }
}

@media (max-width: 479px) {
    .signin {
        gap: 1.25rem;
        /* The site's gutter, as every page and the header above: a narrower one would set the words off the mark's edge. */
        padding: 0.75rem var(--gutter) 3.5rem;
    }

    .signin__panel {
        gap: 2rem;
    }

    .otp__slot {
        height: 3.6rem;
        font-size: 1.9rem;
    }
}

/* ------------------------------------------------------- 7. Reduced motion */

@media (prefers-reduced-motion: reduce) {
    .signin__rule::after,
    .signin__send,
    .signin__send::before,
    .signin__arrow,
    .signin__quiet,
    .otp__slot {
        animation: none !important;
        transition: none !important;
    }

    .signin__send:disabled .signin__arrow,
    .otp__digit,
    .otp__slot.is-current::after {
        animation: none;
    }
}

@media (forced-colors: active) {
    .otp__slot,
    .otp__slot.is-filled,
    .otp__slot.is-current {
        border-color: CanvasText;
    }
}
