/* ============================================================
   AI-Gest — Main Stylesheet
   Font: Raleway (Google Fonts)
   Primary color: #1b4332 (dark green)
   ============================================================ */

/* ---------- RESET & ROOT ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green:        #1b4332;
  --green-mid:    #2d6a4f;
  --green-light:  #40916c;
  --green-pale:   #d8f3dc;
  --white:        #ffffff;
  --glass-white:  rgba(255, 255, 255, 0.88);
  --glass-green:  rgba(27, 67, 50, 0.85);
  --shadow:       0 12px 40px rgba(27, 67, 50, 0.22);
  --header-h:     72px;
  --radius:       6px;
  --transition:   0.28s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Raleway', sans-serif;
  color: var(--green);
  min-height: 100vh;
  background-image: url('../IMAGES/Fondoweb.png');
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-color: #e8f5e9; /* fallback */
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27,67,50,0.35); border-radius: 4px; }


/* ==========================================================
   HEADER
   ========================================================== */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 40px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(27, 67, 50, 0.12);
}

.logo-area {
  flex: 0 0 auto;
  margin-right: auto;
  display: flex;
  align-items: center;
}

.logo {
  height: 72px;
  width: auto;
  object-fit: contain;
  display: block;
}

.logo-fallback {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--green);
  text-transform: uppercase;
}

/* NAV */
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 20px;
}

.nav-link {
  text-decoration: none;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  position: relative;
  white-space: nowrap;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 16px; right: 16px;
  height: 2px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
  border-radius: 2px;
}

.nav-link:hover::after,
.nav-link.active::after { transform: scaleX(1); }
.nav-link.active { font-weight: 700; }

/* header right group: lang + hamburger */
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* LANGUAGE BUTTON */
#lang-btn {
  background: var(--green);
  color: var(--white);
  border: none;
  cursor: pointer;
  font-family: 'Raleway', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: 30px;
  transition: background var(--transition), transform var(--transition);
}
#lang-btn:hover { background: var(--green-mid); transform: scale(1.06); }

/* HAMBURGER — hidden on desktop */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px; height: 38px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background var(--transition);
}
.hamburger:hover { background: var(--green-pale); }
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--green);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
/* animated X state */
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* MOBILE NAV OVERLAY */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0,0,0,0.35);
}
.mobile-nav-overlay.visible { display: block; }


/* ==========================================================
   MAIN & PAGES
   ========================================================== */
main {
  padding-top: var(--header-h);
  min-height: 100vh;
}

.page {
  display: none;
  min-height: calc(100vh - var(--header-h));
}

.page.active {
  display: flex;
  flex-direction: column;
}

/* shared title */
.page-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--green);
  margin-bottom: 10px;
}

.title-rule {
  width: 56px; height: 3px;
  background: var(--green);
  border-radius: 2px;
  margin-bottom: 32px;
}


/* ==========================================================
   HOME PAGE
   ========================================================== */
#page-home { justify-content: center; }

.home-content {
  display: flex;
  align-items: center;
  flex: 1;
  padding: 64px 80px 80px;
  gap: 48px;
  min-height: calc(100vh - var(--header-h));
}

.home-text {
  flex: 1 1 0;
  max-width: 66%;
}

.home-tagline {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--green-light);
  margin-bottom: 18px;
  padding: 4px 14px;
  border: 1.5px solid var(--green-light);
  border-radius: 30px;
}

.home-headline {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--green);
  margin-bottom: 26px;
}

.home-body {
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.82;
  color: var(--green);
  opacity: 0.84;
  max-width: 520px;
  margin-bottom: 40px;
}

.home-cta {
  display: inline-block;
  background: var(--green);
  color: var(--white);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 15px 40px;
  border-radius: var(--radius);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.home-cta:hover {
  background: var(--green-mid);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(27,67,50,0.30);
}

.home-image {
  flex: 0 0 28%;
  max-width: 28%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.home-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 40px rgba(0,0,0,0.18));
}


/* ==========================================================
   SERVICES PAGE
   ========================================================== */
#page-services {
  flex-direction: column;
  overflow-x: hidden;
}

/* ---- top row: title left, video right ---- */
.services-top {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 60px 80px 40px;
  gap: 0;
}

.services-top-left {
  flex: 0 0 50%;
  max-width: 50%;
  padding-right: 48px;
}

.services-intro {
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.8;
  color: var(--green);
  opacity: 0.82;
  max-width: 420px;
}

/* video lives in the right half, left-aligned = starts at page center */
.services-top-right {
  flex: 0 0 50%;
  max-width: 50%;
  display: flex;
  justify-content: flex-start;
  padding-top: 8px;
}

.video-container {
  background: var(--green);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: inline-block;
  line-height: 0;
}

.video-container video {
  width: 10cm;
  height: 10cm;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* ---- scattered shapes ---- */
/*
  Positions (left/right in %):
    1 hexagon   — upper-left
    2 circle    — upper-right
    3 diamond   — mid-center
    4 para      — lower-left
    5 pentagon  — lower-right
  Total container height: 960px (scroll down to see all)
*/
.services-shapes-scatter {
  position: relative;
  width: 100%;
  height: 1560px;
  margin-bottom: 60px;
}

/* base shape
   Background = border colour. shape-inner (white, margin:3px) sits
   3px inside, so the exposed green strip acts as a proper border that
   follows the clip-path outline — the only reliable technique for
   clip-path shapes (CSS border gets rectangularly clipped away). */
.service-shape {
  position: absolute;
  display: flex;
  align-items: stretch;   /* shape-inner fills the full height */
  justify-content: center;
  text-align: center;
  background: var(--green);   /* the "border" colour */
  color: var(--green);
  cursor: default;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.service-shape:hover {
  color: var(--white);
  transform: translateY(-5px) scale(1.04);
  box-shadow: 0 18px 44px rgba(27,67,50,0.32);
  z-index: 10;
}
.service-shape:hover .shape-inner  { background: var(--glass-green); }
.service-shape:hover .service-icon { opacity: 0.18; }

.shape-inner {
  margin: 0px;               /* eliminated 3px of green border around edge */
  background: var(--glass-white);
  flex: 1;                   /* fill available space inside service-shape */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 14px;
  transition: background var(--transition);
}

.service-icon {
  font-size: 2.56rem;
  opacity: 0.28;
  line-height: 1;
  margin-bottom: 4px;
  transition: opacity var(--transition);
}

.service-title {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.service-desc {
  font-size: 1.12rem;
  font-weight: 300;
  line-height: 1.55;
  opacity: 0.85;
}

/* shape sizes — desktop (50% bigger than original)
   Inner padding keeps text inside each shape's visible area:
   - hexagon: content must stay below y≥50px where visible width ≥ 196px
   - circle:  content must be within chord ≥ text width (needs P≥45px)
   - diamond: visible width at content edge = 2×P_top; requires P≥N/4
              → enlarged to 400px so text area (200px) remains readable
   - pentagon: top narrows sharply; requires P≥N*0.22
              → enlarged to 340px for a usable 190px content area
   - parallelogram: gentle slant, default padding is fine
*/
.shape-hexagon {
  width: 293px; height: 293px;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.shape-hexagon .shape-inner { padding: 50px; }

.shape-circle {
  width: 293px; height: 293px;
  border-radius: 50%;
}
.shape-circle .shape-inner { padding: 45px; }

.shape-diamond {
  width: 400px; height: 400px;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.shape-diamond .shape-inner { padding: 100px; }

.shape-parallelogram {
  width: 372px; height: 207px;
  clip-path: polygon(7% 0%, 100% 0%, 93% 100%, 0% 100%);
}
.shape-pentagon {
  width: 340px; height: 340px;
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}
.shape-pentagon .shape-inner { padding: 75px; }

/* scatter positions — recalculated for bigger shapes */
.scatter-1 { top:  30px; left:  6%; }
.scatter-2 { top: 150px; right: 7%; }
.scatter-3 { top: 450px; left: 34%; }
.scatter-4 { top: 850px; left:  5%; }
/* scatter-5: centered horizontally, pinned to bottom */
.scatter-5 { bottom: 50px; left: 50%; right: auto; top: auto; transform: translateX(-50%); }
.scatter-5:hover   { transform: translateX(-50%) translateY(-5px) scale(1.04); }


/* ==========================================================
   NEWS PAGE
   ========================================================== */
#page-news { flex-direction: column; }

.news-inner { padding: 60px 80px 80px; }

.news-header { margin-bottom: 0; }

.news-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
  max-width: 1000px;
}

.news-card {
  background: var(--glass-white);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 32px 36px;
  border: 1px solid rgba(27,67,50,0.10);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.news-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 36px rgba(27,67,50,0.16);
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.news-tag {
  background: var(--green-pale);
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 3px 12px;
  border-radius: 30px;
  white-space: nowrap;
}

.news-date {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--green-light);
  font-style: italic;
}

.news-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--green);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.news-excerpt {
  font-size: 0.88rem;
  font-weight: 300;
  line-height: 1.72;
  color: var(--green);
  opacity: 0.72;
  margin-bottom: 20px;
  flex: 1;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green-mid);
  text-decoration: none;
  font-size: 0.80rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--transition), gap var(--transition);
  align-self: flex-start;
}
.read-more:hover { color: var(--green); gap: 10px; }


/* ==========================================================
   CONTACTS PAGE
   ========================================================== */
#page-contacts { flex-direction: row; align-items: stretch; }

.contacts-inner {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 48px 80px;
  gap: 60px;
  min-height: calc(100vh - var(--header-h));
}

.contact-card {
  background: var(--green);
  color: var(--white);
  width: 42%;
  min-height: 60vh;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 60px;
  box-shadow: 0 24px 64px rgba(27,67,50,0.38);
  flex-shrink: 0;
}

.contact-headline {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 36px;
}

.contact-card p {
  font-size: 1.02rem;
  font-weight: 300;
  line-height: 1.9;
  opacity: 0.92;
}

.contact-card p strong {
  font-weight: 700;
  font-size: 1.15rem;
  opacity: 1;
}

.contact-card a {
  color: var(--white);
  text-decoration-color: rgba(255,255,255,0.45);
}

/* decorative shapes — right side of contacts */
.contact-deco {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  opacity: 0.20;
  pointer-events: none;
}
.deco-hex {
  width: 140px; height: 140px;
  background: var(--green);
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.deco-circle {
  width: 90px; height: 90px;
  background: var(--green-light);
  border-radius: 50%;
}
.deco-diamond {
  width: 110px; height: 110px;
  background: var(--green-mid);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}


/* ==========================================================
   RESPONSIVE — TABLET  (≤ 960px)
   ========================================================== */
@media (max-width: 960px) {
  #site-header { padding: 0 24px; }

  .home-content { padding: 48px 40px 64px; gap: 32px; }
  .home-text { max-width: 62%; }
  .home-headline { font-size: 2.6rem; }

  .services-top { padding: 48px 40px 32px; }
  .services-top-left { padding-right: 32px; }
  .video-container video { width: 8cm; height: 8cm; }

  .news-inner { padding: 48px 40px 64px; }
  .contacts-inner { padding: 40px 40px; gap: 40px; }
}


/* ==========================================================
   RESPONSIVE — MOBILE LANDSCAPE / SMALL TABLET (≤ 768px)
   Shows hamburger menu
   ========================================================== */
@media (max-width: 768px) {

  /* ---- Header ---- */
  /* Remove backdrop-filter on mobile: it creates a compositing layer in
     WebKit/Safari that traps position:fixed children inside the header
     bounds, making the slide-down nav invisible behind the page. */
  #site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.97);
  }

  .main-nav {
    /* slide-down drawer — lives outside the header stacking context now */
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    background: rgba(255, 255, 255, 0.99);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 0 20px;
    border-bottom: 2px solid var(--green-pale);
    z-index: 300;   /* above everything, safe from stacking-context traps */
    transform: translateY(-110%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 0;
  }

  .main-nav.open { transform: translateY(0); }

  .nav-link {
    font-size: 0.88rem;
    padding: 14px 28px;
    border-radius: 0;
    border-bottom: 1px solid rgba(27,67,50,0.06);
  }
  .nav-link::after { display: none; }
  .nav-link.active { background: var(--green-pale); }

  .hamburger { display: flex; }

  /* ---- Home ---- */
  .home-content {
    flex-direction: column;
    padding: 36px 24px 56px;
    align-items: center;
    gap: 28px;
    min-height: auto;
  }
  .home-text { max-width: 100%; }
  .home-headline { font-size: 2rem; }
  .home-body { max-width: 100%; font-size: 0.95rem; }
  .home-image { width: 52%; max-width: 52%; justify-content: center; }

  /* ---- Services ---- */
  .services-top {
    flex-direction: column;
    padding: 36px 24px 24px;
    gap: 28px;
  }
  .services-top-left { flex: unset; max-width: 100%; padding-right: 0; }
  .services-top-right { flex: unset; max-width: 100%; justify-content: center; }
  .video-container video { width: 7cm; height: 7cm; }

  /* shapes: flow layout on mobile (absolute → relative) */
  .services-shapes-scatter {
    position: static;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 16px 24px 48px;
    margin-bottom: 0;
  }
  .service-shape {
    position: static !important;
    /* slightly alternate left/right via margin */
  }
  .scatter-1 { align-self: flex-start; margin-left: 4%; transform: none; }
  .scatter-2 { align-self: flex-end;   margin-right: 4%; transform: none; }
  .scatter-3 { align-self: center;  transform: none; }
  .scatter-4 { align-self: flex-start; margin-left: 4%; transform: none; }
  .scatter-5 { align-self: flex-end;   margin-right: 4%; transform: none; }

  /* ---- News ---- */
  .news-inner { padding: 36px 24px 56px; }
  .news-grid { grid-template-columns: 1fr; gap: 20px; }

  /* ---- Contacts ---- */
  .contacts-inner {
    flex-direction: column;
    padding: 36px 24px 56px;
    align-items: stretch;
    gap: 32px;
    min-height: auto;
  }
  .contact-card {
    width: 100%;
    min-height: auto;
    padding: 40px 36px;
  }
  .contact-headline { font-size: 2.2rem; }
  .contact-deco { flex-direction: row; flex-wrap: wrap; opacity: 0.14; gap: 20px; }
}


/* ==========================================================
   RESPONSIVE — PHONE PORTRAIT  9:16  (≤ 480px)
   ========================================================== */
@media (max-width: 480px) {

  :root { --header-h: 60px; }

  /* ---- Header ---- */
  #site-header { padding: 0 16px; }
  .logo { height: 36px; }
  #lang-btn { padding: 5px 13px; font-size: 0.72rem; }

  /* ---- Home ---- */
  .home-content {
    flex-direction: column;
    padding: 28px 18px 48px;
    gap: 24px;
    align-items: center;
  }
  .home-tagline { font-size: 0.68rem; letter-spacing: 0.18em; }
  .home-headline { font-size: 1.72rem; margin-bottom: 18px; }
  .home-body { font-size: 0.90rem; line-height: 1.75; margin-bottom: 28px; }
  .home-cta { padding: 12px 30px; font-size: 0.76rem; }
  .home-image { width: 70%; max-width: 70%; }

  /* ---- Services ---- */
  .services-top { padding: 28px 18px 20px; gap: 22px; }
  .page-title { font-size: 1.55rem; }
  .title-rule { margin-bottom: 22px; }
  .services-intro { font-size: 0.90rem; }
  .video-container video { width: 100%; height: auto; aspect-ratio: 1/1; }
  .video-container { width: 100%; }
  .services-top-right { width: 100%; max-width: 100%; }

  /* shapes: all centered, smaller */
  .scatter-1, .scatter-2, .scatter-3, .scatter-4, .scatter-5 {
    align-self: center;
    margin-left: 0;
    margin-right: 0;
    transform: none;
  }
  .shape-hexagon, .shape-circle { width: 165px; height: 165px; }
  .shape-diamond { width: 200px; height: 200px; }
  .shape-parallelogram { width: 220px; height: 124px; }
  .shape-pentagon { width: 180px; height: 180px; }
  /* reset large desktop paddings to phone-safe values */
  .shape-hexagon .shape-inner,
  .shape-circle .shape-inner,
  .shape-diamond .shape-inner,
  .shape-pentagon .shape-inner { padding: 16px 20px; }
  .service-icon { font-size: 1.2rem; }
  .service-title { font-size: 0.70rem; }
  .service-desc { font-size: 0.64rem; }

  /* ---- News ---- */
  .news-inner { padding: 28px 18px 48px; }
  .news-card { padding: 24px 22px; }
  .news-title { font-size: 0.96rem; }
  .news-excerpt { font-size: 0.83rem; }

  /* ---- Contacts ---- */
  .contacts-inner { padding: 28px 18px 48px; gap: 24px; }
  .contact-card { padding: 36px 28px; }
  .contact-headline { font-size: 1.8rem; margin-bottom: 24px; }
  .contact-card p { font-size: 0.94rem; }
  .contact-deco { display: none; }
}

/* Extra small safety net */
@media (max-width: 360px) {
  .home-headline { font-size: 1.5rem; }
  .contact-headline { font-size: 1.55rem; }
  .shape-hexagon, .shape-circle { width: 145px; height: 145px; }
  .shape-diamond { width: 150px; height: 150px; }
  .shape-pentagon { width: 148px; height: 148px; }
}
