:root {
  --background: #f7f7f8;
  --surface: #ffffff;
  --surface-subtle: #eef1f4;
  --text: #141414;
  --muted: #5c6570;
  --border: #e3e5e8;
  --accent: #005ac7;
  --accent-soft: #e7f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html[data-embed],
html[data-embed] body {
  background: transparent;
}

body {
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

h1, h2, p { margin: 0; }

a { color: var(--accent); }

.page {
  width: min(100% - 24px, 680px);
  margin: 0 auto;
  padding: 12px 0 28px;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  background: var(--surface);
  color: var(--text);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}

.skip:focus { transform: none; }

:focus-visible {
  outline: 3px solid rgba(0, 90, 199, 0.28);
  outline-offset: 2px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 2px 2px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.65rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.lede {
  max-width: 34rem;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.publisher-payoff {
  flex: 0 0 auto;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

.publisher-payoff strong,
.publisher-payoff a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.panel {
  margin-top: 18px;
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.winner { border-top: 3px solid var(--accent); }

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-subtle);
}

.segment button {
  appearance: none;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3d4450;
  font-size: 0.92rem;
  font-weight: 650;
  cursor: pointer;
}

.segment button[aria-checked="true"] {
  background: var(--accent);
  color: #fff;
}

label {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 650;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#challenge { margin-top: 12px; }

#challenge:empty {
  display: none;
  margin-top: 0;
}

.search-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: var(--surface);
  font-size: 1rem;
}

.search-row input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(0, 90, 199, 0.16);
}

#search, #locate, .choice {
  appearance: none;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
}

#search {
  flex: 0 0 auto;
  padding: 0 16px;
  border: 0;
  background: var(--accent);
  color: #fff;
}

#search:hover { background: #004a9e; }

#search:disabled, #locate:disabled { opacity: 0.6; cursor: default; }

#locate, .choice {
  width: 100%;
  margin-top: 8px;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

#locate { text-align: center; }

#locate:hover, .choice:hover { border-color: var(--accent); color: var(--accent); }

.hint, .note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

form .hint { margin-top: 10px; }

#status { margin-top: 14px; color: var(--muted); }

#error {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

#choices { margin-top: 18px; }

.lead {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: clamp(3rem, 12vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.unit {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0;
}

#result-title, .card-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

#result-where, .card-where { margin-top: 4px; }

#result-distance, .card-distance { margin-top: 6px; }

.warning {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
}

.map-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 14px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.map-link:hover { border-color: var(--accent); color: var(--accent); }

#result-meta { margin-top: 12px; }

.road .hint { margin: 6px 0 12px; }

#others {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

#others li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 12px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

#others .card-title {
  display: block;
  font-size: 1rem;
}

.row-price { padding-top: 2px; }

.map-link.row-link {
  width: fit-content;
  margin-top: 8px;
}

.row-price {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.row-link { grid-column: 2; }

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

details { margin-top: 22px; padding: 0 2px; }

summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 44px;
  display: flex;
  align-items: center;
}

details p { margin-top: 8px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

footer {
  margin-top: 18px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

footer p + p, noscript { margin-top: 6px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

#result .panel { animation: rise 0.35s ease; }

@media (prefers-reduced-motion: reduce) {
  #result .panel { animation: none; }
}

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

@media (max-width: 560px) {
  .page { width: min(100% - 16px, 680px); }
  .masthead { display: grid; gap: 10px; }
  .publisher-payoff { margin: 0; text-align: left; white-space: normal; }
  .panel { padding: 18px 16px; }
  .search-row { flex-direction: column; }
  #search { width: 100%; }
}

/* Nel pezzo dell'articolo il riquadro si appoggia al testo, senza carta e senza payoff. */
html[data-embed] .page {
  width: 100%;
  margin: 0;
  padding: 12px 0 8px;
  border-top: 3px solid var(--accent);
}

html[data-embed] .publisher-payoff { display: none; }

html[data-embed] .masthead {
  display: block;
  padding: 0;
}

html[data-embed] .lede {
  max-width: none;
  margin-top: 6px;
  color: #3a4150;
}

html[data-embed] h1 {
  font-size: clamp(1.35rem, 4.2vw, 1.7rem);
}

html[data-embed] .panel {
  margin-top: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

html[data-embed] .search-row {
  flex-direction: row;
  gap: 8px;
}

html[data-embed] #search { width: auto; }

html[data-embed] .winner {
  margin-top: 18px;
  padding-top: 4px;
}

html[data-embed] details {
  border-top: 1px solid var(--border);
}

html[data-embed] footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 400px) {
  html[data-embed] .search-row { flex-direction: column; }
  html[data-embed] #search { width: 100%; }
}
