/* ──────────────────────────────────────────────────────────────
   Sito di collegamento — editorial, museum-quality
   Palette: bone / ink / terracotta
   Fonts: Cormorant Garamond (display) + Geist (utility)
   ────────────────────────────────────────────────────────────── */

:root {
  --bone:   #efe6d6;
  --bone-2: #e6dcc8;
  --ink:    #1c1815;
  --ink-2:  #3a3530;
  --ink-3:  rgba(28, 24, 21, 0.56);
  --rule:   rgba(28, 24, 21, 0.18);
  --accent: #b85a2c;
  --accent-ink: #1c1815;

  --bg:     var(--bone);
  --bg-2:   var(--bone-2);
  --fg:     var(--ink);
  --fg-2:   var(--ink-2);
  --fg-3:   var(--ink-3);

  --display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --ui:      "Geist", "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --mono:    "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --page-max:   1320px;
  --gutter:     clamp(20px, 4vw, 56px);
  --section-py: clamp(72px, 11vh, 140px);
}

[data-theme="dark"] {
  --bg:   #14110e;
  --bg-2: #1c1815;
  --fg:   #efe6d6;
  --fg-2: #d8cfbe;
  --fg-3: rgba(239, 230, 214, 0.55);
  --rule: rgba(239, 230, 214, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background 600ms ease, color 600ms ease;
}

body {
  /* a faint, organic paper grain */
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, color-mix(in oklab, var(--bg-2) 65%, transparent), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 100%, color-mix(in oklab, var(--bg-2) 50%, transparent), transparent 65%);
}

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

a { color: inherit; text-decoration: none; }

/* ─── Top frame ─────────────────────────────────────────────── */

.frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  padding: 18px var(--gutter);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  mix-blend-mode: normal;
}
[data-theme="dark"] .frame { color: var(--fg); }

.frame .mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  color: var(--fg);
  text-decoration: none;
}
.frame .mark-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 18px;
  line-height: 1;
  padding-bottom: 2px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.frame .mark-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.1;
}
.frame .mark-name {
  font-family: var(--display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.005em;
  font-style: normal;
}
.frame .mark-sub {
  font-family: var(--ui);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 1px;
}
.frame .meta {
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  text-align: right;
}

/* ─── Page container ────────────────────────────────────────── */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ─── Hero ───────────────────────────────────────────────────── */

.hero {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding-top: clamp(120px, 18vh, 200px);
  padding-bottom: clamp(40px, 6vh, 64px);
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 64px;
  align-items: end;
}

.greet {
  font-family: var(--display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(36px, 5.4vw, 76px);
  line-height: 0.95;
  letter-spacing: -0.015em;
  margin: 0 0 0.15em;
  color: var(--fg-2);
}

.greet em {
  font-style: normal;
  font-weight: 400;
  color: var(--fg);
}

.title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(44px, 6.6vw, 96px);
  line-height: 0.98;
  letter-spacing: -0.022em;
  margin: 0 0 0.4em;
  color: var(--fg);
  text-wrap: balance;
  max-width: 18ch;
}

.title .accent {
  color: var(--accent);
  font-style: italic;
  font-weight: 300;
}

.lede {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(18px, 1.55vw, 22px);
  line-height: 1.45;
  letter-spacing: 0.005em;
  color: var(--fg-2);
  max-width: 36ch;
  margin: 0;
  text-wrap: pretty;
}

.hero-index {
  font-family: var(--ui);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
}
.hero-index .ix-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 0.5px solid var(--rule);
}
.hero-index .ix-row:last-child { border-bottom: 0.5px solid var(--rule); }
.hero-index .ix-n { font-family: var(--mono); font-size: 10.5px; color: var(--fg-2); letter-spacing: 0.04em; }
.hero-index .ix-t { color: var(--fg); font-family: var(--display); font-style: italic; font-size: 15px; letter-spacing: 0; text-transform: none; }

.hero-foot {
  margin-top: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.scroll-cue {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.scroll-cue .line {
  width: 56px;
  height: 1px;
  background: var(--fg-3);
  position: relative;
  overflow: hidden;
}
.scroll-cue .line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--fg);
  animation: cue 2.4s cubic-bezier(.6,.05,.4,1) infinite;
  transform-origin: left center;
}
@keyframes cue {
  0%   { transform: scaleX(0); transform-origin: left center; }
  50%  { transform: scaleX(1); transform-origin: left center; }
  50.01% { transform: scaleX(1); transform-origin: right center; }
  100% { transform: scaleX(0); transform-origin: right center; }
}

/* ─── Chapter ───────────────────────────────────────────────── */

.chapter {
  padding: var(--section-py) 0;
  border-top: 0.5px solid var(--rule);
  position: relative;
}

.chapter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}
.chapter.reverse .chapter-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.chapter.reverse .chapter-text { order: 2; }
.chapter.reverse .chapter-media { order: 1; }

.chapter-text { max-width: 38ch; }

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.kicker .n {
  color: var(--accent);
  font-weight: 500;
  font-size: 11px;
}
.kicker .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--fg-3);
}

.ch-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(40px, 5.4vw, 76px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  text-wrap: balance;
}
.ch-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
}

.ch-body {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(17px, 1.4vw, 20px);
  line-height: 1.5;
  color: var(--fg-2);
  margin: 0 0 36px;
  text-wrap: pretty;
}

/* ─── Button (editorial pill, hand-drawn underline on hover) ── */

.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px 14px;
  border: 0.5px solid var(--fg);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-family: var(--ui);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: background 280ms ease, color 280ms ease, border-color 280ms ease, transform 280ms ease;
  position: relative;
  isolation: isolate;
}
.cta .arr {
  display: inline-block;
  transition: transform 320ms cubic-bezier(.4,.05,.2,1);
}
.cta:hover {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.cta:hover .arr { transform: translateX(4px); }
.cta:active { transform: translateY(1px); }

.cta.solid {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.cta.solid:hover {
  background: var(--fg);
  border-color: var(--fg);
}

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.cta-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--ui);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 13px 4px;
  transition: color 220ms ease;
}
.cta-link:hover { color: var(--fg); }

/* ─── Media (image slot in a browser-style frame) ───────────── */

.chapter-media {
  position: relative;
}

.shot-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--bg-2);
  border: 0.5px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.4) inset,
    0 18px 48px -16px rgba(28,24,21,0.18),
    0 4px 14px -6px rgba(28,24,21,0.10);
  transition: transform 600ms cubic-bezier(.2,.7,.2,1), box-shadow 600ms ease;
}
[data-theme="dark"] .shot-frame {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 18px 48px -16px rgba(0,0,0,0.55),
    0 4px 14px -6px rgba(0,0,0,0.35);
}

.shot-chrome {
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: color-mix(in oklab, var(--bg-2) 88%, var(--fg) 4%);
  border-bottom: 0.5px solid var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
}
.shot-chrome .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg-3);
  opacity: 0.4;
  flex-shrink: 0;
}
.shot-chrome .url {
  margin: 0 auto;
  padding: 3px 10px;
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.shot-frame image-slot {
  width: 100% !important;
  height: 100% !important;
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  background: var(--bg-2);
  border: 0 !important;
  border-radius: 0;
  --img-slot-bg: var(--bg-2);
}

/* Aspect ratios tuned per area so screenshots breathe */
.chapter-media .shot-frame { aspect-ratio: 16 / 10; }
.tool-media   .shot-frame  { aspect-ratio: 16 / 10; }

.media-cap {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
}

/* ─── Chapter 03 — Sviluppo (two cards) ──────────────────────── */

.sviluppo {
  padding: var(--section-py) 0;
  border-top: 0.5px solid var(--rule);
}
.sviluppo-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: end;
  margin-bottom: 56px;
}
.sviluppo-head .ch-body { margin: 0; }

.tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 2vw, 32px);
}
.tool {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 0.5px solid var(--rule);
  padding: 28px 0 0;
  position: relative;
}
.tool-media {
  position: relative;
  margin-bottom: 28px;
}
.tool-name {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
  display: block;
}
.tool-tag {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: 500;
  margin-bottom: 10px;
}
.tool-body {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(15px, 1.2vw, 17px);
  line-height: 1.5;
  color: var(--fg-2);
  margin: 0 0 22px;
  max-width: 38ch;
  text-wrap: pretty;
}
.tool-cta {
  align-self: flex-start;
  margin-top: auto;
}

/* ─── Closing ─────────────────────────────────────────────────── */

.closing {
  padding: var(--section-py) 0 calc(var(--section-py) - 20px);
  border-top: 0.5px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: end;
}
.closing-msg {
  font-family: var(--display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(28px, 3.6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 32px;
  color: var(--fg);
  text-wrap: balance;
  max-width: 22ch;
}
.signature {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 22px;
  margin: 0 0 6px;
}
.signature-sub {
  font-family: var(--ui);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.closing-contact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--ui);
}
.closing-contact .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-top: 0.5px solid var(--rule);
  font-size: 13px;
  transition: color 220ms ease, padding 280ms ease;
}
.closing-contact .row:last-child { border-bottom: 0.5px solid var(--rule); }
.closing-contact .row .lbl {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.closing-contact .row .val {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--fg);
  white-space: nowrap;
}
.closing-contact a.row:hover { padding-left: 8px; }
.closing-contact a.row:hover .val { color: var(--accent); }

.foot {
  border-top: 0.5px solid var(--rule);
  padding: 24px var(--gutter) 28px;
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* ─── image-slot internal tweaks ─────────────────────────────── */

image-slot {
  border: 0.5px solid var(--rule);
}
image-slot::part(empty) {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* ─── Entry: scroll-triggered reveal (JS-gated so no-JS / hidden-iframe
       always shows content; safety timeout reveals everything after 2.5s) ─ */

.reveal { /* default: visible. Only hides when body has .js-fade. */ }

@media (prefers-reduced-motion: no-preference) {
  body.js-fade .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition:
      opacity 900ms cubic-bezier(.2,.7,.2,1),
      transform 900ms cubic-bezier(.2,.7,.2,1);
  }
  body.js-fade .reveal.in { opacity: 1; transform: none; }
  body.js-fade .reveal.d1 { transition-delay: 80ms; }
  body.js-fade .reveal.d2 { transition-delay: 170ms; }
  body.js-fade .reveal.d3 { transition-delay: 260ms; }
  body.js-fade .reveal.d4 { transition-delay: 360ms; }
  body.js-fade .reveal.d5 { transition-delay: 460ms; }
}

/* ─── Responsive ─────────────────────────────────────────────── */

@media (max-width: 880px) {
  .hero-inner { grid-template-columns: 1fr; gap: 40px; }
  .hero-index { min-width: 0; }
  .chapter-grid, .chapter.reverse .chapter-grid { grid-template-columns: 1fr; gap: 36px; }
  .chapter.reverse .chapter-text { order: 1; }
  .chapter.reverse .chapter-media { order: 2; }
  .sviluppo-head { grid-template-columns: 1fr; gap: 28px; }
  .tools { grid-template-columns: 1fr; }
  .closing { grid-template-columns: 1fr; gap: 40px; }
  .frame .meta { font-size: 9.5px; }
}

/* ─── Tweaks panel ground (host posts __edit_mode_available) ── */

#tweaks-root { position: fixed; right: 0; bottom: 0; z-index: 9999; }
