/* ============================================================================
 * Fortuna shared styles — estratti da canvas-demo.html durante il refactor.
 * Caricato da ogni pagina in /pages/*.html.
 * Stili view-specific (es. bento brand) restano in file separati: brand.css.
 * ============================================================================ */

:root {
  --bg: #FAFAF9;
  --accent: #D9F378;
  --accent-dark: #C7E55C;
  --sb-half: 116px;
}
@media (max-width: 1024px) {
  :root { --sb-half: 38px; }
}
@media (max-width: 640px) {
  :root { --sb-half: 0px; }
}

html, body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  height: 100%;
  overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Liquid Glass: dock e card translucide ---------- */
.glass {
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%),
    rgba(255,255,255,0.04);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 40px 100px -25px rgba(0, 0, 0, 0.3),
    0 12px 32px -10px rgba(0, 0, 0, 0.12),
    0 1px 0 rgba(255, 255, 255, 1) inset,
    0 2px 4px rgba(255, 255, 255, 0.6) inset,
    0 -1px 0 rgba(0, 0, 0, 0.08) inset,
    1px 0 0 rgba(255, 255, 255, 0.3) inset,
    -1px 0 0 rgba(255, 255, 255, 0.3) inset;
  position: relative;
}
.glass::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.3) 20%,
    rgba(255,255,255,0) 45%, rgba(255,255,255,0) 55%,
    rgba(255,255,255,0.15) 75%, rgba(255,255,255,0.6) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none; z-index: 2;
}
.glass::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse 80% 60% at 50% 0%,
    rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 60%);
  pointer-events: none; z-index: 1;
}
.glass > * { position: relative; z-index: 3; }

.glass-chip {
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ---------- Blob colorati dietro la dock chat ---------- */
.blob {
  position: fixed;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 1;
}
.blob-1 { width: 320px; height: 320px; background: #D9F378; bottom: -160px; left: 50%; transform: translateX(-70%); }
.blob-2 { width: 240px; height: 240px; background: #FDE68A; bottom: -120px; left: 50%; transform: translateX(10%); }
.blob-3 { width: 200px; height: 200px; background: #BAE6FD; bottom: -80px; left: 50%; transform: translateX(-200%); opacity: 0.18; }

/* ---------- Chip enter ---------- */
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) forwards; }

/* ---------- Typing dots (AI is writing) ---------- */
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #71717a; display: inline-block;
  animation: typing-dot 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }

/* ---------- Mic recording pulse ---------- */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(199, 229, 92, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(199, 229, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(199, 229, 92, 0); }
}
.mic-pulse { animation: pulse-ring 2s infinite; }

@keyframes tp-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---------- Canvas grid background ---------- */
.canvas-grid {
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ---------- Sidebar nav buttons ---------- */
.nav-btn { color: #52525b; }
.nav-btn:hover { background: rgba(255,255,255,0.55); color: #18181b; }
.nav-btn[data-active="true"] {
  background: rgba(24,24,27,0.92);
  color: white;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.nav-tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(24,24,27,0.92);
  color: white;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  backdrop-filter: blur(8px);
}
.nav-btn:hover .nav-tooltip { opacity: 1; transform: translateY(-50%) translateX(0); }

input[type="range"] { -webkit-appearance: none; background: transparent; }

/* ---------- Markdown rendering inside chat bubbles ---------- */
.md p { margin: 0.25rem 0; }
.md p:first-child { margin-top: 0; }
.md p:last-child { margin-bottom: 0; }
.md strong { font-weight: 600; }
.md em { font-style: italic; }
.md ul, .md ol { margin: 0.35rem 0; padding-left: 1.25rem; }
.md ul { list-style: disc; }
.md ol { list-style: decimal; }
.md li { margin: 0.15rem 0; }
.md code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
}
.md pre {
  background: rgba(0,0,0,0.06);
  padding: 8px 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.85em;
}
.md pre code { background: transparent; padding: 0; }
.md a { color: #1d4ed8; text-decoration: underline; word-break: break-all; }
.md blockquote {
  border-left: 3px solid #d4d4d8;
  padding-left: 0.75rem;
  color: #71717a;
  margin: 0.5rem 0;
}
.md h1, .md h2, .md h3, .md h4 { font-weight: 600; margin: 0.5rem 0 0.25rem; line-height: 1.3; }
.md h1 { font-size: 1.1em; }
.md h2 { font-size: 1.05em; }
.md h3 { font-size: 1em; }
.md hr { border: none; border-top: 1px solid #e4e4e7; margin: 0.5rem 0; }

/* ---------- Responsive sidebar collapse ---------- */
/* Tablet (641–1024px): sidebar a icone. Mobile (≤640px) usa il drawer sotto, NON il collapse a icone. */
@media (min-width: 641px) and (max-width: 1024px) {
  #sidebar {
    width: 64px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  #sidebar a span:not(.nav-tooltip),
  #sidebar button span:not(.nav-tooltip),
  #sidebar [data-lucide="chevron-down"],
  #sidebar [data-group] > div[id^="grp-"],
  #sidebar > div:last-child > div > div p,
  #sidebar > div:last-child button > span {
    display: none !important;
  }
  #sidebar > a > div { margin: 0 auto; }
  #sidebar nav a, #sidebar nav button {
    justify-content: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  #canvas { padding-left: 80px !important; }
}
@media (max-width: 640px) {
  /* Sidebar → drawer off-canvas (prima era display:none = nessuna navigazione su mobile). */
  #sidebar {
    display: flex !important;
    width: 248px !important;
    left: 0 !important; top: 0 !important; bottom: 0 !important;
    padding-left: 12px !important; padding-right: 12px !important;
    border-radius: 0 14px 14px 0 !important;
    background: #f4f4f5;
    box-shadow: 0 12px 48px rgba(0,0,0,.22);
    transform: translateX(-110%);
    transition: transform .25s ease;
    z-index: 60;
  }
  #sidebar.is-open { transform: translateX(0); }
  #canvas {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-top: 56px !important; /* spazio per l'hamburger fisso */
  }
  #mobile-nav-toggle { display: flex !important; }
  #mobile-nav-overlay.is-open { display: block !important; }
}

/* Hamburger + overlay: nascosti di default (desktop/tablet), attivati solo ≤640px. */
#mobile-nav-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 61;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  border-radius: 12px; background: #18181b; color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); cursor: pointer;
}
#mobile-nav-overlay {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.35);
}
