/* ==========================================================================
   Netcat — Enhancement layer: typography, menu, cinematic motion,
   video-like effects, cookie banner. Loaded after inline page CSS.
   ========================================================================== */

/* ---------- Typography: Fraunces (display) + Instrument Sans (body) ---------- */
/* Selectors bumped (html/:root) so they beat the later inline page CSS. */
html:root {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, sans-serif;
}

html body { font-family: var(--font-body); }

html h1, html h2, html h3, html .trust-card h2, html .proof-panel p {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-weight: 540;
  letter-spacing: -0.018em;
}
html h1 { font-weight: 480; line-height: 1.08; }
html h2 { line-height: 1.06; }
html h3 { font-weight: 580; letter-spacing: -0.01em; line-height: 1.1; }

html .eyebrow {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 0.8rem;
  line-height: 1.2;
  font-variation-settings: "opsz" 18, "SOFT" 60;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
html .site-footer .eyebrow { color: var(--accent); }

html .timeline-item span {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 460;
  font-variation-settings: "opsz" 100, "SOFT" 80;
  letter-spacing: -0.04em;
}

html .article-body h2, html .cookie-prefs-panel h2 { font-weight: 580; }

html .button, html .site-header .nav-links a, html .mobile-menu summary, html .mobile-menu nav a {
  font-family: var(--font-body);
}

/* ==========================================================================
   Menu / navigation
   ========================================================================== */

/* Desktop: animated underline + active dot */
.site-header .nav-links { gap: 4px; }
.site-header .nav-links a {
  position: relative;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}
.site-header .nav-links a::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 9px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transform: scaleX(0);
  transform-origin: 100% 50%;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.site-header .nav-links a:hover::after,
.site-header .nav-links a:focus-visible::after,
.site-header .nav-links a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: 0 50%;
}
.site-header .nav-links a:hover,
.site-header .nav-links a:focus-visible {
  background: transparent;
  color: var(--ink);
}
.site-header .nav-links a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.site-header .nav-links a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: var(--accent);
}

/* Header entrance */
@keyframes header-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
html .site-header { animation: header-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Mobile menu: refined panel with staggered items */
html .mobile-menu summary {
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: background 0.2s ease, border-color 0.2s ease;
}
html .mobile-menu summary:hover { background: rgba(255, 255, 255, 0.8); }
html .mobile-menu summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: 10px;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.25s ease;
}
html .mobile-menu[open] summary::after { transform: rotate(225deg) translateY(-1px); }
html .mobile-menu nav { gap: 4px; padding: 16px; }
html .mobile-menu nav a {
  position: relative;
  min-height: 50px;
  padding: 0 18px 0 38px;
  font-size: 1.02rem;
  font-weight: 600;
  border-radius: 18px;
  transition: background 0.18s ease, color 0.18s ease;
  opacity: 0;
  animation: menu-item-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
html .mobile-menu nav a:nth-child(1) { animation-delay: 0.05s; }
html .mobile-menu nav a:nth-child(2) { animation-delay: 0.10s; }
html .mobile-menu nav a:nth-child(3) { animation-delay: 0.15s; }
html .mobile-menu nav a:nth-child(4) { animation-delay: 0.20s; }
html .mobile-menu nav a:nth-child(5) { animation-delay: 0.25s; }
html .mobile-menu nav a:nth-child(6) { animation-delay: 0.30s; }
@keyframes menu-item-in {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}
html .mobile-menu nav a[aria-current="page"] {
  color: var(--ink);
  background: rgba(15, 110, 143, 0.12);
}
html .mobile-menu nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--accent);
}
html .mobile-menu nav a:last-child {
  margin-top: 8px;
  color: #fff;
  background: linear-gradient(135deg, #06121c, #0a2a3d 52%, #144d63);
}

/* Scrim behind open mobile menu (page content dimmed, header on top) */
html.menu-open body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(4, 12, 20, 0.38);
  backdrop-filter: blur(3px);
  animation: scrim-in 0.3s ease both;
  pointer-events: auto;
}
@keyframes scrim-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Film grain overlay (video feel) ---------- */
.grain-overlay {
  position: fixed;
  inset: -50%;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 9s steps(6) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  16% { transform: translate(-2%, 3%); }
  33% { transform: translate(3%, -2%); }
  50% { transform: translate(-3%, -3%); }
  66% { transform: translate(2%, 2%); }
  83% { transform: translate(-1%, 1%); }
}

/* ---------- Hero canvas layering (home + detail pages) ---------- */
/* .detail-hero/.contact-hero lack position:relative in inline CSS, so the
   absolute canvas collapses to zero — anchor it and lift the copy above. */
html .detail-hero, html .contact-hero { position: relative; }
html .detail-hero > div, html .contact-hero > div, html .contact-hero > form {
  position: relative;
  z-index: 1;
}
.hero-canvas {
  opacity: 0;
  transition: opacity 1.4s ease;
}
.hero-canvas.is-live { opacity: 1; }

/* ---------- Menu quality: scrolled state, hover lift, skip link ---------- */
html .site-header {
  transition:
    padding 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    top 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.35s ease,
    background 0.35s ease;
}
html .site-header.is-scrolled {
  top: 10px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(247, 250, 251, 0.82));
  box-shadow: 0 20px 54px rgba(6, 18, 28, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
html .site-header.is-scrolled .brand img { width: 112px; }
html .brand img { transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

html .site-header .nav-links a {
  transition: color 0.18s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
html .site-header .nav-links a:hover,
html .site-header .nav-links a:focus-visible {
  transform: translateY(-1px);
}

/* Skip link (keyboard users) */
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10002;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  background: #06121c;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  transform: translateY(-220%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 110, 143, 0.5);
}

/* ---------- Scroll reveal (video-like cut-in) ---------- */
/* Kill the inline load-time .reveal animation: visibility is owned by the
   IntersectionObserver (prevents appear→hide→appear flash below the fold;
   without JS elements simply stay visible). */
html .reveal { animation: none; }
.reveal-scroll {
  opacity: 0;
  transform: translateY(26px) scale(0.985);
  filter: blur(6px);
  transition:
    opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(var(--index, 0) * 60ms);
  will-change: opacity, transform, filter;
}
.reveal-scroll.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

/* ---------- Ken Burns on card imagery (cinematic drift) ---------- */
@media (hover: hover) {
  .post-card img, .service-card img {
    animation: kenburns 18s ease-in-out infinite alternate;
    transform-origin: 50% 42%;
  }
  .post-card:nth-child(2n) img, .service-card:nth-child(2n) img { animation-duration: 24s; transform-origin: 42% 58%; }
  .post-card:nth-child(3n) img, .service-card:nth-child(3n) img { animation-duration: 21s; transform-origin: 58% 50%; }
}
@keyframes kenburns {
  from { transform: scale(1) translate(0, 0); }
  to   { transform: scale(1.09) translate(-1.4%, 1.2%); }
}

/* ---------- Card hover: video-frame zoom ---------- */
.post-card, .service-card {
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.45s ease;
}
.post-card:hover, .service-card:hover {
  transform: translateY(-6px);
}
.post-card:hover img, .service-card:hover img {
  animation-play-state: paused;
}

/* ---------- Timeline number ticker ---------- */
.timeline-item span {
  display: inline-block;
  transform-origin: 50% 100%;
}
.timeline-item.is-visible span {
  animation: count-in 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes count-in {
  0% { opacity: 0; transform: translateY(24px) rotate(8deg) scale(0.7); }
  100% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

/* ---------- Magnetic CTA glow ---------- */
.button.primary {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.button.primary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, transparent 35%, rgba(161, 98, 7, 0.55), transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.button.primary:hover::before, .button.primary:focus-visible::before {
  transform: translateX(120%);
}

/* ---------- Marquee strip (infinite video ticker) ---------- */
.marquee {
  overflow: hidden;
  border-block: 1px solid var(--line);
  padding: 18px 0;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
}
.marquee-track {
  display: flex;
  gap: 64px;
  width: max-content;
  animation: marquee 38s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.marquee-track span::after {
  content: "◆";
  margin-left: 64px;
  color: var(--accent);
  font-size: 0.6em;
  vertical-align: middle;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---------- Anchor offset under sticky header ---------- */
section[id], [id="servizi"], [id="magazine"] {
  scroll-margin-top: 110px;
}

/* ---------- Scroll progress bar ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  z-index: 9999;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent-strong), var(--accent), #06121c);
  pointer-events: none;
}

/* ---------- View transition (page change, video cut) ---------- */
@view-transition {
  navigation: auto;
}

/* ==========================================================================
   Cookie banner — Garante privacy (Linee guida 10 giugno 2021)
   ========================================================================== */
.cookie-banner {
  position: fixed;
  inset-inline: 12px;
  bottom: 12px;
  z-index: 10000;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  max-width: 1080px;
  margin-inline: auto;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(250, 250, 249, 0.88));
  box-shadow: 0 26px 72px rgba(28, 25, 23, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(24px) saturate(1.15);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.cookie-banner[hidden] { display: none; }
.cookie-banner.is-visible { opacity: 1; transform: translateY(0); }
.cookie-banner p { margin: 0; font-size: 0.94rem; line-height: 1.55; max-width: 62ch; }
.cookie-banner strong { color: var(--ink); }
.cookie-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.cookie-actions .button { min-height: 48px; padding: 0 14px; font-size: 0.92rem; }
.cookie-link {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cookie-link:hover { color: var(--ink); }

/* Preferences panel */
.cookie-prefs {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: grid;
  place-items: end center;
  padding: 12px;
  background: rgba(12, 10, 9, 0.44);
  backdrop-filter: blur(6px);
}
.cookie-prefs[hidden] { display: none; }
.cookie-prefs-panel {
  width: min(760px, 100%);
  max-height: min(82dvh, 720px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  background: linear-gradient(145deg, #ffffff, #f7fafb);
  box-shadow: 0 30px 90px rgba(12, 10, 9, 0.4);
}
.cookie-prefs-panel h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); margin-bottom: 8px; }
.cookie-prefs-panel > p { margin: 0 0 18px; }
.cookie-toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.cookie-toggle-row:first-of-type { border-top: 0; }
.cookie-toggle-row h3 { font-size: 1rem; font-family: var(--font-body); font-weight: 800; margin: 0 0 4px; }
.cookie-toggle-row p { margin: 0; font-size: 0.9rem; }
.cookie-switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 4px;
}
.cookie-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.cookie-switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(28, 25, 23, 0.18);
  transition: background 0.25s ease;
  pointer-events: none;
}
.cookie-switch .track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(28, 25, 23, 0.35);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.cookie-switch input:checked + .track { background: var(--accent); }
.cookie-switch input:checked + .track::after { transform: translateX(24px); }
.cookie-switch input:disabled + .track { opacity: 0.55; cursor: not-allowed; }
.cookie-switch input:focus-visible + .track { box-shadow: var(--focus-ring); }
.cookie-prefs-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.cookie-prefs-actions .button { flex: 1; min-width: 160px; }

@media (max-width: 780px) {
  .cookie-banner { grid-template-columns: 1fr; inset-inline: 10px; bottom: 10px; padding: 18px; }
  .cookie-actions .button { font-size: 0.88rem; }
  .cookie-prefs-panel { padding: 20px; }
}

/* ---------- Reduced motion: kill decorative video ---------- */
@media (prefers-reduced-motion: reduce) {
  .grain-overlay, .marquee-track,
  .post-card img, .service-card img { animation: none !important; }
  .hero-canvas { opacity: 0.5; }
  .reveal-scroll {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }
  .cookie-banner, .cookie-banner.is-visible { transition: none; }
}
