/* Foglie e solchi — lettura su schermo. */
@font-face { font-family: "Era Garamond"; src: url("fonts/EBGaramond-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Era Garamond"; src: url("fonts/EBGaramond-SemiBold.ttf") format("truetype"); font-weight: 600 900; font-display: swap; }
@font-face { font-family: "Era Garamond"; src: url("fonts/EBGaramond-Italic.ttf") format("truetype"); font-style: italic; font-display: swap; }
@font-face { font-family: "Era Garamond"; src: url("fonts/EBGaramond-SemiBoldItalic.ttf") format("truetype"); font-weight: 600 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Era Fell"; src: url("fonts/IMFellDWPica-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Era Sans"; src: url("fonts/NotoSans-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Era Sans"; src: url("fonts/NotoSans-SemiBold.ttf") format("truetype"); font-weight: 600 900; font-display: swap; }

* { box-sizing: border-box; }
html { color: var(--ink); font: 20px/1.55 "Era Garamond", Georgia, serif; scroll-padding-top: 1rem; }
body { margin: 0; }
a { color: var(--red); text-underline-offset: .16em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, summary:focus-visible, .table-scroll:focus-visible { outline: 3px solid var(--red); outline-offset: 4px; }
.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 10; padding: .6rem 1rem; background: white; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.masthead { background: radial-gradient(ellipse at 80% 100%, #3a2523, transparent 70%), #201f1b; border-bottom: 4px solid var(--red); }
.masthead-inner { max-width: 76rem; margin: auto; padding: 1.8rem 2rem 1.3rem; text-align: center; }
.eyebrow { font: .57rem/1.5 "Era Sans", sans-serif; letter-spacing: .22em; }
.masthead .eyebrow { margin: 0 0 .5rem; }
.brand { font: 2.8rem/1.15 "Era Fell", Georgia, serif; text-decoration: none; }
.ages { display: flex; justify-content: center; align-items: end; gap: .5rem; height: 1.3rem; margin: .7rem auto; }

.library-nav { display: flex; justify-content: center; gap: 1.5rem; font: .67rem/1.5 "Era Sans", sans-serif; }
.library-nav a { padding: .35rem .25rem; }
.page-shell { max-width: 76rem; min-height: 65vh; margin: auto; padding: 0 2rem 1rem; background: var(--paper); }
.site-nav, .resources { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font: .65rem/1.6 "Era Sans", sans-serif; }
.site-nav { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.site-nav a, .resources a { padding: .3rem 0; }
.site-nav a[aria-current="page"] { font-weight: 600; text-decoration-thickness: 2px; }
.resources { padding: .65rem 0; }

.reading-layout { display: flex; align-items: flex-start; gap: 2.5rem; padding-top: 1.5rem; }
.toc-panel { flex: 0 0 14rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; scrollbar-width: thin; padding-right: .75rem; }
.toc-panel summary { font: 1.2rem/1.25 "Era Fell", Georgia, serif; cursor: pointer; padding: .3rem 0 .8rem; border-bottom: 1px solid var(--rule); }
#TOC { font: .68rem/1.5 "Era Sans", sans-serif; }
#TOC ul { list-style: none; padding: 0; margin: .7rem 0; }
#TOC ul ul { padding-left: .8rem; border-left: 1px solid #cfc1a7; }
#TOC li { margin: .25rem 0; }
#TOC a { display: block; padding: .25rem 0; color: var(--muted); text-decoration: none; }
#TOC > ul > li > a { font-weight: 600; }
#TOC a:hover { text-decoration: underline; }
.content { flex: 1; min-width: 0; max-width: 46rem; margin: 0 auto; overflow-wrap: anywhere; }
.document-header { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--red); }

.document-title { font: 2.5rem/1.12 "Era Fell", Georgia, serif; margin: .5rem 0 1rem; }
.downloads { font: .7rem/1.5 "Era Sans", sans-serif; margin-bottom: 0; }
.downloads a { display: inline-block; padding: .65rem 1rem; border: 1px solid var(--red); text-decoration: none; }

p { margin: 0 0 .85rem; }
strong, b { font-weight: 600; }
.book-body h1 { font: 2rem/1.15 "Era Fell", Georgia, serif; margin: 3rem 0 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--red); }
.book-body h2 { font: 1.5rem/1.2 "Era Fell", Georgia, serif; margin: 2rem 0 .8rem; }
.book-body h3 { font-size: 1.15rem; line-height: 1.25; margin: 1.6rem 0 .6rem; }
.book-body h4, .book-body h5, .book-body h6 { font-size: 1rem; margin: 1.4rem 0 .5rem; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; }
.header-section-number { font-size: .72em; }
ul, ol { padding-left: 1.3rem; margin: .6rem 0 1rem; }
li { margin: .3rem 0; }
li > p { margin-bottom: .4rem; }
li::marker { color: var(--red); }
blockquote { margin: 1.2rem 0; padding: .9rem 1.2rem .25rem; border-left: 3px solid var(--red); background: #e9e0cf; }
.history-note { margin: 1.2rem 0; padding: .7rem 0 0 1rem; border-top: 1px solid #c1b396; border-left: 1px solid #b4a17f; font-size: .9rem; }
.example-note { padding-left: 1rem; border-left: 2px solid #ad9876; }
.table-scroll { overflow-x: auto; margin: 1.2rem 0; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; line-height: 1.35; }
th { text-align: left; font-weight: 600; }
th, td { padding: .55rem .65rem; vertical-align: top; border-bottom: 1px solid #cbbda5; min-width: 5rem; }

td p, th p { margin-bottom: .2rem; }
.compact-table { font-size: .78rem; min-width: 34rem; }
col { width: auto !important; }
pre { padding: 1rem; border-top: 1px solid #9f8062; border-bottom: 1px solid #bdac90; white-space: pre-wrap; overflow-wrap: anywhere; font: .8rem/1.5 "Era Sans", sans-serif; }
code { font: .8em "Era Sans", sans-serif; padding: .1em .25em; }
pre code { font: inherit; padding: 0; }
img { max-width: 100%; height: auto; }
figure { margin: 1.5rem 0; text-align: center; }
figcaption { font-size: .85rem; font-style: italic; }
hr { width: 5rem; margin: 1.5rem auto; border: 0; border-top: 1px solid var(--rule); }
.site-footer { border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1rem; font: .6rem/1.8 "Era Sans", sans-serif; text-align: center; }
.back-to-top { display: none; }
@media screen and (max-width: 1000px) {
  .back-to-top {
    display: flex;
    align-items: center;
    gap: .5rem;
    position: fixed;
    z-index: 10;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    padding: .6rem 1rem;
    border: 1px solid #e0d2b6;
    border-radius: .3rem;
    background: var(--red);
    color: var(--paper);
    box-shadow: 0 2px 10px #201f1b33;
    font: .75rem/1.5 "Era Sans", sans-serif;
    text-decoration: none;
  }
  .back-to-top:hover { background: #57221f; }
  .page-shell { padding-bottom: 5rem; }
}
@media (max-width: 1000px) {
  .reading-layout { display: block; }
  .toc-panel { position: static; max-height: none; padding: 0; margin-bottom: 2rem; }
  #TOC { max-height: 16rem; overflow-y: auto; padding-right: .5rem; }
}
@media (max-width: 600px) {
  html { font-size: 19px; }
  .page-shell { padding: 0 1rem 5rem; }
  .masthead-inner { padding: 1.4rem 1rem 1rem; }
  .brand { font-size: 2.3rem; }
  .document-title { font-size: 2rem; }
  .book-body h1 { font-size: 1.65rem; }
  .site-nav, .resources { gap: .2rem .85rem; }
  blockquote { padding-left: .8rem; padding-right: .8rem; }
}
@media print {
  html, .page-shell { background: white; font-size: 12pt; }
  .masthead, .site-nav, .resources, .toc-panel, .downloads, .site-footer, .skip-link { display: none; }
  .page-shell { padding: 0; box-shadow: none; max-width: none; }
  .reading-layout { display: block; }
  .content { max-width: none; }
  .table-scroll { overflow: visible; }
  .compact-table { min-width: 0; }
  th, td { min-width: 0; }
  thead { display: table-header-group; }
  tr, figure { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}

/* Palette, superfici e logo approvati. */
:root {
  --paper: #ece4d2;
  --ink: #272b23;
  --muted: #575746;
  --red: #35502b;
  --rule: #918469;
}
html { background: #514a3d; }
.page-shell {
  background-color: var(--paper);
  background-image: url("grana.svg"),
    linear-gradient(90deg, #61583b0c, transparent 18%, transparent 82%, #484c350c);
  box-shadow: 0 0 2rem #11170e35;
}
.masthead {
  background-color: #242a22;
  background-image: url("grana.svg"),
    radial-gradient(ellipse at 15% 100%, #5e4b2b80, transparent 70%),
    linear-gradient(115deg, #31372b00, #101a1470);
  border-bottom-color: #847049;
  color: #e5dcc2;
}
.masthead .eyebrow { color: #c4bda3; }
.brand { color: #e5dcc2; text-shadow: 1px 1px #080d08; }
.ages span, .ages span:nth-child(2n) {
  position: relative;
  height: 1rem;
  transform: none;
  background:
    radial-gradient(ellipse at 0% 24%, #11170dc0 0, #11170dc0 13%, transparent 19%),
    radial-gradient(ellipse at 100% 69%, #11170da0 0, #11170da0 11%, transparent 18%),
    linear-gradient(90deg, #9f9374 0%, #d0c19a 18%, #d0c19a 76%, #9f9374 91%, #9f9374 100%);
}
.ages span::before {
  content: "";
  position: absolute;
  left: 67%; right: 22%; top: 5%; bottom: 6%;
  background: #15190f;
  opacity: .28;
  border-radius: 45% 20% 50% 25% / 7% 15% 11% 9%;
}
.ages span:last-child {
  height: 1.3rem;
  background:
    radial-gradient(ellipse at 0% 24%, #23140dc0 0, #23140dc0 13%, transparent 19%),
    radial-gradient(ellipse at 100% 69%, #23140da0 0, #23140da0 11%, transparent 18%),
    linear-gradient(90deg, #a85e3c 0%, #d7976a 18%, #a85e3c 28%, #a85e3c 78%, #d7976a 91%, #a85e3c 100%);
}
.ages span:last-child::before { background: #321a12; }

/* Primi cinque uguali in lunghezza; variano solo spessore e bordi. */
.ages span:nth-child(1) { width: 3.6px; border-radius: 18% 38% 42% 14% / 4% 12% 7% 15%; }
.ages span:nth-child(2) { width: 6.12px; border-radius: 46% 10% 22% 40% / 15% 5% 14% 7%; }
.ages span:nth-child(3) { width: 4.32px; border-radius: 12% 48% 26% 34% / 5% 18% 4% 12%; }
.ages span:nth-child(4) { width: 5.184px; border-radius: 38% 14% 45% 19% / 13% 4% 18% 6%; }
.ages span:nth-child(5) { width: 4.032px; border-radius: 22% 44% 13% 40% / 6% 15% 4% 18%; }
.ages span:nth-child(6) { width: 5.76px; border-radius: 34% 12% 46% 22% / 7% 13% 15% 4%; }
.ages span:nth-child(1)::before { left: 65%; right: 25%; top: 2%; bottom: 11%; }
.ages span:nth-child(2)::before { left: 70%; right: 16%; top: 8%; bottom: 3%; }
.ages span:nth-child(3)::before { left: 62%; right: 30%; top: 3%; bottom: 3%; }
.ages span:nth-child(4)::before { left: 72%; right: 19%; top: 1%; bottom: 13%; }
.ages span:nth-child(5)::before { left: 66%; right: 26%; top: 10%; bottom: 2%; }
.ages span:nth-child(6)::before { left: 68%; right: 19%; top: 2%; bottom: 7%; }
.ages span::after {
  content: "";
  position: absolute;
  width: 0; height: 0;
  border: 0 solid transparent;
}
.ages span:nth-child(1)::after {
  right: 0; top: 43%;
  border-width: .06rem 0.0576rem .08rem 0;
  border-right-color: #15190f;
}
.ages span:nth-child(2)::after {
  right: 0; top: 28%;
  border-width: .06rem 0.1152rem .17rem 0;
  border-right-color: #15190f;
}
.ages span:nth-child(3)::after {
  left: 0; top: 64%;
  border-width: .04rem 0 .12rem 0.0936rem;
  border-left-color: #15190f;
}
.ages span:nth-child(4)::after {
  left: 0; top: 19%;
  border-width: .13rem 0 .06rem 0.108rem;
  border-left-color: #15190f;
}
.ages span:nth-child(5)::after {
  left: 0; top: 37%;
  border-width: .05rem 0 .1rem 0.072rem;
  border-left-color: #15190f;
}
.ages span:nth-child(6)::after {
  right: 0; top: 57%;
  border-width: .05rem 0.1008rem .13rem 0;
  border-right-color: #321a12;
}

.library-nav a { color: #d0c7aa; }
.site-nav { border-color: #918469; }
.site-nav a[aria-current="page"] { color: #414d36; }
.resources a, .document-header .eyebrow, .site-footer { color: #575746; }
.document-header { border-color: #8d7256; }
.document-title, .book-body h1 { color: #633c2c; }
.book-body h1 { border-color: #9b8060; }
.book-body h2, .toc-panel summary { color: #784a34; }
.book-body h3 { color: #513c2e; }
.book-body h4, .book-body h5, .book-body h6 { color: #536047; }
.header-section-number { color: #756146; }
.toc-panel summary { border-color: #918469; }
#TOC ul ul { border-color: #a59a7c; }
#TOC > ul > li > a { color: #35502b; }
.downloads a { border-color: #35502b; color: #35502b; border-radius: 0; }
.downloads a:hover { color: #eee5cd; background: #35502b; }
blockquote {
  background-color: #ded3b9;
  background-image: url("grana.svg");
  border-color: #7e8968;
}
.history-note { color: #56543f; border-color: #a09371; }
.example-note { color: #535843; border-color: #7d7859; }
th { background: #4b3c2e url("grana.svg"); color: #f0e7ce; }
td { border-color: #b4a687; }
tbody tr:nth-child(even) { background: #e2d8c1; }
pre { background: #ded3b9 url("grana.svg"); border-color: #8b7b57; color: #35362b; }
code { background: #ded3b9; }
pre code { background: none; }
figcaption { color: #575746; }
hr, .site-footer { border-color: #918469; }
.back-to-top { background: #536047; color: #f0e7ce; border-color: #aea17b; border-radius: 0; }
.back-to-top:hover { background: #414d36; }
@media print {
  html, .page-shell { background: white; }
  th { background: #e5e5df; color: #272b23; }
  blockquote, pre, code { background-image: none; }
}

.book-body a:not(.heading-self-link) { text-decoration-thickness: 1.5px; }
