/* Testata condivisa degli argomenti (PAL-A1-CUM-INT-01): stato chiuso compatto a ogni larghezza,
   pannello con ricerca e gruppi. L'altezza della testata chiusa non dipende dal numero degli argomenti. */
.a1-topic-header {
  --a1-nav-canvas: #edf0e8;
  --a1-nav-paper: #fffefa;
  --a1-nav-ink: #292d27;
  --a1-nav-green: #284832;
  --a1-nav-focus: #854235;
  --a1-nav-border: #65736b;
  --a1-nav-muted: #485745;
  --a1-nav-sage: #e1e9df;
  color: var(--a1-nav-ink);
  background: var(--a1-nav-canvas);
  border-bottom: 1px solid var(--a1-nav-border);
  font: 500 1rem / 1.55 Manrope, system-ui, sans-serif;
}

.a1-topic-header [hidden] { display: none; }

.a1-topic-bar,
.a1-topic-menu {
  box-sizing: border-box;
  width: min(100%, 76rem);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

.a1-topic-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  padding-block: .75rem;
}

.a1-topic-header .a1-topic-brand {
  display: inline-flex;
  align-items: center;
  gap: .25em;
  flex: 1 0 100%;
  min-height: 44px;
  color: var(--a1-nav-green);
  font: 650 clamp(1.25rem, 2.5vw, 1.5rem) / 1.2 Fraunces, Georgia, serif;
  text-decoration: none;
}

.a1-topic-brand em { color: var(--a1-nav-focus); }
.a1-topic-language { min-width: 0; max-width: 100%; }

.a1-topic-header .a1-topic-back,
.a1-topic-header .a1-topic-toggle,
.a1-topic-header .a1-topic-language select,
.a1-topic-header .a1-topic-menu a {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  margin: 0;
  padding: .5rem .75rem;
  border: 1px solid var(--a1-nav-border);
  border-radius: .625rem;
  background: var(--a1-nav-paper);
  color: var(--a1-nav-green);
  font: 650 .875rem / 1.4 Manrope, system-ui, sans-serif;
  overflow-wrap: break-word;
  text-decoration: none;
  white-space: normal;
}

.a1-topic-header .a1-topic-back { text-decoration: underline; text-underline-offset: .18em; }

/* Pulsante del selettore: etichetta e argomento corrente, freccia di stato. */
.a1-topic-header .a1-topic-toggle {
  flex: 1 1 7.5rem;
  justify-content: space-between;
  gap: .75rem;
  min-width: 0;
  padding-block: .25rem;
  text-align: start;
  cursor: pointer;
}

.a1-topic-header .a1-topic-toggle-text { display: grid; min-width: 0; }
.a1-topic-toggle-label,
.a1-topic-toggle-current { display: block; }
.a1-topic-toggle-label { overflow: hidden; color: var(--a1-nav-muted); font-size: .75rem; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
/* Argomento corrente su una sola riga: il titolo completo resta nel nome accessibile, nel pannello e nel titolo della pagina. */
.a1-topic-toggle-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }

.a1-topic-header .a1-topic-toggle:not([hidden])::after {
  content: '';
  flex: 0 0 .45em;
  width: .45em;
  height: .45em;
  border: solid currentColor;
  border-width: 0 .12em .12em 0;
  transform: translateY(-.1em) rotate(45deg);
}

.a1-topic-header .a1-topic-toggle[aria-expanded="true"]::after {
  transform: translateY(.1em) rotate(225deg);
}

/* Pannello aperto: nel flusso della pagina, sotto la barra; solo l'elenco scorre, con limite di altezza. */
.a1-topic-menu { padding-block-end: .75rem; }

.a1-topic-header .a1-topic-panel {
  box-sizing: border-box;
  display: grid;
  gap: .5rem;
  padding: .75rem;
  border: 1px solid var(--a1-nav-border);
  border-radius: .875rem;
  background: var(--a1-nav-paper);
}

.a1-topic-header .a1-topic-search { display: grid; gap: .25rem; min-width: 0; }

.a1-topic-header .a1-topic-search label {
  color: var(--a1-nav-green);
  font: 650 .875rem / 1.4 Manrope, system-ui, sans-serif;
}

.a1-topic-header .a1-topic-search input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: .5rem .75rem;
  border: 1px solid var(--a1-nav-border);
  border-radius: .625rem;
  background: #fff;
  color: var(--a1-nav-ink);
  font: 500 1rem / 1.4 Manrope, system-ui, sans-serif;
}

.a1-topic-header .a1-topic-status {
  margin: 0;
  color: var(--a1-nav-muted);
  font: 600 .875rem / 1.45 Manrope, system-ui, sans-serif;
}

.a1-topic-header .a1-topic-status:empty {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.a1-topic-header .a1-topic-panel { position: relative; }

.a1-topic-header .a1-topic-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  align-items: start;
  gap: .75rem 1rem;
  max-height: min(60vh, 30rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .25rem;
  margin: -.25rem;
}

.a1-topic-header .a1-topic-group { min-width: 0; margin: 0; padding: 0; }

.a1-topic-header .a1-topic-group-title {
  margin: 0 0 .375rem;
  padding: 0;
  color: var(--a1-nav-muted);
  font: 700 .8125rem / 1.3 Manrope, system-ui, sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.a1-topic-header .a1-topic-menu ul {
  display: grid;
  gap: .375rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.a1-topic-header .a1-topic-menu li { min-width: 0; margin: 0; padding: 0; }
.a1-topic-header .a1-topic-menu li::before { content: none; }

.a1-topic-header .a1-topic-menu a {
  display: flex;
  flex-wrap: wrap;
  gap: 0 .5rem;
  width: 100%;
  font-weight: 600;
}

.a1-topic-header .a1-topic-code { font-weight: 750; }
.a1-topic-header .a1-topic-name { flex: 1 1 10rem; min-width: 0; }

.a1-topic-header .a1-topic-here {
  padding: 0 .4rem;
  border: 1px solid currentColor;
  border-radius: .375rem;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.5;
}

.a1-topic-header .a1-topic-menu a[aria-current="page"] {
  background: var(--a1-nav-green);
  border-color: var(--a1-nav-green);
  color: var(--a1-nav-paper);
  text-decoration: underline;
  text-underline-offset: .18em;
}

.a1-topic-header .a1-topic-back:hover,
.a1-topic-header .a1-topic-toggle:hover,
.a1-topic-header .a1-topic-menu a:not([aria-current="page"]):hover { background: var(--a1-nav-sage); }

.a1-topic-header :is(a, button, select, input):focus-visible {
  outline: 3px solid var(--a1-nav-focus);
  outline-offset: 3px;
}

.a1-topic-header .a1-topic-search input:focus-visible { outline-offset: 1px; }
.a1-topic-header .a1-topic-toggle[hidden] { display: none; }

#main-content[data-stage="home"] .intro h1,
#activity[data-stage="home"] .intro h1,
#a103-main .vb-hero .intro h1,
#main:has(#stage):not(:has(#exercise-heading, #summary-heading)) #module-title {
  font: 650 2rem / 1.15 Fraunces, Georgia, serif;
  overflow-wrap: anywhere;
}

@media (min-width: 820px) {
  #main-content[data-stage="home"] .intro h1,
  #activity[data-stage="home"] .intro h1,
  #a103-main .vb-hero .intro h1,
  #main:has(#stage):not(:has(#exercise-heading, #summary-heading)) #module-title { font-size: 2.5rem; }
}

@media (min-width: 960px) {
  .a1-topic-bar { gap: .75rem 1rem; }
  .a1-topic-header .a1-topic-brand { flex: 0 0 auto; margin-inline-end: auto; }
  .a1-topic-header .a1-topic-toggle { flex: 1 1 12rem; max-width: 26rem; }

  #main-content[data-stage="home"] .intro h1,
  #activity[data-stage="home"] .intro h1,
  #a103-main .vb-hero .intro h1,
  #main:has(#stage):not(:has(#exercise-heading, #summary-heading)) #module-title { font-size: 3rem; }
}

@media (forced-colors: active) {
  .a1-topic-header .a1-topic-menu a[aria-current="page"] { border-width: 3px; }
}
