/* Componentes — el sitio (galería y páginas). Estilo propio y mínimo; los componentes viven en /raw.
   Usa los colores de tokens.css para que el sitio y los componentes cambien juntos de tema. */

:root {
  --site-w: 1200px;
  --site-gutter: clamp(16px, 4vw, 32px);
  --preview-bg: color-mix(in srgb, var(--background), var(--color-black) 2.5%);
  --preview-line: color-mix(in srgb, var(--foreground) 5%, transparent);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
.dark { --preview-bg: color-mix(in srgb, var(--background), var(--color-white) 3%); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
html[lang="es"] [data-l="en"], html[lang="en"] [data-l="es"] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: 8px; z-index: 50; padding: 8px 12px; border-radius: 8px; background: var(--foreground); color: var(--background); text-decoration: none; transform: translateY(-200%); }
.skip:focus { transform: none; }
.wrap { max-width: var(--site-w); margin: 0 auto; padding-inline: var(--site-gutter); }

/* ---------- barra ---------- */
.bar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--background) 86%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.bar .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; letter-spacing: -.01em; flex: none; }
.brand svg { width: 20px; height: 20px; }
.bar-search { flex: 1; display: flex; justify-content: center; }
.search { position: relative; width: min(100%, 360px); }
.search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; translate: 0 -50%; color: var(--muted-foreground); pointer-events: none; }
.search input { width: 100%; height: 34px; padding: 0 44px 0 32px; border: 1px solid var(--input); border-radius: 9px; background: var(--background); outline: none; font-size: 13px; transition: border-color .15s, box-shadow .15s; }
.search input::placeholder { color: var(--muted-foreground); }
.search input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 24%, transparent); }
.search kbd { position: absolute; right: 8px; top: 50%; translate: 0 -50%; font: 11px var(--font-sans); color: var(--muted-foreground); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.bar-end { display: flex; align-items: center; gap: 4px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted-foreground); cursor: pointer; text-decoration: none; font-size: 12px; font-weight: 500; }
.icon-btn:hover { background: var(--accent); color: var(--foreground); }
.icon-btn svg { width: 16px; height: 16px; }
.dark .icon-sun, :root:not(.dark) .icon-moon { display: none; }
.lang { display: flex; padding: 2px; border-radius: 9px; background: var(--muted); }
.lang button { border: 0; background: none; height: 28px; min-width: 32px; border-radius: 7px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px #0000000d; }
.dark .lang button[aria-pressed="true"] { background: var(--input); }
.home-link { font-size: 12px; color: var(--muted-foreground); text-decoration: none; padding: 0 8px; }
.home-link:hover { color: var(--foreground); }

/* ---------- inicio ---------- */
.hero { padding-block: 56px 24px; display: grid; gap: 10px; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; font-weight: 600; letter-spacing: -.03em; }
.hero p { color: var(--muted-foreground); max-width: 56ch; font-size: 15px; }
.hero .meta { font-size: 12px; color: var(--muted-foreground); display: flex; flex-wrap: wrap; gap: 4px 16px; }
.hero .meta a { text-underline-offset: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-block: 8px 24px; }
.chip { height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: transparent; font-size: 13px; color: var(--muted-foreground); cursor: pointer; }
.chip:hover { color: var(--foreground); background: var(--accent); }
.chip[aria-pressed="true"] { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px 16px; padding-bottom: 96px; }
.card { display: grid; gap: 10px; text-decoration: none; }
.card-preview { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--preview-bg); container-type: inline-size; transition: border-color .2s; }
.card-preview iframe { position: absolute; top: 0; left: 0; width: 250%; height: 250%; border: 0; transform: scale(.4); transform-origin: 0 0; pointer-events: none; background: transparent; }
.card-preview--wide iframe { width: 444%; height: 444%; transform: scale(.225); }
.card:hover .card-preview { border-color: color-mix(in srgb, var(--foreground) 18%, transparent); }
.card:focus-visible { outline: none; }
.card:focus-visible .card-preview { outline: 2px solid var(--ring); outline-offset: 2px; }
.card-name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 500; }
.card-name span:last-child { font-size: 12px; font-weight: 400; color: var(--muted-foreground); }
.empty { padding: 48px 0; color: var(--muted-foreground); }

/* ---------- página de componente ---------- */
.layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 40px; padding-block: 32px 96px; }
.side { position: sticky; top: 88px; align-self: start; max-height: calc(100dvh - 120px); overflow-y: auto; overflow-x: hidden; font-size: 13px; }
.side h2 { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); margin: 20px 0 6px; }
.side h2:first-child { margin-top: 0; }
.side a { display: block; padding: 4px 10px; margin-inline: -10px; border-radius: 7px; color: var(--muted-foreground); text-decoration: none; }
.side a:hover { color: var(--foreground); background: var(--accent); }
.side a[aria-current="page"] { color: var(--foreground); background: var(--accent); font-weight: 500; }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; min-width: 0; }
.section, .code-block, .code-panel, .viewer { min-width: 0; }
.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted-foreground); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--foreground); }
.title { display: grid; gap: 8px; }
.title h1 { font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -.025em; }
.title p { color: var(--muted-foreground); font-size: 15px; max-width: 62ch; }
.credit { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted-foreground); }
.credit a { text-underline-offset: 3px; }

.viewer { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--background); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--border); }
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--muted); }
.seg button { height: 28px; padding: 0 10px; border: 0; border-radius: 7px; background: none; font-size: 12px; font-weight: 500; color: var(--muted-foreground); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button svg { width: 14px; height: 14px; }
.seg button[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px #0000000d; }
.dark .seg button[aria-pressed="true"] { background: var(--input); }
.viewer-tools { display: flex; align-items: center; gap: 4px; }
.stage { background: var(--preview-bg); background-image: radial-gradient(var(--preview-line) 1px, transparent 1px); background-size: 16px 16px; display: flex; justify-content: center; }
.stage iframe { display: block; width: 100%; height: var(--h, 440px); border: 0; background: transparent; transition: width .3s var(--ease-out); }
.stage[data-device="mobile"] iframe { width: 390px; max-width: 100%; border-inline: 1px solid var(--border); }

.code-block { display: grid; gap: 10px; }
.code-tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.code { margin: 0; max-height: 440px; overflow: auto; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--preview-bg); font: 12.5px/1.6 var(--font-mono); tab-size: 2; white-space: pre; }
.copy { height: 30px; padding: 0 12px; border: 1px solid var(--input); border-radius: 8px; background: var(--background); font-size: 12px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.copy:hover { background: var(--accent); }
.copy svg { width: 14px; height: 14px; }
.code-note { font-size: 12px; color: var(--muted-foreground); }
.code-note a { text-underline-offset: 3px; }

.section { display: grid; gap: 12px; }
.section h2 { font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
.steps { counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 24px 1fr; gap: 10px; color: var(--muted-foreground); }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); color: var(--foreground); font-size: 12px; font-weight: 500; }
.steps code, .prose code { font: 12px var(--font-mono); padding: 1px 5px; border-radius: 5px; background: var(--muted); color: var(--foreground); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: grid; gap: 8px; align-content: start; }
.box h3 { font-size: 13px; font-weight: 600; }
.list li { position: relative; padding-left: 16px; color: var(--muted-foreground); }
.list li + li { margin-top: 6px; }
.list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .5; }
.list.yes li::before { background: var(--success); opacity: 1; }
.list.no li::before { background: var(--destructive); opacity: 1; }
.kbd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kbd-table td { padding: 8px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.kbd-table td:first-child { width: 40%; padding-right: 16px; }
.kbd-table tr:last-child td { border-bottom: 0; }
kbd { font: 11px var(--font-sans); padding: 2px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--background); white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: 11.5px var(--font-mono); padding: 2px 8px; border-radius: 6px; background: var(--muted); color: var(--muted-foreground); }
.pager { display: flex; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.pager a { display: grid; gap: 2px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; min-width: 0; }
.pager a:hover { background: var(--accent); }
.pager small { font-size: 12px; color: var(--muted-foreground); }
.pager .next { text-align: right; margin-left: auto; }

.foot { border-top: 1px solid var(--border); }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 24px; font-size: 12px; color: var(--muted-foreground); }
.foot a { text-underline-offset: 3px; }

/* toast del sitio (copiar) */
.site-toast { position: fixed; left: 50%; bottom: 24px; translate: -50% 16px; padding: 8px 14px; border-radius: 10px; background: var(--foreground); color: var(--background); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, translate .3s var(--ease-out); z-index: 60; }
.site-toast.on { opacity: 1; translate: -50% 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding-top: 20px; }
  .side { display: none; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .bar .wrap { gap: 8px; }
  .brand span, .home-link { display: none; }
  .search kbd { display: none; }
  .search input { padding-right: 10px; }
  .hero { padding-top: 32px; }
  .grid { grid-template-columns: 1fr; }
  .title h1 { font-size: 24px; }
  .viewer-tools .device { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 1ms !important; } }
