/* Freya Summer Quest — estilos locales Sprint 2.5 */
@import url("tokens.css");

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sq-font-body);
  color: var(--sq-color-text-inverse);
  line-height: 1.5;
}

img, svg { display: block; max-width: 100%; height: auto; }

button, input { font: inherit; }

a { color: inherit; }

/* --- Utilidades accesibilidad --- */
.sq-skip-link {
  position: absolute;
  left: -9999px;
  top: var(--sq-space-4);
  z-index: 100;
  padding: var(--sq-space-3) var(--sq-space-4);
  background: #fff;
  color: var(--sq-color-text);
  border-radius: var(--sq-radius-md);
  font-weight: 700;
}
.sq-skip-link:focus {
  left: var(--sq-space-4);
  outline: 3px solid var(--sq-color-star);
}

.sq-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Login (fondo real + overlay) --- */
.sq-auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--sq-color-night-950);
}

.sq-login-scene {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.sq-login-scene--real-bg {
  background-image: var(--sq-login-bg);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.sq-login-scene__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.45) 0%,
    rgba(15, 23, 42, 0.25) 40%,
    rgba(15, 23, 42, 0.55) 100%
  );
  pointer-events: none;
}

.sq-login-mascot {
  position: absolute;
  bottom: 4%;
  right: 4%;
  width: clamp(88px, 18vw, 140px);
  height: auto;
  max-height: 28vh;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}

.sq-login-intro,
.sq-login-parent-title {
  text-align: center;
  margin: 0 0 1.5rem;
  color: var(--sq-color-text-muted);
}

.sq-login-parent-title {
  font-size: 1.25rem;
  color: var(--sq-color-text);
}

.sq-form-field {
  margin-bottom: 1.25rem;
}

.sq-form-field--last {
  margin-bottom: 1.5rem;
}

.sq-login-parent-wrap {
  text-align: center;
  margin-top: 1.5rem;
}

.sq-login-footer-note {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--sq-color-text-muted-inverse);
}

/* Avatar circular (recorte CSS para girl-default RGB) */
.sq-avatar-image {
  width: 96px;
  height: 96px;
  margin: 0 auto var(--sq-space-4);
  border-radius: 50%;
  overflow: hidden;
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--sq-shadow-card);
  background: #e0e7ff;
}

.sq-avatar-image--header {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0;
  border-width: 2px;
}

.sq-avatar-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}

.sq-avatar-image--girl-default img {
  object-position: center 12%;
  transform: scale(1.15);
}

.sq-header-avatar--initial {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #fcd34d, #f472b6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sq-login-wrap {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  margin: 0 auto;
  padding: var(--sq-space-8) var(--sq-space-4) var(--sq-space-12);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sq-login-mascot-fallback {
  display: none;
}

/* --- Logo --- */
.sq-logo {
  text-align: center;
  margin-bottom: var(--sq-space-8);
}
.sq-logo__title {
  font-family: var(--sq-font-display);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  color: var(--sq-color-sand-100);
  letter-spacing: 0.02em;
  margin: 0;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.sq-logo__star {
  display: inline-block;
  color: var(--sq-color-star);
  margin-left: var(--sq-space-2);
}
.sq-logo__subtitle {
  margin: var(--sq-space-2) 0 0;
  font-size: 0.875rem;
  color: var(--sq-color-text-muted-inverse);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* --- Tarjetas y formularios --- */
.sq-card {
  background: var(--sq-color-card);
  color: var(--sq-color-text);
  border-radius: var(--sq-radius-2xl);
  box-shadow: var(--sq-shadow-floating);
  padding: var(--sq-space-6);
}

.sq-card--glass {
  background: var(--sq-color-card-muted);
  color: var(--sq-color-text-inverse);
  backdrop-filter: blur(12px);
  border: 1px solid var(--sq-color-border);
}

.sq-form-label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: var(--sq-space-2);
  color: inherit;
}

.sq-input {
  width: 100%;
  min-height: var(--sq-touch-min);
  padding: var(--sq-space-3) var(--sq-space-4);
  border-radius: var(--sq-radius-xl);
  border: 1px solid var(--sq-color-border-dark);
  background: #fff;
  color: var(--sq-color-text);
  font-size: 1.125rem;
}
.sq-input:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.35);
}
.sq-card--glass .sq-input {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--sq-color-border);
  color: var(--sq-color-text-inverse);
}

.sq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sq-space-2);
  min-height: var(--sq-touch-min);
  padding: var(--sq-space-3) var(--sq-space-6);
  border: none;
  border-radius: var(--sq-radius-xl);
  font-weight: 700;
  font-size: 1.125rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.sq-btn:focus-visible {
  outline: 3px solid var(--sq-color-star);
  outline-offset: 2px;
}
.sq-btn--primary {
  width: 100%;
  background: linear-gradient(135deg, var(--sq-color-primary), var(--sq-color-primary-hover));
  color: #fff;
  box-shadow: var(--sq-shadow-button);
}
.sq-btn--primary:hover { transform: translateY(-1px); }
.sq-btn--ghost {
  background: transparent;
  color: var(--sq-color-text-muted-inverse);
  font-size: 0.875rem;
  min-height: auto;
  padding: var(--sq-space-2);
}
.sq-btn--block { width: 100%; }

.sq-alert {
  padding: var(--sq-space-3) var(--sq-space-4);
  border-radius: var(--sq-radius-lg);
  margin-bottom: var(--sq-space-4);
  background: var(--sq-color-error-soft);
  color: var(--sq-color-error-text);
  border: 1px solid rgba(251, 146, 60, 0.35);
}

.sq-avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto var(--sq-space-4);
  border-radius: 50%;
  background: linear-gradient(145deg, #fcd34d, #f472b6);
  border: 4px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  box-shadow: var(--sq-shadow-card);
}
/* legacy .sq-avatar emoji fallback — sustituido por .sq-avatar-image */

.sq-access-tabs {
  display: flex;
  gap: var(--sq-space-1);
  padding: var(--sq-space-1);
  border-radius: var(--sq-radius-xl);
  background: var(--sq-color-card-muted);
  border: 1px solid var(--sq-color-border);
  margin-bottom: var(--sq-space-6);
}
.sq-access-tabs a {
  flex: 1;
  text-align: center;
  padding: var(--sq-space-3);
  border-radius: var(--sq-radius-lg);
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--sq-color-text-muted-inverse);
}
.sq-access-tabs a[aria-selected="true"],
.sq-access-tabs a.sq-access-tabs__active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.sq-parent-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sq-space-2);
  margin-top: var(--sq-space-6);
  font-size: 0.875rem;
  color: var(--sq-color-sky-300);
  text-decoration: none;
}
.sq-parent-link:hover { text-decoration: underline; }

/* --- Child app shell --- */
.sq-child-body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 50%, #c7d2fe 100%);
  color: var(--sq-color-text);
  padding-bottom: calc(var(--sq-nav-height) + var(--sq-space-4));
}

.sq-child-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sq-space-4);
  padding: var(--sq-space-3) var(--sq-space-4);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--sq-color-border-dark);
  min-height: var(--sq-header-height);
}

.sq-child-header__brand {
  font-weight: 800;
  font-size: 0.875rem;
  color: var(--sq-color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
}

.sq-child-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sq-space-2);
  flex-shrink: 0;
}

.sq-header-logout {
  margin: 0;
}

.sq-header-logout__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: none;
  border-radius: var(--sq-radius-md);
  background: transparent;
  color: var(--sq-color-text-muted);
  cursor: pointer;
}

.sq-header-logout__btn:hover,
.sq-header-logout__btn:focus-visible {
  background: rgba(99, 102, 241, 0.12);
  color: var(--sq-color-primary);
  outline: 2px solid var(--sq-color-primary);
  outline-offset: 2px;
}

.sq-child-main {
  max-width: var(--sq-max-content);
  margin: 0 auto;
  padding: var(--sq-space-4);
}

.sq-greeting {
  margin-bottom: var(--sq-space-6);
}
.sq-greeting h1 {
  font-family: var(--sq-font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0 0 var(--sq-space-1);
  color: var(--sq-color-night-900);
}
.sq-greeting p {
  margin: 0;
  color: var(--sq-color-text-muted);
  font-size: 1rem;
}

.sq-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sq-space-3);
  margin-bottom: var(--sq-space-6);
}

.sq-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sq-space-2);
  padding: var(--sq-space-2) var(--sq-space-4);
  background: #fff;
  border-radius: var(--sq-radius-pill);
  border: 1px solid var(--sq-color-border-dark);
  box-shadow: var(--sq-shadow-card);
  font-weight: 700;
  font-size: 0.875rem;
  min-height: 2.5rem;
}
.sq-stat-chip img,
.sq-stat-chip svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.sq-quest-card {
  background: linear-gradient(135deg, var(--sq-color-primary), #5b21b6);
  color: #fff;
  border-radius: var(--sq-radius-2xl);
  padding: var(--sq-space-6);
  margin-bottom: var(--sq-space-6);
  box-shadow: var(--sq-shadow-button);
  position: relative;
  overflow: hidden;
}
.sq-quest-card::after {
  content: "";
  position: absolute;
  top: -20%;
  right: -10%;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.35), transparent 70%);
  pointer-events: none;
}
.sq-quest-card h2 {
  margin: 0 0 var(--sq-space-2);
  font-size: 1.375rem;
}
.sq-quest-card p {
  margin: 0 0 var(--sq-space-4);
  opacity: 0.92;
  font-size: 0.9375rem;
}
.sq-quest-card .sq-btn--primary {
  background: #fff;
  color: var(--sq-color-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  max-width: 20rem;
}

.sq-map-section h2 {
  font-size: 1.125rem;
  margin: 0 0 var(--sq-space-4);
  color: var(--sq-color-night-900);
}

.sq-world-map-visual {
  position: relative;
  border-radius: var(--sq-radius-xl);
  overflow: hidden;
  box-shadow: var(--sq-shadow-card);
  margin-bottom: var(--sq-space-4);
  background: #1e3a8a;
}

.sq-world-map-visual__image {
  width: 100%;
  height: auto;
  aspect-ratio: 1536 / 1024;
  object-fit: cover;
}

.sq-world-hotspots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sq-hotspot {
  position: absolute;
  left: var(--sq-hotspot-x);
  top: var(--sq-hotspot-y);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  min-width: var(--sq-touch-min);
  min-height: var(--sq-touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 0;
  text-decoration: none;
}

.sq-hotspot__dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.sq-hotspot--active .sq-hotspot__dot {
  background: var(--sq-color-primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.35);
}

.sq-hotspot--locked {
  cursor: not-allowed;
  opacity: 0.85;
}

.sq-hotspot--locked .sq-hotspot__dot {
  background: #94a3b8;
}

.sq-hotspot__lock {
  position: absolute;
  bottom: 0;
  right: 0;
}

.sq-hotspot:focus-visible {
  outline: 3px solid var(--sq-color-star);
  outline-offset: 3px;
  border-radius: 50%;
}

.sq-world-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sq-space-2);
}

.sq-world-list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sq-space-3);
  padding: var(--sq-space-3) var(--sq-space-4);
  background: #fff;
  border-radius: var(--sq-radius-lg);
  border: 1px solid var(--sq-color-border-dark);
  text-decoration: none;
  color: inherit;
  min-height: var(--sq-touch-min);
}

.sq-world-list__link--locked {
  opacity: 0.7;
  cursor: not-allowed;
}

.sq-world-list__title {
  font-weight: 700;
  font-size: 0.875rem;
}

.sq-world-list__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--sq-color-text-muted);
  text-transform: uppercase;
}

.sq-world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sq-space-4);
}

.sq-world-card {
  background: #fff;
  border-radius: var(--sq-radius-xl);
  padding: var(--sq-space-4);
  text-align: center;
  border: 2px solid var(--sq-color-border-dark);
  box-shadow: var(--sq-shadow-card);
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sq-space-2);
}
.sq-world-card--active {
  border-color: var(--sq-color-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}
.sq-world-card--locked {
  opacity: 0.65;
  background: #f1f5f9;
}
.sq-world-card__icon {
  font-size: 2rem;
  line-height: 1;
}
.sq-world-card__title {
  font-weight: 700;
  font-size: 0.8125rem;
  margin: 0;
}
.sq-world-card__badge {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--sq-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sq-mascot-panel {
  display: flex;
  align-items: center;
  gap: var(--sq-space-4);
  background: #fff;
  border-radius: var(--sq-radius-xl);
  padding: var(--sq-space-4);
  margin-top: var(--sq-space-6);
  border: 1px solid var(--sq-color-border-dark);
}
.sq-mascot-panel__blob {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(145deg, #c4b5fd, #7c3aed);
  border: 2px solid #ddd6fe;
}

.sq-mascot-panel__image {
  width: 72px;
  height: auto;
  max-height: 96px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
}
.sq-mascot-panel p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--sq-color-text-muted);
}
.sq-mascot-panel strong {
  display: block;
  color: var(--sq-color-night-900);
  margin-bottom: var(--sq-space-1);
}

.sq-child-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  min-height: var(--sq-nav-height);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--sq-color-border-dark);
  padding: var(--sq-space-2) var(--sq-space-1) env(safe-area-inset-bottom, 0);
}

.sq-child-nav a,
.sq-child-nav .sq-child-nav__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--sq-space-2);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--sq-color-text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  min-width: 0;
}
.sq-child-nav a[aria-current="page"],
.sq-child-nav .sq-child-nav__link--current {
  color: var(--sq-color-primary);
}
.sq-child-nav svg,
.sq-child-nav img {
  width: 1.5rem;
  height: 1.5rem;
}
.sq-child-nav__disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.sq-child-nav__logout {
  flex: 1;
  margin: 0;
  padding: 0;
  display: flex;
}
.sq-child-nav__logout-btn {
  width: 100%;
  font: inherit;
}

.sq-progress {
  height: 12px;
  background: rgba(30, 27, 75, 0.1);
  border-radius: var(--sq-radius-pill);
  overflow: hidden;
}
.sq-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sq-color-star), var(--sq-color-fragment));
  border-radius: var(--sq-radius-pill);
}

.sq-empty-hint {
  font-size: 0.8125rem;
  color: var(--sq-color-text-muted);
  font-style: italic;
  margin-top: var(--sq-space-1);
}

/* --- Legacy / base.html helpers (Sprint 0) --- */
.star {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow: 0 0 8px #fde68a;
  animation: sq-twinkle 3s ease-in-out infinite;
}
.star-1 { top: 10%; left: 15%; }
.star-2 { top: 25%; right: 20%; animation-delay: 0.8s; }
.star-3 { top: 60%; left: 8%; animation-delay: 1.5s; }

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--sq-radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (min-width: 768px) {
  .sq-login-wrap { padding-top: var(--sq-space-12); }
  .sq-world-list { display: none; }
  .sq-world-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767px) {
  .sq-world-hotspots { display: none; }
  .sq-login-mascot { width: 72px; right: 2%; bottom: 2%; }
}

@media (min-width: 1024px) {
  .sq-child-main { padding: var(--sq-space-6) var(--sq-space-8); }
  .sq-world-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 359px) {
  .sq-login-mascot-fallback { width: 64px; height: 64px; right: 4%; }
  .sq-stats-row { flex-direction: column; }
}
