/*
 * Frontendové styly jídelníčku.
 * Barvy jsou řízené přes CSS proměnné, aby šel bezpečně přepnout světlý/tmavý režim
 * a aby komponenta zůstala čitelná podle WCAG 2.1 AA.
 */
.msj-wrapper,
.msj-today,
.msj-empty,
.msj-today-empty {
    --msj-color-text: #1f2328;
    --msj-color-muted: #4f5863;
    --msj-color-bg: #ffffff;
    --msj-color-surface: #ffffff;
    --msj-color-surface-alt: #f1f1f1;
    --msj-color-surface-soft: #fafafa;
    --msj-color-border: #d8d8d8;
    --msj-color-border-soft: #e1e1e1;
    --msj-color-link: #0a4f93;
    --msj-color-focus: #8a5a00;
    --msj-color-accent: #255b25;
    --msj-color-accent-bg: #eef8ee;
    --msj-color-accent-surface: #ffffff;
    --msj-color-accent-soft: #e8f6e8;
    --msj-color-accent-border: #b9d9b9;
    --msj-color-warning-bg: #fff8e2;
    --msj-color-warning-border: #d19a00;
    --msj-color-warning-text: #1f2328;
    color: var(--msj-color-text);
    color-scheme: light;
}

/*
 * Automatický tmavý režim podle systému/prohlížeče.
 * Používá bílý text na černém pozadí a kontrastní okraje/odkazy pro WCAG 2.1 AA.
 */
@media (prefers-color-scheme: dark) {
    .msj-wrapper,
    .msj-today,
    .msj-empty,
    .msj-today-empty {
        --msj-color-text: #ffffff;
        --msj-color-muted: #f2f2f2;
        --msj-color-bg: #000000;
        --msj-color-surface: #000000;
        --msj-color-surface-alt: #111111;
        --msj-color-surface-soft: #1a1a1a;
        --msj-color-border: #8a8a8a;
        --msj-color-border-soft: #707070;
        --msj-color-link: #9bd1ff;
        --msj-color-focus: #ffbf47;
        --msj-color-accent: #b7f7bc;
        --msj-color-accent-bg: #000000;
        --msj-color-accent-surface: #111111;
        --msj-color-accent-soft: #171717;
        --msj-color-accent-border: #8a8a8a;
        --msj-color-warning-bg: #000000;
        --msj-color-warning-border: #c9a227;
        --msj-color-warning-text: #ffffff;
        color-scheme: dark;
    }
}

/*
 * Podpora častých tříd/atributů, které používají WordPress šablony a přepínače režimu.
 * Díky tomu se tmavé barvy aktivují i při ručním přepnutí tématu, nejen podle systému.
 */
html.dark .msj-wrapper,
html.dark .msj-today,
html.dark .msj-empty,
html.dark .msj-today-empty,
body.dark .msj-wrapper,
body.dark .msj-today,
body.dark .msj-empty,
body.dark .msj-today-empty,
.dark .msj-wrapper,
.dark .msj-today,
.dark .msj-empty,
.dark .msj-today-empty,
html.dark-mode .msj-wrapper,
html.dark-mode .msj-today,
html.dark-mode .msj-empty,
html.dark-mode .msj-today-empty,
body.dark-mode .msj-wrapper,
body.dark-mode .msj-today,
body.dark-mode .msj-empty,
body.dark-mode .msj-today-empty,
.dark-mode .msj-wrapper,
.dark-mode .msj-today,
.dark-mode .msj-empty,
.dark-mode .msj-today-empty,
html.is-dark .msj-wrapper,
html.is-dark .msj-today,
html.is-dark .msj-empty,
html.is-dark .msj-today-empty,
body.is-dark .msj-wrapper,
body.is-dark .msj-today,
body.is-dark .msj-empty,
body.is-dark .msj-today-empty,
.is-dark .msj-wrapper,
.is-dark .msj-today,
.is-dark .msj-empty,
.is-dark .msj-today-empty,
html[data-theme="dark"] .msj-wrapper,
html[data-theme="dark"] .msj-today,
html[data-theme="dark"] .msj-empty,
html[data-theme="dark"] .msj-today-empty,
body[data-theme="dark"] .msj-wrapper,
body[data-theme="dark"] .msj-today,
body[data-theme="dark"] .msj-empty,
body[data-theme="dark"] .msj-today-empty,
html[data-color-scheme="dark"] .msj-wrapper,
html[data-color-scheme="dark"] .msj-today,
html[data-color-scheme="dark"] .msj-empty,
html[data-color-scheme="dark"] .msj-today-empty,
body[data-color-scheme="dark"] .msj-wrapper,
body[data-color-scheme="dark"] .msj-today,
body[data-color-scheme="dark"] .msj-empty,
body[data-color-scheme="dark"] .msj-today-empty {
    --msj-color-text: #ffffff;
    --msj-color-muted: #f2f2f2;
    --msj-color-bg: #000000;
    --msj-color-surface: #000000;
    --msj-color-surface-alt: #111111;
    --msj-color-surface-soft: #1a1a1a;
    --msj-color-border: #8a8a8a;
    --msj-color-border-soft: #707070;
    --msj-color-link: #9bd1ff;
    --msj-color-focus: #ffbf47;
    --msj-color-accent: #b7f7bc;
    --msj-color-accent-bg: #000000;
    --msj-color-accent-surface: #111111;
    --msj-color-accent-soft: #171717;
    --msj-color-accent-border: #8a8a8a;
    --msj-color-warning-bg: #000000;
    --msj-color-warning-border: #c9a227;
    --msj-color-warning-text: #ffffff;
    color-scheme: dark;
}


/*
 * Vysoký kontrast webu ZŠ/MŠ Deštná přidává na <body> třídu .high-contrast
 * a vynucuje bílé písmo přes !important. Proto zde aktivujeme také černé pozadí
 * přímo pro komponentu jídelníčku, aby nevzniklo bílé pozadí s bílým textem.
 */
html.high-contrast .msj-wrapper,
html.high-contrast .msj-today,
html.high-contrast .msj-empty,
html.high-contrast .msj-today-empty,
body.high-contrast .msj-wrapper,
body.high-contrast .msj-today,
body.high-contrast .msj-empty,
body.high-contrast .msj-today-empty,
.high-contrast .msj-wrapper,
.high-contrast .msj-today,
.high-contrast .msj-empty,
.high-contrast .msj-today-empty,
html.highcontrast .msj-wrapper,
html.highcontrast .msj-today,
html.highcontrast .msj-empty,
html.highcontrast .msj-today-empty,
body.highcontrast .msj-wrapper,
body.highcontrast .msj-today,
body.highcontrast .msj-empty,
body.highcontrast .msj-today-empty,
.highcontrast .msj-wrapper,
.highcontrast .msj-today,
.highcontrast .msj-empty,
.highcontrast .msj-today-empty,
html.contrast .msj-wrapper,
html.contrast .msj-today,
html.contrast .msj-empty,
html.contrast .msj-today-empty,
body.contrast .msj-wrapper,
body.contrast .msj-today,
body.contrast .msj-empty,
body.contrast .msj-today-empty,
.contrast .msj-wrapper,
.contrast .msj-today,
.contrast .msj-empty,
.contrast .msj-today-empty,
html[data-contrast="high"] .msj-wrapper,
html[data-contrast="high"] .msj-today,
html[data-contrast="high"] .msj-empty,
html[data-contrast="high"] .msj-today-empty,
body[data-contrast="high"] .msj-wrapper,
body[data-contrast="high"] .msj-today,
body[data-contrast="high"] .msj-empty,
body[data-contrast="high"] .msj-today-empty {
    --msj-color-text: #ffffff;
    --msj-color-muted: #f2f2f2;
    --msj-color-bg: #000000;
    --msj-color-surface: #000000;
    --msj-color-surface-alt: #111111;
    --msj-color-surface-soft: #1a1a1a;
    --msj-color-border: #8a8a8a;
    --msj-color-border-soft: #707070;
    --msj-color-link: #9bd1ff;
    --msj-color-focus: #ffbf47;
    --msj-color-accent: #b7f7bc;
    --msj-color-accent-bg: #000000;
    --msj-color-accent-surface: #111111;
    --msj-color-accent-soft: #171717;
    --msj-color-accent-border: #8a8a8a;
    --msj-color-warning-bg: #000000;
    --msj-color-warning-border: #c9a227;
    --msj-color-warning-text: #ffffff;
    color-scheme: dark;
}

/*
 * Tvrdší přepsání pozadí v režimu vysokého kontrastu.
 * Některé šablony nastavují barvy tabulek až za styly pluginu nebo používají !important.
 */
body.high-contrast .msj-wrapper,
body.high-contrast .msj-menu,
body.high-contrast .msj-table-scroll,
body.high-contrast .msj-table,
body.high-contrast .msj-table tbody,
body.high-contrast .msj-table tr,
body.high-contrast .msj-table td,
body.high-contrast .msj-food,
body.high-contrast .msj-allergens,
body.high-contrast .msj-allergen-legend,
body.high-contrast .msj-allergen-group,
body.high-contrast .msj-today,
body.high-contrast .msj-today-empty {
    background: #000000 !important;
    color: #ffffff !important;
}

body.high-contrast .msj-switcher,
body.high-contrast .msj-table thead th,
body.high-contrast .msj-day,
body.high-contrast .msj-meal,
body.high-contrast .msj-allergen-group-head,
body.high-contrast .msj-today-item,
body.high-contrast .msj-empty {
    background: #111111 !important;
    color: #ffffff !important;
}

body.high-contrast .msj-table th,
body.high-contrast .msj-table td,
body.high-contrast .msj-switcher,
body.high-contrast .msj-allergen-legend,
body.high-contrast .msj-allergen-group,
body.high-contrast .msj-allergen-group-head,
body.high-contrast .msj-allergen-child,
body.high-contrast .msj-empty,
body.high-contrast .msj-today-item,
body.high-contrast .msj-today-empty {
    border-color: #8a8a8a !important;
}

body.high-contrast .msj-wrapper *,
body.high-contrast .msj-today *,
body.high-contrast .msj-empty,
body.high-contrast .msj-today-empty {
    color: #ffffff !important;
    text-shadow: none !important;
}

body.high-contrast .msj-wrapper a,
body.high-contrast .msj-today a,
body.high-contrast .msj-today-inline-allergens,
body.high-contrast .msj-allergen-group-head strong,
body.high-contrast .msj-allergen-child strong {
    color: #9bd1ff !important;
}

body.high-contrast .msj-switcher-form select {
    background: #000000 !important;
    border-color: #8a8a8a !important;
    color: #ffffff !important;
}

body.high-contrast .msj-switcher-form select:focus-visible,
body.high-contrast .msj-today-link:focus-visible {
    outline-color: #ffbf47 !important;
}

.msj-wrapper {
    width: 100%;
    background: var(--msj-color-bg);
    color: var(--msj-color-text);
}

.msj-menu {
    margin: 0 0 2.5rem;
    font-size: 16px;
    line-height: 1.45;
    background: var(--msj-color-bg);
    color: var(--msj-color-text);
}

.msj-switcher {
    margin: 0 0 1.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--msj-color-border);
    background: var(--msj-color-surface-soft);
    color: var(--msj-color-text);
    border-radius: 6px;
}

.msj-switcher-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
}

.msj-switcher-form label {
    font-weight: 700;
    color: var(--msj-color-text);
}

.msj-switcher-form select {
    min-width: 270px;
    max-width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--msj-color-border);
    background: var(--msj-color-surface);
    color: var(--msj-color-text);
}

.msj-switcher-form select:focus-visible,
.msj-today-link:focus-visible {
    outline: 3px solid var(--msj-color-focus);
    outline-offset: 3px;
}

.msj-title {
    margin: 0 0 1.25rem;
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1.2;
    text-align: center;
    color: var(--msj-color-text);
}

.msj-table-scroll {
    width: 100%;
    overflow-x: auto;
}

.msj-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--msj-color-surface);
    color: var(--msj-color-text);
}

.msj-table th,
.msj-table td {
    border: 1px solid var(--msj-color-border);
    padding: 0.65rem 0.75rem;
    vertical-align: top;
    color: var(--msj-color-text);
}

.msj-table thead th {
    background: var(--msj-color-surface-alt);
    font-weight: 700;
    text-align: left;
}

.msj-day {
    width: 72px;
    text-align: center;
    background: var(--msj-color-surface-soft);
}

.msj-day-short {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
}

.msj-day-full {
    display: block;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--msj-color-muted);
}

.msj-meal {
    width: 145px;
    white-space: nowrap;
    background: var(--msj-color-surface-soft);
}

.msj-food {
    min-width: 320px;
}

.msj-food-text {
    display: block;
}

.msj-allergens {
    width: 140px;
    min-width: 140px;
    white-space: nowrap;
    text-align: center;
}

.msj-allergen-legend {
    padding: 1rem;
    border: 1px solid var(--msj-color-accent-border);
    background: var(--msj-color-accent-bg);
    color: var(--msj-color-text);
    border-radius: 6px;
}

.msj-allergen-legend-title {
    margin-bottom: 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--msj-color-accent);
}

.msj-allergen-legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.msj-allergen-group {
    border: 1px solid var(--msj-color-accent-border);
    background: var(--msj-color-accent-surface);
    color: var(--msj-color-text);
    border-radius: 4px;
    overflow: hidden;
}

.msj-allergen-group-head {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--msj-color-accent-soft);
    border-bottom: 1px solid var(--msj-color-accent-border);
    font-weight: 600;
}

.msj-allergen-group-head strong {
    min-width: 2rem;
    color: var(--msj-color-accent);
}

.msj-allergen-children {
    padding: 0.35rem 0.75rem 0.55rem;
}

.msj-allergen-child {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid var(--msj-color-border-soft);
}

.msj-allergen-child:last-child {
    border-bottom: 0;
}

.msj-allergen-child strong {
    min-width: 2rem;
    color: var(--msj-color-accent);
}

.msj-notice {
    margin: 0.8rem 0 1rem;
    text-align: right;
    font-weight: 600;
    color: var(--msj-color-text);
}

.msj-allergens-text {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--msj-color-border-soft);
    font-size: 0.95rem;
    color: var(--msj-color-text);
}

.msj-info-text {
    margin-top: 1.3rem;
    color: var(--msj-color-text);
}

.msj-info-text h3 {
    margin-top: 1.6rem;
    color: var(--msj-color-text);
}

.msj-empty {
    padding: 1rem;
    border: 1px solid var(--msj-color-border);
    background: var(--msj-color-surface-soft);
    color: var(--msj-color-text);
}

@media (max-width: 760px) {
    .msj-table th,
    .msj-table td {
        padding: 0.55rem;
    }

    .msj-meal {
        white-space: normal;
    }

    .msj-food {
        min-width: 240px;
    }
}

.msj-separator td {
    padding: 0;
    height: 12px;
    border: 0;
    background: transparent;
}

.msj-day-start > th,
.msj-day-start > td {
    border-top-width: 1px;
}

.msj-today {
    width: 100%;
    background: var(--msj-color-bg);
    color: var(--msj-color-text);
}

.msj-today-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.55rem;
}

.msj-today-title {
    flex: 0 1 auto !important;
    width: auto !important;
    margin: 0 !important;
    color: var(--msj-color-text);
}

.msj-today-date {
    flex: 0 0 auto;
    margin: 0;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    color: var(--msj-color-text);
}

.msj-today-items {
    display: grid;
    gap: 0.55rem;
}

.msj-today-item {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--msj-color-warning-border);
    background: var(--msj-color-warning-bg);
    color: var(--msj-color-warning-text);
    border-radius: 12px;
}

.msj-today-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.2rem;
}

.msj-today-meal {
    font-weight: 700;
    color: var(--msj-color-warning-text);
}

.msj-today-inline-allergens {
    flex: 0 0 auto;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
    color: var(--msj-color-link);
}

.msj-today-food {
    line-height: 1.35;
    color: var(--msj-color-warning-text);
}

.msj-today-link {
    display: inline-block;
    margin-top: 0.65rem;
    color: var(--msj-color-link);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.msj-today-link:hover {
    text-decoration-thickness: 0.14em;
}

.msj-today-empty {
    padding: 0.85rem 1rem;
    border: 1px solid var(--msj-color-border);
    background: var(--msj-color-surface-soft);
    color: var(--msj-color-text);
    border-radius: 8px;
}

@media (max-width: 760px) {
    .msj-today-item-head {
        flex-direction: row;
        align-items: flex-start;
    }

    .msj-today-inline-allergens {
        white-space: nowrap;
        margin-left: auto;
    }
}

@media (max-width: 760px) {
    .msj-today-head {
        align-items: baseline;
        justify-content: space-between;
        flex-direction: row;
    }

    .msj-today-date {
        text-align: right;
    }
}


/* v1.2.0 – WCAG/WAVE: přepínač jídelníčku se neodesílá přes onchange.
 * Uživatel vybere hodnotu a změnu potvrdí běžným tlačítkem.
 */
.msj-switcher-submit {
    min-height: 2.35rem;
    padding: 0.4rem 0.85rem;
    border: 2px solid var(--msj-color-border);
    border-radius: 0.45rem;
    background: var(--msj-color-surface);
    color: var(--msj-color-text);
    font-weight: 700;
    cursor: pointer;
}

.msj-switcher-submit:hover,
.msj-switcher-submit:focus-visible {
    border-color: var(--msj-color-focus);
    text-decoration: none;
}

.msj-switcher-submit:focus-visible {
    outline: 3px solid var(--msj-color-focus);
    outline-offset: 3px;
}

body.high-contrast .msj-switcher-submit,
.high-contrast .msj-switcher-submit {
    background: #000000 !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
}

body.high-contrast .msj-switcher-submit:hover,
body.high-contrast .msj-switcher-submit:focus-visible,
.high-contrast .msj-switcher-submit:hover,
.high-contrast .msj-switcher-submit:focus-visible {
    border-color: #ffbf47 !important;
    color: #ffffff !important;
}


/* v1.2.1 – automatické přepnutí jídelníčku bez inline onchange.
 * Viditelně zůstává jen select jako dříve. Pomocný text je určený pro čtečky.
 */
.msj-switcher .screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

