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

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

.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(--actionable-wash);
  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 ─────────────────────────────────────────────────────────────── */

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

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

.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-title--line2 {
  margin-top: 1px;
  color: var(--text-strong);
}

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

/* ─── Cerca global a la capçalera (sync q; estètica .field/.input a filters.css) ─ */

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

.btn {
  border: 1px solid var(--actionable-line);
  background: var(--actionable-wash);
  color: var(--text-strong);
  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);
}

/* ─── Títol de secció mòbil ──────────────────────────────────────────────── */

/* (les regles només apareixen a les sobreescriptures responsives de sota) */

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

@media (max-width: 1400px) {
  .brand {
    min-width: unset;
  }
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
  .topbar-inner {
    position: relative;
    display: grid;
    /* Col 1 (1fr): hamburger alineat a l'esquerra
       Col 2 (auto): títol de secció, sempre centrat en el header
       Col 3 (1fr): searchbox, simètrica a col 1 → mai solapa el títol */
    grid-template-columns: 1fr auto 1fr;
    column-gap: 36px;
  }
  .topbar .brand--top-link {
    display: none;
  }
  .mobile-section-title {
    text-align: center;
    pointer-events: none;
    overflow: hidden;
  }
  .mobile-section-title-main {
    font-family: var(--font-ui);
    font-weight: 900;
    font-size: var(--font-2xl);
    letter-spacing: 0.2px;
    line-height: 1.1;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-section-title-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: var(--font-base);
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ─── Molt estret (≤ 520 px): cerca al header amagada (substituïda pel drawer) */

@media (max-width: 520px) {
  .topbar-search-field:not(.topbar-search-field--drawer) {
    display: none;
  }
}

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

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

  /* Espai per als badges de Taules (posició absoluta sota l’enllaç, fora del flux) */
  .topbar-inner {
    padding-bottom: 22px;
  }
}
