/* ============================================================================
   layout.css: guscio dell'app (navigazione, barra in alto, menu, pagina, griglie)
   e i layout senza guscio (auth, print). Il palco sta in stage.css, il foglio Crea
   in components.css.
   <900px: barra fissa in basso con 5 posti (Crea al centro); Altro sta nel menu avatar.
   ≥900px: barra laterale con etichette, Crea in cima, poi le 4 voci e il gruppo Altro.
   ============================================================================ */

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ── navigazione: barra in basso ─────────────────────────────────────────── */
.nav-logo, .nav-more, .nav-primary .nav-create-top { display: none; }
.nav-primary {
  position: fixed; z-index: 40; inset: auto 0 0 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding: 0 var(--s1) env(safe-area-inset-bottom);
  background: var(--amp); border-top: 1px solid var(--cable);
}
.nav-list { height: var(--bottomnav-h); display: flex; align-items: center; }
/* posti uguali: la voce attiva (più pesante) non sposta le altre */
.nav-list > li { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; }
.nav-i, .nav-create, .nav-m {
  min-width: var(--hit); min-height: var(--hit); width: 100%; padding: var(--s1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1);
  border: 0; border-radius: var(--r); background: transparent; color: var(--ink-soft); cursor: pointer;
  font-family: var(--fb); font-size: var(--fs-0); font-weight: 600; line-height: 1.2; text-decoration: none;
}
.nav-i svg, .nav-m svg { width: 22px; height: 22px; flex: none; }
.nav-l { white-space: nowrap; max-width: 100%; }
/* in basso le etichette sono nel taglio stretto del titolo: "Repertorio" sta in un quinto di 360px */
.nav-primary .nav-l { font-family: var(--fh); font-stretch: var(--fh-stretch); }
.nav-list .nav-i, .nav-list .nav-create { padding: var(--s1) 2px; }
@media (max-width: 369px) { .nav-list .nav-l { overflow: hidden; text-overflow: ellipsis; } }
.nav-i:hover, .nav-create:hover, .nav-m:hover { color: var(--ink); }
/* voce attiva: colore e peso, così il segno non è solo cromatico */
.nav-i.on, .nav-m.on, .nav-i.on:hover, .nav-m.on:hover { color: var(--cue); font-weight: 800; }
.nav-create { color: var(--ink); }
.nav-create-ico {
  display: grid; place-items: center; width: 40px; height: 24px; border-radius: var(--r);
  background: var(--cue); color: var(--cue-ink); transition: transform var(--dur-fast) var(--ease);
}
.nav-create-ico svg { width: 20px; height: 20px; }
.nav-create:active .nav-create-ico { transform: scale(.94); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }

/* ── navigazione: barra laterale ─────────────────────────────────────────── */
@media (min-width: 900px) {
  .app { flex-direction: row; }
  .side {
    position: sticky; top: 0; height: 100vh; width: var(--side-w); flex: none;
    display: flex; flex-direction: column; gap: var(--s5); padding: var(--s4) var(--s3);
    background: var(--amp); border-right: 1px solid var(--cable); overflow-y: auto;
  }
  .nav-logo {
    display: flex; align-items: center; gap: var(--s2); min-height: var(--hit); padding: 0 var(--s2);
    color: var(--cue); text-decoration: none;
  }
  .nav-brand { font-family: var(--fh); font-weight: var(--fh-weight); font-stretch: var(--fh-stretch); font-size: var(--fs-2); line-height: 1; color: var(--ink); }
  .nav-primary {
    position: static; height: auto; padding: 0; border: 0; background: transparent;
    display: flex; flex-direction: column; gap: var(--s3);
  }
  .nav-list { height: auto; flex-direction: column; align-items: stretch; }
  .nav-list > li { display: block; }
  .nav-list > .nav-slot-create { display: none; }
  .nav-more { display: block; }
  .nav-i, .nav-create, .nav-m, .nav-list .nav-i { flex-direction: row; justify-content: flex-start; gap: var(--s3); padding: 0 var(--s3); }
  .nav-primary .nav-l { font-family: var(--fb); font-stretch: normal; }
  .nav-i svg, .nav-m svg { width: 20px; height: 20px; }
  .nav-i:hover, .nav-m:hover { background: var(--amp-2); }
  /* --cue su --amp-2 non è misurato: la voce attiva resta su --amp anche al passaggio */
  .nav-i.on:hover, .nav-m.on:hover { background: transparent; }
  .nav-primary .nav-create-top { display: flex; background: var(--cue); color: var(--cue-ink); }
  .nav-create-top:hover { color: var(--cue-ink); }
  .nav-create-top .nav-create-ico { width: auto; height: auto; background: transparent; color: inherit; }
  .nav-h {
    font-family: var(--fb); font-stretch: normal; font-size: var(--fs-0); font-weight: 600;
    color: var(--ink-soft); padding: 0 var(--s3); margin-bottom: var(--s1);
  }
  .main { height: 100vh; overflow-y: auto; overflow-x: hidden; padding-bottom: 0; }
}

/* ── barra in alto: una riga sola anche a 375px ──────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4); min-height: calc(var(--hit) + var(--s4));
  background: color-mix(in srgb, var(--stage) 90%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--cable);
}
.wire { position: absolute; left: 0; right: 0; bottom: -13px; height: 26px; width: 100%; display: block; pointer-events: none; z-index: 31; color: var(--cue); }
.top-r { margin-left: auto; display: flex; align-items: center; gap: var(--s2); flex: none; }
@media (min-width: 900px) { .top { gap: var(--s3); padding: var(--s3) var(--s4); min-height: var(--top-h); } }

.top > .projsel, .top > .proj { min-width: 0; flex: 0 1 auto; }
.proj {
  display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s3) var(--s1) var(--s1);
  min-height: var(--hit); min-width: 0; border-radius: var(--r); border: 1px solid var(--cable); background: var(--amp); cursor: pointer;
}
.proj .stack { gap: 1px; align-items: flex-start; min-width: 0; }
.proj-badge {
  width: 32px; height: 32px; border-radius: var(--r); flex: none; display: grid; place-items: center;
  background: var(--cue); color: var(--cue-ink); font-family: var(--fh); font-weight: var(--fh-weight); font-size: var(--fs-0);
}
.proj-name { display: block; max-width: 100%; font-weight: 600; font-size: var(--fs-0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-sub { display: none; font-size: var(--fs-0); color: var(--ink-soft); }
.proj > svg { width: 16px; height: 16px; flex: none; color: var(--ink-soft); }
@media (min-width: 900px) { .proj-sub { display: block; } }

.search {
  flex: 1; min-width: 0; max-width: 440px; height: var(--hit); border-radius: var(--r);
  border: 1px solid var(--cable); background: var(--amp-2); display: flex; align-items: center;
  gap: var(--s2); padding: 0 var(--s3); color: var(--ink-soft); font-size: var(--fs-0); cursor: text;
}
.search svg { width: 16px; height: 16px; flex: none; color: var(--ink-soft); }
.search input { flex: 1; min-width: 0; height: 100%; background: transparent; border: none; color: var(--ink); font-size: var(--fs-0); outline: none; }
.search input::placeholder { color: var(--ink-soft); }
.search:focus-within { outline: 2px solid var(--cue); outline-offset: 2px; }
.search-wide { display: none; }
@media (min-width: 900px) { .search-wide { display: flex; } .topsearch { display: none; } }

.icobtn {
  width: var(--hit); height: var(--hit); border-radius: var(--r); border: 1px solid var(--cable); background: var(--amp);
  display: grid; place-items: center; color: var(--ink-soft); position: relative; cursor: pointer; flex: none;
}
.icobtn svg { width: 18px; height: 18px; }
.icobtn:hover { color: var(--ink); }
.notif-bell .badge {
  position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 var(--s1);
  border-radius: var(--r); background: var(--danger); color: var(--stage);
  font-size: var(--fs-0); line-height: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ── menu a tendina (<details> nativi): progetto, ricerca, avatar ─────────── */
/* sotto 900px i pannelli si agganciano alla barra (.top), non al pulsante: restano nello schermo */
.projsel, .topsearch, .avatar-menu { position: static; }
.projsel > summary, .topsearch > summary, .avatar-menu > summary { list-style: none; cursor: pointer; }
.projsel > summary::-webkit-details-marker, .topsearch > summary::-webkit-details-marker,
.avatar-menu > summary::-webkit-details-marker { display: none; }
.projsel[open] > summary { outline: 2px solid var(--cue); outline-offset: 2px; }
.topsearch > summary, .avatar-menu > summary { min-width: var(--hit); min-height: var(--hit); }
.projsel-panel, .menu-panel {
  position: absolute; top: calc(100% + var(--s1)); left: var(--s4); right: var(--s4); z-index: 60;
  padding: var(--s1); display: flex; flex-direction: column; gap: var(--s1);
  background: var(--amp); border: 1px solid var(--cable); border-radius: var(--r); box-shadow: var(--lift);
}
.menu-panel .search { max-width: none; flex: none; }
.avatar-menu .menu-panel {
  left: auto; width: min(320px, calc(100% - 2 * var(--s4))); overflow-y: auto;
  max-height: calc(100dvh - var(--hit) - var(--bottomnav-h) - var(--s6));
}
@media (min-width: 900px) {
  .projsel, .topsearch, .avatar-menu { position: relative; }
  .projsel-panel, .menu-panel { top: calc(100% + var(--s2)); }
  .projsel-panel { left: 0; right: auto; min-width: 240px; max-width: 320px; }
  .avatar-menu .menu-panel { right: 0; width: 280px; max-height: calc(100vh - var(--top-h) - var(--s4)); }
  .menu-more { display: none; }
}

.sdots { display: inline-flex; gap: var(--s1); align-items: center; }
.sdots:empty { display: none; }
.sdot { width: 8px; height: 8px; border-radius: var(--r); flex: none; display: inline-block; }
.sdot.due { background: var(--danger); }
.sdot.req { background: var(--warn); }
.sdot.fresh { background: var(--cue); }
.projsel-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s1) var(--s2);
  width: 100%; min-height: var(--hit); text-align: left; cursor: pointer; font: inherit;
  background: transparent; border: none; color: var(--ink); padding: var(--s2) var(--s3); border-radius: var(--r);
}
.projsel-item:hover { background: var(--amp-2); }
.projsel-item.on { background: var(--amp-2); font-weight: 700; }
.projsel-item .pi-name { font-weight: 600; font-size: var(--fs-0); }
.projsel-item .pi-tip { grid-column: 1 / -1; color: var(--ink-soft); font-size: var(--fs-0); }

/* avatar: l'unico tondo del sistema */
.avatar-menu > summary { display: grid; place-items: center; border-radius: 50%; }
.av {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--amp-2); border: 1px solid var(--cable); color: var(--ink); font-weight: 700; font-size: var(--fs-0);
}
.avatar-menu[open] .av { border-color: var(--cue); }
.menu-who { padding: var(--s2) var(--s3); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-h {
  font-family: var(--fb); font-stretch: normal; font-size: var(--fs-0); font-weight: 600;
  color: var(--ink-soft); padding: var(--s2) var(--s3) var(--s1);
}
.menu-more, .menu-sec { border-top: 1px solid var(--cable); padding-top: var(--s1); }
.menu-i {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--hit); padding: 0 var(--s3);
  border: 0; border-radius: var(--r); background: transparent; color: var(--ink); cursor: pointer;
  font: inherit; font-weight: 500; text-align: left; text-decoration: none;
}
.menu-i svg { width: 18px; height: 18px; flex: none; color: var(--ink-soft); }
.menu-i:hover { background: var(--amp-2); }
.menu-i.on, .menu-i.on svg { color: var(--cue); font-weight: 700; }
.menu-i.on:hover { background: transparent; }

/* ── pagina ──────────────────────────────────────────────────────────────── */
.page { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--s4) var(--s8); }
@media (min-width: 900px) { .page { padding: var(--s6) var(--s6) var(--s8); } }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-h .eyebrow { margin-bottom: var(--s2); }
.page-h h1 { font-size: var(--fs-3); }
@media (min-width: 900px) { .page-h h1 { font-size: var(--fs-4); } }
.page-h .sub { font-size: var(--fs-0); color: var(--ink-soft); margin-top: var(--s2); }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-0); color: var(--ink-soft); margin-bottom: var(--s3); flex-wrap: wrap; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb svg { width: 13px; height: 13px; color: var(--ink-soft); }

/* griglie di contenuto */
.cols { display: grid; gap: var(--s4); align-items: start; }
.cols-2 { grid-template-columns: 1fr; }
@media (min-width: 760px) { .cols-2 { grid-template-columns: 1fr 1fr; } }

/* ── avviso offline (pwa.js crea .pwa-net in <body>) ─────────────────────── */
.pwa-net {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; text-align: center; font-size: var(--fs-0);
  padding: var(--s2) var(--s3); opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.pwa-net-off {
  opacity: 1; visibility: visible; transform: none; transition-delay: 0s;
  background: var(--amp); color: var(--danger); border-top: 1px solid var(--danger);
}
@media (max-width: 899px) { .pwa-net-off { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); } }

/* ── layout auth ─────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); background: var(--stage); }
.authcard { width: 100%; max-width: 400px; }
.authlogo { display: flex; flex-direction: column; align-items: center; gap: var(--s4); margin-bottom: var(--s5); }
.authlogo .mark {
  width: 64px; height: 64px; border-radius: var(--r); display: grid; place-items: center;
  background: var(--amp); border: 1px solid var(--cable); color: var(--cue);
}
.authlogo .mark svg { width: 38px; height: 38px; }
.authlogo h1 { font-size: var(--fs-4); }
.authlogo h1 .o { color: var(--cue); }
.authwave { height: 30px; position: relative; margin: var(--s4) 0 var(--s1); color: var(--cue); }
.authwave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.form--auth { max-width: none; gap: var(--s3); }

/* ── layout print: anteprima a schermo, carta in stampa ──────────────────── */
.print-body { padding: 0 var(--s4); }
.printbar { max-width: 780px; margin: var(--s4) auto 0; display: flex; justify-content: flex-end; gap: var(--s2); }

@media print {
  .side, .nav-primary, .top, .wire, .create-sheet, .page-actions, .toolbar, .printbar { display: none !important; }
  .main { background: var(--paper); color: var(--paper-ink); overflow: visible; height: auto; }
  .app { display: block; }
  .print-body { padding: 0; }
}
