/* app/static/css/site.css
   lorenzoiotti.com: warm-paper editorial layout, serif display type,
   sans UI, mono details. One accent (ink violet). Light + dark. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --paper: #f6f4ef;
  --surface: #fcfbf9;
  --surface-2: #efece5;
  --ink: #151412;
  --ink-2: #4a4843;
  --ink-3: #6f6b63;
  --rule: #e3dfd6;
  --rule-strong: #cfcac0;
  --accent: #4a3aa7;
  --accent-wash: rgb(74 58 167 / 0.07);
  --accent-line: rgb(74 58 167 / 0.4);
  --voice-model: #4a3aa7;
  --voice-user: #eb6834;
  --live: #1baf7a;
  --shadow: 0 1px 0 rgb(21 20 18 / 0.03), 0 12px 32px -18px rgb(21 20 18 / 0.18);

  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --max: 1180px;
  --gutter: clamp(16px, 4.5vw, 48px);
  --radius: 12px;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0e0e0d;
    --surface: #161615;
    --surface-2: #1d1d1b;
    --ink: #edebe5;
    --ink-2: #b5b2aa;
    --ink-3: #8e8a82;
    --rule: #262624;
    --rule-strong: #3a3935;
    --accent: #9085e9;
    --accent-wash: rgb(144 133 233 / 0.1);
    --accent-line: rgb(144 133 233 / 0.45);
    --voice-model: #9085e9;
    --voice-user: #d95926;
    --live: #199e70;
    --shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 12px 32px -18px rgb(0 0 0 / 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e0e0d;
  --surface: #161615;
  --surface-2: #1d1d1b;
  --ink: #edebe5;
  --ink-2: #b5b2aa;
  --ink-3: #8e8a82;
  --rule: #262624;
  --rule-strong: #3a3935;
  --accent: #9085e9;
  --accent-wash: rgb(144 133 233 / 0.1);
  --accent-line: rgb(144 133 233 / 0.45);
  --voice-model: #9085e9;
  --voice-user: #d95926;
  --live: #199e70;
  --shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 12px 32px -18px rgb(0 0 0 / 0.6);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
a:hover { color: var(--accent); text-decoration-color: var(--accent-line); }

::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }

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

h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--paper); }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in oklab, var(--paper) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 21px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  font-variation-settings: "opsz" 24;
}
.wordmark:hover { color: var(--ink); }

.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); background: var(--surface-2); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 640px) {
  .nav .nav-optional { display: none; }
  .nav a { padding: 6px 8px; }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(48px, 9vw, 112px) 0 clamp(56px, 8vw, 104px); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(40px, 6vw, 72px);
  align-items: end;
}
@media (min-width: 980px) {
  .hero-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
}

.hero h1 {
  margin-top: 20px;
  font-family: var(--font-serif);
  font-size: clamp(54px, 10vw, 118px);
  line-height: 0.92;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 72;
}
.hero .lede {
  margin-top: clamp(24px, 3.5vw, 36px);
  max-width: 26ch;
  text-wrap: balance;
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.22;
  letter-spacing: -0.012em;
  font-variation-settings: "opsz" 36;
}
.hero .intro {
  margin-top: 24px;
  max-width: 58ch;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}
.hero .intro + .intro { margin-top: 12px; }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}
.pill svg { width: 15px; height: 15px; color: var(--ink-3); transition: color 0.15s ease; }
.pill:hover { color: var(--ink); border-color: var(--ink-3); background: var(--surface); }
.pill:hover svg { color: var(--accent); }
.pill.pill-solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pill.pill-solid svg { color: currentColor; opacity: 0.7; }
.pill.pill-solid:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.pill.pill-solid:hover svg { opacity: 1; }

/* "Now" card */
.now-card {
  display: block;
  padding: 22px 22px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.now-card:hover { color: inherit; border-color: var(--rule-strong); transform: translateY(-2px); }
@media (max-width: 979px) { .now-card { max-width: 520px; } }
.now-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.live-dot { display: inline-flex; align-items: center; gap: 8px; }
.live-dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--live) 22%, transparent);
}
.now-card h2 {
  margin-top: 14px;
  font-family: var(--font-serif);
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 30;
}
.now-card p { margin-top: 8px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.now-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}
.now-foot .arrow svg { width: 16px; height: 16px; color: var(--ink); transition: transform 0.2s ease, color 0.2s ease; }
.now-card:hover .now-foot .arrow svg { transform: translateX(3px); color: var(--accent); }

/* Full-duplex tape illustration */
.duplex { margin-top: 18px; }
.duplex svg { width: 100%; height: auto; }
.duplex .lane-bg { fill: var(--surface-2); }
.duplex .lane-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; fill: var(--ink-3); }
.duplex .tick { fill: var(--rule-strong); }
.duplex .seg-user { fill: var(--voice-user); }
.duplex .seg-user-soft { fill: var(--voice-user); opacity: 0.5; }
.duplex .seg-model { fill: var(--voice-model); }
.duplex .seg-model-soft { fill: var(--voice-model); opacity: 0.5; }
.duplex .event { font-family: var(--font-mono); font-size: 9.5px; fill: var(--ink-3); }
.duplex .future { fill: var(--surface); opacity: 0.86; }
.duplex .playhead { stroke: var(--ink); stroke-width: 1.25; }
.duplex .fade-stop-solid { stop-color: var(--surface); stop-opacity: 1; }
.duplex .fade-stop-clear { stop-color: var(--surface); stop-opacity: 0; }
.duplex .tape { animation: duplex-scroll 14s linear infinite; }
@keyframes duplex-scroll { from { transform: translateX(0); } to { transform: translateX(-560px); } }
@media (prefers-reduced-motion: reduce) { .duplex .tape { animation: none; } }

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 8vw, 104px) 0; border-top: 1px solid var(--rule); }
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: clamp(32px, 5vw, 56px);
}
@media (min-width: 980px) {
  .section-head { grid-template-columns: 200px minmax(0, 1fr); gap: 40px; align-items: baseline; }
}
.section-head h2 {
  font-family: var(--font-serif);
  font-size: clamp(32px, 4.4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.022em;
  font-variation-settings: "opsz" 48;
}
.section-sub { max-width: 60ch; font-size: 16px; color: var(--ink-2); }
.section-head h2 + .section-sub { margin-top: 12px; }

/* ---------- Selected work ---------- */
.work-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px 40px;
  padding: clamp(28px, 4vw, 44px) 0;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
@media (min-width: 980px) {
  .work { grid-template-columns: 200px minmax(0, 1fr) 220px; }
}
.work:target { animation: target-wash 2.4s ease-out; }
@keyframes target-wash {
  0%, 30% { background: var(--accent-wash); box-shadow: -16px 0 0 var(--accent-wash), 16px 0 0 var(--accent-wash); }
  100% { background: transparent; box-shadow: none; }
}

.work-meta { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 979px) {
  .work-meta { flex-direction: row; flex-wrap: wrap; align-items: baseline; column-gap: 14px; }
  .work-meta .area-tag + .area-tag::before { content: "·\00a0"; margin-left: -8px; }
}
.work-index {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--ink-3);
  font-variation-settings: "opsz" 14;
}
.work h3 {
  font-family: var(--font-serif);
  font-size: clamp(27px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 40;
}
.work .desc { margin-top: 12px; max-width: 64ch; font-size: 16.5px; line-height: 1.65; color: var(--ink-2); }

.work-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.work-link svg { width: 17px; height: 17px; color: var(--accent); }
.work-link:hover { color: var(--accent); }

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stack li {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
}
@media (min-width: 980px) {
  .stack { display: block; padding-top: 4px; }
  .stack li {
    display: block;
    height: auto;
    padding: 7px 0;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    background: none;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
  }
  .stack li:first-child { border-top: 0; padding-top: 0; }
}

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---------- More experiments ---------- */
.notebook { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px 40px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 980px) {
  .entry { grid-template-columns: 200px minmax(0, 1fr) 220px; align-items: baseline; }
}
.entry-date { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); }
.entry h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 22;
}
.entry p { margin-top: 6px; max-width: 64ch; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.entry-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-tags .tag { font-size: 11px; }

/* ---------- Applied work ---------- */
.applied {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}
.applied-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}
.applied-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.applied-card h3 {
  margin-top: 22px;
  font-family: var(--font-serif);
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 32;
}
.applied-card .role { margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.applied-card .desc { margin-top: 14px; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.applied-card ul { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.applied-card li { position: relative; margin-top: 8px; padding-left: 16px; }
.applied-card li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.7em;
  width: 7px; height: 1px;
  background: var(--ink-3);
}
.applied-card .tags { margin-top: auto; padding-top: 22px; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(32px, 5vw, 56px); }
@media (min-width: 980px) { .about-grid { grid-template-columns: 200px minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; } }
.about-text > p {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.48;
  font-variation-settings: "opsz" 22;
}
.about-text > p + p { margin-top: 18px; }
.about-text > p.muted { color: var(--ink-2); }

.principles { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: principle; }
.principles li { padding: 15px 0; border-top: 1px solid var(--rule); counter-increment: principle; }
.principles li:last-child { border-bottom: 1px solid var(--rule); }
.principles strong { display: block; font-size: 15.5px; font-weight: 500; }
.principles strong::before {
  content: counter(principle, decimal-leading-zero);
  margin-right: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-3);
}
.principles span { display: block; margin-top: 4px; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }

.toolbox { margin-top: 36px; }
.toolbox-group + .toolbox-group { margin-top: 18px; }
.toolbox-group .tags { margin-top: 10px; }

/* ---------- Contact / footer ---------- */
.contact { padding: clamp(64px, 10vw, 128px) 0; border-top: 1px solid var(--rule); }
.contact h2 {
  max-width: 18ch;
  margin-top: 20px;
  font-family: var(--font-serif);
  font-size: clamp(36px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 72;
  overflow-wrap: anywhere;
}
.contact h2 a { text-decoration-thickness: 2px; text-underline-offset: 0.12em; text-decoration-color: var(--accent-line); }
.contact-text { margin-top: 22px; max-width: 56ch; color: var(--ink-2); }

.site-footer { padding: 28px 0 40px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-3); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--ink-2); }

/* ---------- 404 ---------- */
.not-found { padding: clamp(80px, 14vw, 180px) 0; }
.not-found h1 {
  margin-top: 16px;
  max-width: 18ch;
  font-family: var(--font-serif);
  font-size: clamp(44px, 7vw, 80px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 72;
}
.not-found-text { margin-top: 18px; color: var(--ink-2); }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  .site-header, .theme-toggle, .now-card .duplex { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
}
