/* ==========================================================================
   DKing's Hub — estilos
   Dark cálido, tipografía expresiva, identidad por juego.
   ========================================================================== */

:root {
    /* Base — dark cálido (tinte cacao/ámbar en vez de azul frío) */
    --bg: #13100f;
    --bg-raise: #1a1614;
    --card: #1f1a17;
    --card-hi: #26201c;
    --line: rgba(255, 230, 200, 0.06);
    --line-hi: rgba(255, 230, 200, 0.11);

    --text: #f4ede4;
    --text-soft: #b8aa9a;
    --text-muted: #7a6e62;

    /* Acento global del hub (ámbar cálido del clan) */
    --brand: #e8a35c;
    --brand-hi: #f5b874;

    /* Estado */
    --ok: #6ee787;
    --ok-glow: rgba(110, 231, 135, 0.35);
    --warn: #ffb547;
    --err: #ff6b6b;

    /* Por juego — mismo chroma, distinta hue. Pensados para dark bg. */
    --mc: #7bc860;         /* verde musgo */
    --mc-deep: #3a6b2d;
    --rust: #e07a3c;       /* naranja óxido */
    --rust-deep: #7a3814;
    --ts: #5aa9ff;         /* azul señal */
    --ts-deep: #1e4a80;
    --val: #e8a35c;        /* ámbar runa */
    --val-deep: #7a4a1e;

    /* Radii, shadows */
    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 20px;
    --shadow-card: 0 1px 0 rgba(255,255,255,0.02) inset, 0 20px 40px -24px rgba(0,0,0,0.6);

    /* Type */
    --f-display: 'Space Grotesk', system-ui, sans-serif;
    --f-body: 'Inter', system-ui, sans-serif;
    --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

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

html, body { height: 100%; }

body {
    font-family: var(--f-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    background-image:
        radial-gradient(900px 500px at 85% -10%, rgba(232, 163, 92, 0.06), transparent 60%),
        radial-gradient(700px 400px at 10% 10%, rgba(90, 169, 255, 0.035), transparent 60%);
    background-attachment: fixed;
}

.mono { font-family: var(--f-mono); font-feature-settings: "tnum" 1, "zero" 1; }

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(19, 16, 15, 0.78);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    border-bottom: 1px solid var(--line);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.9rem 1.75rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 2rem;
}

/* Logo */
.logo { display: flex; align-items: center; gap: 0.7rem; }
.logo-mark {
    width: 28px; height: 28px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 3px;
}
.logo-square {
    background: var(--text);
    border-radius: 2px;
}
.logo-square:nth-child(1) { background: var(--brand); }
.logo-square:nth-child(4) { background: var(--text-soft); }
.logo-text {
    font-family: var(--f-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    color: var(--text);
}
.logo-slash { color: var(--text-muted); margin: 0 2px; font-weight: 400; }
.logo-sub { color: var(--brand); }

/* Header stats */
.header-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    justify-content: center;
}
.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}
.stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 500;
}
.stat-value {
    font-family: var(--f-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin-top: 0.2rem;
}
.stat-value.mono { font-family: var(--f-mono); font-size: 0.95rem; }
.stat-divider {
    width: 1px;
    height: 22px;
    background: var(--line-hi);
}

/* Refresh indicator */
.refresh {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}
.refresh-ring {
    position: relative;
    width: 34px;
    height: 34px;
}
.refresh-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.refresh-track {
    fill: none;
    stroke: var(--line-hi);
    stroke-width: 2;
}
.refresh-progress {
    fill: none;
    stroke: var(--brand);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 97.4; /* 2 * pi * 15.5 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
    filter: drop-shadow(0 0 4px rgba(232, 163, 92, 0.45));
}
.refresh-dot {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok-glow);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.85); }
}
.refresh-text { display: flex; flex-direction: column; line-height: 1.15; }
.refresh-status {
    font-size: 0.82rem;
    color: var(--text);
    font-weight: 500;
}
.refresh-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

/* ==========================================================================
   CONTAINER
   ========================================================================== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2.5rem 1.75rem 4rem;
}

/* ==========================================================================
   HERO — saludo + destacado
   ========================================================================== */
.hero {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 2.5rem;
    align-items: center;
    margin-bottom: 3.5rem;
    padding: 0.5rem 0 1rem;
}
.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-soft);
    font-weight: 500;
    margin-bottom: 1rem;
}
.hero-eyebrow-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok-glow);
    animation: pulse 2s ease-in-out infinite;
}
.hero-title {
    font-family: var(--f-display);
    font-size: clamp(2.4rem, 4.5vw, 3.4rem);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0.9rem;
}
.hero-accent {
    font-style: italic;
    font-weight: 500;
    color: var(--brand);
    background: linear-gradient(180deg, var(--brand-hi), var(--brand));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle {
    color: var(--text-soft);
    font-size: 1.05rem;
    max-width: 46ch;
    text-wrap: pretty;
}

/* Hero featured (servidor destacado) */
.hero-featured {
    position: relative;
    background: linear-gradient(135deg, var(--card) 0%, var(--card-hi) 100%);
    border: 1px solid var(--line-hi);
    border-radius: var(--r-lg);
    padding: 1.4rem 1.5rem;
    overflow: hidden;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
}
.hero-featured::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(400px 180px at 100% 0%, color-mix(in oklab, var(--game-accent, var(--brand)) 18%, transparent), transparent 60%);
    pointer-events: none;
}
.hero-featured-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
}
.hero-featured-eyebrow {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 600;
}
.hero-featured-name {
    font-family: var(--f-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-top: 0.3rem;
}
.hero-featured-game {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--f-mono);
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in oklab, var(--game-accent, var(--brand)) 14%, transparent);
    color: var(--game-accent, var(--brand));
    border: 1px solid color-mix(in oklab, var(--game-accent, var(--brand)) 30%, transparent);
    text-transform: lowercase;
}
.hero-featured-meta {
    display: flex;
    gap: 1.5rem;
    align-items: baseline;
    position: relative;
}
.hero-featured-bignum {
    font-family: var(--f-display);
    font-size: 2.4rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
}
.hero-featured-bignum-max {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 400;
}
.hero-featured-caption {
    font-size: 0.82rem;
    color: var(--text-soft);
    line-height: 1.3;
    max-width: 22ch;
}

/* ==========================================================================
   SERVERS / SECTIONS
   ========================================================================== */
.servers-root { display: flex; flex-direction: column; gap: 2.75rem; }

.game-section {
    --game-accent: var(--brand);
    --game-accent-deep: var(--brand-deep, #7a4a1e);
}

.section-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.section-head::after {
    content: "";
    position: absolute;
    left: 0; bottom: -1px;
    width: 64px; height: 2px;
    background: var(--game-accent);
    border-radius: 2px;
    box-shadow: 0 0 12px color-mix(in oklab, var(--game-accent) 40%, transparent);
}

.section-glyph {
    width: 36px; height: 36px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--game-accent) 14%, var(--bg-raise));
    border: 1px solid color-mix(in oklab, var(--game-accent) 28%, transparent);
    color: var(--game-accent);
    flex-shrink: 0;
}
.section-glyph svg { width: 20px; height: 20px; }

.section-title {
    font-family: var(--f-display);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}
.section-sub {
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: lowercase;
    letter-spacing: 0.05em;
    margin-left: auto;
}
.section-sub strong { color: var(--game-accent); font-weight: 500; }

.servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

/* ==========================================================================
   CARD BASE
   ========================================================================== */
.server-card {
    --game-accent: var(--brand);
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 1.4rem 1.4rem 1.2rem;
    overflow: visible;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.25s,
                box-shadow 0.25s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-card);
    isolation: isolate;
}

.server-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--game-accent) 40%, transparent);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.02) inset,
        0 24px 40px -18px rgba(0,0,0,0.6),
        0 0 0 1px color-mix(in oklab, var(--game-accent) 18%, transparent);
}

/* pattern layer — overridden per game */
.card-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.55;
    z-index: 0;
    mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 95%);
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 95%);
}

.card-content { position: relative; z-index: 1; display: contents; }

/* Header row */
.server-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}
.server-identity {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    min-width: 0;
}
.server-icon {
    width: 38px; height: 38px;
    border-radius: var(--r-sm);
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--game-accent) 18%, var(--bg-raise));
    border: 1px solid color-mix(in oklab, var(--game-accent) 32%, transparent);
    color: var(--game-accent);
    flex-shrink: 0;
}
.server-icon svg { width: 20px; height: 20px; }
.server-titles { min-width: 0; }
.server-name {
    font-family: var(--f-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.server-version {
    font-family: var(--f-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-family: var(--f-mono);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}
.status-badge.online {
    background: rgba(110, 231, 135, 0.08);
    color: var(--ok);
    border: 1px solid rgba(110, 231, 135, 0.22);
}
.badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: pulse 2s ease-in-out infinite;
}

/* Info grid */
.server-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 1rem;
    padding: 0.8rem;
    border-radius: var(--r-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--line);
}
.info-item { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.info-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    font-weight: 500;
}
.info-value {
    font-family: var(--f-mono);
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.info-value .soft { color: var(--text-muted); font-weight: 400; }

/* Players with tooltip */
.players-container {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
}
.players-toggle {
    width: 16px; height: 16px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: color-mix(in oklab, var(--game-accent) 20%, transparent);
    color: var(--game-accent);
    cursor: help;
    font-size: 10px;
    font-family: var(--f-mono);
    font-weight: 600;
    border: none;
    transition: transform 0.15s;
}
.players-toggle:hover { transform: scale(1.12); }
.custom-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--bg-raise);
    border: 1px solid var(--line-hi);
    border-radius: var(--r-sm);
    padding: 0.6rem 0.8rem;
    min-width: 140px;
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.6);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
    z-index: 20;
    font-family: var(--f-body);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-soft);
    white-space: normal;
    text-align: left;
}
.custom-tooltip-title {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 600;
}
.custom-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 10px;
    border: 5px solid transparent;
    border-top-color: var(--bg-raise);
}
.players-container:hover .custom-tooltip,
.players-toggle:focus + .custom-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Latency color scale */
.latency-good { color: var(--ok); }
.latency-ok { color: var(--warn); }
.latency-bad { color: var(--err); }

/* Actions */
.server-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line-hi);
    border-radius: var(--r-sm);
    background: var(--bg-raise);
    color: var(--text);
    font-family: var(--f-body);
    font-weight: 500;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}
.btn:hover { background: var(--card-hi); border-color: color-mix(in oklab, var(--game-accent) 40%, transparent); }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: color-mix(in oklab, var(--game-accent) 14%, var(--bg-raise));
    border-color: color-mix(in oklab, var(--game-accent) 32%, transparent);
    color: var(--game-accent);
}
.btn-primary:hover {
    background: color-mix(in oklab, var(--game-accent) 22%, var(--bg-raise));
    border-color: color-mix(in oklab, var(--game-accent) 48%, transparent);
}

.btn .ip {
    font-family: var(--f-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-left: 0.1rem;
}
.btn:hover .ip { color: var(--text-soft); }

.btn.copied {
    background: rgba(110, 231, 135, 0.12);
    border-color: rgba(110, 231, 135, 0.3);
    color: var(--ok);
}
.btn.copied .ip { color: var(--ok); opacity: 0.7; }

.icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ==========================================================================
   IDENTIDAD POR JUEGO
   Cada sección/card usa --game-accent y puede tener patrón propio.
   ========================================================================== */

/* ---------- Minecraft — bloques isométricos verdes ---------- */
[data-game="minecraft"] { --game-accent: var(--mc); }
[data-game="minecraft"] .card-pattern {
    background-image:
        linear-gradient(135deg, rgba(123, 200, 96, 0.09) 25%, transparent 25%),
        linear-gradient(225deg, rgba(123, 200, 96, 0.09) 25%, transparent 25%),
        linear-gradient(45deg, rgba(123, 200, 96, 0.09) 25%, transparent 25%),
        linear-gradient(315deg, rgba(123, 200, 96, 0.09) 25%, transparent 25%);
    background-position: 0 0, 10px 0, 10px -10px, 0 10px;
    background-size: 20px 20px;
    background-color: transparent;
    opacity: 0.4;
}

/* ---------- Rust — placas de metal remachadas ---------- */
[data-game="rust"] { --game-accent: var(--rust); }
[data-game="rust"] .card-pattern {
    background-image:
        radial-gradient(circle at 10px 10px, rgba(224, 122, 60, 0.32) 1.5px, transparent 2px),
        linear-gradient(180deg, rgba(224, 122, 60, 0.06), transparent 40%);
    background-size: 40px 40px, 100% 100%;
    opacity: 0.7;
}

/* ---------- TeamSpeak — ondas de audio ---------- */
[data-game="teamspeak"] { --game-accent: var(--ts); }
[data-game="teamspeak"] .card-pattern {
    background-image:
        repeating-linear-gradient(
            90deg,
            rgba(90, 169, 255, 0.18) 0 2px,
            transparent 2px 6px,
            rgba(90, 169, 255, 0.10) 6px 8px,
            transparent 8px 14px,
            rgba(90, 169, 255, 0.22) 14px 16px,
            transparent 16px 24px
        );
    background-position: 0 18px;
    background-size: 100% 40px;
    background-repeat: no-repeat;
    opacity: 0.55;
}

/* ---------- Valheim — runas nórdicas ---------- */
[data-game="valheim"] { --game-accent: var(--val); }
[data-game="valheim"] .card-pattern {
    background-image:
        linear-gradient(45deg, rgba(232, 163, 92, 0.14) 1px, transparent 1px),
        linear-gradient(-45deg, rgba(232, 163, 92, 0.14) 1px, transparent 1px);
    background-size: 16px 16px;
    opacity: 0.5;
}

/* ---------- fallback ---------- */
[data-game="other"] { --game-accent: var(--brand); }

/* ==========================================================================
   LOADING / EMPTY
   ========================================================================== */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}
.spinner {
    width: 32px; height: 32px;
    border: 2px solid var(--line-hi);
    border-radius: 50%;
    border-top-color: var(--brand);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--card);
    border: 1px dashed var(--line-hi);
    border-radius: var(--r-md);
    color: var(--text-soft);
    max-width: 520px;
    margin: 0 auto;
}
.empty-state-title {
    font-family: var(--f-display);
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.4rem;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
    border-top: 1px solid var(--line);
    margin-top: 3rem;
    padding: 1.5rem 1.75rem 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}
.footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}
.footer-mark {
    font-family: var(--f-mono);
    color: var(--text-soft);
    font-weight: 500;
}
.footer-sep { color: var(--text-muted); opacity: 0.5; }
.footer-uptime { margin-left: auto; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 960px) {
    .header-inner { grid-template-columns: 1fr auto; gap: 1rem; }
    .header-stats { display: none; }
    .hero { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 640px) {
    .header-inner { padding: 0.8rem 1rem; }
    .container { padding: 1.8rem 1rem 3rem; }
    .refresh-text { display: none; }
    .hero-title { font-size: 2rem; }
    .servers-grid { grid-template-columns: 1fr; gap: 1rem; }
    .section-sub { display: none; }
}
