/*
 * Kubet88 Theme - Mobile Fixes & Enhancements
 * Fix image overflow, content styling, and responsive improvements
 */

/* ===== UNIVERSAL IMAGE FIX (ALL SCREEN SIZES) ===== */
/* Base image rules - apply to all images */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent images in content from overflowing */
.page-content img,
.post-content img,
.entry-content img,
.article-content img,
.wp-block-image img,
figure img {
    max-width: 100% !important;
    height: auto !important;
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

/* WordPress alignment classes */
.alignnone,
.aligncenter,
.alignleft,
.alignright {
    max-width: 100%;
    height: auto;
}

.aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.alignleft {
    float: left;
    margin-right: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.alignright {
    float: right;
    margin-left: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

/* WordPress figure and caption */
figure {
    max-width: 100%;
    margin: var(--spacing-lg) 0;
}

figure img {
    display: block;
    width: 100%;
    height: auto;
}

figcaption {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
    text-align: center;
}

/* Card images - maintain aspect ratio */
.card-img,
.wp-post-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

/* Promo and feature images */
.promo-image,
.feature-image,
.game-card {
    overflow: hidden;
    position: relative;
}

.promo-image img,
.feature-image img,
.game-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Prevent container overflow */
.container,
.page-content,
.post-content,
.entry-content,
.site-wrapper {
    overflow-x: hidden;
}

/* ===== MOBILE-SPECIFIC IMAGE ADJUSTMENTS ===== */
@media (max-width: 768px) {

    /* Ensure images don't break layout on mobile */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Remove float on mobile for better layout */
    .alignleft,
    .alignright {
        float: none;
        margin: var(--spacing-md) auto;
        display: block;
    }

    /* Card images on mobile */
    .card-img,
    .promo-image img,
    .game-card img,
    .feature-image img,
    article img,
    .post-thumbnail img,
    .wp-post-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: cover;
    }

    /* Content images - ensure proper sizing */
    .page-content img,
    .post-content img,
    .entry-content img,
    .article-content img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        margin: var(--spacing-md) 0;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
    }

    /* WordPress blocks */
    .wp-block-image {
        max-width: 100%;
    }

    .wp-block-image img {
        width: 100% !important;
    }

    /* Figure on mobile */
    figure {
        margin: var(--spacing-md) 0;
    }
}

/* ===== DESKTOP IMAGE OPTIMIZATION ===== */
@media (min-width: 769px) {

    /* Content images - reasonable max width on desktop */
    .page-content img,
    .post-content img,
    .entry-content img,
    .article-content img {
        max-width: 100%;
        height: auto;
    }

    /* Large images in content - prevent excessive size */
    .page-content img[width],
    .post-content img[width],
    .entry-content img[width] {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }

    /* Aligned images on desktop */
    .alignleft,
    .alignright {
        max-width: 50%;
    }
}

/* ===== MOBILE CONTENT TEXT STYLING IMPROVEMENTS ===== */
@media (max-width: 768px) {

    /* Better paragraph spacing and readability */
    p {
        font-size: var(--font-size-base);
        line-height: 1.7;
        margin-bottom: 1.2rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Card content improvements */
    .card-body {
        padding: var(--spacing-md) !important;
    }

    .card-title {
        font-size: var(--font-size-lg) !important;
        line-height: 1.4;
        margin-bottom: var(--spacing-sm);
    }

    .card-text {
        font-size: var(--font-size-sm);
        line-height: 1.6;
        color: #5b6c7f;
    }

    .card-meta {
        font-size: var(--font-size-xs);
        margin-bottom: var(--spacing-sm);
    }

    /* Post content styling */
    .post-content,
    .entry-content,
    .page-content {
        padding: var(--spacing-md);
    }

    .post-content p,
    .entry-content p {
        font-size: var(--font-size-base);
        line-height: 1.7;
        margin-bottom: 1.2em;
    }

    /* Better list styling */
    ul,
    ol {
        padding-left: 1.2em;
        margin-bottom: 1.2em;
    }

    li {
        margin-bottom: 0.6em;
        line-height: 1.6;
    }

    /* Improve button sizing */
    .btn {
        font-size: var(--font-size-sm);
        padding: var(--spacing-sm) var(--spacing-md);
        width: 100%;
        justify-content: center;
    }

    .btn-sm {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* ===== ENTRY CONTENT & ARTICLE CONTENT STYLING ===== */
.entry-content,
.article-content,
.post-content,
.front-page-content {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-body);
}

.entry-content>*,
.article-content>*,
.post-content>*,
.front-page-content>* {
    max-width: 100%;
}

.entry-content p,
.article-content p,
.post-content p,
.front-page-content p {
    margin-bottom: 1.5em;
    line-height: var(--line-height-relaxed);
}

/* Content Links — Distinct from body text */
/* Apply to main text links but allow components like TOC to use their own styles */
.entry-content a,
.article-content a,
.post-content a,
.front-page-content a {
    color: var(--color-primary) !important;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-fast);
    font-weight: 500;
}

/* EXCLUDE TOC, CTA buttons, and specific areas from the blue link override */
.entry-content #toc_container a,
.entry-content .toc_container a,
.entry-content .ez-toc-container a,
.entry-content .lwptoc_i a,
.entry-content .wp-block-table-of-contents a,
.entry-content .ftwp-renderer a,
.article-content #toc_container a,
.article-content .toc_container a,
.article-content .ez-toc-container a,
.article-content .lwptoc_i a,
.post-content #toc_container a,
.post-content .toc_container a,
.post-content .ez-toc-container a,
.post-content .lwptoc_i a,
.front-page-content #toc_container a,
.front-page-content .toc_container a,
.front-page-content .ez-toc-container a,
.front-page-content .lwptoc_i a,
.front-page-content .wp-block-table-of-contents a,
.front-page-content .ftwp-renderer a,
.entry-content .btn,
.entry-content .button,
.front-page-content .cta-simple,
.front-page-content .cta-pulse,
.entry-content .cta-simple,
.entry-content .cta-pulse,
.front-page-content .stadium-actions a,
.front-page-content .header-actions a {
    color: inherit !important;
    border-bottom: none !important;
    font-weight: inherit !important;
}

/* Force child elements inside content links to inherit link color */
/* Only apply within actual post/page content areas */
.entry-content a>strong,
.entry-content a>b,
.entry-content a>span,
.entry-content a>em,
.entry-content a>i,
.article-content a>strong,
.article-content a>b,
.article-content a>span,
.article-content a>em,
.article-content a>i,
.post-content a>strong,
.post-content a>b,
.post-content a>span,
.post-content a>em,
.post-content a>i,
.front-page-content a>strong,
.front-page-content a>b,
.front-page-content a>span,
.front-page-content a>em,
.front-page-content a>i {
    color: inherit !important;
}

.entry-content a:hover,
.article-content a:hover,
.post-content a:hover,
.front-page-content a:hover {
    color: var(--color-primary-dark) !important;
    border-bottom-color: var(--color-primary-dark);
}

/* Reset hover for excluded areas */
.entry-content #toc_container a:hover,
.entry-content .toc_container a:hover,
.entry-content .ez-toc-container a:hover,
.entry-content .lwptoc_i a:hover,
.entry-content .wp-block-table-of-contents a:hover,
.entry-content .ftwp-renderer a:hover,
.front-page-content #toc_container a:hover,
.front-page-content .toc_container a:hover,
.front-page-content .ez-toc-container a:hover,
.front-page-content .lwptoc_i a:hover,
.front-page-content .wp-block-table-of-contents a:hover,
.front-page-content .ftwp-renderer a:hover,
.article-content #toc_container a:hover,
.article-content .ez-toc-container a:hover,
.post-content #toc_container a:hover,
.post-content .ez-toc-container a:hover {
    color: var(--color-primary) !important;
    text-decoration: underline !important;
    border-bottom: none !important;
}

/* Reset hover for CTA buttons */
.front-page-content .cta-simple:hover,
.front-page-content .cta-pulse:hover,
.entry-content .cta-simple:hover,
.entry-content .cta-pulse:hover,
.front-page-content .stadium-actions a:hover,
.front-page-content .header-actions a:hover {
    color: inherit !important;
    border-bottom: none !important;
}

/* Reset visited for CTA buttons */
.front-page-content .cta-simple:visited,
.front-page-content .cta-pulse:visited,
.entry-content .cta-simple:visited,
.entry-content .cta-pulse:visited {
    color: inherit !important;
}

.entry-content a:visited,
.article-content a:visited,
.post-content a:visited,
.front-page-content a:visited {
    color: var(--color-primary) !important;
}


.entry-content h2,
.article-content h2,
.post-content h2,
.front-page-content h2 {
    font-size: var(--font-size-xl);
    margin-top: 1.5em;
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--color-bg-muted);
}

.entry-content h3,
.article-content h3,
.post-content h3,
.front-page-content h3 {
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    font-size: var(--font-size-xl);
    color: var(--color-text-heading);
}

.entry-content h4,
.article-content h4,
.post-content h4,
.front-page-content h4 {
    margin-top: 1.5em;
    margin-bottom: 0.6em;
    font-size: var(--font-size-lg);
    color: var(--color-text-heading);
}

.entry-content ul,
.entry-content ol,
.article-content ul,
.article-content ol,
.post-content ul,
.post-content ol {
    margin-bottom: 1.5em;
    padding-left: 2em;
}

.entry-content ul li::marker,
.article-content ul li::marker,
.post-content ul li::marker {
    color: var(--color-primary);
    font-weight: 700;
}

.entry-content li,
.article-content li,
.post-content li {
    margin-bottom: 0.5em;
    line-height: var(--line-height-relaxed);
}

.entry-content blockquote,
.article-content blockquote,
.post-content blockquote {
    border-left: 5px solid var(--color-primary);
    padding: var(--spacing-lg) var(--spacing-xl);
    margin: var(--spacing-xl) 0;
    font-style: italic;
    color: var(--color-text-body);
    background: var(--color-bg-muted);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    position: relative;
    font-size: 1.1em;
}

.entry-content blockquote::before,
.article-content blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 10px;
    font-size: 3rem;
    color: var(--color-primary);
    opacity: 0.1;
    font-family: serif;
}

.entry-content table,
.article-content table,
.post-content table {
    width: 100%;
    margin-bottom: var(--spacing-lg);
    border-collapse: collapse;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.entry-content table th,
.entry-content table td,
.article-content table th,
.article-content table td,
.post-content table th,
.post-content table td {
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
}

.entry-content table th,
.article-content table th,
.post-content table th {
    background-color: var(--color-primary);
    color: var(--color-text-light);
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.entry-content table tr:nth-child(even),
.article-content table tr:nth-child(even),
.post-content table tr:nth-child(even) {
    background-color: var(--color-bg-muted);
}

.entry-content table tr:hover,
.article-content table tr:hover,
.post-content table tr:hover {
    background-color: rgba(10, 102, 194, 0.05);
}

/* Entry thumbnail */
.entry-thumbnail {
    margin-bottom: var(--spacing-xl);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.entry-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
}

/* Entry header */
.entry-header {
    margin-bottom: var(--spacing-xl);
}

.entry-title {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--spacing-md);
    color: var(--color-text-heading);
}

.entry-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

@media (max-width: 768px) {

    .entry-content,
    .article-content,
    .post-content,
    .front-page-content {
        font-size: var(--font-size-base);
    }

    .entry-title {
        font-size: var(--font-size-2xl);
    }

    .entry-content h2,
    .article-content h2,
    .post-content h2,
    .front-page-content h2 {
        font-size: var(--font-size-xl);
        margin-top: 1.5em;
    }

    .entry-content h3,
    .article-content h3,
    .post-content h3,
    .front-page-content h3 {
        font-size: var(--font-size-lg);
        margin-top: 1.3em;
    }

    .entry-content h4,
    .article-content h4,
    .post-content h4,
    .front-page-content h4 {
        font-size: var(--font-size-base);
        margin-top: 1.2em;
    }

    .entry-content ul,
    .entry-content ol,
    .article-content ul,
    .article-content ol,
    .post-content ul,
    .post-content ol {
        padding-left: 1.5em;
    }

    .entry-content blockquote,
    .article-content blockquote,
    .post-content blockquote {
        padding-left: var(--spacing-md);
        margin: var(--spacing-lg) 0;
    }
}

/* ===== CATEGORY DESCRIPTION STYLING ===== */
.category-description,
.taxonomy-description,
.archive-description {
    background: linear-gradient(135deg, #f8faff 0%, #ffffff 100%);
    border-left: 4px solid var(--color-primary);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.category-description p,
.taxonomy-description p,
.archive-description p {
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-body);
    margin-bottom: 0;
}

.category-description h2,
.taxonomy-description h2,
.archive-description h2 {
    font-size: var(--font-size-2xl);
    color: var(--color-primary);
    margin-top: 0;
    margin-bottom: var(--spacing-md);
}

@media (max-width: 768px) {

    .category-description,
    .taxonomy-description,
    .archive-description {
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-lg);
    }

    .category-description h2,
    .taxonomy-description h2,
    .archive-description h2 {
        font-size: var(--font-size-xl);
    }

    .category-description p,
    .taxonomy-description p,
    .archive-description p {
        font-size: var(--font-size-sm);
    }
}

/* ===== ARCHIVE PAGE HEADER ===== */
.archive-header {
    background: var(--gradient-primary);
    color: var(--color-text-light);
    padding: var(--spacing-2xl) 0;
    margin-bottom: var(--spacing-2xl);
    text-align: center;
}

.archive-header h1 {
    color: var(--color-text-light);
    margin: 0;
    font-size: var(--font-size-4xl);
}

@media (max-width: 768px) {
    .archive-header {
        padding: var(--spacing-lg) 0;
        margin-bottom: var(--spacing-lg);
    }

    .archive-header h1 {
        font-size: var(--font-size-2xl);
    }
}

/* ===== POSTS GRID MOBILE FIX ===== */
@media (max-width: 768px) {
    .posts-grid {
        gap: var(--spacing-lg);
        padding: 0 var(--spacing-md);
    }

    .posts-grid .card {
        margin-bottom: 0;
    }
}

/* ===== RESPONSIVE TABLE FIX ===== */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    table td,
    table th {
        font-size: var(--font-size-sm);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* ===== MOBILE SPACING ADJUSTMENTS ===== */
@media (max-width: 768px) {

    .section,
    .section-lg {
        padding: var(--spacing-2xl) 0;
    }

    .section-sm {
        padding: var(--spacing-lg) 0;
    }

    .container {
        padding: 0 var(--spacing-md);
    }
}