/* La barra rifatta (06/11/2026, app/barra.php). Scura in tutti e due i temi, come
   la vecchia: e' un'isola, quindi colori suoi e non i gettoni della pagina. La linea
   gialla segna dove sei: e' quella del marciapiede. */
.bb, .bb-tab, .bb-foglio {
  --bb-fondo: #071B33;
  --bb-fondo2: #0D2747;
  --bb-riga: rgba(255, 255, 255, .13);
  --bb-testo: #E8EDF4;
  --bb-spento: #B4C2D4;
  --bb-giallo: #FFD23F;
  --bb-su-giallo: #071B33;
  --bb-h: 64px;
  --bb-tab-h: 60px;
}

.bb {
  position: sticky; top: 0; z-index: 1030;
  background: var(--bb-fondo);
  border-bottom: 1px solid var(--bb-riga);
  color: var(--bb-testo);
}
.bb-riga { display: flex; align-items: center; gap: 10px; height: var(--bb-h); }
.bb .bb-marchio { flex: none; margin-right: 10px; color: var(--bb-testo); text-decoration: none; }
/* Il foglio chiaro scurisce il nome fuori dalla barra vecchia: qui e' sempre su blu notte. */
.bb .rm-brand-1 { color: #fff; }
.bb .rm-brand-2 { color: #3D95FF; }

/* Le voci: la linea gialla sta sul bordo della barra. */
.bb-voci { display: flex; align-items: stretch; align-self: stretch; gap: 2px; }
.bb-voci > .bb-voce, .bb-voci > .bb-menu > summary {
  position: relative; display: flex; align-items: center; gap: 3px; height: 100%; padding: 0 10px;
  font: 600 .9rem/1 Inter, system-ui, sans-serif; color: var(--bb-spento); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: color 160ms ease;
}
.bb-voci > .bb-voce::after, .bb-voci > .bb-menu > summary::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; background: var(--bb-giallo);
  transform: scaleX(0); transform-origin: left; transition: transform 200ms cubic-bezier(.23, 1, .32, 1);
}
.bb-voci > .bb-voce:hover, .bb-voci > .bb-menu > summary:hover { color: #fff; }
.bb-voci > .bb-voce.is-active, .bb-voci > .bb-menu:has(.is-active) > summary { color: #fff; }
.bb-voci > .bb-voce.is-active::after, .bb-voci > .bb-menu:has(.is-active) > summary::after { transform: scaleX(1); }
.bb-voci > .bb-gioca > summary, .bb-voci > .bb-gioca > summary:hover { color: var(--bb-giallo); }

/* Le tendine */
.bb-menu { position: relative; display: flex; }
.bb-menu > summary { list-style: none; }
.bb-menu > summary::-webkit-details-marker { display: none; }
.bb-menu > summary .bb-ico { width: 15px; height: 15px; transition: transform 160ms ease; }
.bb-menu[open] > summary .bb-ico { transform: rotate(180deg); }
.bb-tendina {
  position: absolute; top: calc(100% + 1px); left: 0; z-index: 2; display: grid; min-width: 190px; padding: 6px;
  background: var(--bb-fondo2); border: 1px solid var(--bb-riga); border-top: 3px solid var(--bb-giallo); border-radius: 0 0 10px 10px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4);
}
.bb-tendina--dx { left: auto; right: 0; }
.bb-tendina a {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 6px;
  font: 600 .92rem/1.2 Inter, system-ui, sans-serif; color: var(--bb-testo); text-decoration: none;
}
.bb-tendina a:hover { background: rgba(255, 255, 255, .08); }
.bb-tendina a.is-active { color: var(--bb-giallo); }

/* La ricerca */
.bb-cerca {
  position: relative; flex: 1 1 150px; min-width: 120px; max-width: 280px; margin-left: auto; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--bb-riga); border-radius: 8px; color: var(--bb-spento);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.bb-cerca .bb-ico { flex: none; width: 18px; height: 18px; }
.bb-cerca:focus-within { border-color: var(--bb-giallo); background: rgba(255, 255, 255, .11); }
.bb-cerca input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: #fff; font: 500 .9rem/1 Inter, system-ui, sans-serif; }
.bb-cerca input::placeholder { color: var(--bb-spento); opacity: 1; }

/* Tasti tondi, account */
.bb .bb-tondo {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; margin: 0;
  background: transparent; border: 1px solid var(--bb-riga); border-radius: 8px; color: var(--bb-testo); cursor: pointer;
}
.bb .bb-tondo:hover { background: rgba(255, 255, 255, .08); }
.bb .rm-tema { order: 0; margin: 0; }
.bb .bb-cerca-apri { display: none; }
.bb-io { flex: none; align-self: stretch; }
.bb-io > summary { display: flex; align-items: center; gap: 7px; height: 100%; padding: 0 4px; color: var(--bb-testo); font: 600 .88rem/1 Inter, system-ui, sans-serif; cursor: pointer; }
.bb-iniziale { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--bb-giallo); color: var(--bb-su-giallo); font-weight: 800; }
.bb-nome { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.bb-accedi, .bb-registrati { flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0 12px; border-radius: 8px; font: 600 .88rem/1 Inter, system-ui, sans-serif; text-decoration: none; white-space: nowrap; }
.bb-accedi { color: var(--bb-testo); }
.bb-accedi:hover { background: rgba(255, 255, 255, .08); }
.bb-registrati { background: var(--bb-giallo); color: var(--bb-su-giallo); }

/* Fuoco da tastiera ben visibile sul blu notte, anche sulle voci alte tutta la barra */
.bb a:focus-visible, .bb summary:focus-visible, .bb button:focus-visible, .bb-tab a:focus-visible, .bb-tab button:focus-visible, .bb-foglio a:focus-visible {
  outline: 2px solid var(--bb-giallo); outline-offset: -2px; border-radius: 6px;
}
.bb-cerca input:focus-visible { outline: 0; }

/* La barra in basso e il foglio esistono solo su telefono e tavoletta */
.bb-tab, .bb-foglio { display: none; }

/* L'altezza della barra vecchia, che la pagina dei pronostici dava per scontata */
body:has(.bb) .tb-schede { top: 64px; }

@media (max-width: 1099.98px) {
  /* In alto scorre via: la navigazione sta gia' nella barra in basso, e si guadagna
     spazio. Fissa, copriva la barra interna della scheda treno (.st2-nav, top 0). */
  .bb { position: relative; }
  body:has(.bb) .tb-schede { top: 0; }
  .bb-voci, .bb-io, .bb-registrati { display: none; }
  .bb-riga { gap: 8px; }
  .bb .bb-marchio { margin-right: auto; padding: 8px 0; }
  .bb .bb-cerca-apri { display: inline-flex; }
  .bb .bb-tondo { width: 44px; height: 44px; }
  .bb-accedi { height: 44px; }
  /* La ricerca scende sotto la barra quando serve */
  .bb-cerca {
    display: none; position: absolute; top: 100%; left: 0; right: 0; max-width: none; height: 56px; margin: 0; padding: 0 16px;
    border: 0; border-bottom: 1px solid var(--bb-riga); border-radius: 0;
  }
  .bb-cerca, .bb-cerca:focus-within { background: var(--bb-fondo2); }
  .bb.cerca-su .bb-cerca { display: flex; }
  /* 16 px: sotto, iOS ingrandisce la pagina al tocco */
  .bb-cerca input { font-size: 16px; }

  .bb-tab {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--bb-tab-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bb-fondo); border-top: 1px solid var(--bb-riga);
  }
  .bb-tab-v {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; padding: 0; margin: 0;
    background: transparent; border: 0; color: var(--bb-spento); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform 140ms ease-out;
  }
  .bb-tab-v:active { transform: scale(.95); }
  .bb-tab-t { font: 600 11px/1 Inter, system-ui, sans-serif; }
  .bb-tab-v.is-active { color: #fff; }
  .bb-tab-v.is-active::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 3px; background: var(--bb-giallo); }
  .bb-tab-v[aria-expanded="true"] { color: var(--bb-giallo); }

  /* Gioca: il tasto che sporge */
  .bb-tab-gioca, .bb-tab-gioca.is-active { color: var(--bb-giallo); }
  .bb-tab-gioca.is-active::before { content: none; }
  .bb-tab-gioca .bb-tab-ico {
    display: grid; place-items: center; width: 52px; height: 52px; margin-top: -24px; border-radius: 50%;
    background: var(--bb-giallo); color: var(--bb-su-giallo); box-shadow: 0 0 0 4px var(--bb-fondo);
  }
  .bb-tab-gioca .bb-ico { width: 27px; height: 27px; }

  /* Il foglio del menu */
  .bb-foglio.is-open { position: fixed; inset: 0; z-index: 1035; display: block; }
  .bb-velo { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; background: rgba(3, 12, 24, .62); animation: bb-velo 200ms ease-out; }
  .bb-foglio-in {
    position: absolute; left: 0; right: 0; bottom: calc(var(--bb-tab-h) + env(safe-area-inset-bottom, 0px)); max-height: calc(100dvh - 130px); overflow-y: auto; overscroll-behavior: contain;
    display: grid; gap: 14px; padding: 16px 16px 18px; background: var(--bb-fondo2); border-top: 3px solid var(--bb-giallo); border-radius: 14px 14px 0 0; color: var(--bb-testo);
    animation: bb-sale 260ms cubic-bezier(.23, 1, .32, 1);
  }
  .bb-gruppo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 8px; }
  .bb-gruppo-t { grid-column: 1 / -1; margin: 0 0 2px; font: 500 11px/1.3 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--bb-spento); }
  .bb-foglio a { display: flex; align-items: center; min-height: 46px; padding: 0 12px; border-radius: 8px; background: rgba(255, 255, 255, .06); font: 600 .95rem/1.2 Inter, system-ui, sans-serif; color: var(--bb-testo); text-decoration: none; }
  .bb-foglio a.is-active { color: var(--bb-giallo); box-shadow: inset 0 0 0 1px var(--bb-giallo); }
  body:has(.rm-prof) .bb-foglio-in { bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  html:has(.bb-foglio.is-open) { overflow: hidden; }

  /* Tutto cio' che stava attaccato al fondo sale sopra la barra */
  body:has(.bb-tab) { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  body:has(.bb-tab) .rm-prof, body:has(.bb-tab) .rm-cookie, body:has(.bb-tab) .bl-installa { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}

/* Da ospite ci sono due tasti in piu', e il contenitore del sito resta largo 1096 px
   anche sugli schermi grandi: senza stringere, la ricerca tagliava la scritta. */
@media (min-width: 1100px) {
  .bb-riga { gap: 6px; }
  .bb .bb-marchio { margin-right: 2px; }
  .bb-voci > .bb-voce, .bb-voci > .bb-menu > summary { padding: 0 7px; font-size: .86rem; }
  .bb-voci > .bb-voce::after, .bb-voci > .bb-menu > summary::after { left: 7px; right: 7px; }
  .bb-accedi, .bb-registrati { padding: 0 9px; }
}

@media (max-width: 359.98px) {
  .bb-accedi { display: none; }
}

@keyframes bb-sale { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bb-velo { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .bb *, .bb-tab, .bb-tab *, .bb-foglio * { transition: none; animation: none; }
}
