/*
 * Due modi di leggere la stessa pagina:
 *  - documento (senza JS, o vista "testo"): tutto il contenuto in colonna;
 *  - carta (html.js.view-sky / .view-time): canvas a tutto schermo, il <main>
 *    diventa il pannello di dettaglio e mostra solo la stella selezionata.
 */
:root {
  --bg: #0a0c11;
  --panel: #0e1117;
  --fg: #e9ecf2;
  --dim: #8a92a3;
  --accent: #f2b84b;
  --line: rgba(120, 140, 180, .22);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.65 var(--mono); padding: 24px 16px 64px;
}
a { color: inherit; text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--fg); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, ul { margin: 0; }
kbd { font: inherit; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin: 0 1px; color: var(--fg); }
html:not(.js) #controls .needs-js, #sky, #legend, #hints, #panel-close { display: none; }
[hidden] { display: none !important; }

/* ── intestazione ── */
#top { max-width: 72ch; margin: 0 auto 20px; }
#top h1 { font-size: 20px; font-weight: 600; letter-spacing: .02em; }
#top h1 a { text-decoration: none; }
#top .role { color: var(--accent); }
#top .tagline { color: var(--dim); }

/* ── comandi ── */
#controls { max-width: 72ch; margin: 0 auto 32px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#controls button, #controls a.lang {
  font: inherit; color: var(--dim); background: rgba(10, 12, 17, .7); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 3px; cursor: pointer; text-decoration: none; line-height: 1.5;
}
#controls button:hover, #controls a.lang:hover { color: var(--fg); border-color: var(--dim); }
#controls button[aria-pressed="true"] { color: var(--bg); background: var(--fg); border-color: var(--fg); }
#controls .views { display: flex; }
#controls .views button { border-radius: 0; margin-left: -1px; }
#controls .views button:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
#controls .views button:last-child { border-radius: 0 3px 3px 0; }

/* ── per chi ho lavorato ── */
#clients { max-width: 72ch; margin: 0 auto 32px; display: flex; flex-wrap: wrap; gap: 20px 48px; }
#clients div { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
#clients span { color: var(--dim); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; width: 100%; }
#clients a { opacity: .6; transition: opacity .25s; line-height: 0; }
#clients a:hover, #clients a:focus-visible { opacity: 1; }
#clients img { height: 20px; width: auto; display: block; }
#clients a[href="#ukabc"] img, #clients a[href="#treedom"] img { height: 28px; }
.node img.logo { height: 26px; width: auto; border: 0; margin: 0 0 14px; opacity: 1; }

/* ── contenuto ── */
main { max-width: 72ch; margin: 0 auto; }
.group { margin-top: 48px; }
.group > h2, #about > h2 {
  font-size: 11px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase; color: var(--dim);
  border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 20px;
}
.group > .intro { color: var(--dim); margin: -8px 0 20px; }
.node { margin-bottom: 32px; scroll-margin-top: calc(var(--stick, 56px) + 16px); }
.group, #about { scroll-margin-top: calc(var(--stick, 56px) + 8px); }
.node h3 { font-size: 16px; font-weight: 600; }
.node.now h3 { color: var(--accent); }
.node .meta { color: var(--dim); font-size: 12px; }
.node .role { margin-top: 2px; }
.node p.text, #about p { margin-top: 10px; max-width: 68ch; }
.node img { display: block; max-width: 100%; height: auto; margin-top: 14px; border: 1px solid var(--line); opacity: .92; }
.node .visit { display: inline-block; margin-top: 12px; }
.node .linked { margin-top: 14px; color: var(--dim); font-size: 12px; }
.node .linked a { color: var(--fg); margin-right: 6px; white-space: nowrap; }
.group.deep .node h3 { font-weight: 400; }
#about .contacts { margin-top: 16px; list-style: none; padding: 0; }
#about .contacts li::before { content: "→ "; color: var(--dim); }

#foot { max-width: 72ch; margin: 56px auto 0; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
#foot p + p { margin-top: 4px; }

/* ── vista testo con JS: barra dei comandi sempre a portata ── */
html.js.view-text #controls { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; }

/* ── indice: senza JS è una riga di sezioni prima del contenuto ── */
#toc { max-width: 72ch; margin: 0 auto 8px; }   /* stesso font del corpo: 72ch = larghezza del <main> */
#toc > ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; }
#toc a { color: var(--dim); text-decoration: none; }
#toc a:hover, #toc a:focus-visible { color: var(--fg); }
#toc .n { color: var(--dim); opacity: .6; font-size: 11px; }
#toc .y { color: var(--dim); opacity: .6; font-size: 11px; }
#toc li li, #toc ol ol { display: none; }
#toc a[aria-current] { color: var(--fg); }
#toc li.current > a { color: var(--accent); }
html.js:not(.view-text) #toc { display: none; }
/* testo, schermo stretto: riga che resta sotto la barra e scorre di lato */
html.js.view-text #toc {
  position: sticky; top: var(--bar, 48px); z-index: 4; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: 2px 0 8px; overflow-x: auto; scrollbar-width: none;
}
html.js.view-text #toc::-webkit-scrollbar { display: none; }
html.js.view-text #toc > ol { flex-wrap: nowrap; white-space: nowrap; }
/* testo, schermo largo: colonna fissa a sinistra del contenuto, con le voci della sezione corrente
   (il font del contenitore è quello del corpo, così 36ch è mezza colonna del <main>) */
@media (min-width: 1180px) {
  html.js.view-text #toc {
    position: fixed; top: calc(var(--bar, 48px) + 24px); bottom: 24px; z-index: 4;
    right: calc(50% + 36ch + 40px); width: min(230px, calc(50% - 36ch - 56px));
    max-width: none; margin: 0; padding: 0 6px 0 0;
    border: 0; background: none; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
  }
  html.js.view-text #toc > ol { display: block; white-space: normal; }
  html.js.view-text #toc > ol > li { margin-bottom: 6px; }
  html.js.view-text #toc a { font-size: 12px; }
  html.js.view-text #toc > ol > li > a { letter-spacing: .14em; text-transform: uppercase; font-size: 11px; }
  html.js.view-text #toc li.current > ol { display: block; list-style: none; margin: 4px 0 10px; padding: 0 0 0 10px; border-left: 1px solid var(--line); }
  html.js.view-text #toc li.current li { display: block; line-height: 1.5; padding: 1px 0; }
  html.js.view-text #toc li li a[aria-current] { color: var(--fg); }
  html.js.view-text #toc li li a[aria-current]::before { content: "· "; color: var(--accent); margin-left: -10px; }
  html.js.view-text .node, html.js.view-text .group, html.js.view-text #about { scroll-margin-top: calc(var(--bar, 48px) + 16px); }
}

/* ── cielo profondo: con JS parte chiuso, si apre con "espandi" o con il pulsante nella sezione ── */
html.js:not(.deep) #deep-sky .node { display: none; }
#deep-more {
  font: inherit; font-size: 12px; color: var(--dim); background: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 3px; padding: 3px 10px; margin: 0 0 24px;
}
#deep-more:hover, #deep-more:focus-visible { color: var(--fg); border-color: var(--dim); }
html:not(.js) #deep-more, html.js:not(.view-text) #deep-more { display: none; }

/* ── carta: canvas a tutto schermo ── */
html.js:not(.view-text), html.js:not(.view-text) body { height: 100%; overflow: hidden; }
html.js:not(.view-text) body { padding: 0; }
html.js:not(.view-text) #sky { display: block; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
html.js:not(.view-text) #top { position: fixed; top: 20px; left: 24px; margin: 0; z-index: 2; pointer-events: none; max-width: min(62ch, calc(100vw - 48px)); }
html.js:not(.view-text) #top a { pointer-events: auto; }
html.js:not(.view-text) #controls { position: fixed; top: 20px; right: 24px; margin: 0; z-index: 3; justify-content: flex-end; }
html.js:not(.view-text) #foot { position: fixed; right: 24px; bottom: 16px; margin: 0; border: 0; padding: 0; z-index: 2; text-align: right; }
html.js:not(.view-text) #hints { display: block; }
html.js:not(.view-text) #clients {
  position: fixed; z-index: 2; right: 24px; bottom: 76px; margin: 0; flex-wrap: nowrap; gap: 40px; max-width: none;
}
html.js:not(.view-text) #clients div { flex-wrap: nowrap; gap: 20px; }
html.js:not(.view-text) #clients span { width: auto; white-space: nowrap; }
html.js:not(.view-text) #clients img { height: 16px; }
html.js:not(.view-text) #clients a[href="#ukabc"] img, html.js:not(.view-text) #clients a[href="#treedom"] img { height: 22px; }
html.js:not(.view-text) body.has-panel #clients { display: none; }
@media (max-width: 819px) { html.js:not(.view-text) #clients { display: none; } }
#panel, #palette .box { animation: rise .28s cubic-bezier(.2, .7, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { #panel, #palette .box { animation: none; } }
html.js:not(.view-text) #legend {
  display: block; position: fixed; left: 24px; bottom: 16px; z-index: 2; color: var(--dim); font-size: 11px; line-height: 1.9; pointer-events: none;
}
#legend ul { list-style: none; padding: 0; }
#legend svg { width: 14px; height: 14px; vertical-align: -3px; margin-right: 6px; overflow: visible; }
#legend .now { color: var(--accent); }

/* pannello di dettaglio */
html.js:not(.view-text) #panel {
  position: fixed; z-index: 4; top: 76px; right: 24px; max-height: calc(100% - 152px); width: 380px; max-width: calc(100vw - 48px);
  background: rgba(14, 17, 23, .94); border: 1px solid var(--line); border-radius: 3px;
  padding: 22px 24px 24px; overflow: auto; overscroll-behavior: contain; display: none;
}
html.js:not(.view-text) #panel.open { display: block; }
html.js:not(.view-text) #panel .group { margin: 0; }
html.js:not(.view-text) #panel .group > h2,
html.js:not(.view-text) #panel .group > .intro,
html.js:not(.view-text) #panel .node:not(.active),
html.js:not(.view-text) #panel #about:not(.active) { display: none; }
html.js:not(.view-text) #panel .node { margin: 0; }
html.js:not(.view-text) #panel-close {
  display: block; position: sticky; top: 0; float: right; margin: -8px -10px 0 8px;
  font: inherit; color: var(--dim); background: none; border: 0; cursor: pointer; padding: 4px 8px;
}
#panel-close:hover { color: var(--fg); }

/* palette comandi */
#palette { position: fixed; inset: 0; z-index: 10; background: rgba(5, 6, 9, .6); display: flex; justify-content: center; align-items: flex-start; padding: 18vh 16px 0; }
#palette .box { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--dim); border-radius: 4px; overflow: hidden; }
#palette input { width: 100%; font: inherit; font-size: 16px; color: var(--fg); background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 22px; outline: none; }
#palette ul { list-style: none; padding: 4px 0; max-height: 50vh; overflow: auto; }
#palette li { position: relative; display: flex; justify-content: space-between; gap: 16px; padding: 5px 16px 5px 22px; cursor: pointer; }
#palette li[aria-selected="true"] { background: rgba(233, 236, 242, .08); }
#palette li[aria-selected="true"]::before { content: "›"; color: var(--accent); position: absolute; left: 9px; }
#palette .meta { color: var(--dim); font-size: 12px; white-space: nowrap; }

@media (max-width: 819px) {
  html.js:not(.view-text) #top { top: 12px; left: 16px; max-width: calc(100vw - 32px); }
  html.js:not(.view-text) #top .tagline { display: none; }
  html.js:not(.view-text) #top h1 { font-size: 17px; }
  html.js:not(.view-text) #top .role { font-size: 11px; }
  html.js:not(.view-text) #controls { top: 72px; left: 16px; right: 16px; justify-content: flex-start; gap: 6px; font-size: 12px; }
  html.js:not(.view-text) #controls button, html.js:not(.view-text) #controls a.lang { padding: 3px 8px; }
  html.js:not(.view-text) #controls a.lang { position: fixed; top: 12px; right: 16px; }  html.js:not(.view-text) #legend, html.js:not(.view-text) #hints, html.js:not(.view-text) #foot .privacy { display: none; }
  html.js:not(.view-text) #foot { left: 16px; right: 16px; bottom: 10px; text-align: left; }
  html.js:not(.view-text) body.has-panel #foot { display: none; }
  html.js:not(.view-text) #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 48%;
    border-width: 1px 0 0; border-radius: 0; padding: 18px 16px 24px;
  }
}
/* telefono, vista testo: il cielo è una fascia in cima, un tocco apre la carta */
/* telefono e tablet in verticale: solo testo, quindi niente scelta della vista né cielo profondo */
html.phone #controls .views, html.phone #deep-toggle { display: none !important; }
@media (max-width: 819px) {
  html.js.view-text #controls { font-size: 12px; gap: 6px; flex-wrap: nowrap; }
  html.js.view-text #controls button, html.js.view-text #controls a.lang { padding: 3px 8px; }
  html.js.view-text #controls a.lang { margin-left: auto; }
  html.js.view-text #deep-toggle { display: none; }   /* nel testo il cielo profondo è già in fondo alla pagina */
}
@media (hover: none) { #hints { display: none !important; } }
@media print {
  #sky, #controls, #legend, #hints, #palette { display: none !important; }
  body { background: #fff; color: #000; }
}

/* iperspazio: una lista di nomi, i progetti chiusi senza link */
.node ul.names { list-style: none; padding: 0; margin-top: 14px; font-size: 13px; line-height: 1.8; }
.node ul.names .closed { color: var(--dim); font-size: 11px; white-space: nowrap; }
.node .badges { margin-top: 12px; }
.node .badge {
  display: inline-block; font-size: 11px; letter-spacing: .04em; color: var(--dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 8px; line-height: 1.7;
}

.node ul.names a.tag {
  font-size: 11px; color: var(--dim); text-decoration: none; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 3px; padding: 0 6px; margin-left: 4px; vertical-align: 1px;
}
.node ul.names a.tag:hover, .node ul.names a.tag:focus-visible { color: var(--fg); border-color: var(--dim); }

/* anteprima al passaggio: screenshot dei progetti, sulle stelle e nell'iperspazio */
#peek {
  position: fixed; left: 0; top: 0; z-index: 8; width: 307px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55); pointer-events: none; opacity: 0; transition: opacity .15s;
}
#peek.on { opacity: 1; }
#peek img { display: block; width: 100%; height: auto; }
#peek p { margin: 6px 2px 0; font-size: 11px; color: var(--dim); }
#peek p:empty { display: none; }
@media (prefers-reduced-motion: reduce) { #peek { transition: none; } }
@media print { #peek { display: none !important; } }

/* comandi con icona */
#controls .icon { padding: 5px 9px; line-height: 0; }
#controls .icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
#controls .icon svg .dot { fill: currentColor; stroke: none; }
#controls a.lang { letter-spacing: .06em; }
html.js #controls button.icon { padding: 5px 9px; }
@media (max-width: 819px) { html.js #controls button.icon { padding: 4px 8px; } }
html.phone #top .role { font-size: 12px; }
@media (max-width: 380px) { html.phone #top .role { font-size: 11px; } }
/* marchio senza scritta: il simbolo con il nome accanto */
#clients a.mark { display: inline-flex; align-items: center; gap: 7px; line-height: 1; text-decoration: none; }
#clients a.mark b { font-weight: 600; font-size: 15px; letter-spacing: .02em; color: var(--fg); }
html.js:not(.view-text) #clients a.mark b { font-size: 13px; }
