/* ==========================================================================
   Grano & Calma — estilos del sitio público
   Mobile first: los estilos base son para 360px y se amplían con min-width.
   ========================================================================== */

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Paleta */
  --color-bg: #FAF8F5;
  --color-secondary: #E8E4DE;
  --color-text: #4A3B32;
  --color-muted: #6B5A4E;          /* texto secundario (contraste AA sobre el fondo) */
  --color-accent: #C27C5A;         /* detalles, bordes, íconos */
  --color-accent-strong: #A35E3E;  /* botones y texto en acento (contraste AA con blanco) */
  --color-accent-hover: #8C4F33;
  --color-line: #DDD6CD;
  --color-white: #FFFFFF;

  /* Tipografía */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Espaciado y medidas */
  --space-section: clamp(4.5rem, 10vw, 8rem);
  --gutter: 1.25rem;
  --max-width: 72rem;
  --radius: 4px;
  --header-h: 4rem;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ─── Reset mínimo ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 96;
}

p { margin: 0 0 1em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* ─── Accesibilidad ─────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius);
  text-decoration: none;
  transition: top .2s;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 2px solid var(--color-accent-strong);
  outline-offset: 3px;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--space-section); }
.section-alt { background: var(--color-secondary); }

.section-header { max-width: 36rem; margin-bottom: 2.5rem; }
.section-header h2,
.about-text h2,
.contact-info h2 { font-size: clamp(2rem, 6vw, 3rem); }

.eyebrow {
  margin-bottom: .9rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--color-accent-strong);
}
/* Sobre el fondo beige, el acento necesita un tono más oscuro para llegar
   al contraste AA (#A35E3E da 3,9:1 ahí; #8C4F33 da 5:1). */
.section-alt .eyebrow { color: var(--color-accent-hover); }

/* ─── Botones ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 3rem;
  padding: .75rem 1.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  letter-spacing: .02em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}

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

.btn-secundario { border-color: var(--color-line); color: var(--color-text); }
.btn-secundario:hover { border-color: var(--color-accent); }

/* ─── Navegación ────────────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  background: rgba(250, 248, 245, .92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.site-header.is-scrolled { border-bottom-color: var(--color-line); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-amp { color: var(--color-accent); font-style: italic; }

/* Botón hamburguesa */
.nav-toggle {
  position: relative;
  width: 2.75rem; height: 2.75rem;
  margin-right: -.6rem;
  border: 0;
  background: none;
  cursor: pointer;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  position: absolute;
  left: 50%;
  width: 1.4rem; height: 1.5px;
  margin-left: -.7rem;
  background: currentColor;
  transition: transform .3s var(--ease), opacity .2s;
}
.nav-toggle-bar { top: 50%; }
.nav-toggle-bar::before, .nav-toggle-bar::after { content: ''; left: 0; margin: 0; }
.nav-toggle-bar::before { transform: translateY(-6px); }
.nav-toggle-bar::after { transform: translateY(6px); }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar::before { transform: rotate(45deg); background: var(--color-text); }
.nav-toggle[aria-expanded='true'] .nav-toggle-bar::after { transform: rotate(-45deg); background: var(--color-text); }

/* Menú mobile: panel desplegable bajo la barra */
.nav-menu {
  position: absolute;
  top: var(--header-h);
  left: 0; right: 0;
  margin: 0;
  padding: .5rem var(--gutter) 1.5rem;
  list-style: none;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-line);
  /* oculto por defecto */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-.5rem);
  transition: opacity .25s var(--ease), transform .25s var(--ease), visibility 0s .25s;
}
.nav-menu.is-open {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.nav-menu a {
  display: block;
  padding: .85rem 0;
  border-bottom: 1px solid var(--color-secondary);
  font-size: 1.05rem;
  text-decoration: none;
}
.nav-menu li:last-child a { border-bottom: 0; }

/* Sin JS el menú queda siempre visible (no se puede abrir el toggle) */
html:not(.js) .nav-toggle { display: none; }
html:not(.js) .nav-menu { position: static; visibility: visible; opacity: 1; transform: none; }

/* ─── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  gap: 2.5rem;
  padding-top: calc(var(--header-h) + 3rem);
  padding-bottom: var(--space-section);
}

.hero h1 {
  max-width: 14ch;
  margin-bottom: 1.25rem;
  font-size: clamp(2.6rem, 11vw, 5rem);
  font-weight: 300;
}
.hero-lead {
  max-width: 34ch;
  margin-bottom: 2rem;
  font-size: 1.1rem;
  color: var(--color-muted);
}

.hero-media { margin: 0; }
.hero-media img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Entrada inicial del hero (sutil) */
.js .hero-text > *,
.js .hero-media {
  animation: rise .9s var(--ease) both;
}
.js .hero-text > :nth-child(2) { animation-delay: .08s; }
.js .hero-text > :nth-child(3) { animation-delay: .16s; }
.js .hero-text > :nth-child(4) { animation-delay: .24s; }
.js .hero-media { animation-delay: .2s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ─── Nosotros ──────────────────────────────────────────────────────────── */
.about { display: grid; gap: 2.5rem; align-items: center; }
.about-media { margin: 0; }
.about-media img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
}
.about-text h2 { margin-bottom: 1.5rem; }
.about-text p { max-width: 38rem; }

.about-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 2.25rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--color-line);
}
.about-facts dt {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  line-height: 1.1;
  color: var(--color-accent-strong);
}
.about-facts dd {
  margin: .35rem 0 0;
  font-size: .85rem;
  line-height: 1.4;
  color: var(--color-muted);
}

/* ─── Galería ───────────────────────────────────────────────────────────── */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.gallery li { overflow: hidden; border-radius: var(--radius); }
.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  transition: transform .8s var(--ease);
}
.gallery li:hover img { transform: scale(1.03); }

/* ─── Contacto ──────────────────────────────────────────────────────────── */
.contact { display: grid; gap: 2.5rem; }
.contact-info h2 { margin-bottom: 2rem; }

.contact-list { display: grid; gap: 1.5rem; margin: 0; }
.contact-list dt {
  margin-bottom: .3rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.contact-list dd { margin: 0; }
.contact-list a { text-decoration-color: var(--color-accent); text-underline-offset: 3px; }
.contact-list a:hover { color: var(--color-accent-strong); }

.map-placeholder {
  position: relative;
  min-height: 18rem;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
}
.map-placeholder svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.map-pin {
  position: absolute;
  left: 60%; top: 37%;
  width: 1.1rem; height: 1.1rem;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 .5rem rgba(194, 124, 90, .18);
  transform: translate(-50%, -50%);
}
.map-label {
  position: absolute;
  left: 60%; top: 37%;
  margin: 1.1rem 0 0 1rem;
  padding: .3rem .65rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  background: var(--color-white);
  font-size: .85rem;
  white-space: nowrap;
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  padding-block: 3rem;
  border-top: 1px solid var(--color-line);
}
.footer-inner {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  text-align: center;
}

.social { display: flex; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.social a {
  display: grid;
  place-items: center;
  width: 2.75rem; height: 2.75rem;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  transition: border-color .2s, color .2s;
}
.social a:hover { border-color: var(--color-accent); color: var(--color-accent-strong); }
.social svg {
  width: 1.15rem; height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.footer-copy { margin: 0; font-size: .85rem; color: var(--color-muted); }

/* ─── Página 404 ────────────────────────────────────────────────────────── */
.no-encontrada {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 100vh;
  padding-block: 3rem;
}
.no-encontrada .brand { margin-bottom: 3rem; }
.no-encontrada h1 {
  max-width: 16ch;
  margin-bottom: 1rem;
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 300;
}
.no-encontrada-acciones { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ─── Fade-in al hacer scroll ───────────────────────────────────────────── */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* Respeta la preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ─── Breakpoints ───────────────────────────────────────────────────────── */

/* ≥ 600px: tablets chicas */
@media (min-width: 37.5em) {
  :root { --gutter: 2rem; }

  .gallery { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}

/* ≥ 900px: escritorio */
@media (min-width: 56.25em) {
  :root { --header-h: 4.75rem; }

  /* La navegación pasa a ser horizontal */
  .nav-toggle { display: none; }
  .nav-menu,
  html:not(.js) .nav-menu {
    position: static;
    display: flex;
    gap: 2.25rem;
    padding: 0;
    background: none;
    border: 0;
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: none;
  }
  .nav-menu a {
    position: relative;
    padding: .4rem 0;
    border: 0;
    font-size: .95rem;
  }
  .nav-menu a::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 1px;
    background: var(--color-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .3s var(--ease);
  }
  .nav-menu a:hover::after,
  .nav-menu a[aria-current='true']::after { transform: scaleX(1); }

  .hero {
    grid-template-columns: 1.1fr .9fr;
    align-items: center;
    gap: 4rem;
    min-height: min(100vh, 52rem);
    padding-top: calc(var(--header-h) + 2rem);
    padding-bottom: 4rem;
  }
  .hero-media img { aspect-ratio: 4 / 5; }

  .about { grid-template-columns: .85fr 1fr; gap: 5rem; }

  .contact { grid-template-columns: .8fr 1fr; gap: 5rem; align-items: center; }
  .map-placeholder { min-height: 24rem; }

  .footer-inner {
    grid-template-columns: 1fr auto 1fr;
    justify-items: stretch;
    text-align: left;
  }
  .footer-copy { text-align: right; }
}
