/* Scolibro webapp — kit-local styles */
* { box-sizing: border-box; }

/* Badge di notifica sull'icona della bottom-nav (es. messaggi non letti) */
.nav-icon-wrap { position: relative; display: inline-flex; }
.nav-badge {
  position: absolute; top: -4px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: #D4537E; color: #fff;
  font-size: 10px; font-weight: 600; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

.app {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-background-primary);
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  /* clear iOS status bar (≈ 62px) */
  padding-top: 60px;
}

.app-scroll {
  flex: 1; overflow-y: auto;
  padding: 0 16px 100px;
  scroll-behavior: smooth;
}
.app-scroll::-webkit-scrollbar { display: none; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px;
  padding: 0 16px;
  margin-top: 6px;
  background: var(--color-background-primary);
  flex-shrink: 0;
}
.app-header .brand,
.app-header .screen-title {
  font-size: 17px; font-weight: 600; letter-spacing: -0.005em; line-height: 1;
}
.app-header .brand {
  color: #0F6E56; letter-spacing: -0.015em;
  display: inline-flex; align-items: center; gap: 6px;
}
.app-header .brand .brand-mark { display: inline-flex; }
.app-header .brand .brand-word { font-size: 15px; font-weight: 600; }
.app-header .screen-title { color: var(--color-text-primary); margin: 0; padding: 0; }
.app-header .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #E1F5EE; color: #085041;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.app-header .icon-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--color-text-secondary);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
}
.app-header .icon-btn:hover { background: var(--color-background-secondary); }

.section-title {
  font-size: 15px; font-weight:600; margin: 18px 0 10px;
}
.eyebrow-sm {
  font-size: 10px; font-weight:600; letter-spacing: 0.1em;
  color: var(--color-text-tertiary); text-transform: uppercase;
  margin: 16px 0 6px;
}

/* Buttons */
.btn {
  border-radius: 8px; padding: 10px 16px; font-size: 13px; font-weight:600;
  cursor: pointer; border: 0.5px solid transparent;
  font-family: var(--font-sans);
  transition: transform 120ms var(--easing-out), background 120ms var(--easing-out), border-color 120ms var(--easing-out);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #0F6E56; color: #E1F5EE; border-color: #0F6E56; }
.btn-primary:hover { background: #0A5544; border-color: #0A5544; }
.btn-secondary { background: var(--color-background-secondary); color: var(--color-text-primary); border-color: var(--color-border-secondary); }
.btn-secondary:hover { background: var(--color-background-tertiary); }
.btn-ghost { background: transparent; color: #0F6E56; border-color: #1D9E75; }
.btn-ghost:hover { background: #E1F5EE; }
.btn-danger { background: var(--color-background-danger); color: var(--color-text-danger); border-color: var(--color-border-danger); }
.btn-icon { background: var(--color-background-secondary); border: 0.5px solid var(--color-border-secondary); border-radius: 8px; padding: 8px 10px; color: var(--color-text-secondary); }
.btn-sm { padding: 6px 12px; font-size: 11px; border-radius: 6px; }
.btn-block { width: 100%; }

/* Pills */
.pill { font-size: 11px; font-weight:600; padding: 3px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; line-height: 1.4; white-space: nowrap; }
.p-sell  { background: #E1F5EE; color: #085041; }
.p-swap  { background: #E6F1FB; color: #0C447C; }
.p-gift  { background: #FBEAF0; color: #72243E; }
.p-new   { background: #EAF3DE; color: #27500A; }
.p-good  { background: #FAEEDA; color: #633806; }
.p-used  { background: #F1EFE8; color: #444441; }
.p-miur  { background: #E1F5EE; color: #085041; border: 0.5px solid #5DCAA5; }

/* Chips */
.chip { border: 0.5px solid var(--color-border-secondary); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--color-text-secondary); cursor: pointer; background: #fff; transition: all 120ms var(--easing-out); white-space: nowrap; }
.chip:hover { background: var(--color-background-secondary); }
.chip.on { background: #0F6E56; color: #E1F5EE; border-color: #0F6E56; }

/* Input */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--color-text-secondary); }
.inp { border: 0.5px solid var(--color-border-secondary); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--color-text-primary); background: #fff; width: 100%; font-family: var(--font-sans); transition: all 120ms var(--easing-out); }
.inp:focus { border-color: #0F6E56; outline: none; box-shadow: 0 0 0 2px #E1F5EE; }
.inp.error { border-color: var(--color-border-danger); }
.inp-search-wrap { position: relative; }
.inp-search-wrap > i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--color-text-tertiary); }
.inp-search-wrap > .inp { padding-left: 32px; }

/* Book card */
.card-book { background: #fff; border: 0.5px solid var(--color-border-tertiary); border-radius: 12px; padding: 12px; display: flex; gap: 10px; cursor: pointer; transition: border-color 120ms var(--easing-out); }
.card-book:hover { border-color: var(--color-border-secondary); }
.card-book .thumb { width: 44px; height: 56px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #E1F5EE; }
.card-book .thumb.blue { background: #E6F1FB; }
.card-book .thumb.pink { background: #FBEAF0; }
.card-book .thumb.amber { background: #FAEEDA; }
.card-book .thumb i { font-size: 20px; color: #0F6E56; }
.card-book .thumb.blue i { color: #185FA5; }
.card-book .thumb.pink i { color: #993556; }
.card-book .thumb.amber i { color: #854F0B; }
.card-book .body { flex: 1; min-width: 0; }
.card-book .title { font-size: 13px; font-weight:600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-book .author { font-size: 11px; color: var(--color-text-secondary); margin-top: 1px; }
.card-book .footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 6px; }
.card-book .price { font-size: 13px; font-weight: 600; color: #0F6E56; }
.card-book .price.gift { color: #993556; }

/* User card */
.card-user { background: #fff; border: 0.5px solid var(--color-border-tertiary); border-radius: 12px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.card-user .av { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.card-user .av.teal { background: #E1F5EE; color: #085041; }
.card-user .av.blue { background: #E6F1FB; color: #0C447C; }
.card-user .av.pink { background: #FBEAF0; color: #993556; }
.card-user .av.amber { background: #FAEEDA; color: #854F0B; }
.card-user .name { font-size: 13px; font-weight:600; }
.card-user .meta { font-size: 11px; color: var(--color-text-secondary); }
.card-user .stars { color: #BA7517; font-size: 11px; }

/* Stat card */
.card-stat { background: var(--color-background-secondary); border-radius: 8px; padding: 12px 14px; }
.card-stat .num { font-size: 22px; font-weight: 600; color: #0F6E56; line-height: 1; }
.card-stat .lbl { font-size: 11px; color: var(--color-text-secondary); margin-top: 4px; }

/* Notification */
.notif { border: 0.5px solid var(--color-border-tertiary); border-radius: 10px; padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; background: #fff; }
.notif .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border-secondary); flex-shrink: 0; margin-top: 5px; }
.notif .text { font-size: 12px; line-height: 1.4; }
.notif .time { font-size: 11px; color: var(--color-text-tertiary); margin-top: 2px; }
.notif.unread { background: #E1F5EE; border-color: #5DCAA5; }
.notif.unread .dot { background: #0F6E56; }

/* Stepper */
.stepper { display: flex; gap: 0; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.step .line { position: absolute; top: 14px; left: 50%; width: 100%; height: 0.5px; background: var(--color-border-tertiary); z-index: 0; }
.step .circle { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight:600; z-index: 1; background: var(--color-background-secondary); color: var(--color-text-tertiary); border: 0.5px solid var(--color-border-secondary); }
.step .lbl { font-size: 10px; color: var(--color-text-secondary); margin-top: 6px; text-align: center; }
.step.s-done .circle { background: #0F6E56; color: #fff; border-color: #0F6E56; }
.step.s-done .line { background: #0F6E56; }
.step.s-active .circle { background: #E1F5EE; color: #0F6E56; border: 1.5px solid #0F6E56; }

/* Bottom nav */
.bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  padding: 8px 0 12px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-top: 0.5px solid var(--color-border-tertiary);
  z-index: 50;
}
.bottom-nav .item { display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; padding: 4px 10px; }
.bottom-nav .item i { font-size: 22px; color: var(--color-text-tertiary); }
.bottom-nav .item .lbl { font-size: 10px; color: var(--color-text-tertiary); }
.bottom-nav .item.active i, .bottom-nav .item.active .lbl { color: #0F6E56; }
.bottom-nav .item.add i { font-size: 28px; color: #0F6E56; }
.bottom-nav .item.add .lbl { color: #0F6E56; font-weight:600; }

/* Detail screen */
.detail-cover {
  width: 100%; aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #E1F5EE 0%, #C5EBDA 100%);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  border: 0.5px solid var(--color-border-tertiary);
  margin-top: 12px;
}
.detail-cover i { font-size: 80px; color: #0F6E56; opacity: 0.7; }
.detail-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.detail-title { font-size: 20px; font-weight: 600; margin-top: 8px; letter-spacing: -0.01em; }
.detail-author { font-size: 13px; color: var(--color-text-secondary); margin-top: 2px; }
.detail-price { font-size: 26px; font-weight: 600; color: #0F6E56; margin-top: 12px; }
.detail-desc { font-size: 13px; line-height: 1.5; color: var(--color-text-secondary); margin-top: 12px; }
.detail-actions { display: flex; gap: 8px; margin-top: 16px; }

/* CTA bar (fixed at bottom of detail) */
.cta-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 16px 24px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  border-top: 0.5px solid var(--color-border-tertiary);
  display: flex; gap: 8px; align-items: center;
  z-index: 50;
}

/* Back row */
.back-row { display: flex; align-items: center; gap: 8px; padding: 14px 16px 4px; }
.back-row .back { background: none; border: none; color: var(--color-text-secondary); font-size: 14px; padding: 6px; cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.back-row .back:hover { background: var(--color-background-secondary); }
.back-row .title { font-size: 15px; font-weight:600; }

/* Misc */
.divider { border: none; border-top: 0.5px solid var(--color-border-tertiary); margin: 16px 0; }
.row-gap-6 { display: flex; gap: 6px; flex-wrap: wrap; }
.row-gap-8 { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Bacheca (griglia/chip/modal/barra contatto, stile prototipo design-system) ── */
.bh-metastrip { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.bh-pill { font-size: 11px; color: #6B7280; border: 0.5px solid #E8E8E4; background: #fff; border-radius: 999px; padding: 5px 11px; font-family: 'DM Mono', monospace; }
.bh-pill b { color: #1A1A18; font-weight: 600; }

.bh-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.bh-chip {
    font-family: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
    padding: 8px 14px; border-radius: 999px; border: 0.5px solid #D9D9D3;
    background: #fff; color: #1A1A18;
}
.bh-chip.active { background: #0F6E56; border-color: #0F6E56; color: #fff; }

.bh-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.bh-book { position: relative; border: 0.5px solid #E8E8E4; background: #fff; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; text-decoration: none; color: inherit; cursor: pointer; }
.bh-cover { position: relative; aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; border: 0.5px solid #E8E8E4; background: #E1F5EE; }
.bh-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bh-ribbon { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; }
.bh-ribbon.vendo   { background: #0F6E56; }
.bh-ribbon.scambio { background: #185FA5; }
.bh-ribbon.regalo  { background: #993556; }
.bh-photobadge {
    position: absolute; top: 6px; right: 6px; display: flex; align-items: center; gap: 4px;
    background: rgba(26,26,24,.82); color: #fff; font-size: 10px; font-weight: 600;
    padding: 3px 7px; border-radius: 999px;
}
.bh-nophoto {
    position: absolute; top: 6px; right: 6px;
    background: rgba(255,255,255,.92); border: 0.5px solid #D9D9D3; color: #6B7280;
    font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 999px;
}
.bh-remove-btn {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    background: rgba(26,26,24,.72); color: #fff; border: none; border-radius: 50%;
    font-size: 13px; cursor: pointer;
}
.bh-edit-btn {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.92); border: 0.5px solid #D9D9D3; color: #0F6E56;
    border-radius: 50%; font-size: 12px; text-decoration: none;
}
.bh-cat { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: #9CA3AF; margin: 8px 2px 2px; }
.bh-title {
    font-size: 12.5px; font-weight: 600; line-height: 1.25; margin: 0 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 32px;
}
.bh-cond { font-size: 11px; color: #6B7280; margin: 4px 2px 0; }
.bh-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bh-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; border: 0.5px solid; }
.bh-tag.vendo   { color: #0F6E56; border-color: #0F6E56; background: #E1F5EE; }
.bh-tag.scambio { color: #185FA5; border-color: #185FA5; background: #DBEAFE; }
.bh-tag.regalo  { color: #993556; border-color: #993556; background: #FCE7F0; }
.bh-tag.cerco   { color: #A32D2D; border-color: #EFC9C9; background: #FCEBEB; }
.bh-tag.cercato { color: #6B7280; border-color: #D9D9D3; background: #F5F5F3; }
.bh-price { font-size: 12px; font-weight: 600; color: #1A1A18; }
.bh-status { font-size: 10px; color: #9CA3AF; }
.bh-status.match { color: #0A5544; font-weight: 600; }

.bh-fbwrap { margin: 4px 0 20px; }
.bh-fbwrap h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9CA3AF; margin: 0 0 10px; }
.bh-fbcard { border: 0.5px solid #D9D9D3; border-radius: 10px; overflow: hidden; background: #fff; }
.bh-fbcard img { width: 100%; display: block; aspect-ratio: 1.91/1; object-fit: cover; background: #E1F5EE; }
.bh-fbmeta { padding: 10px 12px; border-top: 0.5px solid #E8E8E4; }
.bh-fbmeta .url { font-size: 10px; letter-spacing: .04em; color: #9CA3AF; text-transform: uppercase; }
.bh-fbmeta .h { font-weight: 700; font-size: 13px; margin: 2px 0; }
.bh-fbmeta .d { font-size: 11px; color: #6B7280; }

.bh-contactbar {
    position: sticky; bottom: 0; z-index: 20;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
    border-top: 0.5px solid #E8E8E4; padding: 12px 16px; margin: 0 -16px;
}
.bh-reveal {
    margin-bottom: 10px; padding: 10px 12px; border: 0.5px solid #A9D6C8;
    background: #F0FAF7; border-radius: 8px; font-size: 12px; color: #0A5040; line-height: 1.4;
}
.bh-reveal a { color: #0A5040; font-weight: 600; }
.bh-reveal.unavailable { color: #9CA3AF; background: #F5F5F3; border-color: #E8E8E4; }
.bh-contactbar-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px; border-radius: 10px; border: none; background: #0F6E56; color: #fff;
    font-family: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.bh-contactbar-btn:disabled { opacity: .6; }

.bh-modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; background: rgba(20,20,16,.45); }
.bh-modal[hidden] { display: none; }
.bh-sheet {
    background: #FBFAF7; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto;
    border-radius: 16px 16px 0 0; border: 0.5px solid #E8E8E4; position: relative;
}
.bh-sheet-close {
    position: absolute; top: 10px; right: 12px; z-index: 2;
    width: 32px; height: 32px; border-radius: 50%; border: 0.5px solid #D9D9D3;
    background: #fff; font-size: 18px; line-height: 1; cursor: pointer; color: #1A1A18;
}
.bh-mgallery { display: flex; gap: 2px; overflow-x: auto; scroll-snap-type: x mandatory; background: #1A1A18; }
.bh-mgallery img { flex: 0 0 100%; scroll-snap-align: center; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.bh-mgallery.none { background: #F5F5F3; padding: 30px 16px; display: flex; align-items: center; justify-content: center; color: #9CA3AF; font-size: 13px; text-align: center; }
.bh-mbody { padding: 16px; }
.bh-mref { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 11px; color: #6B7280; }
.bh-mref img { width: 32px; height: 44px; object-fit: cover; border-radius: 4px; border: 0.5px solid #E8E8E4; }
.bh-mcat { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #9CA3AF; }
.bh-mtitle { font-size: 17px; font-weight: 700; margin: 2px 0 10px; }
.bh-mline { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.bh-mnote { font-size: 12px; color: #6B7280; background: #fff; border: 0.5px solid #E8E8E4; border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }

/* ── Skeleton loading ─────────────────────────────────
   Preferito allo spinner (docs/design-system/README.md): bordi sottili,
   niente drop-shadow, pulse leggero con i token di durata del DS. */
.skeleton-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0;
}
.skeleton-block {
    background: var(--color-background-secondary);
    border: var(--border-thin) solid var(--color-border-tertiary);
    border-radius: var(--border-radius-md);
    animation: skeleton-pulse 1.1s var(--easing-standard) infinite;
}
.skeleton-avatar { width: 36px; height: 36px; border-radius: 999px; flex-shrink: 0; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-line { height: 10px; border-radius: var(--border-radius-sm); }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .55; }
}

/* Stato di caricamento per bottoni/link cliccati durante una transizione
   server-side (submit form, redirect di pagina): pulse di luminosità
   invece di uno spinner rotante, stesso principio di .skeleton-block. */
.is-loading {
    animation: is-loading-pulse 1.1s var(--easing-standard) infinite;
    pointer-events: none;
}

/* Stesso trattamento visivo per i bottoni disabilitati via JS durante una
   fetch() (preferiti, azioni inline) — spesso impostano solo l'attributo
   `disabled` senza applicare `.is-loading`, restando altrimenti invariati
   a schermo durante l'attesa. */
button:disabled {
    animation: is-loading-pulse 1.1s var(--easing-standard) infinite;
}

@keyframes is-loading-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

@media (prefers-reduced-motion: reduce) {
    .is-loading, button:disabled {
        animation: none;
        opacity: .6;
    }
}

/* ── Focus visible (A11y) ────────────────────────────── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-border-primary);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}
