/* Import modern typography from Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;600;700;800&display=swap");

/* Define Theme Tokens */
:root {
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-title: "Outfit", system-ui, -apple-system, sans-serif;

  /* Premium HSL Color Palette */
  --primary-hue: 137;
  --primary: hsl(var(--primary-hue), 46%, 43%); /* Beautiful Green */
  --primary-light: hsl(var(--primary-hue), 48%, 92%);
  --primary-hover: hsl(var(--primary-hue), 48%, 36%);

  --secondary-hue: 203;
  --secondary: hsl(var(--secondary-hue), 90%, 12%); /* Premium Dark Navy */
  --secondary-light: hsl(var(--secondary-hue), 25%, 96%);

  --neutral-dark: hsl(200, 20%, 15%);
  --neutral-light: hsl(0, 0%, 98%);
  --border-color: hsl(200, 10%, 90%);
  --bg-gradient: linear-gradient(
    135deg,
    hsl(0, 0%, 100%) 0%,
    hsl(var(--primary-hue), 30%, 98%) 100%
  );

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 16px -6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.12);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 24px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --container-width: 1100px;
}

/* Visually Hidden Utility for Screen Readers */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Accessible Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1.5rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--font-title);
  font-weight: 700;
  z-index: 9999;
  transition: top 0.2s ease;
  box-shadow: var(--shadow-md);
}

.skip-link:focus-visible {
  top: 0;
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
}

/* High Contrast Focus Indication */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* Reset & Global Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem; /* 16px baseline */
  background: var(--neutral-light);
  color: var(--neutral-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Ensure form elements inherit typography to prevent browser default overrides */
input,
textarea,
select,
button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  line-height: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-title);
  color: var(--secondary);
  font-weight: 700;
  line-height: 1.2;
}

p {
  margin-bottom: 1.25rem;
  font-weight: 400;
  color: hsl(200, 15%, 30%);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* Underline inline links inside body text blocks for WCAG 1.4.1 (Use of Color) compliance */
p a,
li a,
.rich-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Keep structural and button links clean unless hovered/focused */
.btn,
.nav-link,
.logo-link,
.footer-links a {
  text-decoration: none !important;
}

.footer-links a:hover {
  text-decoration: underline !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Layout Utilities */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Glassmorphic Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 90px;
}

/* Live Brand Logo Layout */
.logo-link {
  display: inline-block;
  text-decoration: none !important;
  color: inherit;
}

.logo-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 55px;
}

/* live text typography */
.logo-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.05;
  font-family: var(--font-title);
}

.logo-prefix,
.logo-suffix {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(
    --primary-hover
  ); /* Brand green, darkened for better legibility & contrast */
  letter-spacing: 0.04em;
}

.logo-title {
  font-size: 1.55rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(
    --secondary
  ); /* Premium Dark Navy for strong hierarchy and maximum contrast */
  letter-spacing: -0.01em;
  margin: 0.15rem 0; /* Perfectly symmetric vertical spacing */
  white-space: nowrap; /* Prevent words from wrapping */
}

/* 3-tree graphic styling */
.logo-graphics {
  display: flex;
  align-items: flex-end;
  gap: 0.15rem;
  height: 100%;
}

.logo-tree {
  width: auto;
  display: block;
  object-fit: contain;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}

/* Tree Sizing Scale (3 sizes) */
.tree-sm {
  height: 25px;
}

.tree-md {
  height: 38px;
}

.tree-lg {
  height: 52px;
}

/* Staggered spring micro-animations on hover (only on devices that support hover to avoid sticky mobile tap states) */
@media (hover: hover) {
  .logo-link:hover .tree-sm {
    transform: scale(1.1) translateY(-2px);
  }

  .logo-link:hover .tree-md {
    transform: scale(1.1) translateY(-3px);
    transition-delay: 0.04s;
  }

  .logo-link:hover .tree-lg {
    transform: scale(1.1) translateY(-4px);
    transition-delay: 0.08s;
  }
}

/* Responsive Logo scaling for Mobile */
@media (max-width: 1024px) {
  .logo-content {
    height: 44px;
    gap: 0.5em;
  }

  .logo-prefix,
  .logo-suffix {
    font-size: 0.68rem;
  }

  .logo-title {
    font-size: 1.2rem;
    margin: 0.08rem 0; /* Symmetric spacing on mobile */
  }

  .tree-sm {
    height: 19px;
  }

  .tree-md {
    height: 29px;
  }

  .tree-lg {
    height: 40px;
  }
}

.main-nav {
  display: flex;
  gap: 1.75rem;
  list-style: none;
}

.nav-link {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1rem;
  color: var(--secondary);
  position: relative;
  padding: 0.5rem 0;
}

.nav-link-text {
  position: relative;
  display: inline-block;
}

.nav-link-text::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: var(--transition);
}

.nav-link:hover .nav-link-text::after,
.nav-link.active .nav-link-text::after {
  width: 100%;
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
}

/* Mobile Nav Toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 2.2rem;
  cursor: pointer;
  color: var(--secondary);
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: var(--primary-light);
  color: var(--primary-hover);
}

/* Hero Section */
.hero {
  position: relative;
  padding: 8rem 0 6rem;
  background: linear-gradient(
    180deg,
    var(--primary-light) 0%,
    rgba(255, 255, 255, 0) 100%
  );
  text-align: center;
  overflow: hidden;
}

.hero-logo {
  margin: 0 auto 2rem;
  max-width: 180px;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.25rem;
  max-width: 700px;
  margin: 0 auto 2.5rem;
  color: hsl(200, 15%, 25%);
}

.hero-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2rem;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(98, 191, 124, 0.4);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(98, 191, 124, 0.5);
}

.btn-secondary {
  background: var(--secondary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(3, 38, 59, 0.3);
}

.btn-secondary:hover {
  background: hsl(var(--secondary-hue), 90%, 20%);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(3, 38, 59, 0.4);
}

/* Feature Pillars Grid */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 2rem;
  margin: 4rem 0;
}

.pillar-card {
  background: #fff;
  padding: 2.5rem 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.pillar-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.pillar-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pillar-icon img {
  width: 30px;
  height: 30px;
}

.pillar-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

/* Page Containers */
.page-container {
  padding: 4rem 0;
}

.page-title {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
}

.page-title::after {
  content: "";
  display: block;
  width: 60px;
  height: 4px;
  background: var(--primary);
  margin: 0.75rem auto 0;
  border-radius: 2px;
}

.rich-content {
  background: #fff;
  padding: 3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 3rem;
}

.rich-content h2,
.rich-content h3 {
  margin: 2.5rem 0 1rem;
}

.rich-content ul,
.rich-content ol {
  margin: 1.5rem 0 1.5rem 2rem;
}

.rich-content li {
  margin-bottom: 0.5rem;
}

/* Callout Section (5x1000) */
.callout-section {
  background: linear-gradient(
    135deg,
    var(--secondary) 0%,
    hsl(var(--secondary-hue), 90%, 20%) 100%
  );
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 4rem 3rem;
  margin: 4rem 0;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  align-items: center;
  gap: 3rem;
}

.callout-text h2 {
  color: #fff;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.callout-text p {
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

.callout-image img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* Convenzioni (Sponsors) Grid */
.sponsors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin: 3rem 0;
}

.sponsor-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.sponsor-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.sponsor-img-wrapper {
  background: #f7f9fa;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sponsor-img-wrapper img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

.sponsor-info {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sponsor-info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.sponsor-discount {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--primary-light);
  color: var(--primary-hover);
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* Progetti (Blog) */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2.5rem;
}

.post-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.post-card-img {
  height: 200px;
  overflow: hidden;
}

.post-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.post-card:hover .post-card-img img {
  transform: scale(1.05);
}

.post-card-content {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.post-card-meta {
  font-size: 0.85rem;
  color: hsl(200, 10%, 50%);
  margin-bottom: 0.5rem;
}

.post-card h3 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.post-card p {
  font-size: 0.95rem;
  color: hsl(200, 10%, 35%);
  margin-bottom: 1.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-single {
  max-width: 800px;
  margin: 0 auto;
}

.post-single-header {
  text-align: center;
  margin-bottom: 3rem;
}

.post-single-meta {
  color: hsl(200, 10%, 40%);
  margin-top: 0.75rem;
  font-weight: 500;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin: 3.5rem 0;
}

.gallery-grid img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
}

.gallery-grid img:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

/* Contatti Page & Netlify Form */
.contacts-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4rem;
  margin-top: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-family: var(--font-title);
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: hsl(0, 0%, 99%);
  transition: var(--transition);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.rich-content ul.contact-info-list {
  list-style: none;
  margin: 1.5rem 0 1.5rem 0; /* Reset left margin from 2rem to 0 */
  padding-left: 0; /* Reset default browser list indentation */
}

.contact-info-item {
  display: flex;
  align-items: flex-start; /* Align icons with the first line of wrapped text */
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.contact-info-item svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
  flex-shrink: 0; /* Prevent icons from squeezing on small viewports */
  margin-top: 0.2rem; /* Perfect alignment with the first text line */
  stroke-width: 1.5px; /* Uniform thin stroke-width of exactly 1.5 CSS pixels */
}

/* Footer styling */
.site-footer {
  background: var(--secondary);
  color: rgba(255, 255, 255, 0.9);
  padding: 5rem 0 3rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.site-footer a {
  color: hsl(
    137,
    60%,
    65%
  ); /* Bright distinct green with high contrast on dark backgrounds */
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: var(--transition);
}

.site-footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.site-footer p {
  color: rgba(255, 255, 255, 0.7);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.5fr; /* Widen contacts column to prevent email wrap */
  gap: 3rem;
  margin-bottom: 4rem;
}

.footer-widget h3 {
  color: #fff;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

.footer-links {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.75rem;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  .hero h1 {
    font-size: 2.75rem;
  }
  .callout-section {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .contacts-grid {
    grid-template-columns: 1fr;
    gap: 3rem;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 1024px) {
  .header-container {
    height: 75px;
  }
  .main-nav {
    display: none; /* Hidden by default on mobile */
  }
  .main-nav.open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%; /* Perfect alignment: exactly at the bottom of the header */
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    gap: 0;
    z-index: 99;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05); /* Premium soft drop shadow */
  }
  .main-nav.open li {
    width: 100%;
  }
  .main-nav.open .nav-link {
    display: block;
    width: 100%;
    text-align: right;
    padding: 0.75rem 0; /* Better mobile tap target padding */
  }
  .main-nav.open .nav-link-text::after {
    left: auto;
    right: 0;
  }
  .nav-toggle {
    display: flex;
  }
  .hero h1 {
    font-size: 2.25rem;
  }
  .rich-content {
    padding: 1.5rem;
  }
}

/* Prevent overflow of long words, emails, and links on mobile */
a,
p,
span,
li,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.contact-info-item a {
  word-break: break-all;
}

/* Optimizations for very small mobile screens (e.g. iPhone 13 mini) */
@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }
  .rich-content {
    padding: 1.25rem 1rem;
  }
  .contacts-grid {
    gap: 1.5rem;
  }
  .form-input,
  .form-textarea {
    padding: 0.6rem 0.8rem;
  }
  .page-title {
    font-size: 2.25rem;
  }
}

/* Copyable IBAN spacing using pure inline text and margins to prevent newline pasting */
.iban-container {
  display: inline;
}

.iban-part {
  display: inline;
  margin-right: 0.2em;
}

.iban-part:last-child {
  margin-right: 0;
}

/* Copy Button Styling */
.copy-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 4px;
  margin-left: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transition: var(--transition);
}

.copy-btn:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

/* Match footer background style */
.site-footer .copy-btn {
  color: hsl(137, 60%, 65%);
}

.site-footer .copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.copy-btn svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-btn:active svg {
  transform: scale(0.85);
}
