/* =========================
   TERMINE CSS (optimiert)
   - Smartphone: 5% Rand, kein Scroll
   - Tablet Querformat: zentriert
   - Desktop/iPad: Kalender-Navigation einzeilig
   ========================= */

/* Astra Override - Full Width für Spectra Container auf Termine-Seite */
.page-template-page-termine-php .alignfull,
.page-template-page-termine .alignfull {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
}

.page-template-page-termine-php .site-content,
.page-template-page-termine .site-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ==================== KALENDER + LISTE WRAPPER ==================== */

.twp-events-wrapper-grid {
    display: block;
    width: 100%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Zweispaltig ab 1025px */
@media (min-width: 1025px) {
    .twp-events-wrapper-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        align-items: start;
    }
}

/* Cards */
.twp-calendar-section {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: block;
    box-sizing: border-box;
    min-width: 0;
}

.twp-events-list {
    width: 100%;
    display: block;
    min-width: 0;
}

/* Einspaltig bis 1024px */
@media (max-width: 1024px) {
    .twp-calendar-section {
        margin-bottom: 40px;
    }
}

/* ==================== TABLET QUERFORMAT: ZENTRIERUNG ==================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .twp-events-wrapper-grid {
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
        padding: 0 5%;
    }
}

/* ==================== KALENDER NAVIGATION ==================== */
/* Desktop/iPad: immer eine Zeile: Prev | Titel | Next */
.calendar-navigation {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.calendar-prev {
    justify-self: start;
}

.calendar-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0;
    text-align: center;
    justify-self: center;
}

.calendar-next {
    justify-self: end;
}

.calendar-prev,
.calendar-next {
    background: #0d7150;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 24px;
    font-weight: 400;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-prev:hover,
.calendar-next:hover {
    background: #0a5a40;
    transform: translateY(-1px);
}

/* Mobile: Navigation auch einzeilig wie Desktop */
@media (max-width: 768px) {
    .calendar-navigation {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 12px;
    }
    
    .calendar-prev {
        justify-self: start;
    }
    
    .calendar-title {
        font-size: 16px;
        justify-self: center;
    }
    
    .calendar-next {
        justify-self: end;
    }
    
    .calendar-prev,
    .calendar-next {
        padding: 10px 14px;
        font-size: 20px;
        min-width: 44px;
    }
}

/* Fokus-Sichtbarkeit */
.calendar-prev:focus,
.calendar-next:focus,
.event-link-button:focus,
.event-load-more-button:focus {
    outline: 3px solid #0d7150;
    outline-offset: 2px;
}

.event-title a:focus {
    outline: 2px solid #0d7150;
    outline-offset: 2px;
}

/* ==================== KALENDER GRID ==================== */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 20px;
    width: 100%;
}

.calendar-header-row,
.calendar-week-row {
    display: contents;
}

.calendar-day-name {
    text-align: center;
    font-weight: 600;
    color: #0d7150;
    padding: 10px;
    font-size: 14px;
    background: #f0f7f5;
    border-radius: 4px;
}

.calendar-day {
    min-height: 100px;
    padding: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    overflow: hidden;
}

.calendar-day:not(.empty):hover,
.calendar-day:not(.empty):focus-within {
    background: #f0f7f5;
    border-color: #0d7150;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(13, 113, 80, 0.1);
}

.calendar-day.empty {
    background: transparent;
    border: none;
}

.day-number {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.calendar-event-item {
    background: #0d7150;
    color: white;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 11px;
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s ease;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
    max-height: 60px;
}

.calendar-event-item:hover,
.calendar-event-item:focus {
    background: #a7301c;
    transform: scale(1.02);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ==================== SMARTPHONE: 5% RAND, KEIN SCROLL ==================== */
@media (max-width: 768px) {
    /* Wrapper: 90% Breite = 5% Rand links + rechts */
    .twp-events-wrapper-grid {
        width: 90%;
        padding: 0;
        margin: 20px auto;
    }
    
    .twp-calendar-section {
        padding: 16px;
        overflow-x: visible; /* kein Scroll */
        overflow-y: visible;
    }

    .calendar-grid {
        gap: 3px;
        width: 100%;
        min-width: 0;
    }

    .calendar-day {
        min-height: 52px;
        padding: 4px;
    }

    .calendar-day-name {
        font-size: 11px;
        padding: 6px 2px;
    }

    .day-number {
        font-size: 11px;
    }

    .calendar-event-item {
        font-size: 8px;
        padding: 2px 3px;
        max-height: 40px;
        line-height: 1.2;
    }
}

/* ==================== EVENTS LISTE ==================== */

.events-list-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid #0d7150;
}

.events-list-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
}

/* Card darf Inhalt clippen, Grid-Child darf schrumpfen */
.event-item {
    display: grid !important;
    grid-template-columns: 100px 1fr !important;
    gap: 25px !important;
    padding: 30px;
    background: #f9f9f9;
    border-left: 4px solid #0d7150;
    border-radius: 4px;
    transition: all 0.3s ease;
    width: 100% !important;
    align-items: start;
    float: none !important;
    box-sizing: border-box;
    min-width: 0;
    overflow: hidden;
}

.event-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.event-date-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #0d7150;
    color: white;
    border-radius: 4px;
    text-align: center;
    width: 100px;
}

.event-day {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.event-month {
    font-size: 14px;
    text-transform: uppercase;
    margin-top: 5px;
}

.event-year {
    font-size: 12px;
    opacity: 0.9;
}

.event-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.event-title {
    margin: 0 0 10px 0;
    font-size: 20px;
    line-height: 1.3;
    word-wrap: break-word;
}

.event-title a {
    color: #333;
    text-decoration: none;
}

.event-title a:hover {
    color: #0d7150;
}

.event-meta {
    color: #666;
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}

.event-excerpt {
    display: none;
}

/* Button darf umbrechen, nie über Rand */
.event-link-button {
    display: inline-block;
    max-width: 100%;
    padding: 10px 20px;
    background: #a7301c;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s ease;
    font-weight: 500;
    align-self: flex-start;
    white-space: normal;
    overflow-wrap: anywhere;
}

.event-link-button:hover {
    background: #2C2C2C;
}

.event-image {
    display: none !important;
}

/* Mehr laden Button */
.event-load-more-button {
    display: inline-block;
    padding: 15px 40px;
    background: #0d7150;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.event-load-more-button:hover:not(:disabled) {
    background: #0a5a40;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 113, 80, 0.2);
}

.event-load-more-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ==================== RESPONSIVE LISTE ==================== */

@media (max-width: 1024px) {
    .event-item {
        grid-template-columns: 80px 1fr !important;
        gap: 20px !important;
        padding: 20px;
    }
    .event-date-box { width: 80px; }
    .event-title { font-size: 18px; }
    .event-meta { font-size: 13px; }
}

@media (max-width: 768px) {
    .twp-events-list {
        padding: 0;
        box-sizing: border-box;
    }

    .events-list-title {
        font-size: 18px;
        margin-bottom: 15px;
    }

    .event-item {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        padding: 15px;
    }

    .event-date-box {
        width: 100%;
        max-width: none;
        flex-direction: row;
        justify-content: flex-start;
        padding: 10px 15px;
        gap: 12px;
    }

    .event-load-more-button {
        width: 100%;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Screenreader-Status (unsichtbar, aber für SR verfügbar) */
#calendarStatus,
#eventsStatus {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}