:root {
  --container-max: 1280px;

  --gap-col: 32px;
  --gap-row: 64px;

  --radius-media: 30px;

  --font: "Geist", "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  --text: #111;
  --muted: #555;

  --tile-ar-w: 3;
  --tile-ar-h: 4;

  --accent: #ff0044;

  --space-8: 8px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;
  --space-128: 128px;

  --article-max: 900px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
}

img, video { display: block; max-width: 100%; }

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* =========================
   Type
========================= */
.text-h1 { font-size: 48px; font-weight: 400; line-height: 1.05; letter-spacing: -0.02em; }
.text-h2 { font-size: 32px; font-weight: 400; line-height: 1.2; letter-spacing: -0.01em; }

.text-title { font-size: 24px; font-weight: 400; line-height: 1.35; }
.text-small { font-size: 14px; font-weight: 400; line-height: 1.55; }
.text-muted { color: var(--muted); }

.mb-24 { margin-bottom: var(--space-24); }
.mb-32 { margin-bottom: var(--space-32); }
.mb-64 { margin-bottom: var(--space-64); }
.mb-128 { margin-bottom: var(--space-128); }

/* Clamp 2 lines (title/desc) */
.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2; /* para calmar al linter */

  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================
   Profile block
========================= */
.profile {
  padding-top: 56px;
  margin-bottom: var(--space-128);
}

.profile-top,
.profile-bottom {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: start;
}

.profile-top { margin-bottom: 32px; }

.profile-desc {
  font-size: 24px;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-line;
  margin: 0;
}

.profile-avatar-wrap {
  display: flex;
  justify-content: flex-end;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 999px;
  object-fit: cover;
  background: #e6e6e6;
}

@media (min-width: 1024px) {
  .profile-top {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .profile-avatar-wrap { justify-content: flex-end; }
}

@media (max-width: 1023.98px) and (min-width: 640px) {
  .text-h1 { font-size: 36px; }
  .profile-desc { font-size: 20px; }
  .profile-avatar { width: 100px; height: 100px; }
}

@media (max-width: 639.98px) {
  .text-h1 { font-size: 24px; margin-bottom: 32px; }
  .profile-desc { font-size: 16px; }
  .profile-avatar { width: 80px; height: 80px; }
  .container { padding: 0 20px; }
}

.profile-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
  border-radius: 10px;
  background: #000;
  color: #fff;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
}

.profile-cta svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.profile-socials {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
  align-items: center;
}

.profile-socials a {
  display: inline-flex;
  width: 24px;
  height: 24px;
  color: #000;
  text-decoration: none;
}

.profile-socials svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

@media (max-width: 380px) {
  .profile-socials { gap: 12px; }
}

/* =========================
   Grid Title spacing
========================= */
#gridTitle {
  margin-bottom: var(--space-64);
}

/* =========================
   Filter
========================= */
.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 32px;

  margin-bottom: var(--space-64);
}

.filter__item {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;

  font-family: var(--font);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;

  color: var(--text);
  cursor: pointer;
}

.filter__item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--accent);

  transform: scaleX(0);
  transform-origin: left;
  transition: transform 220ms ease;
}

.filter__item[aria-selected="true"] {
  color: var(--accent);
}

.filter__item[aria-selected="true"]::after {
  transform: scaleX(1);
}

.filter__item:focus-visible {
  outline: 2px solid rgba(255, 0, 68, 0.35);
  outline-offset: 6px;
  border-radius: 6px;
}

@media (max-width: 639.98px) {
  .filter { gap: 16px; }
  .filter__item { font-size: 16px; }
}

/* =========================
   Grid
========================= */
.grid {
  display: grid;
  column-gap: var(--gap-col);
  row-gap: var(--gap-row);
  grid-template-columns: 1fr;
  grid-auto-flow: row dense;
  --double-h: auto;
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* >=1024: por defecto 3 cols, pero si el JSON define data-cols, lo respeta (incluye pantallas grandes) */
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .grid[data-cols="1"] { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .grid[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid[data-cols="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.grid-item { min-width: 0; }

.grid-item.is-double { grid-column: auto; grid-row: auto; }
@media (min-width: 1024px) { .grid-item.is-double { grid-column: span 2; } }

@media (max-width: 1023.98px) {
  .grid-item.is-double { grid-column: auto !important; grid-row: auto !important; }
}

.pos-r1c1-2, .pos-r3c3-4, .pos-r5c1-2 { grid-column: auto; grid-row: auto; }

/* Mantienes el “posicionamiento” solo para pantallas grandes.
   Ahora también aplica desde 1024+ porque ya no existe el breakpoint 1280 exclusivo.
   Si quieres conservarlo solo para 1280+, cambia min-width: 1024px por 1280px aquí. */
@media (min-width: 1024px) {
  .pos-r1c1-2 { grid-row: 1; grid-column: 1 / span 2; }
  .pos-r3c3-4 { grid-row: 3; grid-column: 3 / span 2; }
  .pos-r5c1-2 { grid-row: 5; grid-column: 1 / span 2; }
}

.card { display: block; text-decoration: none; color: inherit; }

.card-media {
  border-radius: var(--radius-media);
  overflow: hidden;
  background: #e6e6e6;
}

.grid-item:not(.is-double) .card-media {
  aspect-ratio: var(--tile-ar-w) / var(--tile-ar-h);
}

@media (min-width: 1024px) {
  .grid-item.is-double .card-media { height: var(--double-h); }
}

@media (max-width: 1023.98px) {
  .grid-item.is-double .card-media {
    height: auto;
    aspect-ratio: var(--tile-ar-w) / var(--tile-ar-h);
  }
}

.card-media img,
.card-media video {
  width: 100%;
  height: 100%;
  object-position: center;
}

.grid-item:not(.is-double) .card-media img {
  object-fit: contain;
  background: #e6e6e6;
}

@media (min-width: 1024px) {
  .grid-item.is-double .card-media img,
  .grid-item.is-double .card-media video { object-fit: cover; }
}

@media (max-width: 1023.98px) {
  .grid-item.is-double .card-media img,
  .grid-item.is-double .card-media video {
    object-fit: contain;
    background: #e6e6e6;
  }
}

.card-title { margin-top: var(--space-16); }
.card-desc  { margin-top: 6px; }

@media (hover: hover) {
  .card:hover .card-media { filter: brightness(0.985); }
}

/* =========================
   Article view (Markdown)
========================= */
.article {
  padding-top: 56px;
  padding-bottom: 80px;
}

.article__header {
  max-width: var(--article-max);
  margin: 0 auto 24px auto;
}

.article__back {
  display: inline-block;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}

.article__back:hover {
  text-decoration: underline;
}

.article__content {
  max-width: var(--article-max);
  margin: 0 auto;
}

/* Typography */
.article__content h1 {
  font-size: 40px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 16px 0;
}

.article__content h2 {
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 40px 0 12px 0;
}

.article__content h3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  margin: 28px 0 10px 0;
}

.article__content h4,
.article__content h5,
.article__content h6 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin: 22px 0 8px 0;
}

.article__content p {
  font-size: 16px;
  line-height: 1.75;
  margin: 0 0 14px 0;
  color: var(--text);
}

.article__content a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article__content hr {
  border: 0;
  border-top: 1px solid rgba(0,0,0,0.12);
  margin: 28px 0;
}

.article__content blockquote {
  margin: 18px 0;
  padding: 0 0 0 16px;
  border-left: 3px solid rgba(0,0,0,0.18);
  color: var(--muted);
}

.article__content ul,
.article__content ol {
  margin: 0 0 16px 22px;
  padding: 0;
}

.article__content li {
  margin: 6px 0;
  line-height: 1.7;
}

.article__content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

.article__content pre {
  margin: 16px 0 22px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(0,0,0,0.06);
  overflow: auto;
}

.article__content pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  display: block;
  font-size: 13px;
  line-height: 1.65;
}

.article__content img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  margin: 18px 0;
  background: #e6e6e6;
}

@media (max-width: 639.98px) {
  .article__content h1 { font-size: 28px; }
  .article__content h2 { font-size: 22px; margin-top: 28px; }
}

/* =========================
   Lightbox (overlay) — FIXED + CAPTION
========================= */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.lightbox[hidden] {
  display: none;
}

/* Backdrop real */
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: #B3B3B3;
}

/* Inner “canvas” con padding visible alrededor (inset) */
.lightbox__inner {
  position: fixed;           /* IMPORTANTE: fijo al viewport */
  inset: 24px;               /* mobile default */
  display: grid;
  place-items: center;
}

/* Desktop: inset 64px (tu requerimiento) */
@media (min-width: 1024px) {
  .lightbox__inner {
    inset: 64px;
  }
}

/* Media container: columna (imagen arriba, caption abajo) */
.lightbox__media {
  width: 100%;
  height: 100%;
  display: flex;             /* en vez de grid */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* Si tu JS mete <picture>, lo centramos y lo hacemos “tomar” el espacio */
.lightbox__media picture {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Imagen: NO usar height:100% porque eso rompe el padding abajo.
   Mejor max-height calculado por inset + un extra para caption.
*/
.lightbox__media img {
  max-width: 100%;
  max-height: calc(100vh - 48px - 90px); /* mobile: 24*2 + ~caption */
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Desktop: respeta inset 64px y deja espacio extra para caption */
@media (min-width: 1024px) {
  .lightbox__media img {
    max-height: calc(100vh - 128px - 90px); /* 64*2 + ~caption */
  }
}

/* Caption debajo */
.lightbox__caption {
  width: min(900px, 100%);
  padding: 0 8px;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(0,0,0,0.78);
  user-select: none;
}

/* Iframe (se usa dentro de wrapper) */
.lightbox__media iframe {
  border: 0;
  display: block;
}

/* Wrapper video 16:9 para YouTube/Vimeo */
.lightbox__video {
  width: 100%;
  height: auto;
  max-width: 1200px;
  aspect-ratio: 16 / 9;
}

.lightbox__video iframe {
  width: 100%;
  height: 100%;
}

/* Close: SIEMPRE respecto al viewport */
.lightbox__close {
  position: fixed;
  top: 32px;
  right: 32px;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  z-index: 2;
}

.lightbox__close svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Counter: SIEMPRE respecto al viewport */
.lightbox__counter {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.08em;
  color: #000;
  user-select: none;
  z-index: 2;
}
