/* Codice Fiscale Facile — mobile-first, no frameworks */
:root {
  --ink: #0f1f24;
  --ink-soft: #3a4f56;
  --muted: #5c727a;
  --line: #d5e2e6;
  --surface: #ffffff;
  --bg0: #eef6f7;
  --bg1: #f7fbfc;
  --teal: #0a7a7a;
  --teal-dark: #065858;
  --teal-soft: #d8efef;
  --coral: #e85d4c;
  --ok: #1a7a4c;
  --ok-bg: #e6f6ee;
  --ko: #b42318;
  --ko-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 31, 36, 0.08);
  --tap: 48px;
  --font: "Segoe UI", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
  --max: 720px;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfecec 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #dce9f2 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 280px, #f9fcfc);
  min-height: 100vh;
  overflow-x: hidden;
}

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

a {
  color: var(--teal-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover { color: var(--teal); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(247, 251, 252, 0.88);
  border-bottom: 1px solid rgba(213, 226, 230, 0.8);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  min-height: var(--tap);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--teal), #0c5f6a);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(0.78rem, 3.2vw, 1.02rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-tag {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.nav-toggle {
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  display: grid;
  place-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.nav-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 1rem 1rem;
  box-shadow: var(--shadow);
}

.nav-menu.is-open { display: block; }

.nav-menu a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.5rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  border-radius: 10px;
}

.nav-menu a:hover { background: var(--teal-soft); }

/* Layout */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem;
}

.hero {
  padding: 1.5rem 0 0.75rem;
  text-align: left;
}

.hero-brand {
  font-family: var(--display);
  font-size: clamp(1.85rem, 7vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 0.55rem;
  color: var(--ink);
  background: linear-gradient(100deg, var(--ink) 40%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero-brand { color: var(--ink); }
}

.hero h1 {
  font-family: var(--display);
  font-size: clamp(1.15rem, 4.2vw, 1.45rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
}

.hero-lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 36rem;
}

/* Ad slots — reserved height, never push calc on mobile awkwardly */
.ad-slot {
  margin: 0.85rem auto;
  max-width: var(--max);
  padding: 0 1rem;
}

.ad-slot-inner {
  min-height: 50px;
  border: 1px dashed #c5d5da;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.45);
  color: #8aa0a8;
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ad-slot--side { display: none; }

/* On mobile, keep ads below the tool only */
.ad-slot--after-tool { margin-top: 0.25rem; }

/* Tool card */
.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 1rem 0 1.5rem;
  animation: rise 0.45s ease-out both;
}

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

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f0f6f7;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: var(--tap);
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.tab.is-active {
  color: var(--teal-dark);
  background: var(--surface);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
}

.panel { padding: 1.1rem 1rem 1.25rem; }

.form-grid {
  display: grid;
  gap: 0.9rem;
}

.field label,
.field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field input[type="search"],
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.sex-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.sex-option {
  position: relative;
}

.sex-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.sex-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.sex-option input:checked + span {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.sex-option input:focus-visible + span {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Autocomplete */
.ac-wrap { position: relative; }

.ac-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.35rem;
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.ac-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

.ac-list li.is-active,
.ac-list li:hover {
  background: var(--teal-soft);
}

.ac-name { font-weight: 600; }
.ac-code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  border: 0;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, #0d8888, var(--teal-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(10, 122, 122, 0.28);
}

.btn-primary:hover { background: linear-gradient(180deg, #0a7a7a, #044848); }

.btn-secondary {
  background: #fff;
  color: var(--teal-dark);
  border: 1.5px solid var(--line);
}

.btn-secondary.is-copied {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #b7e0c8;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}

.form-note {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.alert {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--ko-bg);
  color: var(--ko);
  font-weight: 600;
  font-size: 0.92rem;
}

/* Result */
.result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #e8f6f6, #f4fbfb);
  border: 1px solid #c5e4e4;
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.result-label {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cf-code {
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: clamp(1.25rem, 5.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  word-break: break-all;
  line-height: 1.3;
  color: var(--ink);
}

.result-actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.result-actions .btn { flex: 1 1 auto; min-width: 120px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 750;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-ko { background: var(--ko-bg); color: var(--ko); }

.decode-list {
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

.decode-list > div {
  display: grid;
  gap: 0.15rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.decode-list > div:last-child { border-bottom: 0; padding-bottom: 0; }

.decode-list dt {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.decode-list dd { margin: 0; font-weight: 600; }

.mono {
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.04em;
}

/* Content sections */
.section {
  padding: 1.75rem 0;
}

.section h2 {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.65rem;
}

.section p { color: var(--ink-soft); margin: 0 0 0.85rem; }

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 0.75rem;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 0.9rem 0.9rem 0.9rem 3.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0.75rem;
  top: 0.85rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}

.steps strong { display: block; margin-bottom: 0.2rem; color: var(--ink); }

/* FAQ */
.faq-list { display: grid; gap: 0.55rem; }

.faq-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.faq-item > button {
  width: 100%;
  min-height: var(--tap);
  text-align: left;
  padding: 0.85rem 2.75rem 0.85rem 1rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  position: relative;
}

.faq-item > button::after {
  content: "+";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  color: var(--teal);
  font-weight: 400;
}

.faq-item.is-open > button::after { content: "−"; }

.faq-body {
  display: none;
  padding: 0 1rem 1rem;
  color: var(--ink-soft);
}

.faq-item.is-open .faq-body { display: block; }

/* Pages */
.page-hero {
  padding: 1.5rem 0 0.5rem;
}

.page-hero h1 {
  font-family: var(--display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}

.prose {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1rem 1.35rem;
  margin: 1rem 0 2rem;
  box-shadow: var(--shadow);
}

.prose h2 {
  font-size: 1.15rem;
  margin: 1.25rem 0 0.5rem;
}

.prose h2:first-child { margin-top: 0; }

.prose p, .prose li { color: var(--ink-soft); }
.prose ul { padding-left: 1.2rem; }

/* Footer */
.site-footer {
  margin-top: 2rem;
  padding: 1.75rem 0 6.5rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.footer-grid {
  display: grid;
  gap: 1.25rem;
}

.footer-brand {
  font-weight: 800;
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}

.footer-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-nav {
  display: grid;
  gap: 0.15rem;
}

.footer-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  text-decoration: none;
  font-weight: 600;
  color: var(--ink-soft);
}

.disclaimer {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: rgba(15, 31, 36, 0.96);
  color: #e8f2f4;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.2);
}

.cookie-inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  gap: 0.75rem;
}

.cookie-banner p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.cookie-banner a { color: #9fe0e0; }

.cookie-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.cookie-actions .btn { width: 100%; }

.cookie-actions .btn-primary {
  background: var(--teal);
  box-shadow: none;
}

.cookie-actions .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

/* Tablet+ */
@media (min-width: 640px) {
  .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
  }

  .panel { padding: 1.35rem 1.35rem 1.5rem; }

  .cookie-inner {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .cookie-actions {
    grid-template-columns: auto auto;
  }

  .cookie-actions .btn { width: auto; min-width: 120px; }

  .site-footer { padding-bottom: 2.5rem; }

  .footer-grid {
    grid-template-columns: 1.4fr 1fr;
  }
}

@media (min-width: 900px) {
  .nav-toggle { display: none; }

  .nav-menu {
    display: flex !important;
    position: static;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    gap: 0.25rem;
  }

  .nav-menu a {
    min-height: 40px;
    padding: 0 0.7rem;
    font-size: 0.92rem;
  }

  .page-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 160px;
    gap: 1.25rem;
    align-items: start;
  }

  .ad-slot--side {
    display: block;
    position: sticky;
    top: 5.5rem;
    padding: 0;
    margin: 1rem 0;
  }

  .ad-slot--side .ad-slot-inner {
    min-height: 250px;
  }

  .ad-slot--top { grid-column: 1 / -1; }
}

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