/* ==========================================================================
   Modal — used by the claim flow
   Two can be open at once (the consent text sits above the form), so the
   stacking is explicit rather than left to source order.
   ========================================================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    background: rgba(26, 22, 20, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: modal-fade 0.18s ease-out;
}

.modal[hidden] { display: none; }

/* The consent dialog opens on top of the claim dialog */
#claim-consent-modal { z-index: calc(var(--z-modal) + 10); }

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal__panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - var(--space-xl) * 2);
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 60px -12px rgba(26, 22, 20, 0.28);
    animation: modal-rise 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal--narrow .modal__panel { max-width: 460px; }

@keyframes modal-rise {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .modal,
    .modal__panel { animation: none; }
}

/* The panel scrolls, not the page behind it */
.modal__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-2xl) var(--space-xl) var(--space-xl);
}

.modal__close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--ink-3);
    background: var(--paper-2);
    border: 1px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.modal__close:hover {
    color: var(--ink);
    background: var(--paper-3);
}

.modal__close:focus-visible {
    outline: 2px solid var(--ochre);
    outline-offset: 2px;
}

/* -------------------------------------------------------------- content */

.modal__eyebrow {
    margin: 0 0 var(--space-2xs);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ochre);
}

.modal__title {
    margin: 0 0 var(--space-sm);
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 1.15rem + 1vw, 1.75rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--ink);
    text-wrap: balance;
}

.modal__lede {
    margin: 0 0 var(--space-lg);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--ink-2);
}

/* The panes are not .auth-form, so they carry their own rhythm. Gap rather
   than margins: the fields are siblings and the spacing must not collapse
   into the hint text a field owns. */
.modal__pane {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.modal__pane[hidden] { display: none; }

/* Eyebrow, title and lede read as one unit — they sit in their own wrapper
   so the pane's gap applies between blocks, not between those three lines. */
.modal__head {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.modal__head .modal__eyebrow,
.modal__head .modal__title,
.modal__head .modal__lede { margin: 0; }

.modal__head .modal__lede { margin-top: var(--space-2xs); }

/* Result panes are read, not filled in — centre them */
.modal__pane--result {
    text-align: center;
    gap: var(--space-md);
}

.modal__icon {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto;
    color: var(--ink-3);
    background: var(--paper-2);
    border-radius: 50%;
}

.modal__icon--ok {
    color: var(--ochre);
    background: var(--ochre-light);
}

.modal__actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Consent copy */
.modal__prose {
    margin-bottom: var(--space-lg);
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--ink-2);
}

.modal__prose h3 {
    margin: var(--space-lg) 0 var(--space-2xs);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
}

.modal__prose p  { margin: 0 0 var(--space-sm); }
.modal__prose ul { margin: 0 0 var(--space-sm); padding-left: 1.15rem; }
.modal__prose li { margin-bottom: var(--space-2xs); }
.modal__prose a  { color: var(--ochre); }

/* A control that reads as part of the sentence around it */
.link-button {
    padding: 0;
    font: inherit;
    color: var(--ochre);
    background: none;
    border: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.link-button:hover { color: var(--ochre-hover); }

/* ------------------------------------------------------------ form state */

/* .auth-field is a flex column with its own gap, so the message needs no
   margin of its own — a negative one pulls it back against the input it
   belongs to, rather than letting it float between two fields. */
.field-error {
    margin: calc(var(--space-xs) * -0.5) 0 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #9F1239;
}

.auth-field input.is-invalid,
.auth-field textarea.is-invalid {
    border-color: #9F1239;
}

.auth-field input.is-invalid:focus,
.auth-field textarea.is-invalid:focus {
    outline-color: #9F1239;
}

.btn.is-busy {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--white);
    animation: modal-spin 0.7s linear infinite;
}

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

/* Locking the body keeps a long profile page from scrolling underneath */
body.has-modal { overflow: hidden; }

/* -------------------------------------------------------------- mobile */

@media (max-width: 560px) {
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal__panel {
        max-width: none;
        max-height: 92vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        border-bottom: 0;
        animation: modal-sheet 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .modal--narrow .modal__panel { max-width: none; }

    .modal__body {
        /* Room for the home indicator on phones with a gesture bar */
        padding: var(--space-xl) var(--space-lg)
                 calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    }

    @keyframes modal-sheet {
        from { transform: translateY(100%); }
        to   { transform: none; }
    }
}
