/* Plantilla WebGL de SAMOGA (spec 005). Colores de marca: ver BrandColors.cs.
   Sin fuentes ni recursos externos (REQ-TPL-11): pila de fuentes del sistema. */

:root {
  --samoga-blue: #1E60AA;
  --samoga-blue-hover: #174C88;
  --samoga-dark: #0B2A4A;
  --samoga-ink: #231E1A;
  --samoga-yellow: #FDE801;
  --samoga-cyan: #038FCC;
  --samoga-turquoise: #47C1C6;
  --samoga-lime: #CEDC25;
  --samoga-font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--samoga-dark);
  color: var(--samoga-ink);
  font-family: var(--samoga-font);
}

/* REQ-TPL-01: el contenedor ocupa toda la ventana (o el iframe). dvh sigue a las barras del navegador móvil. */
.samoga-app {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--samoga-dark);
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--samoga-dark);
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Texto solo para lectores de pantalla. */
.samoga-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- Pantalla de carga (REQ-TPL-02, 05, 17) ---------- */

.samoga-loader {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 16px;
  overflow: auto;
  background: linear-gradient(160deg, var(--samoga-dark) 0%, var(--samoga-blue) 100%);
  opacity: 1;
  transition: opacity 250ms ease;
}

.samoga-loader.samoga-leaving {
  opacity: 0;
  pointer-events: none;
}

.samoga-card {
  position: relative;
  box-sizing: border-box;
  width: min(440px, 100%);
  margin: auto;
  padding: 28px 32px 40px;
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.samoga-logo {
  display: block;
  width: min(220px, 52%);
  height: auto;
  margin: 0 auto 18px;
}

.samoga-message {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.samoga-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--samoga-dark);
}

.samoga-bar-fill {
  width: 0;
  height: 100%;
  border-radius: 5px;
  background: var(--samoga-yellow);
  transition: width 200ms linear;
}

.samoga-percent {
  margin: 10px 0 0;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.samoga-slow {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.4;
}

/* Franja de marca en la base de la tarjeta (decoración). */
.samoga-strip {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  height: 8px;
}

.samoga-strip span {
  flex: 1;
}

.samoga-strip span:nth-child(1) { background: var(--samoga-yellow); }
.samoga-strip span:nth-child(2) { background: var(--samoga-cyan); }
.samoga-strip span:nth-child(3) { background: var(--samoga-turquoise); }
.samoga-strip span:nth-child(4) { background: var(--samoga-lime); }

/* Pantallas apaisadas bajas (por ejemplo 800x360): logo a la izquierda y progreso a la derecha. */
@media (max-height: 560px) and (orientation: landscape) {
  .samoga-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 28px;
    width: min(640px, 100%);
    padding: 20px 28px 28px;
    text-align: left;
  }

  .samoga-logo {
    width: auto;
    height: min(220px, 56vh);
    margin: 0;
  }

  .samoga-body {
    min-width: 0;
  }
}

/* ---------- Pantalla de error (REQ-TPL-06) ---------- */

.samoga-error {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px 16px;
  overflow: auto;
  background: #fff;
}

.samoga-error::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 8px;
  background: linear-gradient(90deg, var(--samoga-yellow) 0 25%, var(--samoga-cyan) 25% 50%, var(--samoga-turquoise) 50% 75%, var(--samoga-lime) 75% 100%);
}

.samoga-error-card {
  box-sizing: border-box;
  width: min(560px, 100%);
  margin: auto;
}

.samoga-error-logo {
  display: block;
  margin: 0 0 16px;
}

.samoga-error-title {
  margin: 0 0 12px;
  font-size: 26px;
  line-height: 1.25;
  color: var(--samoga-dark);
}

.samoga-error-reason {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.45;
}

.samoga-error-steps {
  margin: 0 0 24px;
  padding-left: 1.4em;
  font-size: 18px;
  line-height: 1.5;
}

.samoga-button {
  min-width: 48px;
  min-height: 48px;
  padding: 12px 32px;
  border: 0;
  border-radius: 999px;
  background: var(--samoga-blue);
  color: #fff;
  font: 600 18px/1.2 var(--samoga-font);
  cursor: pointer;
}

.samoga-button:hover {
  background: var(--samoga-blue-hover);
}

.samoga-button:focus-visible,
.samoga-fullscreen:focus-visible,
.samoga-details summary:focus-visible {
  outline: 3px solid var(--samoga-dark);
  outline-offset: 3px;
}

.samoga-details {
  margin-top: 28px;
  font-size: 16px;
}

.samoga-details summary {
  cursor: pointer;
}

.samoga-details pre {
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  max-height: 40vh;
  border-radius: 8px;
  background: #EAF1FA;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Avisos no fatales (REQ-TPL-07) ---------- */

.samoga-toasts {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.samoga-toast {
  box-sizing: border-box;
  padding: 12px 16px;
  border-left: 6px solid var(--samoga-yellow);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  color: var(--samoga-ink);
  font-size: 16px;
  line-height: 1.4;
}

/* ---------- Botón de pantalla completa (REQ-TPL-08) ---------- */

.samoga-fullscreen {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid var(--samoga-blue);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--samoga-blue);
  cursor: pointer;
}

.samoga-fullscreen:hover {
  background: #fff;
}

.samoga-fullscreen svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.samoga-fullscreen .samoga-icon-exit,
.samoga-fullscreen[data-fullscreen="on"] .samoga-icon-enter {
  display: none;
}

/* En ventanas bajas (por ejemplo 800x360) el botón taparía el pie del HUB: se oculta (F11 sigue disponible). */
@media (max-height: 480px) {
  .samoga-fullscreen {
    display: none;
  }
}

.samoga-fullscreen[data-fullscreen="on"] .samoga-icon-exit {
  display: block;
}

/* ---------- Sin JavaScript ---------- */

.samoga-noscript {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #fff;
  font-size: 20px;
  line-height: 1.4;
  text-align: center;
}

.samoga-noscript img {
  max-width: 50%;
  height: auto;
}

.samoga-noscript p {
  margin: 8px 0;
}

/* ---------- Movimiento reducido (REQ-TPL-10) ---------- */

@media (prefers-reduced-motion: reduce) {
  .samoga-loader,
  .samoga-bar-fill,
  .samoga-fullscreen {
    transition: none !important;
  }
}
