/* Software: sobrio, a la mitxela. Negro absoluto, texto, líneas finas.
   Categorías como pestañas, un riel con todos los proyectos de la categoría
   y un proyecto a la vez, con sus métricas. */

:root {
  --text: #e8e8e8;
  --dim: #8c8c8c;
  --faint: #555;
  --line: #222;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Hubot Sans", sans-serif;
}

/* negro absoluto: identidad del sitio (decisión de RemLam sobre la regla genérica de no-#000) */
body {
  background: #000;
  overflow-x: hidden;
}

#nebula {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 3px;
}

/* ---------- Encabezado ---------- */
.head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 48px) 0;
}
.head .back img {
  width: 42px;
  height: auto;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.head .back:hover img {
  opacity: 1;
}
.emblem {
  width: clamp(56px, 8vw, 80px);
  height: auto;
}

/* ---------- Pestañas ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px clamp(10px, 2vw, 22px);
  padding: 10px clamp(16px, 4vw, 48px) 0;
}
.tab {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--dim);
  font: inherit;
  font-size: 0.95rem;
  padding: 8px 2px;
  cursor: pointer;
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}
.tab .n {
  font-size: 0.7rem;
  color: var(--faint);
  margin-left: 3px;
}

/* ---------- Riel + proyecto ---------- */
.stage {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: clamp(20px, 4vw, 56px);
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px clamp(16px, 4vw, 48px) 64px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
}
.rail button {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  color: var(--dim);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  padding: 5px 0;
  cursor: pointer;
}
.rail button:hover {
  color: var(--text);
}
.rail button[aria-current="true"] {
  color: var(--text);
}
.rail button[aria-current="true"] .name {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(var(--g));
}

.project {
  position: relative;
  transition: opacity 0.15s ease;
}
.project.swap {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .project {
    transition: none;
  }
}

/* título y repo en una fila: los contadores empujan, no se encima nada */
.title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.project h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* logo del proyecto a la altura de las mayúsculas del título */
.project h1 .logo {
  height: 0.9em;
  width: auto;
  margin-right: 0.3em;
  vertical-align: -0.06em;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  color: var(--dim);
  font-size: 0.88rem;
  margin-bottom: 26px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.techs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
/* todos a la misma altura; los logotipos anchos crecen a lo ancho */
.techs .ti {
  height: 1.3rem;
  width: auto;
  max-width: 4.6rem;
  display: block;
}
/* logos que se pierden en el negro (iconTone en catalog.js) */
.techs .ti.invert {
  filter: invert(1);
}
.techs .ti.lift {
  filter: brightness(1.9);
}
.techs .ti.lift-max {
  filter: brightness(3.2) saturate(0.8);
}
.techs .tag {
  font-size: 0.78rem;
  color: var(--dim);
}
.last {
  font-variant-numeric: tabular-nums;
}
/* enlaces: esquina superior derecha; documentación y repo (con estrellas y forks antes del ícono) */
.links {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}
.link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}
.link:hover {
  color: var(--text);
}
.link svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}
.link .count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.link .count svg {
  width: 14px;
  height: 14px;
}

/* descripción y métricas lado a lado */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(20px, 4vw, 48px);
  align-items: start;
  margin-bottom: 30px;
}
.desc {
  font-size: 1.04rem;
  line-height: 1.7;
  margin: 0;
  max-width: 64ch;
}
/* métricas: etiqueta y valor en una línea, barra fina con el percentil debajo */
.metrics {
  margin: 0;
  display: grid;
  gap: 18px;
}
.metric {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  font-size: 0.88rem;
}
.metric dt {
  color: var(--dim);
}
.metric dd {
  display: contents;
}
.metric .v {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}
.metric .bar {
  grid-column: 1 / -1;
  height: 2px;
  margin-top: 8px;
  background: #262626;
}
.metric .bar span {
  display: block;
  height: 100%;
  background: var(--text);
}
.metric .pct {
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--faint);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.gallery figure {
  margin: 0;
}
.gallery figure:first-child:not(:only-child) {
  grid-column: 1 / -1;
}
.gallery img {
  width: 100%;
  height: auto;
  display: block;
}
.gallery figcaption {
  font-size: 0.78rem;
  color: var(--dim);
  margin-top: 6px;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--faint);
}
.pager button {
  background: none;
  border: none;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
  padding: 6px 0;
  min-height: 32px;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pager button:hover {
  color: var(--text);
}

.credits {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 28px;
  font-size: 0.75rem;
  color: var(--faint);
}
.credits a {
  color: var(--dim);
}

/* ---------- Vertical ---------- */
@media (max-width: 820px) {
  .tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar,
  .rail::-webkit-scrollbar {
    display: none;
  }
  .tab {
    flex: none;
  }
  .stage {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 18px;
  }
  .rail {
    position: static;
    flex-direction: row;
    gap: 18px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  .rail button {
    flex: none;
    white-space: nowrap;
  }
  .about {
    grid-template-columns: minmax(0, 1fr);
  }
  .metrics {
    max-width: 420px;
  }
}
