/*
 * MemberCore Realm. Gamification overlay.
 * Scope: .realm-* pattern classes, .wp-block-mcgf-* plugin block classes, .mcgf-* plugin component classes.
 */

/* ============================================================
 * 1. Header
 * ============================================================ */
.realm-header { position: relative; z-index: 10; }
.realm-header__logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.realm-header__logo img {
    display: block;
    height: 52px;
    width: auto;
    filter: drop-shadow(0 0 6px rgba(212,175,55,0.25));
}
.realm-header__nav a:hover {
    color: var(--wp--preset--color--royal-gold);
}

/* ============================================================
 * 2. Hero
 * ============================================================ */
.realm-hero {
    position: relative;
    overflow: hidden;
}
.realm-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../images/parchment-grain.svg");
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.05;
    mix-blend-mode: overlay;
    pointer-events: none;
}
.realm-hero__shield {
    position: relative;
    filter: drop-shadow(0 0 30px rgba(212,175,55,0.3));
}
.realm-hero__shield::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,245,184,0.4) 50%, transparent 70%);
    mix-blend-mode: overlay;
    animation: realm-shimmer 6s ease-in-out infinite;
    pointer-events: none;
}
.realm-hero__headline {
    text-shadow: 0 0 30px rgba(212,175,55,0.25);
}

/* ============================================================
 * 3. Leaderboard featured
 * ============================================================ */
.realm-leaderboard .wp-block-mcgf-leaderboard,
.realm-leaderboard .mcgf-leaderboard {
    max-width: 720px;
    margin-inline: auto;
}
.realm-leaderboard .mcgf-leaderboard tr,
.realm-leaderboard .wp-block-mcgf-leaderboard tr {
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.realm-leaderboard .mcgf-leaderboard tr:hover,
.realm-leaderboard .wp-block-mcgf-leaderboard tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(15,20,41,0.08);
}
.realm-leaderboard .mcgf-leaderboard td:first-child,
.realm-leaderboard .wp-block-mcgf-leaderboard td:first-child {
    color: var(--wp--preset--color--royal-gold);
    font-family: var(--wp--preset--font-family--mono);
    font-weight: 700;
}

/* ============================================================
 * 4. Rank tiers
 * ============================================================ */
.realm-tier-card {
    transition: transform 150ms ease, box-shadow 150ms ease;
    border-radius: 4px;
}
.realm-tier-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(15,20,41,0.12);
}
.realm-tier-card__shield {
    position: relative;
}
.realm-tier-card__shield::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,245,184,0.5) 50%, transparent 70%);
    mix-blend-mode: overlay;
    animation: realm-shimmer 6s ease-in-out infinite;
    pointer-events: none;
}
.realm-tier-card__bullets li {
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--wp--preset--color--ash);
}
.realm-tier-card__bullets li:last-child {
    border-bottom: 0;
}
.realm-tier-card--gold {
    background: linear-gradient(180deg, var(--wp--preset--color--parchment) 0%, #fffbe6 100%);
}

/* ============================================================
 * 5. Achievement showcase
 * ============================================================ */
.realm-achievements__grid {
    gap: 1.5rem;
}
.realm-badge {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.realm-badge:hover {
    transform: translateY(-4px);
}
.realm-badge__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
}
.realm-badge--earned .realm-badge__icon {
    background: linear-gradient(135deg, var(--wp--preset--color--royal-gold), var(--wp--preset--color--royal-gold-light));
    border: 2px solid var(--wp--preset--color--realm-night);
    color: var(--wp--preset--color--realm-night);
    box-shadow: 0 0 16px rgba(212,175,55,0.3);
    position: relative;
}
.realm-badge--earned:nth-child(1) .realm-badge__icon::before,
.realm-badge--earned:nth-child(2) .realm-badge__icon::before {
    content: "✦";
    position: absolute;
    top: -6px;
    right: -6px;
    color: var(--wp--preset--color--royal-gold-light);
    font-size: 1rem;
    animation: realm-sparkle 4s ease-in-out infinite;
}
.realm-badge--locked .realm-badge__icon {
    background: var(--wp--preset--color--ash);
    border: 2px solid var(--wp--preset--color--mute);
    color: var(--wp--preset--color--mute);
    opacity: 0.6;
}
.realm-badge--locked .realm-badge__icon::after {
    content: "🔒";
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 0.85rem;
}

/* ============================================================
 * 6. CTA bands
 * ============================================================ */
.realm-cta--join,
.realm-cta--continue {
    position: relative;
    overflow: hidden;
}
.realm-cta--join::before,
.realm-cta--continue::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../images/parchment-grain.svg");
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.04;
    mix-blend-mode: overlay;
    pointer-events: none;
}
.realm-divider svg,
.realm-divider img {
    display: inline-block;
    max-width: 240px;
}

/* ============================================================
 * 7. 404 + search empty
 * ============================================================ */
.realm-404 {
    text-align: center;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.realm-404__crest img {
    filter: drop-shadow(0 0 24px rgba(212,175,55,0.3));
}

/* ============================================================
 * 7a. Gamification Knowledgebase page (defined section breaks)
 * ============================================================ */
.realm-page-gamification-kb .mcgf-kb-section + .mcgf-kb-section {
    border-top: 0;
    margin-top: 64px;
    padding-top: 0;
    position: relative;
}
.realm-page-gamification-kb .mcgf-kb-section + .mcgf-kb-section::before {
    content: "";
    display: block;
    height: 2px;
    width: 280px;
    margin: 0 auto 56px;
    background: linear-gradient(90deg, transparent 0%, var(--wp--preset--color--royal-gold) 50%, transparent 100%);
    opacity: 0.7;
}

/* Each shortcode entry inside the Shortcodes section gets its own block, with a
   thin gold-tinted divider between consecutive entries to keep them readable. */
.realm-page-gamification-kb .mcgf-kb-shortcode {
    padding: 8px 0 24px;
}
.realm-page-gamification-kb .mcgf-kb-shortcode + .mcgf-kb-shortcode {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px dashed var(--wp--preset--color--royal-gold-dark);
    border-top-color: rgba(139, 111, 29, 0.45);
}

/* ============================================================
 * 7b. Gamification Showcase page (centered presentation)
 * ============================================================ */
.realm-page-gamification-showcase .wp-block-post-content {
    text-align: center;
}
.realm-page-gamification-showcase .wp-block-post-content > .wp-block-group {
    text-align: center;
}
/* Re-left-align code blocks, table cells, and lists so content stays readable. */
.realm-page-gamification-showcase .wp-block-post-content .mcgf-showcase-block,
.realm-page-gamification-showcase .wp-block-post-content table,
.realm-page-gamification-showcase .wp-block-post-content ul,
.realm-page-gamification-showcase .wp-block-post-content ol {
    text-align: left;
    margin-inline: auto;
}

/* Gating-locked reference screenshot embedded in the Content Gating Example section. */
.realm-gating-locked-screenshot img {
    border: 1px solid var(--wp--preset--color--royal-gold-dark);
    border-radius: 6px;
    max-width: 100%;
    height: auto;
}

/* ============================================================
 * 8. Footer
 * ============================================================ */
.realm-footer { position: relative; }
.realm-footer::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../images/parchment-grain.svg");
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.04;
    mix-blend-mode: overlay;
    pointer-events: none;
}
.realm-footer__sep {
    margin-block: 2.5rem;
    opacity: 0.4;
}

/* ============================================================
 * 9. Keyframes
 * ============================================================ */
@keyframes realm-shimmer {
    0%, 100% { transform: translateX(-100%); opacity: 0; }
    20%, 80% { opacity: 1; }
    50%      { transform: translateX(100%); }
}

@keyframes realm-sparkle {
    0%, 100% { opacity: 0; transform: rotate(0deg) scale(0.8); }
    50%      { opacity: 1; transform: rotate(180deg) scale(1.2); }
}

@keyframes realm-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212,175,55,0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(212,175,55,0); }
}

@keyframes realm-fill {
    from { width: 0; }
    to   { width: 100%; }
}

/* ============================================================
 * 10. Scroll-triggered progress bar fill
 *     animation-timeline: view() supported in Chrome/Edge 115+ and Safari 17+.
 *     Browsers without support fall back to the static .mcgf-progress__fill width.
 * ============================================================ */
@supports (animation-timeline: view()) {
    .mcgf-progress__fill,
    .wp-block-mcgf-user-rank .progress-fill {
        animation-name: realm-fill;
        animation-timeline: view();
        animation-range: entry 0% cover 30%;
        animation-fill-mode: forwards;
    }
}

/* ============================================================
 * 11. Sword divider draw-in
 * ============================================================ */
@supports (animation-timeline: view()) {
    .realm-divider svg line,
    .realm-divider img {
        animation: realm-fill 800ms ease forwards;
        animation-timeline: view();
        animation-range: entry 10% cover 30%;
    }
}

/* ============================================================
 * 12. Gold underline on hover (nav links and inline links)
 * ============================================================ */
.realm-header__nav a,
.realm-footer a {
    position: relative;
    text-decoration: none;
}
.realm-header__nav a::after,
.realm-footer a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    height: 2px;
    width: 100%;
    background: var(--wp--preset--color--royal-gold);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 200ms ease;
}
.realm-header__nav a:hover::after,
.realm-footer a:hover::after {
    transform: scaleX(1);
}

/* ============================================================
 * 13. Reduced-motion overrides
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .realm-hero__shield::after,
    .realm-tier-card__shield::after { animation: none; opacity: 0; }
    .realm-badge--earned .realm-badge__icon::before { animation: none; opacity: 0; }
    .mcgf-progress__fill,
    .wp-block-mcgf-user-rank .progress-fill { animation: none; width: var(--mcgf-progress-target, 100%); }
    .realm-divider svg line,
    .realm-divider img { animation: none; }
    .realm-header__nav a::after,
    .realm-footer a::after { transition: none; }
}
