/* =============================
   Bussola Digitale — Elegant Classic UI
   Global stylesheet (mobile-first, flexbox only)
   ============================= */

/* ---- CSS Reset & Normalize ---- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding-left: 1.2rem; }
h1, h2, h3, h4, h5, h6, p { margin: 0; }

/* ---- Theme Tokens ---- */
:root {
  --primary: #0D3B66;
  --primary-700: #0A3054;
  --primary-800: #072742;
  --secondary: #00A896;
  --secondary-700: #028C7D;
  --accent: #F2F8FF;
  --paper: #FFFFFF;
  --canvas: #FAF9F7; /* warm, classic off-white */
  --ink: #2B2B2B; /* elegant dark */
  --muted: #6B7280; /* muted gray for secondary text */
  --line: #E6E2D9; /* classic, warm line */
  --shadow: 0 6px 18px rgba(13, 59, 102, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --focus: 2px solid #0D3B66;
}

/* ---- Base Typography (elegant classic) ---- */
body {
  background: var(--paper);
  color: var(--ink);
  font-family: Verdana, Segoe UI, Tahoma, sans-serif; /* brand body font */
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: Georgia, "Times New Roman", Times, serif; /* classic serif for headings */
  letter-spacing: 0.2px;
  color: var(--primary-800);
}

h1 { font-size: 32px; line-height: 1.2; }
h2 { font-size: 24px; line-height: 1.25; }
h3 { font-size: 18px; line-height: 1.3; }

p, li { font-size: 16px; color: var(--ink); }
small { font-size: 14px; color: var(--muted); }

/* Headings spacing rules for elegance */
.content-wrapper h1 + p,
.content-wrapper h2 + p,
.content-wrapper h3 + p { margin-top: 8px; }

/* Links */
a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--primary-700); }
a.btn { text-decoration: none; }

/* Focus states */
:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---- Layout Wrappers (Flexbox only) ---- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;          /* flex wrapper (mobile-first) */
  flex-direction: column; /* stack by default */
  gap: 20px;
}

/* Generic section rhythm (for sections without .section class) */
section { padding: 40px 0; }

/* ---- MANDATORY SPACING & ALIGNMENT PATTERNS ---- */
.section { margin-bottom: 60px; padding: 40px 20px; }
.card-container { display: flex; flex-wrap: wrap; gap: 24px; }
.card { margin-bottom: 20px; position: relative; }
.content-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; }
.text-image-section { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.testimonial-card { display: flex; align-items: center; gap: 20px; padding: 20px; }
.feature-item { display: flex; flex-direction: column; align-items: flex-start; gap: 15px; }

/* ---- Header & Navigation ---- */
header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1000;
}

header .container {
  flex-direction: row;    /* horizontal in header */
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.logo img { height: 36px; width: auto; }

.main-nav { display: none; align-items: center; gap: 16px; }
.main-nav a {
  color: var(--primary-800);
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease, transform 180ms ease;
}
.main-nav a:hover { background: var(--accent); color: var(--primary); }

.header-ctas { display: none; align-items: center; gap: 10px; }

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--primary-800);
  background: var(--paper);
  transition: background-color 180ms ease, transform 180ms ease, border-color 180ms ease;
}
.mobile-menu-toggle:hover { background: var(--accent); transform: translateY(-1px); border-color: var(--primary); }

/* Mobile Menu Overlay */
.mobile-menu {
  position: fixed; inset: 0; right: 0; top: 0;
  background: rgba(13,59,102,0.08);
  backdrop-filter: blur(2px);
  transform: translateX(100%);
  transition: transform 260ms ease;
  z-index: 9999;
  display: flex; /* flex container */
  align-items: stretch; justify-content: flex-end;
}
.mobile-menu .mobile-nav {
  width: 84%; max-width: 380px; height: 100%;
  background: var(--paper);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; flex-wrap: nowrap;
  padding: 20px;
  box-shadow: var(--shadow);
}
.mobile-menu .mobile-nav a {
  display: flex; align-items: center;
  color: var(--primary-800);
  padding: 12px 10px;
  border-radius: 6px;
  font-size: 17px;
  text-decoration: none;
}
.mobile-menu .mobile-nav a:hover { background: var(--accent); color: var(--primary); }

.mobile-menu-close {
  position: absolute; right: 16px; top: 14px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--primary-800);
}

/* states that JS can toggle */
.mobile-menu.open, .mobile-menu.is-open { transform: translateX(0); }
body.no-scroll { overflow: hidden; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; text-decoration: none;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease, transform 120ms ease;
  font-weight: 600; letter-spacing: 0.2px;
}

.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(13,59,102,0.18); }
.btn.primary:hover { background: var(--primary-700); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(13,59,102,0.22); }
.btn.primary:active { transform: translateY(0); }

.btn.secondary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn.secondary:hover { background: var(--accent); }

/* Utility button variants for cookie UI */
.btn.ghost { background: transparent; color: var(--primary-800); border-color: var(--line); }
.btn.ghost:hover { background: #F6F4F0; }
.btn.negative { background: transparent; color: #8B0D0D; border-color: #E5B3B3; }
.btn.negative:hover { background: #FFF4F4; }

/* ---- Content Blocks ---- */
.content-wrapper {
  display: flex; flex-direction: column; align-items: flex-start; gap: 24px;
}

.text-section {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--secondary);
  padding: 16px 16px 16px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px; /* ensure 20px min between cards */
}

/* Lists inside text-section with icons */
.text-section ul { padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.text-section li { display: flex; align-items: center; gap: 10px; }
.text-section li img { width: 18px; height: 18px; }

/* Testimonial Cards (light background, high readability) */
.testimonial-card {
  background: #F7F7F3; color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.testimonial-card p { margin: 0; }
.testimonial-card p + p { color: var(--primary-800); }
.testimonial-card::before {
  content: "\201C"; /* decorative opening quote */
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 28px; line-height: 0;
  color: var(--secondary);
  margin-right: 4px;
}

/* Hero section style (first section on each page) */
main > section:first-of-type { background: var(--accent); border-bottom: 1px solid var(--line); }
main > section:first-of-type .content-wrapper { padding: 8px 0; }

/* Stats and lists */
ul { display: flex; flex-direction: column; gap: 8px; }
ol { display: flex; flex-direction: column; gap: 8px; padding-left: 1.2rem; }

/* Feature items layout helper */
.feature-item h3 { margin-bottom: 2px; }

/* Cards (generic) */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}

/* Content grid helper for two-up/three-up using flex only */
.content-grid > * { flex: 1 1 260px; min-width: 240px; }
.card-container > * { flex: 1 1 300px; min-width: 260px; }

/* Text + Image section responsive alignment */
.text-image-section > * { flex: 1 1 320px; }

/* ---- Header/Footer Navigation inside sections ---- */
footer { background: var(--canvas); border-top: 1px solid var(--line); }
footer nav a { color: var(--primary-800); text-decoration: underline; text-underline-offset: 2px; }
footer nav a:hover { color: var(--primary); }

/* Footer layout */
footer section .container { gap: 20px; }
footer .content-wrapper { display: flex; flex-wrap: wrap; gap: 20px; }
footer .text-section { border-left-color: var(--primary); }

/* ---- Accessibility spacing & readable paragraphs ---- */
.content-wrapper > p, .content-wrapper > div, .content-wrapper > ul, .content-wrapper > ol { width: 100%; }

/* ---- Mobile-first nav visibility ---- */
/* On mobile: main nav and header ctas hidden, burger visible */
.main-nav, .header-ctas { display: none; }

/* ---- Cookie Consent Banner ---- */
.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 18px rgba(13,59,102,0.06);
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
}
.cookie-banner .cookie-inner {
  max-width: 1120px; width: 100%;
  padding: 16px; margin: 0 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.cookie-banner p { font-size: 14px; color: var(--ink); }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cookie-actions .btn { padding: 8px 14px; }
.cookie-actions .btn.accept { background: var(--primary); color: #fff; }
.cookie-actions .btn.accept:hover { background: var(--primary-700); }
.cookie-actions .btn.reject { border: 1px solid var(--line); color: var(--primary-800); }
.cookie-actions .btn.reject:hover { background: #F6F4F0; }
.cookie-actions .btn.settings { border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.cookie-actions .btn.settings:hover { background: var(--accent); }

/* Cookie Preferences Modal */
.cookie-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.44);
  display: none; align-items: center; justify-content: center; z-index: 10000;
}
.cookie-modal.open { display: flex; }
.cookie-modal .modal-content {
  background: var(--paper);
  width: 92%; max-width: 680px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  transform: translateY(6px); opacity: 0; transition: transform 220ms ease, opacity 220ms ease;
}
.cookie-modal.open .modal-content { transform: translateY(0); opacity: 1; }
.cookie-options { display: flex; flex-direction: column; gap: 12px; }
.cookie-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.cookie-option .label { display: flex; flex-direction: column; gap: 4px; }
.cookie-modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* Toggle switch */
.toggle { position: relative; width: 44px; height: 24px; border-radius: 999px; background: #D7DBE0; flex: 0 0 auto; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .knob { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 180ms ease, background-color 180ms ease; }
.toggle input:checked + .knob { transform: translateX(20px); background: #fff; }
.toggle input:checked ~ .track { background: var(--secondary); }
.toggle .track { position: absolute; inset: 0; border-radius: 999px; background: #D7DBE0; transition: background-color 180ms ease; }

/* ---- Micro-interactions ---- */
.text-section, .card, .testimonial-card { transition: transform 180ms ease, box-shadow 180ms ease; }
.text-section:hover, .card:hover, .testimonial-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(13,59,102,0.12); }

/* ---- Responsive Rules ---- */
@media (min-width: 480px) {
  h1 { font-size: 36px; }
  h2 { font-size: 26px; }
  h3 { font-size: 19px; }
}

@media (min-width: 768px) {
  .container { gap: 28px; }

  /* Show desktop nav */
  .main-nav { display: flex; }
  .header-ctas { display: flex; }
  .mobile-menu-toggle { display: none; }

  /* Balance hero */
  main > section:first-of-type .container { flex-direction: row; align-items: center; }

  /* Let text sections wrap into two columns when many */
  .content-wrapper { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .content-wrapper > .text-section { flex: 1 1 46%; min-width: 300px; }

  .text-image-section { flex-direction: row; align-items: center; }
}

@media (max-width: 768px) {
  /* Required mobile alignment rule */
  .text-image-section { flex-direction: column; }
}

@media (min-width: 992px) {
  h1 { font-size: 44px; }
  h2 { font-size: 30px; }
  h3 { font-size: 20px; }

  header .container { padding-top: 16px; padding-bottom: 16px; }

  .main-nav a { padding: 10px 12px; font-size: 16px; }
}

/* ---- Page-specific subtle accents (using existing classes) ---- */
/* Lists of stats often inside .text-section or .content-wrapper */
.content-wrapper ul li strong { font-family: Georgia, "Times New Roman", Times, serif; color: var(--primary-800); font-size: 18px; }

/* ---- Helper Utilities ---- */
.muted { color: var(--muted); }
.center { display: flex; align-items: center; justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---- Ensure adequate spacing between adjacent cards/sections ---- */
.content-wrapper > .card, .content-wrapper > .text-section, .content-wrapper > .testimonial-card { margin-right: 0; }

/* ---- High contrast in testimonial and review sections ---- */
/* Already ensured by dark text on light background in .testimonial-card */

/* ---- Print tweaks (optional for elegance) ---- */
@media print {
  .mobile-menu, .mobile-menu-toggle, .cookie-banner, .cookie-modal { display: none !important; }
  a { text-decoration: underline; }
}
