/* ================================
   Baro News Magazine – Fluid Responsive
   ================================ */

/* Design tokens */
:root{
    --baro-gap: clamp(14px, 1.8vw, 25px);
    --baro-radius-lg: 12px;
    --baro-radius-md: 10px;
    --baro-shadow-1: 0 4px 20px rgba(0,0,0,0.08);
    --baro-shadow-2: 0 8px 30px rgba(0,0,0,0.12);
    --baro-shadow-sm: 0 2px 15px rgba(0,0,0,0.06);
    --baro-border: 1px solid rgba(0,0,0,0.05);
    --baro-primary: #3498db;
    --baro-overlay: linear-gradient(180deg, rgba(19,50,86,0) 35.67%, #38a749 100%);
    --baro-text: #2c3e50;
    --baro-muted: #666;
  }
  
  /* Root layout - 3 cột với feature chiếm 2x2 */
  .baro-news-magazine{
    display:grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: var(--baro-gap);
    margin: clamp(12px,2.2vw,20px) 0;
    font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  }
  
  /* Empty state */
  .baro-empty{
    text-align:center;
    padding: clamp(24px,4vw,40px) clamp(16px,3vw,20px);
    background: linear-gradient(135deg,#f5f7fa 0%,#c3cfe2 100%);
    color:#666;
  }
  
  /* Cards */
  .baro-featured,
  .baro-side-item,
  .baro-grid-item{
    position:relative;
    overflow:hidden;
    transition: transform .3s ease, box-shadow .3s ease;
    will-change: transform;
  }
  
  .baro-featured{
    grid-column: 1 / 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  
  .baro-featured > a{
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
  }
  
  .baro-featured:hover{ transform: translateY(-2px); box-shadow: var(--baro-shadow-2); }
  .baro-side-item:hover,
  .baro-grid-item:hover{ transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
  
  /* Images (stable ratios) */
  .baro-featured .baro-post-image,
  .baro-side-item .baro-post-image,
  .baro-grid-item .baro-post-image{
    position:relative;
    overflow:hidden;
  }
  
  /* Featured: fill full height, remove aspect-ratio constraint */
  .baro-featured .baro-post-image{
    flex: 1;
    min-height: 0;
    width: 100%;
  }


  
  .baro-side-item .baro-post-image{ aspect-ratio: 16/9; }
  .baro-grid-item .baro-post-image{ aspect-ratio: 16/10; }
  
  .baro-featured .baro-post-image img,
  .baro-side-item .baro-post-image img,
  .baro-grid-item .baro-post-image img{
    width:100%;
    height:100%;
    object-fit:cover;
    transform: translateZ(0);
    transition: transform .3s ease;
  }
  .baro-featured:hover .baro-post-image img,
  .baro-side-item:hover .baro-post-image img,
  .baro-grid-item:hover .baro-post-image img{ transform: scale(1.05); }
  
  /* Overlays */
  .baro-featured .baro-post-image::before{
    content:""; position:absolute; inset:0; background: var(--baro-overlay); z-index:1;
  }
  .baro-side-item .baro-post-image::before{
    content:""; position:absolute; inset:0; background: rgba(0,0,0,.25); z-index:1;
  }
  
  /* Content areas */
  .baro-featured .baro-post-content{
    position:absolute; inset-inline:0; bottom:0; z-index:2;
    padding: clamp(14px,2.8vw,20px);
    color:#fff;
    flex-shrink: 0;
  }
  .baro-side-item .baro-post-content{
    position:absolute; inset-inline:0; bottom:0; z-index:2;
    padding: clamp(12px,2.2vw,16px);
    background: var(--baro-overlay);
    color:#fff;
  }
  .baro-grid-item .baro-post-content{ padding: clamp(12px,2.2vw,16px); }
  
  /* Headings with fluid size */
  .baro-featured h2{
    margin: 0 0 clamp(8px,1vw,12px) 0;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight:700; line-height:1.3; color:#fff;
  }
  .baro-featured h2 a{ color:#fff; text-decoration:none; }
  .baro-featured h2 a:hover{ color:#e8f4ff; }
  
  .baro-side-item h3{
    margin:0 0 6px 0; font-weight:700; line-height:1.32; color:#fff;
    font-size: clamp(16px,1.8vw,22px);
  }
  .baro-side-item h3 a{ color:#fff; text-decoration:none; }
  
  .baro-grid-item h4{
    margin:0 0 6px 0; font-weight:600; line-height:1.32;
    font-size: clamp(14px,1.4vw,16px);
  }
  .baro-grid-item h4 a{
    color: var(--baro-text); text-decoration:none; transition: color .3s ease;
  }
  .baro-grid-item h4 a:hover{ color: var(--baro-primary); }
  
  /* Line clamp helpers */
  .baro-side-item .baro-post-content h3 a{
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow:hidden; text-overflow:ellipsis;
  }
  .baro-excerpt{
    color: var(--baro-muted);
    font-size: clamp(13px,1.2vw,14px);
    line-height:1.55; margin:0 0 12px 0;
  }
  
  /* Meta */
  .baro-eye-icon{ width:15px; height:15px; color:white; }
  .baro-eye-icon.invert {
    filter: invert(1) brightness(2);
  }
  .baro-meta{
    display:flex; align-items:center; gap: clamp(8px,1.5vw,15px);
    font-size: clamp(12px,1.2vw,13px);
    color:#7f8c8d; margin-top:8px; flex-wrap: wrap;
  }
  .baro-date,.baro-views{
    display:flex; align-items:center; gap:4px; font-weight:500;
  }
  .baro-views{
    padding:2px 8px;
  }
  .baro-featured .baro-post-content .baro-meta .baro-date,
  .baro-featured .baro-post-content .baro-meta .baro-views,
  .baro-side .baro-meta,.baro-side .baro-views{ color:#fff; }
  
  /* Side column - nằm ở cột thứ 3 */
  .baro-side{
    grid-column: 3;
    grid-row: 1 / 3;
    display:flex; flex-direction:column; gap: clamp(12px,2vw,20px);
  }
  
  /* Grid list (fluid) - 3 cột bên dưới, bắt đầu từ hàng 3 */
  .baro-grid{
    grid-column: 1 / -1;
    grid-row: 3;
    display:grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(12px,2vw,20px);
    margin-top: clamp(16px,2.2vw,25px);
  }
  
  /* Grid layout for page 2+ */
  .baro-grid-layout{
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: clamp(12px,2vw,20px) !important;
    margin: clamp(12px,2.2vw,20px) 0 !important;
  }
  
  .baro-grid-layout .baro-grid{
    grid-column: unset !important;
    margin-top: 0 !important;
  }
  
  /* Grid items in grid layout should behave as grid items */
  .baro-grid-layout .baro-grid-item{
    display: block;
  }
  
  /* Hover color tweaks */
  .baro-side-item h3 a:hover{ color:#fff; }
  
  /* Loading */
  .baro-loading{
    display:inline-block; width:20px; height:20px;
    border:3px solid rgba(52,152,219,.3); border-radius:50%;
    border-top-color: var(--baro-primary);
    animation: baro-spin 1s ease-in-out infinite;
  }
  @keyframes baro-spin{ to{ transform: rotate(360deg);} }
  
  /* Pagination */
  .baro-pagination{
    text-align: center;
    margin: clamp(20px, 3vw, 30px) 0;
    padding: 0 clamp(16px, 3vw, 20px);
  }
  
  .baro-pagination-wrapper{
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(4px, 0.8vw, 8px);
    flex-wrap: wrap;
  }
  
  .baro-page-link{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(36px, 4vw, 44px);
    height: clamp(36px, 4vw, 44px);
    padding: 0 clamp(8px, 1.2vw, 12px);
    background: #fff;
    color: var(--baro-text);
    text-decoration: none;
    border: 1px solid #e1e8ed;
    font-size: clamp(13px, 1.3vw, 15px);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--baro-shadow-sm);
  }
  
  .baro-page-link:hover:not(.disabled):not(.baro-page-current){
    background: var(--e-global-color-primary);
    color: #fff;
    border-color: var(--e-global-color-primary);
    transform: translateY(-1px);
    box-shadow: var(--baro-shadow-2);
  }
  
  .baro-page-link:active:not(.disabled):not(.baro-page-current){
    transform: translateY(0);
  }
  
  .baro-page-current{
    background: var(--e-global-color-primary);
    color: #fff;
    border-color: var(--e-global-color-primary);
    font-weight: 600;
    cursor: default;
  }
  
  .baro-page-link.disabled{
    background: #f8f9fa;
    color: #adb5bd;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
  }
  
  .baro-page-prev,
  .baro-page-next{
    font-weight: 600;
    min-width: auto;
    padding: 0 clamp(12px, 2vw, 16px);
  }
  
  .baro-page-dots{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: clamp(36px, 4vw, 44px);
    height: clamp(36px, 4vw, 44px);
    color: var(--baro-muted);
    font-size: clamp(13px, 1.3vw, 15px);
    font-weight: 500;
  }
  
  .baro-news-magazine-wrapper.loading{
    opacity: 0.7;
    pointer-events: none;
    position: relative;
  }
  
  .baro-news-magazine-wrapper.loading::after{
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-top-color: var(--baro-primary);
    animation: baro-spin 1s ease-in-out infinite;
    z-index: 1000;
  }
  
  /* ======================
     Responsive breakpoints
     ====================== */
  
  /* <= 1200px: lớn vừa */
  @media (max-width: 1200px){
    .baro-news-magazine{
      grid-template-columns: repeat(3, 1fr);
    }
  }
  
  /* <= 992px: tablet landscape */
  @media (max-width: 992px){
    .baro-news-magazine{
      grid-template-columns: 1fr;  /* stack tất cả */
      grid-template-rows: auto;
    }
    .baro-featured{
      grid-column: 1;
      grid-row: 1;
    }
    .baro-side{
      grid-column: 1;
      grid-row: 2;
      order: 2;
    }
    .baro-grid{
      grid-column: 1;
      grid-row: 3;
      order: 3;
      grid-template-columns: repeat(3, 1fr);
    }
    .baro-grid-layout{
      grid-template-columns: repeat(3, 1fr) !important;
    }
    /* tăng độ tương phản overlay để chữ dễ đọc khi ảnh nhỏ */
    .baro-featured .baro-post-image::before{ background: linear-gradient(180deg, rgba(0,0,0,0) 35%, rgba(0,0,0,.7) 100%); }
  }
  
  /* <= 768px: tablet portrait & mobile lớn */
  @media (max-width: 768px){
    .baro-featured .baro-post-image{ 
      min-height: clamp(200px, 48vw, 360px);
    }
    .baro-meta{ gap: 10px; }
    .baro-grid-layout{
      grid-template-columns: repeat(2, 1fr) !important;
    }
  }
  
  /* <= 576px: mobile phổ biến */
  @media (max-width: 576px){
    .baro-grid{
      grid-template-columns: 1fr;
      gap: 14px;
    }
    .baro-grid-layout{
      grid-template-columns: 1fr !important;
    }
    .baro-featured .baro-post-content,
    .baro-side-item .baro-post-content,
    .baro-grid-item .baro-post-content{
      padding: 12px;
    }
    /* tăng line-clamp để title đỡ dài */
    .baro-side-item .baro-post-content h3 a{ 
      -webkit-line-clamp: 2; 
      line-clamp: 2; 
    }
  }
  
  /* <= 380px: mobile rất nhỏ */
  @media (max-width: 380px){
    .baro-featured h2{ font-size: 17px; }
    .baro-side-item h3{ font-size: 15px; }
    .baro-grid-item h4{ font-size: 14px; }
  }
  
  
  /* Print */
  @media print{
    .baro-news-magazine{ display:block !important; box-shadow:none !important; }
    .baro-featured,.baro-side-item,.baro-grid-item{
      box-shadow:none !important; border:1px solid #ddd !important; break-inside: avoid; margin-bottom:20px;
    }
  }
  
  /* Motion accessibility */
  @media (prefers-reduced-motion: reduce){
    *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  }
  