/* Shared Availability UI — scoped with qa- prefix to avoid clashing with
   game stylesheets. Visual tone follows the qf- (friends) palette since
   the two features sit side-by-side in lobbies + profile.                */

/* ---------- per-game toggle button ---------- */
.qa-toggle-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.95rem; font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: #e8e9f0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.qa-toggle-btn:hover:not(:disabled):not(.qa-toggle-disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(212, 175, 55, 0.45);
    transform: translateY(-1px);
}
.qa-toggle-btn.qa-toggle-on {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.18), rgba(46, 204, 113, 0.06));
    border-color: rgba(46, 204, 113, 0.55);
    color: #d6f5dc;
}
.qa-toggle-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.qa-toggle-btn.qa-toggle-disabled {
    opacity: 0.65; cursor: pointer; font-style: italic;
    color: #b5b7c5;
}

/* ---------- homepage card indicator ----------
   Top-start corner so it doesn't collide with .leaderboard-icon-btn,
   which already pins the top-end corner of each card. */
.qa-card-dot {
    display: none;
    position: absolute;
    inset-inline-start: 12px;
    inset-block-start: 12px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.7);
    z-index: 6;
    pointer-events: none;
    border: 2px solid rgba(15, 23, 42, 0.9);
}
.qa-card-dot.qa-card-dot-on { display: block; }

/* ---------- lobby invite button ---------- */
.qa-invite-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem; font-weight: 600;
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color: #111;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.qa-invite-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
.qa-invite-btn:active { transform: translateY(0); }

/* ---------- invite modal ---------- */
.qa-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none; align-items: center; justify-content: center;
    z-index: 10000;
    padding: 1rem;
}
.qa-overlay.qa-open { display: flex; }
.qa-modal {
    width: 100%; max-width: 460px; max-height: 86vh;
    display: flex; flex-direction: column;
    background: #1a1d2e;
    color: #e8e9f0;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    font-family: 'Tajawal', 'Amiri', system-ui, sans-serif;
}
.qa-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.85rem 1rem 0.4rem;
}
.qa-modal-title {
    margin: 0; font-size: 1.05rem; font-weight: 700; color: #f3f4ff;
}
.qa-modal-close {
    background: transparent; border: none; color: #c7c8d6;
    font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0.2rem 0.5rem;
}
.qa-modal-close:hover { color: #fff; }
.qa-modal-subtitle {
    margin: 0 1rem 0.55rem;
    font-size: 0.82rem;
    color: #9b9eb1;
}
.qa-modal-body {
    padding: 0 0.85rem 0.85rem;
    overflow-y: auto;
    flex: 1;
}

/* ---------- list rows (invite modal) ---------- */
.qa-list { display: flex; flex-direction: column; gap: 0.45rem; }
.qa-row {
    display: flex; align-items: center; gap: 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}
.qa-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    object-fit: cover; background: #2a2e44;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.qa-avatar-stub { color: #c7c8d6; }
.qa-row-main { flex: 1; min-width: 0; }
.qa-row-name {
    font-size: 0.95rem; font-weight: 600; color: #f0f1fa;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qa-row-meta {
    font-size: 0.76rem; color: #9b9eb1;
    display: flex; align-items: center; gap: 0.35rem;
    margin-top: 0.15rem;
}
.qa-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.qa-dot-online  { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.qa-dot-offline { background: #6f7388; }
.qa-row-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.qa-invite-action {
    padding: 0.4rem 0.85rem;
    border-radius: 7px; border: none;
    font-size: 0.85rem; font-weight: 600;
    background: #d4af37; color: #111;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
}
.qa-invite-action:disabled { opacity: 0.55; cursor: default; }

.qa-empty, .qa-error, .qa-loading {
    text-align: center;
    padding: 1.4rem 0.6rem;
    color: #9b9eb1;
    font-size: 0.92rem;
}
.qa-error { color: #ff7a7a; }

/* ---------- profile "Manage availability" card ---------- */
.qa-manage-header { margin-bottom: 0.85rem; }
.qa-manage-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
}
.qa-manage-title {
    margin: 0;
    color: var(--accent-gold, #f7c948);
    font-size: 1.15rem;
}
.qa-manage-counter {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(46, 204, 113, 0.14);
    color: #6ee788;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}
.qa-manage-hint {
    margin: 0;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ---------- icon-tile grid ----------
   Wrapping grid scales horizontally with the catalog. Tiles are kept
   intentionally small (~64px wide, ~32px icon) so the section reads as a
   compact picker, not a wall of game art. max-width on the grid prevents
   sprawl on wide profile cards. */
.qa-manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 80px));
    gap: 0.4rem;
    margin: 0.7rem 0 0.55rem;
    justify-content: center;
    max-width: 460px;
    margin-inline-start: auto;
    margin-inline-end: auto;
}
.qa-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.3rem;
    padding: 0.45rem 0.25rem 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e8e9f0;
    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.12s ease,
        opacity 0.18s ease,
        filter 0.18s ease,
        box-shadow 0.18s ease;
    /* Off-state — desaturated + dimmed so opted-in tiles pop visually. */
    opacity: 0.6;
    filter: saturate(0.55);
    text-align: center;
}
.qa-tile:hover:not(:disabled) {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.22);
    opacity: 0.85;
    filter: saturate(0.85);
}
.qa-tile-on {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.18), rgba(212, 175, 55, 0.06));
    border-color: rgba(212, 175, 55, 0.7);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.18);
    opacity: 1;
    filter: none;
}
.qa-tile-on:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(212, 175, 55, 0.25);
}
.qa-tile:disabled { cursor: wait; opacity: 0.4; }
/* `!important` defends the icon size against any page-level
   `.card img { width: 100% }` rule that would otherwise stretch
   the homepage game art to the full tile width. */
.qa-tile .qa-tile-icon {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    object-fit: cover;
    border-radius: 6px;
    background: #1a1d2e;
    flex-shrink: 0;
    display: block;
}
.qa-tile .qa-tile-emoji {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: 6px;
    background: #1a1d2e;
    flex-shrink: 0;
}
.qa-tile-name {
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.2;
    color: #e8e9f0;
    /* clamp to 2 lines so long names don't break the grid baseline */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.qa-tile-check {
    position: absolute;
    inset-block-start: 3px;
    inset-inline-end: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #d4af37;
    color: #111;
    font-size: 0.66rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.qa-tile-on .qa-tile-check { display: inline-flex; }
/* Dark outlined (not red) — "Turn off all" is not a destructive action. */
.qa-manage-clear {
    margin-top: 0.4rem;
    padding: 0.5rem 1rem;
    background: transparent;
    color: #aaa;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.qa-manage-clear:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); }
.qa-manage-clear:disabled { opacity: 0.55; cursor: wait; }

/* ---------- create/join screen embed ---------- */
.qa-toggle-host {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    margin: 0.6rem 0 0.4rem;
}
.qa-toggle-host .qa-toggle-btn {
    width: 100%;
    justify-content: center;
}
.qa-toggle-hint {
    margin: 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.78rem;
    line-height: 1.5;
    text-align: center;
}
