/* =============================================================
   paolovigano.it — Base CSS
   Reset, tipografia, componenti globali.
   Importa tokens.css prima di questo file.
   ============================================================= */

/* ── RESET ──────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
  -webkit-tap-highlight-color: transparent;
}

/* ── TIPOGRAFIA ─────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-black);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-1);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  line-height: var(--leading-relaxed);
  color: var(--text-2);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}
a:hover { opacity: 0.8; }

strong { font-weight: var(--weight-semibold); color: var(--text-1); }
small  { font-size: var(--text-sm); color: var(--text-2); }
ul, ol { list-style: none; }
img, video, svg { display: block; max-width: 100%; }
img { user-select: none; }

/* ── FORM BASE ──────────────────────────────────────────────── */

input, textarea, select, button {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-1);
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Previeni zoom iOS su focus input */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ── FOCUS ──────────────────────────────────────────────────── */

:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ── SCROLLBAR ──────────────────────────────────────────────── */

::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }

/* ── SELEZIONE TESTO ────────────────────────────────────────── */

::selection { background: var(--accent); color: #fff; }

/* ── BOTTONI ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    opacity var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled)  { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger {
  background: var(--danger-muted);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-sm  { padding: 7px 14px; font-size: var(--text-sm); }
.btn-lg  { padding: 14px 28px; font-size: var(--text-md); }
.btn-block { width: 100%; }

/* ── FORM COMPONENTS ────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: var(--space-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-2);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: var(--text-base);
  color: var(--text-1);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-3); }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-error {
  font-size: var(--text-sm);
  color: var(--danger);
  display: none;
}
.form-error.visible { display: block; }

/* ── CARD ───────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

/* ── BADGE ──────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-accent  { background: var(--accent-muted);  color: var(--accent);  border-color: var(--accent-border); }
.badge-success { background: var(--success-muted); color: var(--success); }
.badge-danger  { background: var(--danger-muted);  color: var(--danger);  border-color: var(--danger-border); }
.badge-neutral { background: var(--surface-2);     color: var(--text-2);  border-color: var(--border); }

/* ── TOAST ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface-3);
  color: var(--text-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-toast);
  transition: opacity var(--transition-base), transform var(--transition-base);
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { border-color: var(--success); color: var(--success); }
.toast.toast-error   { border-color: var(--danger);  color: var(--danger); }

/* ── DIVIDER ────────────────────────────────────────────────── */

.divider { width: 100%; height: 1px; background: var(--border); margin: var(--space-6) 0; }

/* ── UTILITIES ──────────────────────────────────────────────── */

.text-accent   { color: var(--accent); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-muted    { color: var(--text-2); }
.text-faint    { color: var(--text-3); }

.fw-medium   { font-weight: var(--weight-medium); }
.fw-semibold { font-weight: var(--weight-semibold); }
.fw-bold     { font-weight: var(--weight-bold); }
.fw-black    { font-weight: var(--weight-black); }

.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── REDUCED MOTION ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── TOUCH TARGETS ──────────────────────────────────────────── */

@media (pointer: coarse) {
  .btn, button, a { min-height: 44px; }
  .btn-sm { min-height: 36px; }
}
