/* jimbug: a technical-document layout. Paper and ink, one red, Archivo on
   its whole width axis (wide for statements, condensed for titles and labels).
   Fixed index column on the left, catalogue-style lists on the right. */
:root {
  --paper: #f6f4ee;
  --paper-2: #efece4;
  --ink: #141412;
  --ink-2: #4d4b45;
  --ink-3: #8a877f;
  --hair: #dcd8ce;
  --red: #d42a1e;
  --ok: #1d9a4c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121211;
  --paper-2: #1b1b19;
  --ink: #eeece6;
  --ink-2: #b2afa7;
  --ink-3: #77756e;
  --hair: #2c2b28;
  --red: #ff5a4b;
  --ok: #3ecf75;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121211;
    --paper-2: #1b1b19;
    --ink: #eeece6;
    --ink-2: #b2afa7;
    --ink-3: #77756e;
    --hair: #2c2b28;
    --red: #ff5a4b;
    --ok: #3ecf75;
    color-scheme: dark;
  }
}

html[lang="it"] [data-l="en"],
html[lang="en"] [data-l="it"] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
::selection { background: var(--red); color: #fff; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, p, figure, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }

/* small shared type */
.label, .n, .kind, .cv-date, .spec dt, .spec-title {
  font-size: 11.5px;
  font-weight: 700;
  font-stretch: 75%;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.label { display: flex; align-items: baseline; gap: 12px; color: var(--ink-3); }
.n { color: var(--red); letter-spacing: .08em; }

/* ---------------- masthead ---------------- */
.mast {
  margin-inline: max(40px, calc((100% - 1320px) / 2)); padding: 22px 0 14px;
  display: flex; align-items: center; gap: 40px;
  border-bottom: 2px solid var(--ink);
}
.logo {
  display: inline-flex; align-items: baseline;
  font-weight: 800; font-stretch: 125%; font-size: 21px; letter-spacing: -0.02em;
  text-decoration: none;
}
.logo::after { content: "."; color: var(--red); }
.mast-nav { display: flex; gap: 28px; margin-left: auto; }
.mast-nav a {
  display: inline-flex; align-items: baseline; gap: 7px;
  font-weight: 700; font-stretch: 85%; font-size: 17px; letter-spacing: -0.005em;
  text-decoration: none; padding: 2px 0;
  transition: color .2s;
}
.mast-nav .n { font-size: 10.5px; color: var(--ink-3); }
.mast-nav a:hover, .mast-nav a[aria-current="page"], .mast-nav a[aria-current="page"] .n { color: var(--red); }
.mast-nav a[aria-current="page"] { box-shadow: inset 0 -2px var(--red); }
.switches { display: flex; align-items: center; gap: 8px; }
.lang { display: flex; border: 1px solid var(--ink); }
.lang button, .theme {
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--ink); background: none; border: 0; padding: 4px 9px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.theme { border: 1px solid var(--ink); width: 28px; height: 25px; display: grid; place-items: center; padding: 0; }
.theme span { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); }

/* ---------------- main ---------------- */
.main { margin-inline: max(40px, calc((100% - 1320px) / 2)); padding-top: 8px; }

/* home intro */
.intro {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 56px; align-items: center;
  padding: 48px 0 72px; border-bottom: 1px solid var(--ink);
}
.statement {
  margin-top: 0;
  font-weight: 800; font-stretch: 112%;
  font-size: clamp(36px, 4.6vw, 64px);
  line-height: .98; letter-spacing: -0.04em;
  text-wrap: balance;
}
.intro-lead { margin-top: 24px; font-size: 18px; line-height: 1.6; max-width: 46ch; }
.slider { position: relative; outline: none; }
.slides { display: grid; }
.slide { grid-area: 1 / 1; transition: opacity .7s ease; }
.slide[hidden] { display: block; opacity: 0; pointer-events: none; }
.slide img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--paper-2); }
.slide.is-fit img { object-fit: contain; }
.slide figcaption { margin-top: 10px; min-height: 2.6em; font-size: 13px; color: var(--ink-2); }
.slider-bar { display: flex; align-items: center; gap: 12px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--hair); }
.slider-count { font-size: 12px; font-weight: 700; font-stretch: 75%; letter-spacing: .14em; color: var(--ink-3); }
.slider-count b { color: var(--ink); }
.slider-progress { flex: 1; height: 2px; background: var(--hair); overflow: hidden; }
.slider-progress span { display: block; height: 100%; width: 100%; background: var(--red); transform-origin: left; transform: scaleX(0); }
.slider-progress span.run { animation: slide-progress var(--slide-ms, 5000ms) linear forwards; }
.slider:hover .slider-progress span.run, .slider:focus-within .slider-progress span.run { animation-play-state: paused; }
@keyframes slide-progress { to { transform: scaleX(1); } }
.slider-btn {
  width: 34px; height: 30px; display: grid; place-items: center;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  color: var(--ink); background: none; border: 1px solid var(--ink);
  transition: background .15s, color .15s;
}
.slider-btn:hover { background: var(--ink); color: var(--paper); }
.slider:focus-visible { outline: 2px solid var(--red); outline-offset: 6px; }

/* section heads */
.sec { padding-top: 64px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.sec-head h2 { display: flex; align-items: baseline; gap: 14px; line-height: 1.1; font-weight: 700; font-stretch: 85%; font-size: 26px; letter-spacing: -0.01em; }
.sec-head a { font-size: 13.5px; font-weight: 700; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.sec-head a:hover { color: var(--red); }

/* catalogue rows (projects and posts) */
.row {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr 150px 168px;
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  isolation: isolate;
}
.row::before {
  content: ""; position: absolute; left: -16px; right: -16px; top: 0; bottom: 0; z-index: -1;
  background: var(--paper-2); opacity: 0; transition: opacity .2s;
}
.row:hover::before { opacity: 1; }
.row-n { align-self: start; padding-top: 6px; font-size: 13px; font-weight: 700; font-stretch: 75%; letter-spacing: .08em; color: var(--ink-3); }
.row:hover .row-n { color: var(--red); }
.row-main { display: flex; flex-direction: column; gap: 6px; }
.row-title { font-weight: 700; font-stretch: 80%; font-size: clamp(24px, 2.6vw, 32px); line-height: 1.05; letter-spacing: -0.01em; transition: color .2s; }
.row:hover .row-title { color: var(--red); }
.row-sum { font-size: 15px; color: var(--ink-2); max-width: 56ch; }
.row-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.kind { padding: 2px 7px; border: 1px solid var(--ink); }
.year { font-size: 13px; color: var(--ink-3); }
.row-thumb {
  aspect-ratio: 5 / 3; background: var(--paper-2); border: 1px solid var(--hair);
  overflow: hidden; display: grid; place-items: center;
  transition: border-color .2s, transform .25s;
}
.row:hover .row-thumb { border-color: var(--ink); transform: translateX(-4px); }
.row-thumb > * { width: 100%; height: 100%; }
.row-thumb.is-photo img { object-fit: cover; }
.post-row { grid-template-columns: 52px 1fr 150px; }
.empty { padding: 24px 0; color: var(--ink-3); }

/* drawn covers */
svg.cover { color: var(--ink); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cover .r { stroke: var(--red); }
.cover .fillink { fill: currentColor; stroke: none; }
.cover .fillred { fill: var(--red); }
.cover .bg { fill: var(--paper-2); }
.cover .t { fill: currentColor; stroke: none; font-family: "Archivo", sans-serif; font-weight: 700; font-size: 17px; }
.cover .t.small { font-size: 11.5px; letter-spacing: .14em; fill: var(--ink-2); }
.cover .t.big { font-size: 40px; font-stretch: 85%; }
.cover .t.mono { font-family: var(--mono); font-weight: 600; }
.cover .t.mono.big { font-size: 30px; }
.cover .t.mono:not(.big):not(.small) { font-size: 26px; }
.cover .rt { fill: var(--red); }

/* page heads */
.page-head { padding: 40px 0; border-bottom: 1px solid var(--ink); }
.page-head h1, .proj h1, .post h1 {
  margin-top: 18px;
  font-weight: 800; font-stretch: 112%;
  font-size: clamp(44px, 6.4vw, 88px);
  line-height: .95; letter-spacing: -0.04em;
}
.post h1 { font-size: clamp(36px, 5vw, 64px); max-width: 18ch; }
.page-lead { margin-top: 20px; font-size: 19px; line-height: 1.5; color: var(--ink-2); max-width: 54ch; }
.page-head .btn { margin-top: 28px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border: 1px solid var(--ink);
  font-size: 14px; font-weight: 700; text-decoration: none;
  transition: background .15s, color .15s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }


/* project page */
.proj, .post { padding: 32px 0 0; }
.back { display: inline-block; margin-bottom: 36px; font-size: 13.5px; font-weight: 700; text-decoration: none; color: var(--ink-2); }
.back:hover { color: var(--red); }
.proj-sub { margin-top: 10px; font-size: 18px; font-weight: 600; color: var(--ink-2); }
.proj-grid { display: grid; grid-template-columns: 240px 1fr; gap: 48px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--ink); }
.spec { position: sticky; top: 24px; align-self: start; }
.spec-title { color: var(--red); padding-bottom: 10px; }
.spec dl div { padding: 10px 0; border-top: 1px solid var(--hair); }
.spec dt { color: var(--ink-3); }
.spec dd { margin-top: 4px; font-weight: 600; font-size: 14.5px; }
.spec-links { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 16px; }
.spec-links .btn { justify-content: space-between; }
.fig figcaption { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.fig b { color: var(--red); margin-right: 4px; }
.fig-media { aspect-ratio: 5 / 3; background: var(--paper-2); border: 1px solid var(--ink); display: grid; place-items: center; overflow: hidden; }
.fig-media > * { width: 100%; height: 100%; }
.fig-media svg { max-width: 640px; }
.fig-media.is-photo img { object-fit: cover; }
.prose { margin-top: 32px; max-width: 64ch; }
.prose p { font-size: 17.5px; line-height: 1.7; margin-bottom: 18px; }
.prose h2 { margin: 40px 0 12px; font-weight: 700; font-stretch: 85%; font-size: 28px; letter-spacing: -0.01em; }
.prose h3 { margin: 28px 0 10px; font-weight: 700; font-size: 19px; }
.prose ul { margin: 0 0 18px; }
.prose li { position: relative; padding-left: 18px; margin-bottom: 8px; font-size: 17px; line-height: 1.6; }
.prose li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; background: var(--red); }
.prose a { text-decoration-color: var(--red); text-underline-offset: 3px; }
.prose a:hover { color: var(--red); }
.prose code { font-family: var(--mono); font-size: .88em; padding: 1px 5px; background: var(--paper-2); border: 1px solid var(--hair); }
.prose pre { margin: 0 0 20px; padding: 16px 18px; overflow-x: auto; background: var(--ink); color: var(--paper); font-size: 14px; line-height: 1.6; border-left: 4px solid var(--red); }
.prose pre code { padding: 0; background: none; border: 0; font-size: inherit; color: inherit; }
.prose blockquote { margin: 0 0 18px; padding-left: 18px; border-left: 3px solid var(--red); color: var(--ink-2); font-style: italic; }
.pager { display: grid; grid-template-columns: 1fr 1fr; margin-top: 64px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.pager a { display: flex; flex-direction: column; gap: 4px; padding: 18px 0; text-decoration: none; }
.pager a + a { text-align: right; border-left: 1px solid var(--hair); padding-left: 24px; }
.pager-label { font-size: 12px; font-weight: 700; font-stretch: 75%; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.pager strong { font-weight: 700; font-stretch: 80%; font-size: 24px; line-height: 1.1; }
.pager a:hover strong { color: var(--red); }

/* post */
.post .prose { margin-top: 40px; }
.lang-note { margin-top: 16px; font-size: 13.5px; color: var(--ink-3); }

/* resume */
.cv { display: grid; grid-template-columns: 220px 1fr; gap: 32px; padding: 40px 0; border-bottom: 1px solid var(--hair); }
.cv h2 { position: sticky; top: 24px; align-self: start; display: flex; align-items: baseline; gap: 12px; font-weight: 700; font-stretch: 85%; font-size: 24px; letter-spacing: -0.01em; line-height: 1.1; }
.cv-more { padding: 16px 0 0; border-top: 1px solid var(--hair); font-size: 14.5px; font-weight: 700; }
.cv-more a { text-decoration-color: var(--red); text-underline-offset: 3px; }
.cv-more a:hover { color: var(--red); }
.cv-entry { display: grid; grid-template-columns: 130px 1fr; gap: 20px; padding: 14px 0; border-top: 1px solid var(--hair); }
.cv-entry:first-child { border-top: 1px solid var(--ink); }
.cv-date { color: var(--ink-3); padding-top: 4px; }
.cv-entry h3 { font-weight: 700; font-size: 17.5px; line-height: 1.3; }
.cv-entry h3 a { text-decoration: none; }
.cv-entry h3 a:hover { color: var(--red); }
.cv-org { margin-top: 2px; font-size: 14.5px; font-weight: 600; color: var(--red); }
.cv-grade { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); }
.cv-grade b { color: var(--ink); font-weight: 700; }
.cv-desc { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); max-width: 60ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags li { font-size: 12px; font-weight: 600; padding: 1px 8px; border: 1px solid var(--hair); color: var(--ink-2); }
.spec .tags { margin-top: 6px; }
.cv-entry.has-thumb { grid-template-columns: 130px 1fr 112px; }
.cv-thumb {
  align-self: start; padding: 0; cursor: zoom-in;
  aspect-ratio: 4 / 3; background: var(--paper-2); border: 1px solid var(--hair); overflow: hidden;
  transition: border-color .2s;
}
.cv-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.cv-thumb:hover { border-color: var(--ink); }
.cv-thumb:hover img { transform: scale(1.04); }
.skill-group { padding: 14px 0; border-top: 1px solid var(--hair); }
.skill-group:first-child { border-top: 1px solid var(--ink); }
.skill-group h3 { font-size: 11.5px; font-weight: 700; font-stretch: 75%; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.skills { display: flex; flex-wrap: wrap; gap: 6px; }
.skills li { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px; border: 1px solid var(--hair); font-size: 13.5px; font-weight: 600; }
.skills img { width: 16px; height: 16px; }

/* lightbox (certificates) */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-rows: auto 1fr auto; gap: 12px;
  padding: 16px max(16px, 3vw) 20px;
  background: var(--paper);
  opacity: 0; transition: opacity .2s;
}
.lightbox.open { opacity: 1; }
.lightbox[hidden] { display: none; }
.lightbox-close {
  justify-self: start; width: 40px; height: 40px; display: grid; place-items: center;
  font: inherit; font-size: 24px; line-height: 1; cursor: pointer;
  color: var(--ink); background: var(--paper); border: 1px solid var(--ink);
  transition: background .15s, color .15s;
}
.lightbox-close:hover { background: var(--ink); color: var(--paper); }
.lightbox img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lightbox p { text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-2); }
html.no-scroll { overflow: hidden; }

/* support */
.wish-amazon { padding: 22px 0; border-bottom: 1px solid var(--hair); }
.wish-row { grid-template-columns: 52px 1fr 150px; }
.wish-row.has-thumb { grid-template-columns: 52px 1fr 150px 168px; }
.wish-row .row-title { text-decoration: none; }
.wish-code { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; }
.ship { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 28px; padding: 22px 0; border-bottom: 1px solid var(--hair); }
.ship address { font-style: normal; font-weight: 600; font-size: 18px; line-height: 1.5; }
.ship-note { margin-top: 14px; font-size: 14.5px; color: var(--ink-2); max-width: 60ch; }

/* colophon */
.colophon { margin-top: 96px; padding: 28px 0 32px; border-top: 2px solid var(--ink); }
.colophon .label { color: var(--red); }
.mail { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; }
.mail a {
  font-weight: 700; font-stretch: 75%;
  font-size: clamp(26px, 4.6vw, 52px); line-height: 1.1; letter-spacing: -0.01em;
  text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 6px;
  word-break: break-all;
}
.mail a:hover { color: var(--red); }
.copy { font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: none; border: 1px solid var(--ink); padding: 4px 9px; cursor: pointer; }
.copy.done { background: var(--ink); color: var(--paper); }
.colophon-links { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 28px; font-size: 14.5px; font-weight: 700; }
.colophon-links a { text-decoration: none; }
.colophon-links a:hover { color: var(--red); }
.colophon-bar a { text-decoration: none; color: var(--ink-2); font-weight: 700; }
.colophon-bar a:hover { color: var(--red); }
.colophon-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--hair); font-size: 12.5px; color: var(--ink-3); }

/* ---------------- responsive ---------------- */
@media (max-width: 1080px) {
  .row, .wish-row.has-thumb { grid-template-columns: 44px 1fr 120px; }
  .row-thumb { display: none; }
}
@media (max-width: 860px) {
  .mast { flex-wrap: wrap; gap: 14px 16px; margin-inline: 16px; padding: 16px 0 0; border-bottom: 0; }
  .mast .switches { margin-left: auto; }
  .mast-nav {
    order: 3; width: 100%; margin: 0; gap: 22px;
    padding: 10px 0 10px; border-top: 1px solid var(--hair); border-bottom: 2px solid var(--ink);
    overflow-x: auto; scrollbar-width: none;
  }
  .mast-nav::-webkit-scrollbar { display: none; }
  .mast-nav a { white-space: nowrap; font-size: 16px; }
  .main { margin-inline: 16px; }
  .intro { grid-template-columns: 1fr; gap: 28px; padding: 24px 0 48px; }
    .row, .post-row { grid-template-columns: 40px 1fr; gap: 6px 14px; }
  .row-meta { grid-column: 2; flex-direction: row; align-items: center; gap: 10px; }
  .row::before { left: -8px; right: -8px; }
  .proj-grid { grid-template-columns: 1fr; gap: 28px; }
  .spec { position: static; }
  .cv { grid-template-columns: 1fr; gap: 16px; padding: 32px 0; }
  .cv h2 { position: static; }
  .cv-entry, .cv-entry.has-thumb { grid-template-columns: 1fr; gap: 4px; }
  .cv-thumb { width: 140px; margin-top: 8px; }
  .wish-row, .wish-row.has-thumb { grid-template-columns: 40px 1fr; }
  .pager strong { font-size: 19px; }
  .pager a + a { padding-left: 14px; }
}

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