/**
 * Mobile Responsive Styles
 * Works with existing template's menu toggle (is-menu-toggled-on class)
 */

/* ============================================
   BASE RESPONSIVE FIXES
   ============================================ */
html, body {
    overflow-x: hidden;
}

.site, #page {
    overflow-x: hidden;
    position: relative;
}

/* ============================================
   TABLET STYLES (max-width: 992px)
   ============================================ */
@media screen and (max-width: 992px) {
    .layout-medium,
    .layout-fixed {
        padding-left: 20px;
        padding-right: 20px;
    }

    /* 2 column grid for posts */
    .masonry .hentry,
    .blog-masonry .hentry {
        width: 50% !important;
    }
}

/* ============================================
   MOBILE STYLES (max-width: 768px)
   ============================================ */
@media screen and (max-width: 768px) {

    /* ---- HEADER ---- */
    .site-header {
        padding: 10px 0 !important;
        background: #fff;
        position: relative;
        z-index: 9999;
    }

    .primary-navigation {
        padding: 0 15px;
    }

    /* Logo - Center it */
    .social-container {
        position: absolute !important;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        float: none !important;
    }

    .social-container .logo img {
        height: 28px;
    }

    /* Hamburger menu button */
    .menu-toggle {
        display: block !important;
        position: relative;
        z-index: 10001;
        padding: 10px;
        cursor: pointer;
    }

    .menu-toggle .lines {
        display: block;
        width: 24px;
        height: 2px;
        background: #333;
        position: relative;
        transition: all 0.3s ease;
    }

    .menu-toggle .lines:before,
    .menu-toggle .lines:after {
        content: '';
        position: absolute;
        left: 0;
        width: 24px;
        height: 2px;
        background: #333;
        transition: all 0.3s ease;
    }

    .menu-toggle .lines:before {
        top: -7px;
    }

    .menu-toggle .lines:after {
        top: 7px;
    }

    /* Hamburger animation when open */
    .is-menu-toggled-on .menu-toggle .lines {
        background: transparent;
    }

    .is-menu-toggled-on .menu-toggle .lines:before {
        transform: rotate(45deg);
        top: 0;
        background: #333;
    }

    .is-menu-toggled-on .menu-toggle .lines:after {
        transform: rotate(-45deg);
        top: 0;
        background: #333;
    }

    /* Search toggle */
    .search-toggle {
        position: absolute !important;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
    }

    /* ---- MOBILE MENU ---- */
    .nav-menu {
        position: fixed !important;
        top: 0 !important;
        left: -280px;
        width: 280px;
        height: 100vh !important;
        background: #fff;
        z-index: 10000;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
        padding-top: 60px;
    }

    .is-menu-toggled-on .nav-menu {
        left: 0;
    }

    .nav-menu > ul {
        float: none !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    .nav-menu > ul > li {
        display: block !important;
        float: none !important;
        border-bottom: 1px solid #f0f0f0;
        margin: 0 !important;
    }

    .nav-menu > ul > li > a {
        display: block !important;
        padding: 16px 20px !important;
        font-size: 15px !important;
        color: #333 !important;
        text-decoration: none;
        border: none !important;
        background: none !important;
    }

    .nav-menu > ul > li > a:hover,
    .nav-menu > ul > li > a:focus {
        background: #f8f8f8 !important;
        color: #096 !important;
    }

    /* Menu item with submenu - arrow indicator */
    .nav-menu > ul > li.has-submenu > a {
        position: relative;
        padding-right: 45px !important;
    }

    .nav-menu > ul > li.has-submenu > a::after {
        content: '';
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
        width: 8px;
        height: 8px;
        border-right: 2px solid #666;
        border-bottom: 2px solid #666;
        transition: transform 0.3s ease;
    }

    .nav-menu > ul > li.has-submenu.submenu-open > a::after {
        transform: translateY(-50%) rotate(45deg);
    }

    /* Submenu */
    .nav-menu ul ul {
        position: static !important;
        display: none;
        background: #f5f5f5 !important;
        box-shadow: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-menu > ul > li.submenu-open > ul {
        display: block;
        max-height: 500px;
    }

    .nav-menu ul ul li {
        border-bottom: 1px solid #e8e8e8;
    }

    .nav-menu ul ul li:last-child {
        border-bottom: none;
    }

    .nav-menu ul ul li a {
        padding: 14px 20px 14px 40px !important;
        font-size: 14px !important;
        color: #555 !important;
        display: block;
        transition: all 0.2s ease;
    }

    .nav-menu ul ul li a::before {
        content: '›';
        margin-right: 8px;
        color: #096;
        font-weight: bold;
    }

    .nav-menu ul ul li a:hover {
        color: #096 !important;
        background: #eee !important;
        padding-left: 45px !important;
    }

    /* Overlay when menu is open */
    .is-menu-toggled-on::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
    }

    /* Prevent body scroll when menu open */
    .is-menu-toggled-on {
        overflow: hidden !important;
    }

    .is-menu-toggled-on body {
        overflow: hidden !important;
    }

    /* ---- CONTENT AREA ---- */
    .site-main {
        padding: 20px 0;
    }

    .layout-medium,
    .layout-fixed {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Entry header */
    .entry-header .entry-title {
        font-size: 22px !important;
        line-height: 1.3;
    }

    /* Single column for posts */
    .masonry,
    .blog-masonry {
        display: block !important;
    }

    .masonry .hentry,
    .blog-masonry .hentry {
        width: 100% !important;
        float: none !important;
        margin-bottom: 25px;
    }

    .hentry .featured-image {
        margin-bottom: 15px;
    }

    .hentry .featured-image img {
        width: 100%;
        height: auto;
        border-radius: 8px;
    }

    .hentry .entry-title {
        font-size: 20px !important;
        line-height: 1.35;
    }

    .hentry .entry-content {
        font-size: 15px;
        line-height: 1.7;
    }

    .hentry .entry-content .more-link {
        display: inline-block;
        margin-top: 15px;
        padding: 12px 25px;
        background: #096;
        color: #fff !important;
        border-radius: 5px;
        text-decoration: none;
        font-size: 14px;
    }

    /* ---- SINGLE POST ---- */
    article.hentry.post .entry-title {
        font-size: 24px !important;
        line-height: 1.3;
    }

    article.hentry.post .featured-image {
        margin-left: -15px;
        margin-right: -15px;
    }

    article.hentry.post .featured-image img {
        border-radius: 0;
    }

    article.hentry.post .entry-content {
        font-size: 16px;
        line-height: 1.8;
    }

    /* Share links */
    .share-links {
        text-align: center;
        padding: 20px 0;
    }

    .share-links a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 45px;
        height: 45px;
        margin: 5px;
        border-radius: 50%;
        background: #f5f5f5;
        font-size: 16px;
    }

    /* Post navigation */
    .nav-single .row {
        display: block;
    }

    .nav-single .col-sm-6 {
        width: 100%;
        float: none;
        margin-bottom: 20px;
    }

    /* Related posts - You May Also Like */
    .yarpp-related {
        margin-top: 30px !important;
        padding-top: 25px !important;
    }

    .yarpp-related h3 {
        font-size: 13px !important;
        margin-bottom: 20px !important;
    }

    .yarpp-thumbnails-horizontal {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .yarpp-thumbnail {
        display: flex !important;
        flex-direction: row !important;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 10px rgba(0,0,0,0.08);
        text-decoration: none;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .yarpp-thumbnail:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    }

    .yarpp-thumbnail .yarpp-thumbnail-default,
    .yarpp-thumbnail > span:first-child {
        width: 110px !important;
        min-width: 110px !important;
        flex-shrink: 0;
    }

    .yarpp-thumbnail .yarpp-thumbnail-default img,
    .yarpp-thumbnail > span:first-child img {
        width: 110px !important;
        height: 85px !important;
        object-fit: cover;
        display: block;
    }

    .yarpp-thumbnail-title {
        padding: 12px 15px !important;
        font-size: 14px !important;
        color: #333 !important;
        font-weight: 500;
        line-height: 1.4;
        display: flex !important;
        align-items: center;
        flex-grow: 1;
    }

    /* ---- FOOTER ---- */
    .site-footer {
        padding: 25px 0;
    }

    .footer-social ul.social {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
        margin: 0;
        list-style: none;
    }

    .footer-social ul.social li {
        margin: 0;
    }

    .footer-social ul.social li a {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .site-info {
        padding: 15px;
        text-align: center;
    }

    .site-info p {
        font-size: 12px;
        margin: 0;
    }

    /* ---- PAGINATION ---- */
    .pagination .nav-links {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .pagination .page-numbers {
        padding: 10px 15px;
        font-size: 14px;
    }

    /* ---- DOWNLOAD BUTTON ---- */
    .download-section {
        margin: 25px -15px;
        padding: 20px 15px;
        border-radius: 0;
    }

    .download-btn {
        display: block;
        width: 100%;
        text-align: center;
        padding: 16px 20px;
    }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media screen and (max-width: 480px) {

    .social-container .logo img {
        height: 24px;
    }

    .layout-medium,
    .layout-fixed {
        padding-left: 12px;
        padding-right: 12px;
    }

    .entry-header .entry-title {
        font-size: 20px !important;
    }

    .hentry .entry-title {
        font-size: 18px !important;
    }

    article.hentry.post .entry-title {
        font-size: 22px !important;
    }

    article.hentry.post .entry-content {
        font-size: 15px;
    }

    .pagination .page-numbers {
        padding: 8px 12px;
        font-size: 13px;
    }

    .share-links a {
        width: 40px;
        height: 40px;
        margin: 3px;
    }
}

/* ============================================
   BOOKS PAGE - MOBILE
   ============================================ */
@media screen and (max-width: 768px) {
    .bookshelf {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .bookshelf figure {
        width: 100% !important;
        margin: 0 !important;
    }
}

@media screen and (max-width: 480px) {
    .bookshelf {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   GALLERY PAGE - MOBILE
   ============================================ */
@media screen and (max-width: 768px) {
    .r-gallery,
    .gallery {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .r-gallery figure,
    .gallery figure {
        width: 100% !important;
        margin: 0 !important;
    }

    .r-gallery figure img,
    .gallery figure img {
        width: 100%;
        height: auto;
        border-radius: 6px;
    }
}

/* ============================================
   ABOUT PAGE - MOBILE
   ============================================ */
@media screen and (max-width: 768px) {
    .about-image {
        width: 180px !important;
        height: 180px !important;
    }

    .section-title.center {
        font-size: 22px !important;
    }
}

@media screen and (max-width: 480px) {
    .about-image {
        width: 150px !important;
        height: 150px !important;
    }

    .section-title.center {
        font-size: 20px !important;
    }
}
