:root {
  --g3d-accent: #4c94ff;
  --g3d-accent-soft: #6da9ff;
  --g3d-text: #f7f9ff;
  --g3d-muted: #a9b4c6;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body.g3d-body {
  min-height: 100vh;
  color: var(--g3d-text);
  font-family: Inter, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  background: #05070a;
}

.g3d-dashboard-view .dashboard-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.g3d-body .sidebar-link {
  text-decoration: none;
}

/* Página / cabecera de la galería */
.g3d-page {
  width: min(1400px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.g3d-title {
  margin: 0 auto 34px;
  text-align: center;
}

.g3d-title h1 {
  --g3d-title-pointer-x: 50%;
  --g3d-title-pointer-y: 50%;
  position: relative;
  display: inline-block;
  margin: 0;
  color: transparent;
  font-size: clamp(48px, 6.4vw, 88px);
  font-weight: 900;
  letter-spacing: -.065em;
  line-height: .9;
  white-space: nowrap;
  background: linear-gradient(100deg, #ffffff 0%, #f4f9ff 28%, #cbe7ff 48%, #72b8ff 66%, #168cff 84%, #005dbb 100%);
  background-size: 120% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 0 26px rgba(22, 140, 255, .24));
  transform-origin: center;
  transition: filter 380ms ease, transform 380ms ease;
  animation: g3d-title-gradient 12s ease-in-out infinite;
}

.g3d-title h1:hover {
  filter: drop-shadow(0 0 28px rgba(22, 140, 255, .34));
  transform: scale(1.025);
}

.g3d-title h1::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  color: transparent;
  background:
    radial-gradient(
      ellipse 115px 90px at var(--g3d-title-pointer-x) var(--g3d-title-pointer-y),
      #ffffff 0%,
      #eaf6ff 20%,
      #9ed0ff 38%,
      #168cff 56%,
      #005dbb 68%,
      transparent 78%
    );
  background-clip: text;
  -webkit-background-clip: text;
  opacity: 0;
  filter:
    drop-shadow(0 0 5px rgba(235, 248, 255, .82))
    drop-shadow(0 0 14px rgba(22, 140, 255, .78))
    drop-shadow(0 0 30px rgba(0, 93, 187, .58));
  pointer-events: none;
  transition: opacity 180ms ease;
}

.g3d-title h1:hover::after {
  opacity: 1;
}

@keyframes g3d-title-gradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.g3d-status {
  margin: 0 0 20px;
  color: var(--g3d-muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.g3d-status[hidden] {
  display: none;
}

/* Galería en columnas con scroll propio y avance automático */
.g3d-grid {
  --g3d-column-count: 5;
  --g3d-column-gap: 16px;
  height: var(--g3d-grid-height, clamp(460px, calc(100dvh - 250px), 820px));
  display: grid;
  grid-template-columns: repeat(var(--g3d-column-count), minmax(0, 1fr));
  align-items: start;
  gap: var(--g3d-column-gap);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #343641 transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.g3d-column {
  min-width: 0;
}

.g3d-column-track {
  display: flex;
  flex-direction: column;
}

.g3d-column-set {
  flex: 0 0 auto;
  display: grid;
  gap: var(--g3d-column-gap);
  padding-bottom: var(--g3d-column-gap);
}

.g3d-grid-item {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid #262b33;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1016;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .3);
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.g3d-grid-item img,
.g3d-grid-item video {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: var(--g3d-item-ratio, auto);
  object-fit: cover;
  transition: transform 260ms ease, filter 260ms ease;
}

.g3d-grid-item video {
  aspect-ratio: var(--g3d-item-ratio, 9 / 16);
  background: #05070b;
}

.g3d-grid-item[data-media-type="video"]::after {
  content: "VÍDEO";
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  padding: 4px 7px;
  color: #eef7ff;
  border: 1px solid rgba(135, 196, 255, .48);
  border-radius: 999px;
  background: rgba(5, 12, 24, .76);
  box-shadow: 0 0 14px rgba(42, 139, 255, .34);
  backdrop-filter: blur(8px);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .12em;
  pointer-events: none;
}

.g3d-grid-item:hover,
.g3d-grid-item:focus-visible {
  border-color: rgba(108, 169, 255, .75);
  outline: none;
  box-shadow: 0 0 0 1px rgba(108, 169, 255, .35), 0 0 22px rgba(76, 148, 255, .28), 0 16px 30px rgba(0, 0, 0, .4);
  transform: translateY(-3px);
}

.g3d-grid-item:hover :is(img, video),
.g3d-grid-item:focus-visible :is(img, video) {
  transform: scale(1.035);
  filter: brightness(1.05);
}

@media (max-width: 640px) {
  .g3d-title {
    margin-bottom: 26px;
  }

  .g3d-title h1 {
    font-size: clamp(29px, 10vw, 44px);
  }

  .g3d-grid {
    --g3d-column-gap: 10px;
    height: var(--g3d-grid-height, clamp(440px, calc(100dvh - 220px), 720px));
  }
}

/* Modal de información */
body.g3d-modal-open {
  overflow: hidden;
}

.g3d-modal[hidden] {
  display: none;
}

.g3d-modal {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: #f7f9ff;
}

.g3d-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 8, .68);
  backdrop-filter: blur(6px) saturate(.9);
  -webkit-backdrop-filter: blur(6px) saturate(.9);
}

.g3d-modal-window {
  position: relative;
  width: min(1280px, calc(100vw - 32px));
  height: min(920px, calc(100dvh - 32px));
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  background: linear-gradient(145deg, #10141b 0%, #07090d 60%, #0a0d13 100%);
  box-shadow: 0 34px 100px rgba(0, 0, 0, .76);
  animation: g3d-modal-enter 180ms ease-out both;
}

@keyframes g3d-modal-enter {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.g3d-modal-header {
  min-width: 0;
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(105, 149, 212, .22);
  background: rgba(15, 18, 24, .92);
}

.g3d-modal-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.g3d-modal-heading > span {
  color: var(--g3d-accent-soft);
  font-size: 9px;
  font-weight: 850;
}

.g3d-modal-title-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.g3d-modal-title-line > strong {
  min-width: 0;
  overflow: hidden;
  color: #f8faff;
  font-size: 15px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.g3d-modal-model {
  flex: 0 0 auto;
  padding: 4px 8px;
  color: #aeb9ca;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
  border: 1px solid rgba(103, 156, 240, .28);
  border-radius: 999px;
  background: rgba(62, 112, 192, .12);
}

.g3d-modal-model b {
  color: #80b2ff;
  font-weight: 800;
}

.g3d-modal-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #cad3e2;
  border: 1px solid rgba(119, 154, 207, .26);
  border-radius: 6px;
  background: #151a22;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .24);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.g3d-modal-close svg {
  width: 17px;
  height: 17px;
}

.g3d-modal-close:hover,
.g3d-modal-close:focus-visible {
  color: #fff;
  border-color: #5c9dff;
  outline: none;
  background: #17243a;
  box-shadow: 0 0 16px rgba(41, 121, 255, .48), 0 8px 22px rgba(0, 0, 0, .34);
}

.g3d-modal-body {
  min-height: 0;
  overflow: hidden;
  background: #030509;
}

.g3d-modal-figure {
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.g3d-modal-figure img,
.g3d-modal-figure video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #030509;
}

.g3d-modal-figure [hidden] {
  display: none;
}

@media (max-width: 640px) {
  .g3d-modal {
    padding: 8px;
  }

  .g3d-modal-window {
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .g3d-modal-header {
    padding: 0 10px 0 12px;
    gap: 8px;
  }

  .g3d-modal-heading > span {
    display: none;
  }

  .g3d-modal-title-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .g3d-modal-title-line > strong {
    max-width: 100%;
  }

  .g3d-modal-model {
    align-self: flex-start;
    padding: 3px 6px;
    font-size: 9px;
  }
}

@media (max-height: 480px) {
  .g3d-dashboard-view .dashboard-topbar {
    height: 52px;
  }

  .g3d-page {
    padding: 16px 0 20px;
  }

  .g3d-title {
    margin-bottom: 10px;
  }

  .g3d-title h1 {
    font-size: clamp(22px, 5vw, 30px);
  }

  .g3d-status {
    margin-bottom: 8px;
  }
}

/* La galería no utiliza barra superior. En pantallas pequeñas se conserva
   únicamente el acceso flotante al menú lateral. */
.g3d-dashboard-view .dashboard-topbar {
  display: none;
}

@media (max-width: 980px) {
  .g3d-dashboard-view .dashboard-topbar {
    position: fixed;
    z-index: 34;
    top: 12px;
    left: 12px;
    width: 40px;
    height: 40px;
    padding: 0;
    display: block;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .g3d-dashboard-view .dashboard-topbar > :not(.dashboard-menu-button) {
    display: none;
  }

  .g3d-dashboard-view .dashboard-menu-button {
    width: 40px;
    height: 40px;
    display: grid;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .38);
  }
}

@media (prefers-reduced-motion: reduce) {
  .g3d-title h1 {
    animation: none;
    background-position: 50% 50%;
    transition: none;
  }

  .g3d-title h1::after {
    transition: none;
  }

  .g3d-title h1:hover {
    transform: none;
  }

  [data-g3d-copy] {
    display: none !important;
  }

  .g3d-grid-item,
  .g3d-grid-item img,
  .g3d-grid-item video {
    transition: none;
  }
}
