/* ============================================================
   AlboUp — stile
   Mobile-first, tema chiaro/scuro via variabili CSS.
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --text: #1a2333;
  --text-muted: #5b6779;
  --border: #dde3ee;
  --primary: #0b4fd8;
  --primary-soft: #e8effd;
  --on-primary: #ffffff;
  --accent: #0b8a4d;
  --danger: #c62828;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .08);
  --radius: 14px;
  --wrap: 780px;
}

[data-theme="dark"] {
  --bg: #0e1420;
  --surface: #17202f;
  --surface-2: #1e2939;
  --text: #e8edf6;
  --text-muted: #94a1b5;
  --border: #2a3648;
  --primary: #6ea8ff;
  --primary-soft: #1c2c4a;
  --on-primary: #0b1424;
  --accent: #4ade80;
  --danger: #ff6b6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* nessuno scorrimento orizzontale di pagina */
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 16px;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.muted-note { font-size: .85rem; color: var(--text-muted); text-align: center; }

/* ---------- Header ---------- */

.site-header {
  background: linear-gradient(135deg, var(--primary), #0a3ba8);
  color: #fff;
  padding: 18px 0 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
}

[data-theme="dark"] .site-header {
  background: linear-gradient(135deg, #16294d, #0e1b38);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* riga 1: icona + nome a sinistra, toggle tema e link a destra */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-ico {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
}
.brand-ico svg { width: 100%; height: 100%; display: block; border-radius: 8px; }

.brand h1 { margin: 0; font-size: 1.25rem; letter-spacing: .2px; }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* riga 2: sottotitolo completo, a larghezza di pagina */
.header-sub {
  margin: 4px 0 0;
  font-size: .78rem;
  line-height: 1.35;
  opacity: .85;
}

.official-link {
  color: #fff;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px;
  transition: background .15s;
  white-space: nowrap;
}
.official-link:hover { background: rgba(255, 255, 255, .15); }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  color: inherit;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(125, 140, 170, .18); }

/* pulsante tema: cerchio diviso bianco / blu notte */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle svg circle { stroke: rgba(255, 255, 255, .9); }
.theme-toggle:hover svg { transform: rotate(180deg); }
.theme-toggle svg { transition: transform .35s ease; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;         /* le tab vanno a capo invece di sbordare a destra */
  gap: 6px;
  margin: 18px 0 4px;
}

.tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { color: var(--text); border-color: var(--primary); }
.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* schermi stretti: tab compatte per stare su una riga sopra la ricerca */
@media (max-width: 420px) {
  .tabs { margin-top: 14px; }
  .tab { padding: 6px 10px; font-size: .78rem; gap: 4px; }
}

/* ---------- Toolbar ---------- */

.toolbar { margin: 14px 0 6px; }

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px 4px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-ico { opacity: .6; }

.searchbox input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 9px 0;
}
.searchbox input::placeholder { color: var(--text-muted); }

.chips {
  display: flex;
  flex-wrap: wrap;          /* i filtri vanno a capo invece di sbordare */
  gap: 8px;
  margin-top: 12px;
  max-width: 100%;
}

.chip {
  padding: 7px 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--primary); }
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Status ---------- */

.statusline {
  margin: 10px 0 4px;
  font-size: .88rem;
  color: var(--text-muted);
}
.statusline.error { color: var(--danger); font-weight: 600; }
/* nessun messaggio = nessuno spazio sprecato tra le chip e la prima card */
.statusline:empty { margin: 0; min-height: 0; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */

.cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  text-align: left;
  padding: 0;
  width: 100%;
  font: inherit;
  color: inherit;
}
.card:hover { transform: translateY(-2px); border-color: var(--primary); }
.card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 0;
}

.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 3px 9px;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-date { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

.card-body { padding: 8px 16px 4px; }

.card-title {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 12px;
  font-size: .8rem;
  color: var(--text-muted);
}

.tag-num {
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 8px;
}

.attach { display: inline-flex; align-items: center; gap: 4px; }
.new-flag {
  color: var(--accent);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---------- Load more ---------- */

.loadmore-zone { text-align: center; padding: 4px 0 30px; position: relative; }

.btn-secondary {
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-secondary:hover { background: var(--primary); color: var(--on-primary); }
.btn-secondary:disabled { opacity: .55; cursor: wait; }

.to-top { position: fixed; right: 18px; bottom: 18px; z-index: 15; font-size: 1.3rem;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* ---------- Overlay dettaglio ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.overlay-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-bottom: 10px;
  z-index: 2;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 26px;
  margin-bottom: 30px;
}

.d-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 16px; }

.d-cat {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 10px;
}

.d-title { margin: 0 0 10px; font-size: 1.25rem; line-height: 1.4; }

.d-num { font-size: .9rem; color: var(--text-muted); font-weight: 600; }

.d-rows { display: flex; flex-direction: column; }

.d-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--border);
  font-size: .93rem;
}
.d-row dt { color: var(--text-muted); font-weight: 600; }
.d-row dd { margin: 0; overflow-wrap: anywhere; }

.d-actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; }

.d-att-title { margin: 22px 0 8px; font-size: 1rem; }

.d-att-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.d-att-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .92rem;
}

.att-name { min-width: 0; overflow-wrap: anywhere; }
.att-links { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.att-btn { padding: 7px 14px; font-size: .82rem; flex-shrink: 0; }

.att-signed {
  font-size: .8rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.att-signed:hover { color: var(--primary); }

.btn-primary {
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  color: var(--on-primary);
  background: var(--primary);
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.1); }

.d-note { margin-top: 16px; font-size: .82rem; color: var(--text-muted); }

/* ---------- Empty state ---------- */

.empty-box {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 42px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-ico { font-size: 2.6rem; }

.empty-box h3 { margin: 4px 0 0; font-size: 1.08rem; }

.empty-box p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: .92rem;
  max-width: 46ch;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 30px;
  font-size: .85rem;
  color: var(--text-muted);
  background: var(--surface);
}
.site-footer a { color: var(--primary); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 99;
  background: var(--text);
  color: var(--bg);
  font-size: .9rem;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) translateY(10px); opacity: 0; } }

/* ---------- Splash screen ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity .3s ease;
}

.splash-ico { width: 84px; height: 84px; }
.splash-ico svg {
  width: 100%; height: 100%; display: block;
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: splashpulse 1.4s ease-in-out infinite;
}

.splash-name {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--text);
}
.splash-name span { color: var(--primary); }

.splash-out { opacity: 0; pointer-events: none; }

@keyframes splashpulse {
  0%   { transform: scale(.94); opacity: .85; }
  50%  { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(.94); opacity: .85; }
}

/* ---------- Caricamento: icona animata + scheletro ---------- */

.loading-block {
  text-align: center;
  padding: 34px 0 10px;
  color: var(--text-muted);
}
.loading-block > p { margin: 10px 0 0; font-size: .9rem; }

.loading-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  animation: splashpulse 1.5s ease-in-out infinite;
}
.loading-icon svg { width: 100%; height: 100%; display: block; border-radius: 12px; }

.skeletons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 560px;
  margin: 22px auto 0;
}

.skel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skel-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.skel {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

.skel-badge { width: 120px; height: 18px; }
.skel-date  { width: 88px;  height: 14px; }
.skel-line  { width: 92%;   height: 14px; }
.skel-short { width: 55%; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */

/* schermi stretti: header compatto, sottotitolo sempre completo */
@media (max-width: 560px) {
  .site-header { padding: 10px 0 12px; }
  .brand-ico { width: 30px; height: 30px; }
  .brand h1 { font-size: 1.12rem; }
  .header-sub { font-size: .74rem; }
  .official-link { padding: 5px 9px; font-size: .74rem; }
  .theme-toggle svg { width: 20px; height: 20px; }
}

@media (min-width: 640px) {
  .brand h1 { font-size: 1.4rem; }
  .card-title { font-size: 1.05rem; }
  .detail-card { padding: 26px 28px 30px; }
  .d-title { font-size: 1.4rem; }
  .d-row { grid-template-columns: 200px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
