/* FOUC-Guard */
html.js-loading body { visibility: hidden; }

/* =========================================================
   IAN- Reha Klinik — Stylesheet
   ========================================================= */

/* ---------- 1. Design Tokens ---------- */
:root {
    --primary-color: #4A7C59;
    --primary-dark: #3a6247;
    --secondary-color: #6BAED6;
    --accent-color: #D88A72;
    --bg-color: #FDFBF7;
    --text-dark: #2d2d2d;
    --text-light: #666666;
    --white: #FFFFFF;

    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Lato', system-ui, -apple-system, sans-serif;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 5rem;

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 30px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 15px 30px rgba(0, 0, 0, 0.12);

    --transition: all 0.3s ease;
    --nav-height: 80px;
}

html[lang="ar"] {
    --font-heading: 'Amiri', 'Playfair Display', serif;
    --font-body: 'Tajawal', 'Lato', sans-serif;
}
html[lang="ar"] body { line-height: 1.9; }

/* ---------- 2. Reset & Grundlagen ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-height);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text-dark);
    background-color: var(--bg-color);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background-color: var(--accent-color);
    color: var(--white);
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-bottom: var(--space-sm);
    line-height: 1.35;
    text-wrap: balance;
}

p {
    margin-bottom: var(--space-sm);
    color: var(--text-light);
    text-wrap: pretty;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }
address { font-style: normal; }

:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: 3000;
    background: var(--primary-color);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    transition: top 0.2s ease;
}
.skip-link:focus { top: 16px; }

/* ---------- 3. Layout-Helfer ---------- */
.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section { padding: var(--space-xl) 0; }

.section-title {
    text-align: center;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    margin-bottom: var(--space-lg);
    position: relative;
}
.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background-color: var(--accent-color);
    margin: 15px auto 0;
}

.section-intro {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 2.5rem;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: var(--radius-lg);
    font-weight: 700;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}
.btn:hover, .btn:focus-visible {
    background-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ---------- 4. Navigation ---------- */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(253, 251, 247, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--nav-height);
    gap: 15px;
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links {
    display: flex;
    gap: 25px;
    list-style: none;
}
.nav-links a {
    font-weight: 400;
    color: var(--text-dark);
    transition: color var(--transition);
    position: relative;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -6px;
    inset-inline-start: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--primary-color); }
.nav-links a:hover::after, .nav-links a:focus-visible::after { width: 100%; }

.lang-switcher { display: flex; gap: 5px; align-items: center; }
.lang-btn {
    background: none;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 5px 11px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.5px;
}
.lang-btn:hover, .lang-btn.active, .lang-btn[aria-pressed="true"] {
    background: var(--primary-color);
    color: var(--white);
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, color 0.2s ease;
}
.menu-toggle:hover { background: rgba(74, 124, 89, 0.1); }
.menu-toggle.active { color: var(--accent-color); }

/* ---------- 5. Hero ---------- */
.hero {
    height: 100vh;
    min-height: 600px;
    background:
        linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
        url('https://images.unsplash.com/photo-1540555700478-4be289fbecef?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80') center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
}

.hero-content {
    max-width: 800px;
    color: var(--white);
    animation: fadeIn 1.2s ease both;
}
.hero-content h1 {
    font-size: clamp(2.2rem, 6vw, 4rem);
    color: var(--white);
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.hero-content p {
    font-size: clamp(1.05rem, 1.5vw, 1.2rem);
    color: var(--white);
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
html[lang="ar"] .hero-content h1 { font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.3; }

/* ---------- 6. Philosophie ---------- */
.philosophy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}
.philosophy-image img { aspect-ratio: 4 / 3; object-fit: cover; }
.philosophy-text h2 { font-size: clamp(1.7rem, 3.5vw, 2.2rem); }

/* ---------- 7. Therapien ---------- */
.therapies { background-color: var(--white); }

.therapy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}
.therapy-card {
    background-color: var(--bg-color);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    text-align: center;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.therapy-card:hover, .therapy-card:focus-within {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}
.therapy-card h3 { font-size: 1.5rem; margin-bottom: 15px; }

/* ---------- 8. Zimmer & Suiten ---------- */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}
.room-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}
.room-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.room-card img { aspect-ratio: 16 / 10; object-fit: cover; border-radius: 0; width: 100%; }
.room-info { padding: 25px; flex: 1; display: flex; flex-direction: column; }
.room-info h3 { font-size: 1.4rem; margin-bottom: 10px; }
.room-features {
    list-style: none;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #eee;
}
.room-features li {
    position: relative;
    padding-inline-start: 24px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-light);
}
.room-features li::before {
    content: '✓';
    position: absolute;
    inset-inline-start: 0;
    color: var(--primary-color);
    font-weight: bold;
}

/* ---------- 9. Galerie ---------- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    aspect-ratio: 4 / 3;
    background: #e8e4dc;
}
.gallery-item img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}
.gallery-item:hover img, .gallery-item:focus-within img { transform: scale(1.05); }

/* ---------- 10. Testimonials ---------- */
.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}
.testimonial-card {
    background-color: var(--bg-color);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    position: relative;
    font-style: italic;
    color: var(--text-dark);
}
.testimonial-card::before {
    content: '“';
    position: absolute;
    top: 10px;
    left: 20px;
    font-size: 5rem;
    color: rgba(74, 124, 89, 0.1);
    font-family: serif;
    line-height: 1;
    pointer-events: none;
}
html[dir="rtl"] .testimonial-card::before { left: auto; right: 20px; }
.testimonial-card .stars {
    color: #F5B041;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-style: normal;
}
.testimonial-card p { position: relative; z-index: 1; }
.testimonial-author {
    margin-top: 20px;
    font-style: normal;
    display: flex;
    flex-direction: column;
}
.testimonial-author strong { color: var(--primary-color); font-size: 1rem; }
.testimonial-author span { font-size: 0.85rem; color: var(--text-light); }

/* ---------- 11. Kontaktformular ---------- */
.contact-container { max-width: 800px; margin: 0 auto; }
.contact-form {
    background-color: var(--white);
    border-radius: var(--radius-md);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid #eee;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 20px; position: relative; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-dark); margin-bottom: 8px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-dark);
    background-color: var(--bg-color);
    transition: all var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}
.form-group input.error,
.form-group select.error,
.form-group textarea.error { border-color: #e74c3c; background-color: #fdf2f2; }
.form-error { display: block; font-size: 0.8rem; color: #e74c3c; margin-top: 6px; min-height: 16px; }
.form-checkbox { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; }
.form-checkbox input[type="checkbox"] {
    width: 18px; height: 18px;
    margin-top: 3px;
    cursor: pointer;
    accent-color: var(--primary-color);
}
.form-checkbox label {
    flex: 1;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0;
    cursor: pointer;
    line-height: 1.5;
}
.form-checkbox label a { color: var(--primary-color); font-weight: 600; text-decoration: underline; }
.btn-submit { width: 100%; padding: 16px; font-size: 1.05rem; margin-top: 10px; }
.btn-submit.loading { pointer-events: none; opacity: 0.7; }
.form-success { text-align: center; padding: 30px 20px; animation: fadeIn 0.5s ease both; }
.form-success-icon {
    width: 60px; height: 60px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
}
.form-success h3 { font-size: 1.4rem; margin-bottom: 10px; }
.form-success p { color: var(--text-light); }

/* ---------- 12. Footer ---------- */
footer {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 60px 0 20px;
}
.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}
footer h4 {
    color: var(--white);
    font-family: var(--font-body);
    font-size: 1.2rem;
    margin-bottom: 20px;
}
footer p, footer a, footer button {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
}
footer a { text-decoration: underline; text-underline-offset: 2px; }
footer a:hover, footer button:hover { color: var(--white); }
.footer-link-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: start;
    display: block;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}
.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.8rem;
}

/* ---------- 13. Modals ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
}
.modal.active { display: flex; opacity: 1; }
.modal-content {
    background-color: var(--bg-color);
    padding: 40px;
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.3s ease;
}
.modal.active .modal-content { transform: translateY(0) scale(1); }
.modal-content::-webkit-scrollbar { width: 8px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 4px; }
.close-btn {
    position: absolute;
    top: 12px;
    inset-inline-end: 16px;
    width: 40px;
    height: 40px;
    font-size: 1.8rem;
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    border-radius: 50%;
}
.close-btn:hover, .close-btn:focus-visible { color: var(--accent-color); background: rgba(0, 0, 0, 0.05); }
.modal-content h2 {
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
    padding-inline-end: 40px;
}
.modal-content h3 { font-size: 1.3rem; margin-top: 25px; margin-bottom: 10px; }
.modal-content p, .modal-content li { font-size: 0.95rem; color: var(--text-dark); }
.modal-content ul { margin-inline-start: 20px; margin-bottom: 15px; }

/* ---------- 14. Back-to-Top Button ---------- */
.back-to-top {
    position: fixed;
    bottom: 30px;
    inset-inline-end: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, background-color 0.3s;
    z-index: 999;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
}

/* ---------- 15. Terminkalender ---------- */
.calendar-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}
.cal-btn {
    background: var(--white);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.cal-btn:hover, .cal-btn.active {
    background: var(--primary-color);
    color: var(--white);
}
.calendar-wrapper {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    min-width: 600px;
}
.cal-day-header {
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
    padding: 10px 0;
    border-bottom: 2px solid var(--bg-color);
    font-size: 0.9rem;
}
.cal-day {
    text-align: center;
    padding: 15px 5px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70px;
}
.cal-day.free {
    background-color: #e6f4ea;
    color: var(--primary-color);
    border: 1px solid #cce8d5;
    cursor: pointer;
}
.cal-day.free:hover {
    background-color: var(--primary-color);
    color: var(--white);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}
.cal-day.busy {
    background-color: #f1f3f5;
    color: #adb5bd;
    cursor: not-allowed;
    border: 1px solid #e9ecef;
}
.cal-day.busy span {
    font-size: 0.7rem;
    text-transform: uppercase;
    margin-top: 4px;
}
.cal-day.selected {
    background-color: var(--accent-color) !important;
    color: var(--white) !important;
    border-color: var(--accent-color) !important;
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}
.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-light);
}
.legend-item { display: flex; align-items: center; gap: 8px; }
.color-box { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.color-box.free { background-color: #e6f4ea; border: 1px solid #cce8d5; }
.color-box.busy { background-color: #f1f3f5; border: 1px solid #e9ecef; }
.selected-appointment-info {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(216, 138, 114, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-md);
    color: var(--text-dark);
}

/* ---------- 16. Animationen ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
    will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- 17. Responsive ---------- */
@media (max-width: 1000px) {
    .nav-links { gap: 15px; }
    .nav-links a { font-size: 0.85rem; }
    .lang-btn { padding: 4px 8px; font-size: 0.75rem; }
}

@media (max-width: 850px) {
    .menu-toggle { display: block; }
    .nav-right { gap: 12px; }
    .nav-links {
        position: absolute;
        top: var(--nav-height);
        inset-inline-start: -100%;
        flex-direction: column;
        background-color: var(--bg-color);
        width: 100%;
        text-align: center;
        padding: 20px 0;
        box-shadow: 0 10px 10px rgba(0, 0, 0, 0.05);
        transition: inset-inline-start var(--transition);
        gap: 15px;
    }
    .nav-links.active { inset-inline-start: 0; }
    .nav-links a { font-size: 1rem; display: inline-block; padding: 6px 0; }
    .logo { font-size: 1.1rem; }
    .philosophy-grid { grid-template-columns: 1fr; gap: 30px; }
    .gallery-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .contact-form { padding: 25px; }
    .modal-content { padding: 25px; }
    .back-to-top { bottom: 20px; inset-inline-end: 20px; width: 45px; height: 45px; }
}

@media (max-width: 380px) {
    .logo { font-size: 0.95rem; }
    .lang-btn { padding: 3px 6px; font-size: 0.7rem; }
}

/* ---------- 18. Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal, .back-to-top { opacity: 1; transform: none; visibility: visible; }
}

/* ---------- 19. Print ---------- */
@media print {
    nav, footer, .hero, .modal, .lang-switcher, .menu-toggle, .btn, .back-to-top, .calendar-wrapper, .contact-form { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .section { padding: 1rem 0; }
    a { color: #000; text-decoration: underline; }
    .reveal { opacity: 1; transform: none; }
}