/* ============ Andreella.com One-Page (styles.css) ============ */
/* System font stack per performance */
:root {
  --font-sans: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  --radius-xl: 18px;
  --shadow-sm: 0 6px 18px rgba(0,0,0,.12);
  --shadow-glow: 0 0 0 0 rgba(255,0,0,.0);

  /* Tema chiaro (grigio/rosso) */
  --bg: #f7f7f8;
  --panel: #ffffffcc;
  --ink: #1b1b1f;
  --muted: #5b5b63;
  --brand: #cc1f2f;   /* rosso */
  --brand-ink: #fff;
  --line: #d7d9df;
  --bubble: #ffffff;
  --bubble-border: #e3e3ea;
  --link: #cc1f2f;
  --accent: #f2e9ea;  /* rosato molto leggero */
}

/* Tema scuro */
html[data-theme="dark"] {
  --bg: #0f1013;
  --panel: #15171bcc;
  --ink: #ececf1;
  --muted: #a1a1aa;
  --brand: #ff465a;
  --brand-ink: #111;
  --line: #2a2d36;
  --bubble: #1a1d23;
  --bubble-border: #2a2d36;
  --link: #ff465a;
  --accent: #1d1213;
}

/* Alto contrasto (ARIA) */
html[data-theme="hc"] {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #000000;
  --muted: #111111;
  --brand: #000000;
  --brand-ink: #ffffff;
  --line: #000000;
  --bubble: #ffffff;
  --bubble-border: #000000;
  --link: #000000;
  --accent: #ffffff;
}

/* Preferenze OS di alto contrasto: rafforza i bordi */
@media (prefers-contrast: more) {
  :root { --line: #000; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

/* Header */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 .75rem;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 95%, transparent) 100%);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.theme-toggle {
  display: inline-flex; align-items:center; gap:.5rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: .4rem .6rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.theme-toggle .t-dot { width: .9rem; height: .9rem; border-radius:999px; background: var(--brand); display:inline-block; }
.theme-toggle .t-label { font-size: .9rem; }

/* Main */
.main {
  min-height: 100svh;
  position: relative;
  padding-top: 56px; /* spazio header */
}

/* Layer Three.js */
#three-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Texture/parallax di fondo */
.bg-texture {
  position: fixed;
  inset: -10vmax;
  background:
    radial-gradient(60vmax 60vmax at 50% 40%, var(--accent), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0.05'/><feComponentTransfer><feFuncA type='table' tableValues='0 0.035'/></feComponentTransfer></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: cover, 160px 160px;
  opacity: .8;
  z-index: 0;
  transform: translateZ(0);
}

/* Nucleo centrale */
.nucleus {
  position: relative;
  z-index: 2;
  display: grid;
  place-content: center;
  min-height: 60svh;
}
.nucleus__figure {
  position: relative;
  display: grid;
  place-items: center;
  padding: 1rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.nucleus__logo {
  width: clamp(140px, 16vw, 220px);
  height: auto;
  display: block;
}

/* SVG linee (radiali) */
.links-svg {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Sezione costellazione */
.constellation {
  position: relative;
  z-index: 2;
  padding: 6rem 1.25rem 5rem;
}

/* Bubbles layer: overlay full-viewport (per allineare coordinate con SVG) */
.bubbles {
  list-style: none;
  margin: 0; padding: 0;
  position: fixed;            /* prima era relative → ora overlay */
  inset: 0;
  z-index: 3;
  pointer-events: none;       /* il container non intercetta i click */
}

/* Bolla singola (cliccabile) */
.bubble {
  position: absolute;         /* posizionata via JS in coordinate viewport */
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--bubble);
  border: 1px solid var(--bubble-border);
  border-radius: 50%;
  padding: .6rem;
  box-shadow: var(--shadow-sm), var(--shadow-glow);
  transform: translate(-50%, -50%) scale(.6);
  transition: transform .36s cubic-bezier(.2,.7,.2,1), box-shadow .36s, border-color .2s;
  will-change: transform, box-shadow;
  pointer-events: auto;       /* ripristina i click per il link interno */
  z-index: 3;
}
.bubble__link { text-decoration: none; color: inherit; display: contents; }
.bubble__figure { display: grid; place-items: center; gap:.4rem; padding:.2rem; }
.bubble__logo { width: 62%; height: auto; border-radius: 8px; }
.bubble__caption { display: grid; gap: .15rem; }
.bubble__title { font-weight: 700; font-size: clamp(.85rem, .9vw, 1rem); }
.bubble__desc { font-size: clamp(.72rem, .8vw, .9rem); color: var(--muted); }

/* Dimensione in base all’importanza (1 = maggiore) */
.bubble[data-importance="1"] { width: clamp(230px, 20vw, 280px); height: clamp(230px, 20vw, 280px); }
.bubble[data-importance="2"] { width: clamp(200px, 17vw, 240px); height: clamp(200px, 17vw, 240px); }
.bubble[data-importance="3"] { width: clamp(170px, 15vw, 210px); height: clamp(170px, 15vw, 210px); }
.bubble[data-importance="4"] { width: clamp(140px, 13vw, 180px); height: clamp(140px, 13vw, 180px); }
.bubble[data-importance="5"] { width: clamp(120px, 11vw, 160px); height: clamp(120px, 11vw, 160px); }

/* Hover / focus */
.bubble:hover,
.bubble:focus,
.bubble:focus-visible {
  transform: translate(-50%, -50%) scale(1.03);
  border-color: color-mix(in srgb, var(--brand) 60%, var(--bubble-border));
  box-shadow: 0 10px 28px rgba(0,0,0,.18),
              0 0 30px -4px color-mix(in srgb, var(--brand) 50%, transparent);
}

/* Effetto “sboccia” all’ingresso */
.born { animation: pop .6s ease-out both; }
@keyframes pop {
  from { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Mobile: <= 850px → lista verticale elegante */
@media (max-width: 850px) {
  .links-svg, #three-layer { display: none !important; }

  /* il layer torna normale, non overlay */
  .bubbles {
    position: static; inset: auto; z-index: auto; pointer-events: auto;
    display: block;
  }
  .bubble {
    position: static;
    transform: none;
    width: auto; height: auto;
    border-radius: var(--radius-xl);
    display: grid;
    grid-template-columns: 80px 1fr;
    text-align: left;
    padding: .75rem;
    margin: .75rem 0;
  }
  .bubble__logo { width: 70px; }
  .constellation { padding-top: 2rem; }
}

/* Footer */
.site-footer {
  position: relative; z-index:2;
  border-top: 1px solid var(--line);
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

/* Accessibilità: elementi solo-visivi */
.visually-hidden {
  position: absolute !important; height: 1px; width: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap; border:0; padding:0; margin:-1px;
}

/* Riduzione animazioni */
@media (prefers-reduced-motion: reduce) {
  .born, .bubble { animation: none !important; transition: none !important; }
}
