/* ─── Barra superior ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: none;
}

.topbar-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
}

/* ─── Botó de menú mòbil ─────────────────────────────────────────────────── */

.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1h);
  width: 58px;
  min-height: 58px;
  height: 58px;
  padding: 8px 8px;
  border-radius: var(--radius-lg);
  order: -1;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  color: var(--muted);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.mobile-menu-btn:hover {
  background: var(--filter-option-hover-bg);
  border: 1px solid var(--actionable-border);
  color: var(--text-strong);
}

.mobile-menu-label {
  font-family: var(--font-ui);
  font-size: var(--font-sm);
  font-weight: 800;
  letter-spacing: 0.1px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ─── Brand / logo ───────────────────────────────────────────────────────── */

.brand {
  display: flex;
  align-items: center;
  min-width: 220px;
}

.brand--top-static {
  display: none;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}

.logo::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: var(--radius-md);
  border: none;
  pointer-events: none;
}

.logo svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: currentColor;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-title {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: var(--font-4xl);
  letter-spacing: 0.2px;
}

.brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--font-base);
  font-weight: 600;
}

.mobile-nav-header .brand {
  min-width: auto;
}

/* ─── Cerca global (topbar) ──────────────────────────────────────────────── */

.topbar-search-field {
  flex: 0 1 352px;
  max-width: 352px;
  margin-left: auto;
  width: 100%;
  min-width: 0;
}

/* ─── Autenticació / botons ──────────────────────────────────────────────── */

.auth {
  display: none;
}

/*
 * Mateixa família visual que .today-btn al sidebar d'agenda (filtres):
 * lavat primari, vora --actionable-line, radi i alçada de control.
 */
.sidebar-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ctrl-min-height);
  padding: var(--ctrl-pad-y) 14px;
  border-radius: var(--ctrl-radius);
  border: 1px solid var(--actionable-line);
  background: var(--actionable-wash);
  /* color: model secundari a controls.css (alineat amb .programa-col-toggle) */
  font-family: var(--font-ui);
  font-weight: var(--ctrl-font-weight);
  font-size: var(--ctrl-font-size);
  letter-spacing: var(--ctrl-letter-spacing);
  cursor: pointer;
  box-sizing: border-box;
  white-space: nowrap;
  box-shadow: none;
  transition: var(--ctrl-transition);
}

.sidebar-pill-btn:hover {
  border-color: var(--actionable-border);
}

.sidebar-pill-btn:focus {
  outline: none;
}


.btn {
  border: 1px solid var(--actionable-line);
  background: var(--actionable-wash);
  /* color: model secundari a controls.css (alineat amb .programa-col-toggle) */
  padding: var(--ctrl-pad-y) 14px;
  min-height: var(--ctrl-min-height);
  border-radius: var(--ctrl-radius);
  font-size: var(--ctrl-font-size);
  font-weight: var(--ctrl-font-weight);
  font-family: var(--font-ui);
  letter-spacing: var(--ctrl-letter-spacing);
  cursor: pointer;
  transition:
    transform 0.06s ease,
    border-color 0.12s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn.btn-ghost {
  background: var(--actionable-wash);
}

.btn:hover {
  border-color: var(--actionable-border);
}

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

.btn:focus {
  outline: none;
}

.btn-primary {
  background: var(--color-primary-strong);
  border-color: var(--ui-overlay-subtle);
  color: var(--card);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    filter: brightness(1.07);
  }
}

/* ─── Narrow (≤ 980 px) ───────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .brand {
    min-width: unset;
  }
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
  /* El títol/subtítol de secció s'ha retirat de la capçalera (el context viu al
     fil d'Ariadna de .results-header). La cerca global manté l'amplada fixa
     d'escriptori (352px), alineada a la dreta de la columna lliure. */
  .topbar-inner {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
  }
  .auth {
    display: none;
  }
  .topbar .brand--top-link {
    display: none;
  }
}

/* ─── Molt estret (≤ 520 px): topbar compactada per guanyar zona útil.
 * La cerca global es manté visible (substitueix l'antic títol de secció).
 * L'alçada real es mesura via JS (viewport.js) i s'exposa a --topbar-height,
 * que consumeix .page padding-top i els elements sticky (filtres). */

@media (max-width: 520px) {
  /* Alçada topbar suficient per icona + etiqueta «Menú» sense retallats.
   * No es compença contra .main{padding-top}: el separador amb la card roman com està (layout ≤520px). */
  .topbar-inner {
    padding: 11px 10px;
    column-gap: 12px;
    align-items: center;
  }
  .mobile-menu-btn {
    width: 44px;
    min-height: 50px;
    height: auto;
    padding: 5px 4px;
    gap: 3px;
    border-radius: var(--radius-md);
  }
  .mobile-menu-btn svg {
    width: 20px;
    height: 20px;
  }
  .mobile-menu-label {
    font-size: var(--font-xs);
  }
  .logo {
    width: 36px;
    height: 36px;
  }
  .logo::after {
    inset: 2px;
    border-width: 2px;
  }
  .logo svg {
    width: 20px;
    height: 20px;
  }
}

/* ─── Ample (≥ 981 px) ───────────────────────────────────────────────────── */

@media (min-width: 981px) {
  .mobile-menu-btn {
    display: none;
  }
  .brand--top-link {
    display: none;
  }
  .brand--top-static {
    display: flex;
  }
}

/* Escriptori mitjà (981px–1400px): només el logo al topbar per alleugerir la capçalera.
   A partir de 1401px es mostra de nou títol i lema; a ≤980px el comportament és el de sempre (drawer amb marca completa). */
@media (min-width: 981px) and (max-width: 1400px) {
  .topbar .brand--top-static {
    min-width: auto;
  }

  .topbar .brand--top-static .brand-text {
    display: none;
  }
}
