/* Selfcare: foglio di stile unico per portale e amministrazione.
   Nessuna risorsa esterna: font e grafica sono inclusi nel progetto. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --red: #c8242b;        /* il rosso del logo */
  --red-dark: #a61b22;
  --accent: #b81f27;     /* rosso per testi e link: più scuro, per la leggibilità */
  --accent-soft: #fbeced;
  --paper: #faf9f9;
  --panel: #ffffff;
  --surface: #ffffff;
  --text: #1f1a1b;
  --muted: #675e60;
  --line: #e7e0e0;
  --line-strong: #b3a8aa;
  --ok: #1c7a4a;
  --ok-soft: #e4f3ea;
  --bad: #8e1b16;
  --bad-soft: #fbeae8;
  --warn: #7d5200;
  --warn-soft: #fff3d1;
  --btn-bg: var(--red);
  --btn-fg: #ffffff;
  --btn-hover: var(--red-dark);
  --focus: #c8242b;
  --display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff8a8f;
    --accent-soft: #3a1a1c;
    --paper: #151213;
    --panel: #1b1617;
    --surface: #211c1d;
    --text: #f3edee;
    --muted: #b5a9ab;
    --line: #3a3133;
    --line-strong: #6e6163;
    --ok: #6fd39b;
    --ok-soft: #14301f;
    --bad: #ff9a90;
    --bad-soft: #3a1512;
    --warn: #f3c969;
    --warn-soft: #33270a;
    --btn-bg: #d32f37;
    --btn-hover: #e0434a;
    --focus: #ff8a8f;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.6rem); line-height: 1.08; font-weight: 700; }
h2 { font-size: 1.2rem; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; }
[hidden] { display: none !important; }

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

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nowrap { white-space: nowrap; }

.icon { width: 1.5rem; height: 1.5rem; flex: none; }
.icon__slash { display: none; }

/* ------------------------------------------------------------ struttura pubblica */

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(20rem, 40%) 1fr;
}

.brand {
  overflow: hidden;
  isolation: isolate;
  background: var(--panel);
  color: var(--text);
  border-right: 1px solid var(--line);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  /* Su schermi larghi il pannello resta fermo mentre il modulo scorre. */
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

/* Sfondo a tema LAN party: una piastrella vettoriale ripetuta, che sfuma
   dove compaiono logo e nome. */
.brand__art {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("../img/lanparty.svg") 0 0 / 30rem auto;
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent 72%);
  mask-image: linear-gradient(to bottom, #000 35%, transparent 72%);
  pointer-events: none;
}

.brand__id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
  margin-top: auto;
}
.brand__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.4rem, 1.4rem + 3.6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
}
.brand__org { font-size: 1.05rem; color: var(--muted); }
.brand__logo { display: block; margin-bottom: 1.1rem; }
.brand__logo img { display: block; height: clamp(5.5rem, 9vw, 7.5rem); width: auto; max-width: 14rem; }
.brand__help { font-size: 0.95rem; color: var(--muted); }
.brand__help strong { color: var(--text); font-weight: 600; }

.stage {
  display: flex;
  align-items: center;
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1.25rem, 5vw, 4rem);
  padding-bottom: max(clamp(1.5rem, 5vw, 4rem), env(safe-area-inset-bottom));
}
.stage__inner { width: 100%; max-width: 29rem; margin-inline: auto; }
.stage__inner > * + * { margin-top: 1.25rem; }
.stage__help { display: none; color: var(--muted); font-size: 0.95rem; }

@media (max-width: 52rem) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .brand { position: relative; height: auto; padding: 1.1rem 1.25rem; min-height: 0; padding-top: max(1.1rem, env(safe-area-inset-top)); border-right: 0; border-bottom: 1px solid var(--line); }
  .brand__id { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 0.9rem; row-gap: 0; }
  .brand__id .brand__org { flex-basis: 100%; }
  .brand__art {
    background-size: 19rem auto;
    background-position: right -0.5rem top 0.2rem;
    -webkit-mask-image: linear-gradient(to right, transparent 56%, #000 92%);
    mask-image: linear-gradient(to right, transparent 56%, #000 92%);
  }
  .brand__name { font-size: 2.1rem; }
  .brand__org { font-size: 0.95rem; }
  .brand__logo { margin-bottom: 0; }
  .brand__logo img { height: 4rem; }
  .brand__help { display: none; }
  .stage { align-items: flex-start; }
  .stage__help { display: block; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
}

/* ------------------------------------------------------------ testi */

.prose { color: var(--muted); max-width: 34rem; }
.prose > * + * { margin-top: 0.75rem; }
.prose strong { color: var(--text); font-weight: 650; }
.prose ul { margin: 0; padding-left: 1.2rem; }
.prose li + li { margin-top: 0.3rem; }
.prose--small { font-size: 0.95rem; }
.lede { color: var(--muted); max-width: 44rem; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: -0.4rem;
  padding: 0.35rem 0.6rem 0.35rem 0.2rem;
  color: var(--muted);
  font-weight: 550;
  text-decoration: none;
  border-radius: 8px;
}
.back:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.back .icon { width: 1.25rem; height: 1.25rem; }

.aside { font-size: 0.98rem; color: var(--muted); }
.actions { padding-top: 0.5rem; }

/* ------------------------------------------------------------ scelte della pagina iniziale */

.choices { display: grid; gap: 0.75rem; padding-top: 0.5rem; }
.choice {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1rem 1.1rem 1.1rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, translate 0.15s;
}
.choice:hover { border-color: var(--accent); }
.choice:hover .icon--chevron { translate: 3px 0; }
.choice__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.choice__text { display: grid; gap: 0.15rem; flex: 1; min-width: 0; }
.choice__text strong { font-family: var(--display); font-size: 1.15rem; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }
.choice__text span { color: var(--muted); font-size: 0.97rem; line-height: 1.4; }
.icon--chevron { color: var(--line-strong); transition: translate 0.15s; }

/* ------------------------------------------------------------ moduli */

.form { display: grid; gap: 1.1rem; padding-top: 0.25rem; }
.field { display: grid; gap: 0.4rem; min-width: 0; }
.field label { font-weight: 620; font-size: 0.98rem; }
.field__hint { color: var(--muted); font-size: 0.92rem; line-height: 1.4; }

input[type="text"], input[type="password"], input[type="email"], input[type="url"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-size: 1.0625rem; /* mai sotto 16px: evita lo zoom automatico su iPhone */
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  appearance: none;
}
textarea { min-height: 0; line-height: 1.5; resize: vertical; }
select {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a86a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1.25rem;
}
input::placeholder, textarea::placeholder { color: var(--line-strong); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 0;
  border-color: var(--focus);
  border-radius: 10px;
}
input[type="file"] { font: inherit; font-size: 0.95rem; color: var(--muted); max-width: 100%; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.95rem !important; }
.code { font-size: 1.6rem !important; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

.reveal { position: relative; }
.reveal input { padding-right: 3.4rem; }
.reveal__btn {
  position: absolute;
  inset: 0 0 0 auto;
  width: 3.25rem;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  border-radius: 10px;
}
.reveal__btn:hover { color: var(--text); }
.reveal__btn[aria-pressed="true"] .icon__slash { display: inline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.7rem 1.5rem;
  font: inherit;
  font-weight: 650;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1.5px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s;
}
.btn:hover { background: var(--btn-hover); }
.btn[disabled] { opacity: 0.7; cursor: progress; }
.form > .btn { width: 100%; margin-top: 0.4rem; }
.btn--quiet { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--quiet:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.btn--danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.btn--danger:hover { background: var(--bad-soft); }
.btn--small { min-height: 2.4rem; padding: 0.3rem 0.85rem; font-size: 0.92rem; }

.notice {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-weight: 520;
  line-height: 1.45;
}
.notice .icon { margin-top: 0.05rem; }
.notice--bad { background: var(--bad-soft); color: var(--bad); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--ok { background: var(--ok-soft); color: var(--ok); }

/* Elenco dei requisiti, aggiornato mentre si scrive */
.rules {
  padding: 1rem 1.1rem;
  background: color-mix(in srgb, var(--surface) 70%, var(--paper));
  border: 1.5px solid var(--line);
  border-radius: 10px;
}
.rules__title { font-weight: 620; font-size: 0.98rem; margin-bottom: 0.5rem; }
.rules ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.rules li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.4;
}
.rules li .icon {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.08rem;
  padding: 0.15rem;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: transparent;
  stroke-width: 3;
}
.rules li.is-ok { color: var(--text); }
.rules li.is-ok .icon { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.rules .prose { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }

.seal {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.seal .icon { width: 2rem; height: 2rem; }
.seal--ok { background: var(--ok-soft); color: var(--ok); }
.seal--warn { background: var(--warn-soft); color: var(--warn); }
.seal--bad { background: var(--bad-soft); color: var(--bad); }

/* Attivazione MFA */
.steps { margin-bottom: 0; padding-left: 1.3rem; color: var(--muted); display: grid; gap: 0.9rem; }
.steps strong { color: var(--text); }
.steps li::marker { font-family: var(--display); font-weight: 700; color: var(--text); }
.qrbox {
  width: 13rem;
  max-width: 100%;
  margin: 0.9rem 0 0.6rem;
  padding: 0.5rem;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
}
.qr { display: block; width: 100%; height: auto; }
.manual summary { cursor: pointer; color: var(--accent); font-weight: 550; }
.manual p { margin-top: 0.5rem; }
.manual__key {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--text);
  font-size: 1rem;
  word-spacing: 0.25em;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ amministrazione */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
  padding-top: max(0.7rem, env(safe-area-inset-top));
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.bar__id { display: flex; align-items: center; gap: 0.6rem; color: inherit; text-decoration: none; min-width: 0; }
.bar__id strong { font-family: var(--display); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.bar__id span { color: var(--muted); font-size: 0.95rem; }
.bar__id img { height: 2.4rem; width: auto; }
.bar__user { display: flex; align-items: center; gap: 0.8rem; font-size: 0.95rem; color: var(--muted); }

.admin__body {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  max-width: 82rem;
  margin-inline: auto;
}
.menu {
  position: sticky;
  top: 4.2rem;
  align-self: start;
  display: grid;
  gap: 0.15rem;
  padding: 1.75rem 1rem 2rem clamp(1rem, 3vw, 2rem);
}
.menu a {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 520;
}
.menu a:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.menu__label { margin: 1rem 0 0.2rem; padding-inline: 0.8rem; font-size: 0.85rem; color: var(--muted); }
.menu__out { margin-top: 1rem; color: var(--accent) !important; }

.content { padding: 2rem clamp(1rem, 3vw, 2.5rem) 5rem; min-width: 0; }
.content > * + * { margin-top: 1.5rem; }
.content h1 { font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.2rem); }

@media (max-width: 56rem) {
  .admin__body { grid-template-columns: minmax(0, 1fr); }
  .menu {
    position: static;
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .menu a { white-space: nowrap; }
  .menu__label { display: none; }
  .menu__out { margin-top: 0; }
  .bar__id span, .bar__user span { display: none; }
  .content { padding-top: 1.5rem; }
  .savebar .btn { flex: 1 1 auto; min-height: 2.9rem; padding-inline: 1rem; }
}

.settings { display: grid; gap: 1.5rem; }
.group {
  display: grid;
  gap: 1.1rem;
  padding: clamp(1.1rem, 2.5vw, 1.75rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.group, .settings, .form { grid-template-columns: minmax(0, 1fr); }
.group > .field, .group > .toggle, .group > .btn { max-width: 38rem; }
.group > .btn { justify-self: start; }
.group__note { color: var(--muted); font-size: 0.97rem; max-width: 44rem; }
.field--short { max-width: 16rem !important; }

.toggle { display: flex; gap: 0.9rem; align-items: flex-start; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track {
  flex: none;
  width: 2.9rem;
  height: 1.7rem;
  margin-top: 0.1rem;
  border-radius: 1rem;
  background: var(--line-strong);
  position: relative;
  transition: background-color 0.15s;
}
.toggle__track::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #fff;
  transition: translate 0.15s;
}
.toggle input:checked + .toggle__track { background: var(--ok); }
.toggle input:checked + .toggle__track::after { translate: 1.2rem 0; }
.toggle input:focus-visible + .toggle__track { outline: 3px solid var(--focus); outline-offset: 2px; }
.toggle__text { display: grid; gap: 0.1rem; }
.toggle__text strong { font-weight: 620; }
.toggle__text span { color: var(--muted); font-size: 0.93rem; line-height: 1.4; }

.check { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500 !important; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--red); }
.logo-now { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo-now .brand__logo { margin: 0; }
.logo-now .brand__logo img { height: 4.5rem; }

.savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.9rem 0;
  padding-bottom: max(0.9rem, env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.checks { list-style: none; margin: 0; padding: 0; display: grid; }
.checks li { display: flex; align-items: center; gap: 0.9rem; padding: 0.8rem 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; padding-top: 0; }
.checks li:last-child { padding-bottom: 0; }
.checks__mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; flex: none; }
.is-ok .checks__mark { background: var(--ok-soft); color: var(--ok); }
.is-todo .checks__mark { background: var(--warn-soft); color: var(--warn); }
.checks__mark .icon { width: 1.25rem; height: 1.25rem; }
.checks__text { display: grid; flex: 1; min-width: 0; }
.checks__text span { color: var(--muted); font-size: 0.93rem; }
.checks a { white-space: nowrap; font-weight: 550; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.stats dt { color: var(--muted); font-size: 0.93rem; }
.stats dd { margin: 0; font-family: var(--display); font-size: 2.1rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }

.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.content > .table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th { text-align: left; font-weight: 620; color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.table th, .table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.group .table th:first-child, .group .table td:first-child { padding-left: 0; }
.table__detail { color: var(--muted); min-width: 14rem; overflow-wrap: anywhere; }
.table__actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.5rem; background: var(--ok); }
.dot--bad { background: var(--bad); }
.empty { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.filters .field { flex: 1 1 13rem; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.95rem; }
.pager span { margin-right: auto; }

.result { padding: 1.1rem 1.25rem; border-radius: var(--radius); display: grid; gap: 0.75rem; }
.result--ok { background: var(--ok-soft); }
.result--bad { background: var(--bad-soft); }
.result--ok h2 { color: var(--ok); }
.result--bad h2 { color: var(--bad); }
.result dl { margin: 0; display: grid; gap: 0.35rem; }
.result dl div { display: grid; grid-template-columns: 11rem 1fr; gap: 0.75rem; }
.result dt { color: var(--muted); }
.result dd { margin: 0; overflow-wrap: anywhere; }
.result__detail { font-family: ui-monospace, Consolas, monospace; font-size: 0.88rem; overflow-wrap: anywhere; }
@media (max-width: 40rem) { .result dl div { grid-template-columns: 1fr; gap: 0; } }

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

@media print {
  .brand__art, .menu, .savebar, .bar__user { display: none; }
}
