/* ============================================================================
   kidszone_topic_dropdown.css
   Shared "Kids Zone Topics" dropdown. Same look and behaviour as the Counting
   "Topics" dropdown (count_color.css), but every class is prefixed `kzd-` and
   nothing depends on `.counting-main`, so it works on any Kids Zone page and
   cannot clash with topic.css (.topic-nav), count_color.css (.topic-bar) or
   the Connect the Dots theme dropdown.

   To restyle: override the --kzd-* variables on .kzd-bar (see top rule).
   ============================================================================ */

.kzd-bar {
  /* ---- Customisable design tokens ---- */
  --kzd-ink: #0e2770;                 /* text colour */
  --kzd-blue: #2f5fee;                /* current item + focus ring */
  --kzd-border: #e2e8f0;              /* dropdown panel border */
  --kzd-accent: #8fa9f2;              /* trigger border */
  --kzd-tint: #e9effd;                /* hover background */
  --kzd-tint-strong: #dbe5fd;         /* current-item background */
  --kzd-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --kzd-list-max-width: 26rem;
  /* Same trigger width on every page (longest label is "Coloring & Tracing"),
     so the row never depends on which category name is currently shown. */
  --kzd-trigger-width: 13.5rem;

  /* Breadcrumb and picker share one row whenever the bar is wide enough for
     both. The picker has the same width on every page, so the point where it
     drops to its own row is identical on every page (and depends on the bar's
     real width, not the screen's). Below 679px the bar stacks (see the end). */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  width: 100%;
  min-width: 0;
  margin: 0 0 16px 0;
  box-sizing: border-box;
}

/* Same colours as Counting, using oklch() where the browser supports it */
@supports (color: oklch(0.5 0.1 264)) {
  .kzd-bar {
    --kzd-accent: oklch(0.75 0.12 264);
    --kzd-tint: oklch(0.95 0.03 264);
    --kzd-tint-strong: oklch(0.93 0.05 264);
  }
}

/* The page's own breadcrumb sits on the left; its bottom margin moves to the bar.
   Its flex-basis is only a small minimum (12rem), so a long breadcrumb shrinks and
   wraps internally instead of pushing the picker to a second row. */
.kzd-bar > nav.breadcrumb {
  margin-bottom: 0;
  flex: 1 1 12rem;
  min-width: 0;
}

.kzd-bar > nav.breadcrumb > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kzd-picker,
.kzd-picker * {
  box-sizing: border-box;
}

.kzd-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
  font-family: var(--smw-font-stack);
}

.kzd-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--kzd-ink);
  white-space: nowrap;
}

.kzd-dropdown {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.kzd-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: var(--kzd-trigger-width);
  max-width: 100%;
  padding: 0.4rem 0.85rem;
  font-family: var(--smw-font-stack);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--kzd-ink);
  background: #ffffff;
  border: 1.5px solid var(--kzd-accent);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(47, 95, 238, 0.08);
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--kzd-ease), box-shadow 0.2s var(--kzd-ease);
}

.kzd-trigger::-webkit-details-marker { display: none; }
.kzd-trigger::marker { content: ""; }

.kzd-trigger:hover {
  background: var(--kzd-tint);
}

.kzd-trigger:focus-visible {
  outline: 2px solid var(--kzd-blue);
  outline-offset: 2px;
}

.kzd-dropdown[open] > .kzd-trigger {
  box-shadow: 0 0 0 3px rgba(47, 95, 238, 0.15);
}

.kzd-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kzd-chevron {
  flex-shrink: 0;
  transition: transform 0.2s var(--kzd-ease);
}

.kzd-dropdown[open] .kzd-chevron {
  transform: rotate(180deg);
}

.kzd-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 100%;
  width: max-content;
  max-width: min(92vw, var(--kzd-list-max-width));
  max-height: 70vh;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #ffffff;
  border: 1.5px solid var(--kzd-border);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(20, 30, 60, 0.14);
}

.kzd-list li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kzd-option,
.kzd-option:visited {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--kzd-ink);
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 0.2s var(--kzd-ease);
}

.kzd-option:hover {
  background: var(--kzd-tint);
  color: var(--kzd-ink);
  text-decoration: none;
}

.kzd-option.is-current,
.kzd-option.is-current:visited,
.kzd-option.is-current:hover {
  background: var(--kzd-tint-strong);
  color: var(--kzd-blue);
  font-weight: 700;
}

.kzd-option:focus-visible {
  outline: 2px solid var(--kzd-blue);
  outline-offset: -2px;
}

/* ---------- Phones / small tablets ----------
   Breadcrumb above, label above a full-width dropdown. A NON-wrapping column is
   required: a wrapping column is sized by its widest child and could let the
   breadcrumb or dropdown overflow the screen.
   679px = the narrowest width where a 3-item breadcrumb (~250px) + gap + the
   picker (~355px) still fit one row inside the page padding. Wider than this
   (e.g. 735px) the dropdown stays beside the breadcrumb. */
@media (max-width: 679px) {
  .kzd-bar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.75rem;
  }

  .kzd-bar > nav.breadcrumb {
    flex: 0 0 auto;
    max-width: 100%;
  }

  .kzd-picker {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin-left: 0;
    width: 100%;
  }

  .kzd-dropdown {
    width: 100%;
  }

  .kzd-trigger {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    font-size: 1rem;
  }

  .kzd-list {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 60vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kzd-trigger,
  .kzd-chevron,
  .kzd-option {
    transition: none;
  }
}