/* ==========================================================================
   U-TUB Torino — design system di base
   Token (colori, tipografia, spazi), reset e stili degli elementi nativi.
   I componenti sono in style.css.
   ========================================================================== */

/* --- Font ospitati in locale (niente richieste a server esterni) --------- */
@font-face {
    font-family: "Comfortaa";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/comfortaa-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Comfortaa";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/comfortaa-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Dancing Script";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/dancing-script-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* --- Palette del brand (rosso del logo + beige) ----------------------- */
    --red-50: #fbf0f0;
    --red-100: #f5dcdc;
    --red-700: #b10000;
    --red-800: #8c0000;
    --red-900: #6e0000;
    --beige-100: #f8f3ea;
    --beige-200: #f0e6d2;
    --beige-300: #e8d9c5;
    --beige-400: #e0cdba;
    --beige-700: #6b5a45;
    --ink-900: #1c1b1a;
    --ink-600: #545250;
    --ink-500: #8a7a66;
    --green-700: #1c7830;
    --green-50: #e8f3eb;
    --amber-700: #8a5a00;
    --amber-50: #fbf1dc;

    /* --- Ruoli semantici -------------------------------------------------- */
    --color-primary: var(--red-700);
    --color-primary-hover: var(--red-800);
    --color-primary-active: var(--red-900);
    --color-primary-soft: var(--red-50);
    --color-primary-tint: var(--red-100);
    --color-on-primary: #ffffff;
    --color-secondary: var(--beige-200);
    --color-secondary-hover: var(--beige-300);
    --color-secondary-active: var(--beige-400);
    --color-on-secondary: var(--ink-900);
    --color-bg: #faf7f2;
    --color-surface: #ffffff;
    --color-surface-alt: var(--beige-100);
    --color-text: var(--ink-900);
    --color-text-muted: var(--ink-600);
    --color-accent-text: var(--beige-700);
    --color-border: var(--ink-500);
    --color-border-soft: #e9e1d6;
    --color-success: var(--green-700);
    --color-success-bg: var(--green-50);
    --color-warning: var(--amber-700);
    --color-warning-bg: var(--amber-50);
    --color-error: var(--red-700);
    --color-error-bg: var(--red-50);
    --color-focus: var(--ink-900);

    /* --- Tipografia fluida ------------------------------------------------ */
    --font-body: "Comfortaa", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-script: "Dancing Script", "Segoe Script", cursive;
    --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
    --step-1: clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
    --step-2: clamp(1.44rem, 1.3rem + 0.7vw, 1.8rem);
    --step-3: clamp(1.73rem, 1.5rem + 1.15vw, 2.4rem);
    --step-4: clamp(2.07rem, 1.7rem + 1.85vw, 3.2rem);
    --step-5: clamp(2.5rem, 1.9rem + 3vw, 4.4rem);
    --leading: 1.6;
    --leading-tight: 1.2;

    /* --- Spazi ------------------------------------------------------------ */
    --space-3xs: 0.25rem;
    --space-2xs: 0.5rem;
    --space-xs: 0.75rem;
    --space-s: 1rem;
    --space-m: 1.5rem;
    --space-l: 2rem;
    --space-xl: 3rem;
    --space-2xl: 4.5rem;
    --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);
    --content-max: 72rem;
    --prose-max: 46rem;

    /* --- Forme, ombre, movimento ------------------------------------------ */
    --radius-s: 0.5rem;
    --radius-m: 0.875rem;
    --radius-l: 1.25rem;
    --radius-pill: 999px;
    --shadow-s: 0 1px 2px rgb(60 30 10 / 0.08), 0 1px 3px rgb(60 30 10 / 0.06);
    --shadow-m: 0 4px 12px rgb(60 30 10 / 0.08), 0 2px 4px rgb(60 30 10 / 0.05);
    --shadow-l: 0 18px 40px rgb(60 30 10 / 0.14), 0 6px 12px rgb(60 30 10 / 0.06);
    --shadow-primary: 0 8px 22px rgb(177 0 0 / 0.28);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --duration-fast: 150ms;
    --duration: 250ms;
    --duration-slow: 600ms;
    --tap-min: 44px;

    /* --- Layout ----------------------------------------------------------- */
    --tabbar-h: 4.25rem;
    --z-header: 900;
    --z-tabbar: 910;
    --z-toast: 950;
    --z-dialog: 1000;

    color-scheme: light;
}

/* --- Reset moderno -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: 6rem;
}
body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: var(--leading);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4, h5, h6, li, dd, dt { overflow-wrap: break-word; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { line-height: var(--leading-tight); text-wrap: balance; font-weight: 700; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--color-border-soft); margin-block: var(--space-m); }
[hidden] { display: none !important; }

/* --- Link ---------------------------------------------------------------- */
a {
    color: var(--color-primary);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}
a:hover { color: var(--color-primary-hover); text-decoration-thickness: 0.14em; }

/* --- Focus ben visibile, solo da tastiera -------------------------------- */
:focus { outline: none; }
:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 3px;
    border-radius: var(--radius-s);
}
.on-dark :focus-visible, .btn--primary:focus-visible { outline-color: var(--color-focus); }

::selection { background: var(--color-primary-tint); color: var(--color-text); }

/* --- Utilità ------------------------------------------------------------- */
.visually-hidden:not(:focus):not(:active) {
    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(--space-s);
    top: var(--space-s);
    z-index: calc(var(--z-dialog) + 1);
    padding: var(--space-xs) var(--space-s);
    background: var(--color-surface);
    color: var(--color-primary);
    font-weight: 700;
    border-radius: var(--radius-s);
    box-shadow: var(--shadow-l);
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.center { text-align: center; }
.stack > * + * { margin-block-start: var(--stack-space, var(--space-s)); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--cluster-gap, var(--space-xs)); align-items: center; }
.muted { color: var(--color-text-muted); }
.script { font-family: var(--font-script); font-weight: 700; }

/* Icone Material Symbols: decorative per default */
.material-symbols-outlined {
    font-size: 1.4em;
    line-height: 1;
    width: 1em;
    overflow: hidden;
    flex-shrink: 0;
    user-select: none;
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}

/* --- Pulsanti ------------------------------------------------------------ */
.btn {
    --btn-bg: var(--color-secondary);
    --btn-bg-hover: var(--color-secondary-hover);
    --btn-bg-active: var(--color-secondary-active);
    --btn-fg: var(--color-on-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2xs);
    min-height: var(--tap-min);
    min-width: var(--tap-min);
    padding: var(--space-2xs) var(--space-m);
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-weight: 700;
    font-size: var(--step-0);
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-s);
    transition: background-color var(--duration-fast), box-shadow var(--duration), transform var(--duration) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); box-shadow: var(--shadow-m); transform: translateY(-1px); }
.btn:active { background: var(--btn-bg-active); transform: translateY(0); box-shadow: var(--shadow-s); }
.btn:disabled, .btn[aria-disabled="true"] {
    cursor: not-allowed;
    background: #ece8e2;
    color: #6f6b66;
    box-shadow: none;
    transform: none;
}
.btn--primary {
    --btn-bg: var(--color-primary);
    --btn-bg-hover: var(--color-primary-hover);
    --btn-bg-active: var(--color-primary-active);
    --btn-fg: var(--color-on-primary);
}
.btn--primary:hover { box-shadow: var(--shadow-primary); }
.btn--outline {
    --btn-bg: transparent;
    --btn-bg-hover: var(--color-primary-soft);
    --btn-bg-active: var(--color-primary-tint);
    --btn-fg: var(--color-primary);
    border-color: currentColor;
    box-shadow: none;
}
.btn--ghost {
    --btn-bg: transparent;
    --btn-bg-hover: var(--color-primary-soft);
    --btn-bg-active: var(--color-primary-tint);
    --btn-fg: var(--color-text);
    box-shadow: none;
}
.btn--ghost:hover { box-shadow: none; }
.btn--small { min-height: 2.25rem; padding-inline: var(--space-s); font-size: var(--step--1); }
.btn--large { min-height: 3.5rem; padding-inline: var(--space-l); font-size: var(--step-1); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; border-radius: 50%; }

/* --- Form ---------------------------------------------------------------- */
.field { display: grid; gap: var(--space-3xs); align-content: start; }
.field + .field, .field + .fieldset, .fieldset + .field { margin-top: var(--space-s); }
.field label, .label { font-weight: 700; font-size: var(--step--1); }
.field__req { color: var(--color-primary); font-weight: 400; }
.field__hint { font-size: var(--step--1); color: var(--color-text-muted); }
.field__error {
    display: flex;
    gap: var(--space-3xs);
    align-items: center;
    font-size: var(--step--1);
    font-weight: 700;
    color: var(--color-error);
}
.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    min-height: var(--tap-min);
    padding: var(--space-2xs) var(--space-xs);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-s);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
textarea { min-height: 6rem; resize: vertical; }
select { cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--color-text-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 1px;
    border-color: var(--color-text);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
    border-color: var(--color-error);
    background: var(--color-error-bg);
}
input:disabled, input[readonly]:not([type="number"]) {
    background: #f1ede7;
    color: var(--color-text-muted);
    cursor: not-allowed;
}
::placeholder { color: #6f6b66; opacity: 1; }
input[type="checkbox"], input[type="radio"] {
    width: 1.375rem;
    height: 1.375rem;
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
}
.check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xs);
    padding: var(--space-xs);
    border-radius: var(--radius-s);
    cursor: pointer;
    min-height: var(--tap-min);
}
.check:hover { background: var(--color-primary-soft); }
.fieldset { border: 0; padding: 0; min-width: 0; }
.fieldset legend { font-weight: 700; margin-bottom: var(--space-2xs); }

/* --- Movimento ridotto: niente animazioni né transizioni ----------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}
