/* Shared form styles - /richiesta/, /contatti/ and the booking box on tour and excursion pages.
   Tokens only; buttons come from components.css (.btn-primary / .btn-secondary). */

.form-section {
    padding: var(--space-12) 0;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-sm);
}

.form-card-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    line-height: 1.25;
    color: var(--ink);
    margin: 0 0 var(--space-6);
    scroll-margin-top: calc(var(--header-h) + var(--space-12));
}
.form-card-title:focus { outline: none; }
.form-card-title:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; }

.form-intro {
    color: var(--text);
    margin: 0 0 var(--space-6);
    line-height: 1.6;
}

.form-required-note {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin: 0 0 var(--space-6);
}

/* Layout */
.form-group {
    margin: 0 0 var(--space-6);
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
    margin: 0 0 var(--space-6);
}
.form-grid > .form-group { margin: 0; }

@media (min-width: 768px) {
    .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Labels, hints, errors */
.form-label,
.form-legend {
    display: block;
    margin: 0 0 var(--space-2);
    padding: 0;
    font-size: var(--fs-base);
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink);
}

.form-optional {
    font-weight: 400;
    color: var(--text-muted);
}

.form-hint {
    display: block;
    margin: var(--space-1) 0 0;
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-muted);
}

.form-error {
    display: block;
    margin: var(--space-1) 0 0;
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1.5;
    color: var(--danger);
}
.form-error[hidden] { display: none; }

/* Inputs */
.form-control {
    display: block;
    width: 100%;
    min-height: var(--tap);
    box-sizing: border-box;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: var(--fs-base);
    line-height: 1.4;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color var(--transition);
    scroll-margin-top: calc(var(--header-h) + var(--space-12));
}
.form-control:hover { border-color: var(--text-muted); }
.form-control:focus,
.form-control:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-color: var(--brand);
}

textarea.form-control {
    min-height: 8rem;
    resize: vertical;
}

select.form-control {
    appearance: none;
    padding-right: 2.75rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
}

.form-control[aria-invalid="true"] {
    border-color: var(--danger);
    background-color: var(--danger-tint);
}

/* Radio / checkbox groups */
.form-fieldset {
    min-width: 0;
    margin: 0 0 var(--space-6);
    padding: 0;
    border: 0;
}

.choice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-6);
}

.choice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--tap);
    margin: 0;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
}

.choice input {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
    scroll-margin-top: calc(var(--header-h) + var(--space-12));
}

.choice--consent {
    align-items: flex-start;
    padding: var(--space-2) 0;
    line-height: 1.5;
}
.choice--consent input { margin-top: 0.125rem; }
.choice a {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.choice a:hover { color: var(--brand-dark); }
.choice--consent input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; }

@media (max-width: 767.98px) {
    .choice-list {
        flex-direction: column;
    }
}

/* Honeypot: off-screen for people, still in the DOM for bots */
.form-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Info box ("what happens next") */
.form-info {
    margin: 0 0 var(--space-6);
    padding: var(--space-6);
    background: var(--brand-tint);
    border-radius: var(--radius);
    color: var(--text);
}
.form-info h3 {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-lg);
    color: var(--ink);
}
.form-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
    line-height: 1.6;
}
.form-info li + li { margin-top: var(--space-2); }
.form-info li i { color: var(--success); margin-right: var(--space-2); }

/* Turnstile: reserve the widget's height so the page doesn't jump when it loads */
.turnstile-slot {
    min-height: 65px;
    margin: 0 0 var(--space-4);
}
.turnstile-slot.is-failed { min-height: 0; margin: 0; }

/* Actions + messages next to the submit button */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}
.form-actions--end { justify-content: flex-end; }
.form-actions--plain { border-top: 0; padding-top: 0; margin-top: var(--space-4); }

.form-actions .btn-primary:disabled {
    opacity: 0.75;
    cursor: progress;
    transform: none;
}

@media (max-width: 479.98px) {
    .form-actions > .btn-primary,
    .form-actions > .btn-secondary { flex: 1 1 auto; }
}

.form-alert {
    margin: var(--space-4) 0 0;
    padding: var(--space-4);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    background: var(--danger-tint);
    color: var(--danger);
    font-size: var(--fs-sm);
    line-height: 1.6;
    scroll-margin-top: calc(var(--header-h) + var(--space-12));
    scroll-margin-bottom: 96px;
}
.form-alert[hidden] { display: none; }
.form-alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}
.form-alert:empty { display: none; }

/* Step indicator (/richiesta/) */
.progress-steps {
    position: relative;
    display: flex;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto var(--space-8);
    padding: 0;
    list-style: none;
}
.progress-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 16%;
    right: 16%;
    height: 2px;
    background: var(--border-strong);
}

.progress-step {
    position: relative;
    z-index: 1;
    flex: 1;
    text-align: center;
}

.progress-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
}

.progress-step-label {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.progress-step.is-done .progress-step-number,
.progress-step[aria-current="step"] .progress-step-number {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.progress-step[aria-current="step"] .progress-step-label {
    color: var(--ink);
    font-weight: 600;
}

@media (max-width: 767.98px) {
    .progress-steps {
        justify-content: flex-start;
        align-items: center;
        gap: var(--space-2);
        margin-bottom: var(--space-6);
    }
    .progress-steps::before { display: none; }
    .progress-step {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: var(--space-2);
    }
    .progress-step-number { width: 32px; height: 32px; font-size: var(--fs-sm); }
    .progress-step-label { display: none; margin: 0; }
    .progress-step[aria-current="step"] .progress-step-label { display: block; font-size: var(--fs-base); }
}

/* Booking box on tour / excursion pages (partials/booking-form.njk) */
.tour-booking {
    max-width: 680px;
    margin: 0 auto;
}

.tour-booking .customization-title {
    font-size: var(--fs-3xl);
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
    text-align: center;
    margin: 0 0 var(--space-3);
}
.tour-booking .customization-subtitle {
    font-size: var(--fs-lg);
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 var(--space-6);
}

.tour-booking-offer {
    margin: 0 0 var(--space-8);
    padding: var(--space-6);
    background: var(--accent-tint);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    text-align: center;
}
.tour-booking-offer h3 {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-xl);
    color: var(--brand-dark);
}
.tour-booking-offer p {
    margin: 0;
    color: var(--ink);
    line-height: 1.6;
}

.tour-booking .form-group { margin: 0 0 var(--space-6); }
.tour-booking .form-grid > .form-group { margin: 0; }
.tour-booking .form-card { padding: var(--space-8); }

.tour-type-options {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
}
@media (min-width: 768px) {
    .tour-type-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.tour-type-option {
    position: relative;
    display: block;
    margin: 0;
    cursor: pointer;
}

.tour-type-input {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    opacity: 0;
}

.tour-type-body {
    display: block;
    height: 100%;
    box-sizing: border-box;
    padding: var(--space-6) var(--space-4) var(--space-4) var(--space-6);
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition), background-color var(--transition);
}
.tour-type-option:hover .tour-type-body { border-color: var(--text-muted); }

.tour-type-input:checked + .tour-type-body {
    border-color: var(--brand);
    background: var(--brand-tint);
}
.tour-type-input:focus-visible + .tour-type-body {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.tour-type-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--ink);
}

/* Radio indicator drawn in CSS so it matches the card state */
.tour-type-dot {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    box-sizing: border-box;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: var(--surface);
}
.tour-type-input:checked + .tour-type-body .tour-type-dot {
    border: 6px solid var(--brand);
}

.tour-type-desc {
    display: block;
    margin: 0 0 var(--space-3);
    font-size: var(--fs-sm);
    color: var(--text);
    line-height: 1.5;
}

.tour-type-list {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text);
}
.tour-type-list > span { display: block; margin-bottom: var(--space-1); }
.tour-type-list i { width: 1.25rem; color: var(--brand); margin-right: var(--space-1); }

.tour-booking-note {
    margin: var(--space-4) 0 0;
    padding: var(--space-4);
    background: var(--surface-alt);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    color: var(--text);
    line-height: 1.6;
}
.tour-booking-note[hidden] { display: none; }
.tour-booking-note p { margin: 0 0 var(--space-2); }
.tour-booking-note ul { margin: 0; padding-left: 1.25rem; }

.tour-booking .btn-primary { width: 100%; font-size: var(--fs-lg); }

.tour-booking-free {
    margin: var(--space-4) 0 0;
    text-align: center;
    color: var(--ink);
    font-weight: 600;
}
.tour-booking-free i { color: var(--success); margin-right: var(--space-1); }

@media (max-width: 767.98px) {
    .form-card,
    .tour-booking .form-card { padding: var(--space-6) var(--space-4); }
    /* keep the last lines clear of the floating WhatsApp button */
    .form-section { padding-bottom: 96px; }
    .tour-booking { padding-bottom: 72px; }
}

/* Guard: home.css / pages.css still carry an old bright-orange .btn-primary (fails contrast)
   that loads after components.css. Restate the canonical look for form buttons. */
.form-card .btn-primary,
.thank-you .btn-primary {
    display: inline-flex;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 4px 14px rgba(194, 65, 12, 0.3);
}
.form-card .btn-primary:hover,
.thank-you .btn-primary:hover { background: var(--brand-dark); }
.form-card .btn-secondary,
.thank-you .btn-secondary {
    display: inline-flex;
    background: #fff;
    color: var(--ink);
    border: 2px solid var(--border-strong);
}
