/* ============================================================
   Tools FunOps — brand AP Sales (dark edition) + blu Funnel Operator
   ============================================================ */

:root {
  /* Superfici, in scala. Il fondo è il nero di brand; sopra ci stanno
     due gradini più chiari. Servono: senza di loro pannelli e card
     spariscono nel fondo e l'app diventa illeggibile. */
  --base:    #0a0a0b;   /* fondo pagina */
  --surface: #151519;   /* pannelli: Inbox, Blocco, Minimappa */
  --raised:  #1f1f25;   /* Card, menu, campi — l'ultimo gradino */
  --hover:   #292930;   /* stato hover sopra --raised */
  --line:    #33333c;   /* hairline visibile */
  --line-soft: rgba(255, 255, 255, .07);

  /* testo */
  --fg:      #f4f4f5;
  --muted:   #9b9ba4;

  /* accento: blu Funnel Operator. Blu AP Sales = #0062ff */
  --accent:  #1e9cd7;
  --accent-soft: rgba(30, 156, 215, .15);

  /* stati */
  --danger:  #ef5f57;
  --danger-soft: rgba(239, 95, 87, .12);

  /* colori delle Card: unica eccezione alla palette.
     Cinque tinte distinguibili sul fondo scuro, smorzate per non
     litigare con il blu. Stessi nomi dell'app di riferimento. */
  --amber:  #e0ac4a;
  --sky:    #6cc0e0;
  --rose:   #e3707c;
  --violet: #b08ce0;
  --lime:   #9ecb61;

  /* Angoli. L'app di riferimento è tutta arrotondata e senza quello
     non si capisce cosa è una card e cosa è uno sfondo. */
  --r-sm:   10px;   /* bottoni, icone, swatch */
  --r-md:   14px;   /* card, campi, menu */
  --r-lg:   20px;   /* pannelli e blocchi */
  --r-pill: 999px;

  /* Profondità: filo di luce sopra + ombra sotto. È quello che stacca
     una card dal pannello su cui sta appoggiata. */
  --shadow-card:
    0 1px 0 0 rgba(255, 255, 255, .06) inset,
    0 18px 36px -20px rgba(0, 0, 0, .85),
    0 4px 12px -6px rgba(0, 0, 0, .55);
  --shadow-pop:
    0 1px 0 0 rgba(255, 255, 255, .07) inset,
    0 26px 56px -14px rgba(0, 0, 0, .82);
  --shadow-drag:
    0 1px 0 0 rgba(255, 255, 255, .12) inset,
    0 40px 80px -20px rgba(0, 0, 0, .9),
    0 10px 30px -10px rgba(0, 0, 0, .75);

  /* tipografia */
  --display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --text:    "Elza", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --button:  "DM Sans", var(--text);
  --mono:    "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap: 1120px;
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }

html { color-scheme: dark; }

body {
  background: var(--base);
  color: var(--fg);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Grana: la firma visiva AP Sales. Sta sopra tutto ma non intercetta
   niente, e scompare per chi ha chiesto meno effetti. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.5 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.13'/></svg>");
}

/* width:100% non e' decorativo: .wrap e' figlio di un flex in colonna e ha
   margin auto, che disattiva lo stretch — senza, si restringe al contenuto e
   la griglia dei tool collassa su una colonna sola. Con un tool solo non si
   vedeva; col secondo si. */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }

/* ---- etichette mono tecniche ---- */
.label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.label--accent { color: var(--accent); }

/* ---- headline: Jakarta light + una parola bold italic ---- */
.display {
  font-family: var(--display);
  font-weight: 200;
  letter-spacing: -0.035em;
  line-height: 0.98;
  margin: 0;
  font-size: clamp(44px, 9vw, 132px);
}
.display em {
  font-weight: 700;
  font-style: italic;
}

/* ---- rules ---- */
.rule { border: 0; border-top: 1px solid var(--line-soft); margin: 0; }

/* ---- header / footer ---- */
.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
}
.site-header { border-bottom: 1px solid var(--line-soft); }
.site-footer { border-top: 1px solid var(--line-soft); }
.site-header a { text-decoration: none; }

/* ---- pagina "in costruzione" ---- */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.shell > main {
  flex: 1;
  display: flex;
  align-items: center;
}
.stack { display: grid; gap: 28px; padding: 96px 0; }
.stack p { color: var(--muted); max-width: 46ch; margin: 0; }

/* ---- griglia tool ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 400px));
  justify-content: start;
  gap: 18px;
  margin: 48px 0 96px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 30px 28px 34px;
  text-decoration: none;
  display: grid;
  gap: 10px;
  align-content: start;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.card:hover {
  background: var(--raised);
  border-color: var(--line);
  transform: translateY(-2px);
}
.card:hover .card__title { color: var(--accent); }
.card__title {
  font-family: var(--display);
  font-weight: 300;
  font-size: 24px;
  letter-spacing: -0.02em;
  margin: 0;
  transition: color .15s ease;
}
.card p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---- bottone ---- */
.btn {
  font-family: var(--button);
  font-weight: 500;
  font-size: 14px;
  padding: 11px 20px;
  background: var(--accent);
  color: #04121a;
  border: 0;
  border-radius: var(--r-sm);
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn--ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
}

/* ============================================================
   Componenti condivisi: nav, footer legale, bottoni, dialog.
   Usati da ogni pagina della libreria.
   ============================================================ */

/* ---- nav ---- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 13px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--base);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.crumbs a { text-decoration: none; transition: color .15s ease; }
.crumbs a:hover { color: var(--fg); }
.crumbs .sep { color: var(--line); }
.crumbs .here { color: var(--fg); }

.nav__brands {
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand-logo {
  display: block;
  opacity: .82;
  transition: opacity .15s ease;
}
.brand-logo:hover { opacity: 1; }
.brand-logo img { height: 17px; width: auto; }
.brand-logo--aps img { height: 13px; }

/* separazione visiva fra i loghi e il bottone testuale */
.nav__divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}

.text-link {
  font-family: var(--button);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.text-link:hover { color: var(--fg); border-bottom-color: var(--accent); }

/* ---- nav a scomparsa (tool a schermo pieno) ----
   Sopra i 1120px un tool occupa lo schermo intero e la barra in alto non
   scorre via da sola: ogni pixel suo è rubato al lavoro. Quindi sta fuori,
   sopra il bordo, e scende quando il mouse tocca il bordo alto dello schermo
   o la linguetta al centro (lib/topbar.js). All'apertura fa capolino un
   attimo, così chi arriva sa che c'è. Sotto i 1120px la pagina scorre e la
   barra resta normale, la linguetta sparisce. */
.nav-handle { display: none; }
.nav__legal { display: none; margin: 0; text-align: center; opacity: .6; white-space: nowrap; }

@media (min-width: 1120px) {
  .nav--peek {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 60;
    transform: translateY(-100%);
    transition: transform .22s cubic-bezier(.2, .7, .2, 1), box-shadow .22s ease;
  }
  .nav--peek.is-open {
    transform: translateY(0);
    box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .85);
  }
  .nav--peek .nav__legal { display: block; }

  /* la linguetta: zona calda larga, segno piccolo */
  .nav-handle {
    display: block;
    position: fixed;
    top: 0; left: 50%;
    transform: translateX(-50%);
    z-index: 59;
    width: 72px; height: 16px;
    padding: 0; border: 0;
    background: transparent;
    cursor: pointer;
  }
  .nav-handle::before {
    content: "";
    position: absolute;
    left: 50%; top: 4px;
    width: 36px; height: 4px;
    transform: translateX(-50%);
    border-radius: var(--r-pill);
    background: var(--line);
    transition: background .15s ease, width .15s ease;
  }
  .nav-handle:hover::before,
  .nav-handle:focus-visible::before,
  .nav-handle[aria-expanded="true"]::before { background: var(--muted); width: 44px; }
  .nav-handle:focus-visible { outline: none; }
  .nav-handle:focus-visible::before { box-shadow: 0 0 0 2px var(--accent); }
}

/* ---- footer legale ---- */
.legal {
  border-top: 1px solid var(--line-soft);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: baseline;
  justify-content: space-between;
  background: var(--base);
}
.legal p { margin: 0; }

/* ---- bottoni ---- */
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--ghost:hover:not(:disabled) { border-color: var(--muted); background: var(--raised); }

.btn-mono {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.btn-mono:hover:not(:disabled) { color: var(--fg); background: var(--hover); }
.btn-mono:disabled { opacity: .4; cursor: not-allowed; }
.btn-mono--danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }

.icon-btn {
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .15s ease, background .15s ease;
}
.icon-btn:hover:not(:disabled) { color: var(--fg); background: var(--hover); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

/* focus visibile ovunque */
:where(a, button, input, textarea, [tabindex], [contenteditable="true"]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- dialog ---- */
dialog {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 0;
  max-width: min(560px, calc(100vw - 40px));
}
dialog::backdrop { background: rgba(4, 4, 6, .84); backdrop-filter: blur(3px); }

.notice { padding: 34px 32px 28px; display: grid; gap: 18px; }
.notice h2 {
  font-family: var(--display);
  font-weight: 200;
  letter-spacing: -0.03em;
  font-size: 34px;
  line-height: 1.05;
  margin: 0;
}
.notice h2 em { font-weight: 700; font-style: italic; }
.notice p { margin: 0; color: var(--muted); font-size: 14px; }
.notice .actions { display: flex; justify-content: flex-end; }

/* ---- pagina normale: footer sempre in fondo ---- */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.page > main { flex: 1; }

/* ---- utility ---- */
.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;
}

/* barre di scorrimento sottili dentro i pannelli */
.scroll-slim { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.scroll-slim::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-slim::-webkit-scrollbar-track { background: transparent; }
.scroll-slim::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
.scroll-slim::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

@media (max-width: 720px) {
  .nav { padding: 12px 16px; }
  .legal { padding: 14px 16px; }
  .wrap { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  body::after { display: none; }
}
