/*
 * What the three shared form pieces look like (Victor, 2026-10-13): <x-submit-button>, <x-date-input> and
 * <x-message-field>. Every colour, radius and size comes from the palette tokens in style.css; this file
 * is linked once, after the vendor styles, from components/layout/head.blade.php.
 */

/* --- Submit button: one scale, three sizes ------------------------------------------------------------ */

.r2e-submit {
    --r2e-submit-pad-y: var(--r2e-space-2);
    --r2e-submit-pad-x: var(--r2e-space-4);
    --r2e-submit-font: var(--r2e-text-sm);
    padding: var(--r2e-submit-pad-y) var(--r2e-submit-pad-x);
    font-size: var(--r2e-submit-font);
    line-height: var(--r2e-control-line);
    border-radius: var(--r2e-radius);
}

.r2e-submit--sm {
    --r2e-submit-pad-y: var(--r2e-space-1);
    --r2e-submit-pad-x: var(--r2e-space-3);
    --r2e-submit-font: var(--r2e-text-sm);
}

.r2e-submit--md {
    --r2e-submit-pad-y: var(--r2e-space-2);
    --r2e-submit-pad-x: var(--r2e-space-4);
    --r2e-submit-font: var(--r2e-text-base);
}

.r2e-submit--lg {
    --r2e-submit-pad-y: var(--r2e-space-3);
    --r2e-submit-pad-x: var(--r2e-space-6);
    --r2e-submit-font: var(--r2e-text-base);
}

/* The house call-to-action look, for the public site and the funnel. */
.r2e-submit--caps {
    letter-spacing: var(--r2e-tracking-cta);
    text-transform: uppercase;
    font-weight: 600;
}

/* A thumb needs 44px: under 576px every form button (and a button marked r2e-tap) is at least that tall.
   Padding does the work, so a one-line label stays centred and a label with a price keeps its spaces. */
@media (max-width: 575.98px) {
    .r2e-submit,
    .r2e-tap {
        min-height: 2.75rem;
    }

    .r2e-submit--sm,
    .r2e-submit--md {
        --r2e-submit-pad-y: var(--r2e-space-3);
    }

    .r2e-tap {
        --bs-btn-padding-y: var(--r2e-space-3);
    }
}

/* While the form is on its way: the button keeps its size, the spinner takes the colour of its text. */
.r2e-submit[aria-busy="true"],
button[data-r2e-busy="1"] {
    cursor: progress;
}

.r2e-submit-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: var(--r2e-space-2);
    vertical-align: -0.125em;
    border: 0.15em solid currentcolor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: r2e-submit-spin 0.75s linear infinite;
}

.r2e-submit-spinner--alone {
    margin-right: 0;
}

/*
 * A button that keeps its content while it waits (data-busy-overlay, the search button): what it shows, a word, a
 * magnifier or both, stays in place but unseen, so the button does not change size, and the spinner sits over it,
 * centred by its auto margins.
 */
.r2e-submit[data-busy-overlay] {
    position: relative;
}

/* Disabled while it waits, but not dimmed: the spinner stays as readable as the word was (this button only). */
.r2e-submit[data-busy-overlay][data-r2e-busy="1"] {
    opacity: 1;
}

.r2e-submit[data-busy-overlay][data-r2e-busy="1"] > :not(.r2e-submit-spinner) {
    visibility: hidden;
}

.r2e-submit-spinner--overlay {
    position: absolute;
    inset: 0;
    margin: auto;
}

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

@media (prefers-reduced-motion: reduce) {
    .r2e-submit-spinner {
        animation-duration: 2s;
    }
}

/* --- Date field --------------------------------------------------------------------------------------- */

/* flatpickr copies the field's classes onto the visible input and hides the original one. */
.flatpickr-input[readonly].r2e-date-input,
input.r2e-date-input[readonly] {
    background-color: var(--bs-body-bg);
    cursor: pointer;
}

/* --- Birth date funnel (public/js/birth-date-funnel.js) ------------------------------------------------ */

/* The field: the visible input and its button, one group. The original input is hidden. */
.r2e-birth-field {
    flex-wrap: nowrap;
}

.r2e-birth-field > .r2e-birth-input {
    min-width: 0;
}

.r2e-birth-toggle {
    min-width: 2.75rem;
    justify-content: center;
    cursor: pointer;
    color: var(--r2e-ink-secondary);
}

.r2e-birth-toggle:hover {
    color: var(--bs-secondary);
}

.r2e-birth-toggle:focus-visible,
.r2e-birth-nav:focus-visible,
.r2e-birth-cell:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.r2e-birth-error {
    margin-top: var(--r2e-space-1);
}

/* The funnel itself is drawn at the end of <body>, above a Bootstrap window (1055) and its tooltips. */
.r2e-birth-layer {
    position: fixed;
    inset: 0;
    z-index: 1090;
    pointer-events: none;
}

.r2e-birth-panel {
    position: fixed;
    pointer-events: auto;
    width: 20rem;
    max-width: calc(100vw - 1rem);
    padding: var(--r2e-space-3) var(--r2e-space-4) var(--r2e-space-4);
    border: 1px solid var(--bs-gray-300);
    border-radius: var(--r2e-radius-lg);
    background-color: var(--bs-body-bg);
    color: var(--r2e-ink);
    box-shadow: var(--r2e-shadow-lg);
    font-size: var(--r2e-text-base);
    line-height: var(--r2e-leading-snug);
}

.r2e-birth-panel:focus {
    outline: none;
}

.r2e-birth-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--r2e-space-2);
}

.r2e-birth-title {
    margin: 0;
    font-size: var(--r2e-text-base);
    font-weight: 600;
    color: var(--r2e-ink);
}

.r2e-birth-nav {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0 var(--r2e-space-2);
    border: 0;
    background: none;
    color: var(--r2e-primary-700);
    font-size: var(--r2e-text-sm);
    font-weight: 600;
    cursor: pointer;
}

/* Back sits at the start (hidden on the first step so the title stays centred), Close at the end. */
.r2e-birth-back {
    justify-content: flex-start;
}

.r2e-birth-close {
    justify-content: flex-end;
    color: var(--r2e-ink-secondary);
}

.r2e-birth-crumbs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--r2e-space-1) var(--r2e-space-2);
    min-height: 1.75rem;
    margin-bottom: var(--r2e-space-2);
}

.r2e-birth-crumbs span {
    padding: 0 var(--r2e-space-2);
    border-radius: var(--r2e-radius-pill);
    background-color: var(--r2e-primary-100);
    color: var(--r2e-ink);
    font-size: var(--r2e-text-xs);
    line-height: 1.5rem;
}

.r2e-birth-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--r2e-space-2);
}

.r2e-birth-grid[data-step="year"] {
    grid-template-columns: repeat(4, 1fr);
}

.r2e-birth-grid[data-step="day"] {
    grid-template-columns: repeat(7, 1fr);
    gap: var(--r2e-space-1);
}

.r2e-birth-weekday {
    text-align: center;
    font-size: var(--r2e-text-xs);
    color: var(--r2e-ink-muted);
}

/* 44px targets: a day is as tall as a finger, and as wide as seven fit across a 320px phone. */
.r2e-birth-cell {
    min-height: 2.75rem;
    padding: 0;
    border: 1px solid var(--bs-gray-300);
    border-radius: var(--r2e-radius);
    background-color: var(--bs-body-bg);
    color: var(--r2e-ink);
    font: inherit;
    font-size: var(--r2e-text-base);
    cursor: pointer;
}

.r2e-birth-grid[data-step="day"] .r2e-birth-cell {
    font-size: var(--r2e-text-sm);
}

.r2e-birth-cell:hover:not(:disabled) {
    background-color: var(--r2e-primary-100);
}

/* Too young, too old or not yet: greyed, and nothing to press. */
.r2e-birth-cell:disabled {
    background-color: var(--bs-gray-100);
    color: var(--r2e-ink-muted);
    opacity: 0.45;
    cursor: not-allowed;
}

.r2e-birth-cell.is-current {
    border-color: var(--bs-secondary);
    background-color: var(--bs-secondary);
    color: var(--bs-white);
}

/* The keyboard marker shows only once a key has been used. */
.r2e-birth-panel.is-keyboard .r2e-birth-cell.is-active {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* On a phone: a bottom sheet over a scrim, sliding up. */
.r2e-birth-layer--sheet .r2e-birth-scrim {
    position: absolute;
    inset: 0;
    background-color: color-mix(in srgb, var(--bs-secondary) 40%, transparent);
    opacity: 0;
    pointer-events: auto;
    touch-action: none;
    transition: opacity 0.2s ease;
}

.r2e-birth-layer--sheet.is-open .r2e-birth-scrim {
    opacity: 1;
}

.r2e-birth-layer--sheet .r2e-birth-panel {
    inset: auto 0 0 0;
    width: auto;
    max-width: none;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: calc(var(--r2e-space-4) + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: var(--r2e-radius-xl) var(--r2e-radius-xl) 0 0;
    transform: translateY(105%);
    transition: transform 0.25s ease;
}

.r2e-birth-layer--sheet.is-open .r2e-birth-panel {
    transform: translateY(0);
}

.r2e-birth-grab {
    width: 2.5rem;
    height: 0.25rem;
    margin: 0 auto var(--r2e-space-2);
    border-radius: var(--r2e-radius-pill);
    background-color: var(--bs-gray-300);
}

@media (prefers-reduced-motion: reduce) {
    .r2e-birth-layer--sheet .r2e-birth-scrim,
    .r2e-birth-layer--sheet .r2e-birth-panel {
        transition: none;
    }
}

/* iOS zooms into a field under 16px: the birth date is read at full size on a phone. */
@media (max-width: 575.98px) {
    .r2e-birth-field > .r2e-birth-input {
        font-size: var(--r2e-text-base);
    }
}

/* --- Message field ------------------------------------------------------------------------------------ */

.r2e-message-counter {
    margin-top: var(--r2e-space-1);
    font-size: var(--r2e-text-xs);
    line-height: var(--r2e-leading-snug);
    text-align: right;
    color: var(--r2e-ink-muted);
}

.r2e-message-counter[hidden],
[hidden] + .r2e-message-counter {
    display: none;
}

/* At the limit the count reads the accent, never red. */
.r2e-message-counter.is-at-limit {
    color: var(--bs-info);
    font-weight: 600;
}

/* --- Email suggestion: "Did you mean john@gmail.com?" (<x-email-suggest-hint>, public/js/email-suggest.js) --- */

/* An empty live region takes no room: the line appears only when the script has a suggestion. */
.r2e-email-suggest:not(:empty) {
    margin-top: var(--r2e-space-1);
    font-size: var(--r2e-text-sm);
    line-height: var(--r2e-leading-snug);
    color: var(--r2e-ink);
}

.r2e-email-suggest__accept {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--r2e-primary-700);
    text-decoration: underline;
    cursor: pointer;
}

.r2e-email-suggest__accept:hover {
    color: var(--r2e-primary-800);
}

.r2e-email-suggest__accept:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    border-radius: var(--r2e-radius-sm);
}
