/**
 * „Wunschtermin anfragen" auf den Exposé-Landing-Pages
 * Baustein: assets/js/landing-viewing-request.js · Präfix: lvr-
 *
 * Light-Design passend zu .landing-section (assets/css/landing-expose.css).
 * Kontraste WCAG AA: Fließtext ≥ 4.5:1, Feldränder/Bedienelemente ≥ 3:1.
 * Markengrün nur als Fläche mit schwarzer Schrift, Primärbutton schwarz/weiß.
 */

.lvr-section {
    --lvr-text: var(--color-text, #1e1e1e);
    --lvr-text-2: #555555;              /* 7.4:1 auf Weiß, 7.0:1 auf #f9f9f9 */
    --lvr-surface: var(--color-surface, #ffffff);
    --lvr-subtle: var(--color-background, #f9f9f9);
    --lvr-line: var(--color-border, #e0e0e0);
    --lvr-field-border: #8a8a8a;        /* 3.4:1 — Feldrand als Bedienelement erkennbar */
    --lvr-primary: var(--color-primary, #000000);
    --lvr-accent: var(--color-accent, #00e8a2);
    --lvr-accent-soft: #e6fcf5;
    --lvr-error: #b3261e;               /* 6.5:1 auf Weiß */
    --lvr-error-bg: #fdecea;
    --lvr-focus: #000000;
    --lvr-radius: 10px;
    color: var(--lvr-text);
}

.lvr-section *,
.lvr-section *::before,
.lvr-section *::after {
    box-sizing: border-box;
}

.lvr-intro {
    margin: 0 0 24px 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--lvr-text-2);
}

.lvr-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ------------------------------------------------------------ Gruppen */

.lvr-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.lvr-legend {
    padding: 0;
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--lvr-text);
}

.lvr-hint {
    margin: 0 0 14px 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--lvr-text-2);
}

.lvr-hint-field {
    margin: 6px 0 0 0;
}

/* ------------------------------------------------------------ Wunschtermine */

.lvr-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lvr-row {
    background: var(--lvr-subtle);
    border: 1px solid var(--lvr-line);
    border-radius: 12px;
    padding: 16px 18px 18px;
}

.lvr-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
    margin-bottom: 10px;
}

.lvr-row-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--lvr-text);
}

.lvr-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -8px -10px -8px 0;
    padding: 0;
    color: var(--lvr-text-2);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.lvr-remove:hover {
    color: var(--lvr-text);
    background: rgba(0, 0, 0, 0.06);
}

.lvr-remove[hidden] {
    display: none;
}

.lvr-row-body {
    display: grid;
    grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.lvr-date-text {
    margin: 6px 0 0 0;
    min-height: 0;
    font-size: 14px;
    color: var(--lvr-text-2);
}

.lvr-date-text:empty {
    display: none;
}

/* Tageszeit als Segment-Buttons (echte Radios, visuell versteckt) */
.lvr-daytime {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.lvr-daytime > .lvr-label {
    padding: 0;
}

.lvr-segments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.lvr-segment-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.lvr-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 6px 8px;
    text-align: center;
    background: var(--lvr-surface);
    border: 1px solid var(--lvr-field-border);
    border-radius: var(--lvr-radius);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.lvr-segment-label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--lvr-text);
}

.lvr-segment-hint {
    font-size: 14px;
    line-height: 1.2;
    color: var(--lvr-text-2);
}

.lvr-segment:hover {
    border-color: var(--lvr-text);
}

.lvr-segment-input:checked + .lvr-segment {
    background: var(--lvr-accent);
    border-color: var(--lvr-primary);
    box-shadow: inset 0 0 0 1px var(--lvr-primary);
}

.lvr-segment-input:checked + .lvr-segment .lvr-segment-label,
.lvr-segment-input:checked + .lvr-segment .lvr-segment-hint {
    color: #000000;
}

.lvr-segment-input:focus-visible + .lvr-segment {
    outline: 3px solid var(--lvr-focus);
    outline-offset: 2px;
}

.lvr-daytime.lvr-has-error .lvr-segment {
    border-color: var(--lvr-error);
}

.lvr-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    margin-top: 12px;
    padding: 10px 16px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--lvr-text);
    background: transparent;
    border: 1px dashed var(--lvr-field-border);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.lvr-add:hover {
    background: var(--lvr-subtle);
    border-color: var(--lvr-text);
}

.lvr-add[hidden] {
    display: none;
}

/* ------------------------------------------------------------ Felder */

/*
 * :not(#lvr-x) hebt die Spezifität auf (1,2,0): theme.css färbt Felder mit
 * input:not(…):not(…)… = (0,8,1) — ohne die ID-Stufe gewinnt dort der helle
 * Rand (#e0e0e0, 1.3:1) und das Feld ist kaum als Feld erkennbar.
 */

.lvr-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.lvr-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lvr-label {
    display: block;
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--lvr-text);
}

.lvr-optional {
    font-weight: 400;
    color: var(--lvr-text-2);
}

.lvr-section .lvr-input:not(#lvr-x) {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
    font: inherit;
    font-size: 16px;                    /* iOS zoomt unter 16px ins Feld */
    line-height: 1.4;
    color: var(--lvr-text);
    background: var(--lvr-surface);
    border: 1px solid var(--lvr-field-border);
    border-radius: var(--lvr-radius);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-text-fill-color: var(--lvr-text);
    -webkit-appearance: none;
    appearance: none;
}

.lvr-section .lvr-input:not(#lvr-x)::placeholder {
    color: #6b6b6b;                     /* 5.3:1 */
    -webkit-text-fill-color: #6b6b6b;
    opacity: 1;
}

.lvr-section .lvr-input:not(#lvr-x):hover {
    border-color: var(--lvr-text);
}

.lvr-section .lvr-input:not(#lvr-x):focus-visible,
.lvr-section .lvr-input:not(#lvr-x):focus {
    border-color: var(--lvr-primary);
    background-color: var(--lvr-surface);
    box-shadow: 0 0 0 3px rgba(0, 232, 162, 0.45), 0 0 0 1px var(--lvr-primary) inset;
}

.lvr-section .lvr-date {
    min-width: 0;
    background: var(--lvr-surface);
}

/* Safari/iOS: leeres Datumsfeld behält sonst keine Höhe */
.lvr-date::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1.4em;
}

.lvr-date::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
}

.lvr-section .lvr-textarea {
    min-height: 96px;
    resize: vertical;
}

.lvr-counter {
    align-self: flex-end;
    margin: 6px 0 0 0;
    font-size: 14px;
    color: var(--lvr-text-2);
}

.lvr-field-full {
    width: 100%;
}

.lvr-section .lvr-has-error .lvr-input:not(#lvr-x),
.lvr-section .lvr-input:not(#lvr-x)[aria-invalid="true"] {
    border-color: var(--lvr-error);
    box-shadow: 0 0 0 1px var(--lvr-error) inset;
}

.lvr-error {
    display: flex;
    gap: 6px;
    margin: 6px 0 0 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--lvr-error);
}

.lvr-error::before {
    content: "!";
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: #ffffff;
    background: var(--lvr-error);
    border-radius: 50%;
}

.lvr-error[hidden] {
    display: none;
}

/* ------------------------------------------------------------ Einwilligung */

.lvr-consent {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
    padding: 14px 16px;
    background: var(--lvr-subtle);
    border: 1px solid var(--lvr-line);
    border-radius: 12px;
}

.lvr-consent.lvr-has-error {
    border-color: var(--lvr-error);
    background: var(--lvr-error-bg);
}

.lvr-checkbox {
    width: 22px;
    height: 22px;
    margin: 1px 0 0 0;
    accent-color: var(--lvr-primary);
    cursor: pointer;
}

.lvr-checkbox:focus-visible {
    outline: 3px solid var(--lvr-focus);
    outline-offset: 2px;
}

.lvr-consent-label {
    font-size: 14px;
    line-height: 1.55;
    color: var(--lvr-text);
    cursor: pointer;
}

.lvr-consent .lvr-error {
    grid-column: 2;
}

.lvr-link {
    color: var(--lvr-text);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.lvr-link:hover {
    text-decoration-thickness: 2px;
}

.lvr-link:focus-visible {
    outline: 2px solid var(--lvr-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

.lvr-required {
    color: var(--lvr-text-2);
}

/* Honeypot: für Menschen unsichtbar, für Screenreader ausgeblendet (aria-hidden) */
.lvr-hp {
    position: absolute !important;
    left: -10000px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* ------------------------------------------------------------ Absenden */

.lvr-form-error {
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--lvr-error);
    background: var(--lvr-error-bg);
    border: 1px solid var(--lvr-error);
    border-radius: 10px;
}

.lvr-form-error[hidden] {
    display: none;
}

.lvr-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding-top: 4px;
}

.lvr-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    padding: 14px 28px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: var(--lvr-primary);
    border: 0;
    border-radius: var(--lvr-radius);
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.lvr-submit:hover:not(:disabled) {
    opacity: 0.88;
}

.lvr-submit:active:not(:disabled) {
    transform: translateY(1px);
}

.lvr-submit:focus-visible {
    outline: 3px solid var(--lvr-accent);
    outline-offset: 3px;
}

.lvr-submit:disabled {
    cursor: progress;
    opacity: 0.75;
}

.lvr-submit.is-loading::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: lvr-spin 0.8s linear infinite;
}

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

.lvr-note {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--lvr-text-2);
}

/* ------------------------------------------------------------ Erfolg */

.lvr-success {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0 4px;
}

.lvr-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    color: #000000;
    background: var(--lvr-accent);
    border-radius: 50%;
}

.lvr-success-title {
    margin: 6px 0 0 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--lvr-text);
}

.lvr-success-title:focus {
    outline: none;
}

.lvr-success-text {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: var(--lvr-text-2);
}

.lvr-success-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin: 8px 0 0 0;
    padding: 0;
    list-style: none;
}

.lvr-success-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--lvr-text);
    background: var(--lvr-accent-soft);
    border-radius: 10px;
}

.lvr-success-item svg {
    flex: 0 0 auto;
}

/* ------------------------------------------------------------ Mobil */

@media (max-width: 768px) {
    .lvr-row-body,
    .lvr-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .lvr-row {
        padding: 14px 14px 16px;
    }

    .lvr-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .lvr-submit {
        width: 100%;
    }

    .lvr-note {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .lvr-segments {
        gap: 6px;
    }

    .lvr-segment {
        padding: 6px 2px;
    }

    .lvr-segment-label {
        font-size: 14px;
        letter-spacing: -0.01em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lvr-segment,
    .lvr-section .lvr-input:not(#lvr-x),
    .lvr-add,
    .lvr-submit {
        transition: none;
    }

    .lvr-submit.is-loading::before {
        animation-duration: 2s;
    }
}
