/* ==========================================================================
   Richiesta di audit su misura — [maskai_audit]
   Solo token del design system del tema (style.css §01): qui nessun colore
   nuovo. La barra replica quella della home (front-page.css), così il
   modulo ha lo stesso aspetto anche sulle pagine SEO.
   ========================================================================== */

.mk-audit { display: grid; gap: var(--space-s); width: 100%; }
.mk-audit .field-error[hidden] { display: none; }

/* ---- Passo 1: la barra -------------------------------------------------- */
.mk-audit .audit-bar {
  display: grid;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(11, 26, 44, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  overflow: hidden;
}
.mk-audit .audit-bar .field { position: relative; gap: 2px; padding: 0.6rem 1.1rem 0.72rem; }
.mk-audit .audit-bar .field + .field { border-top: 1px solid var(--line); }
@media (min-width: 720px) {
  .mk-audit .audit-bar { grid-template-columns: 1.15fr 1fr auto; align-items: stretch; }
  .mk-audit .audit-bar .field + .field { border-top: 0; border-left: 1px solid var(--line); }
}
.mk-audit .audit-bar .field > label {
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-soft);
  transition: color var(--dur-fast) ease;
}
.mk-audit .audit-bar .field:focus-within > label { color: var(--cobalt); }
.mk-audit .audit-bar .input {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 1.02rem;
  font-weight: 620;
}
.mk-audit .audit-bar .input:focus-visible { outline: none; }
.mk-audit .audit-bar .field::after {
  content: "";
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 0.45rem;
  height: 2px;
  border-radius: 2px;
  background: var(--cobalt);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 240ms var(--ease-out);
}
.mk-audit .audit-bar .field:focus-within::after { transform: scaleX(1); }
.mk-audit .audit-bar .field.has-error > label { color: var(--red-error); }
.mk-audit .audit-bar .field.has-error::after { transform: scaleX(1); background: var(--red-error); }
.mk-audit .audit-bar .btn { min-height: 100%; border-radius: 0; padding-inline: 1.7rem; }
@media (max-width: 719.98px) {
  .mk-audit .audit-bar .btn { min-height: 52px; }
}

/* ---- Passo 2: la finestra ---------------------------------------------- */
html.mk-dialog-open { overflow: hidden; scrollbar-gutter: stable; }

.mk-audit__dialog {
  width: min(44rem, calc(100% - 2 * var(--space-m)));
  max-width: none;
  max-height: min(90dvh, 54rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--white);
  color: var(--ink);
  text-align: left; /* il pannello audit della home centra tutto: qui no */
  box-shadow: 0 30px 80px rgba(11, 26, 44, 0.28);
  overflow: hidden;
}
/* Entrata con keyframes: più affidabili di @starting-style su ::backdrop */
.mk-audit__dialog[open] { animation: mk-sheet-in 260ms var(--ease-out); }
.mk-audit__dialog::backdrop { background: rgba(11, 26, 44, 0.55); }
.mk-audit__dialog[open]::backdrop { animation: mk-fade-in 260ms var(--ease-out); }
@keyframes mk-sheet-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
}
@keyframes mk-fade-in {
  from { opacity: 0; }
}

/* Su telefono la finestra sale dal basso, come un foglio */
@media (max-width: 599.98px) {
  .mk-audit__dialog {
    width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
  }
  .mk-audit__dialog[open] { animation-name: mk-sheet-up; }
}
@keyframes mk-sheet-up {
  from { transform: translateY(100%); }
}

.mk-audit__sheet {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: inherit;
}
.mk-audit__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-m);
  padding: var(--space-xl) var(--space-xl) var(--space-l);
  border-bottom: 1px solid var(--line);
}
.mk-audit__for {
  font-size: var(--size-caption);
  font-weight: 650;
  color: var(--cobalt);
  overflow-wrap: anywhere;
}
.mk-audit__title {
  font-size: var(--size-h3);
  font-stretch: 115%;
  font-weight: 740;
  letter-spacing: -0.015em;
  line-height: var(--leading-heading);
  text-wrap: balance;
}
.mk-audit__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, transform var(--dur-press) var(--ease-out);
}
.mk-audit__close:active { transform: scale(0.97); }
.mk-audit__close:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }

.mk-audit__body {
  display: grid;
  gap: var(--space-l);
  padding: var(--space-l) var(--space-xl);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mk-audit__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-s) var(--space-m);
  padding: var(--space-m) var(--space-xl);
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.mk-audit__foot .field-error { flex: 1 1 16rem; }
@media (max-width: 599.98px) {
  .mk-audit__head, .mk-audit__body, .mk-audit__foot { padding-inline: var(--space-l); }
  .mk-audit__foot .btn { width: 100%; justify-content: center; }
}

.mk-audit__group { border: 0; padding: 0; margin: 0; min-width: 0; }
.mk-audit__group > legend {
  padding: 0;
  margin-bottom: var(--space-xs);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
}
.mk-audit__pair { display: grid; gap: var(--space-m); }
@media (min-width: 600px) {
  .mk-audit__pair { grid-template-columns: 1fr 1fr; }
}
.mk-audit select.input { appearance: auto; cursor: pointer; }
.mk-audit__body textarea.input { min-height: 5.5rem; }
.mk-opt { font-weight: 500; font-size: var(--size-caption); color: var(--ink-soft); }
.mk-audit__social[hidden] { display: none; }

/* ---- Chip: aree e tempi ------------------------------------------------- */
.mk-chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.mk-chip { position: relative; display: inline-flex; }
.mk-chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.mk-chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  min-height: 42px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  transition:
    background-color var(--dur-fast) ease,
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
}
/* Casella: quadrata per le aree (più scelte), tonda per i tempi (una sola) */
.mk-chip span::before {
  content: "";
  flex: none;
  width: 0.85em;
  height: 0.85em;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  opacity: 0.45;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.mk-chip--radio span::before { border-radius: 50%; }
.mk-chip input:checked + span {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: var(--text-on-dark);
}
.mk-chip input:checked + span::before {
  background: var(--green-signal);
  border-color: var(--green-signal);
  opacity: 1;
}
.mk-chip input:focus-visible + span { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.mk-chip input:active + span { transform: scale(0.97); }
.mk-chips--solo { border-top: 1px solid var(--line); padding-top: var(--space-m); }
.mk-chip--all span { border-style: dashed; }
.mk-chip--all input:checked + span { border-style: solid; }

@media (hover: hover) {
  .mk-chip input:not(:checked):hover + span { border-color: var(--ink-soft); }
  .mk-audit__close:hover { border-color: var(--ink-soft); }
}

@media (prefers-reduced-motion: reduce) {
  .mk-audit__dialog[open],
  .mk-audit__dialog[open]::backdrop { animation: none; }
  .mk-chip span { transition: none; }
}
