/*
 * Server detail page polish (server.php + includes/server_*.php).
 * Scoped additions only — loaded through $page_stylesheets = ['server-page'].
 * Plain CSS on purpose: new utility classes would not exist in the prebuilt tailwind.css.
 */

/* ---------- Sidebar: connect hint + status ---------- */
.server-aside-name {
    overflow-wrap: anywhere;
    hyphens: auto;
}

.server-connect-hint {
    margin: -0.15rem 0 0;
    font-size: 0.75rem;
    line-height: 1.3;
    color: rgb(68 64 60);
    text-align: center;
}
.dark .server-connect-hint {
    color: rgb(168 162 158);
}

.server-status {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.7rem 0.75rem;
    border: 1px solid rgb(168 162 158 / 0.55);
    border-left-width: 4px;
    border-radius: 0.375rem;
    background: rgb(231 229 228 / 0.55);
}
.dark .server-status {
    border-color: rgb(68 64 60 / 0.9);
    background: rgb(12 10 9 / 0.35);
}
.server-status--online { border-left-color: #65a30d; }
.server-status--stale { border-left-color: #d97706; }
.server-status--offline,
.server-status--unknown { border-left-color: rgb(120 113 108); }

.server-status__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.server-status__state {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.server-status__label {
    font-size: 0.875rem;
    font-weight: 700;
    color: rgb(28 25 23);
}
.dark .server-status__label {
    color: rgb(245 245 244);
}
.server-status--offline .server-status__label,
.server-status--stale .server-status__label,
.server-status--unknown .server-status__label {
    color: rgb(68 64 60);
}
.dark .server-status--offline .server-status__label,
.dark .server-status--stale .server-status__label,
.dark .server-status--unknown .server-status__label {
    color: rgb(214 211 209);
}

.server-status__dot {
    position: relative;
    display: inline-flex;
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
}
.server-status__core {
    position: relative;
    display: inline-flex;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 9999px;
    background: rgb(120 113 108);
}
.server-status--online .server-status__core { background: #65a30d; }
.server-status--stale .server-status__core {
    background: transparent;
    box-shadow: inset 0 0 0 2px #d97706;
}
.server-status--unknown .server-status__core {
    background: transparent;
    box-shadow: inset 0 0 0 2px rgb(120 113 108);
}
.server-status__ping {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: #84cc16;
    opacity: 0.6;
    animation: server-status-ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes server-status-ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

.server-status__players {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
    color: rgb(28 25 23);
}
.dark .server-status__players {
    color: rgb(245 245 244);
}
.server-status__players strong {
    font-weight: 700;
}
.server-status__muted {
    color: rgb(87 83 78);
}
.dark .server-status__muted {
    color: rgb(168 162 158);
}
.server-status__players--stale {
    font-size: 0.875rem;
    color: rgb(68 64 60);
}
.server-status__players--stale strong {
    color: rgb(146 64 14);
}
.dark .server-status__players--stale {
    color: rgb(214 211 209);
}
.dark .server-status__players--stale strong {
    color: rgb(252 211 77);
}
.server-status__note {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: rgb(68 64 60);
}
.dark .server-status__note {
    color: rgb(168 162 158);
}
.server-status__checked {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.75rem;
    color: rgb(68 64 60);
}
.dark .server-status__checked {
    color: rgb(168 162 158);
}

.server-refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: rgb(68 64 60);
    cursor: pointer;
    transition: background-color var(--duration-fast, 150ms) ease-out, opacity var(--duration-fast, 150ms) ease-out;
}
.server-refresh-btn:hover {
    background: rgb(168 162 158 / 0.35);
    color: rgb(28 25 23);
}
.server-refresh-btn:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 1px;
}
.server-refresh-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}
.server-refresh-btn:disabled svg {
    animation: server-refresh-spin 0.9s linear infinite;
}
@keyframes server-refresh-spin {
    to { transform: rotate(360deg); }
}
.dark .server-refresh-btn { color: rgb(214 211 209); }
.dark .server-refresh-btn:hover { background: rgb(87 83 78 / 0.6); color: rgb(250 250 249); }

/* ---------- Sidebar: links, share ---------- */
.server-ext-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    color: rgb(63 98 18);
    text-decoration: underline;
    text-underline-offset: 3px;
}
.server-ext-link:hover { color: rgb(54 83 14); text-decoration-thickness: 2px; }
.dark .server-ext-link { color: #a3e635; }
.dark .server-ext-link:hover { color: #bef264; }
.server-ext-link:focus-visible,
.server-desc__link:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 2px;
    border-radius: 2px;
}

.server-share-btn {
    position: relative;
}
.server-share-btn:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 2px;
}
.server-share-btn[data-copied]::after {
    content: "Link copied";
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    background: rgb(28 25 23);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

/* Copy buttons: visible focus + clear "copied" / "failed" state */
#copy-ip:focus-visible,
.copy-bedrock:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 3px;
}
.copy-ip[data-copy-failed] .copy-ip-text {
    font-size: 0.8125rem;
}

/* ---------- Mobile sticky actions ---------- */
.server-sticky-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem 5.25rem calc(0.5rem + env(safe-area-inset-bottom, 0px)) 0.75rem; /* right padding keeps the chest button clear */
    background: rgb(245 245 244 / 0.97);
    border-top: 1px solid rgb(168 162 158);
    box-shadow: 0 -4px 14px rgb(0 0 0 / 0.12);
    transform: translateY(110%);
    transition: transform 0.2s ease-out;
}
.server-sticky-bar[hidden] {
    display: none;
}
.server-sticky-bar.is-visible {
    transform: translateY(0);
}
.dark .server-sticky-bar {
    background: rgb(28 25 23 / 0.97);
    border-top-color: rgb(68 64 60);
    box-shadow: 0 -4px 14px rgb(0 0 0 / 0.5);
}
.server-sticky-bar__copy,
.server-sticky-bar__vote {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 0.9rem;
    border: 1px solid;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.server-sticky-bar__copy {
    flex: 1 1 auto;
    min-width: 0;
    background: #84cc16;
    border-color: #35530e;
    color: #1a2e05;
}
.server-sticky-bar__copy .copy-ip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.server-sticky-bar__vote {
    flex: 0 0 auto;
    background: rgb(214 211 209);
    border-color: rgb(120 113 108);
    color: rgb(28 25 23);
}
.dark .server-sticky-bar__vote {
    background: rgb(168 162 158);
}
.server-sticky-bar__copy:focus-visible,
.server-sticky-bar__vote:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 2px;
}
@media (min-width: 768px) {
    .server-sticky-bar { display: none !important; }
}

/* ---------- Overview: description ---------- */
.server-desc {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-width: 72ch;
    line-height: 1.7;
    color: rgb(41 37 36);
    overflow-wrap: anywhere;
}
.dark .server-desc { color: rgb(231 229 228); }
.server-desc p { margin: 0; }
.server-desc__lead { font-weight: 500; }
.server-desc__link {
    color: rgb(63 98 18);
    text-decoration: underline;
    text-underline-offset: 3px;
    word-break: break-word;
}
.dark .server-desc__link { color: #a3e635; }
.server-desc-more > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2.25rem;
    padding: 0.25rem 0;
    font-weight: 700;
    font-size: 0.875rem;
    cursor: pointer;
    list-style: none;
    color: rgb(63 98 18);
}
.server-desc-more > summary::-webkit-details-marker { display: none; }
.server-desc-more > summary:focus-visible {
    outline: 2px solid var(--color-primary, #7ccf00);
    outline-offset: 2px;
}
.dark .server-desc-more > summary { color: #a3e635; }
.server-desc-more[open] > summary .server-desc-more__open,
.server-desc-more:not([open]) > summary .server-desc-more__close { display: none; }
.server-desc-more > .server-desc { margin-top: 0.9rem; }

/* Banner / media: reserve space so nothing shifts */
.server-overview-banner__frame {
    aspect-ratio: 468 / 60;
    width: 100%;
    max-width: 468px;
    overflow: hidden;
    border-radius: 0.125rem;
    background: rgb(168 162 158 / 0.25);
}
.server-overview-banner__frame img,
.server-overview-banner__frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Report dialog ---------- */
#report-server-overlay[data-open="1"] {
    display: flex;
}
.report-dialog {
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}
.report-dialog__error {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgb(185 28 28);
    border-radius: 0.25rem;
    background: rgb(254 226 226);
    color: rgb(127 29 29);
    font-size: 0.8125rem;
}
.dark .report-dialog__error {
    background: rgb(127 29 29 / 0.3);
    color: rgb(254 202 202);
}
.server-flash {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgb(22 163 74);
    border-radius: 0.25rem;
    background: rgb(220 252 231);
    color: rgb(20 83 45);
    font-size: 0.75rem;
}
.dark .server-flash {
    background: rgb(20 83 45 / 0.3);
    color: rgb(187 247 208);
}
.server-claim-link {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    line-height: 1.45;
    text-align: center;
    color: rgb(68 64 60);
}
.server-claim-link a {
    color: rgb(63 98 18);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.dark .server-claim-link { color: rgb(168 162 158); }
.dark .server-claim-link a { color: #a3e635; }

/* ---------- Similar servers ---------- */
.server-similar-status {
    font-size: 0.6875rem;
    color: rgb(87 83 78);
}
.dark .server-similar-status { color: rgb(168 162 158); }

/* ---------- Stats page ---------- */
.server-stats-note {
    margin: 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid rgb(217 119 6 / 0.6);
    border-left-width: 4px;
    border-radius: 0.25rem;
    background: rgb(254 243 199 / 0.7);
    color: rgb(120 53 15);
    font-size: 0.8125rem;
    line-height: 1.45;
}
.dark .server-stats-note {
    background: rgb(120 53 15 / 0.25);
    color: rgb(253 230 138);
}
.server-stats-chart {
    position: relative;
    height: 280px;
    width: 100%;
}
.server-stats-chart canvas {
    display: block;
}
.server-stats-empty {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    font-size: 0.875rem;
    color: rgb(68 64 60);
}
.dark .server-stats-empty { color: rgb(168 162 158); }
.server-stats-chart.is-empty canvas { visibility: hidden; }
.server-stats-chart.is-empty .server-stats-empty { display: flex; }
.server-stats-table caption { text-align: left; }

/* ---------- Vote page ---------- */
.server-vote-when {
    white-space: nowrap;
    font-size: 0.75rem;
    color: rgb(87 83 78);
}
.dark .server-vote-when { color: rgb(168 162 158); }

/* ---------- Motion + small screens ---------- */
@media (prefers-reduced-motion: reduce) {
    .server-status__ping,
    .server-refresh-btn:disabled svg {
        animation: none;
    }
    .server-sticky-bar {
        transition: none;
    }
}
@media (max-width: 767px) {
    .server-page-layout,
    .server-overview {
        max-width: 100%;
    }
    .server-overview img,
    .server-overview video,
    .server-overview iframe {
        max-width: 100%;
    }
    .server-desc { max-width: 100%; }
    /* make room for the sticky action bar so the footer is never covered */
    body.has-server-sticky footer { padding-bottom: 7rem; }
}
