/*
Theme Name: CMGK Modern
Theme URI: https://www.coolmathgameskids.com/
Description: Lightweight modern gaming theme for CoolMathGamesKids.
Version: 1.0.0
Author: CoolMathGamesKids
Text Domain: cmgk-modern
*/

/* =========================================================
   Base
   ========================================================= */

:root {
    --cmgk-bg: #010c14;
    --cmgk-surface: #010c14;
    --cmgk-surface-soft: #213744;
    --cmgk-surface-hover: #294351;
    --cmgk-text: #ffffff;
    --cmgk-muted: #aebbc3;
    --cmgk-border: #304652;
    --cmgk-accent: #5da9ff;
    --cmgk-accent-hover: #7bb9ff;
    --cmgk-radius: 10px;
    --cmgk-container: 1440px;
}

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

html {
    margin: 0;
    padding: 0;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--cmgk-bg);
    color: var(--cmgk-text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

/* =========================================================
   Accessibility
   ========================================================= */

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =========================================================
   Main Site Container
   ========================================================= */

.cmgk-site {
    min-height: 100vh;
}

.cmgk-container {
    width: min(100% - 32px, var(--cmgk-container));
    margin-inline: auto;
}

/* =========================================================
   Header
   ========================================================= */

.cmgk-header {
    background: #010c14;
    border-bottom: 1px solid #263137;
}

.cmgk-header-main {
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.cmgk-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.cmgk-logo img {
    display: block;
    width: auto;
    max-width: 260px;
    max-height: 58px;
}

/* =========================================================
   Search
   ========================================================= */

.cmgk-search {
    flex: 1 1 auto;
    max-width: 560px;
    margin-left: auto;
}

.cmgk-search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.cmgk-search-input {
    width: 100%;
    height: 44px;
    padding: 0 50px 0 16px;
    border: 1px solid #3a5260;
    border-radius: 8px;
    outline: none;
    background: #243a47;
    color: #ffffff;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.cmgk-search-input::placeholder {
    color: #9eafb9;
}

.cmgk-search-input:focus {
    border-color: #5da9ff;
    background: #263f4d;
}

.cmgk-search-input:focus {
    border-color: var(--cmgk-accent);
    background: #ffffff;
}

.cmgk-search-button {
    position: absolute;
    top: 0;
    right: 0;
    width: 46px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--cmgk-muted);
    cursor: pointer;
}

.cmgk-search-button:hover {
    color: var(--cmgk-accent);
}

/* =========================================================
   Navigation
   ========================================================= */

.cmgk-navigation {
    background: #010c14;
    border-top: 1px solid #263137;
}

.cmgk-navigation-inner {
    min-height: 46px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.cmgk-navigation-inner::-webkit-scrollbar {
    display: none;
}

.cmgk-navigation ul {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cmgk-navigation li {
    flex: 0 0 auto;
}

.cmgk-navigation a {
    display: block;
    padding: 8px 13px;
    border-radius: 7px;
    color: #d4dde2;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.cmgk-navigation a:hover,
.cmgk-navigation .current-cat > a,
.cmgk-navigation .current_page_item > a {
    background: #294351;
    color: #ffffff;
}

/* =========================================================
   Homepage
   ========================================================= */

.cmgk-home {
    padding: 28px 0 50px;
}

.cmgk-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.cmgk-section-title {
    margin: 0;
    color: var(--cmgk-text);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
}

/* =========================================================
   Game Grid
   ========================================================= */

.cmgk-game-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 24px 16px;
}

/* =========================================================
   Game Card
   ========================================================= */

.cmgk-game-card {
    min-width: 0;
}

.cmgk-game-card-link {
    display: block;
}

.cmgk-game-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--cmgk-radius);
    background: #e9edf2;
}

.cmgk-game-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.cmgk-game-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--cmgk-radius);
    background: #17252e;
}

.cmgk-game-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1);
    transition:
        transform 0.38s cubic-bezier(0.2, 0.75, 0.25, 1),
        filter 0.38s ease;
    will-change: transform;
}

.cmgk-game-card-link:hover .cmgk-game-thumb img {
    transform: scale(1.09);
    filter: brightness(1.06);
}

.cmgk-game-title {
    margin: 9px 2px 0;
    color: var(--cmgk-text);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmgk-game-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 5px 2px 0;
    color: var(--cmgk-muted);
    font-size: 13px;
    line-height: 1.25;
}

.cmgk-game-views,
.cmgk-game-rating {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.cmgk-game-rating {
    color: #656b72;
}

.cmgk-meta-icon {
    display: inline-flex;
    width: 15px;
    height: 15px;
    margin-right: 4px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* =========================================================
   Pagination
   ========================================================= */

.cmgk-pagination {
    display: flex;
    justify-content: center;
    margin-top: 38px;
}

.cmgk-pagination .wp-pagenavi {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.cmgk-pagination .wp-pagenavi a,
.cmgk-pagination .wp-pagenavi span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--cmgk-border);
    border-radius: 7px;
    background: var(--cmgk-surface);
    color: #555c64;
    font-size: 14px;
}

.cmgk-pagination .wp-pagenavi a:hover,
.cmgk-pagination .wp-pagenavi .current {
    border-color: var(--cmgk-accent);
    background: var(--cmgk-accent);
    color: #ffffff;
}

/* =========================================================
   Footer
   ========================================================= */

.cmgk-footer {
    margin-top: 30px;
    border-top: 1px solid #304652;
    background: #1c2c38;
}

.cmgk-footer-inner {
    padding: 28px 0;
    color: var(--cmgk-muted);
    font-size: 13px;
    text-align: center;
}

/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 1199px) {
    .cmgk-game-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .cmgk-header-main {
        min-height: 68px;
        gap: 18px;
    }

    .cmgk-logo img {
        max-width: 220px;
        max-height: 52px;
    }

    .cmgk-game-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 22px 14px;
    }
}

/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 767px) {
    .cmgk-container {
        width: min(100% - 20px, var(--cmgk-container));
    }

    .cmgk-header-main {
        min-height: 62px;
        gap: 12px;
    }

    .cmgk-logo img {
        max-width: 175px;
        max-height: 48px;
    }

    .cmgk-search {
        max-width: none;
    }

    .cmgk-search-input {
        height: 40px;
        padding-left: 12px;
        padding-right: 42px;
        font-size: 14px;
    }

    .cmgk-search-button {
        width: 40px;
        height: 40px;
    }

    .cmgk-navigation-inner {
        min-height: 43px;
    }

    .cmgk-navigation a {
        padding: 7px 10px;
        font-size: 13px;
    }

    .cmgk-home {
        padding-top: 22px;
    }

    .cmgk-section-title {
        font-size: 21px;
    }

    .cmgk-game-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px 10px;
    }

    .cmgk-game-thumb {
        border-radius: 8px;
    }

    .cmgk-game-title {
        margin-top: 7px;
        font-size: 14px;
    }

    .cmgk-game-meta {
        margin-top: 4px;
        font-size: 12px;
    }

    .cmgk-meta-icon {
        width: 14px;
        height: 14px;
        margin-right: 3px;
    }
}

/* =========================================================
   Small Mobile
   ========================================================= */

@media (max-width: 380px) {
    .cmgk-logo img {
        max-width: 145px;
    }

    .cmgk-header-main {
        gap: 8px;
    }

    .cmgk-game-grid {
        gap: 18px 8px;
    }
}

/* =========================================================
   Reduced Motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* =========================================================
   Single Game Page
   ========================================================= */

.cmgk-single {
    padding: 28px 0 60px;
}

/* Game Header */

.cmgk-game-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

.cmgk-game-header-main {
    min-width: 0;
}

.cmgk-breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 8px;
    color: var(--cmgk-muted);
    font-size: 13px;
}

.cmgk-breadcrumbs a {
    color: var(--cmgk-muted);
}

.cmgk-breadcrumbs a:hover {
    color: var(--cmgk-accent);
}

.cmgk-single-title {
    margin: 0;
    color: var(--cmgk-text);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
}

.cmgk-game-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    color: var(--cmgk-muted);
    font-size: 14px;
    white-space: nowrap;
}


/* Mobile Game Link */

.cmgk-mobile-game-link {
    margin-bottom: 16px;
}

.cmgk-mobile-game-link a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 15px;
    border-radius: 7px;
    background: #eef4ff;
    color: var(--cmgk-accent);
    font-size: 14px;
    font-weight: 600;
}

.cmgk-mobile-game-link a:hover {
    background: #e2ecff;
    color: var(--cmgk-accent-hover);
}


/* Game Player */

.cmgk-game-player {
    width: 100%;
    margin: 0 0 34px;
}

.cmgk-game-player-inner {
    position: relative;
    width: 100%;
    min-height: 300px;
    overflow: hidden;
    border-radius: var(--cmgk-radius);
    background: #11151a;
}

/*
 * Responsive iframe.
 *
 * When the game has no explicit dimensions, the player uses
 * a 16:9 layout. Explicit iframe dimensions supplied by
 * WPArcade are still respected by the iframe itself.
 */

.cmgk-game-iframe {
    display: block;
    width: 100%;
    min-height: 520px;
    border: 0;
    background: #000;
}

.cmgk-game-embed {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.cmgk-game-embed iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 0;
}

.cmgk-game-embed img,
.cmgk-game-embed video {
    max-width: 100%;
    height: auto;
}

.cmgk-game-legacy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 520px;
    overflow: auto;
    background: #000;
}

.cmgk-game-unavailable {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    padding: 30px;
    color: #ffffff;
    text-align: center;
}

.cmgk-game-unavailable img {
    display: block;
    width: min(100%, 720px);
    height: auto;
    margin-bottom: 20px;
    border-radius: 8px;
}

.cmgk-game-unavailable p {
    margin: 0;
    color: #c7ccd2;
}


/* Game Information */

.cmgk-game-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 36px;
    align-items: start;
    margin-bottom: 40px;
}

.cmgk-game-info-main {
    min-width: 0;
}

.cmgk-game-description,
.cmgk-info-section {
    margin-bottom: 30px;
}

.cmgk-game-description h2,
.cmgk-info-section h2,
.cmgk-game-details h2,
.cmgk-rating-box h2 {
    margin: 0 0 12px;
    color: var(--cmgk-text);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.cmgk-content {
    color: #4e555d;
    font-size: 15px;
    line-height: 1.7;
}

.cmgk-content p {
    margin: 0 0 14px;
}

.cmgk-content p:last-child {
    margin-bottom: 0;
}

.cmgk-content a {
    color: var(--cmgk-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cmgk-content a:hover {
    color: var(--cmgk-accent-hover);
}

.cmgk-content ul,
.cmgk-content ol {
    margin: 0 0 16px;
    padding-left: 22px;
}

.cmgk-content li {
    margin-bottom: 6px;
}

.cmgk-content h3,
.cmgk-content h4 {
    margin: 20px 0 8px;
    color: var(--cmgk-text);
}


/* Game Details */

.cmgk-game-details {
    padding: 20px;
    border: 1px solid var(--cmgk-border);
    border-radius: var(--cmgk-radius);
    background: var(--cmgk-surface);
}

.cmgk-game-details h2 {
    font-size: 18px;
}

.cmgk-game-details dl {
    margin: 0;
}

.cmgk-game-details dt {
    margin-top: 14px;
    color: var(--cmgk-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cmgk-game-details dt:first-child {
    margin-top: 0;
}

.cmgk-game-details dd {
    margin: 3px 0 0;
    color: var(--cmgk-text);
    font-size: 14px;
}

.cmgk-game-details dd a {
    color: var(--cmgk-accent);
}

.cmgk-game-details dd a:hover {
    color: var(--cmgk-accent-hover);
}


/* Tags */

.cmgk-game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.cmgk-game-tags a {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 6px;
    background: #eef1f5;
    color: #555c64;
    font-size: 12px;
}

.cmgk-game-tags a:hover {
    background: #e6ebf2;
    color: var(--cmgk-accent);
}


/* Rating */

.cmgk-rating-box {
    margin-bottom: 42px;
    padding: 22px;
    border: 1px solid var(--cmgk-border);
    border-radius: var(--cmgk-radius);
    background: var(--cmgk-surface);
}

.cmgk-rating-content {
    color: var(--cmgk-muted);
}


/* Related Games */

.cmgk-related-games {
    margin-top: 42px;
}

.cmgk-related-games .cmgk-section-header {
    margin-bottom: 18px;
}


/* Not Found */

.cmgk-not-found {
    padding: 80px 20px;
    text-align: center;
}

.cmgk-not-found h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.cmgk-not-found p {
    margin: 0;
    color: var(--cmgk-muted);
}


/* =========================================================
   Single Game - Tablet
   ========================================================= */

@media (max-width: 991px) {

    .cmgk-single {
        padding-top: 24px;
    }

    .cmgk-game-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .cmgk-single-title {
        font-size: 27px;
    }

    .cmgk-game-info {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .cmgk-game-details {
        width: 100%;
    }

    .cmgk-game-iframe {
        min-height: 480px;
    }

    .cmgk-game-legacy {
        min-height: 480px;
    }
}


/* =========================================================
   Single Game - Mobile
   ========================================================= */

@media (max-width: 767px) {

    .cmgk-single {
        padding: 20px 0 40px;
    }

    .cmgk-game-header {
        margin-bottom: 15px;
    }

    .cmgk-breadcrumbs {
        margin-bottom: 6px;
        font-size: 12px;
    }

    .cmgk-single-title {
        font-size: 22px;
        line-height: 1.25;
    }

    .cmgk-game-header-meta {
        font-size: 12px;
    }

    .cmgk-game-player {
        margin-bottom: 26px;
    }

    .cmgk-game-player-inner {
        min-height: 220px;
        border-radius: 8px;
    }

    /*
     * Mobile games should use the available screen width.
     * The minimum height is deliberately smaller than desktop
     * to avoid creating a huge blank area on phones.
     */

    .cmgk-game-iframe {
        min-height: 240px;
    }

    .cmgk-game-legacy {
        min-height: 240px;
    }

    .cmgk-game-unavailable {
        min-height: 260px;
        padding: 20px;
    }

    .cmgk-game-info {
        gap: 24px;
        margin-bottom: 30px;
    }

    .cmgk-game-description,
    .cmgk-info-section {
        margin-bottom: 24px;
    }

    .cmgk-game-description h2,
    .cmgk-info-section h2,
    .cmgk-game-details h2,
    .cmgk-rating-box h2 {
        font-size: 18px;
    }

    .cmgk-content {
        font-size: 14px;
        line-height: 1.65;
    }

    .cmgk-game-details {
        padding: 17px;
        border-radius: 8px;
    }

    .cmgk-rating-box {
        margin-bottom: 32px;
        padding: 18px;
        border-radius: 8px;
    }

    .cmgk-related-games {
        margin-top: 30px;
    }
}


/* =========================================================
   Single Game - Very Small Screens
   ========================================================= */

@media (max-width: 380px) {

    .cmgk-single-title {
        font-size: 20px;
    }

    .cmgk-game-player-inner {
        border-radius: 7px;
    }

    .cmgk-game-iframe {
        min-height: 210px;
    }

    .cmgk-game-legacy {
        min-height: 210px;
    }
}