/*
 * renalab-shared.css — Stili condivisi RenalLab™
 * v20 · Dr. Michele Cavasso
 *
 * Questo file è l'unico punto da modificare per cambiare:
 * colori, tipografia, nav, footer, animazioni, iOS patch, accessibilità.
 * Tutte le 16 pagine lo importano automaticamente.
 */

/* ══════════════════════════════════════
   DESIGN TOKENS
   ══════════════════════════════════════ */
:root {
  --teal:        #2a9d8f;
  --teal-dark:   #1a6e63;
  --teal-light:  #e6f7f5;
  --teal-mid:    #a8ddd8;
  --white:       #fff;
  --off:         #f7faf9;
  --text:        #1a2e2b;
  --muted:       #4a6460;   /* potenziato per WCAG AA */
  --sand:        #f5f0e8;
  --amber:       #e07a2f;
  --amber-dark:  #b85c18;
  --amber-light: #fef3e8;
  --radius:      16px;
  --shadow-sm:   0 2px 8px rgba(26,46,43,0.06);
  --shadow-md:   0 8px 24px rgba(26,46,43,0.09);
  --shadow-lg:   0 16px 48px rgba(26,46,43,0.13);
  /* iOS safe areas */
  --sat: env(safe-area-inset-top,    0px);
  --sar: env(safe-area-inset-right,  0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
}

/* ══════════════════════════════════════
   RESET
   ══════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
body {
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--white);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ══════════════════════════════════════
   NAV (barra fissa in cima)
   ══════════════════════════════════════ */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(68px + var(--sat));
  padding: max(0px, var(--sat)) calc(5% + var(--sar)) 0 calc(5% + var(--sal));
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(42,157,143,0.08);
}
.nav-logo { text-decoration: none; display: flex; align-items: center; }
.nav-links { display: flex; align-items: center; gap: 1.8rem; list-style: none; }
.nav-links a {
  text-decoration: none; font-size: 0.85rem; font-weight: 500;
  color: var(--muted); transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--teal); }
.nav-cta {
  background: var(--teal); color: white !important;
  padding: 0.45rem 1.1rem; border-radius: 50px;
}
/* Hamburger */
.nav-hamburger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.nav-hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--muted); border-radius: 2px; transition: all 0.25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
/* Mobile drawer */
.nav-drawer {
  display: none; position: fixed; left: 0; right: 0; z-index: 99;
  top: calc(68px + var(--sat));
  padding: 1.2rem calc(5% + var(--sar)) 1.8rem calc(5% + var(--sal));
  background: white;
  border-bottom: 1px solid rgba(42,157,143,0.08);
  flex-direction: column; gap: 1.2rem;
  box-shadow: var(--shadow-md);
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  text-decoration: none; font-size: 1rem; font-weight: 500; color: var(--muted);
}
.nav-drawer a:hover { color: var(--teal); }
.nav-drawer .nav-cta { display: inline-block; margin-top: 0.4rem; text-align: center; }
@media(max-width: 860px) { .nav-links { display: none; } .nav-hamburger { display: flex; } }

/* ══════════════════════════════════════
   FOOTER
   ══════════════════════════════════════ */
footer {
  background: var(--text);
  padding: 44px calc(5% + var(--sar)) calc(28px + var(--sab)) calc(5% + var(--sal));
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.footer-disclaimer {
  font-size: max(0.7rem, 12px); color: rgba(255,255,255,0.45);
  max-width: 460px; line-height: 1.6;
}
.footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.footer-links a {
  font-size: 0.76rem; color: rgba(255,255,255,0.58);
  text-decoration: none; transition: color 0.2s;
}
.footer-links a:hover { color: var(--teal-light); }

/* ══════════════════════════════════════
   ANIMAZIONI
   ══════════════════════════════════════ */
.fade-up {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.fade-up.visible { opacity: 1; transform: translateY(0); }

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

/* ══════════════════════════════════════
   ACCESSIBILITÀ — WCAG 2.1 AA
   ══════════════════════════════════════ */
/* Focus visibili */
a:focus-visible, button:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #2a9d8f !important;
  outline-offset: 3px !important;
  border-radius: 4px !important;
}
/* Skip navigation */
.skip-nav {
  position: absolute; top: -44px; left: 0;
  background: #2a9d8f; color: white;
  padding: 8px 16px; border-radius: 0 0 8px 0;
  text-decoration: none; font-weight: 600;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  z-index: 9999; transition: top 0.2s;
}
.skip-nav:focus { top: 0 !important; }
/* Screen reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
/* Font size minimo per testi piccoli */
.hero-label, .cta-note, .footer-disclaimer,
.art-meta-item, .field-note {
  font-size: max(0.75rem, 12px) !important;
}

/* ══════════════════════════════════════
   iOS SAFARI PATCH
   ══════════════════════════════════════ */
input, select, textarea {
  font-size: 16px !important;
  -webkit-appearance: none;
  border-radius: 0;
}
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
select { background-image: none; padding-right: 2rem !important; }

/* Touch targets minimi 44×44 */
button, a, .nav-cta, .triage-card,
.food-item, .rl-sug-btn {
  min-height: 44px;
  min-width: 44px;
}
/* Tool nav */
.tool-nav  { -webkit-overflow-scrolling: touch; }
.tool-nav-inner { padding-bottom: 1px; }

/* Hover disabilitato su touch */
@media(hover: none) and (pointer: coarse) {
  .triage-card:hover,
  .post-card:hover,
  .split-card:hover,
  .tipo-card:hover,
  .food-item:hover,
  .calc-card:hover { transform: none !important; box-shadow: var(--shadow-md) !important; }
}

/* Scroll orizzontale tabelle */
.val-table, .trial-table, .log-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Hero: font size sicuro su iPhone SE */
@media(max-width: 390px) {
  .hero h1, .art-hero h1 { font-size: 1.9rem !important; }
}

/* Sticky budget bar */
.budget-bar-wrap {
  top: calc(76px + var(--sat)) !important;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Scroll nelle liste chat */
.food-results, .na-food-list, #na-food-list {
  -webkit-overflow-scrolling: touch;
}

/* Button press feedback */
button:active, a:active, .triage-card:active { opacity: 0.8; transition: opacity 0.1s; }
