/* appunti — shared stylesheet for gbonomib.com/appunti
   Served at /appunti/appunti.css. Linked by every piece, including ones that
   live in other repos, so the whole writing area shares one source of truth.
   Fountain-pen ink on cool paper; system serif, no webfonts. */

:root {
  --paper:     #efeee7;
  --paper-2:   #e7e5db;
  --ink:       #23262d;
  --ink-soft:  #61636a;
  --ink-faint: #8b8c8f;
  --rule:      #d3d1c5;
  --accent:    #2d3c5e;
  --accent-2:  #46567c;

  --measure: 34rem;
  --serif: "Hoefler Text", "Iowan Old Style", "Palatino Linotype", Palatino,
           "Sitka Text", Georgia, Cambria, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper:#15161a; --paper-2:#1c1e23; --ink:#e9e7df; --ink-soft:#a2a29a;
    --ink-faint:#74757a; --rule:#2d2f36; --accent:#9db1d8; --accent-2:#b7c6e4;
  }
}
:root[data-theme="light"] {
  --paper:#efeee7; --paper-2:#e7e5db; --ink:#23262d; --ink-soft:#61636a;
  --ink-faint:#8b8c8f; --rule:#d3d1c5; --accent:#2d3c5e; --accent-2:#46567c;
}
:root[data-theme="dark"] {
  --paper:#15161a; --paper-2:#1c1e23; --ink:#e9e7df; --ink-soft:#a2a29a;
  --ink-faint:#74757a; --rule:#2d2f36; --accent:#9db1d8; --accent-2:#b7c6e4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(2.2rem, 6vw, 4rem) clamp(1.4rem, 5vw, 3rem) 4rem;
}
.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
a { color: var(--accent); }

/* breadcrumb */
.crumb {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0;
}
.crumb a { color: var(--ink-faint); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.crumb .here { color: var(--ink-soft); }

.dek {
  max-width: 30rem;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 1.1rem 0 0;
}

/* ---------- TIMELINE ---------- */
.epigraph {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 2.6rem 0 2.8rem;
  max-width: 30rem;
}
.entries { position: relative; margin: 0; padding: 0; list-style: none; }
.entries::before {
  content: ""; position: absolute; top: 0.55rem; bottom: 0.55rem;
  left: 6.5rem; width: 1px; background: var(--rule);
}
.yr {
  font-family: var(--sans);
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint); margin: 2.4rem 0 1.2rem; padding-left: 7.5rem;
}
.yr:first-child { margin-top: 0; }
.entry { position: relative; margin: 0 0 1.75rem; }
.entry > a {
  display: grid; grid-template-columns: 5.5rem 2rem 1fr;
  align-items: baseline; text-decoration: none; color: inherit; cursor: pointer;
}
.entry .date {
  grid-column: 1; text-align: right; font-size: 0.8rem; letter-spacing: 0.02em;
  color: var(--ink-faint); white-space: nowrap;
  font-variant-numeric: oldstyle-nums tabular-nums; padding-top: 0.28rem;
}
.entry .node {
  position: absolute; left: 6.5rem; top: 0.62rem; width: 9px; height: 9px;
  transform: translateX(-50%); border-radius: 50%; background: var(--paper);
  border: 1.5px solid var(--ink-faint);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.entry .body { grid-column: 3; }
.entry .title {
  font-size: 1.35rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.005em;
  display: inline; background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size .28s ease, color .18s ease; padding-bottom: 1px;
}
.entry .where {
  font-family: var(--sans); font-size: 0.68rem; letter-spacing: 0.04em;
  color: var(--ink-faint); margin-left: 0.5rem; white-space: nowrap;
}
.entry .summary { color: var(--ink-soft); margin: 0.3rem 0 0; font-size: 1rem; }
.entry .sig {
  font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0.4rem 0 0;
}
.entry > a:hover .title, .entry > a:focus-visible .title { color: var(--accent); background-size: 100% 1px; }
.entry > a:hover .node, .entry > a:focus-visible .node {
  background: var(--accent); border-color: var(--accent); transform: translateX(-50%) scale(1.15);
}
.entry > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

.empty {
  font-family: var(--sans); font-size: 0.9rem; color: var(--ink-faint);
  font-style: italic; margin-top: 3rem;
}

/* ---------- ARTICLE ---------- */
.article { max-width: var(--measure); }
.article .back {
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.03em;
  color: var(--ink-soft); text-decoration: none; display: inline-flex;
  align-items: center; gap: 0.4rem; margin-bottom: 2.4rem;
}
.article .back:hover { color: var(--accent); }
.article .back .arw { transition: transform .2s ease; }
.article .back:hover .arw { transform: translateX(-3px); }
.article .kicker {
  font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0 0 0.9rem;
}
.article h1 {
  font-size: 1.9rem; font-weight: 600; line-height: 1.12; letter-spacing: -0.01em;
  margin: 0; text-wrap: balance;
}
.article .byline {
  color: var(--ink-faint); font-size: 0.85rem; font-style: italic;
  margin: 1rem 0 2.6rem; padding-bottom: 2.2rem; border-bottom: 1px solid var(--rule);
}
.article .byline .sig {
  font-family: var(--sans); font-style: normal; font-size: 0.66rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
  margin-left: 0.55rem; vertical-align: 0.08em;
}
.article .byline .ai-tag {
  font-family: var(--sans); font-style: normal; font-size: 0.62rem;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-faint);
  border: 1px solid var(--rule); border-radius: 999px; padding: 0.18rem 0.55rem;
  margin-left: 0.55rem; white-space: nowrap; vertical-align: 0.1em;
}
.article .byline .repo-tag {
  font-family: var(--mono); font-style: normal; font-size: 0.72rem;
  letter-spacing: 0; color: var(--ink-soft); text-decoration: none;
  margin-left: 0.7rem; white-space: nowrap;
  border-bottom: 1px solid var(--rule); padding-bottom: 1px;
}
.article .byline .repo-tag:hover { color: var(--accent); border-color: var(--accent); }
.article :is(p, ul, ol, blockquote, figure, pre, table, hr) { margin: 0 0 1.3rem; }
.article > .body > :first-child { margin-top: 0; }
.article p.lead { font-size: 1.2rem; line-height: 1.55; }
.article p.lead::first-letter {
  initial-letter: 2; -webkit-initial-letter: 2; font-weight: 600;
  margin-right: 0.6rem; color: var(--accent);
}
.article h2 { font-size: 1.4rem; font-weight: 600; margin: 2.4rem 0 0.9rem; letter-spacing: -0.005em; }
.article h3 { font-size: 1.15rem; font-weight: 600; margin: 2rem 0 0.7rem; }
.article a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.article :is(ul, ol) { padding-left: 1.4rem; }
.article li { margin: 0.3rem 0; }
.article blockquote {
  border-left: 2px solid var(--rule); padding-left: 1.1rem;
  color: var(--ink-soft); font-style: italic;
}
.article img, .article svg { max-width: 100%; height: auto; }
.article table { border-collapse: collapse; font-size: 0.92em; line-height: 1.5; }
.article :is(th, td) { padding: 0.35em 1.1em 0.35em 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.article th { font-weight: 600; color: var(--ink-soft); }
.article figure { margin-inline: 0; }
.article figure > :is(img, svg) { display: block; margin: 0 auto; }
.article figcaption {
  font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint);
  text-align: center; margin-top: 0.6rem;
}
.article :is(pre, code) { font-family: var(--mono); font-size: 0.88em; }
.article code { background: var(--paper-2); padding: 0.1em 0.35em; border-radius: 3px; }
.article pre {
  background: var(--paper-2); padding: 1rem 1.1rem; border-radius: 6px;
  overflow-x: auto; line-height: 1.5;
}
.article pre code { background: none; padding: 0; }
/* Hand-typeset math — display formulas are a .math div of <span> terms;
   variables are <var> (serif italic), subscripts <sub>. No webfonts, no JS. */
.article .math { margin: 0 0 1.3rem; text-align: center; line-height: 1.9; }
.article .math > span { display: inline-block; margin: 0 0.8em; }
.article var { font-style: italic; }
.article :is(sub, sup) { font-size: 0.72em; line-height: 0; }
.article hr { border: 0; border-top: 1px solid var(--rule); }
.article table { border-collapse: collapse; width: 100%; font-size: 0.95rem; display: block; overflow-x: auto; }
.article th, .article td { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--rule); }

/* Share — one quiet "Copy link" at the article foot. Hidden until JS un-hides it. */
.article .share {
  margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--rule);
  display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap;
}
/* `hidden` is display:none in the UA sheet, and the rule below sets display at
   class specificity, which outranks it. Without this a share button the script
   never enabled would still be sitting there — and the edit link, whose hidden
   state is the normal one for a reader, would show on every published page. */
.share-btn[hidden] { display: none; }
.share-btn {
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.03em;
  color: var(--ink-soft); background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.45rem;
  transition: color .18s ease;
}
.share-btn .txt { font-variant-numeric: normal; }
.share-btn svg { width: 15px; height: 15px; }
.share-btn:hover, .share-btn.done { color: var(--accent); }
a.share-btn { text-decoration: none; }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.article th { font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }

/* ---------- STAGING (/lab/appunti) ---------- */
.lock {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.02em;
  color: var(--ink-faint); margin: 1rem 0 0;
}
.lock svg { width: 13px; height: 13px; stroke: var(--ink-faint); fill: none; }
.intro {
  max-width: 32rem; color: var(--ink-soft); font-style: italic;
  font-size: 1.12rem; line-height: 1.5; margin: 0.85rem 0 0;
}
.stats {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.02em;
  color: var(--ink-soft); margin: 2.4rem 0 0; padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
}
.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stats .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-faint); }
.pieces { list-style: none; margin: 0; padding: 0; }
.piece {
  display: grid; grid-template-columns: 1fr auto; align-items: start;
  gap: 0 1.1rem; padding: 1.3rem 0; border-bottom: 1px solid var(--rule);
}
.piece .meta { min-width: 0; }
.piece .ttl-row { display: flex; align-items: baseline; gap: 0.6rem; }
.piece .node {
  flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper); border: 1.5px solid var(--ink-faint); transform: translateY(-1px);
}
.piece[data-public="true"] .node { background: var(--accent); border-color: var(--accent); }
.piece .ttl { font-size: 1.28rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
.piece .ttl a { color: inherit; text-decoration: none; }
.piece .ttl a:hover { color: var(--accent); }
.piece .sum { color: var(--ink-soft); font-size: 0.98rem; margin: 0.2rem 0 0; }
.piece .sub {
  font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.01em;
  color: var(--ink-faint); margin: 0.55rem 0 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
}
.piece .sub a { color: var(--ink-soft); text-decoration: none; }
.piece .sub a:hover { color: var(--accent); }
.piece .sub .dotsep { width: 3px; height: 3px; border-radius: 50%; background: var(--rule); }
.piece .pill {
  font-family: var(--sans); font-size: 0.65rem; letter-spacing: 0.11em;
  text-transform: uppercase; padding: 0.22rem 0.6rem; border-radius: 999px;
  white-space: nowrap; margin-top: 0.3rem; border: 1px solid var(--rule); color: var(--ink-faint);
}
.piece[data-public="true"] .pill { background: var(--accent); border-color: var(--accent); color: var(--paper); }

footer {
  margin-top: 4rem; padding-top: 1.6rem; border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.02em;
  color: var(--ink-faint); line-height: 1.6;
}
footer a { color: var(--ink-soft); }

@media (max-width: 560px) {
  .entries::before { left: 3px; }
  .yr { padding-left: 1.4rem; }
  .entry > a { grid-template-columns: 1fr; }
  .entry .date { grid-column: 1; text-align: left; padding: 0 0 0 1.4rem; }
  .entry .node { left: 3px; top: 0.5rem; }
  .entry .body { grid-column: 1; padding-left: 1.4rem; margin-top: 0.1rem; }
  .entry .where { display: block; margin: 0.15rem 0 0; }
  .piece { grid-template-columns: 1fr; }
  .piece .pill { justify-self: start; margin-top: 0.7rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .entry { opacity: 0; transform: translateY(6px); animation: rise .5s ease forwards; }
  .entry:nth-child(2) { animation-delay: .04s; }
  .entry:nth-child(3) { animation-delay: .08s; }
  .entry:nth-child(4) { animation-delay: .12s; }
  .entry:nth-child(5) { animation-delay: .16s; }
  .entry:nth-child(6) { animation-delay: .20s; }
  .entry:nth-child(7) { animation-delay: .24s; }
  @keyframes rise { to { opacity: 1; transform: none; } }
}

/* ---------- CROSS-PAGE TRANSITION ----------
   A subtle slide between an article and the /appunti timeline, on real
   navigations (the swipe, the "← Appunti" tap, a timeline entry). Pure
   enhancement: browsers without cross-document View Transitions just navigate,
   exactly as before. Direction (back/fwd) is tagged by a tiny script; when the
   tag is absent the base rule below is a plain cross-fade, so it never looks
   wrong. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root), ::view-transition-new(root) {
    animation-duration: .26s; animation-timing-function: ease;
  }
  /* back: article eases off to the right, timeline enters from the left */
  :root:active-view-transition-type(back)::view-transition-old(root) { animation-name: vt-old-back; }
  :root:active-view-transition-type(back)::view-transition-new(root) { animation-name: vt-new-back; }
  /* fwd: timeline eases off to the left, article enters from the right */
  :root:active-view-transition-type(fwd)::view-transition-old(root)  { animation-name: vt-old-fwd; }
  :root:active-view-transition-type(fwd)::view-transition-new(root)  { animation-name: vt-new-fwd; }
  @keyframes vt-old-back { to   { transform: translateX(12%);  opacity: 0; } }
  @keyframes vt-new-back { from { transform: translateX(-12%); opacity: 0; } }
  @keyframes vt-old-fwd  { to   { transform: translateX(-12%); opacity: 0; } }
  @keyframes vt-new-fwd  { from { transform: translateX(12%);  opacity: 0; } }
}
/* Reduced motion: keep the instant swap, no sliding or fading. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation: none !important; }
}
