/*
 * .týždeň – light / dark / system controls
 *
 * One look for every .týždeň page (customer zone, shop, sales funnels); the behaviour is in
 * js/tyzden-theme.js. Sales funnels live in the DB and carry an inline copy – keep them in sync.
 *
 * The host layout maps its own tokens onto these properties (all optional):
 *   --tzt-bg, --tzt-panel, --tzt-text, --tzt-muted, --tzt-rule, --tzt-line, --tzt-accent,
 *   --tzt-serif, --tzt-mix
 *
 * Markup
 *   header menu:
 *     <div class="tz-theme-menu">
 *       <button type="button" class="tz-theme-menu__toggle" aria-expanded="false" aria-controls="ID" aria-label="Vzhľad">
 *         <i|svg class="tz-theme-menu__icon--light"> <i|svg class="tz-theme-menu__icon--dark"> <i|svg class="tz-theme-menu__icon--system">
 *       </button>
 *       <div id="ID" class="tz-theme-menu__list" hidden>
 *         <span class="tz-theme-menu__heading">vzhľad</span>
 *         <button type="button" data-tz-theme-option="light">…icon… svetlý</button> (dark: tmavý, system: podľa systému)
 *       </div>
 *     </div>
 *   footer switch:
 *     <span class="tz-theme-label">vzhľad</span>
 *     <div class="tz-theme" role="group" aria-label="Vzhľad"> …the same three buttons… </div>
 */

.tz-theme-menu,
.tz-theme,
.tz-theme-label {
    --_bg: var(--tzt-bg, #fff);
    --_panel: var(--tzt-panel, #f2f2f2);
    --_text: var(--tzt-text, #000);
    --_muted: var(--tzt-muted, #6b6b6b);
    --_rule: var(--tzt-rule, #000);
    --_line: var(--tzt-line, #c8c8c8);
    --_accent: var(--tzt-accent, #bf1f10);
    --_serif: var(--tzt-serif, 'TheSerif_SemiLight', Georgia, 'Times New Roman', serif);
    --_mix: var(--tzt-mix, 'TheMix_Bold', Arial, sans-serif);
}

/* ------------------------------------------------------------ header menu */

.tz-theme-menu {
    position: relative;
    flex-shrink: 0;
}

.tz-theme-menu__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--_text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.tz-theme-menu__toggle:hover,
.tz-theme-menu__toggle[aria-expanded="true"] {
    color: var(--_accent);
}

.tz-theme-menu__toggle:focus-visible,
.tz-theme button:focus-visible {
    outline: 2px solid var(--_accent);
    outline-offset: 2px;
}

/* the toggle shows the icon of the current preference */
.tz-theme-menu__toggle > * {
    display: none;
}

.tz-theme-menu__toggle svg {
    width: 20px;
    height: 20px;
}

html[data-theme-pref="light"] .tz-theme-menu__icon--light,
html[data-theme-pref="dark"] .tz-theme-menu__icon--dark,
html[data-theme-pref="system"] .tz-theme-menu__icon--system,
html:not([data-theme-pref]) .tz-theme-menu__icon--system {
    display: inline-block;
}

.tz-theme-menu__list {
    position: absolute;
    top: calc(100% + 10px);
    right: -8px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    padding: 6px 0;
    background: var(--_bg);
    border: 1px solid var(--_rule);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .14);
    animation: tz-theme-menu-in .14s ease-out;
}

.tz-theme-menu__list[hidden] {
    display: none;
}

@keyframes tz-theme-menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.tz-theme-menu__heading {
    padding: 6px 16px 8px;
    font-family: var(--_serif);
    font-size: 14px;
    line-height: 1.3;
    color: var(--_muted);
}

.tz-theme-menu__list button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 8px 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--_text);
    font-family: var(--_serif);
    font-size: 17px;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
}

.tz-theme-menu__list button > i,
.tz-theme-menu__list button > svg {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    text-align: center;
    color: var(--_muted);
}

.tz-theme-menu__list button:hover,
.tz-theme-menu__list button:focus-visible {
    background: var(--_panel);
    outline: none;
}

.tz-theme-menu__list button[aria-pressed="true"],
.tz-theme-menu__list button[aria-pressed="true"] > i,
.tz-theme-menu__list button[aria-pressed="true"] > svg {
    color: var(--_accent);
}

/* check mark of the current choice (pure CSS, no icon font needed) */
.tz-theme-menu__list button[aria-pressed="true"]::after {
    content: "";
    width: 5px;
    height: 10px;
    margin: -3px 2px 0 auto;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ------------------------------------------------------------ footer switch */

.tz-theme-label {
    font-family: var(--_serif);
    font-size: 15px;
    color: var(--_muted);
}

.tz-theme {
    display: inline-flex;
    border: 1px solid var(--_line);
}

.tz-theme button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    margin: 0;
    padding: 6px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--_text);
    font-family: var(--_mix);
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.tz-theme button > svg {
    width: 14px;
    height: 14px;
}

.tz-theme button + button {
    border-left: 1px solid var(--_line);
}

.tz-theme button:hover {
    color: var(--_accent);
}

.tz-theme button[aria-pressed="true"],
.tz-theme button[aria-pressed="true"]:hover {
    background: var(--_text);
    color: var(--_bg);
}

@media (prefers-reduced-motion: reduce) {
    .tz-theme-menu__list {
        animation: none;
    }
}
