/* CoopMate design system — base (RD-1): font, reset moderno, tipografia, link, focus, skip-link, movimento ridotto.
   Dipende da tokens.css. Nessun colore letterale: solo var(--ui-*). */

/* Nunito variabile (200–1000), subset latin, self-hosted. Titoli peso 800, testo 400/600. */
@font-face {
    font-family: "Nunito";
    font-style: normal;
    font-weight: 200 1000;
    font-display: swap;
    src: url("../../fonts/nunito-latin-wght.woff2") format("woff2");
}

/* Ripiego con le metriche di Nunito applicate ad Arial (o Liberation Sans): il testo non "salta" quando arriva il font (CLS).
   size-adjust misurato in Chrome sul testo italiano (Nunito 400 / Arial 400 = 1,00; Nunito 800 / Arial Bold = 0,985);
   ascent/descent da Nunito (1011 / 353 su 1000 unità), line-gap 0. */
@font-face {
    font-family: "Nunito Fallback";
    font-weight: 200 599;
    src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Helvetica Neue");
    size-adjust: 100%;
    ascent-override: 101.1%;
    descent-override: 35.3%;
    line-gap-override: 0%;
}

@font-face {
    font-family: "Nunito Fallback";
    font-weight: 600 1000;
    src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Helvetica Neue Bold");
    size-adjust: 98.5%;
    ascent-override: 102.6%;
    descent-override: 35.8%;
    line-gap-override: 0%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--ui-header-h) + var(--ui-space-4));
    scroll-padding-bottom: calc(var(--ui-bottom-bar-h) + var(--ui-space-4));
    color-scheme: light dark;
    background: var(--ui-surface);
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--ui-surface);
    color: var(--ui-ink);
    font-family: var(--ui-font-sans);
    font-size: var(--ui-text-base);
    font-weight: var(--ui-weight-regular);
    line-height: var(--ui-leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 var(--ui-space-3);
    font-weight: var(--ui-weight-heavy);
    line-height: var(--ui-leading-tight);
    letter-spacing: var(--ui-tracking-tight);
    text-wrap: balance;
}

h1 {
    font-size: var(--ui-text-3xl);
}

h2 {
    font-size: var(--ui-text-2xl);
}

h3 {
    font-size: var(--ui-text-xl);
    line-height: var(--ui-leading-snug);
}

h4 {
    font-size: var(--ui-text-lg);
    line-height: var(--ui-leading-snug);
}

h5,
h6 {
    font-size: var(--ui-text-base);
    line-height: var(--ui-leading-snug);
}

p,
ul,
ol,
dl,
blockquote,
pre,
figure {
    margin: 0 0 var(--ui-space-4);
}

p {
    text-wrap: pretty;
}

small {
    font-size: var(--ui-text-sm);
}

b,
strong,
th {
    font-weight: 700;
}

hr {
    height: 0;
    margin: var(--ui-space-5) 0;
    border: 0;
    border-top: 1px solid var(--ui-border);
}

code,
kbd,
samp,
pre {
    font-family: var(--ui-font-mono);
    font-size: .92em;
}

code,
kbd {
    padding: .1em .35em;
    border-radius: var(--ui-radius-xs);
    background: var(--ui-surface-sunken);
}

pre {
    overflow-x: auto;
    padding: var(--ui-space-4);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface-sunken);
}

pre code {
    padding: 0;
    background: none;
}

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

img,
video {
    height: auto;
}

a {
    color: var(--ui-link);
    text-decoration-thickness: .08em;
    text-underline-offset: .18em;
    transition: color var(--ui-dur-fast) var(--ui-ease);
}

a:hover {
    color: var(--ui-link-hover);
    text-decoration-thickness: .14em;
}

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

button {
    cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
}

table {
    border-collapse: collapse;
}

::selection {
    background: var(--ui-accent);
    color: var(--ui-accent-ink);
}

[hidden] {
    display: none !important;
}

/* Focus: anello visibile e coerente solo per la tastiera (e per i dispositivi che lo richiedono). */
:focus-visible {
    outline: 3px solid var(--ui-focus);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Salta al contenuto: invisibile finché non riceve il focus. */
.ui-skip-link {
    position: absolute;
    inset-block-start: var(--ui-space-2);
    inset-inline-start: var(--ui-space-2);
    z-index: var(--ui-z-toast);
    padding: var(--ui-space-3) var(--ui-space-4);
    border-radius: var(--ui-radius-sm);
    background: var(--ui-surface-inverse);
    color: var(--ui-ink-inverse);
    font-weight: 700;
    transform: translateY(-200%);
}

.ui-skip-link:focus {
    transform: none;
}

/* Solo per tecnologie assistive. */
.ui-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Movimento ridotto: nessuna transizione o animazione, scroll immediato. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
