/* ==========================================================================
   Rolario — global.css
   Solo estilos compartidos: variables, tipografía, botones, navegación,
   tarjetas de servidor, etiquetas, modal, toast, footer y utilidades.
   ========================================================================== */

:root {
  /* Superficies */
  --bg: #0e111a;
  --panel: #151a26;
  --card: #1b2132;
  --card-hover: #212840;
  --border: #2a3248;
  --border-strong: #3a4564;

  /* Marca */
  --accent: #6c7bff;
  --accent-2: #a06bff;
  --accent-soft: rgba(108, 123, 255, 0.14);
  --brand-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));

  /* Texto */
  --text: #e8eaf2;
  --text-muted: #9aa3b8;

  /* Estados */
  --ok: #3ddc97;
  --warn: #f5b945;
  --danger: #f2555f;

  /* Colores de grupo de etiqueta */
  --g-universo: #7b8cff;
  --g-tipo: #b98aff;
  --g-personajes: #5fd0e6;
  --g-sistemas: #f5b945;
  --g-idioma: #3ddc97;
  --g-edad: #f2877f;
  --g-tematica: #e58ad4;

  /* Tipografía */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Escala */
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-2xl: clamp(2rem, 1.4rem + 2.6vw, 3.4rem);

  /* Forma */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --container: 1200px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Reset ligero */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.6;
}
main {
  flex: 1;
}
img,
svg {
  max-width: 100%;
  display: block;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--fs-2xl);
}
h2 {
  font-size: var(--fs-xl);
}
h3 {
  font-size: var(--fs-lg);
}
p {
  margin: 0 0 1em;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}

/* Foco visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  top: 0.5rem;
}

/* Utilidades */
.container {
  width: min(100% - 2rem, var(--container));
  margin-inline: auto;
}
.section {
  padding-block: 3rem;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
}
.section-head p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}
.muted {
  color: var(--text-muted);
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.grid-cards {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-sm);
  line-height: 1.2;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.15s;
}
.btn:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-gradient);
  filter: brightness(1.1);
}
.btn-ghost {
  border-color: transparent;
  color: var(--text-muted);
}
.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: var(--fs-base);
}
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.btn-icon {
  padding: 0.55rem;
  aspect-ratio: 1;
}
.btn-fav[aria-pressed="true"] {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(242, 85, 95, 0.1);
}

/* ---------- Cabecera y navegación ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(14, 17, 26, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
}
.brand:hover {
  text-decoration: none;
}
.brand svg {
  width: 30px;
  height: 30px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}
.nav a {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.nav a:hover {
  color: var(--text);
  background: var(--card);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.nav a.nav-profile {
  border: 1px solid var(--border-strong);
  margin-left: 0.5rem;
}
.menu-toggle {
  display: none;
  margin-left: auto;
}

@media (max-width: 860px) {
  .menu-toggle {
    display: inline-flex;
  }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 0 auto;
    width: min(80vw, 320px);
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    margin: 0;
    padding: 1rem;
    background: var(--panel);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    visibility: hidden;
    transition:
      transform 0.25s var(--ease),
      visibility 0.25s;
  }
  .nav.is-open {
    transform: none;
    visibility: visible;
  }
  .nav a {
    padding: 0.8rem 1rem;
    font-size: var(--fs-base);
  }
  .nav a.nav-profile {
    margin: 0.5rem 0 0;
    text-align: center;
  }
}

/* ---------- Formularios ---------- */
.input,
.select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.input::placeholder {
  color: var(--text-muted);
}
.input:hover,
.select:hover {
  border-color: var(--border-strong);
}
.input:focus-visible,
.select:focus-visible {
  border-color: var(--accent);
  outline-offset: 0;
}
.select {
  appearance: none;
  padding-right: 2rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 55%,
    calc(100% - 13px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* ---------- Etiquetas ---------- */
.tag {
  --tag-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tag-color);
  background: color-mix(in srgb, var(--tag-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color) 35%, transparent);
  transition: background 0.2s;
}
a.tag:hover,
button.tag:hover {
  background: color-mix(in srgb, var(--tag-color) 26%, transparent);
  text-decoration: none;
}
.tag[data-group="universo"] {
  --tag-color: var(--g-universo);
}
.tag[data-group="tipo"] {
  --tag-color: var(--g-tipo);
}
.tag[data-group="personajes"] {
  --tag-color: var(--g-personajes);
}
.tag[data-group="sistemas"] {
  --tag-color: var(--g-sistemas);
}
.tag[data-group="idioma"] {
  --tag-color: var(--g-idioma);
}
.tag[data-group="edad"] {
  --tag-color: var(--g-edad);
}
.tag[data-group="tematica"] {
  --tag-color: var(--g-tematica);
}
.tag[aria-pressed="true"] {
  background: var(--tag-color);
  color: #0e111a;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ---------- Actividad ---------- */
.activity {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.activity::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.18);
}
.activity[data-level="media"]::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(245, 185, 69, 0.18);
}
.activity[data-level="baja"]::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(242, 85, 95, 0.18);
}

/* ---------- Tarjeta de servidor ---------- */
.server-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.2s var(--ease);
}
.server-card:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.server-card__top {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}
.server-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.server-icon {
  overflow: hidden;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  background: linear-gradient(
    135deg,
    hsl(var(--hue, 230) 70% 55%),
    hsl(calc(var(--hue, 230) + 50) 70% 40%)
  );
}
.server-card__title {
  min-width: 0;
  flex: 1;
}
.server-card__title h3 {
  margin: 0;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-card__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.server-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.server-card__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.server-card__actions .btn {
  flex: 1;
}
.server-card .tag-list {
  min-height: 1.6rem;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(6, 8, 14, 0.75);
  backdrop-filter: blur(3px);
}
.modal-backdrop[hidden] {
  display: none;
}
.modal {
  width: min(100%, 460px);
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: modal-in 0.2s var(--ease);
}
.modal h2 {
  font-size: 1.4rem;
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: grid;
  gap: 0.5rem;
}
.toast {
  padding: 0.65rem 1.1rem;
  background: var(--card-hover);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  animation: modal-in 0.2s var(--ease);
}

/* ---------- Estado vacío ---------- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}
.empty-state h3 {
  color: var(--text);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding-block: 3rem 2rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 2fr repeat(3, 1fr);
}
.footer-grid h4 {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  margin-bottom: 0.75rem;
}
.footer-grid li {
  margin-bottom: 0.4rem;
}
.footer-grid a {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.footer-grid a:hover {
  color: var(--text);
}
.footer-note {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}
@media (max-width: 720px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
  .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
}

/* Accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Lista de ranking (compartida: inicio y rankings) ---------- */
.rank-list {
  display: grid;
  gap: 0.5rem;
  counter-reset: r;
}
.rank-list li {
  counter-increment: r;
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.rank-list li::before {
  content: "#" counter(r);
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5ch;
}
.rank-list a {
  color: var(--text);
  font-weight: 600;
  flex: 1;
}
.rank-list .metric {
  color: var(--text-muted);
  font-size: 0.85rem;
}
