/**
 * Console Justbitz — sistema visivo.
 *
 * L'idea, presa dal ritmo di justbit.it: i momenti di marca stanno su ink
 * profondo (accesso, attesa), il lavoro sta su carta bianca. Tipografia
 * editoriale grande e stretta, rosso #FF4646 speso una volta per schermata,
 * hairline al posto delle ombre, la freccia come segno ricorrente.
 *
 * L'area di lavoro è sempre chiara: non segue `prefers-color-scheme`.
 */

:root {
	color-scheme: light;

	--ink: #141e23;
	--ink-2: #1b282e;
	--red: #ff4646;
	--red-dark: #e83636;
	--red-wash: #fff0f0;

	--paper: #ffffff;
	--paper-2: #fbfbfa;
	--paper-3: #f4f4f2;
	--line: #e8e8e4;
	--line-2: #d5d5cf;
	--muted: #6e7679;

	--ok: #1f8a4c;
	--warn: #a86a00;
	--err: #d0332c;

	--r: 2px;
	--r-lg: 6px;
	--maxw: 78rem;

	--display: Gilroy, Poppins, "Helvetica Neue", -apple-system, BlinkMacSystemFont, sans-serif;
	--body: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
	--mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

	--ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--paper-2);
	color: var(--ink);
	font-family: var(--body);
	font-size: 15px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* ── Tipografia ─────────────────────────────────────────────────── */

h1, h2, h3, .display {
	font-family: var(--display);
	font-weight: 700;
	letter-spacing: -.03em;
	line-height: 1.05;
	margin: 0;
}

h1 { font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.8rem); }
h2 { font-size: 1.1rem; letter-spacing: -.02em; }
h3 { font-size: .98rem; letter-spacing: -.01em; }

p { margin: 0 0 1rem; }
a { color: inherit; text-decoration: none; }

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.lead { color: var(--muted); font-size: 1.05rem; line-height: 1.55; max-width: 34rem; }

/* Micro-etichetta: il tic tipografico della casa */
.eyebrow, .field > span, th, .badge, .back, .stat__label, .meta-chip {
	font-family: var(--display);
	font-weight: 700;
	font-size: .68rem;
	letter-spacing: .16em;
	text-transform: uppercase;
}

.eyebrow { display: block; color: var(--red); margin-bottom: .9rem; }

/* Parola evidenziata: sottolineatura spessa, non un cambio di colore */
.mark-word {
	background: linear-gradient(transparent 62%, rgba(255, 70, 70, .28) 62%);
	padding: 0 .1em;
}

/* ── Ingresso in scena ──────────────────────────────────────────── */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes halo { 0%, 100% { opacity: .3; transform: scale(1); } 50% { opacity: .08; transform: scale(1.55); } }
@keyframes spin { to { transform: rotate(360deg); } }

.rise { animation: rise .5s var(--ease) both; }
.rise-1 { animation-delay: .05s; }
.rise-2 { animation-delay: .12s; }
.rise-3 { animation-delay: .19s; }

@media (prefers-reduced-motion: reduce) {
	.rise, .brand-mark__halo { animation: none; }
	* { transition-duration: .01ms !important; }
}

/* ── Marchio ────────────────────────────────────────────────────── */

.brand-mark { display: block; }

.brand-mark__halo {
	transform-origin: 129.5px 56.5px;
	animation: halo 3.6s ease-in-out infinite;
	fill: var(--red);
}

/* ── Momenti di marca: ink pieno ────────────────────────────────── */

.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }

.split__brand {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 3rem;
	padding: 3.5rem;
	background: var(--ink);
	color: #fff;
	overflow: hidden;
}

/* Alone rosso appena percepibile: profondità senza diventare un gradiente */
.split__brand::after {
	content: '';
	position: absolute;
	width: 46rem;
	height: 46rem;
	right: -20rem;
	bottom: -24rem;
	background: radial-gradient(circle, rgba(255, 70, 70, .16), transparent 62%);
	pointer-events: none;
}

.split__brand > * { position: relative; z-index: 1; }
.split__brand .brand-mark { width: 46px; height: 46px; color: #fff; }

.statement {
	font-family: var(--display);
	font-weight: 700;
	font-size: clamp(2.1rem, 1.2rem + 2.6vw, 3.4rem);
	line-height: 1.03;
	letter-spacing: -.035em;
	margin: 0;
	max-width: 15ch;
}

.statement em { font-style: normal; color: var(--red); }

.split__meta { display: flex; flex-wrap: wrap; gap: 2.2rem; color: rgba(255, 255, 255, .45); }
.split__meta strong { display: block; color: #fff; font-family: var(--display); font-size: 1.05rem; letter-spacing: -.02em; }
.split__meta span { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; }

.split__form { display: flex; flex-direction: column; justify-content: center; padding: 3.5rem; background: var(--paper); }
.split__form-inner { width: min(24rem, 100%); }

@media (max-width: 900px) {
	.split { grid-template-columns: 1fr; min-height: 0; }
	.split__brand { padding: 2.5rem 1.5rem; gap: 2rem; min-height: 44vh; }
	.split__form { padding: 2.5rem 1.5rem 4rem; }
	.split__form-inner { width: 100%; }
}

/* ── Barra dell'applicazione ────────────────────────────────────── */

/* `display: flex` batte l'attributo [hidden] della UA: va detto esplicitamente,
   altrimenti la barra resta come striscia bianca sulle schermate di accesso. */
.chrome[hidden] { display: none; }

.chrome {
	display: flex;
	align-items: center;
	gap: 2.5rem;
	height: 62px;
	padding: 0 2rem;
	background: var(--paper);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 30;
}

.brand { display: flex; align-items: center; gap: .65rem; }
.brand .brand-mark { width: 24px; height: 24px; color: var(--ink); }
.brand__text { font-family: var(--display); font-weight: 700; letter-spacing: -.02em; font-size: 1rem; }
.brand__text small { margin-left: .4rem; font-weight: 700; font-size: .6rem; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }

.topnav { display: flex; gap: 1.8rem; margin-right: auto; align-items: stretch; height: 100%; }

.topnav a {
	position: relative;
	display: flex;
	align-items: center;
	color: var(--muted);
	font-size: .88rem;
	font-weight: 500;
	transition: color .15s var(--ease);
}

.topnav a::after {
	content: '';
	position: absolute;
	inset: auto 0 -1px;
	height: 2px;
	background: var(--red);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform .22s var(--ease);
}

.topnav a:hover { color: var(--ink); }
.topnav a:hover::after { transform: scaleX(1); }
.topnav a.is-active { color: var(--ink); font-weight: 700; }
.topnav a.is-active::after { transform: scaleX(1); }

.chrome__user { display: flex; align-items: center; gap: .75rem; font-size: .84rem; color: var(--muted); }
.chrome__user img { width: 28px; height: 28px; border-radius: 50%; }
.chrome__user em { font-style: normal; color: var(--red); font-size: .6rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

/* ── Impaginato ─────────────────────────────────────────────────── */

main { max-width: var(--maxw); margin: 0 auto; padding: 3rem 2rem 6rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 2.5rem; }

.back { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); margin-bottom: .8rem; transition: gap .18s var(--ease), color .15s; }
.back:hover { color: var(--red); gap: .7rem; }

.page-head__meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }

.meta-chip {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: .3rem .65rem;
	border: 1px solid var(--line-2);
	border-radius: 99px;
	color: var(--muted);
	font-size: .62rem;
}

.meta-chip--accent { border-color: var(--red); color: var(--red); }

/* Striscia di numeri: dà peso alla pagina senza riempirla di grafici */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); margin-bottom: 2rem; overflow: hidden; }
.stat { padding: 1.2rem 1.4rem; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat__value { font-family: var(--display); font-weight: 700; font-size: 1.9rem; letter-spacing: -.04em; line-height: 1; }
.stat__label { display: block; color: var(--muted); margin-top: .45rem; font-size: .62rem; }
.stat--accent .stat__value { color: var(--red); }

/* ── Superfici ──────────────────────────────────────────────────── */

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.6rem 1.8rem; margin-bottom: 1.2rem; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.card__head h2 { display: flex; align-items: center; gap: .6rem; }
.card--danger { border-color: rgba(208, 51, 44, .35); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1rem; }

/* Scheda progetto: filetto rosso che cresce, freccia che entra */
.project {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: .9rem;
	padding: 1.5rem 1.6rem;
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	overflow: hidden;
	transition: border-color .18s var(--ease), transform .18s var(--ease);
}

.project::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--red); transform: scaleY(0); transform-origin: top; transition: transform .24s var(--ease); }
.project:hover { border-color: var(--line-2); transform: translateY(-3px); }
.project:hover::before { transform: scaleY(1); }
.project:hover .project__go { opacity: 1; transform: none; }

.project__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.project__name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -.02em; line-height: 1.2; }
.project__url { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project__foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: auto; padding-top: .9rem; border-top: 1px solid var(--line); }
.project__go { color: var(--red); font-size: 1.1rem; opacity: 0; transform: translateX(-6px); transition: opacity .2s var(--ease), transform .2s var(--ease); }

/* Vuoto: un disegno, non un rettangolo tratteggiato */
.empty { text-align: center; padding: 4.5rem 2rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); }
.empty svg { width: 84px; height: 84px; margin-bottom: 1.4rem; color: var(--line-2); }
.empty h2 { margin-bottom: .6rem; font-size: 1.35rem; }
.empty p { color: var(--muted); max-width: 26rem; margin-inline: auto; }

/* ── Tab ────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 2rem; border-bottom: 1px solid var(--line); margin-bottom: 2.2rem; flex-wrap: wrap; }
.tabs a { position: relative; padding-bottom: .85rem; color: var(--muted); font-size: .9rem; font-weight: 500; transition: color .15s; }
.tabs a::after { content: ''; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .22s var(--ease); }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); font-weight: 700; }
.tabs a.is-active::after { transform: scaleX(1); }

/* ── Comandi ────────────────────────────────────────────────────── */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: .55rem;
	padding: .75rem 1.4rem;
	font-family: var(--body);
	font-size: .87rem;
	font-weight: 700;
	color: var(--ink);
	background: var(--paper);
	border: 1px solid var(--line-2);
	border-radius: var(--r);
	cursor: pointer;
	transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}

.btn:hover { border-color: var(--ink); }

.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary::after { content: '→'; font-weight: 400; transition: transform .2s var(--ease); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-primary:hover::after { transform: translateX(3px); }

.btn-ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-ink:hover { background: #000; border-color: #000; color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: .35rem .8rem; font-size: .76rem; }
.btn-sm.btn-primary::after { content: none; }
.btn-lg { padding: .9rem 1.7rem; font-size: .95rem; }
.btn-danger { color: var(--err); border-color: rgba(208, 51, 44, .4); }
.btn-danger:hover { background: var(--err); border-color: var(--err); color: #fff; }
.btn-download { flex-direction: column; gap: .15rem; padding: 1rem 1.7rem; }
.btn-download small { font-weight: 400; opacity: .85; }
.btn-download.btn-primary::after { content: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-inline { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--red); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.btn-inline:hover { color: var(--red-dark); }

/* Separatore "oppure" */
.rule-or { display: flex; align-items: center; gap: 1rem; margin: 1.6rem 0; color: var(--muted); font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; }
.rule-or::before, .rule-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Campi ──────────────────────────────────────────────────────── */

.fields { display: grid; gap: 1.1rem; margin: 1.2rem 0 1.6rem; }
.field { display: grid; gap: .4rem; }
.field > span { color: var(--muted); }
.field em { color: var(--red); font-style: normal; }

input[type="text"], input[type="email"], input[type="url"], input[type="password"],
input[type="number"], input[type="search"], select, textarea {
	width: 100%;
	padding: .7rem .85rem;
	font: inherit;
	font-size: .93rem;
	color: var(--ink);
	background: var(--paper);
	border: 1px solid var(--line-2);
	border-radius: var(--r);
	transition: border-color .14s, box-shadow .14s;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20, 30, 35, .07); }
input.is-invalid { border-color: var(--err); }
textarea { resize: vertical; min-height: 4.5rem; }

.options { display: grid; gap: .5rem; margin: 1rem 0 1.8rem; }

.option {
	position: relative;
	display: flex;
	gap: .85rem;
	align-items: flex-start;
	padding: 1rem 1.2rem;
	background: var(--paper);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	cursor: pointer;
	overflow: hidden;
	transition: border-color .15s var(--ease);
}

.option::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--red); transform: scaleY(0); transition: transform .2s var(--ease); }
.option:hover { border-color: var(--line-2); }
.option:has(input:checked) { border-color: var(--line-2); }
.option:has(input:checked)::before { transform: scaleY(1); }
.option input { margin-top: .28rem; accent-color: var(--red); flex: none; }
.option__body strong { font-weight: 600; }
.option__body small { display: block; color: var(--muted); font-size: .83rem; margin-top: .2rem; }

.palettes { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: .6rem; margin-bottom: 1.8rem; }
.palette { position: relative; padding: 1rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); cursor: pointer; text-align: center; font-size: .84rem; transition: border-color .15s; }
.palette:has(input:checked) { border-color: var(--ink); }
.palette input { position: absolute; opacity: 0; }
.palette__swatches { display: flex; justify-content: center; gap: 2px; margin-bottom: .6rem; }
.palette__swatches i { width: 22px; height: 22px; border: 1px solid rgba(20, 30, 35, .12); }

.q { margin: 2.6rem 0; padding-top: 2.2rem; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: none; padding-top: 0; margin-top: 1.5rem; }
.q h3 { margin-bottom: .3rem; font-size: 1.05rem; }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 2.2rem; padding-top: 1.6rem; border-top: 1px solid var(--line); }

/* ── Tabelle ────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
td { padding: .8rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--paper-2); }
tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.actions-cell { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.user-cell { display: flex; align-items: center; gap: .8rem; }
.user-cell img, .avatar-fallback { width: 34px; height: 34px; border-radius: 50%; background: var(--paper-3); flex: none; }

/* ── Segnali ────────────────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .6rem; border: 1px solid currentColor; border-radius: 99px; color: var(--muted); font-size: .62rem; white-space: nowrap; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge--plain::before { content: none; }
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }
.badge--err { color: var(--err); }

.alert { padding: 1.1rem 1.3rem; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--err); border-radius: var(--r-lg); margin: 1.2rem 0; }
.alert p { margin: .4rem 0 0; color: var(--muted); }
.alert--ok { border-left-color: var(--ok); }

.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .85rem 1.4rem; border-radius: var(--r); font-size: .87rem; font-weight: 600; z-index: 100; animation: rise .25s var(--ease); }
.toast--error { background: var(--err); }

.loader { display: flex; align-items: center; justify-content: center; gap: .8rem; padding: 5rem 0; color: var(--muted); font-size: .88rem; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Finestra modale ────────────────────────────────────────────── */

.dialog { border: none; border-radius: var(--r-lg); background: var(--paper); color: var(--ink); padding: 0; width: min(36rem, 94vw); box-shadow: 0 24px 60px rgba(20, 30, 35, .18); }
.dialog::backdrop { background: rgba(20, 30, 35, .6); }
.dialog form { padding: 2rem; }
.dialog h2 { font-size: 1.5rem; margin-bottom: 1.4rem; }
.dialog fieldset { border: none; padding: 0; margin: 0 0 1.2rem; }
.dialog fieldset > span { display: block; color: var(--muted); margin-bottom: .55rem; font-family: var(--display); font-weight: 700; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; }
.dialog menu { display: flex; justify-content: flex-end; gap: .6rem; padding: 1.2rem 2rem; margin: 0; background: var(--paper-2); border-top: 1px solid var(--line); }

/* ── Codice e chiavi ────────────────────────────────────────────── */

code { background: var(--paper-3); padding: .12rem .4rem; border-radius: 2px; font-family: var(--mono); font-size: .84em; }
.downloads { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1.4rem 0 2rem; }
.readme { background: var(--ink); color: #d7dcde; border-radius: var(--r-lg); padding: 1.4rem 1.6rem; overflow-x: auto; font-family: var(--mono); font-size: .78rem; line-height: 1.65; white-space: pre-wrap; }
.key-field input { font-family: var(--mono); font-size: .8rem; }

/* ── Piede ──────────────────────────────────────────────────────── */

.site-footer { max-width: var(--maxw); margin: 0 auto; padding: 2rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .78rem; }
.site-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.site-footer a:hover { color: var(--red); }

@media (max-width: 720px) {
	.chrome { height: auto; padding: .8rem 1rem; gap: 1rem; flex-wrap: wrap; }
	.topnav { order: 3; width: 100%; gap: 1.4rem; }
	.topnav a { padding-bottom: .3rem; }
	main { padding: 2rem 1rem 4rem; }
	.stat { border-right: none; border-bottom: 1px solid var(--line); }
	.site-footer { flex-direction: column; padding: 1.5rem 1rem; }
	.dialog form, .dialog menu { padding: 1.4rem; }
}

/* ── Schermate di marca: occupano tutto, senza impaginato né piede ── */

body.is-brand-screen { background: var(--ink); }
body.is-brand-screen main { max-width: none; margin: 0; padding: 0; }
body.is-brand-screen .site-footer { display: none; }
