/* ============================================================
   Filippo Ugolini — shared stylesheet
   Display & body: Zilla Slab (body at weight 500)
   Labels/nav:     JetBrains Mono
   Chinese rain:   FangSong Rain (subset)
   Color: pale ivory paper, deep ink-blue, garnet accent.
   ============================================================ */

@font-face {
  font-family: "FangSong Rain";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/fangsong-rain-subset.woff2") format("woff2");
}

/* Zilla Slab and JetBrains Mono are self-hosted (woff2 in /assets/fonts). */
@font-face {
  font-family: "Zilla Slab";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("/assets/fonts/zilla-slab-v12-latin-500.woff2") format("woff2");
}
@font-face {
  font-family: "Zilla Slab";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("/assets/fonts/zilla-slab-v12-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Zilla Slab";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("/assets/fonts/zilla-slab-v12-latin-700.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-v24-latin-regular.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-v24-latin-500.woff2") format("woff2");
}

:root {
  --paper:    #f7f4ec;
  --ink:      #15243b;
  --ink-soft: #3a4a63;
  --garnet:   #6e1f23;
  --rule:     #d9d2c2;
  --muted:    #6b6359;
  --max:      52rem;
}

* { box-sizing: border-box; }

/* Page cross-fade is currently disabled. To re-enable, uncomment the line
   below (it must stay at the top level — never inside a media query). */
/* @view-transition { navigation: auto; } */
::view-transition-group(root) { background: var(--paper); }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.7s; }

html { font-size: 19px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }

/* ---------- Header / nav ---------- */
.site-header {
  position: relative;
  z-index: 1;
  min-height: 4.6rem;   /* reserve the header's height so injecting it
                           later via JS doesn't push the page down */
}
.site-header::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: var(--paper);
  -webkit-mask: linear-gradient(to bottom, #000 0, #000 calc(100% - 40px), transparent 100%);
  mask: linear-gradient(to bottom, #000 0, #000 calc(100% - 40px), transparent 100%);
}
.site-header .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 1.4rem 1.5rem; flex-wrap: wrap; gap: 0.6rem;
}
.site-name {
  font-family: "Zilla Slab", serif; font-weight: 700;
  font-size: 1.3rem; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none; border: none;
}
.site-nav {
  display: flex; gap: 1.6rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem; letter-spacing: 0.04em; text-transform: lowercase;
}
.site-nav a {
  position: relative; color: var(--ink-soft); text-decoration: none;
  border: none; padding-bottom: 4px; transition: color .18s;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  height: 2px; width: 0; background: var(--garnet);
  transition: width .25s ease;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { width: 100%; }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after { width: 100%; background: var(--ink); }

/* ---------- Type scale ---------- */
h1 {
  font-family: "Zilla Slab", serif; font-weight: 700;
  font-size: clamp(2.2rem, 5vw, 3.1rem); line-height: 1.08;
  letter-spacing: -0.015em; margin: 0 0 0.7rem;
}
h2 {
  font-family: "Zilla Slab", serif; font-weight: 600;
  font-size: 1.55rem; letter-spacing: -0.01em; margin: 2.6rem 0 0.8rem;
}
p { margin: 0 0 1.1rem; }

a {
  color: var(--garnet); text-decoration: none;
  border-bottom: 1px solid rgba(110,31,35,.35); transition: border-color .18s;
}
a:hover { border-bottom-color: var(--garnet); }

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--garnet); margin-bottom: 1.3rem; display: block;
}

main { padding: 0 0 1rem; }
.lead { font-size: 1.2rem; font-weight: 500; }
.muted { color: var(--ink-soft); }
ul.clean { padding-left: 1.1rem; }
ul.clean li { margin-bottom: 0.5rem; }


/* ---------- Content panels floating above the rain ---------- */
/* Single vertical fade only. A second axis would need mask-composite,
   which flashes black on Firefox under View Transitions — so we don't. */
.panel { position: relative; padding: 3.4rem 4rem; }
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
  -webkit-mask: linear-gradient(to bottom, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
  mask: linear-gradient(to bottom, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}

/* ---------- HERO ---------- */
.hero { position: relative; }
.page-rain {
  position: fixed;
  background: transparent;
  top: 0; left: 0; right: 0;
  width: 100%; height: 100vh;
  z-index: -1;
  pointer-events: none;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 2.5rem;
  align-items: center;
  padding-top: 3.5rem; padding-bottom: 3.5rem;
}
.hero-text h1 { color: var(--ink); }

.hero-photo {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #e7e0d0;
  border-radius: 8px;
  overflow: hidden;
}
.hero-photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.hero-photo .photo-placeholder {
  display: none;
}
.hero-photo.is-empty img { display: none; }
.hero-photo.is-empty .photo-placeholder {
  display: flex; align-items: center; justify-content: center;
  position: absolute; inset: 0;
  font-family: "JetBrains Mono", monospace; font-size: 0.65rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: #9a9183;
}

/* ---------- SECTION INDEX ---------- */
.index { margin-top: 1rem; padding-bottom: 1rem; }
.index a.row {
  display: block; padding: 1.3rem 0; border-bottom: 1px solid var(--rule);
  color: var(--ink); border-bottom-color: var(--rule);
}
.index a.row:first-child { border-top: 1px solid var(--rule); }
.index a.row:hover { background: rgba(21,36,59,.025); }
.index .row-title {
  font-family: "Zilla Slab", serif; font-weight: 600; font-size: 1.25rem;
  margin-bottom: 0.25rem;
}
.index .row-title .arrow { color: var(--garnet); }
.index .row-desc { color: var(--ink-soft); font-size: 1rem; font-weight: 400; }

code, pre { font-family: "JetBrains Mono", monospace; font-size: 0.85em; }

/* ---------- FOOTER ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  min-height: 3rem;     /* reserve footer height to avoid layout shift */
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem; letter-spacing: 0.03em; color: var(--muted);
}
.site-footer::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: var(--paper);
  -webkit-mask: linear-gradient(to top, #000 0, #000 calc(100% - 40px), transparent 100%);
  mask: linear-gradient(to top, #000 0, #000 calc(100% - 40px), transparent 100%);
}
.site-footer .wrap { padding: 0 1.5rem; text-align: center; }
.site-footer a { color: var(--muted); border: none; }
.site-footer a:hover { color: var(--ink); }
.copyleft { display: inline-block; }

/* ---------- Inner pages content width ---------- */
main.page-body { padding-top: 3.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 46rem) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-photo { max-width: 200px; }
}
@media (max-width: 34rem) {
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
}

/* Injected header/footer fade in (set by include.js) */
#site-header, #site-footer { opacity: 0; transition: opacity .22s ease; }
#site-header.ready, #site-footer.ready { opacity: 1; }

/* ---------- Entrance cascade (on page load only) ----------
   Direct children of the content column rise gently into place,
   one after another. Plays once on load. Duration 0.8s — slower
   than the previous 0.6s; delays widened to match. */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
main .wrap > *,
.hero-inner > * {
  animation: rise 0.8s cubic-bezier(.22,.61,.36,1) backwards;
}
main .wrap > *:nth-child(1), .hero-inner > *:nth-child(1) { animation-delay: .06s; }
main .wrap > *:nth-child(2), .hero-inner > *:nth-child(2) { animation-delay: .17s; }
main .wrap > *:nth-child(3), .hero-inner > *:nth-child(3) { animation-delay: .28s; }
main .wrap > *:nth-child(4) { animation-delay: .39s; }
main .wrap > *:nth-child(5) { animation-delay: .50s; }
main .wrap > *:nth-child(6) { animation-delay: .61s; }
main .wrap > *:nth-child(7) { animation-delay: .72s; }
main .wrap > *:nth-child(8) { animation-delay: .83s; }
main .wrap > *:nth-child(n+9) { animation-delay: .94s; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  #site-header, #site-footer { opacity: 1; transition: none; }
  main .wrap > *, .hero-inner > * { animation: none; }
}
