/* =================================
   1) Fuentes + Variables + Reset
================================= */

/* Fuentes auto-hospedadas (en /home/web/3dcomunity/fonts) */
@font-face{
  font-family: 'ThreeDIsometric';
  src: url('fonts/3DIsometric-Regular.ttf') format('truetype'),
       url('fonts/3DIsometric-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'ThreeDIsometric';
  src: url('fonts/3DIsometric-Bold.ttf') format('truetype'),
       url('fonts/3DIsometric-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'ThreeDIsometric';
  src: url('fonts/3DIsometric-Black.ttf') format('truetype'),
       url('fonts/3DIsometric-Black.otf') format('opentype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face{
  font-family: 'Gunplay';
  src: url('fonts/Gunplay-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Variables */
:root {
  --bg-dark: #0a0a0a;
  --bg-panel: #1a1a1a;
  --text-light: #f2f2f2;
  --shadow: rgba(0,0,0,0.7);

  /* Neón */
  --neon-green:  #39FF14;
  --neon-orange: #FF7A18;

  /* Paleta para botones (gradiente) */
  --accent-green: var(--neon-green);
  --accent-orange: var(--neon-orange);
  --btn-grad: linear-gradient(90deg, var(--accent-green) 0%, var(--accent-orange) 100%);

  /* Hover/foco */
  --hover-green: #4caf50;

  /* Tipografías base */
  --font-sans: 'Rajdhani', sans-serif;
  --font-title: 'ThreeDIsometric', var(--font-sans);
  --font-buttons: 'Gunplay', var(--font-sans);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-dark);
  color: var(--text-light);
  height: 100vh;
  display: grid;
  grid-template-rows: 15% 85%;
}

/* =================================
   2) Header + Menú
================================= */

/* --- Header: título arriba, botones debajo --- */
.site-header{
  background:#111;
  box-shadow:0 2px 6px var(--shadow);
  display:grid;                 /* pila vertical: título + menú */
  grid-auto-rows:min-content;
  justify-items:center;         /* centra horizontalmente */
  align-content:center;         /* centra verticalmente dentro del 15% */
  gap:.55rem;                   /* separación título/menú */
  padding:.6rem 1rem 1rem;
  height:100%;
}

/* Título solo color naranja (neón), tamaños sin cambios */
.site-header .site-title{
  font-family: var(--font-title);
  font-weight:800;
  font-size: clamp(3rem, 5vw, 5rem);
  letter-spacing:.06em;
  line-height:1;
  margin:0;
  color: var(--neon-orange);
  text-shadow:
    0 0 8px rgba(255,122,24,.25),
    0 8px 22px rgba(0,0,0,.35);
  white-space: nowrap;
}

/* Menú debajo del título, centrado */
.nav-menu{
  height:auto;
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:.8rem;
}

/* Botones con gradiente verde→naranja */
.nav-menu button{
  font-family: var(--font-buttons);
  font-size: clamp(1.5rem, 1.2vw, 1.5rem);
  padding:.85rem 1.2rem;
  border:none;
  border-radius:.65rem;
  color:#0b0b0b;
  cursor:pointer;

  background-image: var(--btn-grad);
  background-size: 200% 100%;
  background-position: 0% 50%;
  box-shadow:
    0 4px 12px rgba(0,0,0,.5),
    0 0 0 0 rgba(57,255,20,0);

  transition:
    background-position .35s ease,
    transform .12s ease,
    box-shadow .2s ease,
    filter .2s ease;
}
.nav-menu button:hover {
  background-position: 100% 50%;
  transform: translateY(-1px);
  box-shadow:
    0 8px 22px rgba(0,0,0,.55),
    0 0 12px rgba(57,255,20,.35),
    0 0 24px rgba(255,122,24,.25);
  filter: saturate(1.05);
}
.nav-menu button:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(0,0,0,.45) inset;
}
.nav-menu button:focus-visible {
  outline: 2px solid rgba(57,255,20,.9);
  outline-offset: 3px;
  box-shadow:
    0 0 0 2px rgba(57,255,20,.35),
    0 0 10px rgba(255,122,24,.35);
}
.nav-menu button.active{
  /* estado activo en verde sólido */
  background: var(--accent-green);
  background-image: none;
  color:#0b0b0b;
  box-shadow:
    0 6px 16px rgba(0,0,0,.5),
    0 0 10px rgba(57,255,20,.35);
}

/* =================================
   3) Layout principal
================================= */

.content {
  display: flex;
  height: 100%;
}

/* Visor 3D (izquierda) */
#viewer3d {
  width: 70%;
  background: #000;
  padding: 0.5rem;
  display: flex;
  position: relative;
}

/* Model-Viewer base (rellena el contenedor) */
#viewer3d model-viewer {
  width: 100%;
  height: 100%;
  border-radius: .6rem;
  box-shadow: 0 6px 18px var(--shadow);
  outline: 1px solid #111;
}

/* =================================
   4) Panel lateral
================================= */

.side-panel {
  width: 30%;
  background: var(--bg-panel);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: -4px 0 10px var(--shadow);
}

/* =================================
   5) Filtros desplegables
================================= */

.filters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.filter label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: bold;
}
.filter select {
  width: 100%;
  padding: 0.6rem;
  border: 2px solid #444;
  border-radius: 0.4rem;
  background: #222;
  color: var(--text-light);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform .08s ease;
}
.filter select:hover {
  border-color: var(--hover-green);
  box-shadow: 0 0 5px rgba(76,175,80,0.6);
  transform: translateY(-1px);
}

/* =================================
   6) Galería 3×3 (miniaturas)
================================= */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  flex-grow: 1;
  overflow-y: auto;
}
.gallery-item {
  background: #222;
  aspect-ratio: 1;
  display: block;
  border-radius: 0.3rem;
  cursor: pointer;
  border: 2px solid transparent;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter .2s ease;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
  border-color: var(--hover-green);
  filter: saturate(1.05);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display:block;
  border-radius: .25rem;
}

/* Placeholders (si aún no hay 9 imágenes) */
.gallery-item.placeholder{
  color:#777; font-weight:700; font-size:1.2rem;
  display:flex; align-items:center; justify-content:center;
  background:#1f1f1f;
}

/* =================================
   7) Lógica sin JS (hash + :target)
   - Anclas de estado invisibles
   - Mostrar/ocultar <model-viewer> según el hash
   - Resaltar miniatura activa
================================= */

.state-anchor {
  position:absolute;
  left:-9999px;
  width:0; height:0;
  overflow:hidden;
}

/* Por defecto: muestra solo el primer modelo (clase .default) */
#viewer3d .mv { display: none; }
#viewer3d .mv.default { display: block; }

/* Regla para cada estado (robot / benchy / cubo) */
#m-robot:target ~ #viewer3d .mv { display: none; }
#m-robot:target ~ #viewer3d .mv[data-model="robot"] { display: block; }

#m-benchy:target ~ #viewer3d .mv { display: none; }
#m-benchy:target ~ #viewer3d .mv[data-model="benchy"] { display: block; }

#m-cubo:target ~ #viewer3d .mv { display: none; }
#m-cubo:target ~ #viewer3d .mv[data-model="cubo"] { display: block; }

/* Resaltar miniatura activa según el :target */
#m-robot:target ~ .side-panel .gallery-item[data-target="m-robot"],
#m-benchy:target ~ .side-panel .gallery-item[data-target="m-benchy"],
#m-cubo:target   ~ .side-panel .gallery-item[data-target="m-cubo"] {
  border-color: var(--hover-green);
  box-shadow: 0 0 0 2px rgba(76,175,80,0.4) inset;
}

/* =================================
   8) Fallback sin JS para el visor (noscript)
================================= */

.nojs{
  background:#222; border:2px solid #444; border-radius:.5rem;
  padding:1rem; margin-top:.5rem; text-align:center;
}
.nojs .btn{
  display:inline-block; margin-top:.6rem; padding:.6rem 1rem;
  background: var(--btn-grad);
  background-size: 200% 100%;
  background-position: 0% 50%;
  color:#111; border-radius:.4rem; text-decoration:none; font-weight:700;
  box-shadow: 0 4px 8px var(--shadow);
  transition: background-position .35s ease, transform .12s ease, box-shadow .2s ease;
}
.nojs .btn:hover{
  background-position: 100% 50%;
  transform: translateY(-1px);
  box-shadow: 0 8px 14px var(--shadow);
}
/* Mostrar/ocultar según el hash para cada modelo */
#m-coolr3d24:target      ~ #viewer3d .mv { display:none; }
#m-coolr3d24:target      ~ #viewer3d .mv[data-model="coolr3d24"] { display:block; }

#m-gaspiage:target       ~ #viewer3d .mv { display:none; }
#m-gaspiage:target       ~ #viewer3d .mv[data-model="gaspiage"] { display:block; }

#m-kraken:target         ~ #viewer3d .mv { display:none; }
#m-kraken:target         ~ #viewer3d .mv[data-model="kraken"] { display:block; }

#m-davidchamorro:target  ~ #viewer3d .mv { display:none; }
#m-davidchamorro:target  ~ #viewer3d .mv[data-model="davidchamorro"] { display:block; }

#m-lobotomik:target      ~ #viewer3d .mv { display:none; }
#m-lobotomik:target      ~ #viewer3d .mv[data-model="lobotomik"] { display:block; }

#m-lockheart:target      ~ #viewer3d .mv { display:none; }
#m-lockheart:target      ~ #viewer3d .mv[data-model="lockheart"] { display:block; }

#m-mageb:target          ~ #viewer3d .mv { display:none; }
#m-mageb:target          ~ #viewer3d .mv[data-model="mageb"] { display:block; }

#m-mkellsy:target        ~ #viewer3d .mv { display:none; }
#m-mkellsy:target        ~ #viewer3d .mv[data-model="mkellsy"] { display:block; }

#m-prospect3dlab:target  ~ #viewer3d .mv { display:none; }
#m-prospect3dlab:target  ~ #viewer3d .mv[data-model="prospect3dlab"] { display:block; }

#m-snh_base:target       ~ #viewer3d .mv { display:none; }
#m-snh_base:target       ~ #viewer3d .mv[data-model="snh_base"] { display:block; }

#m-snh_usb_ether:target  ~ #viewer3d .mv { display:none; }
#m-snh_usb_ether:target  ~ #viewer3d .mv[data-model="snh_usb_ether"] { display:block; }

#m-tomasla:target        ~ #viewer3d .mv { display:none; }
#m-tomasla:target        ~ #viewer3d .mv[data-model="tomasla"] { display:block; }

#m-waseem-33:target      ~ #viewer3d .mv { display:none; }
#m-waseem-33:target      ~ #viewer3d .mv[data-model="waseem-33"] { display:block; }

/* Resaltado de miniatura activa */
#m-coolr3d24:target     ~ .side-panel .gallery-item[data-target="m-coolr3d24"],
#m-gaspiage:target      ~ .side-panel .gallery-item[data-target="m-gaspiage"],
#m-kraken:target        ~ .side-panel .gallery-item[data-target="m-kraken"],
#m-davidchamorro:target ~ .side-panel .gallery-item[data-target="m-davidchamorro"],
#m-lobotomik:target     ~ .side-panel .gallery-item[data-target="m-lobotomik"],
#m-lockheart:target     ~ .side-panel .gallery-item[data-target="m-lockheart"],
#m-mageb:target         ~ .side-panel .gallery-item[data-target="m-mageb"],
#m-mkellsy:target       ~ .side-panel .gallery-item[data-target="m-mkellsy"],
#m-prospect3dlab:target ~ .side-panel .gallery-item[data-target="m-prospect3dlab"],
#m-snh_base:target      ~ .side-panel .gallery-item[data-target="m-snh_base"],
#m-snh_usb_ether:target ~ .side-panel .gallery-item[data-target="m-snh_usb_ether"],
#m-tomasla:target       ~ .side-panel .gallery-item[data-target="m-tomasla"],
#m-waseem-33:target     ~ .side-panel .gallery-item[data-target="m-waseem-33"]{
  border-color: var(--hover-green);
  box-shadow: 0 0 0 2px rgba(76,175,80,0.4) inset;
}

/* =================================
   9) Responsive
================================= */

@media (max-width: 900px){
  .site-header{
    padding: .5rem .75rem .85rem;
    gap: .5rem;
  }
  /* mantenemos el tamaño del título con el clamp principal */
  .nav-menu{ gap: .6rem; }
  .nav-menu button { padding: .75rem 1rem; font-size: 1.3rem; }
}

@media (max-width: 680px){
  .site-header{
    padding: .5rem .75rem .75rem;
    gap:.45rem;
  }
  .nav-menu{
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem .6rem;
  }
  .nav-menu button { font-size: 1.1rem; padding: .7rem .95rem; }
  .content { flex-direction: column; }
  #viewer3d { width: 100%; height: 60%; }
  .side-panel { width: 100%; height: 40%; }
}
