/* ==========================================================
   Osservatorio del Balcone — token system
   ========================================================== */

:root {
  /* Colore */
  --bg: #0a0f1f;
  --bg-elev: #121a30;
  --bg-elev-2: #182240;
  --line: #232e4d;
  --text: #eef1fb;
  --text-muted: #8b96b8;
  --accent-gold: #e8b84b;
  --accent-gold-dim: #a98737;
  --accent-teal: #5fb3ac;
  --accent-red: #d1665a;

  /* Tipografia */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

a { color: var(--accent-teal); }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin: 0 0 0.6rem;
}

/* ---------- Banner di stato dati ---------- */

.site-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0.7rem 2rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.site-banner.attenzione {
  background: rgba(232, 184, 75, 0.14);
  color: var(--accent-gold);
}

.site-banner.critico {
  background: rgba(209, 102, 90, 0.16);
  color: var(--accent-red);
}

/* ---------- Navigazione ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 15, 31, 0.82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.brand-logo { width: 32px; height: 32px; border-radius: 50%; display: block; }

.topnav nav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.topnav nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
}
.topnav nav a:hover { color: var(--text); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: 88vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

#wedge-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 4rem 2rem 3.5rem;
  max-width: 760px;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.08;
  margin: 0.4rem 0 1.1rem;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 52ch;
  margin: 0 0 2.2rem;
}

.hero-readout {
  display: flex;
  gap: 2.2rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
}

.readout-item { display: flex; flex-direction: column; gap: 0.3rem; }
.readout-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.readout-value { font-size: 1.05rem; color: var(--accent-gold); }

/* ---------- Divisore ad arco (motivo dello spicchio ripreso) ---------- */

.arc-divider {
  position: relative;
  height: 60px;
  margin: 0 auto;
  max-width: 1100px;
}
.arc-divider::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -30px;
  width: 480px;
  height: 480px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 50%;
  clip-path: inset(0 0 calc(100% - 31px) 0);
}

/* ---------- Sezioni ---------- */

.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 2rem;
}

.section-narrow { max-width: 720px; }

.section h2 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  margin-bottom: 1rem;
}

.section-intro {
  color: var(--text-muted);
  max-width: 62ch;
  margin: 0 0 2.4rem;
}

.subsection-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 2.8rem 0 0.6rem;
}

.timelapse-player {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
  background: #000;
}

.section-narrow p {
  color: var(--text-muted);
  margin: 0 0 1.1rem;
}

/* ---------- Card grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.card h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
}

.card-big {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  color: var(--accent-teal);
  margin: 0 0 0.4rem;
}

.card-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Galleria ---------- */

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

.gallery figure { margin: 0; }

.sky-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg-elev);
}

.sky-frame img {
  width: 100%;
  height: 100%;
  /* "contain" (non "cover"): l'immagine nativa deve restare integra e
     centrata per allinearsi esattamente al layer SVG dell'overlay, che usa
     la stessa logica (preserveAspectRatio="xMidYMid meet") — con "cover"
     l'immagine verrebbe ritagliata e le coordinate dell'overlay non
     corrisponderebbero più ai punti giusti. */
  object-fit: contain;
  display: block;
}

.sky-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ov-griglia {
  fill: none;
  stroke: #4a6580;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
}

.ov-costellazione {
  fill: none;
  stroke: #7a92b0;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
  opacity: 0.6;
}

.ov-stella {
  fill: none;
  stroke: #eef1fb;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.ov-pianeta {
  fill: none;
  stroke: var(--accent-gold);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.ov-testo {
  fill: #cfd6ea;
  font-family: var(--font-mono);
  font-size: 14px;
}

.ov-testo-pianeta {
  fill: var(--accent-gold);
}

.gallery figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.overlay-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.overlay-toggle input {
  accent-color: var(--accent-gold);
  cursor: pointer;
}

/* ---------- Analemma ---------- */

.analemma-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Grafico ---------- */

.chart-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
}

/* ---------- Tabella eventi ---------- */

.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.events-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.8rem;
}

.events-table td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--line);
}

/* ---------- Archivio ---------- */

.archive-browser {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.8rem;
}

.archive-controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.archive-controls select {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-mono);
}

.archive-calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 0.5rem;
}

.archive-day {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-muted);
}

.archive-day.has-data {
  color: var(--accent-gold);
  border-color: var(--accent-gold-dim);
}

.archive-day:hover { border-color: var(--accent-teal); color: var(--text); }

.archive-detail {
  margin-top: 1.6rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}

/* ---------- Stati vuoti ---------- */

.empty-state {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-style: italic;
  padding: 1.4rem 0;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .topnav { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .topnav nav { gap: 0.9rem; }
  .hero-content { padding: 3rem 1.3rem 2.5rem; }
  .section { padding: 3.5rem 1.3rem; }
}
