/* Kaidolfest site layout: header, navigation, mobile menu, LangSwitch, footer
   (templates/partials/site-header.php, site-footer.php, lang-switch.php).
   Built only on tokens.css variables; load after components.css. */

/* Desktop/mobile switch for the header. The nav never wraps, so the header stays at --header-h
   (sticky subnavs and the flash container rely on it). The switch width depends on how crowded
   the header is: data-kf-desktop-min on .kf-site-header (1180, 1280 or 1360) comes from
   SiteNav::headerLayout(), which documents the measurements. initSiteMenu() in app.js reads the
   same attribute. */
@media (max-width: 1179.98px) { .kf-desk { display: none !important; } }
@media (min-width: 1180px) and (max-width: 1279.98px) {
    .kf-site-header[data-kf-desktop-min="1280"] .kf-desk,
    .kf-site-header[data-kf-desktop-min="1360"] .kf-desk { display: none !important; }
    .kf-site-header[data-kf-desktop-min="1180"] .kf-mob { display: none !important; }
}
@media (min-width: 1280px) and (max-width: 1359.98px) {
    .kf-site-header[data-kf-desktop-min="1360"] .kf-desk { display: none !important; }
    .kf-site-header:not([data-kf-desktop-min="1360"]) .kf-mob { display: none !important; }
}
@media (min-width: 1360px) { .kf-mob { display: none !important; } }

/* ─── Skip link ──────────────────────────────────────────── */
.kf-skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 100;
    padding: 10px 18px;
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    color: var(--kf-white);
    background: var(--kf-teal-700);
    border-radius: var(--r-pill);
    text-decoration: none;
    transform: translateY(-200%);
}
.kf-skip-link:focus { transform: none; outline: 3px solid var(--focus-ring); outline-offset: 2px; color: var(--kf-white); }
#main-content:focus { outline: none; }
/* In-page targets (skip link, anchors) land below the sticky header */
#main-content,
:target,
[id][tabindex="-1"] { scroll-margin-top: var(--header-h); }

/* ─── Header ─────────────────────────────────────────────── */
.kf-site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    backdrop-filter: var(--blur-glass);
    border-bottom: var(--bw) solid var(--kf-line);
}
.kf-site-header__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1320px;
    min-height: calc(var(--header-h) - var(--bw));
    margin: 0 auto;
    padding: 10px var(--gutter);
}
.kf-site-header__logo { display: flex; flex: none; border-radius: var(--r-sm); }
.kf-site-header__logo img { display: block; width: auto; height: 52px; }
.kf-site-header__actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.kf-site-nav {
    display: flex;
    flex: 1;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.kf-site-nav__link {
    padding: 8px 12px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    white-space: nowrap;
    color: var(--kf-ink);
    text-decoration: none;
    border-radius: var(--r-pill);
    transition: background var(--dur-fast), color var(--dur-fast);
}
.kf-site-nav__link:hover { color: var(--kf-teal-700); background: rgb(var(--kf-teal-100-rgb) / .55); }
.kf-site-nav__link.is-active { color: var(--kf-teal-700); background: var(--kf-teal-100); }
/* Crowded header (9+ items incl. archive and live pill, SiteNav::headerLayout) */
.kf-site-header--dense .kf-site-header__inner { gap: 10px; }
.kf-site-header--dense .kf-site-header__actions { gap: 8px; }
.kf-site-header--dense .kf-site-nav { gap: 0; }
.kf-site-header--dense .kf-site-nav__link { padding-left: 8px; padding-right: 8px; }
/* The fullest header (11 items) would sit against the 1320px cap at every width; a wider cap lets
   wider viewports add room (see SiteNav::headerLayout for the measured slack) */
.kf-site-header[data-kf-desktop-min="1360"] .kf-site-header__inner { max-width: 1400px; }

/* ─── Archive disclosure menu (initNavMenus in app.js) ───── */
/* Without JS only the fallback link shows (jumps to the footer's archive links); JS reveals the
   button and removes the link. The panel is a plain list of links (disclosure, not role=menu). */
.kf-nav-menu { position: relative; display: flex; }
.kf-nav-menu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
}
.kf-nav-menu__toggle[hidden] { display: none; }
.kf-nav-menu__chevron { display: grid; place-items: center; transition: transform var(--dur-fast); }
.kf-nav-menu__toggle[aria-expanded="true"] { color: var(--kf-teal-700); background: rgb(var(--kf-teal-100-rgb) / .55); }
.kf-nav-menu__toggle[aria-expanded="true"] .kf-nav-menu__chevron { transform: rotate(180deg); }
.kf-nav-menu__panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 45;
    width: max-content;
    min-width: 220px;
    max-width: min(340px, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100vh - var(--header-h) - 24px);
    overflow-y: auto;
    padding: 8px;
    background: var(--surface-card);
    border: var(--bw) solid var(--kf-line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-card);
}
.kf-nav-menu__panel[hidden] { display: none; }
.kf-nav-menu__title {
    margin: 0;
    padding: 6px 12px 4px;
    font-size: var(--fs-micro);
    font-weight: var(--fw-semibold);
    line-height: 1.3;
    color: var(--kf-ink-2);
}
.kf-nav-menu__list,
.kf-mobile-nav__group-list { margin: 0; padding: 0; list-style: none; }
.kf-nav-menu__link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: var(--fw-semibold);
    line-height: 1.25;
    color: var(--kf-ink);
    text-decoration: none;
    border-radius: var(--r-sm);
    transition: background var(--dur-fast), color var(--dur-fast);
}
.kf-nav-menu__link:hover { color: var(--kf-teal-700); background: rgb(var(--kf-teal-100-rgb) / .55); }
.kf-nav-menu__link.is-active { color: var(--kf-teal-700); background: var(--kf-teal-100); }
.kf-nav-menu__year {
    flex: none;
    font-family: var(--font-body);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--kf-ink-2);
}
.kf-nav-menu__link.is-active .kf-nav-menu__year { color: var(--kf-teal-700); }

.kf-site-header__logo:focus-visible,
.kf-site-nav__link:focus-visible,
.kf-nav-menu__link:focus-visible,
.kf-menu-button:focus-visible,
.kf-lang-switch__option:focus-visible,
.kf-site-footer a:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* ─── Mobile menu ────────────────────────────────────────── */
.kf-menu-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--kf-ink);
    background: var(--kf-white);
    border: none;
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
}
.kf-menu-button__icon { display: grid; place-items: center; }
.kf-menu-button[aria-expanded="true"] .kf-menu-button__icon--open,
.kf-menu-button[aria-expanded="false"] .kf-menu-button__icon--close { display: none; }

.kf-mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    padding: 8px var(--gutter) 18px;
}
.kf-mobile-nav[hidden] { display: none; }
.kf-mobile-nav .kf-site-nav__link { align-self: stretch; padding: 12px 16px; font-size: 17px; }
.kf-mobile-nav__cta { margin-top: 8px; }
.kf-mobile-nav__live { margin-bottom: 6px; }
.kf-mobile-nav__group { margin-top: 6px; padding-top: 10px; border-top: var(--bw) solid var(--kf-line); }
.kf-mobile-nav__group-title {
    margin: 0;
    padding: 0 16px 4px;
    font-size: var(--fs-small);
    font-weight: var(--fw-semibold);
    color: var(--kf-ink-2);
}
.kf-mobile-nav__group-list { display: flex; flex-direction: column; gap: 4px; }
.kf-mobile-nav .kf-mobile-nav__sublink {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-left: 28px;
}

/* ─── Live-stream pill (Header.jsx) ──────────────────────── */
.kf-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--r-pill);
    background: var(--kf-sakura-600);
    color: var(--kf-white);
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease;
}
.kf-live-pill:hover,
.kf-live-pill.is-active { background: var(--kf-sakura-700); color: var(--kf-white); }
.kf-live-pill:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.kf-live-pill__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
@media (prefers-reduced-motion: no-preference) {
    .kf-live-pill__dot { animation: kf-live-pulse 1.6s ease-in-out infinite; }
}
@keyframes kf-live-pulse { 50% { opacity: .45; } }

/* ─── Language switch ────────────────────────────────────── */
.kf-lang-switch {
    display: inline-flex;
    flex: none;
    padding: 3px;
    background: var(--kf-white);
    border: var(--bw) solid var(--kf-line);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-xs);
}
.kf-lang-switch__option {
    padding: 5px 11px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: var(--fw-semibold);
    line-height: 1.2;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--kf-ink-3);
    text-decoration: none;
    border-radius: var(--r-pill);
    transition: background var(--dur-fast), color var(--dur-fast);
}
.kf-lang-switch__option:hover { color: var(--kf-ink); background: var(--kf-cloud); }
.kf-lang-switch__option.is-active { color: var(--kf-sakura-700); background: var(--kf-sakura-300); }

/* ─── Footer ─────────────────────────────────────────────── */
.kf-site-footer {
    margin-top: 96px;
    background: var(--kf-white);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -10px 40px rgb(var(--kf-teal-rgb) / .18);
}
.kf-site-footer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 36px;
    max-width: var(--container);
    margin: 0 auto;
    padding: 56px var(--gutter) 28px;
}
.kf-site-footer__brand,
.kf-site-footer__col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.kf-site-footer__brand { gap: 12px; }
.kf-site-footer__brand img { display: block; width: 170px; height: auto; }
.kf-site-footer__tagline { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-muted); }
.kf-site-footer__heading {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: var(--fw-semibold);
    color: var(--text-body);
}
.kf-site-footer__col a {
    font-size: 15px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--dur-fast);
}
.kf-site-footer__col a:hover { color: var(--text-link-hover); }
.kf-site-footer a.kf-site-footer__social {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    color: var(--kf-sakura-600);
    text-decoration: none;
}
.kf-site-footer a.kf-site-footer__social:hover { color: var(--kf-sakura-700); }
#newsletter { scroll-margin-top: calc(var(--header-h) + 16px); }
.kf-site-footer__newsletter { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 2px; }
.kf-site-footer__bottom {
    max-width: var(--container);
    margin: 0 auto;
    padding: 18px var(--gutter) 28px;
    font-size: 13px;
    color: var(--text-subtle);
    border-top: var(--bw) solid var(--kf-line);
}

@media print {
    .kf-site-header,
    .kf-site-footer,
    .kf-skip-link { display: none !important; }
}
