/* BEEZY — premium dark UI over the 3D stage */

:root {
  --bg: #0a0d13;
  --bg2: #0e131c;
  --panel: rgba(13, 18, 27, 0.78);
  --line: #232e42;
  --text: #eef2f8;
  --muted: #8b96a8;
  --amber: #f0a929;
  --cyan: #53c8ff;
  --green: #7ee787;
  --pink: #ff6f91;
  --violet: #b695ff;
  --radius: 14px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* no CSS smooth-scroll: native smooth animations starve under the WebGL rAF loop;
   the #scroll-down button animates scrollTop itself */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ————— 3D canvas ————— */
#scene3d {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  /* mobile: vertical swipe scrolls to the content below the hero (pinch-zoom stays disabled so
     our JS handles it); free/Esplora mode switches this to `none` in JS for full gestures */
  touch-action: pan-y;
  z-index: 0;
}

/* ————— loading ————— */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  transition: opacity 0.7s ease, visibility 0.7s;
}
#loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.load-logo { font-size: 3rem; font-weight: 900; letter-spacing: 0.06em; }
.load-logo span, .logo span, #fallback h1 span { color: var(--amber); }
.load-bar { width: 220px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.load-bar span {
  display: block; height: 100%; width: 40%;
  background: var(--amber); border-radius: 2px;
  animation: loadslide 1.1s ease-in-out infinite;
}
@keyframes loadslide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
#loading p { color: var(--muted); font-size: 0.9rem; }

/* ————— fallback ————— */
#fallback {
  position: fixed; inset: 0; z-index: 90; display: none;
  background: radial-gradient(120% 90% at 50% 10%, #182034 0%, var(--bg) 60%);
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  text-align: center; padding: 24px;
}
#fallback.show { display: flex; }
#fallback h1 { font-size: 4rem; font-weight: 900; }
#fallback h2 { font-weight: 600; }
#fallback p { color: var(--muted); max-width: 46ch; }

/* ————— HUD ————— */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px;
  pointer-events: none;
}
#hud .logo { font-size: 1.4rem; font-weight: 900; letter-spacing: 0.05em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.hud-right { display: flex; gap: 10px; pointer-events: auto; }
#quality-select, #sound-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; font-size: 0.85rem; cursor: pointer;
  backdrop-filter: blur(10px);
}
#quality-select:hover, #sound-btn:hover, #light-btn:hover { border-color: var(--amber); }
#light-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; font-size: 0.85rem; cursor: pointer;
  backdrop-filter: blur(10px);
}
#light-pop {
  position: absolute; top: 52px; right: 0;
  display: none; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; backdrop-filter: blur(12px);
}
#light-pop.open { display: flex; }
.lp-title { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.lp-swatches { display: flex; gap: 8px; }
.lp-sw {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
}
.lp-sw:hover, .lp-sw.active { border-color: var(--text); }
.lp-custom {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 0.78rem; color: var(--muted);
}
#light-custom {
  width: 40px; height: 26px; padding: 0; border: 1px solid var(--line);
  border-radius: 6px; background: none; cursor: pointer;
}
#light-intensity { width: 110px; accent-color: var(--amber); cursor: pointer; }

/* ————— zoom controls ————— */
#zoom-controls {
  position: fixed; right: 20px; bottom: 76px;
  z-index: 35; display: flex; flex-direction: column; gap: 8px;
}
#zoom-controls button {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); font-size: 1.5rem; line-height: 1; cursor: pointer;
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
}
#zoom-controls button:hover { border-color: var(--amber); }
#zoom-controls button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
body.shot #zoom-controls { display: none; }

/* ————— hero ————— */
#hero {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center;
  padding: 0 6vw;
  pointer-events: none;
}
.hero-copy {
  max-width: 560px;
  padding: 32px 36px 30px;
  border-radius: 22px;
  /* frosted glass: subtle, with a glossy top highlight */
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015) 40%, rgba(10, 13, 19, 0.30));
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(14px) saturate(1.25);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.10);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.hero-copy h1 {
  font-size: clamp(3.4rem, 8vw, 6.2rem);
  font-weight: 900; letter-spacing: 0.02em; line-height: 0.95;
  background: linear-gradient(120deg, #fff 30%, var(--amber) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
}
.hero-copy h2 {
  font-size: clamp(1.2rem, 2.6vw, 1.7rem);
  font-weight: 600; margin-top: 10px;
}
.hero-copy .lead {
  color: #c6cfdc; margin-top: 16px; font-size: clamp(0.95rem, 1.6vw, 1.08rem); line-height: 1.6;
  max-width: 46ch;
}
.cta-row { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.btn {
  pointer-events: auto;
  display: inline-block;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--text);
  padding: 13px 22px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  backdrop-filter: blur(10px);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--amber); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(120deg, var(--amber), #ffca5f);
  color: #14100a; border-color: transparent;
  box-shadow: 0 6px 24px rgba(240, 169, 41, 0.35);
}
.btn.primary:hover { box-shadow: 0 10px 30px rgba(240, 169, 41, 0.5); }
.btn.ghost { background: rgba(13, 18, 27, 0.6); }
.btn.small { padding: 9px 14px; font-size: 0.85rem; }
.hint { margin-top: 18px; color: var(--muted); font-size: 0.82rem; }
/* ————— scroll-down button ————— */
#scroll-down {
  position: fixed; bottom: 18px; right: 18px; z-index: 35;
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(120deg, var(--amber), #ffca5f);
  color: #14100a; border: none; border-radius: 40px;
  padding: 13px 20px; font-family: var(--font); font-size: 0.9rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 26px rgba(240, 169, 41, 0.45);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#scroll-down:hover { transform: translateY(-2px); box-shadow: 0 10px 32px rgba(240, 169, 41, 0.6); }
#scroll-down:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
#scroll-down .chev { animation: chevbob 1.6s ease-in-out infinite; }
@keyframes chevbob { 50% { transform: translateY(3px); } }
body.shot #scroll-down { display: none; }

/* once scrolled into the content, the fixed 3D overlays get out of the way so the site is readable */
body.scrolled #hero, body.scrolled #scroll-down, body.scrolled #zoom-controls,
body.scrolled #mode-pills, body.scrolled #ops-panel, body.scrolled #agent-panel {
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s;
}

/* hero copy retreats once the user engages with the scene */
body.engaged .hero-copy { opacity: 0; transform: translateY(-16px); pointer-events: none; }
body.engaged .hero-copy .btn { pointer-events: none; }
body.engaged .scroll-hint { opacity: 0; }

/* ————— ops panel ————— */
#ops-panel {
  position: fixed; top: 74px; right: 20px; z-index: 30;
  width: 235px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(12px);
  font-size: 0.82rem;
}
.ops-head {
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; letter-spacing: 0.08em; font-size: 0.72rem;
  color: var(--amber); margin-bottom: 10px;
}
.ops-head .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
.ops-head button {
  margin-left: auto;
  background: transparent; color: var(--amber);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.72rem; padding: 3px 8px; cursor: pointer;
}
.ops-head button:hover { border-color: var(--amber); }
.ops-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); }
.ops-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.ops-selected {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  color: var(--cyan); font-size: 0.78rem; min-height: 1.2em;
}

/* ————— agent panel ————— */
#agent-panel {
  position: fixed; top: 74px; left: 20px; z-index: 30;
  width: 265px; max-height: calc(100vh - 170px); overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(12px);
  transform: translateX(-120%); opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s;
}
#agent-panel.open { transform: none; opacity: 1; }
#ap-close {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer;
}
#ap-close:hover { color: var(--text); }
#agent-panel h3 { font-size: 1.3rem; }
.ap-role { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.ap-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 5px 12px;
  font-size: 0.8rem; margin-bottom: 12px;
}
.ap-grid span { color: var(--muted); }
.ap-grid b { font-weight: 600; }
.ap-progress .bar {
  height: 7px; background: var(--line); border-radius: 4px; overflow: hidden;
}
.ap-progress .bar span { display: block; height: 100%; width: 0; background: var(--amber); border-radius: 4px; transition: width 0.3s; }
.ap-progress small { color: var(--muted); font-size: 0.72rem; }
.ap-sub { margin-top: 12px; font-size: 0.7rem; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 0.72rem; padding: 3px 9px;
  background: rgba(83, 200, 255, 0.1); color: var(--cyan);
  border: 1px solid rgba(83, 200, 255, 0.25); border-radius: 20px;
}
#ap-log { list-style: none; margin-top: 6px; font-size: 0.75rem; color: var(--muted); }
#ap-log li { padding: 3px 0; border-bottom: 1px dashed rgba(35, 46, 66, 0.6); }
#ap-follow { margin-top: 14px; width: 100%; }

/* ————— camera mode pills ————— */
#mode-pills {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 30;
  display: flex; gap: 7px; padding: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 40px;
  backdrop-filter: blur(12px);
  max-width: calc(100vw - 30px);
  overflow-x: auto;
  scrollbar-width: none;
}
#mode-pills::-webkit-scrollbar { display: none; }
.pill {
  white-space: nowrap;
  background: transparent; color: var(--muted);
  border: none; border-radius: 30px;
  padding: 8px 13px; font-size: 0.78rem; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.pill:hover { color: var(--text); }
.pill.active { background: var(--amber); color: #14100a; font-weight: 700; }

/* ————— toasts ————— */
#toasts {
  position: fixed; bottom: 84px; right: 20px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 10px; padding: 10px 15px; font-size: 0.82rem;
  backdrop-filter: blur(10px);
  animation: toastin 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), toastout 0.4s ease 3.7s forwards;
  max-width: 320px;
}
@keyframes toastin { from { transform: translateX(30px); opacity: 0; } }
@keyframes toastout { to { transform: translateX(30px); opacity: 0; } }

/* ————— debug ————— */
#debug-overlay {
  position: fixed; bottom: 18px; left: 18px; z-index: 60;
  background: rgba(0, 0, 0, 0.75); color: var(--green);
  font: 11px/1.6 monospace; padding: 10px 13px; border-radius: 8px;
  white-space: pre; pointer-events: none;
}

/* ————— scrollable content ————— */
#content { position: relative; z-index: 10; pointer-events: none; }
.hero-space { height: 100vh; }
.sections {
  pointer-events: auto;
  position: relative;
  background: linear-gradient(180deg, rgba(10, 13, 19, 0) 0%, var(--bg) 90px, var(--bg) 100%);
  padding-top: 40px;
}
.sections section {
  max-width: 1060px; margin: 0 auto; padding: 72px 24px;
}
.sections h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800;
  margin-bottom: 14px;
}
.sections h2::after {
  content: ""; display: block; width: 52px; height: 3px;
  background: var(--amber); border-radius: 2px; margin-top: 12px;
}
.section-lead { color: var(--muted); max-width: 68ch; line-height: 1.65; margin-bottom: 30px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.agents { grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); }
.card {
  background: var(--bg2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.22s ease, border-color 0.22s ease;
}
.card:hover { transform: translateY(-4px); border-color: #34435f; }
.card h3 { font-size: 1.02rem; margin-bottom: 9px; }
.card p { color: var(--muted); font-size: 0.88rem; line-height: 1.55; }
.card.agent b { font-size: 1.05rem; display: block; }
.card.agent p { margin-top: 9px; }
.tag {
  display: inline-block; margin-top: 6px;
  font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 20px; border: 1px solid;
}
.tag.hub { color: var(--amber); border-color: rgba(240, 169, 41, 0.4); }
.tag.web { color: var(--amber); border-color: rgba(240, 169, 41, 0.4); }
.tag.seo { color: var(--cyan); border-color: rgba(83, 200, 255, 0.4); }
.tag.social { color: var(--pink); border-color: rgba(255, 111, 145, 0.4); }
.tag.auto { color: var(--green); border-color: rgba(126, 231, 135, 0.4); }
.tag.ops { color: var(--violet); border-color: rgba(182, 149, 255, 0.4); }
.card.contact .muted, .muted { color: var(--muted); font-size: 0.85rem; }
.card.contact .btn { margin: 6px 0 12px; }
footer {
  text-align: center; padding: 60px 20px 80px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.85rem;
}
footer .logo { font-size: 1.5rem; font-weight: 900; margin-bottom: 8px; color: var(--text); }
footer .muted { margin-top: 14px; font-size: 0.72rem; }

/* ————— embed mode: iframe hero inside the Next.js site ————— */
body.embed #content, body.embed .scroll-hint { display: none; }
body.embed #hud { top: 60px; }
body.embed #hud .logo { visibility: hidden; }
body.embed #ops-panel { top: 136px; }
body.embed #agent-panel { top: 136px; }

/* ————— screenshot mode: clean frame ————— */
body.shot #hud, body.shot #hero, body.shot #mode-pills, body.shot #ops-panel,
body.shot #toasts, body.shot #content { display: none; }

/* ————— responsive ————— */
@media (max-width: 900px) {
  #ops-panel { display: none; }
  #agent-panel { width: min(300px, calc(100vw - 32px)); top: auto; bottom: 132px; max-height: 40vh; }
  #hero { padding: 0 7vw; align-items: flex-start; padding-top: 12vh; }
  .hero-copy { padding: 24px 22px 22px; }
  /* prominent, centred and clear of the camera pills + the phone toolbar */
  #scroll-down {
    left: 50%; right: auto; transform: translateX(-50%);
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    padding: 13px 24px; font-size: 0.95rem; z-index: 45;
  }
  #mode-pills { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  /* mid-right on mobile — the ops panel is hidden there, so the space is free */
  #zoom-controls { right: 12px; top: 40%; bottom: auto; transform: translateY(-50%); }
  #zoom-controls button { width: 42px; height: 42px; }
  /* keep toasts clear of the centred "Scopri di più" button */
  #toasts { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); left: 14px; right: 14px; align-items: center; }
}
@media (max-width: 560px) {
  .cta-row .btn { width: 100%; text-align: center; }
  #hud { padding: 12px 14px; }
}
