/* pAIperwork — stile "Timbro" (neubrutalista) con temi selezionabili dall'utente */

/* ---------- Temi ---------- */
html[data-theme="inchiostro"] { --bg:#EEF2FB; --pop:#2F55D4; --pop-text:#FFFFFF; --cta:#2F55D4; --cta-text:#FFFFFF; --stamp:#2F55D4; --sent:#DCE3F3; }
html[data-theme="rosso"]      { --bg:#FFFFFF; --pop:#D62839; --pop-text:#FFFFFF; --cta:#D62839; --cta-text:#FFFFFF; --stamp:#D62839; --sent:#F3F1EF; }
html[data-theme="menta"]      { --bg:#ECFAF3; --pop:#7DDDB4; --pop-text:#000000; --cta:#FF7FA8; --cta-text:#000000; --stamp:#1D4ED8; --sent:#D7EDE2; }
html[data-theme="lavanda"]    { --bg:#F4F0FF; --pop:#C4B5FD; --pop-text:#000000; --cta:#FFB547; --cta-text:#000000; --stamp:#C2255C; --sent:#E6E0F7; }
html[data-theme="giallo"]     { --bg:#FFF6D6; --pop:#FFD43B; --pop-text:#000000; --cta:#FF7A59; --cta-text:#000000; --stamp:#C2185B; --sent:#EDE6CF; }

:root {
  --ink: #000000;
  --paper: #FFFFFF;
  --muted: #3A3A3A;
  --line: 3px solid var(--ink);
  --shadow-s: 3px 3px 0 var(--ink);
  --shadow-m: 5px 5px 0 var(--ink);
  --shadow-l: 7px 7px 0 var(--ink);
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --max: 1200px;
  --ok-bg: #DDF3E4; --ok-fg: #14532D;
  --no-bg: #FDE2E2; --no-fg: #8A1C1C;
  --warn-bg: #FFF1D6; --warn-fg: #6B4100;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  transition: background-color .2s ease;
}
img, svg { display: block; }
a { color: var(--ink); }
h1, h2, h3 { line-height: 1.1; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--paper); }

.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--paper); border: var(--line); padding: 10px 14px; z-index: 100; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.topbar { padding: 20px 20px 0; }
.topbar__inner { max-width: var(--max); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.logo {
  font-size: 30px; font-weight: 800; letter-spacing: -0.03em; text-decoration: none;
  padding: 2px 12px; background: var(--pop); color: var(--pop-text);
  border: var(--line); box-shadow: var(--shadow-s); transform: rotate(-2deg);
}
.logo__ai { background: var(--ink); color: #FFFFFF; padding: 0 4px; margin: 0 1px; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.nav a {
  position: relative; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px;
  border: var(--line); background: var(--paper); text-decoration: none; font-weight: 600;
}
.nav a[aria-current="page"] { background: var(--ink); color: #FFFFFF; }
.nav a:hover:not([aria-current="page"]) { box-shadow: var(--shadow-s); transform: translate(-1px, -1px); }
.nav svg { width: 20px; height: 20px; }
.nav .nav__badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--cta); color: var(--cta-text); font-size: 13px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--ink); }

.theme-picker { display: flex; align-items: center; gap: 10px; }
.theme-swatch {
  width: 44px; height: 44px; padding: 0; cursor: pointer;
  border: var(--line); box-shadow: var(--shadow-s);
}
.theme-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }

.demo-banner {
  max-width: var(--max); margin: 18px auto 0; padding: 10px 14px; font-size: 15px;
  background: var(--paper); border: 2px dashed var(--ink);
  width: calc(100% - 40px);
}

main { max-width: var(--max); margin: 0 auto; padding: 28px 20px 140px; outline: none; }

/* ---------- Elementi base ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-title { font-size: clamp(40px, 6vw, 68px); font-weight: 800; letter-spacing: -0.04em; line-height: .95; max-width: 820px; }
.lead { font-size: 19px; color: var(--muted); max-width: 640px; margin-top: 12px; }
.section-title { font-size: 26px; font-weight: 800; margin-bottom: 14px; }

.card { background: var(--paper); border: var(--line); box-shadow: var(--shadow-m); padding: 22px; }
.card--flat { box-shadow: none; }

.btn {
  min-height: 48px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: var(--line); background: var(--paper); color: var(--ink); font-weight: 700; font-size: 16px;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-s);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn--primary { background: var(--cta); color: var(--cta-text); }
.btn--dark { background: var(--ink); color: #FFFFFF; }
.btn--big { min-height: 58px; padding: 0 28px; font-size: 18px; font-weight: 800; box-shadow: var(--shadow-m); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 10px; background: var(--paper); border: 2px solid var(--ink); font-size: 14px; font-weight: 600; }
.chip--ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-fg); }
.chip--warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-fg); }
.chip--no { background: var(--no-bg); color: var(--no-fg); border-color: var(--no-fg); }
.chip--info { background: var(--sent); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-weight: 700; font-size: 15px; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border: var(--line); background: var(--paper);
  font-size: 16px; border-radius: 0;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.hint { font-size: 14px; color: var(--muted); }

.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); margin: 0; }

.empty { text-align: center; padding: 48px 20px; }
.empty .page-title { font-size: 40px; margin-bottom: 12px; }

/* ---------- Offerte ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 26px; }
.filters .field { flex: 1 1 220px; }
.filters .field--small { flex: 0 1 200px; }
.source-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.source-chip { min-height: 40px; padding: 0 12px; border: 2px solid var(--ink); background: var(--paper); font-weight: 600; cursor: pointer; }
.source-chip[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 24px; }
.job {
  position: relative; background: var(--paper); border: var(--line); box-shadow: var(--shadow-l);
  padding: 20px; display: flex; flex-direction: column; gap: 10px; min-height: 230px;
}
.job--selected { background: var(--pop); color: var(--pop-text); }
.job--selected .job__meta { color: inherit; }
.job--sent { background: var(--sent); }
.job__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.job__source { font-size: 14px; font-weight: 600; padding: 3px 10px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); }
.job__match { font-size: 24px; font-weight: 800; }
.job__role { font-size: 22px; font-weight: 800; line-height: 1.15; }
.job__meta { font-size: 16px; color: var(--muted); }
.job__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.job__tags .chip { color: var(--ink); }
.job__actions { margin-top: auto; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.job__actions .check input { accent-color: var(--ink); }
.job--selected .check input { accent-color: #000; }
.link-btn { background: none; border: 0; padding: 8px 0; min-height: 44px; font-weight: 700; text-decoration: underline; cursor: pointer; color: inherit; }

.stamp {
  position: absolute; right: 14px; bottom: 16px; padding: 6px 12px; font-size: 18px; font-weight: 800;
  color: var(--stamp); border: 3px solid var(--stamp); background: rgba(255,255,255,.8);
  transform: rotate(-8deg); pointer-events: none;
}

.actionbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  width: min(var(--max), calc(100% - 40px)); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; background: var(--ink); color: #FFFFFF; border: var(--line); box-shadow: 6px 6px 0 var(--pop);
}
.actionbar strong { font-size: 18px; }
.actionbar .hint { color: #E2E2E2; }

/* Dettaglio offerta */
.dialog { border: var(--line); box-shadow: var(--shadow-l); padding: 0; max-width: 680px; width: calc(100% - 32px); background: var(--paper); color: var(--ink); }
.dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog__body { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.dialog__head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: var(--line); background: var(--paper); cursor: pointer; }

/* ---------- Conferma ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.step { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; }
.step[aria-current="step"] { background: var(--ink); color: #FFFFFF; }
.step--done { background: var(--sent); }
.confirm-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.confirm-layout > .card:first-child { flex: 999 1 560px; min-width: 0; }
.confirm-layout > aside { flex: 1 1 280px; }
.diff { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 6px; }
.diff__row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 2px solid currentColor; }
.diff__row--add { background: var(--ok-bg); color: var(--ok-fg); }
.diff__row--remove { background: var(--no-bg); color: var(--no-fg); }
.diff__row--remove .diff__text { text-decoration: line-through; }
.diff__sign { font-weight: 800; min-width: 92px; }
.diff__text { color: var(--ink); }
.diff__row label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; width: 100%; }
.diff__row input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ink); flex: none; }
.archive-name { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 14px; background: var(--sent); padding: 2px 6px; border: 1px solid var(--ink); word-break: break-all; }
.letter-editor { min-height: 360px; font-size: 17px; line-height: 1.65; }

.sent-moment { text-align: center; padding: 50px 20px; }
.sent-moment .stamp { position: static; display: inline-block; font-size: 44px; padding: 10px 26px; border-width: 5px; margin-bottom: 26px; }
@media (prefers-reduced-motion: no-preference) {
  .sent-moment .stamp { animation: stamp-in .45s cubic-bezier(.2,1.6,.4,1) both; }
  @keyframes stamp-in { from { transform: rotate(-8deg) scale(2.2); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
}

/* ---------- Candidature ---------- */
.app-list { display: flex; flex-direction: column; gap: 14px; }
.app-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.app-row__main { flex: 1 1 320px; min-width: 0; }
.app-row__title { font-size: 20px; font-weight: 800; }
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 28px; }
.counter { padding: 18px; }
.counter__n { font-size: 48px; font-weight: 800; line-height: 1; }
.counter__l { font-weight: 600; margin-top: 6px; }
.reply { margin-top: 10px; padding: 12px 14px; border: 2px solid var(--ink); background: var(--sent); }

/* ---------- Curriculum ---------- */
.cv-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cv-form { flex: 1 1 380px; display: flex; flex-direction: column; gap: 16px; }
.cv-preview-wrap { flex: 1 1 460px; min-width: 0; position: sticky; top: 16px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.exp { border: 2px solid var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--paper); }
.exp__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.paper { background: #FFFFFF; color: #111111; border: var(--line); box-shadow: var(--shadow-l); padding: 40px 44px; font-size: 15px; line-height: 1.55; }
.paper h2 { font-size: 30px; letter-spacing: -0.02em; }
.paper .paper__title { font-size: 18px; font-weight: 600; margin-top: 4px; }
.paper .paper__contacts { color: #444; margin-top: 6px; font-size: 14px; }
.paper h3 { font-size: 15px; font-weight: 800; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 2px solid #111; }
.paper .paper__skills { display: flex; flex-wrap: wrap; gap: 6px; }
.paper .paper__skills span { border: 1.5px solid #111; padding: 1px 8px; font-size: 13px; }
.paper .paper__exp { margin-bottom: 12px; }
.paper .paper__exp strong { display: block; }
.paper .paper__exp small { color: #444; font-size: 13px; }
.paper .letter p { margin-bottom: 12px; white-space: pre-line; }

/* ---------- Archivio ---------- */
.archive-layout { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.folders { flex: 1 1 340px; max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
.folder { text-align: left; width: 100%; cursor: pointer; background: none; border: 0; padding: 0; }
.folder__tab { display: inline-block; padding: 4px 14px 10px; border: 2px solid var(--ink); border-bottom: 0; background: var(--pop); color: var(--pop-text); font-size: 14px; font-weight: 700; }
.folder__body { margin-top: -6px; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 14px 16px; border: var(--line); background: var(--paper); }
.folder[aria-pressed="true"] .folder__body { box-shadow: var(--shadow-m); }
.folder__name { font-size: 18px; font-weight: 800; }
.folder__docs { font-size: 14px; color: var(--muted); }
.archive-view { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.doc-tabs { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Impostazioni / onboarding ---------- */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.theme-list { display: flex; flex-wrap: wrap; gap: 14px; }
.theme-option { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; padding: 4px; }
.theme-option .theme-swatch { width: 64px; height: 64px; }
.platforms { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.platform { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 14px; border: var(--line); background: var(--paper); font-weight: 700; cursor: pointer; }
.platform input { width: 22px; height: 22px; accent-color: var(--ink); margin: 0; }
.platform:has(input:checked) { background: var(--pop); color: var(--pop-text); box-shadow: var(--shadow-s); }
.platform small { display: block; font-weight: 400; font-size: 13px; }
.onboard { max-width: 860px; margin: 0 auto; }
.onboard .card { display: flex; flex-direction: column; gap: 18px; }
.progress { height: 16px; border: var(--line); background: var(--paper); margin-bottom: 26px; }
.progress span { display: block; height: 100%; background: var(--pop); border-right: var(--line); }
.notice { padding: 14px 16px; border: 2px solid var(--ink); background: var(--sent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -150%); z-index: 50;
  max-width: calc(100% - 32px); padding: 12px 18px; background: var(--ink); color: #FFFFFF; font-weight: 700;
  border: var(--line); box-shadow: 5px 5px 0 var(--pop); transition: transform .25s ease, visibility .25s;
  visibility: hidden;
}
.toast--show { transform: translate(-50%, 0); visibility: visible; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .topbar { padding: 14px 16px 0; }
  .logo { font-size: 26px; }
  .theme-picker--header { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0; flex-wrap: nowrap;
    background: var(--paper); border-top: var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav a { flex: 1; flex-direction: column; gap: 2px; justify-content: center; min-height: 62px; padding: 6px 2px; border: 0; font-size: 12px; }
  .nav a + a { border-left: 2px solid var(--ink); }
  .nav .nav__badge { position: absolute; margin: -34px 0 0 26px; }
  .demo-banner { width: calc(100% - 32px); font-size: 14px; }
  main { padding: 22px 16px 170px; }
  .actionbar { bottom: 76px; width: calc(100% - 24px); padding: 12px 14px; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 26px 22px; }
  .cv-preview-wrap { position: static; }
  .diff__sign { min-width: 0; }
}
@media (min-width: 761px) { .nav__label-short { display: none; } }
@media (max-width: 760px) { .nav__label-long { display: none; } }

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

/* ---------- Stampa (salva come PDF) ---------- */
@media print {
  body { background: #FFFFFF; }
  .topbar, .demo-banner, .nav, .toast, .no-print, .folders, .doc-tabs { display: none !important; }
  main { padding: 0; max-width: none; }
  .paper { border: 0; box-shadow: none; padding: 0; }
}
