/* Machine Craft — shared styles for the homepage, downloads and articles. */
:root {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --accent: #38bdf8;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --code-bg: #000000;
    --border: #334155;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.8)),
        url('../bg.jpg');
    background-color: var(--bg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text);
    margin: 0;
    line-height: 1.6;
    min-height: 100vh;
    overflow-wrap: anywhere;
}

/* Widths include the original 20px padding on either side. */
.container {
    max-width: 940px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    text-align: center;
    padding: 60px 0;
}

h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    margin: 0;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.2rem;
}

img, iframe {
    max-width: 100%;
}

iframe {
    display: block;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Shared cards and buttons */
.server-status {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 24px;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

.server-connection, .server-requirements {
    min-width: 0;
}

.server-requirements {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    align-self: stretch;
    border-left: 1px solid var(--border);
    padding-left: 24px;
}

.server-versions {
    display: grid;
    gap: 6px;
}

.server-address {
    margin-top: 14px;
}

.server-address-label {
    display: block;
    font-size: .85rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.ip-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    width: fit-content;
    max-width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 6px 6px 12px;
}

.ip-address {
    color: var(--accent);
    font-weight: bold;
    min-width: 0;
    user-select: all;
}

.copy-ip-btn {
    font: inherit;
    font-size: .85rem;
    font-weight: bold;
    color: var(--accent);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-height: 36px;
    min-width: 78px;
    padding: 6px 10px;
    cursor: pointer;
    transition: 0.2s;
}

.copy-ip-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.copy-ip-btn:disabled {
    cursor: wait;
    opacity: .75;
}

.copy-feedback {
    color: var(--text-dim);
    font-size: .8rem;
    margin: 4px 0 0;
    min-height: 1.28em;
}

.install-modpack {
    text-align: center;
    max-width: 100%;
}

.install-modpack:hover {
    background: #7dd3fc;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.card {
    min-width: 0;
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 1.17em;
    margin: 0 0 1em;
    color: var(--accent);
}

.article-link {
    display: block;
    color: var(--text);
    text-decoration: none;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    transition: 0.2s;
}

.article-link:hover {
    color: var(--accent);
    padding-left: 5px;
}

.btn {
    display: inline-block;
    background: var(--accent);
    color: var(--bg);
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px;
}

.staff-btn {
    display: inline-block;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: 0.3s;
}

.staff-btn:hover {
    background: var(--card-bg);
    color: var(--accent);
    border-color: var(--accent);
}

footer {
    text-align: center;
    margin-top: 60px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Homepage embeds */
.discord-widget {
    width: 350px;
    max-width: 100%;
    height: 500px;
}

.map-card, .downloads-card {
    margin-bottom: 40px;
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.map-header h2 {
    margin: 0;
}

.map-description {
    margin-top: 0;
}

.map-embed {
    width: 100%;
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.map-embed iframe {
    width: 100%;
    height: 100%;
}

.staff-section, .home-navigation {
    text-align: center;
}

.home-navigation {
    margin-bottom: 40px;
}

/* Downloads */
.directory-section {
    margin-top: 20px;
}

.download-group + .download-group {
    margin-top: 3.2em;
}

.file-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    transition: 0.2s;
}

.file-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(15, 23, 42, 0.8);
}

.file-link > span:first-child {
    min-width: 0;
}

.file-link .dl-tag {
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: bold;
}

/* Articles retain their original narrower, left-aligned layout. */
.article-page .container {
    max-width: 840px;
    padding: 60px 20px;
}

.back-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 30px;
    font-weight: bold;
}

.article-page header {
    text-align: left;
    padding: 0;
}

.article-page h1 {
    font-size: clamp(2rem, 5vw, 2.5rem);
    color: var(--text);
    background: none;
    -webkit-text-fill-color: currentColor;
    letter-spacing: normal;
    margin: 0.67em 0 10px;
    line-height: 1.2;
}

.meta {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.article-page h2 {
    color: var(--accent);
    margin-top: 40px;
    border-left: 4px solid var(--accent);
    padding-left: 15px;
}

.article-page p {
    margin-bottom: 20px;
}

.pro-tip {
    background: rgba(56, 189, 248, 0.1);
    border-radius: 8px;
    padding: 20px;
    border-right: 4px solid var(--accent);
    margin: 30px 0;
}

.item-list {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    list-style: none;
}

.item-list li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
}

.item-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
}

.advertisement-date {
    font-size: 1em;
    margin-left: 40px;
    margin-bottom: 1.33em;
}

.article-page footer {
    margin-top: 80px;
    font-size: 0.8rem;
}

/* Responsive layout */
@media (max-width: 700px) {
    body {
        background-attachment: scroll;
    }

    .container, .article-page .container {
        padding: 24px 16px;
    }

    header {
        padding: 32px 0;
    }

    h1 {
        letter-spacing: -1px;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .server-status {
        grid-template-columns: minmax(0, 1fr);
        padding: 20px;
        gap: 16px;
        text-align: center;
    }

    .server-requirements {
        border-left: 0;
        border-top: 1px solid var(--border);
        padding: 16px 0 0;
    }

    .ip-box {
        margin-inline: auto;
        justify-content: center;
    }

    .card {
        padding: 20px;
    }
}

@media (max-width: 420px) {
    .card {
        padding: 16px;
    }

    .file-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Live status indicator and polling messages. */
.live-status-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.status-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: currentColor;
    color: var(--text-dim);
}
.live-status[data-state="online"] .status-dot { color: #4ade80; }
.live-status[data-state="offline"] .status-dot { color: #f87171; }
.live-status[data-state="maintenance"] .status-dot { color: #facc15; }
.status-note {
    color: var(--text-dim);
    font-size: .8rem;
    margin: 4px 0 0;
}
@media (max-width: 700px) {
    .live-status-heading { justify-content: center; }
}

/* Historical statistics: share the Downloads layout and inset surfaces. */
.stats-panel {
    min-width: 0;
    padding: 16px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
}
.stats-group { margin-top: 3.2em; }
.stats-explanation p:first-child, .stats-panel > p:first-child { margin-top: 0; }
.stats-explanation p:last-child, .stats-panel > p:last-child { margin-bottom: 0; }
.stats-controls select { max-width: 100%; min-width: 0; }
.stats-controls button:hover { color: var(--accent); border-color: var(--accent); }
.stats-panel .stats-breakdown div + div { border-top: 1px solid var(--border); }
@media (max-width: 420px) {
    .stats-panel { padding: 12px; }
    .stats-group { margin-top: 2.4em; }
}

.statistics [hidden] { display: none !important; }
.stats-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stats-controls select, .stats-controls button { font: inherit; color: var(--text); background: var(--card-bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; }
.stats-controls button, .stats-details summary { cursor: pointer; }
.stats-message { color: var(--text-dim); font-size: .9rem; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stats-metric { display: flex; flex-direction: column; gap: 4px; }
.stats-metric span, .stats-metric small { color: var(--text-dim); font-size: .85rem; }
.stats-metric strong { color: var(--accent); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stats-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8rem; color: var(--text-dim); }
.stats-key::before { content: ''; display: inline-block; width: .75em; height: .75em; margin-right: .4em; border-radius: 2px; background: var(--key); }
.stats-key-peak { --key: #64748b; } .stats-key-average { --key: #38bdf8; }
.stats-key-online { --key: #4ade80; } .stats-key-offline { --key: #f87171; }
.stats-key-maintenance { --key: #facc15; } .stats-key-unknown { --key: #a78bfa; } .stats-key-unmonitored { --key: #64748b; }
.stats-chart { margin: 16px 0; } .stats-chart svg { width: 100%; height: auto; display: block; }
.stats-details { color: var(--text-dim); font-size: .85rem; }
.stats-table-wrap { max-width: 100%; overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--border); overflow-wrap: normal; }
.stats-table th { color: var(--text-dim); }
.stats-availability { display: flex; height: 14px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.stats-availability span { background: var(--key); }
.stats-breakdown { margin: 16px 0 0; }
.stats-breakdown div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.stats-breakdown dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 380px) { .stats-grid { grid-template-columns: minmax(0, 1fr); } }
