/*
Theme Name: Agrofloresta Viva
Theme URI: https://agrofloresta.es/
Author: Agrofloresta Viva SL
Description: Tema de bloques para Agrofloresta Viva, basado en Gutenberg y en el prototipo visual validado.
Version: 0.9.6
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
Text Domain: agrofloresta-viva
*/

:root {
  --av-forest: #102b22;
  --av-forest-2: #193c30;
  --av-ivory: #f3f0e8;
  --av-sand: #e5dccd;
  --av-sage: #9eae98;
  --av-moss: #67765f;
  --av-ink: #18221d;
  --av-muted: #5e6a64;
  --av-white: #ffffff;
  --av-line: rgba(16, 43, 34, 0.16);
  --av-shadow: 0 28px 80px rgba(12, 36, 27, 0.12);
  --av-radius: 28px;
}

html {
  max-width: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  max-width: 100%;
  overflow-x: clip;
}

img,
svg,
video {
  max-width: 100%;
}

a {
  transition: color 0.25s ease, background-color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.av-site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  color: var(--av-white);
  background: rgba(16, 43, 34, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  transition: background-color 0.3s ease, color 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease;
}

.admin-bar .av-site-header {
  top: 32px;
}

.av-site-header.is-scrolled {
  color: var(--av-forest);
  background: rgba(243, 240, 232, 0.97);
  border-color: var(--av-line);
  box-shadow: 0 1px 0 var(--av-line);
}

.av-header-inner {
  min-height: 92px;
  gap: clamp(1rem, 2.5vw, 2.5rem);
  transition: min-height 0.3s ease;
}

.av-site-header.is-scrolled .av-header-inner {
  min-height: 72px;
}

.av-site-header .custom-logo {
  display: block;
  width: auto;
  max-width: 220px;
  max-height: 76px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  transition: max-width 0.3s ease, max-height 0.3s ease, filter 0.3s ease;
}

.av-site-header.is-scrolled .custom-logo {
  max-width: 138px;
  max-height: 58px;
  filter: none;
}

.av-site-header .wp-block-site-title {
  margin: 0;
  color: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.av-header-inner:has(.custom-logo-link) .wp-block-site-title {
  display: none;
}

.av-site-header .wp-block-navigation,
.av-site-header .wp-block-navigation a {
  color: inherit;
}

.av-site-header .wp-block-navigation-item:not(.av-nav-cta) > a {
  position: relative;
}

.av-site-header .wp-block-navigation-item:not(.av-nav-cta) > a::after {
  position: absolute;
  right: 100%;
  bottom: -0.35rem;
  left: 0;
  height: 1px;
  content: "";
  background: currentColor;
  transition: right 0.25s ease;
}

.av-site-header .wp-block-navigation-item:not(.av-nav-cta) > a:hover::after,
.av-site-header .current-menu-item:not(.av-nav-cta) > a::after {
  right: 0;
}

.av-nav-cta > a,
.wp-block-button.is-style-av-primary .wp-block-button__link {
  color: var(--av-white) !important;
  background: var(--av-forest) !important;
  border: 1px solid var(--av-forest);
  border-radius: 999px;
  padding: 0.85rem 1.35rem;
  font-weight: 700;
}

.av-site-header:not(.is-scrolled) .av-nav-cta > a {
  color: var(--av-forest) !important;
  background: var(--av-white) !important;
  border-color: var(--av-white);
}

.wp-block-button.is-style-av-secondary .wp-block-button__link {
  color: var(--av-forest) !important;
  background: transparent !important;
  border: 1px solid var(--av-line);
  border-radius: 999px;
  padding: 0.85rem 1.35rem;
  font-weight: 700;
}

.wp-block-button__link:hover,
.av-nav-cta > a:hover {
  transform: translateY(-2px);
}

.av-page-main {
  padding-top: 124px;
}

body:has(.av-hero) .av-page-main {
  padding-top: 0;
}

.av-eyebrow {
  margin-bottom: 1rem;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.av-lead {
  max-width: 760px;
  color: var(--av-muted);
  font-size: clamp(1.08rem, 1.5vw, 1.38rem);
}

.av-card {
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--av-line);
  border-radius: 24px;
  box-shadow: none;
  transition: transform 0.35s ease, background-color 0.35s ease, box-shadow 0.35s ease;
}

.av-card:hover {
  background: var(--av-white);
  box-shadow: var(--av-shadow);
  transform: translateY(-6px);
}

.av-cta {
  position: relative;
  overflow: hidden;
  min-height: 520px;
  color: var(--av-white);
  background: linear-gradient(135deg, var(--av-forest), var(--av-forest-2));
}

.av-cta::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle at 82% 18%, rgba(158, 174, 152, 0.24), transparent 36%);
}

.av-cta > .wp-block-group__inner-container,
.av-cta .av-cta-inner {
  position: relative;
  z-index: 1;
}

.av-footer {
  color: var(--av-white);
  background: #0b211a;
}

.av-blog-listing {
  padding: clamp(4.5rem, 8vw, 7rem) var(--wp--style--root--padding-right);
  background: var(--av-ivory);
}

.av-blog-grid {
  gap: clamp(1.25rem, 3vw, 2.25rem);
}

.av-blog-card {
  overflow: hidden;
  padding: 1rem 1rem 1.5rem;
  background: var(--av-white);
  border: 1px solid rgba(16, 43, 34, 0.1);
  border-radius: 22px;
  box-shadow: 0 14px 36px rgba(16, 43, 34, 0.08);
}

.av-blog-card .wp-block-post-title {
  margin: 0.55rem 0;
}

.av-blog-card .wp-block-post-title a {
  color: var(--av-forest);
  text-decoration: none;
}

.av-blog-card .wp-block-post-date {
  margin-top: 1rem;
  color: rgba(16, 43, 34, 0.62);
}

.av-blog-empty {
  max-width: 760px;
  padding: clamp(2rem, 5vw, 4rem);
  text-align: center;
  background: rgba(158, 174, 152, 0.13);
  border-radius: 24px;
}

.av-footer .custom-logo {
  width: auto;
  max-width: 190px;
  max-height: 84px;
  filter: brightness(0) invert(1);
}

.av-footer a {
  color: inherit;
}

.av-footer-grid {
  display: grid;
  grid-template-columns: minmax(250px, 1.45fr) repeat(3, minmax(150px, 0.75fr));
  gap: clamp(2rem, 5vw, 4.75rem);
  align-items: start;
}

.av-footer-brand p,
.av-footer-bottom p {
  color: rgba(255, 255, 255, 0.68);
}

.av-footer-brand p {
  max-width: 31rem;
  margin-top: 1.4rem;
  margin-bottom: 0;
}

.av-footer-column h2 {
  margin: 0 0 1.15rem;
  color: var(--av-white);
  font-family: inherit;
  font-size: 0.79rem !important;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.av-footer-links {
  display: grid;
  gap: 0.72rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.av-footer-links li {
  margin: 0;
}

.av-footer-links a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  text-underline-offset: 0.2em;
}

.av-footer-links a:hover,
.av-footer-links a:focus-visible {
  color: var(--av-white);
  text-decoration: underline;
}

.av-footer-pending {
  color: rgba(255, 255, 255, 0.44);
  cursor: not-allowed;
}

.av-footer-contact a {
  overflow-wrap: anywhere;
}

.av-footer-bottom {
  margin-top: clamp(2.25rem, 5vw, 4rem);
  padding-top: 1.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  gap: 0.75rem 2rem;
}

.av-footer-bottom p {
  margin: 0;
  font-size: 0.86rem;
}

/* Complianz: banner y control persistente adaptados al sistema visual. */
.cmplz-cookiebanner {
  border: 1px solid rgba(16, 43, 34, 0.12) !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 50px rgba(11, 33, 26, 0.2) !important;
}

.cmplz-cookiebanner .cmplz-btn.cmplz-accept,
.cmplz-cookiebanner .cmplz-btn.cmplz-deny {
  color: var(--av-white) !important;
  background: var(--av-forest) !important;
  border-color: var(--av-forest) !important;
}

.cmplz-cookiebanner .cmplz-btn.cmplz-view-preferences {
  color: var(--av-forest) !important;
  background: transparent !important;
  border-color: var(--av-forest) !important;
}

.cmplz-manage-consent {
  right: max(1rem, env(safe-area-inset-right)) !important;
  bottom: max(1rem, env(safe-area-inset-bottom)) !important;
  color: var(--av-forest) !important;
  background: var(--av-ivory) !important;
  border: 1px solid rgba(16, 43, 34, 0.28) !important;
  border-radius: 999px !important;
  box-shadow: 0 8px 24px rgba(11, 33, 26, 0.18) !important;
}

.av-footer-social a {
  display: inline-flex;
  padding: 0.62rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.av-footer-social a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.av-back-to-top {
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 140;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--av-white);
  background: rgba(16, 43, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  box-shadow: 0 14px 34px rgba(10, 30, 23, 0.22);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease, background-color 0.28s ease;
}

.av-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.av-back-to-top:hover {
  background: #0a2119;
  transform: translateY(-3px);
}

.av-back-to-top svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* La plantilla de portada usa el sistema visual validado del prototipo. */
.av-home {
  margin: 0;
}

.av-home + .av-footer {
  margin-block-start: 0;
}

/* El bloque raíz de WordPress añade un gap que el prototipo no tiene. */
.wp-site-blocks > main,
.wp-site-blocks > footer.wp-block-template-part {
  margin-block-start: 0;
}

/* Ajustes de fidelidad tras el QA contra el prototipo publicado. */
.av-site-header:not(.is-scrolled) {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.av-site-header .custom-logo {
  max-height: 132px;
}

.av-site-header.is-scrolled .custom-logo {
  max-height: 66px;
}

.av-site-header:not(.is-scrolled) .av-nav-cta > a {
  color: var(--av-white) !important;
  background: var(--av-forest) !important;
  border-color: var(--av-forest);
}

.av-home .hero h1,
.av-home .dark h1,
.av-home .dark h2,
.av-home .dark h3,
.av-home .cta h1,
.av-home .cta h2,
.av-home .cta h3 {
  color: var(--av-white);
}

/*
 * theme.json asigna un color explícito a los encabezados. En páginas internas
 * debe prevalecer el contraste definido por el prototipo para héroes, bloques
 * oscuros y CTA.
 */
.wp-site-blocks .internal-hero h1,
.wp-site-blocks .dark h1,
.wp-site-blocks .dark h2,
.wp-site-blocks .dark h3,
.wp-site-blocks .cta h1,
.wp-site-blocks .cta h2,
.wp-site-blocks .cta h3,
.wp-site-blocks .network-box h1,
.wp-site-blocks .network-box h2,
.wp-site-blocks .network-box h3,
.wp-site-blocks .dark-card h1,
.wp-site-blocks .dark-card h2,
.wp-site-blocks .dark-card h3 {
  color: var(--av-white);
}

/* Integración de Contact Form 7 con la maqueta del prototipo. */
.contact-layout > .wpcf7 {
  min-width: 0;
}

.contact-layout > .av-form-slot {
  min-width: 0;
  margin: 0;
}

.wpcf7 .wpcf7-form-control-wrap {
  display: block;
}

.wpcf7 form.form-card .form-field > p {
  display: contents;
}

.wpcf7 form.form-card textarea {
  height: 130px;
}

.wpcf7 form.form-card .wpcf7-submit {
  width: 100%;
  cursor: pointer;
}

.wpcf7 form.form-card .form-field:has(.wpcf7-submit) {
  position: relative;
}

.wpcf7 form.form-card .wpcf7-spinner {
  position: absolute;
  top: 50%;
  right: 1rem;
  margin: 0;
  transform: translateY(-50%);
}

.wpcf7 form.form-card .wpcf7-acceptance label {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0;
  font-weight: 600;
  line-height: 1.45;
}

.wpcf7 form.form-card .wpcf7-acceptance input {
  width: auto;
  margin-top: 0.22rem;
}

.wpcf7 form.form-card .wpcf7-not-valid-tip {
  margin-top: 0.4rem;
  font-size: 0.82rem;
}

.wpcf7 form.form-card .wpcf7-response-output {
  margin: 1rem 0 0;
  border-radius: 13px;
}

.av-footer .custom-logo {
  width: 190px;
  max-width: 190px;
  max-height: none;
}

@media (max-width: 680px) {
  .av-site-header .custom-logo {
    max-height: 104px;
  }

  .av-site-header.is-scrolled .custom-logo {
    max-height: 56px;
  }
}

.av-reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.av-reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 1000px) {
  .av-footer-grid {
    grid-template-columns: minmax(240px, 1.2fr) repeat(2, minmax(150px, 0.8fr));
  }

  .av-footer-brand {
    grid-column: 1 / -1;
  }

  .av-header-inner {
    min-height: 78px;
  }

  .av-site-header .custom-logo {
    max-width: 172px;
    max-height: 62px;
  }

  .av-site-header.is-scrolled .custom-logo {
    max-width: 118px;
    max-height: 50px;
  }

  .av-site-header .wp-block-navigation__responsive-container.is-menu-open {
    color: var(--av-forest);
    background: var(--av-ivory);
    padding: 2rem;
  }

  .av-site-header .wp-block-navigation__responsive-container.is-menu-open .av-nav-cta > a {
    color: var(--av-white) !important;
    background: var(--av-forest) !important;
  }
}

@media (max-width: 782px) {
  .admin-bar .av-site-header {
    top: 46px;
  }
}

@media (max-width: 680px) {
  .av-page-main {
    padding-top: 104px;
  }

  .av-header-inner {
    min-height: 70px;
  }

  .av-back-to-top {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
  }

  .av-cta {
    min-height: 460px;
  }

  .av-footer-grid {
    grid-template-columns: 1fr;
    gap: 2.25rem;
  }

  .av-footer-brand {
    grid-column: auto;
  }

  .av-footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .cmplz-cookiebanner {
    right: max(0.75rem, env(safe-area-inset-right)) !important;
    bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    left: max(0.75rem, env(safe-area-inset-left)) !important;
    width: auto !important;
    max-width: none !important;
  }

  .cmplz-manage-consent {
    right: max(0.75rem, env(safe-area-inset-right)) !important;
    bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* Ajustes 0.9.1: páginas legales y fotografía de equipo. */
body.privacy-policy .av-site-header:not(.is-scrolled),
body.page-id-23 .av-site-header:not(.is-scrolled),
body.page-id-27 .av-site-header:not(.is-scrolled) {
  background: var(--av-forest);
}

body.privacy-policy main > .wp-block-post-content,
body.page-id-23 main > .wp-block-post-content,
body.page-id-27 main > .wp-block-post-content {
  padding-top: clamp(3rem, 6vw, 5.5rem);
}

.team-extra-image {
  width: min(100%, 720px);
  margin: clamp(2rem, 4vw, 3.5rem) auto 0;
}

.team-extra-image img {
  display: block;
  width: 100%;
  height: auto !important;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center center;
  border-radius: var(--av-radius);
}


/* Floating controls: WhatsApp below, back-to-top above */
.av-back-to-top { bottom: 96px; }
@media (max-width: 600px) {
  .av-back-to-top { bottom: 90px; right: 23px; }
}


/* Ajuste aviso legal (página 94). */
body.page-id-94 .av-site-header:not(.is-scrolled) { background: var(--av-forest); }
body.page-id-94 main > .wp-block-post-content { padding-top: clamp(3rem, 6vw, 5.5rem); }


/* Ajuste preferencias de privacidad: esquina inferior izquierda. */
.cmplz-manage-consent { left: max(1rem, env(safe-area-inset-left)) !important; right: auto !important; bottom: max(1rem, env(safe-area-inset-bottom)) !important; }


/* Ajustes 0.9.5: controles flotantes y encuadres. */
.joinchat {
  --s: 48px;
  right: 14px;
}

.team-extra-image {
  width: min(100%, 980px);
}

.team-extra-image img {
  aspect-ratio: 16 / 9;
  object-position: center 72%;
}

body.page-id-64 .internal-hero {
  min-height: clamp(34rem, 50vw, 40rem);
  background-position: center, center 55%;
}

@media (max-width: 680px) {
  .joinchat {
    --s: 44px;
    right: 14px;
  }

  .team-extra-image img {
    aspect-ratio: 3 / 4;
    object-position: center 72%;
  }

  body.page-id-64 .internal-hero {
    min-height: 460px;
    background-position: center, center 50%;
  }
}


/* Ajuste 0.9.6: igualar WhatsApp con volver arriba. */
.joinchat {
  --s: 48px !important;
  right: 14px !important;
}

@media (max-width: 680px) {
  .joinchat {
    --s: 44px !important;
    right: 14px !important;
  }
}
