@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Barlow:wght@400;600;700;900&display=swap');

:root {
  --bg:      #f8f5f0;
  --bg2:     #ffffff;
  --bg3:     #f0ece4;
  --accent:  #3d6b35;
  --ocra:    #c8880a;
  --ocra2:   #a06808;
  --red:     #a82020;
  --text:    #2c2416;
  --text2:   #9a8a70;
  --border:  #e0d8c8;
  --mono:    'Share Tech Mono', monospace;
  --sans:    'Barlow', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── HEADER ── */
header {
  background: #fff;
  border-bottom: 2px solid var(--accent);
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: background 0.15s;
  flex-shrink: 0;
}
.back-btn:hover { background: var(--bg3); }
.back-btn.hidden { display: none; }
.header-title {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text2);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.torch-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 1.1rem;
  width: 36px; height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.torch-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── MAIN ── */
main { padding: 1.25rem 1rem 3rem; max-width: 680px; margin: 0 auto; }

/* ── HOME: LOGO ── */
.logo-block { text-align: center; padding: 2rem 0 2rem; }
.logo-icon  { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.logo-title { font-family: var(--mono); font-size: 1.8rem; color: var(--text); letter-spacing: 0.1em; }
.logo-sub   { font-size: 0.78rem; color: var(--text2); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 0.4rem; }

/* ── HOME: WARNING ── */
.home-warning {
  background: #fff8ee;
  border: 1px solid #e0c898;
  border-left: 3px solid var(--ocra);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  color: #7a5820;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}
.home-warning strong { color: var(--ocra); }

/* ── HOME: GRID CATEGORIE ── */
.categories-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.cat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  text-decoration: none;
  display: block;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  -webkit-user-select: none; user-select: none;
}
.cat-card:hover, .cat-card:active {
  background: var(--bg3);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(61,107,53,0.12);
}
.cat-card.solo { grid-column: 1 / -1; max-width: 50%; margin: 0 auto; width: 100%; }
.cat-icon  { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.cat-name  { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); letter-spacing: 0.05em; display: block; margin-bottom: 0.2rem; }
.cat-count { font-size: 0.7rem; color: var(--text2); }

/* ── CHAPTER: HEADER SEZIONE ── */
.chapter-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 0 1.25rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 1.25rem;
}
.chapter-icon  { font-size: 2.2rem; }
.chapter-title { font-family: var(--mono); font-size: 1.2rem; color: var(--accent); }
.chapter-desc  { font-size: 0.8rem; color: var(--text2); margin-top: 0.1rem; }

/* ── CHAPTER: ACCORDION TOPIC ── */
.topic-accordion { display: flex; flex-direction: column; gap: 0.6rem; }

.topic-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: border-color 0.15s;
}
.topic-item.open { border-color: var(--accent); }

.topic-trigger {
  width: 100%;
  background: none;
  border: none;
  padding: 0.95rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  text-align: left;
  -webkit-user-select: none; user-select: none;
}
.topic-trigger:hover { background: var(--bg3); }
.topic-trigger-left { flex: 1; }
.topic-trigger-title { font-weight: 700; font-size: 0.95rem; color: var(--text); display: block; }
.topic-trigger-sub   { font-size: 0.75rem; color: var(--text2); margin-top: 0.1rem; display: block; }
.topic-arrow {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: transform 0.2s;
  display: inline-block;
}
.topic-item.open .topic-arrow { transform: rotate(90deg); }

.topic-body {
  display: none;
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}
.topic-item.open .topic-body { display: block; }

/* ── ILLUSTRAZIONE ── */
.illustration {
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 1rem;
  margin-top: 0.75rem;
  overflow: hidden;
}
.illustration svg { display: block; width: 100%; }
.illus-caption {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text2);
  text-align: center;
  padding: 0.4rem 0.5rem 0.5rem;
  border-top: 1px solid var(--border);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── STEPS ── */
.steps-list { list-style: none; display: flex; flex-direction: column; gap: 0.65rem; margin-top: 0.85rem; }
.step {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
}
.step-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  min-width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-text { font-size: 0.9rem; color: var(--text); line-height: 1.55; }
.step-text strong { color: var(--ocra2); font-weight: 700; }

/* ── BOXES ── */
.warning-box {
  background: #fff5f5;
  border: 1px solid #e8c0c0;
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 0.83rem;
  color: #803020;
  margin-top: 0.75rem;
  line-height: 1.55;
}
.warning-box::before { content: "⚠ "; font-weight: 700; color: var(--red); }

.note-box {
  background: #f0f8ee;
  border: 1px solid #b8d8b0;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  font-size: 0.83rem;
  color: #3a6030;
  margin-top: 0.75rem;
  line-height: 1.55;
}
.note-box::before { content: "✓ "; font-weight: 700; color: var(--accent); }

/* ── INSTALL BANNER ── */
#installBanner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 2px solid var(--accent);
  padding: 0.85rem 1rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
}
#installBanner.hidden { display: none !important; }
.install-text { flex: 1; font-size: 0.82rem; color: var(--text); }
.install-text strong { color: var(--accent); display: block; font-size: 0.88rem; }
.install-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.install-close {
  background: none; border: none;
  color: var(--text2); font-size: 1.2rem;
  cursor: pointer; padding: 0 0.2rem;
}

/* ── TORCH MODE ── */
body.torch-mode { background: #fff; }
body.torch-mode header { border-bottom-color: #ddd; }
body.torch-mode .torch-btn { background: #ffdd00; border-color: #ccaa00; color: #000; }

/* ── PULSANTE HOME FISSO ── */
.home-fixed {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  border-radius: 30px;
  box-shadow: 0 4px 14px rgba(61,107,53,0.35);
  z-index: 150;
  letter-spacing: 0.05em;
  transition: all 0.15s;
  white-space: nowrap;
}
.home-fixed:hover, .home-fixed:active { background: #2d5228; transform: translateX(-50%) translateY(-1px); }

/* ── PULSANTE CHIUDI TOPIC ── */
.chiudi-btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text2);
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}
.chiudi-btn:hover, .chiudi-btn:active { background: var(--border); color: var(--text); }

/* ── BARRA NAVIGAZIONE FISSA IN BASSO ── */
.nav-bar { display: none; } /* rimossa */

main { padding-bottom: 4rem; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── FADE IN ── */
main { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── SEZIONE FONTI ── */
.fonti-section {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}
.fonti-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 0.7rem;
}
.fonte-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-user-select: none; user-select: none;
}
.fonte-item:hover, .fonte-item:active {
  border-color: var(--accent);
  background: var(--bg3);
}
.fonte-icon {
  width: 34px; height: 34px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.fi-doc { background: #e8f0fb; }
.fi-yt  { background: #fde8e8; }
.fi-web { background: #e8f5ee; }
.fonte-info { flex: 1; min-width: 0; }
.fonte-title { font-size: 0.88rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fonte-sub   { font-size: 0.72rem; color: var(--text2); margin-top: 0.1rem; }
.fonte-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}
.badge-doc { background: #e8f0fb; color: #185fa5; }
.badge-yt  { background: #fde8e8; color: #a82020; }
.badge-web { background: #e8f5ee; color: #3d6b35; }
.fonte-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
  transition: all 0.15s;
  -webkit-user-select: none; user-select: none;
}
.fonte-link:hover, .fonte-link:active {
  background: var(--bg3);
  border-color: var(--accent);
}
.fonte-icon-wrap {
  width: 34px; height: 34px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.fonte-cta {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

/* ── DRAWER FONTI ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed;
  bottom: -100%;
  left: 0; right: 0;
  background: var(--bg2);
  border-radius: 18px 18px 0 0;
  z-index: 201;
  transition: bottom 0.3s cubic-bezier(0.4,0,0.2,1);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
}
.drawer.open { bottom: 0; }

.drawer-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 1.1rem 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.drawer-close {
  background: var(--bg3);
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-body {
  padding: 1rem 1.1rem 2rem;
  overflow-y: auto;
  flex: 1;
}
.drawer-desc {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.offline-notice {
  background: #fff8ee;
  border: 1px solid #e0c898;
  border-left: 3px solid var(--ocra);
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #7a5820;
  margin-bottom: 1rem;
  display: none;
}
.offline-notice.show { display: block; }
.open-ext-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.05em;
  margin-top: 0.5rem;
  box-sizing: border-box;
}
.open-ext-btn.yt { background: #cc0000; }
.open-ext-btn:active { opacity: 0.85; }
.drawer-note {
  font-size: 0.75rem;
  color: var(--text2);
  text-align: center;
  margin-top: 0.6rem;
  line-height: 1.5;
}

