/* COAS Consorzio Astigiano - foglio di stile del sito pubblico */

:root {
  --navy: #184580;
  --navy-900: #0f2d57;
  --navy-050: #eef3fa;
  --blue: #1f6fb8;
  --yellow: #ffe600;
  --amber: #b45f06;
  --amber-bg: #fff4e0;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2733;
  --muted: #586577;
  --border: #dde3ea;
  --focus: #ffbf47;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 45, 87, .06), 0 6px 20px rgba(15, 45, 87, .08);
  --container: 1160px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1 0 auto; }

img { max-width: 100%; height: auto; }

a { color: var(--blue); text-underline-offset: .15em; }
a:hover { color: var(--navy); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.2; color: var(--navy-900); margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
h3 { font-size: 1.15rem; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--yellow); color: var(--navy-900); font-weight: 700;
  padding: 10px 16px; border-radius: var(--radius-sm); text-decoration: none;
}
.skip-link:focus { top: 12px; }

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

/* ---------- Header ---------- */

.topbar { background: var(--navy-900); color: #cfdbec; font-size: .875rem; }
.topbar .container { display: flex; justify-content: space-between; gap: 16px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.topbar a { color: #fff; text-decoration: none; }
.topbar a:hover { text-decoration: underline; color: #fff; }
@media (max-width: 600px) { .topbar .container > span:first-child { display: none; } .topbar .container { justify-content: flex-end; } }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.site-header .container { display: flex; align-items: center; gap: 24px; min-height: 76px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy-900); flex-shrink: 0; }
.brand img { width: 74px; height: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; letter-spacing: .02em; }
.brand-text span { font-size: .8rem; color: var(--muted); }

.nav-toggle {
  display: none; margin-left: auto;
  background: var(--navy); color: #fff; border: 0; border-radius: var(--radius-sm);
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer;
  align-items: center; gap: 8px;
}
.nav-toggle svg { width: 20px; height: 20px; }

.main-nav { margin-left: auto; }
.main-nav > ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; gap: 2px; }
.main-nav li { position: relative; }
.nav-item { display: flex; align-items: center; }

.main-nav a, .main-nav button.nav-link {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--navy-900); text-decoration: none; font-weight: 600; font-size: .95rem;
  background: none; border: 0; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.main-nav a:hover, .main-nav button.nav-link:hover,
.main-nav .is-current > .nav-item > a, .main-nav .is-current > .nav-item > button.nav-link { background: var(--navy-050); color: var(--navy); }
.main-nav .is-current > .nav-item > a, .main-nav .is-current > .nav-item > button.nav-link { box-shadow: inset 0 -3px 0 var(--yellow); }

.sub-toggle {
  background: none; border: 0; padding: 10px 6px; margin-left: -8px; cursor: pointer; color: var(--navy);
  border-radius: var(--radius-sm);
}
.sub-toggle:hover { background: var(--navy-050); }
.chev { width: 14px; height: 14px; transition: transform .15s; }
[aria-expanded="true"] .chev { transform: rotate(180deg); }

.submenu {
  list-style: none; margin: 0; padding: 8px;
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
}
.submenu.is-open { display: block; }
.submenu a { font-weight: 500; white-space: normal; }
.submenu a[aria-current="page"] { background: var(--navy-050); color: var(--navy); font-weight: 700; }

@media (hover: hover) and (min-width: 1001px) {
  .main-nav li:hover > .submenu { display: block; }
  .main-nav li:hover > .submenu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
}

@media (max-width: 1000px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    max-height: calc(100vh - 76px); overflow-y: auto;
  }
  .main-nav.is-open { display: block; }
  .main-nav > ul { flex-direction: column; padding: 12px 20px 20px; gap: 0; }
  .main-nav > ul > li { border-bottom: 1px solid var(--border); }
  .nav-item { justify-content: space-between; }
  .main-nav a, .main-nav button.nav-link { padding: 14px 4px; flex: 1; }
  .sub-toggle { padding: 14px 12px; }
  .submenu { position: static; box-shadow: none; border: 0; padding: 0 0 10px 12px; min-width: 0; }
  .main-nav .is-current > .nav-item > a, .main-nav .is-current > .nav-item > button.nav-link { box-shadow: none; }
}

/* ---------- Hero (home) ---------- */

.hero {
  position: relative; color: #fff; isolation: isolate;
  background: var(--navy-900) url(../img/hero-strada.jpg) center 65% / cover no-repeat;
}
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(100deg, rgba(15, 45, 87, .95) 0%, rgba(24, 69, 128, .85) 45%, rgba(24, 69, 128, .35) 100%);
}
.hero .container { padding-top: clamp(48px, 8vw, 96px); padding-bottom: clamp(56px, 9vw, 110px); }
.hero h1 { color: #fff; max-width: 15em; }
.hero p { font-size: 1.15rem; max-width: 34em; color: #e3ebf6; margin: 0 0 28px; }
.eyebrow {
  display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--navy-900); background: var(--yellow); padding: 4px 10px; border-radius: 999px; margin-bottom: 16px;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 1rem; font-family: inherit;
  text-decoration: none; border: 2px solid transparent; cursor: pointer; line-height: 1.2;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--yellow); color: var(--navy-900); }
.btn-primary:hover { background: #fff27a; color: var(--navy-900); }
.btn-ghost { border-color: rgba(255, 255, 255, .7); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-900); color: #fff; }
.btn-outline { border-color: var(--border); color: var(--navy); background: var(--surface); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }

/* ---------- Sezioni ---------- */

.section { padding: clamp(40px, 6vw, 72px) 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }

.quick-links { margin-top: -48px; position: relative; z-index: 2; }
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .card-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
a.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.card:hover { transform: translateY(-2px); border-color: var(--blue); color: var(--text); }
a.card h3 { margin: 6px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
a.card h3::after { content: "\2192"; color: var(--blue); font-weight: 400; transition: transform .15s; }
a.card:hover h3::after { transform: translateX(3px); }
a.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: var(--navy-050); color: var(--navy);
}
.card-icon svg { width: 26px; height: 26px; }

/* News */
.news-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.news-item { display: flex; flex-direction: column; gap: 8px; }
.news-item time {
  align-self: flex-start; font-size: .8rem; font-weight: 700; color: var(--amber);
  background: var(--amber-bg); padding: 3px 10px; border-radius: 999px;
}
.news-item h3 { margin: 0; }
.news-item .news-body { color: var(--muted); font-size: .97rem; }
.news-item .news-body p { margin: 0 0 .6em; }
.empty { color: var(--muted); }

/* Parola al cittadino */
.feedback {
  display: grid; gap: 24px; grid-template-columns: 1.2fr 1fr; align-items: center;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-900) 100%); color: #fff;
  border-radius: var(--radius); padding: clamp(24px, 4vw, 44px);
}
.feedback h2 { color: #fff; }
.feedback p { color: #dbe5f3; margin: 0; }
.feedback .btn-row { justify-content: flex-end; }
@media (max-width: 760px) {
  .feedback { grid-template-columns: 1fr; }
  .feedback .btn-row { justify-content: flex-start; }
}

/* Aziende */
.partners { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.partner {
  display: grid; place-items: center; min-height: 110px; padding: 16px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.partner:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.partner img { max-height: 64px; width: auto; }

/* ---------- Pagine interne ---------- */

.page-hero { background: var(--navy); color: #fff; padding: 28px 0 32px; }
.page-hero h1 { color: #fff; margin: 0; }
.breadcrumb { font-size: .875rem; margin-bottom: 10px; color: #c7d5ea; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.breadcrumb a { color: #fff; }

.page-layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; padding: 32px 20px 64px; }
@media (max-width: 900px) { .page-layout { grid-template-columns: 1fr; } }

.content-card { padding: clamp(22px, 3vw, 40px); }

.sidebar { display: grid; gap: 16px; position: sticky; top: 96px; }
@media (max-width: 900px) { .sidebar { position: static; } }
.sidebar h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav a {
  display: block; padding: 9px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--navy-900); font-weight: 500;
}
.side-nav a:hover { background: var(--navy-050); }
.side-nav a[aria-current="page"] { background: var(--navy); color: #fff; font-weight: 700; }
.side-contact p { margin: 0 0 6px; font-size: .95rem; }

.download {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius-sm);
  background: var(--navy-050); text-decoration: none; color: var(--navy-900); font-weight: 600; word-break: break-word;
}
.download:hover { background: #dde8f6; color: var(--navy-900); }
.download svg { width: 28px; height: 28px; flex-shrink: 0; color: var(--navy); }

.gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-top: 28px; }
.gallery a { display: block; border-radius: var(--radius-sm); overflow: hidden; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

/* Contenuti HTML provenienti dal CMS (FCKeditor): neutralizzo font e stili in linea datati */
.prose { overflow-wrap: anywhere; }
.prose font, .prose span[style] { font-family: inherit !important; font-size: inherit !important; color: inherit; }
.prose [style*="font-family"] { font-family: inherit !important; }
.prose [style*="font-size"] { font-size: inherit !important; }
.prose div[style*="margin-left"] { margin-left: 0 !important; }
.prose p { margin: 0 0 1em; }
.prose p:empty, .prose p:has(> font:only-child:empty) { display: none; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose h2, .prose h3 { margin-top: 1.4em; }
.prose img { border-radius: var(--radius-sm); }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--border); padding: 6px 10px; }
.prose a[href$=".pdf"], .prose a[href$=".PDF"], .prose a[href$=".doc"], .prose a[href$=".docx"] {
  font-weight: 600;
}
.prose a[href$=".pdf"]::before, .prose a[href$=".PDF"]::before {
  content: "PDF"; display: inline-block; font-size: .65rem; font-weight: 800; letter-spacing: .04em;
  color: #fff; background: #c0392b; border-radius: 4px; padding: 1px 5px; margin-right: 6px; vertical-align: 2px;
}

/* ---------- Form ---------- */

.form-card { padding: clamp(22px, 3vw, 40px); }
.form-intro { color: var(--muted); margin: 0 0 24px; }
fieldset { border: 0; margin: 0 0 28px; padding: 0; min-width: 0; }
legend {
  font-size: 1.15rem; font-weight: 700; color: var(--navy-900); padding: 0; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
legend .step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--yellow); color: var(--navy-900); font-size: .9rem;
}
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.field label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; color: var(--navy-900); }
.field .req { color: #b42318; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: #fff; border: 1px solid #c3ccd7; border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 111, 184, .2); }
.was-validated input:invalid, .was-validated select:invalid, .was-validated textarea:invalid { border-color: #b42318; }
.time-row { display: flex; gap: 8px; align-items: center; }
.time-row select { width: auto; min-width: 84px; }

.rating-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.rating-table th { text-align: left; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 8px 8px; }
.rating-table td { padding: 10px 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.rating-table td:first-child { font-weight: 600; width: 46%; }
.rating-table select { min-width: 0; }
@media (max-width: 700px) {
  .rating-table thead { display: none; }
  .rating-table, .rating-table tbody, .rating-table tr, .rating-table td { display: block; width: 100% !important; }
  .rating-table tr { border-top: 1px solid var(--border); padding: 12px 0; }
  .rating-table td { border: 0; padding: 4px 0; }
  .rating-table td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
}

.consent {
  background: var(--navy-050); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px; font-size: .95rem;
}
.consent label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.consent input[type="checkbox"] { width: 20px; height: 20px; margin-top: 3px; flex-shrink: 0; accent-color: var(--navy); }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.form-error {
  display: none; background: #fdecea; color: #8a1c13; border: 1px solid #f5c2bd;
  border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px;
}
.form-error.is-visible { display: block; }

/* Esito invio */
.result { text-align: center; padding: clamp(32px, 6vw, 64px) 24px; }
.result-icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 18px; background: #e5f5ec; color: #1d7a46; }
.result-icon svg { width: 36px; height: 36px; }
.result p { color: var(--muted); max-width: 32em; margin: 0 auto 24px; }
.result .btn-row { justify-content: center; }

/* ---------- Footer ---------- */

.site-footer { background: var(--navy-900); color: #c7d5ea; font-size: .95rem; margin-top: auto; }
.site-footer a { color: #fff; }
.footer-grid { display: grid; gap: 32px; grid-template-columns: 1.4fr 1fr 1fr; padding: 48px 20px 32px; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.footer-brand img { width: 64px; }
.footer-brand strong { color: #fff; display: block; font-size: 1.05rem; }
.site-footer h2 { color: #fff; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer address { font-style: normal; }
.cert { display: inline-block; background: #fff; border-radius: var(--radius-sm); padding: 6px 10px; margin-top: 10px; }
.cert img { height: 56px; width: auto; display: block; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .12); }
.footer-bottom .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 20px; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .site-header, .site-footer, .sidebar, .skip-link { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
