/* ============================================
   base.css — body, grain, cursor custom,
   scroll airplane, numeración editorial,
   notas Caveat, círculo/subrayado dibujado.
   ============================================ */

html {
  scroll-behavior: auto; /* Lenis gestiona el scroll */
}

body {
  font-family: var(--ff-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-blue);
  background: var(--c-cream);
  position: relative;
  overflow-x: hidden;
  font-variation-settings: "wght" 400;
}

/* Lenis */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-scrolling iframe { pointer-events: none; }

/* ------- Grano global (overlay sutil) ------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  background-image: url("../assets/svg/grain.svg");
  background-size: 220px 220px;
  opacity: 0.06;
  mix-blend-mode: multiply;
}

/* Pequeño viñeteo crema en bordes (anti-IA: textura, no plano) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9001;
  background: radial-gradient(120% 80% at 50% 50%,
              transparent 55%,
              rgba(14, 42, 71, 0.05) 100%);
}

/* ------- Tipografía base ------- */
h1, h2, h3, h4 {
  font-family: var(--ff-display);
  font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-tight);
  color: var(--c-blue);
}

p { color: var(--c-ink); }
p + p { margin-top: 1em; }

/* Numeración editorial sobre cada sección */
.section-num {
  display: inline-block;
  font-family: var(--ff-display);
  font-style: italic;
  font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 500;
  font-size: var(--fs-sm);
  color: var(--c-mustard);
  letter-spacing: var(--tr-snug);
  margin-bottom: var(--sp-3);
}
.section-num::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--c-mustard);
  vertical-align: middle;
  margin-left: 10px;
  transform: translateY(-3px);
}

/* Notas manuscritas Caveat dispersas */
.note-hand {
  font-family: var(--ff-hand);
  font-weight: 500;
  color: var(--c-terracotta);
  font-size: clamp(1.15rem, 0.9rem + 0.6vw, 1.45rem);
  line-height: 1.1;
  display: inline-block;
  transform: rotate(-4deg);
}
.note-hand--blue   { color: var(--c-blue); }
.note-hand--sage   { color: var(--c-sage); }
.note-hand--mustard{ color: var(--c-mustard); }

/* Palabra con círculo dibujado a mano */
.circle-word {
  position: relative;
  display: inline-block;
  padding: 0 0.35em;
}
.circle-word::before {
  content: "";
  position: absolute;
  inset: -8% -8% -10% -8%;
  background: url("../assets/svg/handdrawn-circle.svg") center/100% 100% no-repeat;
  pointer-events: none;
}

/* Subrayado dibujado a mano (mostaza por defecto) */
.handline {
  position: relative;
  display: inline-block;
}
.handline::after {
  content: "";
  position: absolute;
  left: -0.04em;
  right: -0.04em;
  bottom: -0.28em;
  height: 0.22em;
  background: url("../assets/svg/handdrawn-underline.svg") center/100% 100% no-repeat;
  pointer-events: none;
}

/* Separador ondulado entre secciones (SVG) */
.wave-sep {
  display: block;
  width: 100%;
  height: 32px;
  background: url("../assets/svg/wave-separator.svg") center/100% 100% no-repeat;
  margin: var(--sp-7) 0;
  opacity: 0.6;
}

/* ------- Container general ------- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 48px);
}
.container--narrow { max-width: var(--max-w-narrow); }
.container--text   { max-width: var(--max-w-text); }

/* ------- Cursor custom (desktop) ------- */
@media (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  body { cursor: none; }
  a, button, input, textarea, select, [role="button"], .clickable { cursor: none; }

  .cursor-dot {
    position: fixed;
    top: 0; left: 0;
    width: 20px; height: 20px;
    border: 1.5px solid var(--c-blue);
    border-radius: 50%;
    background: transparent;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    transition: width 0.25s var(--ease-out),
                height 0.25s var(--ease-out),
                background 0.25s var(--ease-out),
                border-color 0.25s var(--ease-out),
                mix-blend-mode 0.25s var(--ease-out);
    will-change: transform;
  }
  .cursor-dot.is-hover {
    width: 60px; height: 60px;
    background: var(--c-terracotta);
    opacity: 0.55;
    border-color: var(--c-terracotta);
    mix-blend-mode: multiply;
  }
  .cursor-dot.is-down {
    width: 14px; height: 14px;
    background: var(--c-blue);
  }
}
@media (hover: none), (pointer: coarse), (max-width: 1023.98px) {
  .cursor-dot { display: none; }
}

/* ------- Header sticky ------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 800;
  background: var(--c-cream-85);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-bottom: 1px solid var(--c-blue-12);
}
.site-header__inner {
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: var(--sp-5);
}

/* Logo */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand__mark {
  height: 42px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
}
/* Si en algún momento se vuelve a usar el lockup tipográfico al lado */
.brand__name {
  font-family: var(--ff-display);
  font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 700;
  font-size: 1.05rem;
  color: var(--c-blue);
  letter-spacing: var(--tr-tight);
  line-height: 1;
}
.brand__name em {
  font-style: italic;
  font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 500;
  color: var(--c-terracotta);
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
}
.nav__link {
  font-size: var(--fs-sm);
  color: var(--c-blue);
  position: relative;
  padding: 6px 2px;
  font-weight: 500;
  transition: color var(--dur) var(--ease-out);
}
.nav__link::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 2px;
  height: 1.5px;
  background: var(--c-terracotta);
  transition: right var(--dur) var(--ease-out);
}
.nav__link:hover { color: var(--c-terracotta); }
.nav__link:hover::after { right: 0; }

/* Hamburger button — solo móvil */
.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  background: var(--c-cream);
  border: 1.5px solid var(--c-blue);
  box-shadow: 3px 3px 0 var(--c-blue);
  margin-right: 8px;
  position: relative;
  flex: none;
}
.nav-toggle span {
  position: absolute;
  left: 11px; right: 11px;
  height: 2px;
  background: var(--c-blue);
  transition: transform var(--dur) var(--ease-out),
              opacity var(--dur) var(--ease-out),
              top var(--dur) var(--ease-out);
}
.nav-toggle span:nth-child(1) { top: 14px; }
.nav-toggle span:nth-child(2) { top: 21px; }
.nav-toggle span:nth-child(3) { top: 28px; }
.nav-toggle.is-open span:nth-child(1) { top: 21px; transform: rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { top: 21px; transform: rotate(-45deg); }

@media (max-width: 880px) {
  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--c-cream);
    flex-direction: column;
    align-items: stretch;
    padding: 24px clamp(20px, 4vw, 48px) 32px;
    gap: 0;
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: transform var(--dur) var(--ease-out),
                opacity var(--dur) var(--ease-out),
                visibility 0s linear var(--dur);
    border-bottom: 1.5px solid var(--c-blue);
    box-shadow: 0 14px 24px rgba(14, 42, 71, 0.08);
    z-index: 798;
  }
  .nav.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform var(--dur) var(--ease-out),
                opacity var(--dur) var(--ease-out),
                visibility 0s;
  }
  .nav__link {
    font-family: var(--ff-display);
    font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 600;
    font-size: 1.4rem;
    padding: 14px 0;
    border-bottom: 1px dashed var(--c-blue-30);
  }
  .nav__link:last-of-type { border-bottom: none; }
  .nav__link::after { display: none; }
  .nav__link:hover { color: var(--c-terracotta); padding-left: 8px; }

  .nav-toggle { display: inline-block; order: -1; }
  .site-header__inner { grid-template-columns: auto auto 1fr auto auto; }
  .brand { grid-column: 2; }
  .lang-switch { grid-column: 4; }
  .btn-cotizar-header { grid-column: 5; }
}
@media (min-width: 881px) {
  .nav-toggle { display: none; }
}

/* Switch idioma ES/EN */
.lang-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1.4px solid var(--c-blue);
  background: var(--c-cream);
  box-shadow: 3px 3px 0 var(--c-blue);
  margin-right: 8px;
  position: relative;
  overflow: hidden;
}
.lang-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-family: var(--ff-display);
  font-variation-settings: "opsz" 120, "SOFT" 100, "wght" 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--c-blue);
  background: transparent;
  transition: background var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out);
  cursor: pointer;
  border: 0;
  position: relative;
}
.lang-switch__btn + .lang-switch__btn {
  border-left: 1px dashed var(--c-blue-30);
}
.lang-switch__btn:hover {
  background: var(--c-bone);
}
.lang-switch__btn.is-active {
  background: var(--c-terracotta);
  color: var(--c-cream);
}
.lang-switch__btn.is-active::after {
  content: "";
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px; height: 1.5px;
  background: var(--c-mustard);
}
@media (max-width: 480px) {
  .lang-switch { box-shadow: 2px 2px 0 var(--c-blue); margin-right: 4px; }
  .lang-switch__btn { width: 26px; height: 28px; font-size: 0.7rem; }
}

/* CTA header (terracotta + sombra dura azul) */
.btn-cotizar-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--c-terracotta);
  color: var(--c-cream);
  font-family: var(--ff-body);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
  box-shadow: 3px 3px 0 var(--c-blue);
  transition: transform var(--dur) var(--ease-out),
              box-shadow var(--dur) var(--ease-out);
  border: 1.5px solid var(--c-blue);
}
.btn-cotizar-header:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--c-blue);
}
.btn-cotizar-header:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--c-blue);
}

/* ------- Scroll plane (avioncito sobre línea punteada en header) ------- */
.scrollplane {
  grid-column: 1 / -1;
  position: absolute;
  left: 0; right: 0;
  bottom: -1px;
  height: 14px;
  pointer-events: none;
}
.scrollplane__rail {
  position: absolute;
  left: 6%; right: 6%;
  top: 50%;
  border-top: 1.2px dashed var(--c-blue-30);
  transform: translateY(-50%);
}
.scrollplane__plane {
  position: absolute;
  top: 50%;
  width: 22px; height: 22px;
  transform: translate(-50%, -50%);
  left: 6%;
  background: url("../assets/svg/plane.svg") center/contain no-repeat;
  filter: drop-shadow(1px 1px 0 var(--c-blue-30));
  transition: left 80ms linear;
}

/* spacer para que el body no quede debajo del header fijo */
.header-spacer { height: var(--header-h); }

/* ------- Anti-IA helpers ------- */
.rot-l   { transform: rotate(-1.4deg); }
.rot-r   { transform: rotate(1.5deg); }
.rot-l-2 { transform: rotate(-2.4deg); }
.rot-r-2 { transform: rotate(2.6deg); }
.rot-l-6 { transform: rotate(-6deg); }
.rot-r-3 { transform: rotate(3deg); }

/* Imágenes con overlay de grano local */
.img-grain {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
}
.img-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/svg/grain.svg") center/180px 180px;
  opacity: 0.10;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .cursor-dot { display: none; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
