/* ==========================================================================
   Horizontal Scroll News - Frontend Slider
   ========================================================================== */

.hsn-wrapper {
    --hsn-accent: #e63312;
    --hsn-title-color: #111111;
    --hsn-card-bg: #ffffff;
    --hsn-text-color: #444444;
    --hsn-cat-bg: #e63312;
    --hsn-cat-color: #ffffff;
    --hsn-arrow-bg: #e63312;
    --hsn-arrow-color: #ffffff;
    --hsn-card-width: 280px;
    --hsn-card-height: 200px;
    --hsn-radius: 8px;
    --hsn-gap: 16px;
    --hsn-title-size: 26px;
    --hsn-title-weight: 800;
    --hsn-card-title-size: 16px;
    --hsn-card-title-weight: 700;
    --hsn-excerpt-size: 13px;
    --hsn-section-title-font: Georgia, "Times New Roman", serif;
    --hsn-card-title-font: Georgia, "Times New Roman", serif;
    --hsn-excerpt-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --hsn-title-transform: none;
    --hsn-title-align: left;
    --hsn-title-justify: flex-start;
    --hsn-card-title-align: left;

    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 28px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    box-sizing: border-box;
}

.hsn-wrapper * {
    box-sizing: border-box;
}

/* ---------- Section header ---------- */
.hsn-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    border-bottom: 2px solid #ededed;
    padding-bottom: 12px;
    position: relative;
}

.hsn-section-header::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 64px;
    height: 3px;
    background: var(--hsn-accent);
}

.hsn-section-header.hsn-title-centered,
.hsn-section-header.hsn-title-right {
    justify-content: center;
}

.hsn-section-header.hsn-title-centered .hsn-nav-buttons,
.hsn-section-header.hsn-title-right .hsn-nav-buttons {
    order: 3;
    flex-basis: 100%;
    justify-content: center;
}

.hsn-section-title {
    font-size: var(--hsn-title-size);
    font-weight: var(--hsn-title-weight);
    text-transform: var(--hsn-title-transform);
    text-align: var(--hsn-title-align);
    color: var(--hsn-title-color);
    margin: 0;
    line-height: 1.1;
    font-family: var(--hsn-section-title-font);
    display: flex;
    align-items: baseline;
    justify-content: var(--hsn-title-justify);
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hsn-title-icon {
    color: var(--hsn-accent);
    font-size: 20px;
    font-weight: 900;
    font-family: -apple-system, sans-serif;
}

.hsn-section-header::after {
    content: none;
}

/* underline accent alignment variants */
.hsn-section-header.hsn-title-centered::before {
    left: 50%;
    transform: translateX(-50%);
}

.hsn-section-header.hsn-title-right::before {
    left: auto;
    right: 0;
}

/* ---------- Nav buttons ---------- */
.hsn-nav-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.hsn-nav-standalone {
    position: absolute;
    top: -46px;
    right: 0;
}

.hsn-prev, .hsn-next {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hsn-arrow-bg);
    color: var(--hsn-arrow-color);
    border: none;
    cursor: pointer;
    transition: all .18s ease;
    padding: 0;
}

.hsn-arrow-circle { border-radius: 50%; }
.hsn-arrow-square { border-radius: 6px; }
.hsn-arrow-minimal {
    background: transparent !important;
    color: var(--hsn-arrow-bg) !important;
    border: 1.5px solid var(--hsn-arrow-bg);
    border-radius: 50%;
}

.hsn-prev:hover, .hsn-next:hover {
    opacity: 0.85;
    transform: scale(1.06);
}

.hsn-prev:disabled, .hsn-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.hsn-prev svg, .hsn-next svg {
    pointer-events: none;
}

/* ---------- Track ---------- */
.hsn-track-container {
    overflow: hidden;
    position: relative;
    width: 100%;
}

.hsn-track {
    display: flex;
    gap: var(--hsn-gap);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px 4px 16px 4px;
}

.hsn-track::-webkit-scrollbar {
    display: none;
}

/* ---------- Cards ---------- */
.hsn-card {
    flex: 0 0 var(--hsn-card-width);
    width: var(--hsn-card-width);
    max-width: 88vw;
    background: var(--hsn-card-bg);
    border-radius: var(--hsn-radius);
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
}

.hsn-card.hsn-shadow {
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.hsn-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.hsn-card-image {
    position: relative;
    width: 100%;
    height: var(--hsn-card-height);
    background-size: cover;
    background-position: center;
    background-color: #eee;
    overflow: hidden;
    border-radius: var(--hsn-radius) var(--hsn-radius) 0 0;
}

/* No-JS fallback: lazy images without JS still get their bg via inline data attr through CSS attr() is not supported for url(), so we rely on .hsn-loaded toggling. If JS never runs, .hsn-skeleton shimmer remains visible which is an acceptable degrade. */

.hsn-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,0.35) 100%);
}

.hsn-cat-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--hsn-cat-bg);
    color: var(--hsn-cat-color);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 4px 10px;
    border-radius: var(--hsn-std-badge-radius, 4px);
    z-index: 2;
}

.hsn-photo-icon {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.92);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    z-index: 2;
}

.hsn-card-body {
    padding: var(--hsn-std-card-padding, 14px) var(--hsn-std-card-padding, 14px) calc(var(--hsn-std-card-padding, 14px) + 2px);
}

.hsn-card-title {
    font-family: var(--hsn-card-title-font);
    font-size: var(--hsn-card-title-size);
    font-weight: var(--hsn-card-title-weight);
    text-align: var(--hsn-card-title-align);
    line-height: 1.32;
    color: #1a1a1a;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: var(--hsn-std-title-lines, 3);
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hsn-card-excerpt {
    font-family: var(--hsn-excerpt-font);
    font-size: var(--hsn-excerpt-size);
    line-height: 1.5;
    color: var(--hsn-text-color);
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: var(--hsn-std-excerpt-lines, 2);
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hsn-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.hsn-meta-date, .hsn-meta-author {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--hsn-std-meta-size, 11px);
    color: var(--hsn-std-meta-color, #999);
    font-weight: 500;
}

.hsn-read-more {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--hsn-std-read-more-color, var(--hsn-accent));
    text-decoration: none;
}

/* ---------- Hover effects ---------- */
.hsn-hover-lift .hsn-card:hover {
    transform: translateY(-6px);
}
.hsn-hover-lift .hsn-card.hsn-shadow:hover {
    box-shadow: 0 14px 28px rgba(0,0,0,0.14);
}

.hsn-hover-zoom .hsn-card-image {
    transition: background-size .35s ease;
}
.hsn-hover-zoom .hsn-card:hover .hsn-card-image {
    background-size: 112%;
}

.hsn-hover-glow .hsn-card {
    border: 2px solid transparent;
    transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.hsn-hover-glow .hsn-card:hover {
    border-color: var(--hsn-accent);
    box-shadow: 0 0 0 4px rgba(0,0,0,0.08);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--hsn-accent) 18%, transparent);
}

.hsn-hover-none .hsn-card:hover {
    transform: none;
}

/* ---------- Dots ---------- */
.hsn-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}
.hsn-dots .hsn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d8d8d8;
    cursor: pointer;
    transition: all .2s;
}
.hsn-dots .hsn-dot.active {
    background: var(--hsn-accent);
    width: 18px;
    border-radius: 4px;
}

/* ---------- No posts ---------- */
.hsn-no-posts {
    text-align: center;
    color: #999;
    padding: 30px;
    font-style: italic;
}

/* ==========================================================================
   Loading Skeleton
   ========================================================================== */

.hsn-card-image.hsn-skeleton {
    background-image: none !important;
    background-color: #e8e8ec;
    background-image: linear-gradient(90deg, #e8e8ec 25%, #f3f3f6 37%, #e8e8ec 63%);
    background-size: 400% 100%;
    animation: hsnSkeletonShimmer 1.4s ease infinite;
}

.hsn-card-image.hsn-skeleton.hsn-loaded {
    animation: none;
    background-image: none;
}

@keyframes hsnSkeletonShimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ==========================================================================
   Fade-in entrance animation
   ========================================================================== */

@supports (animation: hsnCardFadeIn 1s) {
    .hsn-fade-in .hsn-card {
        opacity: 0;
        transform: translateY(14px);
        animation: hsnCardFadeIn .5s ease forwards;
    }

    .hsn-fade-in .hsn-card:nth-child(1) { animation-delay: .03s; }
    .hsn-fade-in .hsn-card:nth-child(2) { animation-delay: .08s; }
    .hsn-fade-in .hsn-card:nth-child(3) { animation-delay: .13s; }
    .hsn-fade-in .hsn-card:nth-child(4) { animation-delay: .18s; }
    .hsn-fade-in .hsn-card:nth-child(5) { animation-delay: .23s; }
    .hsn-fade-in .hsn-card:nth-child(6) { animation-delay: .28s; }
    .hsn-fade-in .hsn-card:nth-child(n+7) { animation-delay: .32s; }
}

@keyframes hsnCardFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Sticky slider
   ========================================================================== */

.hsn-wrapper.hsn-is-sticky {
    transition: box-shadow .25s ease;
}

.hsn-wrapper.hsn-is-sticky.hsn-stuck {
    background: var(--hsn-card-bg);
    padding-top: 8px;
    padding-bottom: 8px;
}

.hsn-wrapper.hsn-is-sticky.hsn-stuck.hsn-sticky-shadow-on {
    box-shadow: 0 6px 18px rgba(0,0,0,0.10);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .hsn-section-title {
        font-size: clamp(17px, calc(var(--hsn-title-size) * 0.78), var(--hsn-title-size));
    }
    .hsn-prev, .hsn-next {
        width: 32px;
        height: 32px;
    }
    .hsn-card-title {
        font-size: clamp(13px, calc(var(--hsn-card-title-size) * 0.9), var(--hsn-card-title-size));
    }
    .hsn-nav-standalone {
        top: -42px;
    }
}

@media (max-width: 480px) {
    .hsn-wrapper {
        margin: 20px 0;
    }
    .hsn-section-title {
        font-size: clamp(16px, calc(var(--hsn-title-size) * 0.7), var(--hsn-title-size));
    }
    .hsn-card-body {
        padding: 11px 12px 13px;
    }
    .hsn-card-excerpt {
        display: none;
    }
}

@media (max-width: 360px) {
    .hsn-card-image {
        height: clamp(120px, calc(var(--hsn-card-height) * 0.75), var(--hsn-card-height));
    }
    .hsn-prev, .hsn-next {
        width: 28px;
        height: 28px;
    }
    .hsn-nav-standalone {
        top: -38px;
    }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .hsn-track {
        scroll-behavior: auto;
    }
    .hsn-card {
        transition: none;
    }
    .hsn-fade-in .hsn-card {
        animation: none;
        opacity: 1;
        transform: none;
    }
    .hsn-card-image.hsn-skeleton {
        animation: none;
    }
}

/* ==========================================================================
   Compact Card Style — India Today / 2-column image-title style
   All values driven by --hsn-compact-* CSS custom properties from slider.php
   ========================================================================== */

.hsn-style-compact .hsn-card {
    background: var(--hsn-card-bg);
    border-radius: var(--hsn-radius, 0px);
    box-shadow: none;
}
.hsn-style-compact .hsn-card.hsn-shadow {
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

/* Compact: hide overlay, excerpt, read-more, photo-icon by default.
   Badge & date are PHP-toggled so they render only when admin enables them —
   these CSS rules act as a safety net for any edge case. */
.hsn-style-compact .hsn-card-overlay  { display: none; }
.hsn-style-compact .hsn-card-excerpt  { display: none; }
.hsn-style-compact .hsn-read-more     { display: none; }
.hsn-style-compact .hsn-photo-icon    { display: none; }

/* .hsn-card-meta itself stays hidden by default (compact's minimal design),
   but becomes visible whenever it actually contains date, author, or
   reading-time content — those are individually PHP-gated by their own
   toggles. slider.php adds .hsn-meta-has-content when there's something to
   show; the :has() rule is a defensive fallback for any other markup path. */
.hsn-style-compact .hsn-card-meta { display: none; }
.hsn-style-compact .hsn-card-meta.hsn-meta-has-content { display: flex; }
.hsn-style-compact .hsn-card-meta:has(.hsn-meta-date, .hsn-meta-author, .hsn-meta-reading-time) {
    display: flex;
}

/* When compact badge IS enabled (PHP prints it), make it show */
.hsn-style-compact .hsn-cat-badge {
    display: inline-block;
    border-radius: var(--hsn-compact-badge-radius, 4px);
}

/* Compact date — shown inside card-body, not card-meta row */
.hsn-style-compact .hsn-compact-date {
    display: block;
    font-size: 11px;
    color: var(--hsn-std-meta-color, #999);
    margin-top: 4px;
}

/* Image height + object-fit + background + hover transition */
.hsn-style-compact .hsn-card-image {
    height: var(--hsn-compact-image-height, 200px);
    border-radius: var(--hsn-radius, 0px) var(--hsn-radius, 0px) 0 0;
    background-size: var(--hsn-cs-bg-size, cover);
    background-color: transparent;
    transition: transform .35s ease;
    overflow: hidden;
    display: block;
}

/* Card body padding controlled by admin */
.hsn-style-compact .hsn-card-body {
    padding: var(--hsn-compact-title-padding, 10px) var(--hsn-compact-title-padding, 10px) calc(var(--hsn-compact-title-padding, 10px) - 2px);
}

/* Title — font-size and line-clamp controlled by admin */
.hsn-style-compact .hsn-card-title {
    font-size: var(--hsn-compact-title-size, 15px);
    font-weight: var(--hsn-card-title-weight, 700);
    font-family: var(--hsn-card-title-font);
    line-height: 1.32;
    color: var(--hsn-title-color, #1a1a1a);
    display: -webkit-box;
    -webkit-line-clamp: var(--hsn-compact-title-lines, 3);
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* ==========================================================================
   Compact Scroll — Thumbnail & Smooth Scroll admin controls
   All values driven by --hsn-cs-* CSS custom properties from slider.php
   Zero Touch: only .hsn-style-compact scoped rules below
   ========================================================================== */

/* Cards visible at once — overrides fixed card-width when set */
.hsn-style-compact .hsn-track {
    -webkit-overflow-scrolling: touch;
}

/* Show/hide scrollbar (toggled by JS adding class) */
.hsn-style-compact.hsn-cs-hide-scrollbar .hsn-track::-webkit-scrollbar { display: none; }
.hsn-style-compact.hsn-cs-hide-scrollbar .hsn-track {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Aspect ratio modes (overrides fixed height when not custom) */
.hsn-style-compact[data-cs-aspect-ratio="1:1"] .hsn-card-image {
    height: 0;
    padding-bottom: 100%;
}
.hsn-style-compact[data-cs-aspect-ratio="4:3"] .hsn-card-image {
    height: 0;
    padding-bottom: 75%;
}
.hsn-style-compact[data-cs-aspect-ratio="16:9"] .hsn-card-image {
    height: 0;
    padding-bottom: 56.25%;
}

/* Hover zoom — strength controlled by --hsn-cs-zoom */
.hsn-style-compact.hsn-cs-zoom-on .hsn-card:hover .hsn-card-image {
    transform: scale(calc(var(--hsn-cs-zoom, 108) / 100));
}

/* Responsive: cards per view driven by --hsn-cs-cards-* */
@media (min-width: 900px) {
    .hsn-style-compact .hsn-card {
        flex: 0 0 calc((100% - (var(--hsn-cs-cards-desktop, 2) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-desktop, 2));
        width: calc((100% - (var(--hsn-cs-cards-desktop, 2) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-desktop, 2));
    }
}
@media (min-width: 600px) and (max-width: 899px) {
    .hsn-style-compact .hsn-card {
        flex: 0 0 calc((100% - (var(--hsn-cs-cards-tablet, 2) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-tablet, 2));
        width: calc((100% - (var(--hsn-cs-cards-tablet, 2) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-tablet, 2));
    }
}
@media (max-width: 599px) {
    .hsn-style-compact .hsn-card {
        flex: 0 0 calc((100% - (var(--hsn-cs-cards-mobile, 1) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-mobile, 1));
        width: calc((100% - (var(--hsn-cs-cards-mobile, 1) - 1) * var(--hsn-gap, 12px)) / var(--hsn-cs-cards-mobile, 1));
    }
}

/* ==========================================================================
   Reading Time & "NEW" Freshness Badge — new in 3.4.0, opt-in, default OFF
   Applies to Horizontal Scroll and Compact Scroll (both use this stylesheet)
   ========================================================================== */

.hsn-fresh-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    border-radius: 4px;
    line-height: 1;
    text-transform: uppercase;
    z-index: 2;
}

.hsn-meta-reading-time {
    font-size: 11px;
    color: #999;
    font-weight: 500;
}
