/* ============================================================
   Digistore — Sistema de diseño
   Tech minimalista · claro · monocromo + un acento
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Color */
  --bg:            #FFFFFF;
  --surface:       #FAFAFA;
  --text:          #0A0A0C;
  --text-2:        #6B6B75;   /* 5.27:1 sobre blanco */
  --line:          #E8E8EC;
  --line-strong:   #D4D4DA;
  --accent:        #0F766E;   /* 5.47:1 sobre blanco */
  --accent-soft:   #0F766E1A;

  /* Espaciado — escala amplia */
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 40px;
  --s-5: 64px;
  --s-6: 96px;
  --section-y: clamp(72px, 10vw, 140px);

  /* Layout */
  --container: 1240px;
  --gutter: clamp(20px, 5vw, 48px);
  --header-h: 72px;

  /* Tipografía */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Movimiento */
  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.03em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

a {
  color: inherit;
  text-decoration: none;
  transition: color .2s var(--ease);
}

img { max-width: 100%; display: block; }

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  font-size: .875rem;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- Microetiqueta mono ---------- */
.mono-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-2);
}

.mono-label__num {
  color: var(--accent);
  position: relative;
  padding-right: 12px;
}
.mono-label__num::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 6px;
  height: 1px;
  background: var(--accent);
}

/* Índice de sección: solo el número, sin repetir el título */
.section-index {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.section-index::after {
  content: "";
  height: 1px;
  width: 28px;
  background: var(--accent);
  opacity: .45;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid transparent;
  transition: background .3s var(--ease), border-color .3s var(--ease), backdrop-filter .3s var(--ease);
}

.header.is-stuck {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom-color: var(--line);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.brand {
  font-family: var(--font-mono);
  font-size: .9375rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px; /* objetivo táctil mínimo */
}

.brand__dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  flex: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.4vw, 34px);
}

.nav__link {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 12px 0;
  position: relative;
}

.nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width .3s var(--ease);
}

.nav__link:hover { color: var(--text); cursor: pointer; }
.nav__link:hover::after { width: 100%; }

/* Botón menú móvil */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  place-items: center;
}

.nav-toggle__bars { display: block; width: 22px; height: 10px; position: relative; }
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--text);
  transition: transform .3s var(--ease), top .3s var(--ease);
}
.nav-toggle__bars::before { top: 0; }
.nav-toggle__bars::after  { top: 8px; }

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { top: 4px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after  { top: 4px; transform: rotate(-45deg); }

/* Menú overlay móvil */
.menu {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: var(--s-2) 0 var(--s-4);
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s var(--ease), transform .28s var(--ease), visibility .28s;
  z-index: 99;
}
.menu.is-open { opacity: 1; transform: none; visibility: visible; }

.menu__link {
  display: block;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  padding-top: calc(var(--header-h) + clamp(72px, 14vh, 150px));
  padding-bottom: clamp(72px, 12vh, 140px);
  overflow: hidden;
}

/* Grilla técnica de fondo */
.hero__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 72%);
          mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 0%, transparent 72%);
  opacity: .85;
}

.hero .container { position: relative; }

.hero__eyebrow { margin-bottom: clamp(24px, 4vw, 40px); }

.display {
  font-size: clamp(3rem, 11.5vw, 9rem);
  line-height: 0.9;
  letter-spacing: -0.045em;
  font-weight: 700;
}

/* Líneas enmascaradas para el reveal */
.line { display: block; overflow: hidden; padding-bottom: 0.04em; }
.line > span {
  display: block;
  transform: translateY(105%);
  transition: transform 1s var(--ease);
}
.is-loaded .line > span { transform: none; }
.line:nth-child(2) > span { transition-delay: .09s; }

.hero__rule {
  width: 0;
  height: 2px;
  background: var(--accent);
  margin: clamp(28px, 4vw, 44px) 0 clamp(22px, 3vw, 32px);
  transition: width 1s var(--ease) .35s;
}
.is-loaded .hero__rule { width: clamp(80px, 12vw, 140px); }

.hero__sub {
  max-width: 34ch;
  font-size: clamp(1.0625rem, 1.6vw, 1.375rem);
  line-height: 1.5;
  color: var(--text-2);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .8s var(--ease) .5s, transform .8s var(--ease) .5s;
}
.is-loaded .hero__sub { opacity: 1; transform: none; }

/* ============================================================
   Secciones
   ============================================================ */
.section {
  padding-block: var(--section-y);
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 18px);
}

.section__inner {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: clamp(32px, 5vw, 88px);
}

.section__head { align-self: start; }

@media (min-width: 900px) {
  .section__head { position: sticky; top: calc(var(--header-h) + 48px); }
}

.section__title {
  margin-top: var(--s-3);
  font-size: clamp(1.875rem, 3.4vw, 2.75rem);
  line-height: 1.02;
}

.prose p {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text-2);
  max-width: 62ch;
}
.prose p + p { margin-top: var(--s-3); }

/* Sección de ancho completo (servicios, trabajos) */
.section--full .section__head { position: static; margin-bottom: clamp(40px, 6vw, 72px); }

/* ============================================================
   Grilla con hairlines (servicios y estadísticas)
   ============================================================ */
.grid-hairline {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.grid-hairline > * { background: var(--bg); }

.services { grid-template-columns: repeat(4, 1fr); }

.service {
  position: relative;
  padding: clamp(28px, 3.6vw, 48px) clamp(20px, 2.4vw, 32px);
  min-height: clamp(170px, 20vw, 230px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: background .3s var(--ease);
}

.service__num {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.service__name {
  font-size: clamp(1rem, 1.35vw, 1.1875rem);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.service::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width .45s var(--ease);
}

.service:hover { background: var(--surface); }
.service:hover::after { width: 100%; }

/* ============================================================
   Banda de estadísticas (inversión de contraste)
   ============================================================ */
.band {
  --bg: #0A0A0C;
  --text: #F4F4F6;
  --text-2: #9C9CA6;
  --line: #24242B;
  --accent: #2DD4BF;
  background: #0A0A0C;
  color: #F4F4F6;
  border-top: 0;
}

.band .section__title,
.band .brand { color: #F4F4F6; }

.stats { grid-template-columns: repeat(4, 1fr); }

.stat {
  padding: clamp(32px, 4vw, 52px) clamp(20px, 2.4vw, 32px);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.stat__value {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  line-height: 1.6;
}

/* ============================================================
   Contacto
   ============================================================ */
.contact-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-top: var(--s-2);
}

/* El correo es la cadena más larga: va en su propia fila a lo ancho */
.contact-item--wide { grid-column: 1 / -1; }

.contact-item { padding: clamp(28px, 3.4vw, 44px) clamp(20px, 2.4vw, 32px); }

.contact-item__label {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s-2);
}

.contact-item__value {
  font-size: clamp(1.0625rem, 1.8vw, 1.375rem);
  font-weight: 500;
  letter-spacing: -0.02em;
}

/* Correo y teléfono nunca deben partirse en dos líneas */
a.contact-item__value { white-space: nowrap; }

.contact-item__value--email { font-size: clamp(.9375rem, 1.9vw, 1.375rem); }

a.contact-item__value {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
a.contact-item__value:hover { color: var(--accent); cursor: pointer; }

a.contact-item__value svg {
  flex: none;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
a.contact-item__value:hover svg { opacity: 1; transform: none; }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(36px, 5vw, 56px);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.footer__copy {
  font-size: .875rem;
  color: var(--text-2);
  line-height: 1.6;
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.footer__link {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.footer__link:hover { color: var(--accent); cursor: pointer; }

/* ============================================================
   Páginas legales
   ============================================================ */
.legal-hero {
  padding-top: calc(var(--header-h) + clamp(56px, 10vh, 100px));
  padding-bottom: clamp(40px, 6vw, 64px);
}

.legal-hero__title {
  margin-top: var(--s-3);
  font-size: clamp(2rem, 5.5vw, 3.75rem);
  line-height: 1.0;
  letter-spacing: -0.04em;
}

.legal-hero__meta {
  margin-top: var(--s-3);
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* Bloque de identidad */
.identity {
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: var(--surface);
  padding: clamp(24px, 3.4vw, 40px);
  max-width: 74ch;
}

.identity__title {
  font-family: var(--font-mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--s-3);
}

.identity__name {
  font-size: clamp(1.125rem, 2vw, 1.375rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-2);
}

.identity__row {
  font-size: .9375rem;
  line-height: 1.9;
  color: var(--text-2);
}
.identity__row strong { color: var(--text); font-weight: 500; }
.identity__row a { color: var(--accent); }
.identity__row a:hover { text-decoration: underline; cursor: pointer; }

/* Cuerpo legal */
.legal-body {
  padding-top: clamp(48px, 7vw, 80px);
  padding-bottom: clamp(72px, 10vw, 120px);
}

.legal-body__inner { max-width: 68ch; }

.legal-section { padding-top: clamp(36px, 5vw, 52px); }
.legal-section + .legal-section { border-top: 1px solid var(--line); }

.legal-section__title {
  display: flex;
  gap: 14px;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.4;
  margin-bottom: var(--s-3);
}

.legal-section__num {
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 500;
  color: var(--accent);
  padding-top: .35em;
  flex: none;
}

.legal-section p,
.legal-section li {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-2);
}
.legal-section p + p,
.legal-section p + ul,
.legal-section ul + p { margin-top: var(--s-3); }

.legal-section ul { display: grid; gap: 10px; }

.legal-section li {
  position: relative;
  padding-left: 22px;
}
.legal-section li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .82em;
  width: 6px;
  height: 1px;
  background: var(--accent);
}

.legal-section a { color: var(--accent); }
.legal-section a:hover { text-decoration: underline; cursor: pointer; }

.legal-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(48px, 6vw, 72px);
  padding: 14px 22px;
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.legal-back:hover { border-color: var(--accent); color: var(--accent); cursor: pointer; }

/* ============================================================
   Animaciones de entrada
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--delay, 0s);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 960px) {
  .services { grid-template-columns: repeat(2, 1fr); }
  .stats    { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .section__inner { grid-template-columns: 1fr; gap: var(--s-4); }
  .section__head  { position: static; }
}

@media (max-width: 720px) {
  .nav { display: none; }
  .nav-toggle { display: grid; }
  .hero__grid { background-size: 48px 48px; }
  .contact-grid { grid-template-columns: 1fr; }
  /* La flecha sólo indica hover, que en táctil no existe: liberamos ese ancho
     para que el correo entre en una línea. */
  a.contact-item__value svg { display: none; }
  .footer__inner { flex-direction: column; align-items: flex-start; gap: var(--s-2); }
}

@media (max-width: 520px) {
  /* Con 0.2em de tracking la etiqueta se parte en dos líneas en teléfonos angostos */
  .hero__eyebrow { letter-spacing: 0.1em; }
}

@media (max-width: 460px) {
  .services { grid-template-columns: 1fr; }
  .stats    { grid-template-columns: 1fr; }
  .service  { min-height: 0; gap: var(--s-4); }
}

/* ============================================================
   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;
    transition-delay: 0s !important;
  }

  .line > span { transform: none; }
  .hero__rule  { width: clamp(80px, 12vw, 140px); }
  .hero__sub   { opacity: 1; transform: none; }
  .reveal      { opacity: 1; transform: none; }
}
