/**
 * Rozcestník directory — layout for the zpd/taxonomy-filter block.
 *
 * Kept out of style.css so the shared ZPDv2 theme file stays mergeable.
 * Uses the theme's design tokens throughout; no new colour values.
 */

/* ── Layout ────────────────────────────────────────────────────────────── */

.zpd-filter-wrapper {
    max-width: min(1280px, 100% - var(--spacing-3));
    margin-inline: auto;
    color: var(--color-text-primary);
}

.zpd-filter-container {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: var(--spacing-3);
    align-items: start;
}

@media (max-width: 900px) {
    .zpd-filter-container { grid-template-columns: minmax(0, 1fr); }
}

/* The directory is the page — a duplicate post title above it adds nothing. */
.page-rozcestnik .wp-block-post-title { display: none; }

/* ── Banner ────────────────────────────────────────────────────────────── */

.zpd-filter-banner {
    margin-bottom: var(--spacing-4);
}

/* render.php nests the headline and search in an inner wrapper; that is the
   flex row, so the banner lines up with the grid below it. */
.zpd-filter-banner__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-3);
}

.zpd-filter-banner__logo {
    flex: 0 0 auto;
    width: auto;
    height: 3.75rem;
}

/* Headline drops under the logo+search row: the text takes the full second
   row of the wrapping flex container, so the first row is logo left (space-
   between) and the search pill right. */
.zpd-filter-banner__text {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
}

.zpd-filter-banner__subtitle {
    margin: var(--spacing-1) 0 0;
    color: var(--color-text-secondary);
}

/* The default link green reaches only 4.12:1 on white at this size; one step
   darker clears AA. These links are the crisis numbers — the last place to
   make someone squint. */
.zpd-filter-banner__subtitle a {
    color: var(--color-zpd-primary-700);
}

/* The plugin already lays the banner search out as a flex row (icon + input,
   border on the wrapper) — only the sizing is adjusted here. Do not position
   the icon absolutely: it would overlap the input's placeholder. */
.zpd-filter-banner__search-wrap {
    flex: 1 1 320px;
    max-width: 460px;
}

.zpd-filter-banner__search-wrap:focus-within {
    outline: 2px solid var(--color-brand-600);
    outline-offset: 1px;
}

.zpd-filter-banner .zpd-filter-search-input {
    font-size: 0.95rem;
    color: var(--color-text-primary);
}

.zpd-filter-search-input::placeholder { color: var(--color-text-secondary); }

/* Standalone search bar (above / inside positions) — no wrapper to inherit. */
.zpd-filter-search .zpd-filter-search-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--color-black-300);
    border-radius: var(--radius-4xl);
    background: var(--color-white);
    font: inherit;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.zpd-filter-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    position: sticky;
    top: var(--spacing-2);
}

@media (max-width: 900px) {
    .zpd-filter-panel { position: static; }
}

/* Border, corners and padding come from the border-1 border-black-200
   rounded-lg padding-2 utilities in the markup. */
.zpd-filter-accordion {
    background: var(--color-white);
}

/* Layout only — type comes from the utility classes in the plugin's markup
   (body-small text-black-900 font-bold), so nothing here may override it. */
.zpd-filter-accordion-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-1);
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.zpd-filter-accordion-title:focus-visible {
    outline: 2px solid var(--color-brand-600);
    outline-offset: 2px;
}

/* Chevron: up when open, down when collapsed.
   The plugin toggles the panel with an inline `display` style and never sets a
   state class, so the arrow is driven off the content's own visibility via
   :has() rather than a class that would always be absent. */
.zpd-filter-accordion-title::after {
    content: "";
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(-135deg);
    transition: transform 0.18s ease;
}

.zpd-filter-accordion:has( .zpd-filter-accordion-content[style*="display: none"] )
    .zpd-filter-accordion-title::after {
    transform: translateY(-3px) rotate(45deg);
}

.zpd-filter-accordion-content { margin-top: var(--spacing-2); }

.zpd-filter-terms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.75rem;
}

/* Long labels read better stacked. */
.zpd-filter-terms:not([data-taxonomy="spadovost"]) {
    grid-template-columns: minmax(0, 1fr);
}

.zpd-filter-term {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    line-height: 1.3;
    cursor: pointer;
    /* Zdroj terms are long unbreakable strings
       ("DTB_Koordinace_DETI_A_ADOLESCENTI - PRAHA 1") that would otherwise
       overflow the filter column. */
    overflow-wrap: anywhere;
}

/* Selector mirrors the plugin's `.zpd-filter-term input[type='checkbox']`,
   which sets a 15px box and would otherwise win on specificity. */
.zpd-filter-term input[type='checkbox'].zpd-filter-term-input {
    appearance: none;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin: 0;
    position: relative;
    border: 2px solid var(--color-black-300);
    border-radius: var(--radius-md);
    background: var(--color-white);
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.zpd-filter-term input[type='checkbox'].zpd-filter-term-input:checked {
    background: var(--color-brand-600);
    border-color: var(--color-brand-600);
}

/* Centred via transform rather than fixed offsets, so the tick stays put if
   the box size ever changes. top 45% + the -55% Y nudge lift the glyph
   slightly: a checkmark's visual mass sits below its bounding box centre. */
.zpd-filter-term-input:checked::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 45%;
    width: 6px;
    height: 11px;
    border-right: 2.5px solid var(--color-white);
    border-bottom: 2.5px solid var(--color-white);
    transform: translate(-50%, -55%) rotate(45deg);
}

.zpd-filter-term-input:focus-visible {
    outline: 2px solid var(--color-brand-600);
    outline-offset: 2px;
}

.zpd-filter-term-help { color: var(--color-brand-600); cursor: help; }

.zpd-filter-show-more {
    margin-top: var(--spacing-2);
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-brand-700);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

/* ── Results ───────────────────────────────────────────────────────────── */

.zpd-filter-results {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

/* Layout of this bar (flex, pills left / count right) comes from the plugin;
   only the spacing above it is ours. */
.zpd-filter-results-bar {
    margin-top: calc(var(--spacing-2) * 0.75);
}

.zpd-filter-active-pills {
    align-items: center;
}

.zpd-filter-active-pills:not(:empty)::before {
    content: "Aktivní filtry";
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.zpd-filter-pill-active {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-lg);
    background: var(--color-brand-50);
    color: var(--color-brand-900);
    font-size: 0.875rem;
}

.zpd-filter-pill-remove {
    border: 0;
    padding: 0;
    background: none;
    color: var(--color-brand-700);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.zpd-filter-results-count {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    text-align: right;
    /* Line up with the first row of pills, which carry vertical padding. */
    padding-top: 0.3rem;
}

.zpd-filter-posts {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

/* ── Card ──────────────────────────────────────────────────────────────── */

.zpd-card--organizace {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    background: var(--color-white);
}

.zpd-card__head {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

/* Colours come from the bg-brand-50 text-brand-500 utilities in the markup. */
.zpd-card__avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    height: 3rem;
    aspect-ratio: 1;
    line-height: 1;
}

.zpd-card__heading { min-width: 0; flex: 1 1 auto; }

/* ČAP badge. The delivered PNGs put the seal on a black square with a wide
   margin; the copies in assets/badges are already cropped to the circle with
   transparent corners (see README), so only the size is needed here. */
.zpd-card__badge {
    flex: 0 0 auto;
    /* width:auto is required: the img carries width/height attributes (which
       reserve layout space and prevent a shift), and without this the
       attribute width would win and stretch the badge sideways. */
    width: auto;
    height: 3rem;
    aspect-ratio: 1;
}

.zpd-card__title { margin: 0; }

.zpd-card__sub { margin: 0; }

.zpd-card__meta {
    display: grid;
    grid-template-columns: 12ch minmax(0, 1fr);
    gap: 0.4rem 1rem;
    margin: 0;
    border: 0;
    padding: 0;
}

.zpd-card__meta-label,
.zpd-card__meta-value {
    display: flex;
    align-items: center;
}

.zpd-card__meta-label {
    margin: 0;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.zpd-card__meta-value { margin: 0; line-height: 1.45; }

@media (max-width: 560px) {
    .zpd-card__meta { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
    .zpd-card__meta-value { margin-bottom: 0.5rem; }
}

.zpd-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* The phone/mail/web glyph inside a .button-secondary-small. */
.zpd-action__icon { flex: 0 0 auto; color: var(--color-brand-700); }

/* Contacts repeat the meta list's two-column layout: the group's heading
   ("Nonstop Linka důvěry") sits in the label column with its buttons beside it,
   so the card reads as one table rather than two unrelated blocks. Contacts
   without a heading share a single row with an empty label. */
/* ── Pagination ────────────────────────────────────────────────────────── */

/* The plugin centres the row; with all page numbers shown it reads better
   left-aligned under the results. Overridden here, not in the plugin, so
   Sanitka keeps its centred prev/next. */
.zpd-filter-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: start;
    gap: 0.35rem;
    margin-top: var(--spacing-1);
}

.zpd-pages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.zpd-page {
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--color-text-primary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.zpd-page:hover {
    background: var(--color-brand-50);
}

.zpd-page.is-current {
    background: var(--color-brand-100);
    color: var(--color-brand-900);
}

/* Both are driven by the numbered list injected in rozcestnik-filter.js —
   hidden, not removed, because goToPage() clicks Prev/Next to fetch. */
.zpd-filter-page-info,
.zpd-filter-page-prev,
.zpd-filter-page-next { display: none; }
