/* ==========================================================================
   Tienda de apps Atecresa · Design system "Tecla"
   El logo de Atecresa es un teclado de TPV (teclas 1·2·3·5). Todo el sistema
   se construye con ese lenguaje: teclas con canto, que se hunden al pulsarlas.
   Mobile-first. Sin dependencias.
   ========================================================================== */

/* ---------- Fuentes (alojadas en el propio sitio) ---------- */
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plexmono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plexmono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  /* Marca (logo + atecresa.com) */
  --ink: #0b1630;
  --indigo: #363575;
  --red: #b91c1c;          /* acción: 6,5:1 sobre blanco */
  --red-brand: #cd2527;    /* tecla 5 del logo */
  --yellow: #f2df4d;       /* tecla 3 del logo */
  --grey: #ececec;         /* tecla 2 del logo */

  /* Cantos de tecla (variantes oscuras de cada color) */
  --ink-edge: #02060f;
  --indigo-edge: #1f1e4b;
  --red-edge: #7c1010;
  --yellow-edge: #b8a425;
  --grey-edge: #bcc0c8;

  /* Neutros derivados del azul tinta */
  --paper: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef4;
  --line: #dde1ea;
  --line-strong: #c3c9d6;
  --text: #0b1630;
  --text-2: #3f4a64;
  --text-3: #58637d;
  --on-ink: #ffffff;
  --on-ink-2: #c3cbe0;
  --focus: #0b1630;
  --focus-halo: #f2df4d;

  /* Tipografía */
  --font: "Archivo", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  --fs-app: clamp(2rem, 1.4rem + 3vw, 3.25rem);
  --fs-display: clamp(2.5rem, 1.4rem + 5.4vw, 5rem);

  /* Espaciado (base 4) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px; --s9: 112px;
  --gutter: clamp(16px, 4vw, 40px);
  --page: 1200px;

  /* Radios */
  --r-sm: 10px;
  --r-key: 14px;
  --r-card: 20px;
  --r-lg: 28px;
  --r-pill: 999px;

  /* Elevación */
  --shadow-1: 0 1px 2px rgb(11 22 48 / 0.06);
  --shadow-2: 0 2px 4px rgb(11 22 48 / 0.06), 0 8px 24px -8px rgb(11 22 48 / 0.16);
  --shadow-3: 0 4px 8px rgb(11 22 48 / 0.08), 0 24px 48px -16px rgb(11 22 48 / 0.28);

  /* Movimiento */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-press: 120ms;
  --t-ui: 180ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #070c1b;
    --surface: #0e1630;
    --surface-2: #152043;
    --line: #223058;
    --line-strong: #33447a;
    --text: #eef1f8;
    --text-2: #c0c8dc;
    --text-3: #98a3bd;
    --ink-edge: #000000;
    --grey-edge: #8d93a3;
    --red: #d42f2e;
    --focus: #f2df4d;
    --focus-halo: #0b1630;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 2px 4px rgb(0 0 0 / 0.3), 0 8px 24px -8px rgb(0 0 0 / 0.6);
    --shadow-3: 0 4px 8px rgb(0 0 0 / 0.3), 0 24px 48px -16px rgb(0 0 0 / 0.7);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* "hidden" siempre gana, aunque el componente declare su propio display (p. ej. .empty { display: grid }). */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.55;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }
main:focus { outline: none; }

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
h1, h2, h3 { line-height: 1.1; text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
img { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

code, .mono { font-family: var(--mono); font-size: 0.9em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--focus-halo);
  border-radius: 6px;
}

.wrap {
  width: min(var(--page), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 1.25em; height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 1em; height: 1em; }

.skip-link {
  position: absolute;
  top: var(--s2); left: var(--s2);
  z-index: 100;
  padding: var(--s3) var(--s4);
  background: var(--ink);
  color: var(--on-ink);
  border-radius: var(--r-sm);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Tipografía de sistema ---------- */
.display {
  font-size: var(--fs-display);
  font-weight: 800;
  font-stretch: 118%;
  letter-spacing: -0.025em;
  line-height: 0.98;
}
.display--app { font-size: var(--fs-app); line-height: 1.02; }

.section-title {
  font-size: var(--fs-xl);
  font-weight: 760;
  font-stretch: 112%;
  letter-spacing: -0.015em;
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow--on-dark { color: var(--yellow); }

.lede { font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem); line-height: 1.5; max-width: 38ch; }
.lede--muted { color: var(--text-2); }

/* ==========================================================================
   TECLA — componente base del sistema
   --size controla todo: radio, canto y tamaño del glifo escalan con él.
   ========================================================================== */
.key {
  --size: 56px;
  --face: var(--indigo);
  --edge: var(--indigo-edge);
  --fg: #ffffff;
  --depth: max(2px, calc(var(--size) * 0.075));
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: var(--size);
  block-size: var(--size);
  margin-block-end: var(--depth);
  border-radius: calc(var(--size) * 0.24);
  background:
    linear-gradient(155deg, rgb(255 255 255 / 0.22) 0%, rgb(255 255 255 / 0) 46%),
    var(--face);
  color: var(--fg);
  box-shadow:
    0 var(--depth) 0 0 var(--edge),
    0 calc(var(--depth) * 2) calc(var(--depth) * 3) -1px rgb(11 22 48 / 0.3),
    inset 0 1px 0 rgb(255 255 255 / 0.3);
  font-weight: 800;
  font-stretch: 112%;
  font-size: calc(var(--size) * 0.34);
  letter-spacing: -0.02em;
  line-height: 1;
  user-select: none;
  transition: transform var(--t-press) var(--ease), box-shadow var(--t-press) var(--ease);
}
.key img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

.key--indigo { --face: var(--indigo); --edge: var(--indigo-edge); --fg: #ffffff; }
.key--red    { --face: var(--red-brand); --edge: var(--red-edge); --fg: #ffffff; }
.key--yellow { --face: var(--yellow); --edge: var(--yellow-edge); --fg: var(--ink); }
.key--grey   { --face: var(--grey); --edge: var(--grey-edge); --fg: var(--ink); }
.key--ink    { --face: var(--ink); --edge: var(--ink-edge); --fg: #ffffff; }

@media (prefers-color-scheme: dark) {
  .key--ink { --face: #26325c; --edge: #0a1022; }
}

.key--xs  { --size: 26px; font-size: 13px; font-stretch: 100%; font-weight: 700; }
.key--sm  { --size: 40px; }
.key--md  { --size: 60px; }
.key--lg  { --size: 72px; }
.key--xl  { --size: clamp(84px, 18vw, 128px); }
.key--xxl { --size: clamp(84px, 20vw, 140px); font-weight: 300; font-stretch: 100%; font-size: calc(var(--size) * 0.5); }
.key--step { --size: 44px; font-size: 18px; }

/* Estado pulsado: la tecla baja y el canto casi desaparece */
.key.is-pressed,
.app-card:hover .key,
.related__item:hover .key {
  transform: translateY(calc(var(--depth) * 0.7));
  box-shadow:
    0 calc(var(--depth) * 0.3) 0 0 var(--edge),
    0 1px 2px rgb(11 22 48 / 0.25),
    inset 0 1px 0 rgb(255 255 255 / 0.3);
}

/* ---------- Botones ---------- */
.btn {
  --face: var(--ink);
  --edge: var(--ink-edge);
  --fg: #ffffff;
  --depth: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  min-height: 48px;
  padding: var(--s3) var(--s5);
  margin-block-end: var(--depth);
  border: 0;
  border-radius: var(--r-key);
  background: var(--face);
  color: var(--fg);
  box-shadow: 0 var(--depth) 0 0 var(--edge), var(--shadow-1);
  font: inherit;
  font-weight: 650;
  font-stretch: 105%;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease), box-shadow var(--t-press) var(--ease), filter var(--t-ui) var(--ease);
}
.btn:hover { filter: brightness(1.08); }
.btn:active {
  transform: translateY(calc(var(--depth) - 1px));
  box-shadow: 0 1px 0 0 var(--edge);
}
.btn--red { --face: var(--red); --edge: var(--red-edge); }
.btn--ink { --face: var(--ink); --edge: var(--ink-edge); }
@media (prefers-color-scheme: dark) {
  .btn--ink { --face: #26325c; --edge: #0a1022; }
}

.btn--key {
  --depth: 4px;
  justify-content: flex-start;
  min-height: 64px;
  padding: var(--s3) var(--s5) var(--s3) var(--s4);
  text-align: left;
}
.btn--key .icon { width: 26px; height: 26px; }
.btn__text { display: grid; gap: 2px; }
.btn__main { font-size: var(--fs-md); }
.btn__sub { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 400; opacity: 0.88; letter-spacing: 0.02em; }

.btn--pending {
  --depth: 0px;
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px dashed var(--line-strong);
  box-shadow: none;
  cursor: default;
}
.btn--pending:hover { filter: none; }
.btn--pending:active { transform: none; box-shadow: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-ui) var(--ease), transform var(--t-press) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Cabecera y pie
   ========================================================================== */
.sample-banner {
  padding: var(--s2) var(--gutter);
  background: var(--yellow);
  color: var(--ink);
  font-size: var(--fs-sm);
  text-align: center;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
  flex: none;
}
.brand__logo { width: auto; height: 34px; }
.brand__store {
  padding-left: var(--s3);
  border-left: 1px solid var(--line-strong);
  font-weight: 760;
  font-stretch: 115%;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
}
/* Modo oscuro: <picture> sirve la versión oficial en blanco (sin placa). Es más ancha que alta
   que la de color (sin el lema), así que se ajusta la altura para igualar el peso visual. */
@media (prefers-color-scheme: dark) {
  .brand__logo { height: 28px; }
}

.header-search {
  display: none;
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-inline: auto;
}
.header-search .icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.header-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s4) 0 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
}
.header-search input::placeholder { color: var(--text-3); }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; align-items: center; gap: var(--s1); }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--text-2);
  transition: background var(--t-ui) var(--ease), color var(--t-ui) var(--ease);
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav li:last-child { display: none; }
/* Móviles estrechos (<400px): con lupa en la cabecera no cabe también «Catálogo»;
   el logo ya lleva al catálogo, así que se oculta ese enlace. */
@media (max-width: 399px) {
  .site-nav__search-link + li { display: none; }
}
/* 320–359px: cabecera compacta para que logo, «Apps» y navegación quepan sin scroll horizontal. */
@media (max-width: 359px) {
  .brand { gap: var(--s2); }
  .brand__logo { height: 28px; }
  .brand__store { padding-left: var(--s2); }
  .site-nav a { padding: 0 var(--s2); }
}
@media (max-width: 359px) and (prefers-color-scheme: dark) {
  .brand__logo { height: 24px; }
}

@media (min-width: 720px) {
  .header-search { display: block; }
  .site-nav__search-link { display: none; }
  .site-nav li:last-child { display: list-item; }
  .brand__logo { height: 38px; }
}
@media (min-width: 720px) and (prefers-color-scheme: dark) {
  .brand__logo { height: 31px; }
}

.site-footer {
  margin-top: var(--s9);
  padding-block: var(--s7);
  background: var(--surface);
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.site-footer__inner {
  display: grid;
  gap: var(--s5);
}
.site-footer__brand { display: flex; align-items: center; gap: var(--s4); }
.site-footer__brand img { width: 48px; height: 48px; }
.site-footer__brand strong { color: var(--text); font-stretch: 110%; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.site-footer__links a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; color: var(--text); }
.site-footer__legal { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); }

@media (min-width: 800px) {
  .site-footer__inner { grid-template-columns: 1fr auto; align-items: center; }
  .site-footer__legal { grid-column: 1 / -1; }
}

/* ==========================================================================
   Portada · Hero con teclado destacado
   ========================================================================== */
.hero {
  --focus: var(--yellow);
  --focus-halo: var(--ink);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding-block: var(--s7);
  background: var(--ink);
  color: var(--on-ink);
}
/* Matriz de teclado al fondo, muy tenue, que se desvanece hacia el texto */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  background-position: -1px -1px;
  mask-image: radial-gradient(ellipse 60% 80% at 78% 45%, #000 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 80% at 78% 45%, #000 10%, transparent 70%);
}
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 720px; height: 720px;
  right: -220px; top: -120px;
  background: radial-gradient(closest-side, rgb(54 53 117 / 0.85), transparent);
  pointer-events: none;
}

.hero__grid { display: grid; gap: var(--s7); align-items: center; }
.hero__grid > * { min-width: 0; }
.hero__copy { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.hero__copy .display { max-width: 12ch; }
.hero__accent { color: var(--yellow); white-space: nowrap; }
.hero .lede { color: var(--on-ink-2); }

.search { display: grid; gap: var(--s2); max-width: 560px; margin-top: var(--s2); }
.search__label { font-size: var(--fs-sm); font-weight: 600; color: var(--on-ink); }
.search__field {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px;
  border-radius: calc(var(--r-key) + 4px);
  background: #ffffff;
  box-shadow: 0 4px 0 0 #b9c0d2, var(--shadow-3);
}
.search__field > .icon { margin-left: 10px; color: #58637d; }
.search__field input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-md);
}
.search__field input::placeholder { color: #58637d; }
.search__field input:focus-visible { outline: none; box-shadow: none; }
.search__field:focus-within { outline: 3px solid var(--yellow); outline-offset: 3px; }
.search__submit { margin-block-end: 0; min-height: 48px; padding-inline: var(--s5); }
.search__submit:focus-visible { box-shadow: 0 0 0 7px var(--ink); }

/* Teclado destacado: reproduce la disposición del logo (1·2 / 3·5 girado) */
.hero__featured {
  display: grid;
  gap: var(--s6);
  justify-items: center;
}
.pad {
  --pad: clamp(176px, 48vw, 280px);
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--pad) * 0.08);
  width: var(--pad);
  aspect-ratio: 1;
  transform: rotate(-33deg);
  margin-block: calc(var(--pad) * 0.08);
}
.pad__key {
  --size: calc(var(--pad) * 0.46);
  --depth: calc(var(--size) * 0.09);
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  inline-size: auto;
  block-size: auto;
  font-weight: 300;
  font-stretch: 100%;
  font-size: calc(var(--size) * 0.46);
}
.pad__num { transform: rotate(33deg) translateY(4%); display: block; }
.pad__key[data-slot="2"] .pad__num { color: #6d7487; }
.pad__key[data-slot="3"] .pad__num { color: #ffffff; text-shadow: 0 1px 0 rgb(0 0 0 / 0.12); }

/* Pasar por una destacada hunde su tecla en el teclado */
.hero__featured:has(.pad-legend__link[data-slot="1"]:is(:hover, :focus-visible)) .pad__key[data-slot="1"],
.hero__featured:has(.pad-legend__link[data-slot="2"]:is(:hover, :focus-visible)) .pad__key[data-slot="2"],
.hero__featured:has(.pad-legend__link[data-slot="3"]:is(:hover, :focus-visible)) .pad__key[data-slot="3"],
.hero__featured:has(.pad-legend__link[data-slot="5"]:is(:hover, :focus-visible)) .pad__key[data-slot="5"] {
  transform: translateY(calc(var(--depth) * 0.8));
  box-shadow: 0 calc(var(--depth) * 0.2) 0 0 var(--edge), 0 1px 2px rgb(0 0 0 / 0.3), inset 0 1px 0 rgb(255 255 255 / 0.3);
}

.pad-legend { width: 100%; max-width: 420px; }
.pad-legend__title {
  margin-bottom: var(--s2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-ink-2);
}
.pad-legend__list { border-top: 1px solid rgb(255 255 255 / 0.14); }
.pad-legend__list li { border-bottom: 1px solid rgb(255 255 255 / 0.14); }
.pad-legend__link {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 60px;
  padding: var(--s2) var(--s2);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: background var(--t-ui) var(--ease);
}
.pad-legend__link:hover { background: rgb(255 255 255 / 0.06); }
.pad-legend__num { margin-block-end: 2px; }
.pad-legend__text { display: grid; flex: 1; line-height: 1.25; }
.pad-legend__name { font-weight: 700; font-stretch: 108%; }
.pad-legend__cat { font-size: var(--fs-sm); color: var(--on-ink-2); }
.pad-legend__arrow { color: var(--on-ink-2); transition: transform var(--t-ui) var(--ease), color var(--t-ui) var(--ease); }
.pad-legend__link:hover .pad-legend__arrow,
.pad-legend__link:focus-visible .pad-legend__arrow { transform: translateX(4px); color: var(--yellow); }

@media (min-width: 960px) {
  .hero { padding-block: var(--s8) var(--s9); }
  .hero__grid { grid-template-columns: 1.15fr 0.85fr; gap: var(--s8); }
  .pad { --pad: 280px; }
}

/* ==========================================================================
   Catálogo
   ========================================================================== */
.catalog { padding-top: var(--s7); scroll-margin-top: 72px; }
/* Destinos de salto (#catalogo, #contenido): reciben foco por programa, sin anillo. */
[tabindex="-1"]:focus { outline: none; box-shadow: none; }
.catalog__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.catalog__count { font-family: var(--mono); font-size: var(--fs-sm); color: var(--text-3); }

.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); margin-bottom: var(--s5); }

.chips {
  margin-inline: calc(var(--gutter) * -1);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent 100%);
}
.chips::-webkit-scrollbar { display: none; }
.chips ul { display: flex; gap: var(--s2); width: max-content; box-sizing: content-box; padding: var(--s2) var(--gutter) var(--s3); }
.chips li { scroll-snap-align: start; }

.chip {
  --depth: 3px;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-key);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 var(--depth) 0 0 var(--line-strong);
  font-size: var(--fs-sm);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--t-press) var(--ease), box-shadow var(--t-press) var(--ease), background var(--t-ui) var(--ease);
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 0 var(--line-strong); }
.chip[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
  box-shadow: 0 1px 0 0 var(--ink-edge);
  transform: translateY(2px);
}
@media (prefers-color-scheme: dark) {
  .chip[aria-current="true"] { background: var(--yellow); border-color: var(--yellow); color: var(--ink); box-shadow: 0 1px 0 0 var(--yellow-edge); }
}
.chip__n {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-3);
}
.chip[aria-current="true"] .chip__n { color: inherit; opacity: 0.75; }

.segmented ul {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segmented a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  transition: background var(--t-ui) var(--ease), color var(--t-ui) var(--ease);
}
.segmented a:hover { color: var(--text); }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
/* Móvil: el control ocupa el ancho disponible y reparte las opciones, en vez de desbordar a 320px. */
@media (max-width: 599px) {
  .segmented ul { display: flex; width: 100%; }
  .segmented li { flex: 1 1 auto; }
  .segmented a { width: 100%; justify-content: center; padding: 0 var(--s2); }
}
/* 5 opciones (Todas · Windows · Android · iOS · Web) en 320px: menos relleno lateral. */
@media (max-width: 379px) {
  .segmented ul { gap: 0; padding: 3px; }
  .segmented a { padding: 0 4px; }
}

@media (min-width: 900px) {
  /* Categorías en una fila completa y plataformas debajo: con 7+ categorías no caben lado a lado. */
  .chips { margin-inline: 0; mask-image: none; -webkit-mask-image: none; overflow: visible; }
  .chips ul { flex-wrap: wrap; width: auto; padding: var(--s1) 0 var(--s2); }
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--s4);
}

/* Tarjeta de app */
.app-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr auto;
  column-gap: var(--s4);
  row-gap: var(--s3);
  height: 100%;
  padding: var(--s5) var(--s5) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-ui) var(--ease), box-shadow var(--t-ui) var(--ease), border-color var(--t-ui) var(--ease);
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.app-card:has(.app-card__link:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 7px var(--focus-halo); }
.app-card__title { align-self: center; min-width: 0; }
.app-card__name { font-size: var(--fs-lg); font-weight: 740; font-stretch: 108%; letter-spacing: -0.01em; }
.app-card__link { text-decoration: none; }
.app-card__link:focus-visible { outline: none; box-shadow: none; }
.app-card__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.app-card__meta { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); }
.app-card__tagline {
  grid-column: 1 / -1;
  color: var(--text-2);
  font-size: 0.975rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.app-card__foot {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}
.app-card__version { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); }

.platforms { display: flex; flex-wrap: wrap; gap: 6px; }
.platform {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s3);
  padding: var(--s8) var(--s4);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-card);
  text-align: center;
  color: var(--text-2);
}
.empty__title { font-size: var(--fs-lg); font-weight: 720; color: var(--text); margin-top: var(--s3); }
.empty .btn { margin-top: var(--s3); }

/* ==========================================================================
   Ficha de app
   ========================================================================== */
.detail { padding-top: var(--s5); }

.crumbs ol { display: flex; flex-wrap: wrap; gap: var(--s2); font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); }
.crumbs li + li::before { content: "/"; margin-right: var(--s2); color: var(--line-strong); }
.crumbs a { display: inline-block; padding-block: 12px; color: var(--text-2); }
.crumbs span { display: inline-block; padding-block: 12px; }

.detail-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s5);
  align-items: center;
  margin-top: var(--s3);
}
.detail-head__text { display: grid; gap: var(--s2); min-width: 0; }
.detail-head__tagline { color: var(--text-2); font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem); max-width: 52ch; }
.detail-head__dev { font-size: var(--fs-sm); font-weight: 600; color: var(--red); }
.detail-head__dev a { color: inherit; }
@media (prefers-color-scheme: dark) { .detail-head__dev { color: #ff8a80; } }
@media (max-width: 560px) {
  .detail-head { grid-template-columns: 1fr; gap: var(--s4); }
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: var(--s6);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  overflow: hidden;
}
.stats__item { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.stats__item:nth-child(odd) { border-right: 1px solid var(--line); }
.stats__item:nth-last-child(-n + 2) { border-bottom: 0; }
/* Con 3 datos (apps en la nube) el último ocupa la fila entera en vez de dejar un hueco. */
.stats__item:nth-child(3):last-child { grid-column: 1 / -1; border-right: 0; }
.stats__item:nth-child(2):nth-last-child(2) { border-bottom: 1px solid var(--line); }
.stats dt { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.stats dd { margin-top: 2px; font-size: var(--fs-md); font-weight: 650; }
@media (min-width: 720px) {
  .stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .stats__item,
  .stats__item:nth-child(2):nth-last-child(2) { border-bottom: 0; border-right: 1px solid var(--line); }
  .stats__item:nth-child(3):last-child { grid-column: auto; }
  .stats__item:last-child { border-right: 0; }
}

.get { margin-top: var(--s5); }
.get__list { display: grid; gap: var(--s3); }
.get__list .btn { width: 100%; }
.get__note { margin-top: var(--s3); font-size: var(--fs-sm); color: var(--text-3); }
@media (min-width: 720px) {
  .get__list { display: flex; flex-wrap: wrap; }
  .get__list .btn { width: auto; min-width: 280px; }
}

.detail-layout { display: grid; gap: var(--s7); margin-top: var(--s7); }
.detail-main { display: grid; gap: var(--s8); min-width: 0; }
@media (min-width: 1100px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s8); align-items: start; }
  .detail-aside { position: sticky; top: 96px; }
}

.cover {
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
}
.cover img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; }

.block { display: grid; gap: var(--s4); }
.block__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.block__intro { margin-top: calc(var(--s2) * -1); color: var(--text-3); font-size: var(--fs-sm); }
.prose { display: grid; gap: var(--s3); max-width: 68ch; color: var(--text-2); }
.prose p:first-child { color: var(--text); font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem); }

/* Puntos clave con viñeta-tecla */
.highlights { display: grid; gap: var(--s3); margin-top: var(--s2); }
.highlights li {
  /* Viñeta y texto en rejilla: la viñeta se alinea con la PRIMERA línea del texto,
     no con el centro de la caja (que crece cuando la tarjeta vecina tiene dos líneas). */
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: var(--s3);
  align-items: start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-key);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 560;
  line-height: 1.45;
}
.highlights li::before {
  content: "";
  width: 16px; height: 16px;
  /* centra la tecla en la altura de una línea (1lh), contando su canto de 2px */
  margin-top: calc((1lh - 18px) / 2);
  border-radius: 5px;
  background: var(--yellow);
  box-shadow: 0 2px 0 var(--yellow-edge);
}
@media (min-width: 640px) { .highlights { grid-template-columns: 1fr 1fr; } }

/* Galería */
.gallery__controls { display: flex; gap: var(--s2); }
.gallery__track {
  display: flex;
  gap: var(--s4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0;
  padding-bottom: var(--s3);
  border-radius: var(--r-card);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
/* Fotos apaisadas a su proporción; capturas verticales (móvil, kiosco) todas a la misma
   altura, como en las tiendas de apps. El ancho de cada una sale de su proporción. */
.gallery { --gallery-h: clamp(340px, 92vw, 460px); }
.gallery__track { align-items: flex-start; }
.gallery__item { flex: 0 0 min(85vw, 560px); scroll-snap-align: start; }
.gallery__item img,
.gallery__item .media-slot { width: 100%; border-radius: var(--r-card); }
.gallery__item img { height: auto; }
.gallery__item--portrait { flex: none; }
.gallery__item--portrait figure { display: table; }
.gallery__item--portrait img {
  width: auto;
  height: var(--gallery-h);
  max-width: 85vw;
  object-fit: cover;
  border: 1px solid var(--line);
}
.gallery__item figcaption { margin-top: var(--s2); font-size: var(--fs-sm); color: var(--text-3); }
.gallery__item--portrait figcaption { display: table-caption; caption-side: bottom; }

/* Hueco de imagen pendiente: honesto, no una imagen inventada */
.media-slot {
  display: grid;
  width: 100%;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-card);
  background:
    repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--line) 45%, transparent) 10px 11px),
    var(--surface);
  color: var(--text-3);
  text-align: center;
}
/* El SVG da la altura según su viewBox; el texto se superpone centrado en la misma celda. */
.media-slot > * { grid-area: 1 / 1; }
.media-slot__sizer { display: block; width: 100%; height: auto; }
.media-slot__text {
  display: grid;
  place-self: center;
  justify-items: center;
  gap: var(--s1);
  padding: var(--s4);
}
.media-slot__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); max-width: 34ch; }
.media-slot__ratio { font-family: var(--mono); font-size: var(--fs-xs); }

/* Guía paso a paso: teclas numeradas unidas por un hilo */
.guide { display: grid; }
.guide__step {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: var(--s4);
  padding-bottom: var(--s6);
}
.guide__step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 21px;
  top: 56px;
  bottom: 8px;
  width: 2px;
  background: repeating-linear-gradient(var(--line-strong) 0 6px, transparent 6px 12px);
}
.guide__step:last-child { padding-bottom: 0; }
.guide__body { display: grid; gap: var(--s2); padding-top: 8px; min-width: 0; color: var(--text-2); }
.guide__title { font-size: var(--fs-lg); font-weight: 720; font-stretch: 106%; color: var(--text); }
.guide__media { margin-top: var(--s3); max-width: 560px; }
.guide__media img { border-radius: var(--r-card); }
.guide__media--portrait { max-width: 240px; }
/* Los huecos de captura pendiente ocupan menos que una imagen real */
.guide__media:has(.media-slot) { max-width: 400px; }
.guide__media--portrait:has(.media-slot) { max-width: 200px; }

.tip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2);
  margin-top: var(--s1);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.tip__label {
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Novedades */
.changelog { display: grid; gap: var(--s3); }
.changelog__entry {
  display: grid;
  gap: var(--s2);
  padding: var(--s4) var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.changelog__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3); font-size: var(--fs-sm); color: var(--text-3); }
.changelog__version { font-family: var(--mono); font-weight: 500; font-size: var(--fs-md); color: var(--text); }
.changelog__meta time { margin-left: auto; font-family: var(--mono); font-size: var(--fs-xs); }
.changelog__list { padding-left: 1.1em; color: var(--text-2); }
.changelog__list li::marker { color: var(--red-brand); }

/* Panel lateral */
.detail-aside { display: grid; gap: var(--s4); }
.panel {
  display: grid;
  gap: var(--s3);
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}
.panel__title {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.panel__link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: var(--fs-sm); font-weight: 650; }

.facts > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s3);
  padding-block: var(--s2);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-3); }
.facts dd { display: grid; justify-items: end; text-align: right; font-weight: 600; }
.facts__sub { font-size: var(--fs-xs); font-weight: 400; color: var(--text-3); }
.facts__hash { grid-template-columns: 1fr !important; }
.facts__hash dd { justify-items: start; text-align: left; }
.facts__hash code { font-size: 11px; word-break: break-all; color: var(--text-2); }

.checklist { display: grid; gap: var(--s2); font-size: var(--fs-sm); color: var(--text-2); }
.checklist li { position: relative; padding-left: 24px; }
.checklist li::before {
  content: "";
  position: absolute;
  left: 2px; top: 0.45em;
  width: 10px; height: 6px;
  border-left: 2px solid var(--red);
  border-bottom: 2px solid var(--red);
  transform: rotate(-45deg);
}

.related { display: grid; gap: var(--s1); }
.related__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2);
  margin-inline: calc(var(--s2) * -1);
  border-radius: var(--r-sm);
  transition: background var(--t-ui) var(--ease);
}
.related__item:hover { background: var(--surface-2); }
.related__item .key { margin-block-end: 3px; }
.related__item > div { display: grid; line-height: 1.3; }
.related__link { font-weight: 700; text-decoration: none; }
.related__link::after { content: ""; position: absolute; inset: 0; }
.related__meta { font-size: var(--fs-sm); color: var(--text-3); }

/* ==========================================================================
   404 / Error
   ========================================================================== */
.lost {
  display: grid;
  justify-items: center;
  gap: var(--s5);
  padding-block: var(--s8) var(--s6);
  text-align: center;
}
.lost .lede { max-width: 46ch; }
.lost__keys { display: flex; gap: clamp(10px, 3vw, 24px); margin-bottom: var(--s4); }
.lost__keys .key:nth-child(1) { rotate: -8deg; }
.lost__keys .key:nth-child(2) { rotate: 4deg; translate: 0 12px; }
.lost__keys .key:nth-child(3) { rotate: -3deg; }
.lost__keys .key:only-child { rotate: -8deg; translate: none; }

/* ==========================================================================
   Movimiento reducido
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .app-card:hover { transform: none; }
}

@media (forced-colors: active) {
  .key, .btn, .chip { border: 1px solid CanvasText; }
  .chip[aria-current="true"], .segmented a[aria-current="true"] { outline: 2px solid Highlight; }
}
