/* Tokens de color: ver specs/002-paleta.md §3. Ningún color fuera de :root. */
:root {
  --almond: #F0DCCA;
  --ink: #1F2126;
  --slate: #585B68;
  --teal: #476156;
  --teal-deep: #364B42;
  --sage-teal: #8D9F87;
  --sage: #CDC6A5;
  --slate-edge: #696D7D;
  --teal-soft: #6F9283;
  --paper: #FAF4EE;

  --font: "Familjen Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Escala modular 1.25 */
  --s-1: 0.8rem;
  --s0: 1rem;
  --s1: 1.25rem;
  --s2: 1.563rem;
  --s3: 1.953rem;
  --s4: 2.441rem;

  --gutter: clamp(1rem, 4vw, 3rem);
  --max: 76rem;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--almond);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }

/* Cortes de línea: titulares balanceados, prosa sin palabras sueltas al final. */
h1, h2, h3, dt { text-wrap: balance; }
p, dd, figcaption { text-wrap: pretty; }

::selection { background: var(--sage); color: var(--ink); }

a { color: inherit; }

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

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

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: .5rem 1rem;
  z-index: 10;
}
.skip:focus { left: 1rem; }

/* Header */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-block: 1.5rem;
}
.brand {
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.header-mail,
.mail-link {
  color: var(--teal);
  text-underline-offset: .2em;
  text-decoration-thickness: 1px;
}
.header-mail:hover,
.mail-link:hover { text-decoration-thickness: 2px; }
/* Zona de toque de 44px sin mover el layout. */
.header-mail {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -12px;
}

.hero-cta {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 1rem; /* fila: deja lugar a la zona de toque y al foco del link */
  font-size: var(--s1);
  line-height: 1.45;
}
.mail-link {
  display: inline-block;
  font-weight: 600;
  padding-block: .55rem;
  margin-block: -.55rem;
}
.hero-cta span { color: var(--slate); font-size: var(--s0); }

/* Hero */
.hero {
  padding-block: clamp(2.5rem, 8vw, 6rem) clamp(3rem, 8vw, 6rem);
}
.hero-title {
  font-size: clamp(2.6rem, 7.4vw, 6.4rem);
  font-weight: 500;
  line-height: .96;
  letter-spacing: -0.045em;
  max-width: 14ch;
  text-wrap: balance;
}
.hero-lede {
  margin-top: 2rem;
  max-width: 34rem;
  font-size: var(--s1);
  line-height: 1.45;
  color: var(--slate);
}

/* Demo */
.demo {
  margin: clamp(3rem, 7vw, 5rem) 0 0;
}
.stage {
  position: relative;
  background: var(--sage-teal);
  border-radius: 6px;
  padding: clamp(1rem, 3vw, 2.5rem);
  overflow: hidden;
  /* Alto fijo: el del dispositivo en su ancho mínimo. Así la página no salta
     al arrastrar; el dispositivo se centra dentro (main.js). */
  height: calc((var(--device-h) + 16px) * var(--scale-max, 1) + 2 * clamp(1rem, 3vw, 2.5rem));
  --device-h: 440px;
}
.device {
  width: calc(var(--w, 1000) * 1px);
  height: var(--device-h);
  background: var(--paper);
  border-radius: 12px;
  box-shadow: 0 0 0 8px var(--ink);
  transform: translate(var(--dx, 0px), var(--dy, 0px)) scale(var(--scale, 1));
  transform-origin: top left;
  overflow: hidden;
  container-type: inline-size;
  container-name: device;
  margin-left: 8px;
  margin-top: 8px;
}
.device[data-mode="phone"] { border-radius: 30px; }
.device[data-mode="tablet"] { border-radius: 20px; }

.demo-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .5rem 1.5rem;
  margin-top: 1.5rem;
}
.demo-label { font-weight: 600; }
.demo-controls input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--teal);
  height: 2rem;
  cursor: ew-resize;
}
.readout {
  font-variant-numeric: tabular-nums;
  min-width: 17ch;
  color: var(--slate);
}
/* En pantallas angostas: label arriba, slider y lectura en la misma fila. */
@media (max-width: 560px) {
  .demo-controls { grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem; }
  .demo-label { grid-column: 1 / -1; }
}
#readout-px { color: var(--ink); font-weight: 600; }
.demo-caption {
  margin-top: .75rem;
  color: var(--slate);
  max-width: 40rem;
}

/* Mock app (dentro del dispositivo) */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink);
}
.app-nav, .app-detail { display: none; }
.app-main { padding: 28px 18px 12px; overflow: hidden; }
.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.app-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.app-count {
  background: var(--teal);
  color: var(--paper);
  border-radius: 999px;
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
}
.app-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
}
.app-list li {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--almond);
  border-radius: 10px;
}
.app-list time { font-weight: 600; font-variant-numeric: tabular-nums; }
.app-list em {
  font-style: normal;
  font-size: 12px;
  color: var(--ink);
  background: var(--sage);
  padding: 3px 8px;
  border-radius: 999px;
}
.app-list li.is-selected { box-shadow: inset 0 0 0 2px var(--teal); }
.app-tabs {
  display: flex;
  justify-content: space-around;
  padding: 12px 8px 20px;
  border-top: 1px solid var(--sage-teal);
  font-size: 12px;
  color: var(--slate);
}
.app-tabs .is-active { color: var(--teal); font-weight: 600; }

/* Tablet: riel lateral + lista en dos columnas */
@container device (min-width: 420px) {
  .app { grid-template-columns: 64px 1fr; grid-template-rows: 1fr; }
  .app-tabs { display: none; }
  .app-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px 0;
    background: var(--ink);
    color: var(--paper);
  }
  .app-logo { display: none; }
  .nav-item i {
    font-style: normal;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-weight: 600;
  }
  .nav-item i svg { width: 18px; height: 18px; }
  .nav-item b { display: none; }
  .nav-item.is-active i { background: var(--teal-soft); color: var(--ink); }
  .app-main { padding: 28px 24px; }
  /* Dos columnas solo cuando entran sin recortar (RF-3); antes, una. */
  .app-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
}

/* Escritorio: menú con texto + lista + detalle */
@container device (min-width: 701px) {
  .app { grid-template-columns: 180px 1fr 260px; }
  .app-nav { align-items: stretch; padding: 24px 14px; gap: 4px; }
  .app-logo {
    display: block;
    font-weight: 600;
    font-size: 18px;
    padding: 0 10px 18px;
    letter-spacing: -0.02em;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
  }
  .nav-item i { width: 26px; height: 26px; border-radius: 7px; font-size: 13px; background: color-mix(in srgb, var(--paper) 12%, transparent); }
  .nav-item i svg { width: 14px; height: 14px; }
  .nav-item b { display: inline; font-weight: 500; }
  .nav-item.is-active { background: color-mix(in srgb, var(--paper) 10%, transparent); }
  .app-list { grid-template-columns: 1fr; }
  .app-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 28px 22px;
    border-left: 1px solid var(--sage-teal);
  }
  .detail-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
  .detail-meta { color: var(--slate); margin-bottom: 8px; }
  .detail-line { height: 10px; border-radius: 5px; background: var(--sage); }
  .detail-line.short { width: 60%; }
  .detail-btn {
    margin-top: auto;
    background: var(--teal);
    color: var(--paper);
    border-radius: 8px;
    padding: 11px;
    text-align: center;
    font-weight: 600;
  }
}

/* Bloques de contenido */
.block {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 1.5rem;
  row-gap: 1.5rem;
  padding-block: clamp(3rem, 7vw, 5.5rem);
  border-top: 1px solid var(--sage-teal);
}
.block-title {
  grid-column: 1 / span 4;
  font-size: var(--s3);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.block > :not(.block-title) { grid-column: 5 / -1; }

.services { display: grid; gap: 2.25rem; }
.service dt {
  font-size: var(--s2);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.service dd {
  margin-top: .5rem;
  max-width: 38rem;
  color: var(--slate);
}

.steps {
  list-style: none;
  padding: 0;
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5rem 2rem;
}
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: block;
  font-size: var(--s4);
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-bottom: .75rem;
}
.steps h3 { font-size: var(--s1); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.steps p { margin-top: .4rem; color: var(--slate); max-width: 30rem; }

.stack { display: grid; gap: 1.25rem; max-width: 42rem; }
.stack strong { display: block; font-weight: 600; }
.stack p { color: var(--slate); }

/* Contacto */
.contact {
  background: var(--ink);
  color: var(--almond);
  padding-block: clamp(4rem, 10vw, 8rem);
}
.contact-title {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  max-width: 16ch;
  text-wrap: balance;
}
.contact-text {
  margin-top: 1.5rem;
  max-width: 34rem;
  font-size: var(--s1);
  line-height: 1.5;
  letter-spacing: .005em;
  color: var(--sage);
}
.contact-actions { margin-top: 2.5rem; display: grid; gap: 1.25rem; justify-items: start; }

.btn {
  display: inline-block;
  background: var(--almond);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--s1);
  text-decoration: none;
  padding: 1.05rem 1.6rem;
  border-radius: 4px;
  transition: background-color .15s ease;
}
.btn:hover { background: var(--sage); }
.btn:focus-visible { outline-color: var(--sage-teal); }

.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.mail-text { user-select: all; color: var(--sage); }
.btn-ghost {
  font: inherit;
  font-size: var(--s-1);
  font-weight: 600;
  color: var(--almond);
  background: transparent;
  border: 1px solid var(--slate-edge);
  border-radius: 4px;
  padding: .4rem .8rem;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--almond); }
.btn-ghost:focus-visible { outline-color: var(--sage-teal); }
.copy-status { font-size: var(--s0); font-weight: 600; color: var(--sage-teal); min-height: 1.55em; }

/* Footer */
.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  padding-block: 1.75rem;
  font-size: var(--s-1);
  color: var(--slate);
}

/* Hero en dos columnas: la demo arriba del pliegue */
@media (min-width: 1080px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: clamp(2rem, 4vw, 4rem);
    align-items: start;
    padding-block-start: clamp(2rem, 5vw, 4rem);
  }
  .hero-title { font-size: clamp(3rem, 5.4vw, 5.2rem); }
  .demo { margin-top: .5rem; }
}

/* Responsive */
@media (max-width: 860px) {
  .block-title, .block > :not(.block-title) { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .steps { grid-template-columns: 1fr; }
  .stage { --device-h: 520px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
