/* Shared UI components: nav additions, footer, toasts, dialogs, buttons.
   Loaded on every page by Layout.astro, after nav.css and styles.css. */

/* ---------- Page shell ---------- */
/* Several restored pages make <body> a centring flex container. Stack nav / content / footer
   vertically in that case, with nav and footer always full width. */
body {
    flex-direction: column;
}

body > .site-navbar,
body > .site-footer {
    align-self: stretch;
    flex-shrink: 0;
}

/* ---------- Nav: active link, badge, profile dropdown ---------- */
.site-navbar__link.is-active {
    color: var(--player-one, var(--cp-player-one));
}

.site-navbar__link.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 2px;
    border-radius: 2px;
    background: var(--player-one, var(--cp-player-one));
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--player-two, var(--cp-player-two));
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: middle;
}

.nav-badge[hidden] {
    display: none;
}

.nav-profile {
    position: relative;
}

.nav-profile .profile-btn {
    font: inherit;
}

.nav-profile__caret {
    font-size: 0.75rem;
    opacity: 0.7;
}

.nav-profile__menu {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    min-width: 13rem;
    padding: 0.5rem;
    border-radius: 15px;
    background: var(--cp-primary-black);
    border: 2px solid rgba(8, 217, 214, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1300;
}

.nav-profile__menu[hidden] {
    display: none;
}

.nav-profile__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    color: var(--primary-text, var(--cp-primary-text));
    text-decoration: none;
    font-weight: 500;
}

.nav-profile__item:hover,
.nav-profile__item:focus-visible,
.nav-profile__item.is-active {
    background: rgba(8, 217, 214, 0.12);
    color: var(--player-one, var(--cp-player-one));
}

.nav-profile__item--danger:hover,
.nav-profile__item--danger:focus-visible {
    background: rgba(255, 46, 99, 0.12);
    color: var(--player-two, var(--cp-player-two));
}

.nav-profile__divider {
    height: 1px;
    margin: 0.4rem 0.25rem;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 1150px) {
    .site-navbar__link.is-active::after {
        display: none;
    }

    .nav-profile__menu {
        position: static;
        margin-top: 0.5rem;
        box-shadow: none;
    }
}

body.light-mode .nav-profile__menu {
    background: #fff;
}

/* ---------- Footer ---------- */
.site-footer {
    margin-top: 60px;
    border-top: 2px solid rgba(8, 217, 214, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.site-footer__inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.site-footer__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.7;
    font-size: 0.9rem;
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
}

.site-footer__links a {
    color: var(--primary-text, var(--cp-primary-text));
    opacity: 0.7;
    text-decoration: none;
    font-size: 0.9rem;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.site-footer__links a:hover,
.site-footer__links a:focus-visible {
    opacity: 1;
    color: var(--player-one, var(--cp-player-one));
}

@media (max-width: 600px) {
    .site-footer__inner {
        padding: 20px;
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---------- Buttons ---------- */
.cp-btn {
    padding: 10px 22px;
    border-radius: 50px;
    border: 2px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary-text, var(--cp-primary-text));
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cp-btn:hover {
    transform: translateY(-1px);
}

.cp-btn--primary {
    background: linear-gradient(135deg, var(--cp-player-one), var(--cp-player-two));
}

.cp-btn--danger {
    background: var(--cp-player-two);
}

.cp-btn--ghost {
    background: transparent;
    border-color: rgba(8, 217, 214, 0.4);
}

/* ---------- Toasts ---------- */
.cp-toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 40px));
    pointer-events: none;
}

.cp-toast {
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--cp-primary-black);
    border: 2px solid rgba(8, 217, 214, 0.5);
    color: var(--cp-primary-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.cp-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.cp-toast--success {
    border-color: rgb(34, 197, 94);
}

.cp-toast--error {
    border-color: var(--cp-player-two);
}

/* ---------- Dialog ---------- */
.cp-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 2900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.cp-dialog {
    width: min(440px, 100%);
    padding: 28px;
    border-radius: 20px;
    background: var(--cp-primary-black);
    border: 2px solid rgba(8, 217, 214, 0.4);
    color: var(--cp-primary-text);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.cp-dialog__title {
    margin: 0 0 10px;
    font-size: 1.3rem;
}

.cp-dialog__message {
    margin: 0 0 20px;
    opacity: 0.8;
    line-height: 1.5;
}

.cp-dialog__input {
    width: 100%;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid rgba(8, 217, 214, 0.3);
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    font: inherit;
    resize: vertical;
}

.cp-dialog__input:focus {
    outline: none;
    border-color: var(--cp-player-one);
}

.cp-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* The hidden attribute must win over component display rules (e.g. .btn { display: inline-flex }). */
[hidden] {
    display: none !important;
}

/* ---------- Notification bell ---------- */
.nav-bell {
    position: relative;
}

.nav-bell__button {
    position: relative;
    padding: 8px 10px;
    border-radius: 50%;
    border: 2px solid rgba(8, 217, 214, 0.3);
    background: transparent;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.nav-messages__link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.nav-messages__link[aria-current="page"] {
    border-color: var(--player-one, var(--cp-player-one));
}

.nav-bell__count {
    position: absolute;
    top: -6px;
    right: -8px;
    margin: 0;
}

.nav-bell__menu {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    width: min(340px, 90vw);
    max-height: 420px;
    overflow-y: auto;
    padding: 0.5rem;
    border-radius: 15px;
    background: var(--cp-primary-black);
    border: 2px solid rgba(8, 217, 214, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1300;
}

.nav-bell__title {
    padding: 0.5rem 0.75rem;
    font-weight: 700;
    color: var(--cp-player-one);
}

.nav-bell__item {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--cp-primary-text);
    text-decoration: none;
    font-size: 0.92rem;
}

.nav-bell__item:hover {
    background: rgba(8, 217, 214, 0.12);
}

.nav-bell__item.is-unread {
    background: rgba(8, 217, 214, 0.07);
    font-weight: 600;
}

.nav-bell__time {
    display: block;
    font-size: 0.75rem;
    opacity: 0.6;
    font-weight: 400;
}

.nav-bell__empty {
    padding: 1rem;
    text-align: center;
    opacity: 0.6;
}

@media (max-width: 1150px) {
    .nav-bell__menu {
        position: static;
        width: 100%;
        margin-top: 0.5rem;
        box-shadow: none;
    }
}

/* ---------- Profile showcase (pinned achievements, favourite games, premium banners) ---------- */
.profile-showcase {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 18px;
}

.profile-showcase[hidden] {
    display: none;
}

.showcase-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(8, 217, 214, 0.35);
}

.showcase-chip--game {
    border-color: rgba(255, 46, 99, 0.35);
}

.profile-header.banner-sunset { background: linear-gradient(135deg, rgba(255, 94, 98, 0.35), rgba(255, 153, 102, 0.25)) !important; }
.profile-header.banner-ocean  { background: linear-gradient(135deg, rgba(14, 165, 233, 0.35), rgba(8, 217, 214, 0.2)) !important; }
.profile-header.banner-forest { background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(16, 185, 129, 0.2)) !important; }
.profile-header.banner-gold   { background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(251, 191, 36, 0.2)) !important; }
