/* ==========================================================================
   main.css — Sistema de diseño del sitio de pacas de heno (Costa Rica)
   Mobile-first · Sin frameworks · Paleta y tipografías según la propuesta
   aprobada (docs/propuesta-arquitectura.md §3 y §4).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fuentes self-hosted (woff2 variable, latin subset).
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Bitter";
  src: url("/fonts/bitter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/fonts/source-sans-3-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   2. Tokens (custom properties)
   -------------------------------------------------------------------------- */
:root {
  /* Paleta exacta de la propuesta §3 */
  --color-bg: #FAF7F0;        /* blanco hueso, fondo */
  --color-surface: #F0E6CF;   /* beige paja, tarjetas/bloques */
  --color-primary: #2E5339;   /* verde oscuro, header/footer/botones */
  --color-accent: #D9A441;    /* amarillo dorado heno, CTAs/acentos */
  --color-olive: #7A8B3F;     /* verde oliva, detalles/iconos */
  --color-earth: #6B4F2E;     /* marrón tierra, titulares secundarios */
  --color-text: #2B2620;      /* texto principal */
  --color-whatsapp: #0E6E3B;  /* WhatsApp accesible con icono blanco */

  /* Derivados de la paleta (mismos tonos, usos puntuales) */
  --color-primary-dark: #234029;   /* hover de botones verdes */
  --color-accent-dark: #9A6E1F;    /* texto/iconos dorados con contraste AA sobre fondos claros */
  --color-border: #DCCFB2;         /* bordes suaves acordes al beige */
  --color-white: #FFFFFF;

  /* Tipografía */
  --font-headings: "Bitter", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Escala tipográfica fluida */
  --fs-small: 0.875rem;
  --fs-body: 1rem;
  --fs-lead: 1.125rem;
  --fs-h3: 1.25rem;
  --fs-h2: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  --fs-h1: clamp(1.875rem, 1.4rem + 2.4vw, 2.75rem);

  /* Espaciado */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;

  /* Radios */
  --radius-s: 0.375rem;
  --radius-m: 0.75rem;
  --radius-l: 1.25rem;
  --radius-full: 999px;

  /* Sombras suaves */
  --shadow-s: 0 1px 3px rgba(43, 38, 32, 0.12);
  --shadow-m: 0 4px 12px rgba(43, 38, 32, 0.14);
  --shadow-l: 0 8px 28px rgba(43, 38, 32, 0.18);

  /* Layout */
  --container-max: 72rem;
  --header-height: 4.25rem;
}

/* --------------------------------------------------------------------------
   3. Reset / base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-headings);
  line-height: 1.2;
  color: var(--color-primary);
  margin: 0 0 var(--space-m);
}

h1 { font-size: var(--fs-h1); font-weight: 700; }
h2 { font-size: var(--fs-h2); font-weight: 700; }
h3 { font-size: var(--fs-h3); font-weight: 600; color: var(--color-earth); }

p {
  margin: 0 0 var(--space-m);
  max-width: 65ch;
}

ul,
ol {
  margin: 0 0 var(--space-m);
  padding-left: var(--space-l);
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

/* Foco visible en todo lo interactivo */
:focus-visible {
  outline: 3px solid var(--color-white);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--color-primary-dark);
  border-radius: var(--radius-s);
}

/* Enlace "saltar al contenido" */
.skip-link {
  position: absolute;
  left: var(--space-m);
  top: -100%;
  z-index: 300;
  padding: var(--space-s) var(--space-m);
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: var(--radius-s);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: var(--space-m);
  color: var(--color-white);
}

/* --------------------------------------------------------------------------
   4. Utilidades de layout
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-m);
}

.section {
  padding-block: var(--space-2xl);
}

.section--surface {
  background-color: var(--color-surface);
}

.section__title {
  text-align: center;
  margin-bottom: var(--space-xs);
}

.section__intro {
  text-align: center;
  margin-inline: auto;
  margin-bottom: var(--space-xl);
  font-size: var(--fs-lead);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }

/* --------------------------------------------------------------------------
   5. Header sticky + navegación
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background-color: var(--color-primary);
  color: var(--color-white);
  box-shadow: var(--shadow-s);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: var(--header-height);
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-s);
  flex: 0 0 auto;
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-white);
  text-decoration: none;
  line-height: 1.2;
  padding-block: var(--space-xs);
}

.site-logo::before {
  content: "";
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 2.75rem;
  background: url("/images/logo-rdiaz.svg") center / contain no-repeat;
}

.site-logo:hover {
  color: var(--color-surface);
}

.site-header--compact .container {
  gap: var(--space-xs);
}

.site-header--compact .site-logo {
  font-size: 1rem;
}

.site-header--compact .lang-switcher {
  flex: 0 0 auto;
  padding: 0;
}

/* Botón hamburguesa (visible solo en móvil) */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-xs);
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-s);
  color: var(--color-white);
  cursor: pointer;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-toggle__icon {
  width: 24px;
  height: 24px;
}

/* Navegación principal: panel desplegable en móvil */
.site-nav {
  position: absolute;
  inset: var(--header-height) 0 auto 0;
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background-color: var(--color-primary);
  box-shadow: var(--shadow-m);
  display: none;
}

.site-nav[data-open="true"] {
  display: block;
}

.site-nav__list {
  list-style: none;
  margin: 0;
  padding: var(--space-s) var(--space-m) var(--space-m);
  display: flex;
  flex-direction: column;
}

.site-nav__link {
  display: block;
  padding: var(--space-s) var(--space-m);
  min-height: 44px;
  color: var(--color-white);
  text-decoration: none;
  border-radius: var(--radius-s);
}

.site-nav__link:hover,
.site-nav__link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.14);
  color: var(--color-surface);
}

/* Selector de idioma */
.lang-switcher {
  display: flex;
  gap: var(--space-2xs);
  padding: var(--space-s) var(--space-m) var(--space-m);
}

.lang-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-xs) var(--space-s);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-s);
  color: var(--color-white);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-small);
}

.lang-switcher a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--color-surface);
}

.lang-switcher a[aria-current="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}

@media (min-width: 64rem) {
  .nav-toggle {
    display: none;
  }

  .site-nav,
  .site-nav[data-open] {
    position: static;
    display: flex;
    align-items: center;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }

  .site-nav__list {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 0;
  }

  .site-nav__link {
    padding: var(--space-xs) var(--space-s);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    font-size: var(--fs-small);
  }

  .lang-switcher {
    padding: 0 0 0 var(--space-s);
  }
}

/* --------------------------------------------------------------------------
   6. Botones (targets táctiles ≥ 44px)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: var(--space-s) var(--space-l);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-body);
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, transform 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
  color: var(--color-white);
}

/* Texto oscuro sobre dorado: contraste AA */
.btn-accent {
  background-color: var(--color-accent);
  color: var(--color-text);
}

.btn-accent:hover {
  background-color: #C48F2F;
  color: var(--color-text);
}

/* Verde WhatsApp oscurecido para contraste AA con texto blanco */
.btn-whatsapp {
  background-color: var(--color-whatsapp);
  color: var(--color-white);
}

.btn-whatsapp:hover {
  background-color: #07552D;
  color: var(--color-white);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn__icon {
  width: 20px;
  height: 20px;
  flex: none;
}

/* Botón flotante de WhatsApp */
.wa-float {
  position: fixed;
  right: var(--space-m);
  bottom: var(--space-m);
  z-index: 250;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background-color: var(--color-whatsapp);
  color: var(--color-white);
  box-shadow: var(--shadow-m);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wa-float:hover {
  transform: scale(1.06);
  box-shadow: var(--shadow-l);
  color: var(--color-white);
}

.wa-float__icon {
  width: 30px;
  height: 30px;
}

/* --------------------------------------------------------------------------
   7. Hero
   -------------------------------------------------------------------------- */
.hero {
  background-color: var(--color-surface);
  padding-block: var(--space-2xl);
}

.hero .container {
  display: grid;
  gap: var(--space-xl);
  align-items: center;
}

.hero__title {
  margin-bottom: var(--space-s);
}

.hero__lead {
  font-size: var(--fs-lead);
  margin-bottom: var(--space-l);
}

.hero__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
}

.hero__media img {
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-m);
  width: 100%;
  object-fit: cover;
}

@media (min-width: 56rem) {
  .hero .container {
    grid-template-columns: 1.1fr 1fr;
  }

  .hero {
    padding-block: var(--space-3xl);
  }
}

/* --------------------------------------------------------------------------
   8. Tarjetas de confianza
   -------------------------------------------------------------------------- */
.trust-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-m);
}

.trust-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  padding: var(--space-l);
  box-shadow: var(--shadow-s);
}

.trust-card__icon {
  width: 40px;
  height: 40px;
  color: var(--color-olive);
  margin-bottom: var(--space-s);
}

.trust-card h3 {
  margin-bottom: var(--space-2xs);
}

.trust-card p {
  margin-bottom: 0;
  font-size: var(--fs-small);
}

@media (min-width: 40rem) {
  .trust-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 64rem) {
  .trust-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --------------------------------------------------------------------------
   9. Segmentación por tipo de cliente
   -------------------------------------------------------------------------- */
.segments {
  display: grid;
  gap: var(--space-l);
}

.segment {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-l);
  padding: var(--space-xl);
  box-shadow: var(--shadow-s);
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

.segment h3 {
  font-size: var(--fs-h3);
}

.segment p {
  flex: 1;
}

.segment .btn {
  align-self: flex-start;
}

@media (min-width: 56rem) {
  .segments {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --------------------------------------------------------------------------
   10. Pasos numerados (proceso de confección)
   -------------------------------------------------------------------------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-l);
  counter-reset: paso;
}

.step {
  position: relative;
  padding-left: 3.5rem;
  counter-increment: paso;
}

.step::before {
  content: counter(paso);
  position: absolute;
  left: 0;
  top: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-white);
  font-family: var(--font-headings);
  font-weight: 700;
  font-size: 1.125rem;
}

.step h3 {
  margin-bottom: var(--space-2xs);
}

.step p {
  margin-bottom: 0;
}

@media (min-width: 56rem) {
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }

  .step {
    padding-left: 0;
    padding-top: 3.5rem;
  }
}

/* --------------------------------------------------------------------------
   11. Tabla responsive
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  background: var(--color-white);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.table caption {
  text-align: left;
  padding: var(--space-s) var(--space-m);
  font-weight: 600;
  color: var(--color-earth);
}

.table th,
.table td {
  padding: var(--space-s) var(--space-m);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  min-width: 8rem;
}

.table thead th {
  background: var(--color-primary);
  color: var(--color-white);
  font-weight: 600;
}

.table tbody tr:nth-child(even) {
  background: var(--color-bg);
}

/* --------------------------------------------------------------------------
   12. Galería + lightbox
   -------------------------------------------------------------------------- */
.gallery-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 56rem) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.gallery-grid button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--color-white);
  cursor: pointer;
  box-shadow: var(--shadow-s);
}

.gallery-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: rgba(43, 38, 32, 0.88);
}

.lightbox[data-open="true"] {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-l);
}

.lightbox__close {
  position: absolute;
  top: var(--space-m);
  right: var(--space-m);
  min-width: 44px;
  min-height: 44px;
  border: 2px solid var(--color-white);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-white);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* --------------------------------------------------------------------------
   13. Acordeón FAQ
   -------------------------------------------------------------------------- */
.faq {
  max-width: 52rem;
  margin-inline: auto;
}

.faq__item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  background: var(--color-white);
  margin-bottom: var(--space-s);
  overflow: hidden;
}

.faq__question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  width: 100%;
  min-height: 44px;
  padding: var(--space-m);
  background: transparent;
  border: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--color-primary);
  text-align: left;
  cursor: pointer;
}

.faq__question:hover {
  background: var(--color-bg);
}

.faq__question::after {
  content: "";
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.faq__question[aria-expanded="true"]::after {
  transform: rotate(-135deg);
}

.faq__answer {
  padding: 0 var(--space-m) var(--space-m);
}

.faq__answer[hidden] {
  display: none;
}

.faq__answer p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   14. Breadcrumbs
   -------------------------------------------------------------------------- */
.breadcrumbs {
  padding-block: var(--space-s);
  font-size: var(--fs-small);
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-xs);
  color: var(--color-earth);
}

.breadcrumbs a {
  color: var(--color-primary);
}

.breadcrumbs [aria-current="page"] {
  color: var(--color-earth);
}

/* --------------------------------------------------------------------------
   15. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--color-primary);
  color: var(--color-white);
  padding-block: var(--space-2xl) var(--space-xl);
  margin-top: var(--space-3xl);
}

.site-footer .container {
  display: grid;
  gap: var(--space-xl);
}

.site-footer h2,
.site-footer h3 {
  color: var(--color-accent);
  font-size: var(--fs-h3);
}

.site-footer a {
  color: var(--color-white);
}

.site-footer a:hover {
  color: var(--color-surface);
}

.footer-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-xs);
}

.footer-nav a {
  display: inline-flex;
  align-items: center;
  padding-block: var(--space-2xs);
  min-height: 44px;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.footer-contact p {
  margin-bottom: var(--space-s);
}

.footer-map {
  grid-column: 1 / -1;
}

.footer-map__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-s);
  margin-bottom: var(--space-s);
}

.footer-map__header h2 {
  margin-bottom: 0;
}

.footer-map__frame {
  height: clamp(16rem, 42vw, 22rem);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-m);
  background: var(--color-surface);
  box-shadow: var(--shadow-m);
}

.footer-map__frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  padding-top: var(--space-m);
  font-size: var(--fs-small);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
}

.footer-bottom p {
  margin: 0;
}

@media (min-width: 56rem) {
  .site-footer .container {
    grid-template-columns: 1.2fr 1fr 1fr;
  }

  .footer-bottom {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------------------------
   16. Página 404
   -------------------------------------------------------------------------- */
.error-page {
  text-align: center;
  padding-block: var(--space-3xl);
}

.error-page__code {
  font-family: var(--font-headings);
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 700;
  color: var(--color-accent-dark);
  margin: 0 0 var(--space-s);
  line-height: 1;
}

.error-page .btn {
  margin: var(--space-xs);
}

/* --------------------------------------------------------------------------
   17. Movimiento reducido
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
