/*
Theme Name:  MH Magazine Lite Child
Theme URI:   https://mhthemes.com/
Description: Child theme nâng cao cho MH Magazine Lite — hỗ trợ tuỳ chỉnh font, màu sắc, bố cục, sidebar, nội dung bài viết, dark mode, thanh tiến trình đọc, nút back-to-top, breaking news ticker, custom CSS và nhiều tính năng khác.
Author:      Your Name
Author URI:  https://yourwebsite.com/
Template:    mh-magazine-lite
Version:     1.0.0
License:     GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: mh-magazine-lite-child
*/

/* =====================================================================
   CSS VARIABLES — được ghi đè bởi Customizer
   ===================================================================== */
:root {
    --mhc-primary-color:       #c0392b;
    --mhc-secondary-color:     #2c3e50;
    --mhc-accent-color:        #e74c3c;
    --mhc-link-color:          #c0392b;
    --mhc-link-hover-color:    #e74c3c;

    --mhc-body-bg:             #f7f7f7;
    --mhc-content-bg:          #ffffff;
    --mhc-sidebar-bg:          #ffffff;
    --mhc-header-bg:           #222222;
    --mhc-footer-bg:           #1a1a1a;

    --mhc-body-text-color:     #333333;
    --mhc-heading-color:       #1a1a1a;
    --mhc-meta-color:          #888888;

    --mhc-body-font:           'Open Sans', sans-serif;
    --mhc-heading-font:        'Montserrat', sans-serif;
    --mhc-body-font-size:      15px;
    --mhc-body-line-height:    1.7;

    --mhc-site-width:          1080px;
    --mhc-sidebar-width:       300px;
    --mhc-content-padding:     30px;
    --mhc-border-radius:       4px;
    --mhc-box-shadow:          0 2px 8px rgba(0,0,0,0.08);
}

/* =====================================================================
   DARK MODE VARIABLES
   ===================================================================== */
body.mhc-dark-mode {
    --mhc-body-bg:         #121212;
    --mhc-content-bg:      #1e1e1e;
    --mhc-sidebar-bg:      #1e1e1e;
    --mhc-header-bg:       #0d0d0d;
    --mhc-footer-bg:       #0a0a0a;
    --mhc-body-text-color: #e0e0e0;
    --mhc-heading-color:   #ffffff;
    --mhc-meta-color:      #aaaaaa;
    --mhc-box-shadow:      0 2px 8px rgba(0,0,0,0.4);
}

/* =====================================================================
   BASE RESET & TYPOGRAPHY
   ===================================================================== */
body {
    font-family: var(--mhc-body-font);
    font-size:   var(--mhc-body-font-size);
    line-height: var(--mhc-body-line-height);
    color:       var(--mhc-body-text-color);
    background:  var(--mhc-body-bg);
    transition:  background 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--mhc-heading-font);
    color:       var(--mhc-heading-color);
    line-height: 1.3;
}

a { color: var(--mhc-link-color); transition: color 0.2s; }
a:hover { color: var(--mhc-link-hover-color); }

/* =====================================================================
   SITE-WIDE LAYOUT
   ===================================================================== */
#mh-wrapper,
.mh-container {
    max-width: var(--mhc-site-width);
}

#mh-content {
    background: var(--mhc-content-bg);
    border-radius: var(--mhc-border-radius);
    box-shadow: var(--mhc-box-shadow);
    padding: var(--mhc-content-padding);
    transition: background 0.3s ease;
}

/* =====================================================================
   HEADER
   ===================================================================== */
#mh-head {
    background: var(--mhc-header-bg);
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */
#mh-sidebar {
    background: var(--mhc-sidebar-bg);
    border-radius: var(--mhc-border-radius);
    box-shadow: var(--mhc-box-shadow);
    transition: background 0.3s ease;
}

/* =====================================================================
   POST / ARTICLE CONTENT
   ===================================================================== */
.mh-entry-title a {
    font-family: var(--mhc-heading-font);
    color:       var(--mhc-heading-color);
}
.mh-entry-title a:hover {
    color: var(--mhc-primary-color);
}

.mh-meta, .mh-meta a {
    color: var(--mhc-meta-color);
}

.entry-content {
    font-size: var(--mhc-body-font-size);
    line-height: var(--mhc-body-line-height);
    color: var(--mhc-body-text-color);
}

.entry-content p {
    margin-bottom: 1.3em;
}

.entry-content img {
    border-radius: var(--mhc-border-radius);
    max-width: 100%;
    height: auto;
}

/* =====================================================================
   DARK MODE — general overrides
   ===================================================================== */
body.mhc-dark-mode #mh-wrapper,
body.mhc-dark-mode .mh-article,
body.mhc-dark-mode .widget {
    background: var(--mhc-content-bg);
    color:      var(--mhc-body-text-color);
}

body.mhc-dark-mode input,
body.mhc-dark-mode textarea,
body.mhc-dark-mode select {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

/* =====================================================================
   READING PROGRESS BAR
   ===================================================================== */
#mhc-reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: var(--mhc-primary-color);
    z-index: 99999;
    transition: width 0.1s linear;
}

/* =====================================================================
   BACK TO TOP BUTTON
   ===================================================================== */
#mhc-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: var(--mhc-primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    z-index: 9999;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
#mhc-back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}
#mhc-back-to-top:hover {
    background: var(--mhc-accent-color);
}

/* =====================================================================
   DARK MODE TOGGLE
   ===================================================================== */
#mhc-dark-toggle {
    position: fixed;
    bottom: 30px;
    right: 84px;
    width: 44px;
    height: 44px;
    background: var(--mhc-secondary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: background 0.2s;
}
#mhc-dark-toggle:hover {
    background: var(--mhc-primary-color);
}

/* =====================================================================
   BREAKING NEWS TICKER
   ===================================================================== */
#mhc-ticker {
    background: var(--mhc-primary-color);
    color: #fff;
    padding: 8px 0;
    overflow: hidden;
    display: flex;
    align-items: center;
}
#mhc-ticker .mhc-ticker-label {
    background: var(--mhc-secondary-color);
    padding: 0 15px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    height: 100%;
    display: flex;
    align-items: center;
    min-height: 30px;
    flex-shrink: 0;
}
#mhc-ticker .mhc-ticker-wrap {
    overflow: hidden;
    flex: 1;
    position: relative;
}
#mhc-ticker .mhc-ticker-items {
    display: flex;
    animation: mhc-ticker-scroll 30s linear infinite;
    white-space: nowrap;
}
#mhc-ticker .mhc-ticker-items a {
    color: #fff;
    text-decoration: none;
    padding: 0 30px;
    font-size: 13px;
}
#mhc-ticker .mhc-ticker-items a:hover {
    text-decoration: underline;
}
#mhc-ticker:hover .mhc-ticker-items {
    animation-play-state: paused;
}
@keyframes mhc-ticker-scroll {
    0%   { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* =====================================================================
   STICKY HEADER
   ===================================================================== */
body.mhc-sticky-header #mh-head {
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: box-shadow 0.3s;
}

/* =====================================================================
   CUSTOM BUTTON STYLES
   ===================================================================== */
.mhc-btn,
.mh-pagination a,
input[type="submit"] {
    background: var(--mhc-primary-color);
    color: #fff;
    border-radius: var(--mhc-border-radius);
    border: none;
    transition: background 0.2s;
}
.mhc-btn:hover,
.mh-pagination a:hover,
input[type="submit"]:hover {
    background: var(--mhc-accent-color);
    color: #fff;
}

/* =====================================================================
   FIX THUMBNAIL ĐỒNG ĐỀU TRÊN TRANG DANH SÁCH BÀI VIẾT
   ===================================================================== */

/* Cố định chiều cao figure chứa ảnh */
.mh-loop-thumb {
    width: 220px;
    height: 145px;        /* Tỉ lệ 3:2 — đổi số này nếu muốn cao/thấp hơn */
    flex-shrink: 0;
    overflow: hidden;
    border-radius: var(--mhc-border-radius, 3px);
}

/* Ảnh fill đều, không bị méo */
.mh-loop-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;  /* crop từ trên xuống, giữ phần trên ảnh */
    display: block;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 768px) {
    :root {
        --mhc-body-font-size: 14px;
        --mhc-content-padding: 15px;
    }

    /* Tablet: thu nhỏ thumbnail cho vừa màn hình */
    .mh-loop-thumb {
        width: 130px  !important;
        max-width: 130px !important;
        height: 90px  !important;   /* giữ tỉ lệ ~3:2 */
        flex-shrink: 0;
        overflow: hidden;
    }
    .mh-loop-thumb img {
        width:        100% !important;
        height:       100% !important;
        object-fit:   cover !important;
        object-position: center center !important;
    }
    #mhc-back-to-top  { bottom: 15px; right: 15px; }
    #mhc-dark-toggle  { bottom: 15px; right: 65px; }
}

/* =====================================================================
   FIX ẢNH FEATURED IMAGE TRONG BÀI VIẾT — hiển thị sắc nét, đúng tỉ lệ
   ===================================================================== */

/* Đảm bảo ảnh featured không bị méo, không bị mờ do stretch */
.entry-thumbnail {
    overflow: hidden;
    line-height: 0;           /* Xoá khoảng trắng dưới ảnh */
    margin-bottom: 20px;
    border-radius: var(--mhc-border-radius, 4px);
}

.entry-thumbnail img {
    width: 100%;
    height: auto;             /* Giữ đúng tỉ lệ ảnh gốc, không méo */
    display: block;
    max-width: 100%;
    /* Trình duyệt dùng thuật toán tốt nhất khi render ảnh */
    image-rendering: auto;
}

/* Caption dưới ảnh */
.entry-thumbnail figcaption.wp-caption-text {
    font-size: 13px;
    color: #1a1a1a;
    text-align: center;
    padding: 6px 0;
    line-height: 1.5;
    font-weight: 600; /* ← thêm dòng này cho chữ đậm hơn */
}

/* Căn giữa chú thích ảnh trong bài viết */
.entry-content .wp-caption-text,
.entry-content figcaption {
    text-align: center;
}

/* Mobile nhỏ (≤620px) — khớp breakpoint của main theme
   Main theme set max-width:80px lên .mh-loop-thumb nhưng không đặt height
   → height:145px của child bị giữ nguyên → ảnh thành hình dọc (dài).
   Fix: override cả width + height để giữ đúng tỉ lệ ngang. */
@media screen and (max-width: 620px) {
    .mh-loop-thumb {
        width:       80px !important;
        max-width:   80px !important;
        height:      60px !important;   /* 80×0.75 → tỉ lệ 4:3, trông gọn */
        flex-shrink: 0;
        overflow:    hidden;
    }
    .mh-loop-thumb img {
        width:           100% !important;
        height:          100% !important;
        object-fit:      cover !important;
        object-position: center center !important;
        max-width:       none !important; /* bỏ max-width:235px từ main theme */
    }
}
