/* Transmart design system (mirrors the Cosimo Google-Apps-Script app) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

/* === Design Tokens === */
:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', monospace;
  --radius: 9px;
  --radius-sm: 5px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* compact radii / shadows / motion (Transmart) */
  --r-xs: 3px; --r-sm: 5px; --r: 7px; --r-md: 9px; --r-lg: 12px; --r-full: 9999px;
  --shadow-xs: 0 1px 1px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.03);
  --shadow:    0 4px 6px -1px rgba(15,23,42,.08), 0 2px 4px -2px rgba(15,23,42,.04);
  --shadow-md: 0 10px 15px -3px rgba(15,23,42,.10), 0 4px 6px -2px rgba(15,23,42,.04);
  --shadow-lg: 0 20px 40px -10px rgba(15,23,42,.20);
  --t: 120ms ease-out; --t-fast: 80ms ease-out;

  /* brand + semantic transport colors (theme-independent) */
  --primary: #32589d; --primary-hover: #25406f; --primary-soft: #eef2fa;
  --primary-3: #4568a6; --primary-light: #7a92bf; --primary-ring: rgba(50,88,157,.22);
  --text-strong: #0f172a; --text-subtle: #94a3b8;
  --border-soft: #f1f5f9; --border-hard: #cbd5e1; --bg-muted: #e2e8f0;
  --consegna: #2563eb; --consegna-bg: #eff6ff;
  --ritiro: #f97316; --ritiro-bg: #fff7ed;
  --success: #059669; --danger: #dc2626; --warning: #d97706;
}

/* === Dark Theme (default) === */
[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-subtle: #0f1525;
  --surface: #141c2e;
  --surface-hover: #1a253a;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(251, 191, 36, 0.35);
  --text: #e8ecf4;
  --text-muted: #7c879c;
  --accent: #fbbf24;
  --accent-dim: #d4991a;
  --accent-glow: rgba(251, 191, 36, 0.08);
  --accent-glow-strong: rgba(251, 191, 36, 0.15);
  --code-bg: rgba(251, 191, 36, 0.07);
  --code-text: #fcd34d;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --hero-gradient: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

/* === Light Theme (Transmart) === */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: var(--primary-3);
  --text: #1e293b;
  --text-muted: #475569;
  --accent: var(--primary);            /* navy — was amber */
  --accent-dim: var(--primary-hover);
  --accent-glow: var(--primary-soft);
  --accent-glow-strong: rgba(50, 88, 157, 0.12);
  --code-bg: var(--primary-soft);
  --code-text: var(--primary-hover);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .04);
  --hero-gradient: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  --grain: none;
}

/* === Base === */
html { font-family: var(--font-body); scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--grain);
  pointer-events: none;
  z-index: 9999;
}

/* === Entrance Animation === */
@keyframes reveal {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
main { animation: reveal 0.5s ease-out; }
main .grid > article:nth-child(1) { animation: reveal 0.5s ease-out 0.05s both; }
main .grid > article:nth-child(2) { animation: reveal 0.5s ease-out 0.12s both; }
main .grid > article:nth-child(3) { animation: reveal 0.5s ease-out 0.19s both; }

/* === Navigation === */
nav {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0.85;
  z-index: -1;
}
nav > .container {
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}
nav ul {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-bottom: 0;
}
nav li strong {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  line-height: 1.5;
}
nav li a {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
}
nav li a:hover {
  color: var(--accent);
  background: var(--accent-glow);
}
nav li a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  background: transparent;
  border-radius: 0;
  border-bottom: 2px solid var(--accent);
}

/* === Theme Toggle === */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1;
  color: var(--text-muted);
}
.theme-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--border-hover);
  color: var(--accent);
}

/* === Main Content === */
main { padding-top: 1.5rem; }

/* === Hero === */
.hero {
  text-align: center;
  padding: 3.5rem 1.5rem 2.5rem;
  margin-bottom: 2rem;
  background: var(--hero-gradient);
  border-radius: var(--radius);
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.6rem;
  word-break: break-word;
}
.hero h1 span.accent { color: var(--accent); }
.hero > p {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 300;
  font-size: 1.05rem;
}

/* === Badge === */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border);
  letter-spacing: 0.01em;
}

/* === Section Labels === */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-left: 0.15rem;
}

/* === Cards (Pico articles) === */
article {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
article:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 24px var(--accent-glow-strong);
  transform: translateY(-1px);
}
article header {
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
article footer {
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* === Headings === */
h2 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

/* === Code === */
code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  padding: 0.12em 0.4em;
  font-size: 0.85em;
  font-weight: 500;
}

/* === Buttons === */
button.outline, [role="button"].outline {
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
button.outline:hover, [role="button"].outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* === Page Footer === */
footer[class="container"] {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}
footer[class="container"] a {
  color: var(--accent);
  text-decoration: none;
}
footer[class="container"] a:hover { text-decoration: underline; }

/* === HTMX transitions === */
.htmx-request { opacity: 0.5; transition: opacity 0.3s; }

/* === Toast Notifications === */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  font-family: var(--font-body);
  padding: 0.55rem 0.9rem;
  border-radius: var(--r);
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  background: var(--primary);
  border: none;
  box-shadow: var(--shadow-lg);
  animation: toastSlide 0.3s ease-out, toastFade 0.3s ease-in 2.7s forwards;
}
.toast-success,
.toast-ok      { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--primary); }
/* copiato/salvato ma qualcosa resta da sistemare a mano: non e' un errore
   (il lavoro c'e') ma non e' un "tutto a posto" */
.toast-warn    { background: var(--warning, #b45309); }
@keyframes toastSlide {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastFade {
  to { opacity: 0; transform: translateY(-0.5rem); }
}

/* === Responsive === */
@media (max-width: 768px) {
  .hero { padding: 2.5rem 1rem 2rem; }
  nav li a { font-size: 0.75rem; padding: 0.25rem 0.5rem; }
}
