/* ==========================================================================
   Home — intro photo, search + content filter, featured feed, contact.
   Builds on css/kw.css (tokens and components); kh- classes are home-only.
   ========================================================================== */

/* Masthead + intro photo ------------------------------------------------ */
.kh-hero .se-masthead { padding-bottom: 32px; }
.kh-hero .se-masthead__intro { font-size: 17px; }
.kh-hero__media {
    display: block;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--se-stone);
}
.kh-hero__media img {
    width: 100%; height: 100%;
    object-fit: cover;
    animation: kh-fade 1.4s .15s var(--se-ease) both;
}
@keyframes kh-fade { from { opacity: 0; } }

/* Discover: head, toolbar ----------------------------------------------- */
.kh-discover { padding: 56px var(--se-gutter) 0; scroll-margin-top: var(--se-appbar-h); }

.kh-toolbar { display: flex; gap: 10px; align-items: stretch; }
.kh-search { position: relative; flex: 1; min-width: 0; }
.kh-search__icon {
    position: absolute; left: 14px; top: 50%;
    width: 16px; height: 16px;
    transform: translateY(-50%);
    color: var(--se-ink-soft);
    pointer-events: none;
}
.kh-search__input { padding-left: 40px; padding-right: 40px; border-radius: 999px; -webkit-appearance: none; appearance: none; }
.kh-search__input::-webkit-search-cancel-button { display: none; }
.kh-search__clear {
    position: absolute; right: 6px; top: 50%;
    width: 34px; height: 34px;
    display: grid; place-items: center;
    transform: translateY(-50%);
    color: var(--se-ink-soft);
}
.kh-search__clear .se-icon { width: 14px; height: 14px; }

.kh-suggest {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
    max-height: 280px;
    margin: 0; padding: 6px;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--se-line);
    border-radius: 14px;
    background: var(--se-surface);
    box-shadow: 0 18px 40px -18px rgba(60, 40, 25, .28);
}
.kh-suggest li {
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    cursor: pointer;
}
.kh-suggest li:hover,
.kh-suggest li.is-active { background: var(--se-stone); }

.kh-filter-btn { flex: 0 0 auto; padding: 0 18px; }
.kh-count {
    display: inline-grid; place-items: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--se-accent);
    color: #fff;
    font-size: 10px;
    letter-spacing: 0;
}
.kh-count[hidden] { display: none; }

/* Active filter chips under the toolbar */
.kh-active { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.kh-active__chip { display: inline-flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: .02em; font-size: 12px !important; }
.kh-active__chip .se-icon { width: 11px; height: 11px; }

/* Filter panel: bottom sheet on mobile/tablet --------------------------- */
.kh-filters {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    display: flex; flex-direction: column;
    max-height: 82vh;
    border-radius: 18px 18px 0 0;
    background: var(--se-surface);
    box-shadow: 0 -20px 50px -20px rgba(60, 40, 25, .3);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform .4s var(--se-ease), visibility 0s .4s;
}
.kh-filters.is-open { transform: none; visibility: visible; transition: transform .4s var(--se-ease); }
.kh-filters-scrim { position: fixed; inset: 0; z-index: 65; background: rgba(60, 40, 25, .28); }
.kh-filters__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 14px 10px var(--se-gutter);
    border-bottom: 1px solid var(--se-line);
}
.kh-filters__head .se-eyebrow { margin: 0; }
.kh-filters__body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px var(--se-gutter) 8px; -webkit-overflow-scrolling: touch; }
.kh-filters__foot {
    display: flex; gap: 10px;
    padding: 12px var(--se-gutter) calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--se-line);
}
.kh-filters__foot .se-btn { flex: 1; }

.kh-filter-group { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.kh-filter-group legend { padding: 0; margin-bottom: 10px; }
.kh-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.kh-chip { position: relative; cursor: pointer; }
.kh-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.kh-chip span {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--se-stone);
    font-size: 12.5px;
    line-height: 1.3;
    transition: background .2s, color .2s;
}
.kh-chip input:checked + span { background: var(--se-accent); color: #fff; }
.kh-chip input:focus-visible + span { outline: 1.5px solid var(--se-accent); outline-offset: 2px; }

/* Feed ------------------------------------------------------------------ */
.kh-feed {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-flow: dense;
    gap: 28px 12px;
    margin-top: 28px;
    transition: opacity .3s var(--se-ease);
}
.kh-feed.is-busy { opacity: .35; pointer-events: none; }
.kh-feed > .se-card { max-width: none; animation: se-rise .8s var(--se-ease) both; }
.kh-card--wide { grid-column: span 2; }
.kh-card .se-card__media { position: relative; }
.kh-card .se-card__title { font-size: 18px; }
.kh-card--wide .se-card__title { font-size: 22px; }
.kh-card .se-card__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12.5px;
}
.kh-card__eyebrow {
    margin-top: 12px;
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: var(--se-track);
    text-transform: uppercase;
    color: var(--se-ink-soft);
}
.kh-card__eyebrow + .se-card__title { margin-top: 4px; }

.kh-badge {
    position: absolute; left: 10px; top: 10px;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px 4px 7px;
    border-radius: 999px;
    background: rgba(251, 249, 245, .86);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.kh-badge .se-icon { width: 10px; height: 10px; }

.kh-empty { margin-top: 28px; text-align: center; }
.kh-empty img { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 4px; }
.kh-empty p { margin: 18px 0 16px; font-family: var(--se-serif); font-size: 20px; font-style: italic; color: var(--se-ink-soft); }

.kh-more { display: grid; justify-items: center; gap: 14px; padding-top: 40px; }
.kh-sentinel { display: block; width: 1px; height: 1px; }
.kh-spinner {
    width: 22px; height: 22px;
    border: 1.5px solid var(--se-line);
    border-top-color: var(--se-accent);
    border-radius: 50%;
    animation: kh-spin .8s linear infinite;
}
.kh-spinner[hidden] { display: none; }
@keyframes kh-spin { to { transform: rotate(360deg); } }

/* Contact + newsletter -------------------------------------------------- */
.kh-person__actions { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }
.kh-person__actions .se-link { padding-bottom: 0; color: var(--se-ink-soft); }

.kh-newsletter__form { display: grid; gap: 4px; max-width: 460px; }
.kh-newsletter__form .se-field { margin-bottom: 10px; }
.kh-newsletter__form .se-btn { justify-self: start; }
.kh-trap { position: absolute; left: -5000px; }

/* ==========================================================================
   Tablet (≥ 768px)
   ========================================================================== */
@media (min-width: 768px) {
    .kh-hero__media { aspect-ratio: 16 / 9; margin: 0 var(--se-gutter); }
    .kh-hero .se-masthead { padding-bottom: 44px; }
    .kh-hero .se-masthead__intro { font-size: 19px; }

    .kh-discover { padding-top: 88px; }
    .kh-filters { left: 50%; right: auto; width: min(640px, 100%); transform: translate(-50%, 100%); }
    .kh-filters.is-open { transform: translate(-50%, 0); }

    .kh-feed { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 20px; }
    .kh-card .se-card__title { font-size: 20px; }
    .kh-card--wide .se-card__title { font-size: 26px; }
    .kh-card .se-card__excerpt { font-size: 13px; }

    .kh-newsletter__form { grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
    .kh-newsletter__form .se-field { margin-bottom: 0; }
    .kh-newsletter__form .se-btn { min-height: 46px; }
}

/* ==========================================================================
   Desktop (≥ 1100px): filter panel opens inline under the toolbar
   ========================================================================== */
@media (min-width: 1100px) {
    .kh-hero__media { max-width: 1320px; margin: 0 auto; aspect-ratio: 21 / 9; }
    .kh-hero .se-masthead { padding-bottom: 56px; }

    .kh-discover { padding-top: 120px; }
    .kh-discover .se-section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }

    .kh-toolbar { max-width: 720px; }
    .kh-filter-btn:hover { border-color: var(--se-ink-soft); }

    .kh-filters,
    .kh-filters.is-open {
        position: static;
        width: auto;
        max-height: none;
        margin-top: 18px;
        border: 1px solid var(--se-line);
        border-radius: 14px;
        box-shadow: none;
        transform: none;
        visibility: visible;
        transition: none;
    }
    .kh-filters:not(.is-open) { display: none; }
    .kh-filters-scrim { display: none; }
    .kh-filters__head { padding: 14px 14px 10px 28px; }
    .kh-filters__body {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 8px 32px;
        padding: 24px 28px 4px;
    }
    .kh-filters__foot { justify-content: flex-end; padding: 12px 28px 16px; }
    .kh-filters__foot .se-btn { flex: 0 0 auto; }
    .kh-filters__done { display: none; }
    .kh-chip span:hover { background: #ECE8E1; }
    .kh-chip input:checked + span:hover { background: var(--se-accent); }

    .kh-feed { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 56px 24px; margin-top: 40px; }
    .kh-card .se-card__title { font-size: 21px; }
    .kh-card--wide .se-card__title { font-size: 28px; }

    .kh-suggest li { font-size: 14.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .kh-feed > .se-card,
    .kh-hero__media img { animation: none; }
    .kh-spinner { animation-duration: 2s; }
}
