/* =========================================================================
   styles.css — tema dark/terminal, dark fisso.
   Palette e token in :root; poi layout; poi responsive in fondo.
   ========================================================================= */

:root {
  /* colori */
  --bg: #0d1117;
  --surface: #161b22;
  --border: #2a2f3a;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #7ee787;
  --cyan: #4de3ff;
  --yellow: #e3b341;
  --orange: #ffa657;
  --red: #ff7b72;
  --grey: #6e7681;

  /* accenti tenui (hover) */
  --green-soft: rgba(126, 231, 135, 0.12);
  --cyan-soft: rgba(77, 227, 255, 0.10);

  /* misure */
  --maxw: 960px;
  --radius: 5px;
  --gap: 16px;

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "SFMono-Regular",
    "Cascadia Code", Menlo, Consolas, monospace;
}

/* ------------------------------ reset ------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* scrollbar personalizzata, coerente col tema */
html {
  scrollbar-color: var(--border) var(--bg);   /* firefox: thumb / track */
  scrollbar-width: thin;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid var(--bg);   /* margine interno -> thumb "sottile" */
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: #3a4150; }
::-webkit-scrollbar-corner { background: var(--bg); }

img { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; }

/* focus visibile ovunque */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* offset per l'header sticky quando si salta a una sezione via ancora */
#top, #progetto, #progetti, #info { scroll-margin-top: 72px; }

.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
}
.skip-link:focus { left: 12px; top: 12px; }

/* prompt / etichette ---------------------------------------------- */
/* .prompt e .label sono usati anche su <h2> (heading di sezione):
   peso normale così l'aspetto resta identico a quando erano <p>. */
.prompt {
  color: var(--green);
  font-size: 0.95rem;
  font-weight: 400;
  margin: 0 0 12px;
}

.label {
  font-size: 0.9rem;
  font-weight: 400;
  margin: 0 0 14px;
  letter-spacing: 0.02em;
}
.label-green { color: var(--green); }
.label-cyan { color: var(--cyan); }

.cursor {
  color: var(--green);
  font-weight: 400;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cursor { animation: none; }
}

/* ------------------------------ header ------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  font-size: 0.95rem;
  white-space: nowrap;
}
.brand-path { color: var(--text); }
.brand-sep { color: var(--muted); margin: 0 4px; }
.brand-pct { color: var(--green); }

.nav-desktop {
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-desktop a {
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.15s ease;
}
.nav-desktop a:hover { color: var(--text); }
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}
.nav-icon svg { width: 18px; height: 18px; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
}

/* menu mobile */
.mobile-menu {
  position: fixed;
  inset: 56px 0 0 0;
  background: var(--bg);
  z-index: 90;
  border-top: 1px solid var(--border);
}
.mobile-menu-inner {
  display: flex;
  flex-direction: column;
  padding: 12px 24px;
}
.mobile-menu-inner a {
  display: flex;
  align-items: center;
  min-height: 52px;
  color: var(--text);
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
}

/* ------------------------------ hero ------------------------------ */
.hero { padding: 72px 0 56px; }
.hero-prompt { margin-bottom: 20px; }
.hero-name {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  line-height: 1.1;
}
.hero-tagline {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 20px;
}
.hero-bio { color: var(--text); max-width: 640px; }
.hero-bio p { margin: 0 0 6px; color: var(--muted); }

/* ---------------------- progetto in evidenza ---------------------- */
.featured-section { padding: 24px 0 48px; }

/* --state = colore accento del blocco, deciso dallo stato del server.
   La classe state-* viene messa su #progetto da main.js. */
#progetto { --state: var(--green); --state-soft: var(--green-soft); }
#progetto.state-online { --state: var(--green); --state-soft: var(--green-soft); }
#progetto.state-manutenzione { --state: var(--orange); --state-soft: rgba(255, 166, 87, 0.14); }
#progetto.state-offline { --state: var(--red); --state-soft: rgba(255, 123, 114, 0.14); }

/* elementi che seguono il colore dello stato */
#featured-label { color: var(--state); }                     /* "// il mio progetto" */
#progetto .link-inline { color: var(--state); }              /* "come entrare →" */
#progetto .btn-primary { color: var(--state); border-color: var(--state); }
#progetto .btn-primary:hover { background: var(--state-soft); border-color: var(--state); }
#progetto .btn.copied { color: var(--state); border-color: var(--state); background: var(--state-soft); }

.featured {
  border: 1px solid var(--state);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  align-items: start;
}

.featured-main { min-width: 0; }
.featured-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.featured-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.featured-desc { color: var(--muted); margin: 0 0 14px; }

.keypoints { list-style: none; margin: 0 0 18px; padding: 0; }
.keypoints li {
  color: var(--text);
  padding-left: 18px;
  position: relative;
  margin-bottom: 6px;
  font-size: 0.92rem;
}
.keypoints li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--state, var(--green));
}

.featured-media { min-width: 0; }

/* badge di stato */
.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-online { color: var(--green); border-color: var(--green); }
.badge-offline { color: var(--red); border-color: rgba(255,123,114,0.55); }
.badge-manutenzione { color: var(--orange); border-color: rgba(255,166,87,0.55); }
.badge-shipped { color: var(--green); border-color: rgba(126,231,135,0.5); }
.badge-dev { color: var(--yellow); border-color: rgba(227,179,65,0.5); }
.badge-archived { color: var(--grey); border-color: var(--border); }

/* bottoni terminale */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  min-height: 40px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.btn:hover { border-color: var(--green); background: var(--green-soft); }
.btn:active { transform: scale(0.98); }
.btn-primary { border-color: var(--green); color: var(--green); }
.btn-primary:hover { background: var(--green-soft); }
.btn.copied { border-color: var(--green); color: var(--green); background: var(--green-soft); }

/* micro-riga sotto i bottoni + accordion */
.featured-meta {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.link-inline {
  color: var(--cyan);
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
.link-inline:hover { text-decoration: underline; }
.link-inline.link-green { color: var(--green); }

.howto { margin-top: 12px; }
.howto[hidden] { display: none; }
.howto ol {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 0.88rem;
}
.howto li { margin-bottom: 5px; }

/* --------------------- cornice screenshot / browser --------------- */
.shot {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.shot img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.shot.clickable { cursor: zoom-in; }

/* finto browser per i siti web */
.browser-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: #0f141b;
}
.browser-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.browser-frame img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ------------------------- griglia progetti ----------------------- */
.projects-section { padding: 24px 0 48px; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap);
}
.empty-state {
  grid-column: 1 / -1;
  color: var(--green);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0;
  font-size: 0.9rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.card:hover,
.card:focus-visible {
  border-color: var(--green);
  background: #1a2029;
}
.card-media { position: relative; }
.card-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.15s ease;
}
.card:hover .card-media img,
.card:focus-visible .card-media img { border-bottom-color: var(--green); }
.card-fallback {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
}
.card-body { padding: 12px 14px 14px; }
.card-name { font-size: 1rem; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.card-desc { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.tag {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

.about-tags { margin-top: 14px; }

/* ------------------------------ about ------------------------------ */
.about-section { padding: 24px 0 48px; }
.about-body { max-width: 680px; margin-bottom: 6px; }
.about-body p { margin: 0 0 6px; color: var(--muted); }

/* ------------------------------ footer ----------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 56px;
  margin-top: 24px;
}
.contact-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 0 0 24px;
  padding: 0;
}
.contact-list a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  min-height: 44px;
}
.contact-list a:hover { color: var(--cyan); }
.contact-list svg { width: 16px; height: 16px; }

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
}
.to-top {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.to-top:hover { color: var(--text); border-color: var(--cyan); }

/* ---------------------- overlay dettaglio ------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}
.overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  z-index: 2;
}
.overlay-close:hover { border-color: var(--cyan); }

.detail-cover { margin-bottom: 14px; }
.detail-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.detail-thumb {
  width: 84px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  padding: 0;
  background: none;
  cursor: zoom-in;
}
.detail-thumb img { aspect-ratio: 16 / 9; object-fit: cover; }
.detail-thumb:hover { border-color: var(--cyan); }

.detail-name { font-size: 1.6rem; font-weight: 700; margin: 0 0 6px; }
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-desc { color: var(--muted); margin: 0 0 16px; max-width: 60ch; }
.detail-stack { margin-bottom: 20px; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.detail-actions .btn { min-height: 44px; padding: 11px 18px; }

.dl-meta {
  width: 100%;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: -4px;
}
.dl-note {
  width: 100%;
  font-size: 0.78rem;
  color: var(--grey);
  margin-top: 2px;
}

/* --------------------------- lightbox ----------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  --lb-accent: var(--green);   /* colore outline frecce; sovrascritto da JS per il server */
}
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: fixed; inset: 0; background: rgba(1, 4, 9, 0.9); }
.lb-figure {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 90vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lb-figure img {
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  opacity: 0;                       /* nascosta finché non è caricata */
  transition: opacity 0.2s ease;
}
.lb-figure img.ready { opacity: 1; }
.lb-counter { color: var(--muted); font-size: 0.85rem; }

/* spinner mostrato mentre l'immagine (spesso pesante) carica */
.lb-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  display: none;
  animation: lb-spin 0.7s linear infinite;
}
.lightbox.loading .lb-spinner { display: block; }
@keyframes lb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .lb-spinner { animation: none; } }
.lb-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
}
.lb-arrow {
  position: fixed;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  display: flex;                 /* centra la freccia dentro al box */
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--lb-accent);
  background: var(--surface);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
}
.lb-arrow:hover { border-color: var(--lb-accent); background: var(--bg); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

body.no-scroll { overflow: hidden; }

/* ======================= RESPONSIVE ============================== */

/* tablet: 768–1024px → griglia si adatta (auto-fit), doormc può impilarsi */
@media (max-width: 900px) {
  .featured {
    grid-template-columns: 1fr;
  }
  .featured-media { order: -1; } /* cover in alto quando impilato */
}

/* mobile < 768px */
@media (max-width: 767px) {
  .nav-desktop { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .hero { padding: 48px 0 40px; }

  .btn-row .btn { width: 100%; justify-content: center; }

  .detail-actions { flex-direction: column; }
  .detail-actions .btn { width: 100%; justify-content: center; }

  .overlay { padding: 0; align-items: stretch; }
  .overlay-panel {
    max-width: none;
    min-height: 100%;
    border: none;
    border-radius: 0;
    padding: 20px 18px 40px;
  }

  .footer-bottom { flex-direction: column; align-items: flex-start; }
  .lb-arrow { width: 44px; height: 44px; }
}

/* desktop ampio */
@media (min-width: 1024px) {
  body { font-size: 15.5px; }
}
