/* Dashboard di Altair ID. Layout, misure, colori e animazioni vengono dal prototipo «Home app Altair» (launcher):
   il vincolo che vale più dell'estetica è che le prime DUE righe di card (6 app su 3 colonne) stiano per intero in
   1440×800 e in 1280×720 senza scorrere (il conto verticale è nel README: non aumentare le misure senza rifarlo).
   Carattere: Stack Sans Headline per tutto il testo (come Mentorship con il tema Altair: testo 300, titoli e comandi
   600/400), tranne il saluto e i titoli grandi, in Newsreader 400 (il nome nel saluto in corsivo, che Newsreader ha
   davvero). Famiglie nei soli token --font e --font-title; i controlli ereditano con `font: inherit`.
   Ogni colore è un token su :root; il tema scuro (data-theme="dark", o il sistema se la scelta non c'è) li
   ridefinisce. Niente stili in linea nell'HTML e nessun attributo style: la CSP non li ammette. I font stanno in
   /fonts, con la versione nel nome: per cambiarne uno si cambia il nome del file (si tengono in cache un anno). */

@font-face { font-family: 'Stack Sans Headline'; font-style: normal; font-weight: 300; font-display: swap; src: url('/fonts/stack-sans-headline-5.3.0-latin-300.woff2') format('woff2'); }
@font-face { font-family: 'Stack Sans Headline'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/stack-sans-headline-5.3.0-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'Stack Sans Headline'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/stack-sans-headline-5.3.0-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Newsreader'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/newsreader-5.3.0-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'Newsreader'; font-style: italic; font-weight: 400; font-display: swap; src: url('/fonts/newsreader-5.3.0-latin-400-italic.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --bg: #f0f1f4;
  --bg-top: #e8ebfb;
  --bg-grad: linear-gradient(180deg, #e8ebfb 0%, #f1f2f7 40%, #f0f1f4 100%);
  --surface: #ffffff;
  --ink: #12152b;
  --title: #0f1226;
  --muted: #4f566c;
  --faint: #596078;
  --line: rgba(24, 32, 90, 0.08);
  --card-line: rgba(24, 32, 90, 0.06);
  --blue: #2b44d1;
  --blue-soft: #e4e8fb;
  --blue-line: rgba(43, 68, 209, 0.2);
  --avatar: #3451f0;
  --focus: rgba(43, 68, 209, 0.5);
  --menu-hover: #f1f3fd;
  --chip-bg: rgba(255, 255, 255, 0.85);
  --btn-bg: #0b0b0f;
  --btn-ink: #ffffff;
  --shadow-card: 0 1px 2px rgba(24, 32, 90, 0.04), 0 8px 24px rgba(24, 32, 90, 0.05);
  --shadow-card-hover: 0 2px 4px rgba(24, 32, 90, 0.05), 0 24px 48px rgba(43, 68, 209, 0.16);
  --shadow-icon: 0 6px 14px rgba(24, 32, 90, 0.18);
  --shadow-icon-hover: 0 12px 24px rgba(43, 68, 209, 0.3);
  --shadow-menu: 0 16px 40px rgba(24, 32, 90, 0.16);
  --shadow-chip: 0 4px 14px rgba(24, 32, 90, 0.1);
  --logo-filter: none;
  --font: 'Stack Sans Headline', system-ui, sans-serif;
  --font-title: 'Newsreader', Georgia, serif;
  --weight-body: 300;
}

/* Il tema scuro: lo stesso di prima (nero, bianco, azzurro #3056ff), riportato sui token del prototipo. Lo scrivo due
   volte, uguale: con la scelta esplicita (data-theme="dark") e con il sistema scuro quando non c'è nessuna scelta. */
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #000000;
  --bg-top: #070b24;
  --bg-grad: linear-gradient(180deg, #070b24 0, #000000 360px);
  --surface: #121212;
  --ink: #ffffff;
  --title: #ffffff;
  --muted: #c9ced6;
  --faint: #9aa1ab;
  --line: #2a2a2a;
  --card-line: #2a2a2a;
  --blue: #8ea2ff;
  --blue-soft: #0b143d;
  --blue-line: rgba(142, 162, 255, 0.45);
  --avatar: #3056ff;
  --focus: rgba(142, 162, 255, 0.75);
  --menu-hover: #1d1d1d;
  --chip-bg: rgba(18, 18, 18, 0.85);
  --btn-bg: #ffffff;
  --btn-ink: #0b0b0f;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 1px 2px rgba(0, 0, 0, 0.5), 0 24px 48px rgba(48, 86, 255, 0.28);
  --shadow-icon: 0 6px 14px rgba(0, 0, 0, 0.5);
  --shadow-icon-hover: 0 12px 24px rgba(48, 86, 255, 0.35);
  --shadow-menu: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-chip: 0 4px 14px rgba(0, 0, 0, 0.5);
  /* Il logo è azzurro scuro su trasparente: su nero lo si rende bianco. */
  --logo-filter: brightness(0) invert(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #000000;
    --bg-top: #070b24;
    --bg-grad: linear-gradient(180deg, #070b24 0, #000000 360px);
    --surface: #121212;
    --ink: #ffffff;
    --title: #ffffff;
    --muted: #c9ced6;
    --faint: #9aa1ab;
    --line: #2a2a2a;
    --card-line: #2a2a2a;
    --blue: #8ea2ff;
    --blue-soft: #0b143d;
    --blue-line: rgba(142, 162, 255, 0.45);
    --avatar: #3056ff;
    --focus: rgba(142, 162, 255, 0.75);
    --menu-hover: #1d1d1d;
    --chip-bg: rgba(18, 18, 18, 0.85);
    --btn-bg: #ffffff;
    --btn-ink: #0b0b0f;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-card-hover: 0 1px 2px rgba(0, 0, 0, 0.5), 0 24px 48px rgba(48, 86, 255, 0.28);
    --shadow-icon: 0 6px 14px rgba(0, 0, 0, 0.5);
    --shadow-icon-hover: 0 12px 24px rgba(48, 86, 255, 0.35);
    --shadow-menu: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-chip: 0 4px 14px rgba(0, 0, 0, 0.5);
    --logo-filter: brightness(0) invert(1);
  }
}

/* ---------- animazioni (valori del prototipo) ---------- */
@keyframes al-rise {
  from { opacity: 0; transform: translateY(28px) scale(0.97); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes al-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes al-title {
  from { opacity: 0; transform: translateY(18px); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes al-pop {
  from { opacity: 0; transform: scale(0.55) rotate(-10deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  to { opacity: 1; transform: none; }
}
@keyframes al-drop {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.al-rise { animation: al-rise 0.75s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(0.5s + var(--i, 0) * 0.09s); }
.al-fade { animation: al-fade 0.8s ease-out both; }
.al-fade-late { animation-delay: 0.1s; }
.al-title { animation: al-title 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.al-title-1 { animation-delay: 0.12s; }
.al-title-2 { animation-delay: 0.26s; }
.al-title-3 { animation-delay: 0.4s; }
.al-pop { animation: al-pop 0.7s cubic-bezier(0.2, 0.8, 0.3, 1) both; animation-delay: calc(0.72s + var(--i, 0) * 0.09s); }
.al-drop { animation: al-drop 0.2s ease-out both; transform-origin: top right; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-grad) no-repeat;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: var(--weight-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 40; padding: 0.6rem 1rem; border-radius: 10px; background: var(--btn-bg); color: var(--btn-ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: 1rem; }

a, button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
main:focus { outline: none; }
.muted { color: var(--muted); }

/* ---------- intestazione: padding sopra 16, riga alta 44 ---------- */
/* position + z-index: l'intestazione (e il menu che si apre da lì) sta sopra il saluto, che con le animazioni di entrata
   ha un contesto di sovrapposizione suo e altrimenti coprirebbe il menu. */
.top { position: relative; z-index: 20; width: 100%; max-width: 1000px; margin: 0 auto; padding: 16px 24px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; border-radius: 8px; }
.brand-logo { display: block; height: 44px; width: auto; filter: var(--logo-filter); }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account { position: relative; display: flex; align-items: center; min-width: 0; }

/* Interruttore del tema: un pulsante-icona; il sole diventa luna (e viceversa) ruotando e dissolvendosi. */
.theme-toggle { position: relative; display: grid; place-items: center; flex: none; width: 40px; height: 40px; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--chip-bg); color: var(--ink); cursor: pointer; transition: background 0.25s ease, box-shadow 0.25s ease; }
.theme-toggle:hover { background: var(--surface); box-shadow: var(--shadow-chip); }
.theme-toggle:focus-visible { outline-offset: 2px; border-radius: 50%; }
.theme-icon { grid-area: 1 / 1; transition: transform 0.3s ease, opacity 0.3s ease; }
.theme-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }
:root[data-theme='dark'] .theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
:root[data-theme='dark'] .theme-moon { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
  :root:not([data-theme]) .theme-moon { opacity: 1; transform: none; }
}

.chip { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; max-width: 100%; margin: 0; padding: 4px 14px 4px 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--chip-bg); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; transition: box-shadow 0.25s ease, background 0.25s ease; }
.chip:hover, .chip[aria-expanded='true'] { background: var(--surface); box-shadow: var(--shadow-chip); }
.chip:focus-visible { outline-offset: 2px; border-radius: 999px; }
.chip-avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--avatar); color: #fff; font-size: 14px; font-weight: 600; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.chip-caret { flex: none; transition: transform 0.25s ease; }
.chip[aria-expanded='true'] .chip-caret { transform: rotate(180deg); }

/* Menu dell'account: sotto il pulsante, allineato al suo bordo destro; sul telefono (320 px compresi) resta dentro lo schermo. */
.menu { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-menu); }
.menu-email { padding: 8px 10px; font-size: 12px; font-weight: 400; color: var(--faint); overflow-wrap: anywhere; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; margin: 0; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; transition: background 0.15s ease; }
.menu-item:hover, .menu-item:focus-visible { background: var(--menu-hover); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item svg { flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 18px; border: 1px solid transparent; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); min-height: 46px; padding-inline: 26px; font-size: 16px; }
.btn-primary:hover { background: var(--blue); color: #fff; }
:root[data-theme='dark'] .btn-primary:hover { color: #0b0b0f; }

main { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 24px; }

/* ---------- titolo: padding sopra 32 e sotto 28 ---------- */
.hero { padding: 32px 0 28px; }
.title { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: clamp(34px, 4.4vw, 48px); line-height: 1.08; letter-spacing: -0.025em; color: var(--title); }
.title-greeting, .title-name { display: inline-block; }
.title-name { font-style: italic; color: var(--blue); }
.title-dot { font-style: normal; color: var(--title); }
.lede { margin: 8px 0 0; color: var(--muted); font-size: 16px; line-height: 1.5; }

/* Ricerca (solo oltre 8 app) */
.search { margin: 0 0 16px; }
.search-input { width: 100%; max-width: 26rem; min-height: 44px; padding: 8px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 400; }
.search-input::placeholder { color: var(--faint); }
.search-input:focus-visible { outline-offset: 2px; border-radius: 999px; }
.no-match { margin: 8px 0 0; }

/* ---------- card compatte: padding 20, raggio 18, icona 48, gap 14, griglia a 260 px minimo ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.grid > li { display: flex; }
.tile { display: flex; flex: 1; flex-direction: column; align-items: flex-start; min-width: 0; padding: 20px; border: 1px solid var(--card-line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-card); color: inherit; text-decoration: none; cursor: pointer; transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease, border-color 0.35s ease; }
.tile:hover { transform: translateY(-6px); border-color: var(--blue-line); box-shadow: var(--shadow-card-hover); }
.tile:active { transform: translateY(-2px) scale(0.99); transition-duration: 0.12s; }
.tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 18px; }
.tile-icon { display: block; width: 48px; height: 48px; }
.tile-logo { display: block; width: 48px; height: 48px; border-radius: 19%; box-shadow: var(--shadow-icon); transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.35s ease; }
.tile:hover .tile-logo { transform: translateY(-2px) scale(1.08) rotate(-4deg); box-shadow: var(--shadow-icon-hover); }
.tile-name { display: block; margin-top: 14px; font-size: 18px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; transition: color 0.25s ease; }
.tile:hover .tile-name { color: var(--blue); }
.tile-desc { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin-top: auto; padding-top: 16px; }
.tile-host { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-size: 13px; font-weight: 400; transition: color 0.25s ease; }
.tile:hover .tile-host { color: var(--blue); }
.tile-arrow { display: flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); transition: background 0.25s ease, color 0.25s ease, transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1); }
.tile-arrow svg { transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.tile:hover .tile-arrow { background: var(--blue); color: #ffffff; transform: scale(1.08); }
:root[data-theme='dark'] .tile:hover .tile-arrow { color: #0b0b0f; }
.tile:hover .tile-arrow svg { transform: translateX(2px); }

/* ---------- stato vuoto, errore, uscita ---------- */
.empty { max-width: 34rem; margin: 0 0 3rem; padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px dashed var(--line); border-radius: 18px; background: var(--surface); }
.empty-icon { color: var(--faint); }
.empty-title { margin: 12px 0 6px; font-family: var(--font-title); font-weight: 400; font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; color: var(--title); }
.empty .muted { margin: 0; }
.center { padding: 6rem 0; text-align: center; }
.card-center { display: flex; justify-content: center; padding: clamp(2rem, 8vw, 5rem) 0; }
.panel { width: 100%; max-width: 32rem; padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid var(--card-line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-card); }
.panel-title { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: clamp(1.7rem, 5vw, 2.1rem); line-height: 1.15; letter-spacing: -0.02em; color: var(--title); }
.panel-text { margin: 0.9rem 0 1.5rem; color: var(--muted); }
.code { margin: -0.75rem 0 1.5rem; color: var(--faint); font-size: 0.8rem; font-weight: 400; letter-spacing: 0.02em; }
.code:empty { display: none; }

/* ---------- piede: al centro, 15 px, con il lucchetto ---------- */
.foot { width: 100%; max-width: 1000px; margin: 0 auto; padding: 24px 24px 24px; display: flex; justify-content: center; color: var(--faint); font-size: 15px; font-weight: 400; line-height: 1.5; }
.foot-note { display: inline-flex; align-items: center; gap: 8px; }
.foot-note .icon { flex: none; }

@media (max-width: 799px) {
  /* Sotto circa 800 px le card vanno in colonna e scorrere va bene. */
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .brand-logo { height: 38px; }
  .top { gap: 8px; }
  .chip-name { max-width: 7.5rem; }
}

/* Con movimento ridotto niente animazioni né transizioni; l'hover cambia solo i colori. */
@media (prefers-reduced-motion: reduce) {
  .al-rise, .al-fade, .al-title, .al-pop, .al-drop { animation: none !important; }
  .tile, .tile *, .chip, .chip-caret, .theme-toggle, .theme-icon, .menu-item { transition: none !important; }
  .tile:hover, .tile:hover .tile-logo, .tile:hover .tile-arrow, .tile:hover .tile-arrow svg { transform: none !important; }
}

@media (forced-colors: active) {
  .tile, .chip, .panel, .search-input, .theme-toggle { border-color: CanvasText; }
  .tile:hover { border-color: Highlight; }
}
