/* Same world as davidegiacomel.space: violet, lime highlight, ink frames, Bricolage Grotesque.
   WHY a frame of ruled cells: Davide drew the pages that way on the whiteboard (2026-11-09).
   WHY the font is served from here: the CSP allows no external request. Bricolage Grotesque, SIL Open Font License. */
@font-face {
  font-family: "Bricolage Grotesque"; src: url("/bricolage.woff2") format("woff2");
  font-weight: 300 800; font-style: normal; font-display: swap;
}
:root {
  --hero: oklch(0.70 0.14 280);
  --ink: oklch(0.21 0.05 276);
  --ink-soft: oklch(0.33 0.05 276);
  --bg: oklch(1 0 0);
  --surface: oklch(0.965 0.012 280);
  --tint: oklch(0.88 0.055 280);
  --muted: oklch(0.47 0.03 276);
  --line: oklch(0.89 0.02 280);
  --accent: oklch(0.93 0.18 118);
  --accent-soft: oklch(0.97 0.06 118);
  --gain: oklch(0.82 0.22 148);
  --on-dark: oklch(0.97 0.01 280);
  --bad: oklch(0.47 0.17 27);
  --bad-bg: oklch(0.96 0.025 27);
  --wait: oklch(0.42 0.14 280);
  --rule: 2px solid var(--ink);
  --cell-x: clamp(1rem, 2.2vw, 1.75rem);
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
  accent-color: var(--wait);
  scrollbar-color: var(--ink) var(--hero);
}
* { box-sizing: border-box; }
/* WHY: .button and .cell set display, which would otherwise beat the hidden attribute */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--hero); }
body {
  margin: 0; color: var(--ink); caret-color: var(--wait);
  font: 400 1rem/1.5 "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
::selection { background: var(--ink); color: var(--accent); }
:focus-visible { outline: 2px solid var(--wait); outline-offset: 2px; }
a { color: var(--ink); text-underline-offset: 3px; }
p { margin: 0; }
.wrap { max-width: 76rem; margin-inline: auto; padding-inline: clamp(.75rem, 3vw, 2rem); }
.skip { position: absolute; left: -999rem; }
a.skip:focus { left: 1rem; top: .75rem; padding: .4rem .8rem; background: var(--ink); color: var(--on-dark); border-radius: 999px; z-index: 1; }
main { padding-block: clamp(.75rem, 3vw, 2.5rem) clamp(2rem, 5vw, 4rem); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

h1, h2 { margin: 0; font-weight: 750; line-height: 1.05; letter-spacing: -0.03em; text-wrap: balance; }
.title { margin-block: clamp(.75rem, 2vw, 1.5rem) clamp(1.25rem, 3vw, 2.25rem); font-size: clamp(2.6rem, 7vw, 5.5rem); letter-spacing: -0.035em; }
.mark {
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 88% / 100% 0.32em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  padding-inline: .06em;
}

/* ---------- the frame ---------- */
.sheet { background: var(--bg); border: var(--rule); border-radius: 1.5rem; overflow: clip; box-shadow: 0 1.5rem 3rem -2rem oklch(0.21 0.05 276 / 0.7); }
/* WHY: the frame clips its corners, and would also cut an open explanation that does not fit inside it */
.sheet:has(.help:hover), .sheet:has(.help button:focus) { overflow: visible; }
.sheet > .go, .sheet > .head { border-radius: calc(1.5rem - 2px) calc(1.5rem - 2px) 0 0; }
.cells { display: grid; grid-template-columns: minmax(0, 1fr) clamp(15rem, 30%, 22rem); }
.cells > * + * { border-left: var(--rule); }
.pad { padding: clamp(1.25rem, 2.5vw, 2rem) var(--cell-x); border-top: var(--rule); }

.strip { background: var(--ink); color: var(--on-dark); font-size: .9rem; }
.strip .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .1rem 1.5rem; padding-block: .85rem; }
.strip a { color: inherit; font-weight: 650; }
.strip a:hover { color: var(--accent); }
.strip a:focus-visible { outline-color: var(--accent); }

.head { background: var(--tint); }
.head h1 { padding: clamp(1.25rem, 3vw, 2.25rem) var(--cell-x); font-size: clamp(2.1rem, 4.6vw, 3.75rem); }
.head h1.described { font-size: clamp(1.3rem, 2.2vw, 1.75rem); line-height: 1.2; letter-spacing: -0.02em; overflow-wrap: anywhere; text-wrap: pretty; }
/* WHY violet and underlined: on white it looked like a separate block of plain text. It belongs to the title and it is a link (Davide, 2026-11-09) */
.back {
  display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 1rem var(--cell-x);
  font-size: clamp(1.1rem, 1.6vw, 1.35rem); font-weight: 700; letter-spacing: -0.015em; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px;
  transition: background-color .3s var(--ease);
}
.back:hover { background: var(--accent); }
.back:hover .ic { translate: -.2em 0; }
.back:focus-visible, .go:focus-visible { outline-offset: -5px; }
.ic { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; transition: translate .3s var(--ease); }

/* ---------- home ---------- */
.go {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: clamp(1.25rem, 2.5vw, 2rem) var(--cell-x);
  background: var(--ink); color: var(--on-dark); font-size: clamp(1.9rem, 3.8vw, 3.25rem); font-weight: 750; line-height: 1.05; letter-spacing: -0.03em; text-decoration: none;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
.go:hover { background: var(--accent); color: var(--ink); }
.go:focus-visible { outline-color: var(--accent); }
.go:hover .ic { translate: .25em 0; }
.stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 0; border-top: var(--rule); }
.stats > div { padding: 1.1rem var(--cell-x) 1.2rem; }
.stats > div + div { border-left: var(--rule); }
.stats dt { font-weight: 600; line-height: 1.25; }
.stats dd { margin: .15rem 0 0; font-size: clamp(1.7rem, 3vw, 2.6rem); font-weight: 750; line-height: 1.05; letter-spacing: -0.03em; }
.history { padding: clamp(1.1rem, 2vw, 1.5rem) var(--cell-x); padding-bottom: .9rem; border-top: var(--rule); font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
.empty { max-width: none; border-top: 0; padding-top: 0; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; }
th { padding: .6rem 1rem; border-bottom: var(--rule); font-size: .875rem; font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th + th, td + td { border-left: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: var(--cell-x); }
th:last-child, td:last-child { padding-right: var(--cell-x); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .2s var(--ease); }
/* WHY the whole row opens the search: a title alone did not read as a way in (Davide, 2026-11-09). The link stretches over the row, the buttons sit above it */
tbody tr { position: relative; }
tbody tr:hover { background: var(--accent-soft); }
.open { display: flex; align-items: flex-start; gap: .45rem; max-width: 36rem; text-decoration: none; }
.open::after { content: ""; position: absolute; inset: 0; }
.open .clamp { text-decoration: underline; }
.open .ic { width: 1.05em; height: 1.05em; margin-top: .2em; }
tbody tr:hover .open .ic { translate: .25em 0; }
.action .button, .action form, .help button { position: relative; z-index: 1; }
th.num, td[data-label="Spesa API AI"] { text-align: right; }
td.num { white-space: nowrap; }
td[data-label="Ricerca"] .muted { display: block; margin-top: .15rem; font-size: .875rem; }
td[data-label="Aziende"] { min-width: 9rem; white-space: normal; }
.action { text-align: right; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; max-width: 34rem; font-weight: 650; }

/* ---------- status ---------- */
/* WHY one word and one thin line: dots and a three-part bar were too much, and the last step did not read as the end (Davide, 2026-11-09) */
.status { position: relative; width: 12rem; max-width: 100%; }
.status.failed p { display: flex; align-items: center; gap: .3rem; }
.status p { font-size: .9375rem; line-height: 1.25; }
.status strong { font-weight: 700; }
.status .detail { display: block; margin-top: .1rem; color: var(--muted); font-size: .8125rem; }
.track { display: block; height: .4rem; margin-top: .45rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.track i { display: block; width: 33%; height: 100%; border-radius: inherit; background: var(--ink); }
.understanding .track i { width: 15%; }
.queued .track i, .running .track i, .failed.late .track i { width: 66%; }
.done .track i { width: 100%; background: var(--gain); }
.failed .track i { background: var(--bad); }
.failed strong { color: var(--bad); }
.canceled .track { display: none; }
.understanding .track i, .queued .track i, .running .track i {
  background: linear-gradient(90deg, var(--wait) 30%, var(--accent) 50%, var(--wait) 70%) 0 0 / 200% 100%;
  animation: flow 1.8s linear infinite;
}
@keyframes flow { to { background-position-x: -200%; } }

/* ---------- one search ---------- */
.run-top { border-top: var(--rule); }
.sheet > .alert + .run-top { border-top: var(--rule); }
.run-top.single { grid-template-columns: minmax(0, 1fr); }
.status-cell { display: grid; align-content: center; gap: .9rem; padding: clamp(1.1rem, 2.2vw, 1.6rem) var(--cell-x); }
.status-cell .status { width: min(30rem, 100%); }
.status-cell .status p { font-size: 1rem; }
.status-cell strong { font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.status-cell .track { height: .6rem; margin-top: .65rem; }
.status-cell .progress { margin: 0; }
.go.compact { padding-block: 1.1rem; font-size: clamp(1.3rem, 2.2vw, 1.8rem); }
.go-form { display: grid; margin: 0; }
.run-actions { display: grid; grid-template-rows: 1fr auto; }
.go.edit { padding-block: .9rem; border-top: var(--rule); background: var(--tint); color: var(--ink); font-size: clamp(1.05rem, 1.5vw, 1.25rem); letter-spacing: -0.02em; line-height: 1.15; }
.go.edit:hover { background: var(--accent); }
.go.edit:focus-visible { outline-color: var(--wait); }
button.go { width: 100%; border: 0; font-family: inherit; text-align: left; cursor: pointer; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.facts > div { min-width: 0; padding: 1rem var(--cell-x) 1.1rem; border-top: var(--rule); }
.facts .wide { grid-column: 1 / -1; }
.facts .half + .half { border-left: var(--rule); }
.facts dt { font-size: clamp(1.05rem, 1.4vw, 1.2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.facts dd { margin: .3rem 0 0; font-size: 1.0625rem; max-width: 75ch; overflow-wrap: anywhere; }
.facts strong { font-size: clamp(1.7rem, 3vw, 2.6rem); font-weight: 750; line-height: 1.05; letter-spacing: -0.03em; margin-right: .5rem; }
.history + form > .facts > div:first-child, .history + form > .facts > div:nth-child(2) { border-top: var(--rule); }

/* ---------- login ---------- */
.login { max-width: 40rem; margin: clamp(1.5rem, 9vh, 6rem) auto 0; }
.login .title { font-size: clamp(2.5rem, 6.5vw, 4rem); }
.login-head { margin: 0; padding: clamp(1.1rem, 2.5vw, 1.75rem) var(--cell-x); font-size: clamp(1.9rem, 3.6vw, 2.75rem); }
.login .end .primary { width: 100%; }
.strip-end { display: flex; align-items: center; gap: 1.5rem; font-size: 1.125rem; }
.logout { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.logout:hover { color: var(--accent); }
.logout:focus-visible { outline-color: var(--accent); }

/* ---------- score legend ---------- */
.stats, #criteria-field, .history-row { position: relative; }
.stats dt { display: flex; align-items: center; gap: .3rem; }
.history-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1.5rem; padding: clamp(1.1rem, 2vw, 1.5rem) var(--cell-x) .9rem; border-top: var(--rule); }
.history-row .history { padding: 0; border: 0; }
.legend .tip { left: var(--cell-x); width: min(31rem, 84vw); font-weight: 400; letter-spacing: 0; }
tbody .legend .tip { left: auto; right: var(--cell-x); }
.fit-line { display: flex; align-items: center; gap: .3rem; }
.tip b { font-weight: 750; }
.tip > b:first-child { display: block; margin-bottom: .25rem; font-size: 1rem; }
.tip .line { display: block; }
.tip .line.first { margin-top: .5rem; }

/* ---------- how to use it ---------- */
/* WHY no display here: a display on .how would keep the closed popover on screen */
.how { width: min(62rem, 100vw - 1.5rem); max-height: calc(100dvh - 1.5rem); padding: 0; border: var(--rule); border-radius: 1.5rem; background: var(--bg); color: var(--ink); overflow: auto; overscroll-behavior: contain; scrollbar-color: var(--ink) transparent; }
.how:popover-open { animation: how-in .35s var(--ease); }
@keyframes how-in { from { opacity: 0; translate: 0 .75rem; } }
.how::backdrop { background: oklch(0.21 0.05 276 / 0.6); }
.how h3 { margin: 0 0 .25rem; font-size: clamp(1.15rem, 1.6vw, 1.35rem); font-weight: 750; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
.how-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: clamp(.9rem, 2vw, 1.4rem) var(--cell-x); border-bottom: var(--rule); background: var(--tint); }
.how-head h2 { font-size: clamp(1.7rem, 3.4vw, 2.75rem); }
.how-close { flex: none; width: 2.75rem; padding: 0; }
.how-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.how-steps li { position: relative; counter-increment: step; padding: 1.1rem var(--cell-x) 1.2rem calc(var(--cell-x) + 2.75rem); }
.how-steps li + li { border-top: var(--rule); }
.how-steps li::before { content: counter(step); position: absolute; left: var(--cell-x); top: .85rem; font-size: 2.25rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.how-steps p { max-width: 62ch; }
.how-side { display: grid; grid-template-rows: auto 1fr; }
.how-side > section { padding: 1.1rem var(--cell-x) 1.2rem; }
.how-side > section > p + h3 { margin-top: 1rem; }
.how-score { background: var(--surface); font-size: .9375rem; line-height: 1.4; }
.how-score b { font-weight: 750; font-variant-numeric: tabular-nums; }
.how .line:not(.note) { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr); gap: .5rem; margin-top: .3rem; }
.how .line.first { margin-top: .75rem; }
.how .note { display: block; }
.how .note b { font-variant-numeric: normal; }
.how.ask { width: min(32rem, 100vw - 1.5rem); padding: clamp(1.25rem, 3vw, 1.75rem) var(--cell-x); }
.ask h2 { margin-bottom: .6rem; font-size: clamp(1.6rem, 3vw, 2.1rem); }
.ask form { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }

/* ---------- form ---------- */
.new > .cells, .new > .cell { border-top: var(--rule); }
.cell { display: grid; align-content: start; gap: .3rem; min-width: 0; padding: 1rem var(--cell-x) 1.1rem; transition: background-color .3s var(--ease); }
/* WHY the whole cell lights up: the inputs have no box of their own, the ruled cell is the box */
.cell:focus-within { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--wait); }
.cell input:focus-visible, .cell textarea:focus-visible { outline: none; }
label { font-size: clamp(1.1rem, 1.5vw, 1.3rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.label-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.skipped .hint { display: none; }
.skipped, .skipped:focus-within { background: var(--surface); box-shadow: none; }
.skipped textarea { cursor: not-allowed; resize: none; }
.skipped .button.small { background: var(--accent); }
textarea, input[type="number"], input[type="text"], input[type="password"] { width: 100%; padding: .1rem 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1.125rem; }
textarea { display: block; resize: vertical; scrollbar-color: var(--ink) transparent; }
/* WHY: the browser's arrows clash with the page (Davide, 2026-11-09). The number is typed; the keyboard arrows still work */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
::placeholder { color: var(--muted); opacity: 1; }
.hint { font-size: .875rem; color: var(--muted); max-width: 70ch; }
.end { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: 1.1rem var(--cell-x); border-top: var(--rule); }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.75rem; padding: .55rem 1.2rem;
  border: 0; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink);
  font: inherit; font-size: .95rem; font-weight: 650; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color .3s var(--ease), box-shadow .3s var(--ease), color .3s var(--ease), translate .3s var(--ease);
}
.button:hover { background: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); translate: 0 -2px; }
.button.primary { background: var(--ink); box-shadow: none; color: var(--on-dark); }
.button.primary:hover { background: var(--accent); color: var(--ink); }
.end .primary { font-size: 1.05rem; padding-inline: 1.6rem; }
/* WHY flex: inline, the circle sat on the text baseline and looked lower than the words */
.estimate { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; line-height: 1.35rem; }
.estimate strong { font-weight: 750; }
.help { display: flex; margin-left: .2rem; }
.help button { position: relative; width: 1.35rem; height: 1.35rem; padding: 0; border: 0; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); font: inherit; font-size: .8125rem; font-weight: 750; line-height: 1; cursor: help; transition: background-color .3s var(--ease); }
/* WHY: a bigger area to hit than the small circle */
.help button::before { content: ""; position: absolute; inset: -.5rem; }
.help:hover button, .help button:focus { background: var(--accent); }
.help.bad button { box-shadow: inset 0 0 0 2px var(--bad); color: var(--bad); }
.help.bad:hover button, .help.bad button:focus { background: var(--bad); color: var(--bg); }
.tip {
  position: absolute; z-index: 2; left: 0; bottom: calc(100% + .7rem); width: min(25rem, 76vw); padding: .75rem 1rem; border-radius: 1.1rem;
  background: var(--ink); color: var(--on-dark); font-size: .875rem; line-height: 1.4;
  box-shadow: 0 .75rem 1.5rem -.75rem oklch(0.21 0.05 276 / 0.7);
  opacity: 0; visibility: hidden; translate: 0 .3rem; transition: opacity .2s var(--ease), translate .2s var(--ease), visibility .2s;
}
/* WHY: bridges the gap, so the mouse can move onto the text without closing it */
.tip::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: .7rem; }
.help:hover .tip, .help button:focus + .tip { opacity: 1; visibility: visible; translate: 0 0; }
.button.small { min-height: 2rem; padding: .25rem .85rem; font-size: .8125rem; }
.button.danger { box-shadow: inset 0 0 0 2px var(--bad); color: var(--bad); }
.button.danger:hover { background: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); color: var(--bg); }

/* ---------- one search ---------- */
.check { display: flex; gap: .6rem; align-items: baseline; padding: .75rem 1rem; border-radius: 1.1rem; background: var(--accent-soft); font-size: 1rem; font-weight: 600; letter-spacing: 0; line-height: 1.35; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; flex: none; translate: 0 .12em; }
td form { margin: 0; }
.alert { padding: .7rem var(--cell-x); background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.alert a { color: inherit; font-weight: 700; }
.sheet > .alert { border-top: var(--rule); }
.progress { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; font-variant-numeric: tabular-nums; }
.counts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1.25rem; margin: 0; }
.counts dt { color: var(--muted); }
.counts dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 52rem) {
  .cells { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts .half + .half { border-left: 0; }
  .stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stats > div:nth-child(odd) { border-left: 0; }
  .stats > div:nth-child(n + 3) { border-top: var(--rule); }
  .cells > * + * { border-left: 0; border-top: var(--rule); }
  .back { justify-content: flex-start; }
  textarea { min-height: 7.25rem; }
  table, tbody, tr, td { display: block; }
  thead { position: absolute; left: -999rem; }
  tr { display: grid; gap: .4rem; padding: .95rem var(--cell-x); border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td, td:first-child, td:last-child { padding: 0; border: 0; text-align: left !important; white-space: normal; }
  td + td { border-left: 0; }
  td[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: right !important; }
  td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); }
  td[data-label="Ricerca"]::before, td[data-label="Stato"]::before { display: none; }
  td[data-label="Stato"] { display: block; margin-block: .2rem; text-align: left !important; }
  .status { width: 100%; }
  td[data-label="Ricerca"] { order: -1; display: block; text-align: left !important; }
  td:empty { display: none; }
  .action { margin-top: .35rem; }
  .action .button { width: 100%; }
  .fit-line { justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
