/* Thalvaren — la web como interfaz de un MMO clásico: marcos de piedra con bisel dorado, tooltips,
   colores de rareza como jerarquía, barra de acción como navegación. */

@font-face {
  font-family: "Cinzel";
  src: url("/fonts/cinzel-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel";
  src: url("/fonts/cinzel-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  --night: #07080b;
  --stone: #15161b;
  --stone-2: #1c1d24;
  --stone-3: #262731;
  --slot: #0c0d11;
  --gold: #c9a24a;
  --gold-hi: #f2d78f;
  --gold-lo: #5e4719;
  --parch: #ece4cf;
  --muted: #aaa28d;
  --tip: rgba(9, 12, 26, 0.96);
  --tip-edge: #8d93a8;
  --poor: #9d9d9d;
  --common: #ffffff;
  --uncommon: #1eff00;
  --rare: #3d93f5;
  --epic: #b562f5;
  --legendary: #ff8a1c;
  --hp: #22a833;
  --mana: #2b6fe0;
  --danger: #e4433a;
  --warn: #ffd23c;
  --display: "Cinzel", "Palatino Linotype", "Book Antiqua", serif;
  --ui: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --frame-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 30% 0%, rgba(201, 162, 74, 0.07), transparent 60%),
    radial-gradient(ellipse 120% 80% at 50% 120%, rgba(30, 40, 80, 0.35), transparent 70%),
    var(--night);
  color: var(--parch);
  font: 16px/1.55 var(--ui);
  padding-bottom: 96px; /* espacio para la barra de acción fija */
}
::selection { background: var(--gold); color: var(--night); }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--night); }
::-webkit-scrollbar-thumb { background: var(--stone-3); border: 2px solid var(--night); border-radius: 6px; }
a { color: var(--gold-hi); text-underline-offset: 3px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

.page { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------------ cabecera */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 0 6px;
}
.wordmark {
  font: 800 clamp(2.1rem, 4.2vw, 3.4rem)/1 var(--display);
  letter-spacing: 0.06em;
  color: var(--gold-hi);
  text-shadow: 0 1px 0 #fff3c9, 0 2px 0 var(--gold-lo), 0 3px 0 #2a1f0a, 0 8px 18px rgba(0, 0, 0, 0.8);
  margin: 0;
}
.status-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 14px; border: 1px solid var(--gold-lo); border-radius: 999px;
  background: rgba(12, 13, 17, 0.8); color: var(--muted); font-size: 0.9rem; white-space: nowrap;
}
.status-chip b { color: var(--parch); font-weight: 600; }
.led { width: 9px; height: 9px; border-radius: 50%; background: var(--poor); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.led.on { background: var(--uncommon); }
.led.maint { background: var(--danger); }
.tagline { margin: 6px 0 22px; color: var(--muted); max-width: 62ch; font-size: 1.05rem; }

/* ------------------------------------------------------------------ marco de ventana del juego */
.frame {
  position: relative;
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border: 2px solid var(--gold-lo);
  border-radius: 6px;
  box-shadow: var(--frame-shadow), inset 0 0 0 1px #000, inset 0 1px 0 rgba(242, 215, 143, 0.18);
}
.frame::before { /* filete dorado interior, como los marcos de la interfaz */
  content: ""; position: absolute; inset: 5px; border: 1px solid rgba(201, 162, 74, 0.35); border-radius: 3px; pointer-events: none;
}
.frame-title {
  position: relative; margin: -2px -2px 0; padding: 10px 18px;
  background: linear-gradient(180deg, #2b2416, #17130b);
  border-bottom: 1px solid var(--gold-lo); border-radius: 6px 6px 0 0;
  font: 600 1.05rem/1.2 var(--display); letter-spacing: 0.04em; color: var(--gold-hi);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.frame-title small { font: 400 0.85rem var(--ui); letter-spacing: 0; color: var(--muted); }
.frame-body { position: relative; padding: 18px 20px 20px; }

/* ------------------------------------------------------------------ primera pantalla */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }

.realms { width: 100%; border-collapse: collapse; }
.realms th {
  text-align: left; font: 600 0.78rem var(--ui); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold); padding: 6px 12px 10px; border-bottom: 1px solid var(--stone-3);
}
.realms td { padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.realms tbody tr { transition: background-color .15s ease-out; }
.realms tbody tr:hover { background: rgba(201, 162, 74, 0.06); }
.realms tr.recommended { background: rgba(201, 162, 74, 0.11); }
.realms tr.recommended td:first-child { box-shadow: inset 2px 0 0 var(--gold-hi); }
.realm-name { font-weight: 600; color: var(--common); }
.realm-hint { display: block; font-size: 0.8rem; color: var(--gold-hi); }
.pop-quiet { color: var(--poor); } .pop-low { color: var(--uncommon); } .pop-mid { color: var(--warn); } .pop-high { color: var(--legendary); }
.lat-good { color: var(--uncommon); } .lat-ok { color: var(--warn); } .lat-bad { color: var(--danger); }
.state-on { color: var(--uncommon); } .state-maint { color: var(--danger); }

.realm-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

/* Botones de la interfaz: placa de metal con bisel */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 22px; cursor: pointer; text-decoration: none;
  font: 600 1rem var(--display); letter-spacing: 0.03em; color: var(--gold-hi);
  background: linear-gradient(180deg, #3a2a10, #1f160a);
  border: 1px solid var(--gold); border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, 0.25), 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: filter .15s ease-out, transform .1s ease-out;
}
.btn:hover { filter: brightness(1.25); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.primary { color: #1a1206; background: linear-gradient(180deg, #f5d98d, #b98d32); border-color: #fff0bf; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
.btn svg { width: 18px; height: 18px; }

/* Minimapa */
.minimap-wrap { display: grid; justify-items: center; gap: 10px; padding: 20px 16px 18px; }
.minimap {
  width: 240px; height: 240px; border-radius: 50%; overflow: hidden; position: relative;
  border: 4px solid var(--gold-lo); box-shadow: 0 0 0 2px #000, 0 0 0 5px var(--gold), 0 14px 30px rgba(0,0,0,.6);
  background: #0e1a12;
}
.minimap canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.minimap .night { position: absolute; inset: 0; background: rgba(10, 20, 60, 0.45); mix-blend-mode: multiply; pointer-events: none; }
.zone-name { font: 600 1.05rem var(--display); color: var(--gold-hi); letter-spacing: .05em; }
.zone-sub { font-size: .85rem; color: var(--muted); margin-top: -6px; }

/* Marco de unidad (jugadores en línea) */
.unit { display: grid; gap: 6px; padding: 14px 18px 18px; border-top: 1px solid var(--stone-3); }
.unit-row { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.unit-row b { color: var(--parch); }
.bar { height: 14px; background: #000; border: 1px solid #000; border-radius: 2px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.bar > i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.bar.hp > i { background: linear-gradient(180deg, #46d655, var(--hp)); }
.bar.mana > i { background: linear-gradient(180deg, #5c95ff, var(--mana)); }

.banner {
  margin: 0 0 18px; padding: 12px 18px; border: 1px solid var(--danger); border-radius: 4px;
  background: rgba(90, 14, 10, 0.55); color: #ffd9d4; font-weight: 600;
}

/* ------------------------------------------------------------------ secciones */
.section { margin-top: 56px; }
.section > h2 {
  font: 600 clamp(1.5rem, 2.6vw, 2rem)/1.15 var(--display); color: var(--gold-hi); letter-spacing: .05em;
  margin: 0 0 6px; text-shadow: 0 2px 0 #000;
}
.section > p.lead { margin: 0 0 22px; color: var(--muted); max-width: 70ch; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }

/* Descargas como ranuras de objeto */
.downloads { display: flex; flex-wrap: wrap; gap: 14px; }
.item-slot {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 14px; min-width: 260px;
  padding: 10px 16px 10px 10px; text-decoration: none; color: var(--parch);
  background: var(--slot); border: 1px solid var(--stone-3); border-radius: 4px;
  transition: border-color .15s ease-out, background-color .15s ease-out;
}
.item-slot:hover, .item-slot:focus-visible { border-color: var(--epic); background: #120c18; }
.item-icon {
  width: 56px; height: 56px; display: grid; place-items: center; border-radius: 3px;
  border: 2px solid var(--epic); background: radial-gradient(circle at 35% 30%, #3a2350, #120a1a);
  box-shadow: inset 0 2px 10px rgba(181, 98, 245, .3);
}
.item-icon svg { width: 30px; height: 30px; color: #e8d5ff; }
.item-name { display: block; color: var(--epic); font-weight: 700; }
.item-meta { display: block; font-size: .85rem; color: var(--muted); }

/* Formularios */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .85rem; color: var(--gold); letter-spacing: .03em; }
.field input, .field select {
  min-height: 42px; padding: 0 12px; font: 1rem var(--ui); color: var(--parch);
  background: #08090c; border: 1px solid var(--stone-3); border-radius: 3px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); box-shadow: inset 0 2px 6px rgba(0,0,0,.6), 0 0 0 2px rgba(201,162,74,.25); }
.field input::placeholder { color: #8a8371; }
.field .hint { font-size: .8rem; color: var(--muted); }
.msg { min-height: 24px; margin-top: 10px; font-weight: 600; }
.msg.err { color: #ff8c84; } .msg.ok { color: var(--uncommon); }

/* Selección de personaje */
.chars { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.char {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px;
  padding: 10px 14px; background: var(--slot); border: 1px solid var(--stone-3); border-radius: 4px;
}
.portrait { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px rgba(0,0,0,.45); }
.char-name { font-weight: 700; }
.char-meta { font-size: .85rem; color: var(--muted); }
.char-level { font: 600 .9rem var(--display); color: var(--gold-hi); }

/* Clases: retratos con tooltip de objeto */
.classes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.class-card {
  display: grid; justify-items: center; gap: 12px; padding: 22px 14px 18px; cursor: default;
  background: var(--slot); border: 1px solid var(--stone-3); border-radius: 4px; text-align: center;
  transition: border-color .15s ease-out, transform .15s ease-out;
}
.class-card:hover, .class-card:focus-visible { border-color: var(--gold); transform: translateY(-2px); }
.class-sigil { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; border: 3px solid currentColor; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.12), rgba(0,0,0,.5)); }
.class-sigil svg { width: 40px; height: 40px; }
.class-card h3 { margin: 0; font: 600 1.15rem var(--display); letter-spacing: .05em; }
.class-card p { margin: 0; font-size: .9rem; color: var(--muted); }

/* Tooltip estilo objeto */
.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 320px; padding: 10px 12px;
  background: var(--tip); border: 1px solid var(--tip-edge); border-radius: 4px;
  box-shadow: 0 6px 12px rgba(0,0,0,.6); font-size: .9rem; line-height: 1.4;
}
.tip .t-name { font-weight: 700; font-size: 1rem; }
.tip .t-line { color: var(--common); }
.tip .t-dim { color: var(--muted); }
.tip .t-green { color: var(--uncommon); }
.tip .t-gold { color: var(--gold-hi); }
.tip hr { border: 0; border-top: 1px solid rgba(141,147,168,.35); margin: 7px 0; }

/* Registro de misiones (zonas y novedades) */
.questlog { display: grid; grid-template-columns: 260px 1fr; min-height: 280px; }
.ql-list { border-right: 1px solid var(--stone-3); padding: 10px 0; margin: 0; list-style: none; }
.ql-list button {
  width: 100%; text-align: left; padding: 9px 18px; cursor: pointer; background: none; border: 0;
  font: 600 .95rem var(--ui); color: var(--warn);
}
.ql-list button[aria-selected="true"] { background: rgba(201,162,74,.14); color: var(--common); }
.ql-list button .lvl { color: var(--muted); font-weight: 400; margin-left: 6px; }
.ql-detail { padding: 18px 24px; }
.ql-detail h3 { margin: 0 0 8px; font: 600 1.25rem var(--display); color: var(--gold-hi); }
.ql-detail p { margin: 0 0 12px; max-width: 65ch; }
.ql-detail ul { margin: 0; padding-left: 20px; }
.ql-detail li { margin-bottom: 6px; }

footer { margin-top: 64px; padding: 26px 0 10px; border-top: 1px solid var(--stone-3); color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ------------------------------------------------------------------ barra de acción (navegación) */
.actionbar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 40;
  display: flex; gap: 6px; padding: 8px 10px 10px;
  background: linear-gradient(180deg, #23201a, #110f0b);
  border: 2px solid var(--gold-lo); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.7), inset 0 1px 0 rgba(242,215,143,.2);
}
.slot {
  position: relative; width: 58px; height: 58px; padding: 0; cursor: pointer; overflow: hidden;
  display: grid; place-items: center; color: #e9dcc0;
  background: radial-gradient(circle at 35% 30%, #34302a, #0b0a08);
  border: 2px solid #4a3d22; border-radius: 4px;
  box-shadow: inset 0 0 0 1px #000, inset 0 -8px 14px rgba(0,0,0,.55);
  transition: border-color .12s ease-out;
}
.slot svg { width: 30px; height: 30px; }
.slot:hover, .slot:focus-visible { border-color: var(--gold-hi); }
.slot.glow { border-color: var(--gold); box-shadow: inset 0 0 0 1px #000, inset 0 -8px 14px rgba(0,0,0,.55), 0 2px 12px rgba(242, 215, 143, .4); }
.slot .key { position: absolute; top: 2px; right: 5px; font: 700 .78rem var(--ui); color: #fff; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.slot .label { position: absolute; left: 0; right: 0; bottom: 1px; font-size: .7rem; color: #cfc5ad; text-shadow: 0 1px 2px #000; text-align: center; }
.slot::after { /* barrido de enfriamiento */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: conic-gradient(from 0deg, rgba(0,0,0,.72) var(--cd, 0%), transparent 0);
}
.slot.cooldown::after { opacity: 1; animation: cooldown 900ms linear forwards; }
@property --cd { syntax: "<percentage>"; inherits: false; initial-value: 100%; }
@keyframes cooldown { from { --cd: 100%; } to { --cd: 0%; } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1000px) {
  .stage { grid-template-columns: 1fr; }
  .minimap-wrap { grid-template-columns: auto 1fr; justify-items: start; align-items: center; }
  .minimap { width: 150px; height: 150px; }
  .classes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body { padding-bottom: 88px; }
  .top { flex-direction: column; align-items: flex-start; }
  .cols, .questlog { grid-template-columns: 1fr; }
  .ql-list { border-right: 0; border-bottom: 1px solid var(--stone-3); display: flex; overflow-x: auto; padding: 0; }
  .ql-list button { white-space: nowrap; }
  .realms thead { display: none; }
  .realms tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 6px; border-bottom: 1px solid var(--stone-3); }
  .realms td { padding: 0 6px; border: 0; }
  .realms td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .realms tr { padding: 8px 4px; }
  .realms tr:not(.recommended) td[data-label="Latencia"], .realms tr:not(.recommended) td[data-label="Población"]::before { display: none; }
  .realm-name { font-size: .95rem; }
  .tagline { font-size: 1rem; }
  .actionbar { left: 0; right: 0; bottom: 0; transform: none; border-radius: 0; justify-content: center; padding: 6px 4px 8px; }
  .slot { width: 52px; height: 52px; }
  .item-slot { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .slot.cooldown::after { animation: none; opacity: 0; }
  .bar > i, .class-card { transition: none; }
}
