/* ==========================================================================
   base.css — reset + @font-face (self-hosted, max 2) + element base + a11y floor
   Design "Carta — L'Acciughina" (Carta Viva v6 — editoriale stagionale). Mobile first. Requires tokens.css first.
   ========================================================================== */

/* ---- self-hosted fonts (OFL; see assets/fonts/OFL-*.txt); no CDN --------- */
@font-face {
  font-family: "Fraunces";
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/Fraunces-Variable.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/Inter-Regular.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/Inter-Bold.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* metric-compatible fallbacks to reduce CLS on swap */
@font-face {
  font-family: "Fraunces Fallback"; src: local("Georgia");
  size-adjust: 115%; ascent-override: 90%; descent-override: 20%; line-gap-override: 0%;
}
@font-face {
  font-family: "Inter Fallback"; src: local("Arial");
  size-adjust: 107%; ascent-override: 90%; descent-override: 22%; line-gap-override: 0%;
}

/* ---- reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 4; scroll-padding-top: var(--header-h); }
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
img { font-style: italic; color: var(--muted); }

body {
  min-height: 100svh;
  background-color: var(--cream);
  color: var(--seppia);
  font-family: var(--font-inter);
  font-size: var(--text-base);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  accent-color: var(--ruggine);
}

/* ---- headings (Fraunces; intentional scale; balance) ---------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-fraunces);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.012em;
  text-wrap: balance;
  max-width: var(--measure);
}
h1 { font-size: var(--text-hero); line-height: 1.02; letter-spacing: -0.015em; }
h2 { font-size: var(--text-2xl); font-style: italic; line-height: 1.15; }
h3 { font-size: var(--text-xl); font-style: italic; }
h4 { font-size: var(--text-md); font-style: italic; }
p { text-wrap: pretty; }
p, li, dt, dd { max-width: var(--measure); }
small { font-size: var(--text-sm); }

/* ---- links ------------------------------------------------------------- */
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: from-font; }
a:hover { color: var(--ruggine); }

/* ---- forms / tap targets (tap >=44px) ---------------------------------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
button, [role="button"], input[type="button"], input[type="submit"],
input[type="reset"], select, summary { min-height: 44px; min-width: 44px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
  min-height: 44px; padding: 0.5rem 0.75rem;
  background: var(--cream); border: 1px solid var(--line); border-radius: 0.375rem;
}

/* ---- accessibility ----------------------------------------------------- */
:focus-visible {
  outline: 3px solid var(--ruggine);
  outline-offset: 2px;
  border-radius: 2px;
}
/* on dark surfaces (seppia), use oro-spento/cream for focus */
.section--dark :focus-visible,
.hero :focus-visible,
.site-header :focus-visible,
.site-footer :focus-visible { outline-color: var(--oro-spento); }
:focus:not(:focus-visible) { outline: none; }

::selection { background-color: var(--ruggine); color: var(--cream); }
[hidden] { display: none !important; }

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

.skip-link {
  position: absolute; left: var(--gutter); top: calc(-1 * var(--header-h));
  z-index: 1000; padding: 0.75rem 1rem; min-height: 44px;
  background: var(--seppia); color: var(--cream);
  border-radius: 0.375rem; text-decoration: none;
  transition: top var(--dur-fast) var(--ease);
}
.skip-link:focus-visible { top: 0.5rem; }

/* ---- surfaces (Carta Viva: cream light, seppia dark, paper support) - */
body { background-color: var(--cream); }
.section--dark { background-color: var(--seppia); color: var(--cream); }
.section--cream { background-color: var(--cream); color: var(--seppia); }
.section--paper { background-color: var(--paper); color: var(--seppia); }

/* secondary text respects surface contrast */
.section--dark .muted, .site-footer .muted { color: var(--muted-on-dark); }
.section--cream .muted, .section--paper .muted { color: var(--muted); }
.muted { color: var(--muted); }

/* link color respects surface */
.section--dark a { color: var(--cream); }
.section--dark a:hover { color: var(--oro-spento); }
.section--cream a, .section--paper a { color: var(--seppia); }
.section--cream a:hover, .section--paper a:hover { color: var(--ruggine); }