/* RuneScape: Dragonwilds theme on top of Bootstrap 5 (dark). Stone panels, gold trim, ember accents. */

:root, [data-bs-theme="dark"] {
    --dw-bg: #0c0e11;
    --dw-panel: #15181d;
    --dw-panel-2: #1b1f26;
    --dw-border: #2b303a;
    --dw-gold: #d4a64a;
    --dw-gold-light: #f3d58a;
    --dw-ember: #e8742a;
    --dw-red: #c0392b;
    --dw-parchment: #efe2c2;
    --dw-text: #d8d3c6;
    --dw-muted: #8f897c;
    --dw-green: #6cc070;

    --bs-body-bg: var(--dw-bg);
    --bs-body-color: var(--dw-text);
    --bs-secondary-color: var(--dw-muted);
    --bs-border-color: var(--dw-border);
    --bs-tertiary-bg: var(--dw-panel-2);
    --bs-emphasis-color: var(--dw-parchment);
    --bs-link-color: var(--dw-gold-light);
    --bs-link-color-rgb: 243, 213, 138;
    --bs-link-hover-color: #fff0c4;
    --bs-link-hover-color-rgb: 255, 240, 196;
    --bs-primary: var(--dw-ember);
    --bs-primary-rgb: 232, 116, 42;
    --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 50% -120px, rgba(232, 116, 42, .16), transparent 70%),
        radial-gradient(800px 400px at 100% 0, rgba(179, 38, 30, .10), transparent 70%),
        var(--dw-bg);
    background-attachment: fixed;
}

h1, h2, h3, .font-display, .navbar-brand, .dw-card-title, .stat-label {
    font-family: "Cinzel", Georgia, "Times New Roman", serif;
    letter-spacing: .02em;
}
h1, h2, h3 { color: var(--dw-parchment); }

::selection { background: rgba(232, 116, 42, .45); }

/* ---------- sparks drifting up the page ---------- */
.embers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.embers span {
    position: absolute;
    bottom: -10px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #ffb35c;
    box-shadow: 0 0 6px 2px rgba(232, 116, 42, .7);
    opacity: 0;
    animation: rise linear infinite;
}
@keyframes rise {
    0% { transform: translate(0, 0); opacity: 0; }
    10% { opacity: .9; }
    100% { transform: translate(var(--drift, 30px), -105vh); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .embers { display: none; } .pulse::after { animation: none !important; } }
main, nav, footer { position: relative; z-index: 1; }

/* ---------- navbar ---------- */
.dw-nav {
    background: linear-gradient(180deg, rgba(21, 24, 29, .96), rgba(16, 18, 22, .96));
    border-bottom: 1px solid var(--dw-border);
    box-shadow: 0 1px 0 rgba(212, 166, 74, .25), 0 8px 24px rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
}
.navbar-brand { color: var(--dw-parchment) !important; font-weight: 700; }
.navbar-brand img { width: 34px; height: 34px; filter: drop-shadow(0 0 6px rgba(232, 116, 42, .45)); }
.brand-sub { font-family: var(--bs-font-sans-serif); font-size: .72rem; color: var(--dw-muted); letter-spacing: .08em; text-transform: uppercase; }
.dw-tabs .nav-link {
    color: var(--dw-muted);
    border-radius: .4rem;
    padding: .4rem .75rem;
    font-weight: 500;
}
.dw-tabs .nav-link:hover { color: var(--dw-parchment); background: rgba(255, 255, 255, .04); }
.dw-tabs .nav-link.active {
    color: var(--dw-gold-light);
    background: rgba(212, 166, 74, .12);
    box-shadow: inset 0 -2px 0 var(--dw-gold);
}
.nav-divider { width: 1px; align-self: stretch; margin: .35rem .4rem; background: var(--dw-border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--dw-gold); object-fit: cover; }

.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.btn-discord:hover, .btn-discord:focus { background: #4752c4; border-color: #4752c4; color: #fff; }

/* ---------- buttons ---------- */
.btn-ember {
    color: #1a0f05;
    font-weight: 600;
    background: linear-gradient(180deg, #f6a04d, #d9601b);
    border: 1px solid #f0a35a;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .3), 0 4px 14px rgba(232, 116, 42, .25);
}
.btn-ember:hover, .btn-ember:focus { color: #1a0f05; filter: brightness(1.08); }
.btn-gold {
    color: var(--dw-gold-light);
    border: 1px solid rgba(212, 166, 74, .55);
    background: rgba(212, 166, 74, .06);
}
.btn-gold:hover, .btn-gold:focus { color: #fff3cf; background: rgba(212, 166, 74, .16); border-color: var(--dw-gold); }
.btn-danger-soft { color: #ff9c8f; border: 1px solid rgba(192, 57, 43, .6); background: rgba(192, 57, 43, .08); }
.btn-danger-soft:hover, .btn-danger-soft:focus { color: #fff; background: rgba(192, 57, 43, .35); border-color: var(--dw-red); }
.btn:disabled { opacity: .45; }

/* ---------- panels ---------- */
.dw-card {
    background: linear-gradient(180deg, var(--dw-panel-2), var(--dw-panel));
    border: 1px solid var(--dw-border);
    border-radius: .7rem;
    box-shadow: inset 0 1px 0 rgba(212, 166, 74, .28), 0 10px 30px rgba(0, 0, 0, .35);
    position: relative;
}
.dw-card > .card-body { padding: 1.15rem 1.25rem; }
.dw-card-title {
    color: var(--dw-gold-light);
    font-size: .95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.dw-card-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(212, 166, 74, .45), transparent); }

/* ---------- hero ---------- */
.hero {
    border-radius: .9rem;
    border: 1px solid var(--dw-border);
    background:
        linear-gradient(180deg, rgba(12, 14, 17, .1), rgba(12, 14, 17, .85)),
        radial-gradient(700px 260px at 20% 0, rgba(232, 116, 42, .22), transparent 70%),
        linear-gradient(135deg, #1d1a17, #12151a 60%);
    box-shadow: inset 0 1px 0 rgba(212, 166, 74, .35), 0 16px 40px rgba(0, 0, 0, .45);
    overflow: hidden;
    position: relative;
}
.hero-mountains { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 110px; opacity: .55; pointer-events: none; }
.hero .card-body { position: relative; padding: 1.75rem 1.75rem 2rem; }
.hero-title {
    font-size: clamp(1.7rem, 3.2vw, 2.6rem);
    font-weight: 700;
    background: linear-gradient(180deg, #fff1c8, var(--dw-gold) 70%, #9b6c22);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 2px 18px rgba(232, 116, 42, .25);
}
.address-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .5rem .35rem .8rem;
    border-radius: .5rem;
    background: rgba(0, 0, 0, .35);
    border: 1px solid var(--dw-border);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    color: var(--dw-parchment);
}

/* ---------- status ---------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .8rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: .9rem;
    border: 1px solid currentColor;
    background: rgba(0, 0, 0, .3);
}
.status-pill .dot { width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; position: relative; }
.pulse::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(3); opacity: 0; } }
.st-active { color: var(--dw-green); }
.st-activating, .st-deactivating, .st-reloading { color: #f1c40f; }
.st-failed { color: #ff6b5b; }
.st-inactive, .st-unknown { color: #9aa0a6; }

/* ---------- stat tiles ---------- */
.stat {
    background: rgba(0, 0, 0, .22);
    border: 1px solid var(--dw-border);
    border-radius: .6rem;
    padding: .85rem 1rem;
    height: 100%;
}
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--dw-muted); }
.stat-value { font-size: 1.45rem; font-weight: 700; color: var(--dw-parchment); line-height: 1.25; margin-top: .15rem; }
.stat-sub { font-size: .8rem; color: var(--dw-muted); }
.slots { display: flex; gap: .3rem; margin-top: .45rem; }
.slots i { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); }
.slots i.on { background: linear-gradient(90deg, var(--dw-ember), var(--dw-gold)); box-shadow: 0 0 8px rgba(232, 116, 42, .5); }

/* ---------- players ---------- */
.player-row { display: flex; align-items: center; gap: .75rem; padding: .55rem .25rem; border-bottom: 1px dashed var(--dw-border); }
.player-row:last-child { border-bottom: 0; }
.player-badge {
    width: 36px; height: 36px; flex: none;
    border-radius: .5rem;
    display: grid; place-items: center;
    font-family: "Cinzel", serif; font-weight: 700;
    color: #1a0f05;
    background: linear-gradient(160deg, var(--dw-gold-light), var(--dw-gold) 55%, #8d6220);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}
.player-badge.off { filter: grayscale(1) brightness(.6); }
.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--dw-red), var(--dw-ember), var(--dw-gold)); }
.podium .dw-card { text-align: center; }
.podium .rank { font-family: "Cinzel", serif; font-size: 1.8rem; font-weight: 700; color: var(--dw-gold); line-height: 1; }

.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(212, 166, 74, .05); }
.table th { font-family: "Cinzel", serif; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dw-muted); font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.badge-online { background: rgba(108, 192, 112, .15); color: var(--dw-green); border: 1px solid rgba(108, 192, 112, .45); }
.badge-offline { background: rgba(255, 255, 255, .05); color: var(--dw-muted); border: 1px solid var(--dw-border); }
.badge-banned { background: rgba(192, 57, 43, .18); color: #ff9c8f; border: 1px solid rgba(192, 57, 43, .5); }

/* ---------- activity ---------- */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.feed li:last-child { border-bottom: 0; }
.feed-icon { width: 1.8rem; text-align: center; flex: none; }
.feed-time { color: var(--dw-muted); font-size: .8rem; white-space: nowrap; margin-left: auto; padding-left: .5rem; }
.chip-filter .btn { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .7rem; --bs-btn-font-size: .85rem; }
.chip-filter .btn.active { background: rgba(212, 166, 74, .18); color: var(--dw-gold-light); border-color: var(--dw-gold); }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: 200px; display: block; overflow: visible; }
.chart .grid { stroke: rgba(255, 255, 255, .06); }
.chart .axis { fill: var(--dw-muted); font-size: 11px; }
.chart .down { fill: rgba(192, 57, 43, .12); }
.chart .tip {
    position: absolute; pointer-events: none; transform: translate(-50%, -110%);
    background: #0f1115; border: 1px solid var(--dw-gold); color: var(--dw-parchment);
    border-radius: .4rem; padding: .25rem .5rem; font-size: .8rem; white-space: nowrap; opacity: 0; transition: opacity .1s;
}

/* ---------- wiki ---------- */
.wiki-search { max-width: 560px; }
.wiki-hit { display: block; padding: .6rem .75rem; border-radius: .5rem; border: 1px solid transparent; color: inherit; text-decoration: none; cursor: pointer; }
.wiki-hit:hover { background: rgba(212, 166, 74, .07); border-color: var(--dw-border); color: inherit; }
.wiki-hit strong { color: var(--dw-gold-light); }
.wiki-img { width: 140px; height: 140px; object-fit: contain; background: radial-gradient(circle, rgba(232, 116, 42, .18), transparent 70%); border-radius: .6rem; flex: none; }
.wiki-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem; }
.wiki-field { background: rgba(0, 0, 0, .22); border: 1px solid var(--dw-border); border-radius: .5rem; padding: .45rem .65rem; }
.wiki-field .k { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dw-muted); }
.wiki-field .v { white-space: pre-line; color: var(--dw-parchment); }
.mat {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .55rem; margin: .15rem .2rem .15rem 0;
    border-radius: 999px; background: rgba(212, 166, 74, .08); border: 1px solid rgba(212, 166, 74, .3);
    font-size: .85rem; color: var(--dw-parchment); cursor: pointer;
}
.mat b { color: var(--dw-gold-light); }
.mat:hover { background: rgba(212, 166, 74, .18); }
.recipe { padding: .6rem .75rem; border-left: 3px solid var(--dw-ember); background: rgba(0, 0, 0, .2); border-radius: 0 .5rem .5rem 0; margin-bottom: .5rem; }

/* ---------- logs ---------- */
.log-view {
    background: #08090b;
    border: 1px solid var(--dw-border);
    border-radius: .5rem;
    padding: .75rem;
    height: 62vh;
    overflow: auto;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: .78rem;
    line-height: 1.45;
    white-space: pre;
    color: #b9b4a8;
}
.log-view .err { color: #ff7b6b; }
.log-view .warn { color: #f1c40f; }
.log-view .join { color: var(--dw-green); }

/* ---------- dialogs and toasts ---------- */
dialog.dw-dialog {
    border: 1px solid var(--dw-gold);
    border-radius: .8rem;
    background: var(--dw-panel-2);
    color: var(--dw-text);
    max-width: 440px;
    width: calc(100% - 2rem);
    padding: 1.4rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
dialog.dw-dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: grid; gap: .5rem; }
.dw-toast {
    background: var(--dw-panel-2); border: 1px solid var(--dw-border); border-left: 3px solid var(--dw-gold);
    border-radius: .5rem; padding: .6rem .9rem; min-width: 240px; max-width: 360px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    animation: toast-in .2s ease-out;
}
.dw-toast.err { border-left-color: var(--dw-red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.busy-banner {
    border: 1px solid rgba(241, 196, 15, .45); background: rgba(241, 196, 15, .07); color: #f6dc7a;
    border-radius: .5rem; padding: .5rem .8rem;
}
.spinner-ember { width: 1rem; height: 1rem; border: 2px solid rgba(232, 116, 42, .3); border-top-color: var(--dw-ember); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-control, .form-select { background-color: rgba(0, 0, 0, .3); border-color: var(--dw-border); color: var(--dw-parchment); }
.form-control:focus, .form-select:focus { background-color: rgba(0, 0, 0, .4); border-color: var(--dw-gold); box-shadow: 0 0 0 .2rem rgba(212, 166, 74, .2); color: var(--dw-parchment); }
.form-control::placeholder { color: #6d685e; }

.site-footer { color: var(--dw-muted); font-size: .8rem; }
.site-footer a { color: var(--dw-muted); }
.tabular { font-variant-numeric: tabular-nums; }
.min-w-0 { min-width: 0; }

/* ---------- audit log ---------- */
.audit-scroll { max-height: 70vh; overflow-y: auto; }
.audit-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--dw-panel-2); }
.audit-failed td { background: rgba(192, 57, 43, .06); }
.audit-avatar { width: 28px; height: 28px; font-size: .8rem; }
.audit-error { color: #ff9c8f; }
.via-web { background: rgba(212, 166, 74, .12); color: var(--dw-gold-light); border: 1px solid rgba(212, 166, 74, .4); }
.via-discord { background: rgba(88, 101, 242, .15); color: #aab3ff; border: 1px solid rgba(88, 101, 242, .45); }
.via-system { background: rgba(255, 255, 255, .05); color: var(--dw-muted); border: 1px solid var(--dw-border); }
