/* ==========================================================
   Calcolatori · Step Portal
   Palette mutuata da step.prandi.net/portal
   ========================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --accent:   #e16b2e;
  --accent-h: #c95922;
  --accent-soft:#fff5f0;
  --teal:     #0d6971;
  --teal-soft:#edf7f8;
  --ink:      #1a1a2e;
  --muted:    #6b7280;
  --line:     #e5e7eb;
  --bg:       #f9fafb;
  --white:    #ffffff;
  --green:    #059669;
  --green-soft:#ecfdf5;
  --blue:     #4f8ef7;
  --blue-soft:#eff4ff;
  --purple:   #7c3aed;
  --purple-soft:#f5f0ff;
  --warn:     #d97706;
  --danger:   #dc2626;
  --radius:   16px;
  --radius-s: 10px;
  --max:      1200px;
  --shadow:   0 12px 32px rgba(0,0,0,.08);
  --focus:    0 0 0 3px rgba(225,107,46,.22);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.wrap { width: min(calc(100% - 32px), var(--max)); margin: 0 auto; }

/* ---------- Header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.03em;
  color: var(--ink);
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small {
  font-size: 11px; font-weight: 500; color: var(--muted);
  letter-spacing: 0;
}
.header-actions { display: flex; gap: 10px; align-items: center; }

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
}
.lang-switch button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
}
.lang-switch button.active {
  background: var(--ink);
  color: #fff;
}
.lang-switch button:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 56px 16px 40px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.08;
  margin-bottom: 14px;
}
.hero h1 span { color: var(--accent); }
.hero p {
  color: var(--muted);
  font-size: 17px;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---------- Tools grid ---------- */
.tools-section { padding: 44px 0 48px; }
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 20px;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  position: relative;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
  opacity: 0;
  transition: opacity .18s;
}
.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: transparent;
}
.tool-card:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.tool-card:hover::before,
.tool-card:focus-visible::before { opacity: 1; }

.tool-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: var(--card-bg, var(--accent-soft));
  flex-shrink: 0;
}
.tool-icon svg { width: 32px; height: 32px; }

.tool-name {
  font-size: 16px; font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink); line-height: 1.2;
}
.tool-desc {
  font-size: 13px; color: var(--muted);
  line-height: 1.5; flex: 1;
}
.tool-btn {
  display: inline-flex;
  align-items: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border-radius: 999px;
  background: var(--card-accent, var(--accent));
  color: #fff; font-size: 13px; font-weight: 700;
  border: 0;
  transition: filter .15s, transform .15s;
}
.tool-btn:hover { filter: brightness(1.08); transform: scale(1.03); }

/* ---------- Calc pages (shared layout) ---------- */
.calc-header {
  background: linear-gradient(180deg, var(--white), var(--bg));
  border-bottom: 1px solid var(--line);
  padding: 32px 0 28px;
}
.calc-header .back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  margin-bottom: 14px;
  transition: color .15s;
}
.calc-header .back:hover { color: var(--accent); }
.calc-header h1 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 900; letter-spacing: -.03em;
  line-height: 1.15;
  display: flex; align-items: center; gap: 12px;
}
.calc-header .hero-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--card-bg, var(--accent-soft));
  flex-shrink: 0;
}
.calc-header .hero-icon svg { width: 28px; height: 28px; }
.calc-header p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  max-width: 640px;
  line-height: 1.55;
}

.calc-main { padding: 32px 0 48px; flex: 1; }
.calc-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .calc-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.panel + .panel { margin-top: 16px; }
.panel h2 {
  font-size: 16px; font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.panel .sub {
  font-size: 13px; color: var(--muted);
  margin-bottom: 18px;
}

/* ---------- Form controls ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.field .hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.input-row > * { flex: 1; min-width: 0; }

input[type="number"],
input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 14px;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  border: 0;
  transition: filter .15s, transform .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.segmented button.active {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ---------- Result panel ---------- */
.result {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--ink);
}
.result .big {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--accent);
}
.result .sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.result ul { list-style: none; padding: 0; margin-top: 14px; }
.result li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid rgba(0,0,0,.08);
  font-size: 14px;
}
.result li strong { font-weight: 800; }

.result-muted {
  background: var(--white);
  border: 1.5px solid var(--line);
}
.result-muted .big { color: var(--ink); }

/* ---------- Badges per classificazione BMI ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-underweight { background: var(--blue-soft); color: var(--blue); }
.badge-normal { background: var(--green-soft); color: var(--green); }
.badge-overweight { background: #fff5e0; color: var(--warn); }
.badge-obese { background: #fee2e2; color: var(--danger); }

/* ---------- Tables ---------- */
.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.t th, .t td {
  padding: 10px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.t th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 700;
}
.t tr:last-child td { border-bottom: 0; }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Ad slots ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    #f3f4f6,
    #f3f4f6 10px,
    #eef0f3 10px,
    #eef0f3 20px
  );
  border: 1px dashed #d1d5db;
  border-radius: var(--radius-s);
  color: #9ca3af;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
  overflow: hidden;
}
.ad-slot[hidden] { display: none; }
.ad-slot-leaderboard { min-height: 90px; margin: 16px 0; }
.ad-slot-rectangle { min-height: 250px; margin-bottom: 16px; }
.ad-slot-sidebar { min-height: 600px; }
.ad-slot-inline { min-height: 120px; margin: 16px 0; }

/* ---------- Legal pages ---------- */
.doc {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 820px;
  margin: 32px auto;
}
.doc h1 { font-size: 28px; margin-bottom: 8px; letter-spacing: -.03em; }
.doc .updated { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.doc h2 { font-size: 18px; margin: 22px 0 8px; }
.doc p, .doc li { font-size: 15px; line-height: 1.65; color: var(--ink); }
.doc ul { padding-left: 22px; margin-bottom: 10px; }
.doc a { color: var(--accent); text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 20px 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.footer-legal { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-legal a {
  color: var(--muted);
  transition: color .15s;
  font-size: 11px;
}
.footer-legal a:hover { color: var(--ink); }

/* ---------- Cookie banner ---------- */
#cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: #1a1a2e;
  color: rgba(255,255,255,.88);
  font-size: 13px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(0,0,0,.18);
}
#cookie-banner[hidden] { display: none; }
#cookie-banner p { margin: 0; line-height: 1.5; max-width: 700px; }
#cookie-banner a { color: #f0a07a; text-decoration: underline; }
.cookie-btns { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
  height: 34px; padding: 0 16px; border-radius: 8px;
  font-size: 12px; font-weight: 700; cursor: pointer; border: 0;
}
.cookie-btn.accept { background: var(--accent); color: #fff; }
.cookie-btn.reject {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
}
.cookie-btn:hover { filter: brightness(1.15); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .brand-text small { display: none; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tool-card { padding: 20px 14px; }
  .hero { padding: 40px 16px 32px; }
  .panel { padding: 18px; }
}
@media (max-width: 380px) {
  .tools-grid { grid-template-columns: 1fr; }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
