@property --scrolled {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

@keyframes mark-scrolled {
  to {
    --scrolled: 1;
  }
}

html {
  animation: mark-scrolled steps(1, end) both;
  animation-timeline: scroll(self);
  animation-range: calc(100svh - 1px) 100svh;
}

:root {
  --max-width: 1024px;

  --black: hsl(184, 100%, 3%);
  --white: hsl(0, 0%, 100%);

  --green-200: hsl(80, 45%, 52%);
  --green-300: hsl(80, 45%, 44%);
  --green-400: hsl(80, 45%, 30%);
  --green-500: hsl(80, 45%, 25%);

  --orange-400: hsl(19, 92%, 47%);
  --orange-500: hsl(18, 91%, 41%);

  --gray-text: hsl(0, 0%, 33%);

  --font: "Noto Sans", sans-serif;
  --serif: "Noto Serif", serif;

  --bg: var(--green-400);
  --font-color: var(--white);
  --font-color-contrast: var(--black);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

ul {
  list-style-type: none;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

body {
  font-family: var(--font);
  line-height: 1.65;
  color: var(--font-color);
  background-color: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  position: relative;
}

header {
  position: fixed;
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: transparent;
  padding: 1rem;
  z-index: 100;

  nav {
    background-color: var(--white);
    display: flex;
    height: 4rem;
    padding: 0.25rem 0.25rem 0.25rem 1.25rem;
    border-radius: 1rem;
    width: 100%;
    margin: 0;
    font-size: 0.9rem;
    outline: 2px solid var(--green-300);

    ul {
      display: flex;
      align-items: center;
      border-radius: inherit;
      gap: 0;
      justify-content: space-between;
      width: 100%;

      li {
        color: var(--font-color-contrast);
        height: 100%;
        display: block;
        border-radius: inherit;

        a {
          border-radius: 0.625rem;
          font-family: var(--font);
          height: 100%;
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          text-align: center;
          letter-spacing: 0.025em;
          text-transform: uppercase;
          padding: 0 1rem;
          font-weight: 700;
          transition: background-color 0.15s ease;
        }

        a:hover {
          background-color: #f0f0f0;
        }
      }

      li:last-child {
        display: block;

        a {
          background-color: var(--orange-400);
          color: var(--white);
          border-radius: 0.625rem;
          position: relative;
        }

        a:hover {
          background-color: var(--orange-500);
        }

        a::before {
          content: "";
          position: absolute;
          top: calc(100% + 0.2rem);
          left: 50%;
          transform: translateX(-50%);
          border: 5px solid transparent;
          border-bottom-color: var(--black);
          pointer-events: none;
          opacity: 0;
          transition: opacity 0.15s ease;
        }

        a::after {
          content: attr(data-tooltip);
          position: absolute;
          top: calc(100% + 0.7rem);
          left: 50%;
          transform: translateX(-50%);
          background: var(--black);
          color: var(--white);
          font-size: 0.75rem;
          font-weight: 400;
          letter-spacing: 0.02em;
          white-space: nowrap;
          padding: 0.3rem 0.65rem;
          border-radius: 0.375rem;
          pointer-events: none;
          opacity: 0;
          transition: opacity 0.15s ease;
        }

        a:hover::before,
        a:hover::after {
          opacity: 1;
        }
      }
    }
  }
}

/* ── HERO ── */
[data-section="hero"] {
  background-image: url(./img/horizontal.gif);
  background-repeat: no-repeat;
  background-position: center center;
  height: 100svh;
  position: relative;
  min-height: fit-content;
  background-size: cover;
}

[data-section="hero"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(15, 25, 8, 0.6);
  pointer-events: none;
}

[data-section="hero"] > div {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: fit-content;
  max-width: var(--max-width);
  margin-inline: auto;
  padding: 1.5rem;

  /* spazio in basso per la navbar mobile sticky */
  padding-bottom: 6rem;

  display: flex;
  flex-direction: column;
}

[data-hero="bottom"] {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

[data-hero="bottom"] > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-direction: column;
}

[data-hero="bottom"] > div > a {
  border: 1px solid var(--green-200);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

[data-hero="bottom"] > a {
  display: none;
}

[data-section="content"] {
  background-color: var(--white);
  color: var(--black);
  padding: 4rem 1.5rem 0 1.5rem;
}

[data-section="content"] > div {
  max-width: var(--max-width);
  margin-inline: auto;
}

[data-section="content"] h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.5rem;
  font-weight: 400;
  margin-bottom: 2.5rem;
  opacity: 0.9;
  text-align: center;
}

[data-section="content"] ul {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  padding-bottom: 4rem;
}

[data-section="content"] li {
  border-radius: 1.25rem;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.07);
  max-width: 660px;
}

[data-section="content"] li img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 0.75rem;
}

[data-section="content"] li > div {
  padding: 1rem 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  h3 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--black);
  }

  p {
    font-size: 0.95rem;
    color: var(--gray-text);
    line-height: 1.65;
  }
}

hgroup {
  display: grid;
  gap: 1.5rem;
  border-radius: 1rem;

  h1 {
    font-family: var(--serif);
    line-height: 1.04;
    letter-spacing: -0.025em;
    font-size: 4rem;
    font-style: italic;
    text-wrap: pretty;
    color: var(--green-200);
  }

  p {
    font-weight: 400;
    line-height: 1.5;
    font-size: 1.75rem;
    text-wrap: balance;
  }
}

/* ── CAROUSEL ── */
[data-section="carousel"] {
  overflow: hidden;
  margin-top: 0.5rem;
}

[data-carousel="track"] {
  display: flex;
  width: max-content;
  animation: carousel-scroll 32s linear infinite;
}

[data-carousel="inner"] {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  padding: 0 0.25rem;
}

[data-carousel="inner"] img {
  height: 240px;
  width: auto;
  border-radius: 8px;
}

@keyframes carousel-scroll {
  to {
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-carousel="track"] {
    animation-play-state: paused;
  }
}

@media (width >= 768px) {
  [data-carousel="inner"] img {
    height: 360px;
  }
}

/* ── LIGHTBOX ── */
[data-lightbox] {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 999;
  place-items: center;
  cursor: zoom-out;
}

[data-lightbox]:target {
  display: grid;
}

[data-lightbox-close] {
  position: absolute;
  inset: 0;
}

[data-lightbox] img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  position: relative;
  cursor: default;
  pointer-events: none;
}

/* ── ABOUT ── */
[data-section="about"] {
  background-color: var(--bg);
  padding: 4rem 1.5rem;
}

[data-section="about"] > div {
  max-width: var(--max-width);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

[data-section="about"] img {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 1rem;
  order: -1;
}

[data-section="about"] h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 2.5rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

[data-section="about"] p {
  opacity: 0.85;
  line-height: 1.75;
}

[data-section="about"] p + p {
  margin-top: 1rem;
}

@media (width >= 768px) {
  [data-section="about"] > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
  }

  [data-section="about"] img {
    order: 0;
    height: 100%;
    min-height: 360px;
  }

  [data-section="about"] h2 {
    font-size: 3rem;
  }
}

footer {
  background-color: var(--green-500);
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  p {
    font-size: 0.85rem;
    opacity: 0.7;
  }
}

[data-footer="top"] {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;

  > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
}

[data-footer="social"] {
  display: flex;
  gap: 1rem;
  align-items: center;

  a {
    opacity: 0.7;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
  }

  a:hover {
    opacity: 1;
  }

  [data-footer="divider"] {
    display: block;
    width: 1px;
    height: 1.25rem;
    background-color: rgba(255, 255, 255, 0.3);
  }

  a:not([aria-label]) {
    font-size: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
  }
}

[data-footer="legal"] {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 1.5rem;
}

[data-footer="terms"] {
  line-height: 1.6;
}

/* ── MOBILE ── */
@media (width < 768px) {
  main {
    display: flex;
    flex-direction: column;
  }

  header {
    position: sticky;
    bottom: 0;
    top: auto;
    left: auto;
    right: auto;
    order: 999;
  }

  [data-section="content"] {
    padding: 2rem 0.75rem 0 0.75rem;
  }

  [data-section="content"] ul {
    gap: 0.75rem;
  }

  [data-footer="top"] {
    flex-direction: column;
  }

  [data-footer="social"] {
    flex-wrap: wrap;
  }

  [data-footer="divider"] {
    width: 100%;
    height: 1px;
  }
}

/* ── DESKTOP ── */
@media (width >= 768px) {
  [data-section="content"],
  [data-section="carousel"],
  [data-section="about"] {
    scroll-margin-top: 6rem;
  }

  [data-section="hero"] > div {
    align-items: flex-end;
    padding-top: 9rem;
    padding-bottom: 3rem;
    padding-left: 6rem;
  }

  hgroup {
    height: fit-content;

    h1 {
      font-size: 8.25rem;
    }
    p {
      max-width: 75%;
      font-size: 1.75rem;
    }
  }

  [data-hero="bottom"] {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  [data-hero="bottom"] > div {
    flex-direction: row;
  }

  /* Desktop: la navbar non è la CTA principale — mostriamo il bottone */
  [data-hero="bottom"] > a {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    background: var(--white);
    color: var(--font-color-contrast);
    padding: 0.75rem 1.75rem;
    border-radius: 0.625rem;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  [data-hero="bottom"] > a:hover {
    background-color: var(--orange-400);
    color: var(--white);
  }

  [data-section="content"] h2 {
    font-size: 3.5rem;
  }

  [data-section="content"] ul {
    background-image: url(./img/tree_climbing.webp);
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: contain;
  }

  [data-section="content"] li {
    grid-template-columns: 300px 1fr;
  }

  [data-section="content"] li img {
    height: 100%;
    min-height: 180px;
  }

  [data-section="content"] li > div {
    padding: 0.75rem 1rem;
    justify-content: center;
    gap: 0.75rem;

    h3 {
      font-size: 1.4rem;
    }
  }

  [data-section="content"] li[data-reverse] {
    grid-template-columns: 1fr 300px;
    margin-left: auto;
  }

  [data-section="content"] li[data-reverse] img {
    order: 2;
  }

  [data-section="content"] li[data-reverse] > div {
    order: 1;
  }

  header {
    bottom: auto;
    top: 0;
    padding: 1rem;

    nav {
      margin-left: auto;
      margin-right: 0;
      width: fit-content;
      transform: translateX(calc((-50vw + 50%) * (1 - var(--scrolled))));
      transition: transform 1s ease;

      ul {
        gap: 0.75rem;
        li {
          display: block;
        }
      }
    }
  }
}

@media (orientation: portrait) and (width < 768px) {
  [data-section="hero"] {
    background-image: url(./img/vertical.gif);
    height: 100svh;
  }
}

@media (orientation: landscape) and (width < 768px) {
  [data-hero="bottom"] > div {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}
