/* =========================================================
   SPARK S.r.l. · Advanced Marine Engineering · Viareggio
   Minimalist High-Tech Dark Theme · Option B + C Mix
   Bespoke Engineering Atelier · English Primary + Italian
   ========================================================= */

:root {
  --bg-primary: #070e1b;
  --bg-secondary: #0d182b;
  --bg-subtle: #12223c;
  --navy-950: #040811;
  --navy-900: #070e1b;
  --navy-800: #0d182b;
  --text: #cbd5e1;
  --text-heading: #ffffff;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --yellow: #ffd400;
  --yellow-hover: #ffe04d;
  --yellow-accent: #ffd400;
  --cyan: #38bdf8;
  --cyan-subtle: rgba(56, 189, 248, 0.12);
  --font-head: "Exo 2", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;
  --container: 1240px;
  --radius: 8px;
  --radius-sm: 4px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  color: var(--text-heading);
  line-height: 1.15;
  margin: 0 0 .4em;
  letter-spacing: -.02em;
}

h1 { font-size: clamp(2.1rem, 4.2vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
h4 { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.container {
  width: min(100% - 48px, var(--container));
  margin-inline: auto;
}

/* Monospace technical tag & coordinates */
.tech-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1rem;
  max-width: 100%;
}
.tech-meta span { opacity: .7; }

/* Hydrodynamic flow subtle dark background */
.hydro-bg {
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 85% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 15% 70%, rgba(255, 212, 0, 0.04) 0%, transparent 50%),
    url("../img/hydro-flow.svg");
  background-size: auto, auto, 1200px 600px;
}

/* ---------- Header & Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 14, 27, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  transition: padding .2s, border-color .2s;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand img {
  height: 32px;
  width: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-link {
  font-family: var(--font-head);
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .02em;
  padding: 4px 0;
  position: relative;
  transition: color .2s;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--yellow);
  transform: scaleX(0);
  transition: transform .2s var(--ease);
}
.nav-link:hover,
.nav-link.active {
  color: #ffffff;
}
.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

/* Language Switcher */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 700;
  background: rgba(13, 24, 43, 0.6);
}
.lang-item {
  padding: 2px 6px;
  border-radius: 2px;
  transition: all .2s;
}
.lang-item.active {
  background: var(--yellow);
  color: var(--navy-950);
}
.lang-item:not(.active) {
  color: var(--text-muted);
}
.lang-item:not(.active):hover {
  color: #ffffff;
}

.btn-contact-header {
  font-family: var(--font-head);
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  background: var(--yellow);
  color: var(--navy-950);
  border: 1px solid var(--yellow);
  transition: all .2s var(--ease);
}
.btn-contact-header:hover {
  background: var(--yellow-hover);
  transform: translateY(-1px);
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  width: 36px; height: 36px;
  padding: 6px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: #ffffff;
  margin: 5px 0;
  transition: transform .25s, opacity .25s;
}
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: .92rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s var(--ease);
  text-decoration: none;
}
.btn-primary {
  background: var(--yellow);
  color: var(--navy-950);
  border: 1px solid var(--yellow);
}
.btn-primary:hover {
  background: var(--yellow-hover);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: #ffffff;
  border: 1px solid var(--line-strong);
}
.btn-outline:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--cyan-subtle);
}
.btn .ico {
  width: 16px; height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* ---------- Badges ---------- */
.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.2rem;
}
.badge-tech {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-secondary);
  color: var(--cyan);
}
.badge-tech.gold {
  border-color: rgba(255, 212, 0, 0.4);
  background: rgba(255, 212, 0, 0.12);
  color: #ffd400;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ffd400;
}

/* ---------- Viewport-Driven Sections ---------- */
.page-compact {
  padding: 48px 0 60px;
  min-height: calc(100vh - 130px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Homepage Hero Manifesto */
.hero-manifesto {
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--line);
}
.hero-manifesto h1 {
  max-width: 980px;
  margin-bottom: .4em;
}
.hero-manifesto .lead-manifesto {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 820px;
  line-height: 1.65;
  margin-bottom: 0;
}
.hero-manifesto .lead-manifesto strong {
  color: #ffffff;
  font-weight: 600;
}

/* Homepage Trittico Portal (3 Pillars) */
.portal-trittico {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.portal-col {
  padding: 44px 36px 48px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-primary);
  transition: background .25s var(--ease);
}
.portal-col:last-child {
  border-right: none;
}
.portal-col::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.portal-col:hover {
  background: var(--bg-secondary);
}
.portal-col:hover::before {
  transform: scaleX(1);
}
.portal-num {
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 14px;
}
.portal-col h2 {
  font-size: 1.35rem;
  margin-bottom: .6em;
}
.portal-col p {
  color: var(--text-muted);
  font-size: .94rem;
  line-height: 1.6;
  margin-bottom: 24px;
  flex-grow: 1;
}
.portal-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #ffffff;
  transition: gap .2s, color .2s;
}
.portal-col:hover .portal-link {
  color: var(--yellow);
  gap: 12px;
}
.portal-link svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* Homepage Compact Bottom Bar (Partner strip + credentials) */
.home-credentials {
  padding: 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.home-credentials-label {
  font-family: var(--font-mono);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-light);
}
.home-partners-compact {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}
.home-partners-compact img {
  height: 24px;
  width: auto;
  opacity: .55;
  filter: brightness(0) invert(1);
  transition: opacity .2s, filter .2s;
}
.home-partners-compact img:hover {
  opacity: 1;
  filter: none;
}

/* ---------- Subpage Compact Split Layout ---------- */
.subpage-head {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
}
.breadcrumbs-compact {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-light);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  max-width: 100%;
}
.breadcrumbs-compact a { color: var(--cyan); }
.breadcrumbs-compact span,
.breadcrumbs-compact a { word-break: break-word; }

.split-compact {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: start;
}

/* Product Media & Floating Render */
.product-visual-box {
  position: relative;
  background: radial-gradient(circle at 50% 50%, #0e1e36 0%, var(--bg-secondary) 100%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  overflow: hidden;
}
.product-visual-box img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, .45));
}

/* Technical Specification List (Compact) */
.spec-list {
  list-style: none;
  margin: 24px 0 32px;
  padding: 0;
  display: grid;
  gap: 16px;
}
.spec-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.spec-num {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  color: var(--cyan);
  flex: none;
  padding-top: 2px;
}
.spec-content strong {
  display: block;
  font-family: var(--font-head);
  font-size: .96rem;
  color: #ffffff;
  margin-bottom: 2px;
}
.spec-content p {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Technical Sample Proportional Image Box */
.sample-image-frame {
  margin-top: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}
.sample-image-frame img {
  width: 100%;
  height: auto;
  display: block;
}

/* Real Photo Box */
.photo-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-secondary);
}
.photo-box img,
.photo-box video {
  width: 100%;
  height: 380px;
  object-fit: cover;
  display: block;
}

.media-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  padding: 0 4px;
}

/* ---------- Contact Page Layout (Minimalist Dark) ---------- */
.contact-split {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 56px;
  align-items: start;
}
.contact-details {
  display: grid;
  gap: 24px;
}
.contact-detail-item {
  border-left: 2px solid var(--line-strong);
  padding-left: 16px;
}
.contact-detail-item:hover {
  border-left-color: var(--yellow);
}
.contact-detail-label {
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--cyan);
  margin-bottom: 4px;
}
.contact-detail-value {
  font-size: 1rem;
  color: #ffffff;
  font-weight: 600;
  margin: 0;
}
.contact-detail-value a {
  color: inherit;
  transition: color .2s;
}
.contact-detail-value a:hover {
  color: var(--yellow);
}

.contact-form-minimal {
  background: var(--bg-secondary);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 32px;
}
.form-row { margin-bottom: 18px; }
.form-row label {
  display: block;
  font-family: var(--font-head);
  font-size: .84rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-primary);
  font-family: var(--font-body);
  font-size: .94rem;
  color: #ffffff;
  transition: border-color .2s;
}
.form-input:focus {
  outline: none;
  border-color: var(--cyan);
}
textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

/* ---------- Minimal Single-Row Footer ---------- */
.site-footer-minimal {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  background: var(--bg-primary);
}
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: .82rem;
  color: var(--text-muted);
}
.footer-coords {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .06em;
  color: var(--text-light);
}

/* ---------- Mobile & Responsive Overhaul ---------- */
@media (max-width: 960px) {
  .portal-trittico { grid-template-columns: 1fr; }
  .portal-col { border-right: none; border-bottom: 1px solid var(--line); padding: 32px 24px; }
  .portal-col:last-child { border-bottom: none; }
  .split-compact,
  .contact-split { grid-template-columns: 1fr; gap: 32px; }
  .product-visual-box { min-height: 280px; padding: 24px; }
  .product-visual-box img { max-height: 260px; }
  .photo-box img,
  .photo-box video { height: 260px; }
}

@media (max-width: 820px) {
  /* Prevent any horizontal overflow on body */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .site-header {
    padding: 12px 0;
  }

  .nav-toggle {
    display: block;
    margin-left: auto;
    z-index: 101;
  }

  /* Full mobile slide-down menu with backdrop */
  .main-nav {
    position: fixed;
    inset: 58px 0 0 0;
    height: calc(100vh - 58px);
    max-height: calc(100vh - 58px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(7, 14, 27, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line-strong);
    padding: 24px 20px 48px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    box-shadow: 0 24px 48px rgba(0,0,0,.6);
    transform: translateY(-110%);
    opacity: 0;
    visibility: hidden;
    transition: transform .3s var(--ease), opacity .25s, visibility .25s;
    z-index: 99;
  }

  .nav-open .main-nav {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  body.nav-open {
    overflow: hidden;
  }

  .nav-link {
    width: 100%;
    font-size: 1.05rem;
    padding: 12px 6px;
    border-bottom: 1px solid var(--line);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-link::after {
    display: none;
  }

  .nav-link.active {
    color: var(--yellow);
    border-bottom-color: rgba(255, 212, 0, 0.3);
  }

  /* Language Switcher prominent in mobile menu */
  .lang-switch {
    order: -1;
    align-self: flex-start;
    padding: 4px 6px;
    font-size: .82rem;
    margin-bottom: 8px;
  }

  .btn-contact-header {
    width: 100%;
    text-align: center;
    padding: 12px 20px;
    margin-top: 10px;
    font-size: .95rem;
    box-sizing: border-box;
    justify-content: center;
  }

  /* Page content mobile layout */
  .page-compact {
    padding: 28px 0 44px;
    min-height: auto;
  }

  .subpage-head {
    padding: 20px 0 16px;
    margin-bottom: 24px;
  }

  .footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* Smartphone Specific Optimization (< 640px) */
@media (max-width: 640px) {
  .container {
    width: min(100% - 32px, var(--container));
  }

  /* Headers and typography scaling */
  h1 {
    font-size: clamp(1.65rem, 7.5vw, 2.25rem);
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    margin-bottom: .4em;
  }

  h2 {
    font-size: clamp(1.3rem, 5.5vw, 1.65rem);
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .hero-manifesto {
    padding: 32px 0 24px;
  }

  .hero-manifesto .lead-manifesto {
    font-size: .98rem;
    line-height: 1.55;
  }

  .tech-meta {
    font-size: .68rem;
    letter-spacing: .08em;
    gap: 6px 10px;
    flex-wrap: wrap;
    margin-bottom: .75rem;
  }

  .breadcrumbs-compact {
    font-size: .7rem;
    gap: 4px 6px;
    flex-wrap: wrap;
  }

  .portal-col {
    padding: 24px 16px;
  }

  .portal-num {
    font-size: .75rem;
  }

  /* Force all button rows to stack cleanly */
  .spec-actions,
  div[style*="display:flex"][style*="flex-wrap"] {
    flex-direction: column;
    width: 100%;
  }

  .btn {
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    padding: 12px 18px;
  }

  /* Media containers on phone */
  .product-visual-box {
    min-height: 220px;
    padding: 20px 14px;
  }

  .product-visual-box img {
    max-height: 200px;
  }

  .photo-box img,
  .photo-box video,
  .video-box video {
    width: 100% !important;
    height: auto !important;
    min-height: 190px;
    max-height: 240px !important;
    object-fit: cover;
  }

  .sample-image-frame {
    margin-top: 24px;
  }

  /* Forms on phone */
  .contact-form-minimal {
    padding: 20px 16px;
  }

  .form-input {
    font-size: 16px; /* Prevents auto-zoom in Safari iOS */
    padding: 10px 12px;
  }

  /* Credentials and partner logos */
  .home-credentials {
    padding: 20px 0;
    gap: 14px;
  }

  .home-partners-compact {
    gap: 18px 24px;
  }

  .home-partners-compact img {
    height: 20px;
  }
}

/* ---------- News Grid (responsive) ---------- */
.news-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
}
.news-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  background: var(--bg-secondary);
  min-width: 0;
}
@media (max-width: 820px) {
  .news-grid { grid-template-columns: 1fr; gap: 18px; }
  .news-card { padding: 20px 18px; }
}
