/* ═════════ Vista de cuadrícula (PRUEBA) ═════════
   Se activa con ?vista=cuadricula y &cols=2 o &cols=3 (clase .g-mode en <html>).
   Mismo HTML y contenido; aquí solo cambia la disposición. En móvil: una columna. */

.cols-switch { display: none; }

.g-mode .workhead { padding-block: clamp(2rem, 5vw, 3rem) 1rem; max-width: calc(1400px + 2 * var(--pad-x)); }
.g-mode .cols-switch {
  display: none;   /* decidido: 2 columnas */ margin-left: auto; padding: 4px; gap: 4px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--bg2);
}
.g-mode .cols-switch a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.75rem; min-height: 2.25rem; padding: 0 .75rem; border-radius: var(--r-pill);
  font-size: .875rem; font-weight: 600; text-decoration: none; color: var(--mute);
  transition: background-color .2s ease, color .2s ease;
}
.g-mode .cols-switch a:hover { color: var(--ink); }
.g-mode .cols-switch a[aria-current="true"] { background: var(--bg); color: var(--ink); box-shadow: var(--card-shadow); }

/* La rejilla */
.g-mode #projects {
  display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: clamp(1.25rem, 2.5vw, 2rem);
  max-width: calc(1400px + 2 * var(--pad-x)); margin: 0 auto;
  padding: 0 var(--pad-x) clamp(3rem, 8vw, 6rem);
}
.g-mode[data-cols="3"] #projects { --cols: 3; }
.g-mode #empty { grid-column: 1 / -1; }

/* Cada proyecto, una tarjeta */
.g-mode #projects .proj { padding: clamp(1rem, 2vw, 1.5rem); border-radius: var(--r-box); }
.g-mode #projects .proj::before { inset: -20%; opacity: calc(var(--ambient-op) * .8); }
.g-mode #projects .proj::after { background: none; }
.g-mode #projects .proj > .in { max-width: none; margin: 0; }
.g-mode #projects .proj > .in > h2 { font-size: clamp(1.4rem, 2.4vw, 2.25rem); margin: 0 0 1rem; }
.g-mode #projects .stage .video { border-radius: var(--r-inner); }
.g-mode #projects .o-h .meta, .g-mode #projects .proj.alt .o-h .meta, .g-mode #projects .proj:not(.alt) .o-h .meta {
  margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: .9rem;
  background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.g-mode #projects .o-h .meta .glow { display: none; }
/* aquí la ficha no es un bloque de vidrio: sin esquinas ni refracción, que recortaban la primera letra
   (!important porque glass-fx.js pone la refracción como estilo en línea) */
.g-mode #projects .meta.glass { border-radius: 0; overflow: visible; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.g-mode #projects .meta.glass p {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-size: .9375rem; color: var(--mute);
}
.g-mode #projects .sheets { display: none; }                         /* las fichas irían al abrir el proyecto */

/* Con 3 columnas: tarjetas más compactas */
.g-mode[data-cols="3"] #projects .proj > .in > h2 { font-size: clamp(1.25rem, 1.8vw, 1.75rem); }
.g-mode[data-cols="3"] #projects .meta.glass p { -webkit-line-clamp: 2; }
.g-mode[data-cols="3"] #projects .chips { display: none; }
.g-mode[data-cols="3"] #projects .pill { font-size: .75rem; padding: .35rem .65rem .35rem .55rem; }

@media (max-width: 760px) {
  .g-mode #projects, .g-mode[data-cols="3"] #projects { --cols: 1; }
  .g-mode .cols-switch { display: none; }
}

/* Proyecto destacado (el que se ensancha para completar filas): título algo mayor */
.g-mode #projects .proj.featured > .in > h2 { font-size: clamp(1.75rem, 3vw, 2.75rem); }
.g-mode[data-cols="3"] #projects .proj.featured .chips { display: flex; }

/* ═════════ Tarjetas clicables y pop-up de proyecto ═════════ */
.g-mode #projects .proj { cursor: pointer; transition: box-shadow .2s ease; }
.g-mode #projects .proj:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
@media (hover: hover) { .g-mode #projects .proj:hover { box-shadow: var(--card-shadow-hover); } }
.g-mode #projects .proj.is-open > .in { visibility: hidden; }        /* su contenido está en el pop-up */

html.modal-open, html.modal-open body { overflow: hidden; }

#project-modal {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden;
}
#project-modal::backdrop { background: rgba(10, 10, 14, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .35s var(--spring); }
#project-modal.shown::backdrop { opacity: 1; }
#project-modal { display: none; }
#project-modal[open] { display: grid; place-items: center; }

/* El panel es un .proj más: hereda el resplandor de color y los estilos de la versión vertical */
.pm-panel {
  position: relative; width: min(1100px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 28px; background: var(--bg); box-shadow: 0 40px 120px rgba(2, 2, 6, .35);
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem) clamp(2rem, 5vw, 3.5rem) !important;
  transform-origin: top left; will-change: transform, opacity;
}
.pm-panel > .in { max-width: none; }
.pm-panel h2 { padding-right: 3.5rem; }                               /* no choca con la X */
.pm-close {
  position: sticky; top: 0; float: right; z-index: 5; margin: -.5rem -.5rem 0 0;
  width: 2.75rem; height: 2.75rem; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--glass); color: var(--ink);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  transition: transform .1s ease-out;
}
.pm-close:active { transform: scale(.92); }
.pm-close svg { width: 1.1rem; height: 1.1rem; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
@media (max-width: 760px) {
  .pm-panel { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
}
