/* Guida del Club — layout e componenti.
   I token (colori, font display, motion, .btn, .tt-*) arrivano da design-tokens.css, copia del Club. */

:root {
    color-scheme: dark;
    --font-inter: "Inter", system-ui, -apple-system, sans-serif;
    --g-header: 64px;
    --g-nav: 18.5rem;
    --g-read: 46rem;
    --g-gutter: clamp(16px, 4vw, 40px);
    --g-ink-dim: rgba(245, 242, 236, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--g-header) + 16px); }
body {
    margin: 0;
    background: hsl(var(--surface-1));
    color: var(--ink);
    font: 400 16px/1.65 var(--font-inter);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

.g-sr {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.g-skip {
    position: absolute; left: 16px; top: -60px; z-index: 100;
    padding: 10px 16px; border-radius: 999px;
    background: hsl(var(--gold)); color: hsl(var(--gold-ink));
    font-weight: 600; text-decoration: none;
}
.g-skip:focus { top: 12px; }

/* --- Header */
.g-header {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: var(--g-header);
    padding: 0 var(--g-gutter);
    background: hsla(var(--surface-1) / 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}
.g-brand {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    font-family: var(--font-display); font-size: 1.125rem; letter-spacing: -0.01em;
    text-decoration: none; white-space: nowrap;
}
.g-brand__logo { display: block; width: auto; height: 44px; }
.g-brand__sep { color: var(--g-ink-dim); }
.g-brand__guide { color: var(--ink-muted); font-style: italic; }
.g-header__actions { display: flex; align-items: center; gap: 8px; }
.g-nav-toggle, .g-nav__head, .g-nav__club { display: none; }

/* --- Struttura: lettura a sinistra, indice a destra */
.g-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--g-nav);
    gap: clamp(32px, 5vw, 80px);
    max-width: 76rem;
    margin: 0 auto;
    padding: 0 var(--g-gutter);
}
.g-main { min-width: 0; max-width: var(--g-read); padding: 48px 0 96px; }
.g-nav {
    position: sticky; top: var(--g-header); align-self: start;
    max-height: calc(100vh - var(--g-header));
    overflow-y: auto; overscroll-behavior: contain;
    padding: 40px 4px 40px 28px;
    border-left: 1px solid var(--border-soft);
}

/* --- Ricerca */
.g-search { position: relative; margin: 0 0 28px; }
.g-search svg {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--ink-dim); pointer-events: none;
}
.g-search input {
    width: 100%; height: 42px; padding: 0 14px 0 40px;
    border: 1px solid var(--border-strong); border-radius: 999px;
    background: hsl(var(--surface-2)); color: var(--ink);
    font: inherit; font-size: 14px;
    transition: border-color var(--dur-fast) var(--ease-out);
}
.g-search input::placeholder { color: var(--g-ink-dim); }
.g-search input:focus { outline: none; border-color: hsl(var(--gold)); }
.g-search input::-webkit-search-cancel-button { filter: invert(0.7); }

.g-results, .g-tree ul { list-style: none; margin: 0; padding: 0; }
.g-results li + li { margin-top: 4px; }
.g-results a { display: block; padding: 8px 0; text-decoration: none; color: var(--ink); font-size: 14px; line-height: 1.4; }
.g-results a:hover .g-results__title, .g-results a:focus-visible .g-results__title { color: hsl(var(--gold)); }
.g-results__section { display: block; margin-top: 2px; font-size: 12px; color: var(--g-ink-dim); }
.g-results__empty { margin: 0; font-size: 14px; color: var(--g-ink-dim); }

/* --- Albero delle voci */
.g-tree__section + .g-tree__section { margin-top: 24px; }
.g-tree__title {
    display: block; margin-bottom: 6px;
    font-size: var(--fs-kicker); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--ink-muted); text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
}
.g-tree__title:hover, .g-tree__title.is-active { color: hsl(var(--gold)); }
.g-tree li a {
    position: relative; display: block; padding: 5px 0 5px 14px;
    font-size: 14px; line-height: 1.4; color: var(--ink-muted); text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
}
.g-tree li a:hover { color: var(--ink); }
.g-tree li a.is-active { color: var(--ink); }
.g-tree li a.is-active::before {
    content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
    width: 2px; background: hsl(var(--gold));
}

/* --- Testate di pagina */
.g-crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; font-size: 13px; color: var(--g-ink-dim); }
.g-crumbs a { color: var(--ink-muted); text-decoration: none; }
.g-crumbs a:hover { color: hsl(var(--gold)); }
.g-page-head { margin-bottom: 40px; }
.g-page-head .tt-eyebrow { margin-bottom: 12px; }
.g-page-head h1 { margin: 0 0 14px; }
.g-lede { margin: 0; max-width: 40rem; font-size: 1.125rem; line-height: 1.6; color: var(--ink-muted); }
.g-tier { margin: 18px 0 0; }

/* --- Home */
.g-hero { padding: 16px 0 48px; }
.g-hero h1 { margin: 14px 0 16px; }
.g-hero__search { max-width: 32rem; margin-top: 32px; }
.g-hero__search .g-search { margin: 0; }
.g-hero__search .g-search svg { left: 18px; width: 18px; height: 18px; }
.g-hero__search .g-search input { height: 52px; padding: 0 56px 0 46px; font-size: 15px; }
.g-hero__search kbd {
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%); pointer-events: none;
    padding: 3px 8px; border: 1px solid var(--border-strong); border-radius: 6px;
    font: 500 12px/1.2 var(--font-inter); color: var(--g-ink-dim);
}
.g-hero__search input:not(:placeholder-shown) + kbd { display: none; }
.g-hero__search .g-results, .g-hero__search .g-results__empty { margin-top: 12px; padding: 0 18px; }
.g-cards {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 16px;
}
.g-card a {
    display: flex; flex-direction: column; gap: 8px; height: 100%;
    padding: 22px 22px 20px;
    border: 1px solid var(--border-soft); border-radius: 14px;
    background: hsl(var(--surface-2)); text-decoration: none;
    transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.g-card a:hover { border-color: hsla(var(--gold) / 0.45); background: hsl(var(--surface-3)); }
.g-card h2 { margin: 0; }
.g-card p { flex: 1; margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-muted); }
.g-card__count { font-size: 12px; letter-spacing: 0.04em; color: var(--g-ink-dim); }

/* --- Elenco di sezione */
.g-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-soft); }
.g-list li { border-bottom: 1px solid var(--border-soft); }
.g-list a { display: block; padding: 18px 0; text-decoration: none; }
.g-list__title {
    display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 500;
    transition: color var(--dur-fast) var(--ease-out);
}
.g-list a:hover .g-list__title { color: hsl(var(--gold)); }
.g-list__summary { display: block; margin-top: 4px; font-size: 14px; color: var(--ink-muted); }

/* --- Corpo dell'articolo */
.g-prose { font-size: 1.0625rem; line-height: 1.75; color: rgba(245, 242, 236, 0.86); }
.g-prose > * { margin: 0; }
.g-prose > * + * { margin-top: 1.1em; }
.g-prose h2, .g-prose h3 { font-family: var(--font-display); font-weight: 500; color: var(--ink); }
.g-prose h2 { margin-top: 2.2em; font-size: var(--fs-h2); line-height: 1.25; letter-spacing: -0.01em; }
.g-prose h3 { margin-top: 1.8em; font-size: var(--fs-h3); line-height: 1.3; }
.g-prose a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.g-prose a:hover { color: hsl(var(--gold-soft)); }
.g-prose strong { font-weight: 600; color: var(--ink); }
.g-prose ul { padding-left: 1.3em; }
.g-prose li + li { margin-top: 0.5em; }
.g-prose li > * + * { margin-top: 0.8em; }
.g-prose li > p { margin-bottom: 0; }
.g-prose li > p:first-child { margin-top: 0; }
.g-prose li > ul, .g-prose li > ol { margin: 0.8em 0 0; }
/* Le liste numerate sono i passi del tutorial. */
.g-prose ol { list-style: none; padding: 0; counter-reset: step; }
.g-prose ol > li { position: relative; padding-left: 2.6em; counter-increment: step; }
.g-prose ol > li + li { margin-top: 1.6em; }
.g-prose ol > li::before {
    content: counter(step);
    position: absolute; left: 0; top: 0.15em;
    display: grid; place-items: center;
    width: 1.75em; height: 1.75em; border-radius: 50%;
    border: 1px solid var(--border-strong);
    color: var(--ink-muted); font-size: 0.8125rem; font-weight: 600; line-height: 1;
}
.g-prose code, .g-prose kbd {
    padding: 0.1em 0.4em; border-radius: 6px;
    background: hsl(var(--surface-3)); font-size: 0.9em;
}
.g-prose figure { margin: 1.2em 0 0; }
.g-prose figure img {
    display: block; width: 100%; height: auto;
    border: 1px solid var(--border-soft); border-radius: 12px;
    background: hsl(var(--surface-2));
}
.g-prose figcaption { margin-top: 10px; font-size: 13px; line-height: 1.5; color: var(--g-ink-dim); }

.callout {
    padding: 16px 20px; border-radius: 12px; border: 1px solid; font-size: 15px; line-height: 1.6;
}
.callout > * { margin: 0; }
.callout > * + * { margin-top: 0.6em; }
.callout__title { font-size: var(--fs-kicker); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.callout--nota { background: hsl(var(--status-info-bg)); border-color: hsla(var(--status-info) / 0.25); }
.callout--nota .callout__title { color: hsl(var(--status-info)); }
.callout--attenzione { background: hsl(var(--status-pending-bg)); border-color: hsla(var(--status-pending) / 0.3); }
.callout--attenzione .callout__title { color: hsl(var(--status-pending)); }

.g-open { margin: 44px 0 0; }

.g-pager {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border-soft);
}
.g-pager a { display: block; text-decoration: none; }
.g-pager__next { grid-column: 2; text-align: right; }
.g-pager small {
    display: block; margin-bottom: 4px;
    font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--g-ink-dim);
}
.g-pager span { font-family: var(--font-display); font-size: 1.125rem; transition: color var(--dur-fast) var(--ease-out); }
.g-pager a:hover span { color: hsl(var(--gold)); }

.g-help {
    margin-top: 64px; padding: 28px;
    border: 1px solid var(--border-soft); border-radius: 14px;
    background: hsl(var(--surface-2));
}
.g-help h2 { margin: 0 0 6px; }
.g-help p { margin: 0 0 18px; font-size: 15px; color: var(--ink-muted); }
.g-help .g-help__alt { margin: 16px 0 0; font-size: 14px; }

.g-footer {
    padding: 28px var(--g-gutter);
    border-top: 1px solid var(--border-soft);
    font-size: 13px; color: var(--g-ink-dim); text-align: center;
}
.g-footer p { margin: 0 auto; max-width: 60rem; }
.g-footer a { color: var(--ink-muted); }
.g-footer .g-footer__legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-top: 12px; }

/* --- Tablet e telefono: l'indice diventa un drawer da destra */
@media (max-width: 1023px) {
    .g-shell { display: block; }
    .g-main { max-width: none; padding: 32px 0 72px; }
    .g-nav-toggle { display: inline-flex; }

    .g-nav {
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
        align-self: stretch;
        width: min(22rem, 88vw); max-height: none;
        padding: 16px 20px 32px;
        background: hsl(var(--surface-2));
        border-left: 1px solid var(--border-soft);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform var(--dur-base) var(--ease-out), visibility 0s linear var(--dur-base);
    }
    .nav-open .g-nav { transform: none; visibility: visible; transition: transform var(--dur-base) var(--ease-out); }
    .nav-open { overflow: hidden; }
    .g-nav__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
    .g-nav__club { display: flex; margin-top: 32px; }
    .g-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.55); }
}

@media (max-width: 559px) {
    .g-header__club { display: none; }
    .g-brand { font-size: 1rem; gap: 8px; }
    .g-brand__logo { height: 28px; }
    /* Sotto i 16px iOS Safari ingrandisce la pagina quando il campo prende il focus. */
    .g-search input, .g-hero__search .g-search input { font-size: 16px; }
    .g-pager { grid-template-columns: 1fr; }
    .g-pager__next { grid-column: 1; text-align: left; }
    .g-help { padding: 22px; }
}
