/* =========================================================
   Ortskalender Köln-Meschenich – Styles
   Mobile First | WCAG 2.1 AA konform
   ========================================================= */

/* ── Wrapper ──────────────────────────────────────────────── */
#ok-wrap {
    font-family: inherit;
    max-width: 100%;
    box-sizing: border-box;
}

#ok-wrap *,
#ok-wrap *::before,
#ok-wrap *::after {
    box-sizing: inherit;
}

/* ── Screenreader-only ────────────────────────────────────── */
.ok-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Legende (interaktive Kategorie-Filter) ──────────────────────────────── */
.ok-legend-fieldset {
    border: none;
    margin: 0 0 14px;
    padding: 0;
}

.ok-legend-legend {
    font-size: calc(var(--ok-font-legend, 0.82rem) * 0.92);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #777;
    padding: 0 0 6px;
    margin: 0;
}

.ok-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 18px;
}

@media (max-width: 380px) {
    .ok-legend {
        grid-template-columns: 1fr;
    }
}

.ok-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: var(--ok-font-legend, 0.82rem);
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
}

.ok-legend-checkbox {
    width: 1.3em;
    height: 1.3em;
    margin: 0;
    cursor: pointer;
    accent-color: #222;
    flex-shrink: 0;
}

.ok-legend-checkbox:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

.ok-legend-dot {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Wenn eine Kategorie ausgeblendet ist, Beschriftung dezent abblenden (JS-gesteuert, läuft auch in älteren Browsern ohne :has()-Support) */
.ok-legend-item--off {
    opacity: 0.45;
}

.ok-legend-quick {
    display: flex;
    gap: 14px;
    margin-top: 8px;
}

.ok-legend-quick-btn {
    background: none;
    border: none;
    padding: 2px 0;
    font-size: calc(var(--ok-font-legend, 0.82rem) * 0.93);
    color: #555;
    text-decoration: underline;
    cursor: pointer;
    min-height: 32px; /* Touch-Target, auch wenn der Text klein ist */
}

.ok-legend-quick-btn:hover {
    color: #222;
}

.ok-legend-quick-btn:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ── Hover-Vorschau (Maus-Komfortfeature, parallel zur Klick-Box) ──────────── */
#ok-hover-preview {
    position: fixed;
    z-index: 9999;
    max-width: 280px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    padding: 12px 14px;
    pointer-events: none; /* Maus kann nie "in" die Vorschau wandern, kein Flackern */
}

.ok-hover-title {
    font-weight: 600;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.05);
    margin-bottom: 4px;
    line-height: 1.3;
}

.ok-hover-meta {
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.9);
    color: #555;
    margin-bottom: 4px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.ok-hover-meta svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #888;
}

.ok-hover-location {
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.88);
    color: #666;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 4px;
}

.ok-hover-location svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #888;
}

.ok-hover-recurrence {
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.88);
    color: #666;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 4px;
}

.ok-hover-recurrence svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #888;
}

.ok-hover-desc {
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.88);
    color: #444;
    line-height: 1.4;
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.ok-hover-desc svg {
    flex-shrink: 0;
    margin-top: 3px;
    color: #888;
}

.ok-hover-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

@media print {
    #ok-hover-preview {
        display: none !important;
    }
}

/* ── View-Toggle ──────────────────────────────────────────── */
#ok-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.ok-btn {
    padding: 7px 18px;
    border: 2px solid currentColor;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    min-height: 44px; /* WCAG Touch Target */
}

.ok-btn:hover {
    background: rgba(0,0,0,.07);
}

.ok-btn--active {
    background: #222;
    color: #fff;
    border-color: #222;
}

.ok-btn:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ── Ladeanzeige / Fehler ────────────────────────────────── */
#ok-loading {
    padding: 24px 0;
    color: #666;
    font-size: 0.9rem;
}

.ok-error {
    color: #c00;
    padding: 12px 0;
}

/* ── FullCalendar-Overrides ───────────────────────────────── */

/* Toolbar-Buttons gut anfassbar */
.ok-wrap .fc-button,
#ok-wrap .fc-button {
    min-height: 40px;
}

/* Event-Balken */
.ok-event-inner {
    display: flex;
    flex-direction: column;
    padding: 2px 5px;
    border-radius: 3px;
    width: 100%;
    min-height: 100%;
    overflow: hidden;
    cursor: pointer;
    outline: none;
}

.ok-event-inner:focus-visible {
    box-shadow: 0 0 0 3px #005fcc;
}

.ok-event-time {
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.88);
    line-height: 1.3;
    color: rgba(255,255,255,0.88);
}

.ok-event-title {
    font-size: var(--ok-font-event, 0.85rem);
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Text-Schatten für bessere Lesbarkeit auf hellen Farben */
.ok-event-inner {
    text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* Listenansicht: Kategorien als farbige linke Kante */
.fc-list-event-dot {
    display: none !important;
}

/* Schriftgröße der FullCalendar-Listenansicht – per Backend einstellbar */
.fc .fc-list-event-title a,
.fc .fc-list-event-time,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
    font-size: var(--ok-font-list, 0.875rem) !important;
}

/* ── Detail-Panel ─────────────────────────────────────────── */
#ok-detail {
    margin-top: 18px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    animation: okSlideIn 0.2s ease;
}

@keyframes okSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ok-detail-inner {
    padding: 18px 20px;
    position: relative;
}

.ok-detail-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    color: #555;
    padding: 4px 8px;
    border-radius: 4px;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ok-detail-close:hover {
    background: rgba(0,0,0,.06);
}

.ok-detail-close:focus-visible {
    outline: 3px solid #005fcc;
}

.ok-detail-title {
    margin: 0 44px 10px 0;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.3);
    line-height: 1.3;
}

.ok-detail-meta {
    margin: 0 0 6px;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.06);
    color: #444;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.ok-detail-meta svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #888;
}

.ok-detail-location {
    margin: 4px 0;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.06);
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.ok-detail-location svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #888;
}

.ok-detail-recurrence,
.ok-detail-organizer {
    margin: 4px 0;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.06);
    color: #555;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.ok-detail-recurrence svg,
.ok-detail-organizer svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #888;
}

.ok-detail-desc {
    margin: 10px 0 0;
    font-size: calc(var(--ok-font-event, 0.85rem) * 1.035);
    line-height: 1.6;
    color: #444;
    white-space: pre-line;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.ok-detail-desc svg {
    flex-shrink: 0;
    margin-top: 4px;
    color: #888;
}

.ok-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.ok-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    color: #fff;
    font-size: calc(var(--ok-font-event, 0.85rem) * 0.92);
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* ── Mobile-Anpassungen ──────────────────────────────────── */
@media (max-width: 600px) {
    .fc .fc-toolbar-title {
        font-size: 1rem !important;
    }

    .fc .fc-col-header-cell-cushion {
        font-size: 0.78rem;
    }

    .ok-event-time {
        display: none; /* Zeit zu eng auf kleinen Screens */
    }

    .ok-event-title {
        font-size: calc(var(--ok-font-event, 0.85rem) * 0.89);
    }

    #ok-legend {
        gap: 6px 14px;
    }

    .ok-legend-item {
        font-size: calc(var(--ok-font-legend, 0.82rem) * 0.95);
    }

    .ok-detail-inner {
        padding: 14px 14px;
    }
}

/* ── High-Contrast / Reduced-Motion ─────────────────────── */
@media (forced-colors: active) {
    .ok-event-inner {
        border: 1px solid ButtonText;
    }
    .ok-tag {
        border: 1px solid ButtonText;
    }
}

@media (prefers-reduced-motion: reduce) {
    #ok-detail {
        animation: none;
    }
    .ok-btn {
        transition: none;
    }
}

/* ── Druckansicht ─────────────────────────────────────────── */
@media print {
    /* Bedienelemente, die auf Papier keinen Sinn ergeben */
    #ok-view-toggle,
    .ok-legend-quick,
    .ok-legend-checkbox,
    #ok-loading,
    #ok-detail,
    .fc .fc-toolbar-chunk:first-child,
    .fc .fc-button {
        display: none !important;
    }

    /* Aktuell ausgeblendete Kategorien bleiben auch auf dem Ausdruck weg */
    .ok-legend-item--off {
        display: none !important;
    }

    /* Roter "Jetzt"-Zeitbalken ist auf Papier sinnlos */
    .fc-timegrid-now-indicator-line,
    .fc-timegrid-now-indicator-arrow {
        display: none !important;
    }

    html, body {
        background: #fff !important;
    }

    /* Eigene Breite erzwingen, damit wir zumindest selbst keine Begrenzung mitbringen –
       eine zu schmale bedruckbare Fläche durch das Theme (siehe Hinweis im Chat) bleibt davon unberührt */
    #ok-wrap,
    #ok-calendar,
    .fc {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Hintergrundfarben der Termin-Balken/Tags erzwingen – sonst druckt der Browser sie weiß */
    .ok-event-inner,
    .ok-legend-dot,
    .ok-tag,
    .ok-heute-tag {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .fc-daygrid-row {
        page-break-inside: avoid;
    }

    .fc-list-event,
    .fc-list-table tr {
        page-break-inside: avoid;
    }

    .fc-list-day {
        page-break-after: avoid;
    }
}

@page {
    margin: 12mm;
}
