/* MeteorBall public pages (server-rendered): the game's palette and type, laid out for reading. */

html:has(body.public), body.public {
    background-color: #07060c;
    height: auto;
    min-height: 100%;
    overflow: auto;
    -webkit-user-select: text;
    user-select: text;
}
body.public {
    background: #07060c radial-gradient(ellipse at 50% -10%, #241a3a 0%, #07060c 60%) no-repeat;
    line-height: 1.55;
    font-size: 1.05rem;
}
body.public a { color: var(--mb-accent); }
body.public a:hover { text-decoration-thickness: 2px; }
body.public :focus-visible { outline: 3px solid var(--mb-accent); outline-offset: 2px; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px; background: var(--mb-accent); color: #111 !important; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 12px; }

/* ---------- Header and footer ---------- */
.site-header {
    position: relative; z-index: 20;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
    padding: 10px 20px;
    background: rgba(7, 6, 12, 0.85);
    border-bottom: 1px solid #2a2433;
}
.site-brand { line-height: 0; }
.site-brand img { width: 120px; height: auto; }
.site-nav { flex: 1; }
.site-nav ul, .site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-nav a, .site-account a { text-decoration: none; font-weight: 600; padding: 6px 0; display: inline-block; }
.site-nav a:hover, .site-account a:hover { text-decoration: underline; }
.site-account { display: flex; gap: 14px; align-items: center; }
.site-account-name { color: #d8cccc; }
.site-main { display: block; min-height: 60vh; }
.site-main:focus { outline: none; }
.site-footer { margin-top: 48px; padding: 24px 20px 32px; border-top: 1px solid #2a2433; color: #bfb3b3; font-size: 0.95rem; }
.site-footer ul { justify-content: center; margin-bottom: 10px; }
.site-footer p { text-align: center; margin: 0; }

/* ---------- Home: the original title screen ---------- */
body.public:has(.home-hero) .site-header { position: absolute; inset: 0 0 auto 0; background: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0)); border: 0; }
.home-hero { position: relative; height: 100vh; height: 100svh; min-height: 620px; overflow: hidden; }
.home-hero .menu-content { padding-top: max(8vh, 84px); }
.home-hero .menu-play, .home-hero .menu-creator { display: block; }
.menu-island { min-height: calc(min(60vw, 263px) * 300 / 630); display: flex; justify-content: center; }
.menu-island .menu-options { width: min(60vw, 263px); }
.menu-island .overlay { position: fixed; }
.home-more {
    position: absolute; right: 18px; bottom: 18px;
    padding: 8px 18px; border-radius: 999px; background: rgba(7, 6, 12, 0.8); font-weight: 600; text-decoration: none;
}

/* ---------- Content ---------- */
.page-content { max-width: 960px; margin: 0 auto; padding: 8px 20px 0; box-sizing: border-box; }
.page-content h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.2; margin: 12px 0 10px; }
.page-content h2 { font-size: 1.35rem; margin: 30px 0 10px; }
.page-content h3 { font-size: 1.1rem; margin: 0; }
.lead { font-size: 1.15rem; color: #e8dfdf; }
.prose p, .prose li { max-width: 72ch; }
.prose li { margin: 6px 0; }
.prose code { background: #241f2b; padding: 1px 6px; border-radius: 4px; }
.fact-list li { margin: 8px 0; }
.fact-table { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 16px 0; padding: 16px 20px; background: rgba(36, 31, 43, 0.7); border-radius: 12px; }
.fact-table dt { font-weight: 700; color: #d8cccc; }
.fact-table dd { margin: 0; }
.link-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 24px 0; }
.plain-list { list-style: none; padding: 0; }
.notice, .result-count { color: #e0d6d6; }
.home-sections { padding-top: 24px; }

.button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px; box-sizing: border-box;
    border-radius: 10px; border: 2px solid var(--mb-accent); background: var(--mb-accent); color: #1a1414 !important;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.button-secondary { background: #2a2626; color: var(--mb-text) !important; border-color: #5a5252; }
.button-large { min-height: 52px; font-size: 1.15rem; padding: 10px 26px; }

.breadcrumbs { max-width: 960px; margin: 0 auto; padding: 14px 20px 0; box-sizing: border-box; font-size: 0.92rem; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: #9a8f8f; }
.breadcrumbs [aria-current] { color: #d8cccc; }

/* ---------- Community ---------- */
.community-search { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 12px; }
.community-search input {
    flex: 1; min-width: 200px; min-height: 44px; padding: 8px 12px; box-sizing: border-box;
    font: inherit; color: var(--mb-text); background: #2a2626; border: 2px solid #5a5252; border-radius: 10px;
}
.community-sorts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.community-sort { padding: 6px 14px; border-radius: 999px; border: 2px solid #5a5252; background: #2a2626; color: var(--mb-text) !important; text-decoration: none; font-weight: 600; }
.community-sort.active { border-color: var(--mb-accent); background: #4a3a1f; }
.level-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.level-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; background: rgba(36, 31, 43, 0.85); border-radius: 12px; }
.level-card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font-size: 0.93rem; color: #d8cccc; }
.level-card-name a { text-decoration: none; }
.level-card-name a:hover { text-decoration: underline; }
.player-rating { color: #ffe08a; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }

.level-header { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.level-header h1 { margin-bottom: 0; }
.level-byline { margin: 0 0 10px; font-size: 1.1rem; }
.version-list li { margin: 6px 0; }

/* ---------- Contact form ---------- */
.contact-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.contact-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.contact-field label { font-weight: 700; }
.contact-field input, .contact-field select, .contact-field textarea {
    width: 100%; box-sizing: border-box; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--mb-text);
    background: #1c1824; border: 2px solid #5a5252; border-radius: 8px;
}
.contact-field textarea { resize: vertical; }
.contact-field input:focus-visible, .contact-field select:focus-visible, .contact-field textarea:focus-visible { outline: 3px solid var(--mb-accent); }
.contact-field [aria-invalid="true"] { border-color: #ff8a7a; }
.contact-field small, .contact-recaptcha { color: #d8cccc; font-size: 0.88rem; }
.contact-error { margin: 0; color: #ffb3a8; font-weight: 600; }
.contact-error::before { content: "⚠ "; }
.contact-form .button { align-self: flex-start; }
.contact-problem { padding: 10px 14px; border-radius: 8px; background: #3a1f1f; border-left: 4px solid #ff8a7a; }
.contact-problem ul { margin: 4px 0 0; }
.contact-sent { padding: 12px 16px; border-radius: 8px; background: #1f3a2a; border-left: 4px solid #6fd08a; }
.contact-sent p { margin: 4px 0; }
/* The honeypot field: off-screen for sighted users, aria-hidden and unfocusable for everyone else. */
.contact-website { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* reCAPTCHA v3's floating badge: Google's text notice is shown in the form instead, as Google permits. */
.grecaptcha-badge { visibility: hidden; }

/* ---------- Social community (Phase 8B) ---------- */
/* Default avatar: drawn in CSS from the game's colours; no image and no user-supplied URL (Avatars.Default). */
.avatar { display: inline-block; flex: none; width: 32px; height: 32px; border-radius: 50%; vertical-align: middle; }
.avatar-default { background: radial-gradient(circle at 35% 35%, #ffe08a 0 18%, #c9822f 19% 46%, #5a3a1f 47%); box-shadow: 0 0 0 2px #2a2433; }
.avatar-large { width: 56px; height: 56px; }
.creator-heading { display: flex; align-items: center; gap: 14px; }
.creator-heading h1 { margin: 0; }
.follow-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 12px 0; }
.follower-count { font-weight: 700; }
.follow-self { color: #d8cccc; }
.button-small { padding: 4px 10px; font-size: 0.85rem; min-height: 32px; }
.button-danger { background: #8a2a1f; border-color: #c0392b; color: #fff !important; }

.discussion { margin: 28px 0; }
.discussion-guidance, .comment-help { color: #d8cccc; font-size: 0.93rem; }
.discussion-status { padding: 8px 12px; border-radius: 8px; background: #1f3a2a; border-left: 4px solid #6fd08a; }
.discussion-status.problem { background: #3a1f1f; border-left-color: #ff8a7a; }
.comment-form, .comment-action form { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 16px; max-width: 100%; }
.comment-form label, .comment-action label { font-weight: 600; }
.comment-form textarea, .comment-action textarea {
    width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; color: var(--mb-text);
    background: #1c1824; border: 2px solid #5a5252; border-radius: 8px; resize: vertical;
}
.comment-form textarea:focus-visible, .comment-action textarea:focus-visible { outline: 3px solid var(--mb-accent); }
.comment-form .button, .comment-action .button { align-self: flex-start; }
.comment-list, .comment-replies { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comment-replies { margin: 8px 0 0 24px; padding-left: 12px; border-left: 2px solid #3a3346; }
.comment { padding: 10px 14px; background: rgba(36, 31, 43, 0.85); border-radius: 12px; min-width: 0; }
.comment.by-creator { border: 1px solid var(--mb-accent); }
.comment-header { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.9rem; color: #d8cccc; }
.comment-author { font-weight: 700; color: var(--mb-text); overflow-wrap: anywhere; }
.comment-badge { padding: 1px 8px; border-radius: 999px; background: var(--mb-accent); color: #1a1400; font-weight: 700; font-size: 0.8rem; }
.comment-edited { font-style: italic; }
.comment-body { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.comment-placeholder { margin: 0; font-style: italic; color: #bfb3b3; }
.comment-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 14px; font-size: 0.9rem; }
.comment-action { min-width: 0; max-width: 100%; }
.comment-action[open] { flex-basis: 100%; }
.comment-action summary { cursor: pointer; color: var(--mb-accent); text-decoration: underline; }
.comment-action summary:focus-visible { outline: 3px solid var(--mb-accent); outline-offset: 2px; }
.comment-action fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.comment-action legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.report-reason { font-weight: 400 !important; }
.comment-reported { color: #d8cccc; font-style: italic; }

.site-notifications { position: relative; text-decoration: none; }
.notification-count { display: inline-block; min-width: 1.4em; margin-left: 2px; padding: 0 5px; border-radius: 999px; background: #c0392b; color: #fff; font-size: 0.8rem; font-weight: 700; text-align: center; }
.notifications-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.notification-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notification { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; background: rgba(36, 31, 43, 0.6); border-radius: 12px; }
.notification.unread { background: rgba(58, 47, 24, 0.85); border-left: 4px solid var(--mb-accent); }
.notification-new { padding: 1px 8px; border-radius: 999px; background: var(--mb-accent); color: #1a1400; font-weight: 700; font-size: 0.8rem; }
.notification-text { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.notification-text time { color: #d8cccc; font-size: 0.85rem; }
.notification-open { text-align: left; color: var(--mb-text) !important; }

/* ---------- How to Play piece reference (PieceHelp) ---------- */
.piece-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.piece-list > li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 14px; background: rgba(36, 31, 43, 0.85); border-radius: 12px; }
.piece-list h4 { margin: 0 0 4px; font-size: 1.05rem; }
.piece-list p { margin: 0 0 6px; }
.piece-list ul { margin: 0; padding-left: 1.1em; font-size: 0.93rem; color: #e0d6d6; }
.piece-art { position: relative; display: block; width: 48px; height: 48px; }
.piece-art img { position: absolute; inset: 0; width: 100%; height: 100%; }
.piece-list .piece-orientations { list-style: none; padding: 0; margin-top: 8px; display: grid; gap: 6px; }
.piece-orientations li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 8px; align-items: center; }
.piece-orientations .piece-art { width: 32px; height: 32px; }

/* ---------- Rankings and creator milestones (Phase 8A) ---------- */
.ranking-section { margin: 26px 0; }
.ranking-rule, .fact-note { color: #d8cccc; font-size: 0.93rem; }
.ranking-list { margin: 12px 0; padding-left: 2.2em; display: flex; flex-direction: column; gap: 8px; }
.ranking-item { padding: 10px 14px; background: rgba(36, 31, 43, 0.85); border-radius: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.ranking-item::marker { color: var(--mb-accent); font-weight: 700; }
.ranking-name { font-weight: 700; font-size: 1.05rem; }
.ranking-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.93rem; color: #d8cccc; flex: 1 1 260px; }
.ranking-item .button-play { margin-left: auto; }
.badge-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.creator-badge { padding: 6px 12px; border-radius: 999px; border: 2px solid var(--mb-accent); background: #3a2f18; font-weight: 600; }
.badge-mark { color: var(--mb-accent); }

/* ---------- Owner review and status pages ---------- */
.owner-review { margin: 16px 0; padding: 12px 16px; border: 2px dashed var(--mb-accent); border-radius: 10px; background: rgba(74, 58, 31, 0.35); }
.status-page { padding-top: 40px; text-align: center; }
.status-page .link-row { justify-content: center; }
.request-id { text-align: center; color: #bfb3b3; }

@media (max-width: 640px) {
    .site-header { padding: 8px 16px; }
    /* On phones the wrapped navigation sits above the title screen instead of over the logo. */
    body.public:has(.home-hero) .site-header { position: relative; background: rgba(7, 6, 12, 0.95); border-bottom: 1px solid #2a2433; }
    .home-hero .menu-content { padding-top: 6vh; }
    .home-more { right: 50%; transform: translateX(50%); }
    .site-nav { flex-basis: 100%; order: 3; }
    .page-content, .breadcrumbs { padding-left: 16px; padding-right: 16px; }
    .level-card { flex-direction: column; align-items: stretch; }
    .ranking-item .button-play { margin-left: 0; }
    .comment-replies { margin-left: 8px; padding-left: 8px; }
    .fact-table { grid-template-columns: 1fr; gap: 2px; }
    .fact-table dd { margin-bottom: 8px; }
}

/* Advertising slots (docs/ADVERTISING.md): a fixed-height box, so an ad that loads late, is blocked or isn't
   filled never moves the content around it. */
.ad-slot { max-width: 960px; margin: 20px auto; padding: 0 20px; box-sizing: border-box; }
.page-content .ad-slot { padding: 0; }
.ad-label { display: block; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: #9a8f8f; margin-bottom: 4px; }
.ad-slot .ad-unit { display: block; width: 100%; height: 250px; overflow: hidden; }
.ad-placeholder { min-height: 0; }
.ad-placeholder .ad-label { display: flex; align-items: center; justify-content: center; height: 250px; border: 2px dashed #5a5252; border-radius: 10px; color: #bfb3b3; text-transform: none; }
@media (max-width: 640px) {
    .ad-slot .ad-unit, .ad-placeholder .ad-label { height: 280px; }
}
