/* Guido Lavorgna: portfolio. Plain CSS, no build step. */

:root {
  --bg: #f7f6f1;
  --surface: #ffffff;
  --ink: #1d2320;
  --ink-soft: #4a5450;
  --line: #dcdad0;
  --green: #2a7a4b;
  --blue: #1f4e9b;
  --ochre: #e9b13a;
  --accent: var(--green);
  --accent-ink: #1f5f3a;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 8px 24px rgba(20, 30, 25, .06);
  --radius: 10px;
  --header-h: 60px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131715;
    --surface: #1c221f;
    --ink: #eceee9;
    --ink-soft: #b3bbb6;
    --line: #2f3833;
    --accent: #58b47c;
    --accent-ink: #7ccf9c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 64px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: .01em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.main-nav { display: flex; align-items: center; gap: clamp(10px, 3vw, 28px); }
.main-nav a.nav-link { color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: .98rem; padding: 6px 2px; border-bottom: 2px solid transparent; }
.main-nav a.nav-link:hover { color: var(--ink); }
.main-nav a.nav-link[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ochre); }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: .78rem; font-weight: 600; letter-spacing: .04em; }
.lang button { all: unset; cursor: pointer; padding: 5px 10px; color: var(--ink-soft); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lang button:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }

/* ---------- Hero (About) ---------- */
.hero { padding: clamp(40px, 8vw, 88px) 0 clamp(28px, 5vw, 56px); }
.hero .wrap { display: grid; gap: 32px; align-items: center; grid-template-columns: 1fr; }
.eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--accent-ink); font-weight: 600; margin: 0 0 14px; }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.4rem, 7vw, 4.2rem); line-height: 1.05; margin: 0 0 18px; letter-spacing: -.01em; }
.hero .lede { font-size: clamp(1.05rem, 2.2vw, 1.3rem); color: var(--ink-soft); max-width: 40ch; margin: 0; }
.hero .rule { display: flex; height: 4px; width: 120px; margin-top: 28px; border-radius: 2px; overflow: hidden; }
.hero .rule i { flex: 1; }
.hero .rule i:nth-child(1) { background: #a9cfdc; }
.hero .rule i:nth-child(2) { background: var(--ochre); }
.hero .rule i:nth-child(3) { background: var(--blue); }
.hero .rule i:nth-child(4) { background: var(--green); }
.portrait { margin: 0; justify-self: start; }
.portrait img { width: min(300px, 80vw); aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 0; border-radius: 16px; box-shadow: var(--shadow); border: 6px solid var(--surface); background: var(--surface); }
@media (min-width: 820px) {
  .hero .wrap { grid-template-columns: 1.4fr 1fr; gap: 56px; }
  .portrait { justify-self: end; }
  .portrait img { width: min(360px, 100%); }
}

/* ---------- About layout: TOC + chapters ---------- */
.about-grid { display: grid; gap: 0; grid-template-columns: minmax(0, 1fr); padding-bottom: 72px; }
.about-grid > * { min-width: 0; }
.toc { position: sticky; top: var(--header-h); z-index: 40; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); margin-inline: -16px; padding-inline: 16px; }
.toc ol { list-style: none; margin: 0; padding: 10px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.toc ol::-webkit-scrollbar { display: none; }
.toc a { display: block; white-space: nowrap; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .86rem; color: var(--ink-soft); text-decoration: none; background: var(--surface); }
.toc a .n { font-weight: 700; margin-right: 6px; color: var(--accent-ink); }
.toc a .t { display: inline; }
.toc a[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toc a[aria-current="true"] .n { color: var(--ochre); }
@media (min-width: 980px) {
  .about-grid { grid-template-columns: 250px minmax(0, 1fr); gap: 56px; }
  .toc { top: calc(var(--header-h) + 24px); align-self: start; margin: 0; padding: 0; border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .toc ol { flex-direction: column; overflow: visible; gap: 2px; padding: 0; border-left: 1px solid var(--line); }
  .toc a { border: 0; border-radius: 0; background: none; white-space: normal; padding: 8px 0 8px 16px; margin-left: -1px; border-left: 2px solid transparent; font-size: .92rem; line-height: 1.35; }
  .toc a[aria-current="true"] { background: none; color: var(--ink); border-left-color: var(--ochre); font-weight: 600; }
  .toc a[aria-current="true"] .n { color: var(--accent-ink); }
  .toc a .n { display: inline-block; min-width: 1.4em; }
}

.chapter { padding: clamp(36px, 6vw, 60px) 0; border-bottom: 1px solid var(--line); }
.chapter:last-child { border-bottom: 0; }
.chapter-head { display: flex; gap: 16px; align-items: baseline; margin-bottom: 22px; }
.chapter-head .num { font-family: var(--serif); font-size: clamp(2rem, 5vw, 3rem); color: var(--ochre); line-height: 1; font-weight: 600; }
.chapter h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.45rem, 3.4vw, 2rem); line-height: 1.2; margin: 0; }
.chapter p { max-width: 68ch; margin: 0 0 1em; }
.bridge { color: var(--ink-soft); font-style: italic; border-left: 3px solid var(--line); padding-left: 16px; margin-top: 28px !important; }

.cards { display: grid; gap: 16px; margin: 24px 0; padding: 0; list-style: none; grid-template-columns: 1fr; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); border-top: 4px solid var(--accent); }
.card:nth-child(4n+1) { border-top-color: #7fb6c9; }
.card:nth-child(4n+2) { border-top-color: var(--ochre); }
.card:nth-child(4n+3) { border-top-color: var(--blue); }
.card:nth-child(4n+4) { border-top-color: var(--green); }
.card h3 { font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; margin: 0 0 8px; }
.card p { margin: 0; font-size: .97rem; color: var(--ink-soft); max-width: none; }
.card .more { display: inline-block; margin-top: 10px; font-weight: 600; font-size: .95rem; }
@media (min-width: 700px) {
  .cards.two { grid-template-columns: repeat(2, 1fr); }
  .cards.three { grid-template-columns: repeat(3, 1fr); }
}

/* Table: real table on desktop, stacked cards on mobile */
.table-wrap { margin: 24px 0; }
.projects-table { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.projects-table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); padding: 12px 14px; background: color-mix(in srgb, var(--line) 40%, var(--surface)); }
.projects-table td { padding: 14px; vertical-align: top; border-top: 1px solid var(--line); }
.projects-table td:first-child { font-weight: 600; font-family: var(--serif); font-size: 1.02rem; }
@media (max-width: 759px) {
  .projects-table, .projects-table tbody, .projects-table tr, .projects-table td { display: block; }
  .projects-table thead { position: absolute; left: -9999px; }
  .projects-table { border: 0; background: none; box-shadow: none; }
  .projects-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; padding: 6px 4px; box-shadow: var(--shadow); }
  .projects-table td { border: 0; padding: 8px 14px; }
  .projects-table td::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 600; margin-bottom: 2px; font-family: var(--sans); }
}

.pull { font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.65rem); line-height: 1.45; border-left: 4px solid var(--ochre); padding-left: 22px; max-width: 46ch !important; }

/* ---------- Page header (Projects) ---------- */
.page-head { padding: clamp(36px, 6vw, 72px) 0 28px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.08; margin: 0 0 12px; }
.page-head .lede { color: var(--ink-soft); font-size: 1.15rem; max-width: 52ch; margin: 0; }
.section { padding: 28px 0 56px; }
.section h2 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 20px; }

/* Video facade */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #16201b; box-shadow: var(--shadow); max-width: 960px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play { all: unset; cursor: pointer; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background:
  radial-gradient(120% 90% at 20% 10%, rgba(233,177,58,.35), transparent 55%),
  radial-gradient(120% 90% at 90% 100%, rgba(42,122,75,.55), transparent 55%),
  linear-gradient(135deg, #1f4e9b, #16201b); text-decoration: none; }
.video-play:focus-visible { outline: 4px solid var(--ochre); outline-offset: -8px; }
.video-play .btn { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: rgba(255,255,255,.95); transition: transform .2s; }
.video-play:hover .btn { transform: scale(1.08); }
.video-play svg { width: 34px; height: 34px; margin-left: 5px; fill: #16201b; }
.video-play .label { position: absolute; bottom: 16px; left: 20px; right: 20px; font-size: .95rem; opacity: .92; }
.video-note { font-size: .85rem; color: var(--ink-soft); margin: 10px 0 0; }

/* Project cover card */
.project-card { display: grid; grid-template-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: transform .2s, box-shadow .2s; }
.project-card:hover { transform: translateY(-3px); color: inherit; box-shadow: 0 2px 4px rgba(20,30,25,.08), 0 16px 36px rgba(20,30,25,.12); }
.project-card .cover { aspect-ratio: 16 / 9; background: #f0efe8; }
.project-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: left center; }
.project-card .body { padding: 24px 26px 28px; display: flex; flex-direction: column; justify-content: center; }
.project-card h3 { font-family: var(--serif); font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; margin: 0 0 6px; }
.project-card .sub { font-style: italic; color: var(--ink-soft); margin: 0 0 14px; }
.project-card p { margin: 0 0 16px; color: var(--ink-soft); }
.project-card .cta { font-weight: 600; color: var(--accent-ink); }
@media (min-width: 860px) { .project-card { grid-template-columns: 1.3fr 1fr; } .project-card .cover { aspect-ratio: auto; min-height: 320px; } }

/* ---------- Project page ---------- */
.back { display: inline-block; margin: 28px 0 0; font-size: .95rem; text-decoration: none; color: var(--ink-soft); }
.back:hover { color: var(--ink); }
.meta { display: grid; gap: 16px 32px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 28px 0 0; padding: 22px 0 0; border-top: 1px solid var(--line); }
.meta dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); font-weight: 600; margin-bottom: 4px; }
.meta dd { margin: 0; }
.gallery { display: grid; gap: 14px; grid-template-columns: 1fr; list-style: none; padding: 0; margin: 0; }
@media (min-width: 560px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .gallery { grid-template-columns: repeat(3, 1fr); gap: 18px; } }
.gallery button { all: unset; display: block; cursor: zoom-in; width: 100%; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; }
.gallery button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.gallery img { width: 100%; aspect-ratio: 1376 / 728; object-fit: cover; transition: transform .35s; }
.gallery button:hover img { transform: scale(1.03); }
.gallery .cap { display: block; padding: 10px 14px 12px; font-size: .88rem; color: var(--ink-soft); line-height: 1.4; }
.gallery .cap b { color: var(--accent-ink); margin-right: 6px; }
.hint { color: var(--ink-soft); font-size: .9rem; margin: 0 0 18px; }

/* Lightbox */
dialog.lightbox { border: 0; padding: 0; background: transparent; width: 100vw; height: 100dvh; max-width: none; max-height: none; color: #fff; overflow: hidden; }
dialog.lightbox::backdrop { background: rgba(8, 11, 10, .96); }
.lb { position: relative; width: 100%; height: 100%; display: grid; grid-template-rows: 1fr auto; padding: 56px 12px 16px; touch-action: pan-y; }
.lb figure { margin: 0; min-height: 0; display: grid; place-items: center; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; background: #f7f6f1; }
.lb figcaption { text-align: center; padding-top: 12px; font-size: .95rem; color: #e8ebe6; }
.lb .count { color: #aab3ad; margin-right: 8px; }
.lb button { all: unset; cursor: pointer; position: absolute; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: rgba(12,16,14,.72); border: 1px solid rgba(255,255,255,.35); color: #fff; font-size: 1.6rem; line-height: 1; }
.lb button:hover { background: rgba(12,16,14,.95); }
.lb button:focus-visible { outline: 3px solid var(--ochre); }
.lb .close { top: 8px; right: 8px; }
.lb .prev, .lb .next { top: 50%; transform: translateY(-50%); }
.lb .prev { left: 8px; }
.lb .next { right: 8px; }
@media (max-width: 640px) { .lb .prev, .lb .next { top: auto; bottom: 8px; transform: none; } .lb figcaption { padding-bottom: 54px; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--ink-soft); font-size: .88rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print { .site-header, .toc, .video, .site-footer { display: none; } }

/* equal-height gallery tiles */
.gallery li { display: flex; }
.gallery button { display: flex; flex-direction: column; }
.gallery .cap { flex: 1; }
