/**
 * KEYCONTACTS PAGE STYLES
 * Prinz-von-Homburg-Schule
 *
 * SOTA Design basierend auf Apple, Linear, Stripe, Stanford
 * Beibehaltenes Card-Design mit länglichem Bildformat
 */

/* ==========================================================================
   1. COMPACT HERO
   ========================================================================== */

.keycontacts-hero {
    padding: var(--space-2xl) 0 var(--space-3xl); /* padding-bottom für Platz vor Divider */
    background: white;
}

.keycontacts-hero-container {
    padding-left: 1rem;
    padding-right: 1rem;
}

.keycontacts-hero h1 {
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
    color: var(--brand);
    margin-bottom: var(--space-sm);
}

.keycontacts-hero .hero-subtitle {
    font-size: 1.125rem;
    color: var(--secondary);
    max-width: 600px;
    line-height: 1.6;
    margin-bottom: var(--space-xl);
}

/* Search & Filter Bar */
.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    border-radius: 8px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.search-input-wrapper .material-icons-outlined {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cadet-gray);
    font-size: 20px;
}

#contact-search {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 1px solid var(--ui-background);
    border-radius: 8px;
    font-size: 1rem;
    background: transparent;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease;
}

/* Default: weißer Hintergrund wenn Wrapper keine Farbe hat */
.search-input-wrapper:not([style*="background"]) #contact-search {
    background: white;
}

#contact-search:focus {
    outline: none;
    border-color: var(--penn-blue);
    box-shadow: 0 0 0 3px rgba(20, 27, 77, 0.1);
}

/* Filter Pills */
.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-pill {
    padding: 8px 16px;
    border: 2px solid var(--ui-background);
    border-radius: 20px;
    background: white;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill.active {
    background: var(--penn-blue);
    border-color: var(--penn-blue);
    color: white;
}

/* ==========================================================================
   FILTER-PILL FARBEN - Palette-Reihenfolge
   1. Deep Navy (#141B4D) → Leitung
   2. Dust Grey (#DBD5CD) → Sekretariat
   3. Powder Blue (#B1C6DB) → Grundschule
   4. Muted Olive (#BCCA87) → Sek I
   5. Old Gold (#CEB829) → Oberstufe
   6. Deep Navy (#141B4D) → Reitsport
   ========================================================================== */

.filter-pills .filter-pill[data-filter="Leitung"] {
    background: rgba(20, 27, 77, 0.2);
    border-color: var(--penn-blue);
    color: var(--penn-blue);
}
.filter-pills .filter-pill[data-filter="Verwaltung"] {
    background: rgba(219, 213, 205, 0.6);
    border-color: var(--timberwolf);
    color: #5D4037;
}
.filter-pills .filter-pill[data-filter="Grundschule"] {
    background: rgba(188, 202, 135, 0.4);
    border-color: var(--olivine);
    color: #3a4a2a;
}
.filter-pills .filter-pill[data-filter="Mittelstufe"] {
    background: rgba(177, 198, 219, 0.4);
    border-color: var(--powder-blue);
    color: #3a5a7a;
}
.filter-pills .filter-pill[data-filter="Oberstufe"] {
    background: rgba(206, 184, 41, 0.3);
    border-color: var(--old-gold);
    color: #6a5a10;
}
.filter-pills .filter-pill[data-filter="Reitsport"] {
    background: rgba(20, 27, 77, 0.15);
    border-color: var(--penn-blue);
    color: var(--penn-blue);
}

/* Active States */
.filter-pills .filter-pill[data-filter="Leitung"].active {
    background: var(--penn-blue);
    border-color: var(--penn-blue);
    color: white;
}
.filter-pills .filter-pill[data-filter="Verwaltung"].active {
    background: var(--timberwolf);
    border-color: var(--timberwolf);
    color: var(--penn-blue);
}
.filter-pills .filter-pill[data-filter="Grundschule"].active {
    background: var(--olivine);
    border-color: var(--olivine);
    color: var(--penn-blue);
}
.filter-pills .filter-pill[data-filter="Mittelstufe"].active {
    background: var(--powder-blue);
    border-color: var(--powder-blue);
    color: var(--penn-blue);
}
.filter-pills .filter-pill[data-filter="Oberstufe"].active {
    background: var(--old-gold);
    border-color: var(--old-gold);
    color: white;
}
.filter-pills .filter-pill[data-filter="Reitsport"].active {
    background: var(--penn-blue);
    border-color: var(--penn-blue);
    color: white;
}

/* Sticky Filter Bar */
.sticky-filter-bar {
    position: sticky;
    top: 60px;
    z-index: 100;
    background: white;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--ui-background);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.sticky-filter-bar.visible {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================================
   2. TEAM SECTIONS
   ========================================================================== */

.team-section {
    margin-bottom: 0;
    padding: 4rem 0;
}

/* Erste Section: mehr Abstand zum Divider */
.team-section:first-of-type {
    padding-top: 4rem;
}

/* ==========================================================================
   SECTION-HINTERGRÜNDE - Opaque Farben (keine Transparenz!)
   ========================================================================== */

.team-section.section-leadership {
    --section-accent: var(--penn-blue);
    background: #F7F7F7;
}
.team-section.section-sekretariat {
    --section-accent: var(--timberwolf);
    background: #F7F5F3;
}
.team-section.section-grundschule {
    --section-accent: var(--olivine);
    background: #EBF0E3;
}
.team-section.section-sek1 {
    --section-accent: var(--powder-blue);
    background: #E8EEF3;
}
.team-section.section-oberstufe {
    --section-accent: var(--old-gold);
    background: #F5F1E0;
}
.team-section.section-reitsport {
    --section-accent: var(--penn-blue);
    background: #EDEEF2;
}

/* Keine Farbpunkte vor h2 - sauberes Design */

/* ==========================================================================
   3. CARDS SCROLLER (Horizontal Scrolling - Netflix Style)
   ========================================================================== */

.cards-scroller-wrapper {
    position: relative;
}

.cards-scroller {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 0;
    margin: 0;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Richtung wird vom Browser per initial-gesture-delta erkannt.
       touch-action auf pan-x würde mit pan-y im Child zu leerer Intersection
       und damit zu komplett blockierten Gesten führen (MDN/WebKit-Spec). */
    overscroll-behavior-x: contain;
}

.cards-scroller::-webkit-scrollbar {
    display: none;
}

.cards-scroller-platter {
    display: flex;
    gap: 20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    width: max-content;
}

/* Scroll Buttons (Desktop) */
.section-scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s, transform 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--penn-blue);
}

.cards-scroller-wrapper:hover .section-scroll-btn {
    opacity: 1;
}

.section-scroll-btn:hover {
    transform: translateY(-50%) scale(1.1);
    background: var(--penn-blue);
    color: white;
}

.section-scroll-btn.prev { left: 8px; }
.section-scroll-btn.next { right: 8px; }

/* Mobile: Scroll-Buttons ausblenden */
@media (max-width: 768px) {
    .section-scroll-btn {
        display: none;
    }
}

/* Desktop: Grid-Layout statt horizontales Scrollen */
@media (min-width: 769px) {
    .cards-scroller {
        overflow-x: visible;
        overflow-y: visible;
        width: auto;
        margin-left: 0;
        scroll-snap-type: none;
        touch-action: auto;
    }

    .cards-scroller-platter {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 24px;
        width: auto;
        padding: 0 2rem;
        max-width: 1400px;
        margin: 0 auto;
    }

    .contact-card {
        width: auto;
        scroll-snap-align: none;
    }

    /* Scroll-Buttons auf Desktop nicht mehr nötig */
    .section-scroll-btn {
        display: none;
    }

    /* Section-Headings mit korrektem Padding */
    .team-section h2 {
        padding-left: 2rem;
        padding-right: 2rem;
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Hero Container an Grid anpassen */
    .keycontacts-hero-container {
        padding-left: 2rem;
        padding-right: 2rem;
        max-width: 1400px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ==========================================================================
   4. CONTACT CARDS
   ========================================================================== */

.contact-card {
    flex: 0 0 auto;
    width: 300px;
    height: 450px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
}

.contact-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Card Image */
.contact-card-image {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: var(--ui-background);
    flex-shrink: 0;
    position: relative;
}

/* Initialen-Avatar für fehlende Bilder */
.contact-card-image.initials-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-card-image .initials {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

/* Email Quick Action (Overlay auf Bild) */
.card-quick-email {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    color: var(--penn-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
    opacity: 0;
    text-decoration: none;
}

.contact-card:hover .card-quick-email {
    opacity: 1;
}

.card-quick-email:hover {
    transform: scale(1.1);
    background: var(--penn-blue);
    color: white;
}

.card-quick-email .material-icons-outlined {
    font-size: 18px;
}

/* Card Content */
.contact-card-content {
    padding: 20px 24px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.contact-card-name {
    font-family: var(--font-brand);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: 4px;
    line-height: 1.2;
}

.contact-card-role {
    font-family: var(--font-interface);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--penn-blue);
    margin-bottom: 12px;
}

/* Card Info (Scrollable - Gradient zeigt mehr Inhalt) */
.contact-card-info {
    font-family: var(--font-interface);
    font-size: 0.875rem;
    color: var(--secondary);
    line-height: 1.4;
    flex: 1;
    min-height: 0;                /* iOS: flex-child darf kleiner werden als Content → overflow greift */
    overflow-y: auto;
    overscroll-behavior: contain; /* Verhindert Scroll-Chaining zur Hauptseite */
    position: relative;
    max-height: 180px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--ui-background) transparent;
}

.contact-card-info::-webkit-scrollbar {
    width: 4px;
}

.contact-card-info::-webkit-scrollbar-track {
    background: transparent;
}

.contact-card-info::-webkit-scrollbar-thumb {
    background: var(--ui-background);
    border-radius: 2px;
}

/* Gradient-Overlay als Scroll-Hinweis (via Pseudo-Element auf Parent) */
.contact-card-content::after {
    content: '';
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
    height: 30px;
    background: linear-gradient(transparent, white);
    pointer-events: none;
}

/* Responsibilities Box */
.contact-card-responsibilities {
    background: var(--ui-background);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.contact-card-responsibilities h4 {
    font-family: var(--font-interface);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--penn-blue);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-card-responsibilities ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.contact-card-responsibilities li {
    font-family: var(--font-interface);
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 2px;
}

/* Contact Details */
.contact-card-contact {
    border-top: 1px solid var(--ui-background);
    padding-top: 12px;
    font-family: var(--font-interface);
    font-size: 0.75rem;
    color: var(--secondary);
}

.contact-card-contact a {
    color: var(--penn-blue);
    text-decoration: none;
    transition: all 0.2s ease;
}

.contact-card-contact a:hover {
    text-decoration: underline;
    color: var(--brand);
}

/* Contact Items mit Icons */
.contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    line-height: 1.4;
}

.contact-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--battleship-gray);
}

.contact-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--penn-blue);
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

.contact-item span {
    flex: 1;
    word-break: break-word;
}

/* Bio */
.contact-card-bio {
    font-family: var(--font-interface);
    font-size: 0.8125rem;
    color: var(--secondary);
    line-height: 1.4;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--ui-background);
}

/* Expand Button - ENTFERNT: Scroll in Card ist intuitiver */

/* ==========================================================================
   5. DETAIL MODAL
   ========================================================================== */

.contact-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 27, 77, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.contact-modal.active {
    opacity: 1;
    visibility: visible;
}

.contact-modal .modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 32px;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.contact-modal.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--ui-background);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--penn-blue);
    color: white;
}

.modal-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 20px;
    background-size: cover;
    background-position: center;
    background-color: var(--penn-blue);
}

.modal-name {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand);
    margin-bottom: 4px;
}

.modal-role {
    text-align: center;
    font-size: 1rem;
    color: var(--penn-blue);
    margin-bottom: 24px;
}

.modal-details {
    background: var(--ui-background);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}


.detail-row .material-icons-outlined {
    color: var(--penn-blue);
    font-size: 20px;
    flex-shrink: 0;
}

.detail-text {
    font-size: 0.9375rem;
    color: var(--secondary);
    line-height: 1.4;
}

.modal-bio {
    font-size: 0.9375rem;
    color: var(--secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: center;
}

.modal-email {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--penn-blue);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s;
}

.modal-email:hover {
    background: var(--brand);
}

/* ==========================================================================
   6. PLACEHOLDER CARD
   ========================================================================== */

.contact-card.placeholder .contact-card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .contact-card {
        width: 280px;
        height: 430px;
    }

    .cards-scroller-platter {
        padding-left: 16px;
        padding-right: 16px;
        gap: 16px;
    }

    .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-wrapper {
        max-width: none;
    }

    .filter-pills {
        justify-content: center;
    }

    .keycontacts-hero h1 {
        font-size: 1.75rem;
    }

    /* Modal: Kompakte Gesamtansicht auf Mobile — alles ohne Scroll sichtbar */
    .contact-modal {
        align-items: flex-start;
        padding: 12px;
    }

    .contact-modal .modal-content {
        max-height: calc(100dvh - 24px);
        width: 100%;
        padding: 20px 20px 24px;
        margin-top: 12px;
        display: grid;
        grid-template-columns: 72px 1fr;
        grid-template-areas:
            "avatar name"
            "avatar role"
            "details details"
            "bio bio"
            "actions actions";
        column-gap: 16px;
        row-gap: 8px;
    }

    .contact-modal .modal-avatar {
        grid-area: avatar;
        width: 72px;
        height: 72px;
        margin: 0;
        align-self: center;
    }

    .contact-modal .modal-avatar .initials {
        font-size: 1.5rem !important;
    }

    .contact-modal .modal-name,
    .contact-modal .modal-role {
        text-align: left;
        margin: 0;
    }

    .contact-modal .modal-name {
        grid-area: name;
        align-self: end;
        font-size: 1.125rem;
        line-height: 1.2;
    }

    .contact-modal .modal-role {
        grid-area: role;
        align-self: start;
        font-size: 0.875rem;
        line-height: 1.3;
    }

    .contact-modal .modal-details {
        grid-area: details;
        padding: 12px 14px;
        margin: 12px 0 0;
    }

    .contact-modal .detail-row {
        padding: 6px 0;
        font-size: 0.875rem;
    }

    .contact-modal .detail-text {
        font-size: 0.875rem;
    }

    .contact-modal .modal-bio {
        grid-area: bio;
        margin: 0;
        font-size: 0.875rem;
        line-height: 1.5;
    }

    .contact-modal .modal-actions {
        grid-area: actions;
        margin: 0;
    }

    .contact-modal .modal-email {
        padding: 10px 20px;
    }

    .modal-close {
        top: 8px;
        right: 8px;
    }
}

/* ==========================================================================
   8. SEARCH RESULTS SECTION
   ========================================================================== */

.section-search {
    background: var(--seasalt);
}

.section-search h2 {
    color: var(--brand);
}

/* ==========================================================================
   9. HIDDEN UTILITY
   ========================================================================== */

.contact-card.hidden {
    display: none;
}

.team-section.hidden {
    display: none;
}
