/* Colores del manual de marca Tracto Oriente */
:root {
  --amber: #ffc300;        /* amarillo de marca */
  --amber-dark: #e6b000;
  --amber-text: #9a7100;   /* amarillo oscurecido para texto sobre fondo claro */
  --ink: #2f2725;          /* negro café de marca */
  --ink-2: #3a3230;
  --ink-line: #4a413e;
  --steel: #6b625e;
  --line: #e4e0dd;
  --paper: #f3f1ef;        /* gris claro de marca */
  --white: #ffffff;
  --on-dark: #d4cdc9;
  --on-dark-muted: #a39995;
  --radius: 6px;
  /* La fuente de marca es Nexa; Montserrat es la alternativa web más cercana */
  --font-head: "Nexa", "Montserrat", system-ui, sans-serif;
  --font-body: "Montserrat", system-ui, sans-serif;

  /* Tokens de superficie: cambian entre modo claro y oscuro */
  --bg: var(--white);
  --bg-alt: var(--paper);
  --text: var(--ink);
  --text-muted: var(--steel);
  --border: var(--line);
  --accent-text: var(--amber-text);
  --field-bg: var(--white);
  --field-border: #cdc7c3;
  --btn-dark-bg: var(--ink);
  --btn-dark-hover: var(--ink-2);
  --btn-dark-text: var(--white);
  --footer-bg: #221c1a;
  --error: #b42318;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1a1514;
  --bg-alt: #221c1a;
  --text: #ece6e3;
  --text-muted: #a39995;
  --border: #3a3230;
  --accent-text: var(--amber);
  --field-bg: #2a2321;
  --field-border: #4a413e;
  --btn-dark-bg: #ece6e3;
  --btn-dark-hover: var(--white);
  --btn-dark-text: var(--ink);
  --footer-bg: #120e0d;
  --error: #f97066;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background .2s, color .2s;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1.08;
  margin: 0 0 .5em;
  text-transform: uppercase;
}
h2 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: inherit; }

.container { width: min(1180px, 100% - 32px); margin-inline: auto; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.eyebrow {
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: .8em;
}

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-weight: 700; font-size: .95rem;
  letter-spacing: .04em; text-transform: uppercase; text-decoration: none;
  padding: .95em 1.7em; border: 0; border-radius: var(--radius);
  cursor: pointer; transition: background .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--amber); color: var(--ink); }
.btn--primary:hover { background: var(--amber-dark); }
.btn--dark { background: var(--btn-dark-bg); color: var(--btn-dark-text); }
.btn--dark:hover { background: var(--btn-dark-hover); }
.btn--sm { padding: .65em 1.2em; font-size: .85rem; }
.btn--block { width: 100%; }

/* Barra superior */
.topbar { background: var(--amber); color: var(--ink); font-size: .8rem; font-weight: 600; }
.topbar__inner { display: flex; gap: .75rem; justify-content: center; padding: .4rem 0; flex-wrap: wrap; }
.topbar__sep { opacity: .4; }

/* Botón de modo claro / oscuro */
.theme-toggle {
  order: 2; margin-left: 1.75rem;
  width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 1px solid var(--ink-line); border-radius: 50%;
  color: var(--on-dark); cursor: pointer; transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--amber); border-color: var(--amber); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }

/* Encabezado */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink); color: var(--white);
  border-bottom: 1px solid #1f1a18;
}
.header__inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }

.logo { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.logo img { height: 38px; width: auto; display: block; }
.logo__text { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; line-height: 1.05; }
.logo__text strong { display: block; color: var(--amber); font-weight: 800; }

.nav { display: flex; align-items: center; gap: 2rem; margin-left: auto; }
.nav a:not(.btn) {
  font-weight: 600; font-size: .85rem;
  letter-spacing: .08em; text-transform: uppercase; text-decoration: none;
  color: var(--on-dark); transition: color .15s;
}
.nav a:not(.btn):hover { color: var(--amber); }

.nav-toggle {
  display: none; background: none; border: 0; padding: 8px; cursor: pointer;
  flex-direction: column; gap: 5px;
}
.nav-toggle span { display: block; width: 26px; height: 3px; background: var(--white); transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Hero */
.hero {
  position: relative; overflow: hidden;
  background: var(--ink); color: var(--white);
  padding: clamp(4rem, 9vw, 7.5rem) 0 0;
}
/* Isotipo de marca como marca de agua */
.hero::after {
  content: ""; position: absolute; right: -4%; top: 8%;
  width: 52%; aspect-ratio: 480 / 334;
  background: url("img/logo-to-amarillo.png") no-repeat center / contain;
  opacity: .07; pointer-events: none;
}
.hero__inner {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  column-gap: 2rem; align-items: center;
}
.hero__copy { max-width: 760px; }
.hero__stats { grid-column: 1 / -1; }

/* Render de la retroexcavadora, sobresale hacia la derecha */
.hero__machine { position: relative; margin-right: -5%; }
.hero__machine::after {
  content: ""; position: absolute; left: 6%; right: 10%; bottom: 2%; height: 14%;
  background: radial-gradient(closest-side, rgba(0,0,0,.55), transparent);
  z-index: -1;
}
.hero__machine img { display: block; width: 100%; height: auto; }

/* Giro 360°: la caja del cuadro 0 coincide con la imagen fija; el resto de ángulos sobresale.
   Valores que imprime herramientas/postproceso_giro.py (izq, arriba, ancho, alto del cuadro 0) */
.hero__machine {
  --spin-x: .0777; --spin-y: .0013; --spin-w: .6341; --spin-h: .9745;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.hero__machine img.spin {
  position: absolute; display: none; max-width: none;
  width: calc(100% / var(--spin-w));
  left: calc(-100% * var(--spin-x) / var(--spin-w));
  top: calc(-100% * var(--spin-y) / var(--spin-h));
  pointer-events: none;
}
.hero__machine.is-ready { cursor: grab; }
.hero__machine.is-ready picture { visibility: hidden; }
.hero__machine.is-ready img.spin { display: block; }
.hero__machine.is-spinning { cursor: grabbing; }

.spin__hint {
  position: absolute; left: 50%; bottom: -1.75rem; transform: translateX(-50%);
  display: none; align-items: center; gap: .45rem; margin: 0;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--on-dark-muted); white-space: nowrap; pointer-events: none;
  transition: opacity .4s;
}
.spin__hint svg { width: 18px; height: 18px; color: var(--amber); }
.hero__machine.is-ready .spin__hint { display: inline-flex; }
.hero__machine.was-used .spin__hint { opacity: 0; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 4.4rem); }
.hero h1 span { color: var(--amber); }
.hero__lead { font-size: 1.08rem; color: var(--on-dark); max-width: 600px; margin-bottom: 2rem; }

.search { display: flex; gap: .5rem; max-width: 620px; }
.search input {
  flex: 1; min-width: 0;
  font: inherit; padding: .9em 1em;
  border: 2px solid var(--ink-line); border-radius: var(--radius);
  background: var(--ink-2); color: var(--white);
}
.search input::placeholder { color: var(--on-dark-muted); }
.search input:focus { outline: none; border-color: var(--amber); }
.search__hint { font-size: .85rem; color: var(--on-dark-muted); margin-top: .6rem; }

.hero__stats {
  list-style: none; margin: clamp(3rem, 7vw, 5rem) 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--ink-line);
}
.hero__stats li { padding: 1.6rem 1rem 1.8rem 0; }
.hero__stats li + li { padding-left: 1.5rem; border-left: 1px solid var(--ink-line); }
.hero__stats strong { display: block; font-family: var(--font-head); font-weight: 800; font-size: 2.2rem; color: var(--amber); line-height: 1.1; }
.hero__stats span { color: var(--on-dark-muted); font-size: .9rem; }

/* Secciones */
.section { padding: clamp(4rem, 8vw, 6.5rem) 0; }
.section--alt { background: var(--bg-alt); }
.section--dark { background: var(--ink); color: var(--white); }
.section--dark .eyebrow { color: var(--amber); }
.section__head { max-width: 640px; margin-bottom: 3rem; }
.section__head p:last-child { color: var(--text-muted); }
.section--dark .section__head p:last-child { color: var(--on-dark-muted); }

/* Tarjetas de categoría */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1px; background: var(--border); border: 1px solid var(--border);
}
.card { background: var(--bg); padding: 2rem 1.75rem; transition: background .2s; }
.card:hover { background: var(--bg-alt); }
.card svg { width: 44px; height: 44px; color: var(--text); margin-bottom: 1rem; }
.card:hover svg { color: var(--accent-text); }
.card p { color: var(--text-muted); font-size: .93rem; margin: 0; }

/* Máquinas */
.machines {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem;
}
.machines li {
  font-weight: 700; font-size: .95rem;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 1.1rem 1.25rem; border: 1px solid var(--ink-line); border-radius: var(--radius);
  background: var(--ink-2); transition: border-color .15s, color .15s;
}
.machines li:hover { border-color: var(--amber); color: var(--amber); }

/* Marcas */
.brands {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  border-top: 1px solid var(--border); border-left: 1px solid var(--border);
}
.brands li {
  font-weight: 800; font-size: 1rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  text-align: center; padding: 1.75rem 1rem;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transition: color .15s;
}
.brands li:hover { color: var(--text); }

/* Misión y visión */
.purpose {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: clamp(2rem, 5vw, 4rem);
  margin-top: clamp(3rem, 6vw, 4.5rem); padding-top: clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--border);
}
.purpose .eyebrow { margin-bottom: .75rem; }
.purpose__text { margin: 0; font-size: clamp(1.05rem, 1.6vw, 1.2rem); line-height: 1.7; color: var(--text); max-width: 62ch; }

/* Distribuidor oficial */
.dealer {
  margin-top: 3rem; padding: clamp(1.5rem, 4vw, 2.5rem);
  display: grid; grid-template-columns: auto 1fr auto; gap: clamp(1.25rem, 4vw, 2.5rem); align-items: center;
  background: var(--ink); color: var(--on-dark);
}
.dealer__logo { display: block; width: 120px; height: auto; }
.dealer .eyebrow { color: var(--amber); margin: 0; }
.dealer h3 { margin: .25rem 0 .5rem; color: var(--white); font-size: clamp(1.25rem, 2.5vw, 1.6rem); }
.dealer p:last-child { margin: 0; color: var(--on-dark-muted); max-width: 520px; }
@media (max-width: 900px) {
  .dealer { grid-template-columns: auto 1fr; }
  .dealer .btn { grid-column: 2; justify-self: start; }
}@media (max-width: 760px) {
  .dealer { grid-template-columns: 1fr; justify-items: start; }
  .dealer .btn { grid-column: auto; }
  .dealer__logo { width: 96px; }
}

/* Dos columnas */
.split { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(2.5rem, 6vw, 5rem); align-items: start; }
.split > div > p { color: var(--text-muted); max-width: 480px; }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.75rem; }
.features li { display: flex; gap: 1.25rem; }
.features__num {
  font-family: var(--font-head); font-weight: 800; font-size: 1.3rem; color: var(--accent-text);
  line-height: 1.2; min-width: 2.2rem;
}
.features h3 { margin-bottom: .3em; }
.features p { color: var(--text-muted); margin: 0; }

/* Formulario */
.note { font-size: .93rem; color: var(--text-muted); }
.note strong { color: var(--text); }
.form {
  background: var(--bg-alt); padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--border); border-top: 4px solid var(--amber);
  display: grid; gap: 1.1rem;
}
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.form label {
  display: grid; gap: .35rem;
  font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em;
}
.form input, .form select, .form textarea {
  font: inherit; font-size: .95rem; text-transform: none; letter-spacing: normal; font-weight: 400;
  padding: .75em .9em; border: 1px solid var(--field-border); border-radius: var(--radius);
  background: var(--field-bg); color: var(--text); width: 100%;
}
.form textarea { resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--amber-dark); box-shadow: 0 0 0 3px rgba(255,195,0,.3);
}
.form__error { color: var(--error); font-weight: 600; margin: 0; }

/* Contacto */
.contact { display: grid; grid-template-columns: 1fr 1.4fr; gap: 3rem; align-items: start; }
.contact__logo { width: 180px; height: auto; margin-top: 1.5rem; opacity: .9; }
.contact__list { list-style: none; margin: 0; padding: 0; }
.contact__list li {
  display: grid; grid-template-columns: 140px 1fr; gap: 1rem;
  padding: 1rem 0; border-bottom: 1px solid var(--ink-line); font-size: 1rem;
}
.contact__list a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--ink-line); }
.contact__list a:hover { color: var(--amber); border-color: var(--amber); }
.contact__list span {
  font-weight: 700; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--amber); padding-top: .15rem;
}

/* Pie */
.footer { background: var(--footer-bg); color: var(--on-dark-muted); font-size: .82rem; padding: 1.75rem 0; }
.footer__inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer a { color: var(--on-dark); text-decoration: none; }
.footer a:hover { color: var(--amber); }

/* WhatsApp flotante */
.wa-float {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background: #25d366; color: var(--white);
  box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: transform .2s;
}
.wa-float:hover { transform: scale(1.07); }
.wa-float svg { width: 30px; height: 30px; }

/* Responsive */
@media (max-width: 900px) {
  .nav-toggle { display: flex; order: 3; margin-left: .5rem; }
  .theme-toggle { margin-left: auto; }
  .nav {
    position: absolute; top: 72px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--ink); border-bottom: 1px solid var(--ink-line);
    padding: .5rem 16px 1.25rem;
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a:not(.btn) { padding: .9rem 0; border-bottom: 1px solid var(--ink-2); }
  .nav .btn { margin-top: 1rem; }

  .split, .contact { grid-template-columns: 1fr; }
  .hero::after { width: 80%; top: auto; bottom: 18%; right: -20%; }
  .hero__inner { grid-template-columns: 1fr; }
  .hero__machine { margin: 2.5rem -4% 0 0; max-width: 640px; justify-self: center; }
}

@media (max-width: 560px) {
  .search { flex-direction: column; }
  /* Barra superior: sin separadores sueltos al partirse en varias líneas */
  .topbar { font-size: .74rem; }
  .topbar__inner { column-gap: 1rem; row-gap: 0; padding: .35rem 0; }
  .topbar__sep { display: none; }
  .hero__stats { grid-template-columns: 1fr; }
  .hero__stats li, .hero__stats li + li { padding: 1.1rem 0; border-left: 0; border-bottom: 1px solid var(--ink-line); }
  .form__row { grid-template-columns: 1fr; }
  .contact__list li { grid-template-columns: 1fr; gap: .15rem; }
}

/* Animaciones (solo con la clase .anim en <html>) */
@keyframes subir {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}
@keyframes entrar-maquina {
  from { opacity: 0; transform: translateX(80px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes sombra {
  from { opacity: 0; transform: scaleX(.6); }
  to { opacity: 1; transform: none; }
}

/* Entrada del hero al cargar */
.anim .hero__copy > * { animation: subir .8s cubic-bezier(.2, .7, .2, 1) both; }
.anim .hero__copy > :nth-child(1) { animation-delay: .1s; }
.anim .hero__copy > :nth-child(2) { animation-delay: .2s; }
.anim .hero__copy > :nth-child(3) { animation-delay: .35s; }
.anim .hero__copy > :nth-child(4) { animation-delay: .5s; }
.anim .hero__copy > :nth-child(5) { animation-delay: .6s; }
.anim .hero__machine img { animation: entrar-maquina 1.1s cubic-bezier(.16, .8, .24, 1) .35s both; }
.anim .hero__machine::after { animation: sombra 1.1s cubic-bezier(.16, .8, .24, 1) .5s both; }
.anim .hero__stats { animation: subir .8s cubic-bezier(.2, .7, .2, 1) .8s both; }

/* Aparición al hacer scroll: script.js agrega .reveal y luego .is-visible */
/* Se repite cada vez que el elemento vuelve a la pantalla. El retraso escalonado solo
   aplica a la entrada; los colores de hover conservan su transición corta */
.anim .reveal {
  opacity: 0; transform: translateY(28px);
  transition:
    opacity .7s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms),
    transform .7s cubic-bezier(.2, .7, .2, 1) var(--d, 0ms),
    background-color .2s, color .15s, border-color .15s;
}
.anim .reveal.is-visible { opacity: 1; transform: none; }

/* Al salir el hero de la pantalla se apagan sus animaciones; al volver se reinician */
.anim .hero.is-reset .hero__copy > *,
.anim .hero.is-reset .hero__machine img,
.anim .hero.is-reset .hero__machine::after,
.anim .hero.is-reset .hero__stats { animation: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
