/* ==========================================================================
   components.css — reusable building blocks used on several pages:
   navbar, footer, buttons, cards, tags & badges, notices, callouts,
   progress bars, stat tiles, quiz choices, page header, loading skeletons,
   the qubit demo and the chatbot widget (both near the bottom).

   Page-specific styling goes in css/pages/<page>.css instead.
   Colors/spacing come from variables.css.
   ========================================================================== */

/* ==========================================================================
   Navbar  (HTML is created by js/components/navbar.js)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  min-height: var(--header-height);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-heading);
  font-size: 1.15rem;
  font-weight: var(--weight-black);
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-decoration: none;
}

.brand:hover {
  color: var(--color-heading);
}

.brand__logo {
  width: 2.4rem;
  height: 2.4rem;
  flex: none;
}

/* Hamburger button (mobile only) */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--color-heading);
}

.nav-toggle:hover {
  background: var(--steel-100);
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 1.25rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast);
}

.nav-toggle__bars {
  position: relative;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle__bars::before {
  top: -6px;
}

.nav-toggle__bars::after {
  top: 6px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile: the menu is a panel under the header, hidden until opened */
.site-nav {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: var(--z-menu);
  display: none;
  padding: var(--space-3) var(--gutter) var(--space-5);
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

.site-nav[data-open="true"] {
  display: block;
}

.site-nav__list {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__list li + li {
  margin-top: 0;
}

.site-nav__link {
  display: block;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  text-decoration: none;
}

.site-nav__link:hover {
  background: var(--steel-100);
  color: var(--color-heading);
}

/* The page you are on */
.site-nav__link[aria-current="page"] {
  background: var(--blue-50);
  color: var(--blue-900);
  box-shadow: inset 0 0 0 1px var(--blue-200);
}

@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }

  .site-nav {
    position: static;
    display: block;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .site-nav__list {
    display: flex;
    align-items: center;
    gap: 0.15rem;
  }

  .site-nav__link {
    padding: 0.5rem 0.8rem;
  }
}

/* ==========================================================================
   Footer  (HTML is created by js/components/footer.js)
   ========================================================================== */
.site-footer {
  margin-top: auto;
  padding-block: var(--space-7) var(--space-6);
  background: var(--ink-900);
  color: var(--color-on-dark-muted);
  font-size: var(--text-sm);
  --focus-ring-color: var(--color-focus-on-dark);
}

.site-footer a {
  color: #ffffff;
}

.site-footer a:hover {
  color: var(--color-on-dark-quantum);
}

.site-footer__grid {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 900px) {
  .site-footer__grid {
    grid-template-columns: 1.6fr 1fr 1.2fr;
  }
}

.site-footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: var(--weight-black);
  text-decoration: none;
}

.site-footer__brand img {
  width: 2.2rem;
  height: 2.2rem;
}

.site-footer__heading {
  margin-bottom: var(--space-3);
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.site-footer__links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__links li + li {
  margin-top: var(--space-2);
}

.site-footer__fine {
  max-width: none;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-dark);
  font-size: var(--text-xs);
}

/* ==========================================================================
   Buttons:  <button class="btn btn--primary">  or  <a class="btn btn--secondary">
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem; /* big enough to tap on a phone */
  padding: 0.65rem 1.25rem;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: var(--weight-bold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast),
    transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  color: var(--color-on-primary);
}

.btn--secondary {
  background: #ffffff;
  color: var(--blue-800);
  border-color: var(--blue-700);
}

.btn--secondary:hover {
  background: var(--blue-50);
  color: var(--blue-900);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--steel-500); /* 5.7:1 on white, so the button outline itself is easy to see */
}

.btn--ghost:hover {
  background: var(--steel-100);
  color: var(--color-heading);
}

/* Buttons that sit on dark sections */
.btn--light {
  background: #ffffff;
  color: var(--ink-900);
}

.btn--light:hover {
  background: var(--cyan-100);
  color: var(--ink-900);
}

.btn--outline-light {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.7);
}

.btn--outline-light:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.btn--sm {
  min-height: 2.25rem;
  padding: 0.35rem 0.95rem;
  font-size: 0.9rem;
}

.btn--lg {
  min-height: 3.25rem;
  padding: 0.85rem 1.7rem;
  font-size: 1.1rem;
}

/* A button that stays "on" once pressed, e.g. "Mark as complete" (use aria-pressed) */
.btn--toggle[aria-pressed="true"] {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: var(--color-success);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Cards  (built by js/components/card.js → createCard())
   ========================================================================== */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card__header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.card__icon {
  font-size: 2.1rem;
  line-height: 1;
}

.card__eyebrow {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card__title {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

.card__title a {
  color: inherit;
  text-decoration: none;
}

.card__title a:hover {
  text-decoration: underline;
}

.card__body > * + * {
  margin-top: var(--space-3);
}

.card__section {
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border-strong);
}

.card__section-label {
  margin-bottom: 0.2rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-heading);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.85rem;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: var(--space-2);
}

/* Clickable card: the title link is stretched over the whole card */
.card--link {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur);
}

.card--link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--blue-200);
}

.card--link .card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

@supports selector(:has(*)) {
  .card--link .card__link:focus-visible {
    outline: none;
  }

  .card--link:has(.card__link:focus-visible) {
    outline: 3px solid var(--focus-ring-color);
    outline-offset: 3px;
  }
}

/* Dark variant for cards inside dark sections */
.card--dark {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--color-border-dark);
  color: var(--color-on-dark);
  box-shadow: none;
}

.card--dark .card__eyebrow {
  color: var(--color-on-dark-muted);
}

/* ==========================================================================
   Tags & badges
   ========================================================================== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--steel-200);
  border-radius: var(--radius-pill);
  background: var(--steel-100);
  color: var(--steel-800);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
}

.tag--blue {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-900);
}

.tag--cyan {
  background: var(--cyan-50);
  border-color: var(--cyan-100);
  color: var(--cyan-900);
}

.tag--orange {
  background: var(--orange-50);
  border-color: var(--orange-100);
  color: var(--orange-900);
}

.tag--violet {
  background: var(--violet-50);
  border-color: var(--violet-100);
  color: var(--violet-900);
}

.tag--green {
  background: var(--green-50);
  border-color: var(--green-100);
  color: var(--green-900);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-black);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.5;
}

/* "SAMPLE" / "VERIFY" markers on illustrative data */
.badge--sample {
  background: var(--color-sample-bg);
  border: 1px solid var(--color-sample-border);
  color: var(--color-sample-text);
}

.badge--done {
  background: var(--color-success-bg);
  border: 1px solid var(--green-700);
  color: var(--color-success-text);
}

/* ==========================================================================
   Notices (info / error / success / sample banners)
   ========================================================================== */
.notice {
  display: flex;
  max-width: none;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-md);
  background: var(--color-info-bg);
  color: var(--blue-900);
}

.notice__icon {
  flex: none;
  font-size: 1.25rem;
  line-height: 1.5;
}

.notice__title {
  font-weight: var(--weight-black);
}

.notice__body > * + * {
  margin-top: var(--space-2);
}

.notice--error {
  background: var(--color-error-bg);
  border-color: #fca5a5;
  color: var(--color-error-text);
}

.notice--success {
  background: var(--color-success-bg);
  border-color: #86efac;
  color: var(--color-success-text);
}

.notice--sample {
  background: var(--color-sample-bg);
  border-color: var(--color-sample-border);
  color: var(--color-sample-text);
}

/* ==========================================================================
   Callouts: highlighted boxes inside lessons (analogy, jobs, Chicago…)
   Set the colors with the --callout-* variables or use a ready-made variant.
   ========================================================================== */
.callout {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--callout-border, var(--color-border));
  border-left: 6px solid var(--callout-accent, var(--steel-500));
  border-radius: var(--radius-md);
  background: var(--callout-bg, var(--steel-50));
  color: var(--color-text);
}

.callout__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: var(--text-base);
  font-weight: var(--weight-black);
  color: var(--callout-title, var(--color-heading));
}

.callout > * + * {
  margin-top: var(--space-2);
}

.callout--analogy {
  --callout-bg: var(--violet-50);
  --callout-border: var(--violet-100);
  --callout-accent: var(--violet-700);
  --callout-title: var(--violet-900);
}

.callout--jobs {
  --callout-bg: var(--orange-50);
  --callout-border: var(--orange-100);
  --callout-accent: var(--orange-700);
  --callout-title: var(--orange-900);
}

.callout--chicago {
  --callout-bg: var(--cyan-50);
  --callout-border: var(--cyan-100);
  --callout-accent: var(--cyan-700);
  --callout-title: var(--cyan-900);
}

.callout--tip {
  --callout-bg: var(--blue-50);
  --callout-border: var(--blue-100);
  --callout-accent: var(--blue-700);
  --callout-title: var(--blue-900);
}

/* ==========================================================================
   Progress bar:
   <div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="7" aria-valuenow="3" aria-label="Topics completed">
     <div class="progress__bar" style="width: 43%"></div>
   </div>
   ========================================================================== */
.progress {
  height: 0.65rem;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--steel-100);
  box-shadow: inset 0 0 0 1px var(--steel-200);
}

.progress__bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue-700), var(--cyan-700));
  transition: width var(--dur-slow) var(--ease);
}

/* ==========================================================================
   Stat tile: a big number with a label (progress panel, results…)
   ========================================================================== */
.stat {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.stat__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  line-height: 1.1;
  color: var(--color-heading);
}

.stat__label {
  margin-top: 0.2rem;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Quiz choices (multiple choice with big, easy-to-tap answers)
   <fieldset class="choice-group">
     <legend class="choice-group__legend">Question?</legend>
     <label class="choice">
       <input class="choice__input" type="radio" name="q1" value="0">
       <span class="choice__box"><span class="choice__text">Answer</span></span>
     </label>
   </fieldset>
   After answering, add .choice--correct or .choice--incorrect to the <label>.
   ========================================================================== */
.choice-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-group__legend {
  margin-bottom: var(--space-3);
  padding: 0;
  font-weight: var(--weight-bold);
  color: var(--color-heading);
}

.choice {
  position: relative;
  display: block;
}

.choice + .choice {
  margin-top: var(--space-2);
}

/* The real radio button covers the whole choice (so the full box is clickable) but is invisible */
.choice__input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice__box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--color-text);
  transition: border-color var(--dur-fast), background-color var(--dur-fast);
}

/* The round "radio dot" is drawn here */
.choice__box::before {
  content: "";
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  border: 2px solid var(--steel-500);
  border-radius: 50%;
  background: #ffffff;
}

.choice__text {
  flex: 1;
}

.choice:hover .choice__box,
.choice__input:checked + .choice__box {
  border-color: var(--blue-700);
  background: var(--blue-50);
}

.choice__input:checked + .choice__box::before {
  border-color: var(--blue-700);
  background: var(--blue-700);
  box-shadow: inset 0 0 0 3px #ffffff;
}

.choice__input:focus-visible + .choice__box {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.choice__input:disabled {
  cursor: default;
}

/* Answer feedback colours must beat the hover/checked blue above, so these selectors are more specific */
.choice.choice--correct .choice__box,
.choice.choice--correct:hover .choice__box,
.choice.choice--correct .choice__input:checked + .choice__box {
  border-color: var(--green-700);
  background: var(--green-100);
  color: var(--green-900);
}

.choice.choice--correct .choice__box::before,
.choice.choice--correct .choice__input:checked + .choice__box::before {
  border-color: var(--green-700);
  background: var(--green-700);
  box-shadow: inset 0 0 0 3px var(--green-100);
}

.choice.choice--incorrect .choice__box,
.choice.choice--incorrect:hover .choice__box,
.choice.choice--incorrect .choice__input:checked + .choice__box {
  border-color: var(--red-700);
  background: var(--red-100);
  color: var(--red-900);
}

.choice.choice--incorrect .choice__box::before,
.choice.choice--incorrect .choice__input:checked + .choice__box::before {
  border-color: var(--red-700);
  background: var(--red-700);
  box-shadow: inset 0 0 0 3px var(--red-100);
}

/* ==========================================================================
   Page header: the dark banner at the top of every inner page
   <section class="page-header surface-dark"><div class="container">
     <p class="eyebrow">…</p><h1>Title</h1><p class="lead">…</p>
   </div></section>
   ========================================================================== */
.page-header {
  padding-block: var(--space-7);
  background: var(--gradient-hero);
  color: var(--color-on-dark);
}

.page-header .container > * + * {
  margin-top: var(--space-3);
}

.page-header .lead {
  max-width: 44rem;
}

/* ==========================================================================
   Loading skeletons (grey shimmering boxes shown while content loads)
   ========================================================================== */
.skeleton {
  min-height: 1rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--steel-100) 25%, var(--steel-50) 37%, var(--steel-100) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* Small helper for "Mark as complete" check icons, etc. */
.icon-inline {
  display: inline-block;
  vertical-align: -0.12em;
}

/* ==========================================================================
   Filter bar + pills  (built by js/components/filterBar.js)
   <form class="filter-bar"> search box, sort menu, groups of .chip pills, count, "Clear filters"
   ========================================================================== */
.filter-bar {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.filter-bar__top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3) var(--space-4);
}

.filter-bar__top:empty {
  display: none;
}

.filter-bar__label {
  display: block;
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-heading);
}

.filter-bar__input,
.filter-bar__select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  border: 2px solid var(--steel-500);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--color-text);
  font-size: var(--text-base);
}

.filter-bar__input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.filter-bar__input:focus-visible,
.filter-bar__select:focus-visible {
  border-color: var(--blue-700);
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.filter-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-group__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* A pill. The real radio/checkbox covers it (invisible), so the whole pill is clickable and keyboard-friendly. */
.chip {
  position: relative;
  display: inline-flex;
}

.chip__input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip__text {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.3rem 0.95rem;
  border: 2px solid var(--steel-300);
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--steel-800);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}

.chip:hover .chip__text {
  border-color: var(--blue-700);
  background: var(--blue-50);
}

.chip__input:checked + .chip__text {
  border-color: var(--blue-700);
  background: var(--blue-700);
  color: #ffffff;
}

/* A check mark, so "selected" never relies on color alone */
.chip__input:checked + .chip__text::before {
  content: "✓";
  margin-right: 0.4rem;
  font-weight: var(--weight-black);
}

.chip__input:focus-visible + .chip__text {
  outline: 3px solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* The pill groups sit inside a "Filters" disclosure: collapsed on phones, always open from 900px up */
.filter-bar__groups {
  min-width: 0;
}

.filter-bar__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--steel-500);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--color-heading);
  font-weight: var(--weight-bold);
  list-style: none;
  cursor: pointer;
}

.filter-bar__summary::-webkit-details-marker {
  display: none;
}

.filter-bar__summary::after {
  content: "▾";
  content: "▾" / "";
  font-size: 1.1em;
  transition: transform var(--dur-fast);
}

.filter-bar__groups[open] > .filter-bar__summary::after {
  transform: rotate(180deg);
}

.filter-bar__summary:hover {
  background: var(--steel-50);
}

.filter-bar__active {
  margin-left: auto;
  padding: 0.1rem 0.65rem;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-pill);
  background: var(--blue-50);
  color: var(--blue-900);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.filter-bar__groups-body {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-4);
}

.filter-bar__groups.is-static > .filter-bar__summary {
  display: none;
}

.filter-bar__groups.is-static > .filter-bar__groups-body {
  padding-top: 0;
}

.filter-bar__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
}

.filter-bar__count {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ==========================================================================
   AI label: every AI-written summary carries one of these (wording lives in config.js)
   ========================================================================== */
.ai-label {
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--violet-100);
  border-radius: var(--radius-sm);
  background: var(--violet-50);
  color: var(--violet-900);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
}

/* Plain excerpt from the publisher's own feed (not written by AI) */
.ai-label--source {
  border-color: var(--steel-200);
  background: var(--steel-50);
  color: var(--steel-700);
}

/* ==========================================================================
   Qubit demo  (added by the qubit demo component — js/components/qubitDemo.js)
   ========================================================================== */
/* A "lab panel": dark card with the dial, the bar, the gate buttons and the explanation. */

/* ---- State view (one qubit state) ---- */
.qubit-view {
  --focus-ring-color: var(--color-focus-on-dark);
  --qubit-dial-size: 9.5rem;
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-4);
  background: var(--ink-950);
  color: var(--color-on-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
}

.qubit-view__title {
  margin: 0;
  color: var(--color-on-dark-quantum);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qubit-view__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3) var(--space-4);
}

.qubit-view__readout {
  flex: 1 1 7rem;
  min-width: 0;
}

.qubit-view__ket {
  display: inline-block;
  margin: 0;
  color: #ffffff;
  font-size: 3.25rem;
  line-height: 1.1;
}

.qubit-view__ket.is-changed {
  animation: qubit-pop var(--dur-slow) var(--ease);
}

.qubit-view__name {
  margin: var(--space-1) 0 0;
  color: var(--color-on-dark-muted);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.qubit-view__measure {
  display: grid;
  gap: var(--space-2);
}

.qubit-view__odds {
  margin: 0;
  color: var(--color-on-dark-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

@keyframes qubit-pop {
  0% {
    transform: scale(0.8);
    color: var(--cyan-300);
  }
  100% {
    transform: scale(1);
    color: #ffffff;
  }
}

/* Small version: used to show a puzzle target */
.qubit-view--sm {
  --qubit-dial-size: 8rem;
  gap: var(--space-2);
  padding: var(--space-3);
}

.qubit-view--sm .qubit-view__main {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: var(--space-3);
}

.qubit-view--sm .qubit-view__ket {
  font-size: 1.9rem;
}

.qubit-view--sm .qubit-view__name {
  font-size: var(--text-xs);
}

.qubit-view--sm .qubit-view__odds {
  font-size: var(--text-xs);
}

.qubit-view--sm .qubit-bar {
  height: 1.75rem;
}

.qubit-view--sm .qubit-bar__label {
  padding: 0 0.4rem;
  font-size: var(--text-xs);
}

.qubit-view--sm .qubit-dial__label {
  font-size: 36px;
}

@media (max-width: 30rem) {
  .qubit-view--sm .qubit-bar__label {
    padding: 0 0.25rem;
    font-size: 0.6875rem;
  }
}

/* ---- Compass dial ---- */
.qubit-dial {
  flex: 0 0 var(--qubit-dial-size);
  width: var(--qubit-dial-size);
  max-width: 100%;
}

.qubit-dial__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.qubit-dial__ring {
  fill: var(--ink-800);
  stroke: var(--steel-500);
  stroke-width: 2;
}

.qubit-dial__axis {
  stroke: var(--ink-700);
  stroke-width: 2;
  stroke-dasharray: 4 6;
}

.qubit-dial__dot {
  fill: var(--ink-950);
  stroke: var(--steel-300);
  stroke-width: 2;
  transition: fill var(--dur) var(--ease), stroke var(--dur) var(--ease);
}

.qubit-dial__dot.is-active {
  fill: var(--cyan-300);
  stroke: var(--cyan-300);
}

.qubit-dial__label {
  fill: var(--color-on-dark-muted);
  font-size: 30px;
  transition: fill var(--dur) var(--ease);
}

.qubit-dial__label.is-active {
  fill: var(--cyan-300);
  font-weight: var(--weight-bold);
}

.qubit-dial__arrow {
  transform-origin: 150px 125px;
  transition: transform var(--dur-slow) var(--ease);
  filter: drop-shadow(0 0 6px var(--cyan-400));
}

.qubit-dial__arrow line {
  stroke: var(--cyan-300);
  stroke-width: 6;
  stroke-linecap: round;
}

.qubit-dial__arrow polygon,
.qubit-dial__hub {
  fill: var(--cyan-300);
}

.qubit-dial.is-instant .qubit-dial__arrow {
  transition: none;
}

/* ---- Measurement bar: two hues AND a stripe pattern, plus text labels ---- */
.qubit-bar {
  display: flex;
  height: 2.5rem;
  overflow: hidden;
  background: var(--ink-800);
  border: 2px solid var(--steel-500);
  border-radius: var(--radius-pill);
}

.qubit-bar__seg {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  transition: width var(--dur-slow) var(--ease);
}

.qubit-bar__seg--zero {
  background: var(--cyan-400);
}

.qubit-bar__seg--one {
  background: repeating-linear-gradient(135deg, var(--orange-400) 0 8px, var(--orange-100) 8px 13px);
  box-shadow: inset 2px 0 0 var(--ink-950);
}

.qubit-bar.is-instant .qubit-bar__seg {
  transition: none;
}

.qubit-bar__label {
  padding: 0.1rem 0.65rem;
  background: var(--ink-950);
  color: #ffffff;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

/* ---- Playground ---- */
.qubit-demo {
  --focus-ring-color: var(--color-focus-on-dark);
  container: qubit-demo / inline-size;
  padding: var(--space-4);
  background: linear-gradient(160deg, var(--ink-900) 0%, var(--ink-800) 100%);
  color: var(--color-on-dark);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.qubit-demo__layout {
  display: grid;
  gap: var(--space-5);
}

.qubit-demo__panel {
  display: grid;
  align-content: start;
  gap: var(--space-4);
  min-width: 0;
}

.qubit-demo__label {
  margin: 0;
  color: var(--color-on-dark-quantum);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qubit-demo__controls {
  display: grid;
  gap: var(--space-3);
}

.qubit-demo__controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.qubit-demo__gates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: var(--space-3);
}

.qubit-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 5rem;
  padding: var(--space-3) var(--space-2);
  background: var(--ink-700);
  color: #ffffff;
  border: 2px solid var(--cyan-400);
  border-radius: var(--radius-md);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease);
}

.qubit-gate:hover {
  background: var(--cyan-400);
  color: var(--ink-950);
}

.qubit-gate:active {
  transform: translateY(2px) scale(0.98);
}

.qubit-gate__letter {
  font-size: 2rem;
  font-weight: var(--weight-black);
  line-height: 1;
}

.qubit-gate__caption {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

@container qubit-demo (max-width: 26rem) {
  .qubit-demo__gates {
    grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr));
    gap: var(--space-2);
  }

  .qubit-gate {
    padding-inline: var(--space-1);
  }
}

.qubit-demo__what {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--ink-950);
  border-left: 4px solid var(--cyan-400);
  border-radius: var(--radius-sm);
}

.qubit-demo__what.is-fresh {
  animation: qubit-flash var(--dur-slow) var(--ease);
}

.qubit-demo__what-text {
  margin: 0;
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

@keyframes qubit-flash {
  0% {
    background: var(--ink-700);
  }
  100% {
    background: var(--ink-950);
  }
}

.qubit-demo__history {
  display: grid;
  gap: var(--space-2);
}

.qubit-history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.qubit-history__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.qubit-history__item + .qubit-history__item::before {
  content: "→";
  content: "→" / "";
  color: var(--color-on-dark-muted);
  font-weight: var(--weight-bold);
}

.qubit-chip {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  background: var(--ink-700);
  color: #ffffff;
  border: 1px solid var(--steel-500);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.qubit-chip--latest {
  background: var(--cyan-300);
  color: var(--ink-950);
  border-color: var(--cyan-300);
}

.qubit-chip--more {
  font-weight: var(--weight-regular);
}

.qubit-demo__note {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  color: var(--color-on-dark-muted);
  border: 1px dashed var(--steel-500);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  transition: border-color var(--dur), color var(--dur);
}

.qubit-demo__note.is-highlighted {
  color: #ffffff;
  border-color: var(--cyan-300);
  border-style: solid;
}

@media (min-width: 600px) {
  .qubit-demo {
    padding: var(--space-5);
  }
}

/* Wide playground: state on the left, controls on the right (measured on the playground itself, not the screen). */
@container qubit-demo (min-width: 40rem) {
  .qubit-demo__layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
    gap: var(--space-6);
  }

  .qubit-demo .qubit-view {
    align-content: start;
    padding: var(--space-5);
  }

  .qubit-demo .qubit-view__main {
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }

  .qubit-demo .qubit-view {
    --qubit-dial-size: 16rem;
  }

  .qubit-demo .qubit-view__readout {
    flex: none;
  }

  .qubit-demo .qubit-view__ket {
    font-size: 3.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qubit-dial__arrow,
  .qubit-bar__seg,
  .qubit-dial__dot,
  .qubit-dial__label,
  .qubit-gate,
  .qubit-demo__note {
    transition: none;
  }

  .qubit-view__ket.is-changed,
  .qubit-demo__what.is-fresh {
    animation: none;
  }
}

/* ==========================================================================
   Chatbot widget  (HTML is created by js/components/chatbot.js)
   A round launcher button, bottom-right, that opens a chat panel.
   Phones: the panel is a bottom sheet. Computers: a 24rem card in the corner.
   ========================================================================== */

/* Room at the bottom of every page so the launcher never covers the footer text */
.has-chatbot .site-footer {
  padding-bottom: calc(var(--space-6) + 5rem);
}

/* ---------- Launcher ---------- */
.chatbot__launcher {
  position: fixed;
  right: max(var(--space-4), env(safe-area-inset-right));
  bottom: max(var(--space-4), env(safe-area-inset-bottom));
  z-index: var(--z-chatbot);
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: 3px solid #ffffff; /* the white ring keeps the button visible on dark sections too */
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background-color var(--dur-fast), transform var(--dur) var(--ease);
}

.chatbot__launcher[hidden] {
  display: none;
}

.chatbot__launcher:hover {
  background: var(--color-primary-hover);
  transform: scale(1.06);
}

.chatbot__launcher:focus-visible {
  outline: 4px solid var(--color-focus-on-dark);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ink-900), var(--shadow-lg);
}

.chatbot__launcher-icon {
  width: 1.65rem;
  height: 1.65rem;
}

/* ---------- Panel ---------- */
.chatbot__panel {
  position: fixed;
  right: max(var(--space-2), env(safe-area-inset-right));
  bottom: max(var(--space-2), env(safe-area-inset-bottom));
  left: max(var(--space-2), env(safe-area-inset-left));
  z-index: var(--z-chatbot);
  display: flex;
  flex-direction: column;
  height: min(40rem, 85vh);
  height: min(40rem, 85dvh);
  overflow-x: hidden;
  overflow-y: auto; /* on very short screens (zoomed in) the whole panel scrolls instead of clipping */
  scroll-padding-top: 8rem; /* keeps a focused input from hiding under the pinned header */
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  animation: chatbot-rise var(--dur-slow) var(--ease);
}

.chatbot__panel[hidden] {
  display: none;
}

@keyframes chatbot-rise {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-height: 32rem) {
  .chatbot__panel {
    height: calc(100vh - 1rem);
    height: calc(100dvh - 1rem);
  }
}

@media (min-width: 600px) {
  .chatbot__panel {
    left: auto;
    right: max(var(--space-5), env(safe-area-inset-right));
    bottom: max(var(--space-5), env(safe-area-inset-bottom));
    width: 24rem;
    height: min(40rem, calc(100vh - 3rem));
    height: min(40rem, calc(100dvh - 3rem));
  }

  .chatbot__launcher {
    right: max(var(--space-5), env(safe-area-inset-right));
    bottom: max(var(--space-5), env(safe-area-inset-bottom));
  }
}

/* ---------- Header (dark navy) ---------- */
.chatbot__header {
  position: sticky; /* Clear chat and Close stay reachable even when the panel scrolls */
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--gradient-hero);
  color: var(--color-on-dark);
  --focus-ring-color: var(--color-focus-on-dark);
}

.chatbot__titles {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
}

.chatbot__title {
  color: var(--color-on-dark);
  font-size: var(--text-base);
  line-height: var(--leading-tight);
}

@media (min-width: 600px) {
  .chatbot__title {
    font-size: var(--text-lg);
  }
}

.chatbot__mode {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-on-dark-quantum);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  line-height: 1.5;
}

.chatbot__actions {
  display: flex;
  gap: var(--space-2);
}

.chatbot__action {
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-pill);
  background: transparent;
  color: #ffffff;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: 1.2;
  cursor: pointer;
  transition: background-color var(--dur-fast);
}

.chatbot__action:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* ---------- Safety wording ---------- */
.chatbot__disclaimer {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-info-bg);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.45;
}

.chatbot__privacy {
  padding: 0 var(--space-4) var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

/* ---------- Conversation ---------- */
.chatbot__body {
  position: relative;
  flex: 1;
  min-height: 8rem; /* the conversation is never squeezed smaller than this */
  padding: var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--steel-25);
}

.chatbot__log {
  display: grid;
  gap: var(--space-3);
}

.chatbot__msg {
  display: flex;
}

.chatbot__msg--user {
  justify-content: flex-end;
}

.chatbot__bubble {
  max-width: 92%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chatbot__bubble > * + * {
  margin-top: var(--space-2);
}

.chatbot__msg--bot .chatbot__bubble {
  border-bottom-left-radius: var(--radius-sm);
  background: var(--steel-100);
  color: var(--steel-800);
}

.chatbot__msg--user .chatbot__bubble {
  border-bottom-right-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: var(--weight-medium);
}

.chatbot__lead {
  color: var(--color-text-muted);
  font-weight: var(--weight-semibold);
}

/* Links to pages (and other websites) under an answer */
.chatbot__links {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.chatbot__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--color-link);
  font-weight: var(--weight-bold);
  line-height: 1.25;
  text-decoration: none;
}

.chatbot__link::after {
  content: "→";
  content: "→" / "";
  flex: none;
}

.chatbot__link:hover {
  border-color: var(--color-link);
  background: var(--blue-50);
  color: var(--color-link-hover);
}

/* Question buttons: the starters and "You might also ask" */
.chatbot__more-label {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chatbot__chips,
.chatbot__more {
  display: grid;
  gap: var(--space-2);
}

.chatbot__starters:not(:empty) {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.chatbot__chip {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.4rem 0.9rem;
  border: 2px solid var(--blue-700);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--blue-800);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.chatbot__chip:hover {
  background: var(--blue-50);
  color: var(--blue-900);
}

/* Error and loading states */
.chatbot__error {
  display: grid;
  gap: var(--space-3);
}

.chatbot__loading {
  display: grid;
  gap: var(--space-2);
  max-width: 80%;
}

.chatbot__loading .skeleton:last-child {
  width: 60%;
}

/* ---------- Typing area ---------- */
.chatbot__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chatbot__label {
  color: var(--color-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.chatbot__row {
  display: flex;
  gap: var(--space-2);
}

.chatbot__input {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.4rem 1rem;
  border: 2px solid var(--steel-500);
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
}

.chatbot__send {
  flex: none;
}

/* Printed pages don't need a chat window */
@media print {
  .chatbot {
    display: none;
  }
}

/* ==========================================================================
   Windows High Contrast ("forced colors"): the browser removes background colors,
   so parts that are drawn ONLY with a background need a real border or a system color.
   ========================================================================== */
@media (forced-colors: active) {
  .progress {
    border: 1px solid CanvasText;
  }

  .progress__bar {
    background: Highlight;
    forced-color-adjust: none;
  }

  .qubit-bar {
    border: 1px solid CanvasText;
  }

  .qubit-bar__seg {
    border-right: 1px solid CanvasText;
  }

  /* The round dot of a selected answer is a background: make selection a thick ring instead */
  .choice__input:checked + .choice__box::before {
    border-width: 0.4rem;
  }

  .chip__input:checked + .chip__text {
    border-width: 4px;
  }
}
