/* ══════════════════════════════════════════════════════════════════
   MasterMu — componentes compartidos por Inicio, Panel y Ranking.

   Todo lo que aparece en más de una página vive aquí. Las páginas solo
   añaden lo que es exclusivamente suyo.
   ══════════════════════════════════════════════════════════════════ */

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

html { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;

  /* Antes había `overflow:hidden` con alturas fijas: a la altura mínima
     del launcher el contenido se recortaba sin forma de llegar a él.
     Ahora el que desplaza es el área de contenido, no el documento. */
  overflow: hidden;
}

/* ── Estructura ───────────────────────────────────────────────── */

.shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--pad) calc(var(--pad) + 4px);
}

.shell > header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border-soft);
}

/* El área que desplaza. min-height:0 es lo que permite que un hijo
   flexible pueda encogerse por debajo de su contenido y desplazar. */
.shell > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-top: var(--gap);
}

/* ── Pie ──────────────────────────────────────────────────────
   Una sola linea, delgada, presente con sesion y sin ella. Antes esto
   era un bloque de dos columnas y el enlace de la guia vivia en una
   tarjeta de 90 px de alto dentro del contenido; en un area util de
   335 px eso es una cuarta parte de la pantalla gastada en un enlace. */

footer.thin {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
footer.thin .who { color: var(--muted); }
footer.thin .sep { color: var(--border); }
footer.thin .lead { color: var(--muted); }

/* El enlace externo se marca con la flecha para que se vea que sale del
   launcher antes de pulsarlo, no despues. */
footer.thin .ext {
  color: var(--warm-text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
footer.thin .ext::after {
  content: "\2197";
  font-size: 11px;
  margin-left: 3px;
}
footer.thin .ext:hover {
  color: var(--warm-hover);
  border-bottom-color: var(--warm-dim);
  text-decoration: none;
}
footer.thin .ext:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Barras de desplazamiento acordes al tema ─────────────────── */

*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
  border-radius: 5px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--surface-hover); }

/* ── Marca ────────────────────────────────────────────────────── */

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

/* Rombo facetado dibujado con CSS: mismo gesto que la joya que el
   launcher dibuja proceduralmente. Sin archivo de imagen. */
.brand .mark {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--surface-hover), var(--panel-deep));
  border: 1px solid var(--warm-dim);
  transform: rotate(45deg);
}
.brand .mark span {
  transform: rotate(-45deg);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  color: var(--warm-text);
  line-height: 1;
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 300;              /* ligero: es lo que lo hace elegante */
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--bright);
  line-height: 1.2;
}

.brand .sub {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Títulos de sección ───────────────────────────────────────── */

.section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* ── Estadísticas de cabecera ─────────────────────────────────── */

.stats { display: flex; gap: 20px; align-items: center; flex: 0 0 auto; }
.stat { text-align: right; }
.stat .k {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--muted);
}
.stat .v {
  display: block;
  font-size: 16px;
  color: var(--text);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.stat .v.on { color: var(--warm-text); }

/* ── Píldora de estado ────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 10px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted);
  white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.up      { border-color: rgba(95,184,106,.4); color: var(--success-text); }
.pill.up .dot { background: var(--success-text); }
.pill.down      { border-color: rgba(169,73,79,.5); color: var(--danger-text); }
.pill.down .dot { background: var(--danger-text); }

/* ── Superficies de contenido ─────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 15px 16px;
}

.rail {
  background: var(--panel-deep);
  border: 1px solid var(--border-soft);
  padding: 14px;
  min-height: 0;
}

/* ── Botones ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--bright);
  font: inherit; font-size: 12px;
  text-transform: uppercase; letter-spacing: .12em;
  padding: 9px 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent);
  /* Los botones que son <a> heredaban el subrayado de la regla `a:hover`
     y quedaban subrayados al pasar por encima. Un boton no se subraya. */
  text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--surface-hover); border-color: var(--border); }

.btn.full { width: 100%; }

/* La acción principal. Igual que en el launcher: ámbar sólido con
   texto oscuro encima (7.2:1). Texto claro sobre ámbar se quedaría en
   2.25:1, ilegible — por eso el texto invierte. */
.btn.primary {
  background: var(--warm);
  border-color: var(--warm);
  color: var(--bg);
  font-weight: 700;
}
.btn.primary:hover { background: var(--warm-hover); border-color: var(--warm-hover); }

/* Un ámbar con opacidad reducida sobre fondo oscuro no se lee como
   "apagado": se lee como verde oliva sucio. El estado deshabilitado
   abandona el color de acento y vuelve a superficie neutra. */
.btn.primary[disabled],
.btn.primary[disabled]:hover {
  background: var(--surface-alt);
  border-color: var(--border-soft);
  color: var(--muted);
  opacity: 1;
}

.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-hover); border-color: var(--accent); color: var(--bright); }

/* ── Campos ───────────────────────────────────────────────────── */

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 10px; text-transform: uppercase; letter-spacing: .13em;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font: inherit; font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover { border-color: var(--border); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(165,120,43,.18);
}
input::placeholder { color: var(--muted); opacity: .8; }

.row { display: flex; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 0; }
.row + .row { margin-top: 8px; }

/* ── Enlaces ──────────────────────────────────────────────────── */

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--warm-text); text-decoration: underline; }
a:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Estado vacío ─────────────────────────────────────────────── */

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  background: var(--surface);
}
.empty h3 {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 400;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: .06em;
}
.empty p { font-size: 12.5px; max-width: 460px; margin: 0 auto; }

/* ── Acceso a la cuenta (cabecera) ────────────────────────────
   No es un boton del launcher: es un enlace de la propia pagina, y por
   eso vive aqui y no en C#. Lleva a panel.php dentro del mismo WebView,
   igual que Inicio o Ranking. */

.account {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 13px 6px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.account:hover {
  background: var(--surface-hover);
  border-color: var(--warm-dim);
  text-decoration: none;
}
.account:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.account .ico {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--surface-hover);
  border: 1px solid var(--warm-dim);
  color: var(--warm-text);
  font-family: var(--font-display);
  font-size: 13px; font-weight: 400;
  line-height: 1;
}

.account .k {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--warm-text);
}
.account .v {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account.is-in .v { color: var(--bright); }

/* ── Emblema de gremio ────────────────────────────────────────
   Rejilla de 8x8 celdas: los mismos 32 bytes del G_Mark, sin GD, sin
   imagen y sin una peticion HTTP por clan. Las celdas del indice 0 se
   quedan sin fondo, que es como el juego las trata: transparentes. */

.gmark {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 32px; height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  /* Los emblemas son pixel art: sin esto los bordes de cada celda se
     ven suavizados por el subpixel del navegador. */
  image-rendering: pixelated;
}
.gmark > i { display: block; }
.gmark.is-empty { background: var(--surface-alt); }
.gmark.lg { width: 56px; height: 56px; }

/* ── Pantalla de acceso ───────────────────────────────────────
   Sin sesion, Inicio es SOLO esto. El pie sigue abajo, asi que la
   tarjeta se centra en el hueco que queda, no en la ventana entera:
   por eso `.gate` es una columna flexible y no un grid de 100vh. */

.gate {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--pad) calc(var(--pad) + 4px);
}
.gate-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 8px 0;

  /* `safe center` y no `center` a secas: cuando el contenido es mas alto
     que el contenedor, un centrado normal desborda por ARRIBA y esa
     parte no se puede alcanzar desplazando. Con safe, en ese caso se
     alinea al principio y todo queda accesible. Importa aqui porque la
     ventana del launcher se puede achicar. */
  align-items: safe center;
}

.card-login {
  width: 340px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-top: 3px solid var(--warm);
  padding: 22px 24px 20px;
  box-shadow: var(--shadow);
}
.card-login .brand { margin-bottom: 18px; }
.card-login .note {
  margin-top: 13px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.alert {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 11px; margin-bottom: 13px;
  font-size: 12.5px; line-height: 1.45;
  border: 1px solid var(--danger-hover);
  border-left-width: 3px;
  background: rgba(169,73,79,.12);
  color: var(--danger-text);
}

/* ── Identidad en la cabecera del panel ───────────────────────── */

.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; flex: 0 0 auto;
  background: var(--surface-hover);
  border: 1px solid var(--warm-dim);
  display: grid; place-items: center;
  color: var(--warm-text);
  font-family: var(--font-display); font-weight: 400; font-size: 15px;
}
.who .name {
  font-size: 15px; color: var(--bright);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who .role {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .15em;
  color: var(--muted);
}

/* Los botones de la cabecera van juntos y no se estiran. El form de
   salir es un elemento de bloque: sin esto se lleva una linea entera. */
.head-actions {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto; flex-wrap: wrap;
}
.head-actions form { display: contents; }

/* ── Acceso a la cuenta (cabecera de Inicio) ──────────────────
   No es un boton del launcher: es un enlace de la propia pagina, y por
   eso vive aqui y no en C#. Lleva a panel.php dentro del mismo WebView,
   igual que cualquier otra pagina del sitio. */

.account {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 13px 6px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.account:hover {
  background: var(--surface-hover);
  border-color: var(--warm-dim);
  text-decoration: none;
}
.account:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.account .ico {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--surface-hover);
  border: 1px solid var(--warm-dim);
  color: var(--warm-text);
  font-family: var(--font-display);
  font-size: 13px; font-weight: 400;
  line-height: 1;
}

.account .k {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--warm-text);
}
.account .v {
  display: block;
  font-size: 12px;
  color: var(--bright);
  margin-top: 2px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Emblema de gremio ────────────────────────────────────────
   Rejilla de 8x8 celdas: los mismos 32 bytes del G_Mark, sin GD, sin
   imagen y sin una peticion HTTP por clan. Las celdas del indice 0 se
   quedan sin fondo, que es como el juego las trata: transparentes. */

.gmark {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--border-soft);
  background: var(--bg);
  image-rendering: pixelated;
}
.gmark > i { display: block; }
.gmark.is-empty { background: var(--surface-alt); }
.gmark.lg { width: 52px; height: 52px; }

/* ── Accesibilidad ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.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;
}
