/*
 * Booking area: the /online/ wizard (blocks/booking_widget.blade.php + js/booking.js), contract 09 §6.
 * Only additions to the CSS API of site.css (00 §8, §11); mobile-first, breakpoints 640/960/1200.
 *
 *   1. Progressive enhancement
 *   2. Panel, progress, status
 *   3. Step frame
 *   4. Step 1 — doctors
 *   5. Step 2 — services
 *   6. Step 3 — dates and times
 *   7. Step 4 — contacts, summary
 *   8. Step 5 — success
 *
 * Chosen states (a pressed filter button, the picked date and slot, the current step number) are filled
 * with --c-brand-dark, not --c-brand: white on #ff7349 gives 2,7:1 and the day a patient had just chosen
 * was the hardest number on the screen to read (10 §3 д. 31). --c-brand stays the colour of the accents.
 */

/* 1. Progressive enhancement ---------------------------------------------- */

/* Without JS the wizard cannot work: the phone block of the stub stays the only way (09 §6). */
html:not(.js) .booking {
    display: none;
}

html.js [data-booking-fallback] {
    display: none;
}

/* 2. Panel, progress, status ---------------------------------------------- */

/*
 * Stage 1 kept /online/ in the narrow column of page-online.php (areas/promotions.css). The wizard needs
 * the usual width: five doctor cards, a form and the summary next to it. Without JS — and with a MIS that
 * does not answer — the page shows the phone block and stays narrow, exactly as before.
 */
html.js .online-page:has(.booking) .container {
    max-width: calc(var(--container) + 2 * var(--gutter));
}

.booking {
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.booking__notice {
    max-width: none;
    margin-bottom: var(--space-5);
}

.booking__head {
    padding: clamp(1.25rem, 0.9rem + 1.6vw, 2rem) clamp(1rem, 0.6rem + 2vw, 2.25rem) var(--space-4);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(135deg, #fff 0%, var(--c-brand-soft) 100%);
}

.booking__title {
    margin: 0;
    font-size: clamp(1.25rem, 1.1rem + 0.8vw, 1.75rem);
}

.booking__lead {
    max-width: 38rem;
    margin: var(--space-2) 0 0;
    color: var(--c-ink-2);
    font-size: 0.9375rem;
}

.booking__progress {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-1);
    margin: 0;
    padding: var(--space-4) clamp(0.5rem, 0.2rem + 1.5vw, 1.5rem);
    border-bottom: 1px solid var(--c-line);
    list-style: none;
    counter-reset: none;
}

.booking__progress-item {
    display: grid;
    justify-items: center;
    gap: 0.35rem;
    position: relative;
    padding: 0 0.15rem;
    color: var(--c-ink-2);
    text-align: center;
}

/* The connector sits behind the number, from the previous item. */
.booking__progress-item + .booking__progress-item::before {
    content: "";
    position: absolute;
    top: 0.9rem;
    right: 50%;
    left: -50%;
    height: 2px;
    background: var(--c-line);
}

.booking__progress-num {
    display: grid;
    place-items: center;
    position: relative;
    z-index: 1;
    width: 1.875rem;
    height: 1.875rem;
    border: 2px solid var(--c-line);
    border-radius: 50%;
    background: #fff;
    font: 700 0.875rem/1 var(--font-display);
}

.booking__progress-label {
    font-size: 0.6875rem;
    line-height: 1.25;
}

.booking__progress-item[data-state="current"] {
    color: var(--c-ink-strong);
}

.booking__progress-item[data-state="current"] > .booking__progress-label {
    font-weight: 700;
}

.booking__progress-item[data-state="current"] > .booking__progress-num {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-dark);
    color: #fff;
}

.booking__progress-item[data-state="done"] {
    color: var(--c-brand-dark);
}

.booking__progress-item[data-state="done"] > .booking__progress-num {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-soft);
    color: var(--c-brand-dark);
}

.booking__progress-item[data-state="done"] + .booking__progress-item::before,
.booking__progress-item[data-state="current"] + .booking__progress-item::before {
    background: var(--c-brand-tint);
}

@media (min-width: 640px) {
    .booking__progress-label {
        font-size: 0.8125rem;
    }

    .booking__progress-num {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }

    .booking__progress-item + .booking__progress-item::before {
        top: 1.1rem;
    }
}

.booking__status,
.booking__alert {
    margin: clamp(1rem, 0.8rem + 1vw, 1.5rem) clamp(1rem, 0.6rem + 2vw, 2.25rem) 0;
}

.booking__status {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    color: var(--c-ink-2);
    font-size: 0.9375rem;
}

.booking__status[hidden],
.booking__alert[hidden],
.booking__alert-actions[hidden] {
    display: none;
}

/* Spinner: the global prefers-reduced-motion rule of site.css stops the animation. */
.booking__status::before {
    content: "";
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--c-brand-tint);
    border-top-color: var(--c-brand);
    border-radius: 50%;
    animation: booking-spin 0.8s linear infinite;
}

@keyframes booking-spin {
    to {
        transform: rotate(1turn);
    }
}

.booking__alert {
    max-width: none;
}

/*
 * At 360px the default padding of .notice plus the icon leave about 200px for the message. The panel is
 * already a framed box, so the alert can give that space back to the text.
 */
@media (max-width: 479px) {
    .booking__alert,
    .booking__notice {
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
    }
}

.booking__alert-text,
.booking__alert-actions {
    margin: 0;
}

.booking__alert-actions {
    margin-top: var(--space-3);
}

.booking__help {
    margin: 0;
    padding: 0 clamp(1rem, 0.6rem + 2vw, 2.25rem) clamp(1.25rem, 1rem + 1vw, 1.75rem);
    color: var(--c-ink-2);
    font-size: 0.9375rem;
}

.booking__help a {
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

/* 3. Step frame ------------------------------------------------------------ */

.booking__steps {
    padding: clamp(1.25rem, 0.9rem + 1.6vw, 2rem) clamp(1rem, 0.6rem + 2vw, 2.25rem);
}

.booking-step[hidden] {
    display: none;
}

/* The heading takes focus when a step opens, so its outline has to hug the text, not the column. */
.booking-step__title {
    width: fit-content;
    max-width: 100%;
    margin: 0 0 var(--space-2);
    font-size: clamp(1.125rem, 1.05rem + 0.5vw, 1.375rem);
}

.booking-step__title:focus-visible {
    outline-offset: 4px;
}

.booking-step__hint,
.booking-step__empty,
.booking-step__chosen {
    margin: 0 0 var(--space-4);
    color: var(--c-ink-2);
    font-size: 0.9375rem;
}

.booking-step__chosen b {
    color: var(--c-ink-strong);
}

.booking-step__empty[hidden] {
    display: none;
}

.booking-step__label {
    margin: var(--space-5) 0 var(--space-3);
    color: var(--c-ink-strong);
    font-size: 0.9375rem;
}

.booking-step__back {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: var(--space-4);
    padding: 0.4rem 0.75rem 0.4rem 0.5rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--c-brand-dark);
    font: 700 0.875rem/1.2 var(--font-display);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease);
}

.booking-step__back:hover {
    background: var(--c-brand-soft);
}

.booking-step__back .icon {
    width: 1.1em;
    height: 1.1em;
}

/* «Изменить» next to the chosen doctor and service. */
.booking-step__change {
    padding: 0.1rem 0.5rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--c-brand-soft);
    color: var(--c-brand-dark);
    font: 700 0.8125rem/1.4 var(--font-display);
    cursor: pointer;
}

.booking-step__change:hover {
    background: var(--c-brand-tint);
}

/* 4. Step 1 — doctors ------------------------------------------------------ */

.booking-filter {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.booking-filter__btn {
    min-height: 2.5rem;
    padding: 0.45rem 1.05rem;
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--c-ink-strong);
    font: 700 0.8125rem/1.2 var(--font-display);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.booking-filter__btn:hover {
    border-color: var(--c-brand);
    color: var(--c-brand-dark);
}

.booking-filter__btn[aria-pressed="true"] {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-dark);
    color: #fff;
}

.booking-doctors {
    --grid-gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.booking-doctors > li[hidden] {
    display: none;
}

/* A square portrait keeps the whole list of doctors on one screen; the crop is top-aligned (doctors.css). */
.booking-doctor {
    --card-ratio: 1 / 1;
    height: 100%;
}

.booking-doctor .card__body {
    gap: var(--space-2);
    padding: var(--space-4);
}

.booking-doctor__label {
    margin: var(--space-2) 0 0;
    color: var(--c-ink-2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.booking-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.booking-chip {
    min-height: 2.25rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--c-brand-tint);
    border-radius: var(--radius-pill);
    background: var(--c-brand-soft);
    color: var(--c-brand-dark);
    font: 700 0.8125rem/1.2 var(--font-display);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.booking-chip:hover {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-dark);
    color: #fff;
}

/* 5. Step 2 — services ----------------------------------------------------- */

.booking-services {
    --grid-gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.booking-service {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    align-items: flex-start;
    width: 100%;
    height: 100%;
    padding: var(--space-4);
    border: 1.5px solid var(--c-line);
    border-radius: var(--radius);
    background: #fff;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.booking-service:hover {
    border-color: var(--c-brand);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.booking-service__title {
    color: var(--c-ink-strong);
    font: 700 1rem/1.35 var(--font-display);
}

.booking-service__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    align-items: baseline;
    width: 100%;
    color: var(--c-ink-2);
    font-size: 0.875rem;
}

.booking-service__price {
    color: var(--c-ink-strong);
    font: 700 1.0625rem/1.3 var(--font-display);
}

/* 6. Step 3 — dates and times ---------------------------------------------- */

.booking-dates {
    display: grid;
    gap: var(--space-4);
}

.booking-month__title {
    margin: 0 0 var(--space-2);
    color: var(--c-ink-2);
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.booking-month__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.booking-date {
    display: grid;
    gap: 0.1rem;
    place-items: center;
    min-width: 3.25rem;
    padding: 0.4rem 0.5rem;
    border: 1.5px solid var(--c-line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--c-ink-strong);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.booking-date__day {
    font: 700 1.0625rem/1.1 var(--font-display);
}

.booking-date__weekday {
    color: var(--c-ink-2);
    font-size: 0.6875rem;
}

.booking-date:hover {
    border-color: var(--c-brand);
    color: var(--c-brand-dark);
}

.booking-date[aria-pressed="true"] {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-dark);
    color: #fff;
}

.booking-date[aria-pressed="true"] .booking-date__weekday {
    color: #fff;
}

.booking-times {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.25rem, 1fr));
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.booking-slot {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem 0.25rem;
    border: 1.5px solid var(--c-line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--c-ink-strong);
    font: 700 0.9375rem/1.2 var(--font-display);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.booking-slot:hover {
    border-color: var(--c-brand);
    background: var(--c-brand-soft);
    color: var(--c-brand-dark);
}

.booking-slot[aria-pressed="true"] {
    border-color: var(--c-brand-dark);
    background: var(--c-brand-dark);
    color: #fff;
}

/* 7. Step 4 — contacts, summary -------------------------------------------- */

.booking-contacts {
    display: grid;
    gap: var(--space-5);
}

@media (min-width: 960px) {
    .booking-contacts {
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
        gap: var(--space-6);
        align-items: start;
    }
}

.booking-form {
    display: grid;
    gap: var(--space-4);
}

.booking-form__grid {
    display: grid;
    gap: var(--space-4);
}

/* A hint under one field must not stretch the input of its neighbour. */
.booking-form .field {
    align-content: start;
}

@media (min-width: 640px) {
    .booking-form__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.booking-form__comment {
    min-height: 5.5rem;
}

.booking-form__hint {
    margin: 0;
    color: var(--c-ink-2);
    font-size: 0.8125rem;
}

.booking-form__consent a {
    font-weight: 700;
}

.booking-methods {
    margin: 0;
    padding: 0;
    border: 0;
}

.booking-methods__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.booking-method {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.4rem 0.9rem;
    border: 1.5px solid var(--c-line-strong);
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.booking-method:has(input:checked) {
    border-color: var(--c-brand);
    background: var(--c-brand-soft);
    color: var(--c-ink-strong);
    font-weight: 700;
}

.booking-method input {
    margin: 0;
}

/* Honeypot: off-screen instead of display:none, so bots still fill it (09 §1 п. 6). */
.booking-honeypot {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.booking-summary {
    padding: var(--space-5);
    border: 1px solid var(--c-brand-tint);
    border-radius: var(--radius);
    background: var(--c-brand-soft);
    /* On one column the summary comes first: the patient sees what they are booking before typing. */
    order: -1;
}

@media (min-width: 960px) {
    .booking-summary {
        order: 0;
    }
}

.booking-summary__title {
    margin: 0 0 var(--space-3);
    font-size: 1.0625rem;
}

/*
 * Narrow screens stack label over value: two columns would squeeze a doctor's name to three letters.
 * One flat gap for every row would untie a label from its value, so the pairs keep their own spacing:
 * the value sits right under its label, the next label starts a new group.
 */
.booking-summary__list {
    display: grid;
    gap: 0;
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
    font-size: 0.9375rem;
}

.booking-summary__list dt {
    margin-top: var(--space-3);
    color: var(--c-ink-2);
}

.booking-summary__list dt:first-child {
    margin-top: 0;
}

.booking-summary__list dd {
    margin: 0.15rem 0 0;
    color: var(--c-ink-strong);
    font-weight: 700;
    overflow-wrap: break-word;
}

@media (min-width: 640px) {
    .booking-summary__list {
        gap: var(--space-2) var(--space-4);
        grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
    }

    .booking-summary__list dt,
    .booking-summary__list dd {
        margin: 0;
    }
}

@media (min-width: 960px) {
    .booking-summary {
        position: sticky;
        top: calc(var(--header-h) + 1rem);
    }
}

/* 8. Step 5 — success ------------------------------------------------------ */

.booking-success {
    display: grid;
    justify-items: center;
    gap: var(--space-4);
    text-align: center;
}

.booking-success .booking-summary__list {
    justify-items: start;
    width: 100%;
    max-width: 30rem;
    padding: var(--space-5);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-bg-soft);
    text-align: left;
}

.booking-success__icon {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    margin: 0;
    border-radius: 50%;
    background: var(--c-success-soft);
    color: var(--c-success);
}

.booking-success__icon .icon {
    width: 2rem;
    height: 2rem;
}

.booking-success__text {
    margin: 0;
    font-size: 1.0625rem;
}

.booking-success__reminder {
    max-width: 34rem;
    margin: 0;
    color: var(--c-ink-2);
    font-size: 0.875rem;
}

.booking-success__debug {
    margin: 0;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    background: var(--c-warning-soft);
    color: var(--c-warning);
    font-size: 0.8125rem;
}

.booking-success__debug[hidden] {
    display: none;
}

.booking-success__actions {
    justify-content: center;
}
