/* Luca Pedetti — sito autore
   Un solo foglio di stile: le tre "anime" del sito (home, Emerging Tech, Compass)
   cambiano solo i token definiti sulle classi .theme-* del <body>. */

/* ---------- Font (ospitati in locale, licenza SIL OFL) ---------- */
@font-face { font-family: "Oswald"; src: url("../fonts/oswald.woff2") format("woff2"); font-weight: 200 700; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-italic.woff2") format("woff2"); font-weight: 400 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-condensed-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-condensed-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* ---------- Token ---------- */
:root {
    --max: 1160px;
    --gutter: clamp(16px, 5vw, 48px);
    --gap: clamp(28px, 6vw, 88px);
    --radius: 4px;

    /* Scala tipografica: sette livelli, usati ovunque */
    --fs-label: 13px;                          /* etichette maiuscole, badge */
    --fs-ui: 16px;                             /* menu, pulsanti, moduli, note */
    --fs-body: 19px;                           /* testo corrente */
    --fs-lead: clamp(20px, 1.9vw, 23px);       /* paragrafi di apertura, sottotitoli */
    --fs-h3: clamp(28px, 3vw, 38px);           /* titoli di blocco, citazioni */
    --fs-h2: clamp(34px, 4vw, 50px);           /* titoli di sezione */
    --fs-h1: clamp(52px, 8vw, 100px);          /* titolo di pagina */

    --font-ui: "Barlow", "Segoe UI", Arial, sans-serif;
    --font-garamond: "EB Garamond", Garamond, Georgia, serif;
    --font-palatino: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
}

.theme-home {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --ink: #18212f;
    --muted: #586273;
    --accent: #2f5aa8;
    --line: #18212f24;
    --header-bg: #f6f4efe6;
    --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-text: var(--font-garamond);
}

.theme-roger {
    color-scheme: dark;
    --bg: #07081b;
    --surface: #0f1132;
    --ink: #ebebf8;
    --muted: #aeb0d4;
    --accent: #9a8cff;
    --line: #ffffff1f;
    --header-bg: #07081be0;
    --font-display: "Oswald", "Arial Narrow", sans-serif;
    --font-text: var(--font-garamond);
}

.theme-compass {
    --bg: #ffffff;
    --surface: #f2f6fb;
    --ink: #1c2b45;
    --muted: #55647d;
    --accent: #2f5aa8;
    --line: #1c2b4524;
    --header-bg: #ffffffe6;
    --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
    --font-text: var(--font-palatino);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 84px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: var(--fs-body);
    line-height: 1.65;
    overflow-x: hidden;
}

h1, h2, h3, p, blockquote, figure, dl, dd, ul { margin: 0; }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: .2px;
    text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: .95; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

.theme-roger h1, .theme-roger h2, .theme-roger h3 { font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

p + p { margin-top: 18px; }

a { color: inherit; text-underline-offset: 4px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
}

.wrap { width: min(var(--max), calc(100% - 2 * var(--gutter))); margin-inline: auto; }

.skip {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
}
.skip:focus { top: 12px; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.eyebrow {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--fs-label);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    color: var(--muted);
}

.lead { font-size: var(--fs-lead); line-height: 1.5; }
.muted { color: var(--muted); }

/* ---------- Griglia a due colonne, condivisa da tutte le sezioni ----------
   Colonna sinistra: titolo (o copertina). Colonna destra: contenuto.
   Il bordo sinistro del contenuto è lo stesso in ogni pagina. */
.split {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    gap: var(--gap);
    align-items: start;
}
.section-head h2 { margin-top: 12px; }
.section-head p { margin-top: 18px; }

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 68px;
}

.brand { display: block; text-decoration: none; }
.brand img { height: 30px; width: auto; }

.nav__links { display: flex; align-items: center; gap: 28px; }
.nav__links a { text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav__links a.active { border-bottom-color: var(--accent); }

.nav__toggle {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    width: 44px;
    height: 44px;
    cursor: pointer;
}
.nav__toggle span, .nav__toggle span::before, .nav__toggle span::after {
    display: block;
    width: 20px;
    height: 2px;
    margin: auto;
    background: currentColor;
    position: relative;
    content: "";
}
.nav__toggle span::before { position: absolute; top: -6px; }
.nav__toggle span::after { position: absolute; top: 6px; }

/* ---------- Pulsanti ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
}
.btn:hover { background: transparent; color: var(--accent); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--accent); }
.theme-roger .btn { background: linear-gradient(100deg, #5a6bff, #b45cff); border-color: transparent; }
.theme-roger .btn:hover { background: linear-gradient(100deg, #6c7bff, #c272ff); color: #fff; }
.theme-roger .btn--ghost { background: transparent; border-color: var(--line); }
.theme-roger .btn--ghost:hover { background: #ffffff10; border-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }

/* ---------- Libro 3D ---------- */
.book3d {
    --spine: #1a1d4a;
    perspective: 1600px;
    width: min(100%, 340px);
}
.book3d__body {
    position: relative;
    transform: rotateY(24deg) rotateX(4deg);
    transform-style: preserve-3d;
    transition: transform .6s cubic-bezier(.2, .7, .2, 1);
    box-shadow: 22px 26px 40px #0000004d;
}
.book3d__body::before {
    /* dorso: piano perpendicolare alla copertina, ruotato attorno al bordo sinistro */
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 100%;
    background: linear-gradient(90deg, color-mix(in srgb, var(--spine) 70%, #fff), var(--spine));
    transform: rotateY(90deg);
    transform-origin: left;
}
.book3d__body::after {
    /* riflesso lungo la cerniera */
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #ffffff30 0, #0000 4%, #00000026 5.5%, #0000 9%);
    pointer-events: none;
}
.book3d:hover .book3d__body, .book-card:hover .book3d__body { transform: rotateY(8deg) rotateX(2deg); }
.book3d img { width: 100%; }
.book3d--compass { --spine: #d9e3f1; }

/* ---------- Home ---------- */
.home-hero { padding: clamp(64px, 10vw, 128px) 0 clamp(48px, 7vw, 88px); }
.home-hero .lead { max-width: 34ch; margin-top: 28px; color: var(--muted); }

.books { padding-bottom: clamp(64px, 9vw, 112px); }
.books__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; margin-bottom: 28px; }

.books__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.book-card {
    position: relative;
    display: grid;
    grid-template-columns: minmax(130px, 42%) 1fr;
    gap: clamp(20px, 3vw, 36px);
    align-items: center;
    padding: clamp(26px, 4vw, 44px);
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    isolation: isolate;
    transition: transform .35s, box-shadow .35s;
}
.book-card:hover { transform: translateY(-4px); box-shadow: 0 24px 50px #18212f2e; color: inherit; }
.book-card h3 { margin: 12px 0; line-height: 1; }
.book-card p { line-height: 1.5; }
.book-card .more {
    display: inline-block;
    margin-top: 20px;
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
    font-weight: 600;
    border-bottom: 1px solid currentColor;
}
.book-card .eyebrow { color: inherit; opacity: .75; }

.book-card--roger { background: #07081b; color: #ebebf8; }
.book-card--roger::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(60% 70% at 85% 10%, #3445c466, #0000 70%),
        radial-gradient(50% 60% at 70% 100%, #a14fd84d, #0000 70%);
}
.book-card--roger h3 { font-family: "Oswald", sans-serif; font-weight: 500; text-transform: uppercase; }
.book-card--roger h3 span { color: #c9b8ff; }

.book-card--compass { background: #ffffff; color: #1c2b45; border: 1px solid #1c2b451f; }
.book-card--compass::before {
    content: "";
    position: absolute;
    right: -12%;
    bottom: -8%;
    width: 80%;
    aspect-ratio: 2.05;
    z-index: -1;
    background: url("../img/compass-pattern.webp") no-repeat right bottom / contain;
    opacity: .16;
}
.book-card--compass h3 { font-family: "Barlow Condensed", sans-serif; color: #2f5aa8; }
.book-card--compass p { font-family: var(--font-palatino); }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99px;
    background: #2f5aa8;
    color: #fff;
    font-family: var(--font-ui);
    font-size: var(--fs-label);
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

/* ---------- Sezioni ---------- */
.section { padding: clamp(64px, 9vw, 112px) 0; border-top: 1px solid var(--line); }
.section--surface { background: var(--surface); }

.prose { max-width: 66ch; }
.prose p { text-wrap: pretty; }
.prose h3 { margin: 44px 0 0; }
.about .prose strong { font-weight: 600; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Pagina libro: hero ---------- */
.book-hero {
    position: relative;
    padding: clamp(48px, 8vw, 104px) 0 clamp(64px, 9vw, 120px);
    isolation: isolate;
    overflow: hidden;
}
.book-hero .split { align-items: center; }
.book-hero .book3d { justify-self: center; }
.book-hero h1 { margin: 16px 0 20px; }
.book-hero .subtitle {
    font-family: var(--font-display);
    font-size: var(--fs-lead);
    line-height: 1.3;
    color: var(--muted);
    max-width: 34ch;
}
.book-hero .lead { margin-top: 24px; max-width: 40ch; }

/* Emerging Tech: l'illustrazione della copertina fa da fondale */
.theme-roger .book-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background: url("../img/emerging-tech-art.webp") no-repeat 78% 62% / min(1100px, 120%) auto;
    opacity: .5;
}
.theme-roger .book-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(90deg, #07081bee 0%, #07081b99 45%, #07081b33 100%), linear-gradient(0deg, #07081b 0%, #0000 30%);
}
.theme-roger .book-hero .subtitle { font-weight: 400; text-transform: uppercase; letter-spacing: .4px; color: #c9cbef; }
.theme-roger h1 .accent {
    background: linear-gradient(90deg, #9aa6ff, #e472f6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Compass: il mosaico di rombi scorre dietro il libro, come in copertina */
.theme-compass .book-hero::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 6%;
    width: min(720px, 46%);
    aspect-ratio: 2.05;
    z-index: -1;
    background: url("../img/compass-pattern.webp") no-repeat right center / contain;
    -webkit-mask-image: linear-gradient(90deg, #0000 0%, #000 45%);
    mask-image: linear-gradient(90deg, #0000 0%, #000 45%);
    opacity: .7;
}
.theme-compass .book-hero h1 { color: var(--accent); }
.theme-compass .book-hero .subtitle { font-weight: 500; color: #3d66ad; }

/* ---------- Pagina libro: contenuti ---------- */
.pullquote {
    margin: 0 0 32px;
    padding-left: 24px;
    border-left: 3px solid var(--accent);
    font-size: var(--fs-h3);
    line-height: 1.25;
    font-style: italic;
}
.theme-roger .pullquote { border-image: linear-gradient(#9aa6ff, #e472f6) 1; }

.audience {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
    padding: 0;
    list-style: none;
}
.audience li {
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 99px;
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
    line-height: 1.3;
    background: var(--bg);
}

.facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
}
.facts > div { background: var(--bg); padding: 18px 22px; }
.section--surface .facts > div { background: var(--surface); }
.facts dt {
    font-family: var(--font-ui);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--muted);
}
.facts dd { margin-top: 4px; }

.stores {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    padding: 0;
    list-style: none;
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
    line-height: 1.3;
}
.stores a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    height: 100%;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    transition: border-color .2s, background .2s;
}
.stores a:hover { border-color: var(--accent); background: #ffffff0a; }
.stores a::after { content: "↗"; color: var(--accent); }
.stores .stores__main { grid-column: 1 / -1; }
.stores .stores__main a {
    background: linear-gradient(100deg, #5a6bff, #b45cff);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.stores .stores__main a::after { color: #fff; }
.stores small { display: block; margin-top: 2px; font-size: var(--fs-label); color: var(--muted); font-weight: 400; }
.stores .stores__main small { color: #ffffffcc; }
.note { margin-top: 18px; font-family: var(--font-ui); font-size: var(--fs-ui); color: var(--muted); }

.notify {
    padding: clamp(28px, 4vw, 44px);
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
}
.notify p { color: #ffffffe0; }
.notify .actions { margin-top: 24px; }
.notify .btn { background: #fff; color: var(--accent); border-color: #fff; }
.notify .btn:hover { background: transparent; color: #fff; }

/* Rimando all'altro libro: stessa griglia delle sezioni */
.crosslink { text-decoration: none; align-items: center; }
.crosslink:hover { color: inherit; }
.crosslink img { width: 120px; justify-self: end; box-shadow: 8px 10px 22px #00000040; }
.crosslink h2 { margin: 10px 0 8px; }
.crosslink .arrow { display: inline-block; margin-left: 12px; color: var(--accent); transition: transform .25s; }
.crosslink:hover .arrow { transform: translateX(6px); }

/* ---------- Modulo contatti ---------- */
.form { display: grid; gap: 20px; font-family: var(--font-ui); font-size: var(--fs-ui); line-height: 1.5; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.field .hint { color: var(--muted); }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #18212f40;
    border-radius: var(--radius);
    background: var(--surface);
    line-height: 1.4;
}
.field textarea { min-height: 160px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field [aria-invalid="true"] { border-color: #b3261e; }

.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }

/* honeypot: fuori dallo schermo ma non display:none, così i bot lo compilano */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.form__status { min-height: 24px; font-weight: 600; }
.form__status[data-state="ok"] { color: #1d6b3a; }
.form__status[data-state="error"] { color: #b3261e; }
.form button[disabled] { opacity: .6; cursor: progress; }

/* ---------- Footer ---------- */
.site-footer {
    padding: 40px 0;
    border-top: 1px solid var(--line);
    font-family: var(--font-ui);
    font-size: var(--fs-ui);
    color: var(--muted);
}
.site-footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; }

/* ---------- Pagine di testo (privacy, 404) ---------- */
.page { padding: clamp(48px, 8vw, 96px) 0; }
.page h1 { margin: 16px 0 32px; }
.page h2 { font-size: var(--fs-h3); margin: 44px 0 14px; }
.page ul { padding-left: 22px; }
.page li + li { margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .books__grid, .split { grid-template-columns: 1fr; }
    .book-hero .book3d { width: min(70%, 280px); }
    .theme-roger .book-hero::before { background-position: 50% 30%; background-size: 160% auto; opacity: .35; }
    .theme-roger .book-hero::after { background: linear-gradient(0deg, #07081b 10%, #07081bbb 60%, #07081b88 100%); }
    .theme-compass .book-hero::before { opacity: .18; width: 100%; }
    .crosslink { grid-template-columns: 96px 1fr; gap: 24px; }
    .crosslink img { width: 96px; }
}

@media (max-width: 760px) {
    :root { --fs-body: 18px; }
    .brand img { height: 26px; }
    .nav__toggle { display: block; }
    .nav__links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px var(--gutter) 16px;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
    }
    .nav__links.is-open { display: flex; }
    .nav__links a { padding: 14px 0; border-bottom: 1px solid var(--line); }
    .nav__links a.active { border-bottom-color: var(--line); color: var(--accent); }
    .book-card { grid-template-columns: 1fr; }
    .book-card .book3d { width: 58%; }
    .form__row, .facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; }
}

@media print {
    .site-header, .nav__toggle, .form, .actions, .notify { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .theme-roger .book-hero::before, .theme-roger .book-hero::after { display: none; }
}
