/* emtest.io: una pagina, nessun font o file esterno (la CSP permette solo questo sito). */

:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --ink: #15181d;
  --muted: #59606b;
  --line: #e2ddd2;
  --accent: #0d5f4f;
  --accent-ink: #ffffff;
  --accent-soft: #d8ebe5;
  --bar: #0d5f4f;
  --danger: #a8321d;
  --danger-soft: #f8e3dd;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgb(20 24 30 / 6%), 0 8px 28px rgb(20 24 30 / 7%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --edge: clamp(20px, 5vw, 64px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111417;
    --surface: #191d21;
    --ink: #eef0f2;
    --muted: #9ba4ae;
    --line: #2a3036;
    --accent: #3fb48e;
    --accent-ink: #08140f;
    --accent-soft: #173a30;
    --bar: #3fb48e;
    --danger: #f08c74;
    --danger-soft: #3b1d17;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 28px rgb(0 0 0 / 28%);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: 3px; }

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

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip {
  position: absolute; left: var(--edge); top: 10px; z-index: 10;
  padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--bg); text-decoration: none;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: calc(1180px + 2 * var(--edge));
  margin-inline: auto;
  padding-inline: var(--edge);
}

/* Barra in alto */
.bar { border-bottom: 1px solid var(--line); }
.bar__in {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 64px;
}
.mark {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px;
  font-weight: 700; font-size: 18px; letter-spacing: -0.01em; text-decoration: none;
}
.mark__dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.tag {
  font: 500 13px/1 var(--mono);
  color: var(--muted);
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px;
}

/* Pagina: a sinistra i numeri, a destra il login */
.page {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "intro intro" "stats login";
  column-gap: clamp(32px, 5vw, 80px);
  row-gap: clamp(24px, 4vh, 44px);
  align-content: start;
  padding-block: clamp(32px, 7vh, 72px) clamp(32px, 6vh, 64px);
}
.intro { grid-area: intro; max-width: 820px; }
.stats { grid-area: stats; min-width: 0; }
.login { grid-area: login; min-width: 0; }

h1 {
  margin: 0;
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 750;
  text-wrap: balance;
}
.lead {
  margin: 18px 0 0;
  max-width: 620px;
  font-size: clamp(17px, 1.4vw, 19px);
  color: var(--muted);
  text-wrap: pretty;
}

/* I numeri */
.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: clamp(28px, 4vw, 56px);
  row-gap: 26px;
  align-items: end;
  align-content: start;
}
.figure { display: grid; gap: 4px; }
.figure__label {
  font-size: 14px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.figure__value {
  display: block;
  font-size: clamp(40px, 4.4vw, 56px);
  line-height: 1;
  font-weight: 720;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  transition: color 0.6s ease;
}
.figure--big .figure__value { font-size: clamp(72px, 9vw, 128px); }
.figure__note { font-size: 14px; color: var(--muted); }
.figure__value.is-new { color: var(--accent); transition: none; }

.regions { grid-column: 1 / -1; }
.regions__title {
  margin: 0 0 12px;
  font-size: 15px; font-weight: 650;
}
.regions__list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
}
.region {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 4.5rem;
  align-items: center; gap: 14px;
  font-size: 15px;
}
.region__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.region__track {
  height: 10px; border-radius: 999px; background: var(--line); overflow: hidden;
}
.region__fill {
  display: block; height: 100%; border-radius: inherit; background: var(--bar);
  transform-origin: left center;
  animation: grow 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.region__count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.regions__empty, .regions__more { margin: 0; font-size: 15px; color: var(--muted); }
.regions__more { margin-top: 10px; }
.status { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--danger); }
.status:empty { display: none; }

/* Il login */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 3vw, 36px);
}
.card h2 {
  margin: 0 0 22px;
  font-size: 22px; line-height: 1.2; letter-spacing: -0.015em; font-weight: 700;
}
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 15px; font-weight: 600; }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.field input:hover { border-color: var(--muted); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field__error { margin: 0; font-size: 14px; color: var(--danger); }

.button {
  justify-self: start;
  min-height: 48px;
  padding: 0 26px;
  font: 650 16px/1 var(--font);
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-s);
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(0 0 0 / 8%);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgb(13 95 79 / 24%); filter: brightness(1.05); }
.button:active { transform: translateY(0) scale(0.98); box-shadow: 0 1px 0 rgb(0 0 0 / 8%); transition-duration: 0.05s; }
.button[aria-busy="true"] { cursor: progress; filter: saturate(0.6); }

.denied {
  display: none;
  margin: 0;
  padding: 12px 14px;
  font-size: 15px; font-weight: 600;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-s);
}
.denied:target, .denied.is-shown { display: block; }
.denied.is-shown { animation: nudge 0.35s ease; }

.fine { margin: 22px 0 0; font-size: 14px; color: var(--muted); }

.foot {
  padding-block: 20px 28px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.foot p { margin: 0; }

/* Entrata della pagina, una volta sola */
.enter { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.enter--1 { animation-delay: 0.08s; }
.enter--2 { animation-delay: 0.16s; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes nudge { 30% { transform: translateX(-4px); } 60% { transform: translateX(3px); } }

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

/* Tablet e telefono: una colonna */
@media (max-width: 900px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "intro" "stats" "login";
  }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; row-gap: 22px; }
  .region { grid-template-columns: minmax(0, 1fr) 5rem 3.5rem; gap: 10px; }
  .button { justify-self: stretch; }
}
