/* Schedule module: next entries, list, calendar and print view */
.mod-termine { margin: 16px 0; text-align: left; }

.termine-kopf { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.termine-drucken {
    padding: 8px 14px;
    border: 0;
    border-radius: 6px;
    background: #27ae60;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}
.termine-drucken:hover { background: #229954; }

.termine-leer { color: #666; font-style: italic; }

/* Next rehearsal / next event */
.termine-naechste {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.termin-karte {
    padding: 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #fff;
}
.termin-art {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72em;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.termin-probe .termin-art { background: #e8f4f8; color: #2471a3; }
.termin-veranstaltung .termin-art { background: #fdeef0; color: #b03a2e; }
.termin-datum { font-weight: 700; margin-bottom: 4px; }
.termin-zeit, div.termin-ort { color: #555; font-size: 0.92em; }
.termin-titel { font-weight: 600; margin-top: 6px; }
.termin-gruppen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.termin-gruppe {
    --termin-gruppe: #555;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.72em;
    font-weight: 600;
    color: var(--termin-gruppe);
    border: 1px solid var(--termin-gruppe);
}

/* List */
.termine-tabelle { overflow-x: auto; }
.termine-tabelle table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.termine-tabelle th { background: #34495e; color: #fff; text-align: left; padding: 8px 7px; }
.termine-tabelle td { padding: 7px; border-bottom: 1px solid #ddd; vertical-align: top; }
.termine-tabelle tbody tr:nth-child(even) td { background: #f5f7f9; }
.termine-tabelle tbody tr.termin-veranstaltung td { background: #fdf3f4; }

.termine-archiv { margin: 16px 0; }
.termine-archiv summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* Calendar */
.termine-kalender { margin-top: 24px; }
.termine-kalender-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.termine-kalender table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.termine-kalender th { background: #34495e; color: #fff; padding: 6px; font-size: 0.85em; }
.termine-kalender td { border: 1px solid #ddd; height: 76px; padding: 4px; vertical-align: top; font-size: 0.8em; background: #fff; }
.termine-kalender td.termine-tag-leer { background: #f7f7f7; }
.termine-kalender td.termine-heute { background: #eaf2fb; border-color: #3498db; }
.termine-tag { display: block; font-weight: 700; color: #555; margin-bottom: 2px; }
.termine-kalender td { position: relative; }
.termine-eintrag { margin-top: 2px; padding: 2px 4px; border-radius: 3px; background: #e8f4f8; color: #1b4f72; }
.termine-eintrag.termin-veranstaltung { background: #fdeef0; color: #922b21; }
/* Up to three lines in the cell; the whole text is one tap away */
.termine-eintrag summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    /* No padding here: it would sit inside the clipped box and show a strip of a third line */
    line-height: 1.25;
    cursor: pointer;
    list-style: none;
    overflow-wrap: anywhere;
}
.termine-eintrag summary::-webkit-details-marker { display: none; }
.termine-eintrag summary span { font-weight: 700; }
.termine-eintrag[open] { outline: 2px solid currentColor; outline-offset: -2px; }
/* The details float above the calendar instead of widening the cell */
.termine-eintrag-info {
    position: absolute;
    z-index: 20;
    left: 0;
    top: 100%;
    width: max-content;
    max-width: min(260px, 80vw);
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #222;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    font-size: 0.95em;
    line-height: 1.35;
    text-align: left;
}
.termine-eintrag-info strong { display: block; margin-bottom: 2px; }
.termine-eintrag-gruppen { color: #666; font-size: 0.9em; margin-top: 2px; }
/* Last columns open towards the left, so the box stays on the page */
.termine-kalender td:nth-child(n+5) .termine-eintrag-info { left: auto; right: 0; }

/* Summary sentences (#probenplan_<group>#) */
.probenplan-kurz p { margin: 0 0 8px; }

/* Heading and footer of the print view stay hidden on screen */
.termine-druckkopf, .termine-druckfuss { display: none; }

@media print {
    html.termine-print body * { visibility: hidden; }
    html.termine-print .termine-druckbereich,
    html.termine-print .termine-druckbereich * { visibility: visible; }
    html.termine-print .termine-druckbereich { position: absolute; left: 0; top: 0; width: 100%; }

    html.termine-print .termine-druckkopf { display: block; border-bottom: 2px solid #333; margin-bottom: 14px; }
    html.termine-print .termine-druckkopf h1 { font-size: 20px; margin: 0 0 4px; }
    html.termine-print .termine-druckkopf p { font-size: 12px; color: #555; margin: 0 0 10px; }
    html.termine-print .termine-druckfuss { display: block; margin-top: 16px; padding-top: 8px; border-top: 1px solid #ccc; font-size: 11px; color: #777; }

    html.termine-print .termine-tabelle table { font-size: 12px; }
    html.termine-print .termine-tabelle thead { display: table-header-group; }
    html.termine-print .termine-tabelle tr { page-break-inside: avoid; }
    html.termine-print .termine-tabelle th,
    html.termine-print .termine-tabelle td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    @page { size: A4; margin: 18mm 15mm; }
}

/* Tables and calendar need the full width of the content column; templates
   often cap text at a reading width. */
.content_text:has(.mod-termine) { max-width: none; }

/* ---------- Narrow screens -------------------------------------------- */

/* Site templates often linearise tables inside content on phones (every
   row and cell becomes a block) - meant for old layout tables, it breaks
   the module's real tables. The module decides itself how they look. */
.mod-termine table, .termine-kalender table { display: table !important; }
.mod-termine thead, .termine-kalender thead { display: table-header-group !important; }
.mod-termine tbody, .termine-kalender tbody { display: table-row-group !important; }
.mod-termine tr, .termine-kalender tr { display: table-row !important; }
.mod-termine th, .mod-termine td, .termine-kalender th, .termine-kalender td { display: table-cell !important; }

/* The day number links to the month list, which only phones show */
.termine-kalender a.termine-tag { color: inherit; text-decoration: none; pointer-events: none; }

/* Cards: hidden on wide screens, where the table is shown */
.termine-agenda { display: none; list-style: none; margin: 0; padding: 0; }
.termine-monatsliste { display: none; }

.termine-agenda li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #e3e3e3;
    scroll-margin-top: 70px;
}
.termine-agenda li:target { background: #fff8dc; }
.agenda-datum {
    flex: 0 0 56px;
    padding: 4px 0;
    border-radius: 6px;
    background: #e8f4f8;
    color: #1b4f72;
    text-align: center;
    line-height: 1.2;
}
.termin-veranstaltung .agenda-datum { background: #fdeef0; color: #922b21; }
.agenda-wochentag { display: block; font-size: 0.75em; font-weight: 700; text-transform: uppercase; }
.agenda-tag { display: block; font-weight: 700; }
.agenda-text { min-width: 0; line-height: 1.35; }
.agenda-titel { font-weight: 600; overflow-wrap: anywhere; }
.agenda-zeit { font-weight: 700; margin-right: 2px; }
.agenda-ort { font-size: 0.92em; }
.agenda-gruppen { font-size: 0.82em; color: #666; }

@media (max-width: 600px) {
    .mod-termine .termine-tabelle { display: none; }
    .termine-agenda { display: block; }

    /* Calendar: a compact grid with a mark on days with entries; the
       entries themselves follow below as a list */
    /* Arrows only, so month and navigation fit on one line */
    .termine-kalender-kopf { flex-wrap: nowrap; }
    .termine-kalender-kopf a { padding: 4px 14px; font-size: 1.4em; line-height: 1; text-decoration: none; }
    .termine-nav-text { display: none; }
    /* Templates set content tables to width:auto on phones */
    .termine-kalender table { width: 100% !important; table-layout: fixed; }
    .termine-kalender td { height: 42px; padding: 2px; text-align: center; vertical-align: middle; }
    .termine-kalender th { padding: 4px 0; }
    .termine-kalender .termine-eintrag { display: none; }
    .termine-kalender .termine-tag { display: block; margin: 0; font-size: 1.05em; }
    .termine-kalender a.termine-tag { pointer-events: auto; }
    .termine-hat-eintraege .termine-tag::after {
        content: "";
        display: block;
        width: 6px;
        height: 6px;
        margin: 2px auto 0;
        border-radius: 50%;
        background: #c0392b;
    }
    .termine-monatsliste { display: block; margin-top: 12px; }
}

@media print {
    .termine-agenda, .termine-monatsliste { display: none !important; }
    .mod-termine .termine-tabelle { display: block !important; }
}
