/**
 * Newsmatic — UI/UX Enhancements
 *
 * Layered on top of main.css — only additive improvements.
 * No color overrides, preserves all existing branding.
 *
 * @package Newsmatic
 * @since   2.0.0
 */

/* =========================================================
   CSS Custom Properties (Enhancement Tokens)
   ========================================================= */

:root {
    --nm-gap:          24px;
    --nm-gap-sm:       16px;
    --nm-gap-lg:       40px;
    --nm-section-gap:  56px;
    --nm-radius:       10px;
    --nm-radius-sm:    6px;
    --nm-radius-pill:  999px;
    --nm-transition:   all 0.28s ease;
    --nm-shadow-sm:    0 1px 4px rgba(0,0,0,.07);
    --nm-shadow-md:    0 4px 16px rgba(0,0,0,.1);
    --nm-shadow-lg:    0 8px 32px rgba(0,0,0,.14);
    --nm-card-bg:      #fff;
}

/* =========================================================
   Typography Refinements
   ========================================================= */

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.entry-title,
.newsmatic-block-title {
    line-height: 1.22 !important;
    letter-spacing: -0.01em;
}

.entry-content p {
    line-height: 1.75;
    margin-bottom: 1.3em;
}

.entry-content h2 { font-size: 1.5rem; margin-top: 2em; }
.entry-content h3 { font-size: 1.25rem; margin-top: 1.75em; }

/* =========================================================
   Post Cards — Polish
   ========================================================= */

.post-inner,
.newsmatic-post-inner,
article.post {
    transition: var(--nm-transition);
}

/* Lift card on hover */
.news-list-wrap .post,
.news-grid-wrap .post,
.newsmatic-posts-wrap .post {
    border-radius: var(--nm-radius);
    overflow: hidden;
    transition: transform 0.28s ease, box-shadow 0.28s ease;
}

.news-list-wrap .post:hover,
.news-grid-wrap .post:hover,
.newsmatic-posts-wrap .post:hover {
    transform: translateY(-3px);
    box-shadow: var(--nm-shadow-lg) !important;
}

/* Thumbnail image zoom */
.post-thumbnail,
.newsmatic-post-thumbnail {
    overflow: hidden;
    border-radius: var(--nm-radius-sm);
}

.post-thumbnail img,
.newsmatic-post-thumbnail img,
.nm-thumb img {
    transition: transform 0.4s ease;
    will-change: transform;
}

.post-thumbnail:hover img,
.newsmatic-post-thumbnail:hover img,
.nm-thumb:hover img {
    transform: scale(1.05);
}

/* =========================================================
   Links & Buttons — Smooth Transitions
   ========================================================= */

a {
    transition: color 0.2s ease, opacity 0.2s ease;
}

.wp-block-button .wp-block-button__link,
button,
input[type="submit"],
.button,
.btn {
    transition: var(--nm-transition) !important;
}

/* =========================================================
   Sticky Header Shrink
   ========================================================= */

#masthead {
    transition: box-shadow 0.3s ease, padding 0.3s ease;
}

#masthead.nm-scrolled {
    box-shadow: 0 2px 12px rgba(0,0,0,.12) !important;
}

/* =========================================================
   Sticky Sidebar (Desktop)
   ========================================================= */

@media (min-width: 1025px) {
    .secondary-sidebar .widget-area,
    .secondary-sidebar > aside {
        position: sticky;
        top: 90px; /* below fixed header */
        max-height: calc(100vh - 110px);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(0,0,0,.15) transparent;
    }

    .secondary-sidebar .widget-area::-webkit-scrollbar {
        width: 4px;
    }
    .secondary-sidebar .widget-area::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,.15);
        border-radius: 4px;
    }
}

/* =========================================================
   Social Share Bar
   ========================================================= */

.nm-social-share {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 28px 0;
    padding: 16px 20px;
    background: rgba(0,0,0,.03);
    border-radius: var(--nm-radius);
    border: 1px solid rgba(0,0,0,.06);
}

.nm-social-share__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.55;
    margin-right: 4px;
}

.nm-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: var(--nm-radius-pill);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: var(--nm-transition);
    white-space: nowrap;
}

.nm-share-btn span {
    line-height: 1;
}

.nm-share-btn--twitter  { background: #000; color: #fff; }
.nm-share-btn--facebook { background: #1877f2; color: #fff; }
.nm-share-btn--whatsapp { background: #25d366; color: #fff; }
.nm-share-btn--linkedin { background: #0a66c2; color: #fff; }
.nm-share-btn--copy     { background: rgba(0,0,0,.08); color: inherit; }

.nm-share-btn:hover {
    opacity: 0.85;
    transform: translateY(-2px);
    box-shadow: var(--nm-shadow-sm);
}

/* Copy success state */
.nm-share-btn--copy.nm-copied {
    background: #16a34a;
    color: #fff;
}

@media (max-width: 480px) {
    .nm-share-btn span { display: none; }
    .nm-share-btn { padding: 8px; border-radius: 50%; }
}

/* =========================================================
   Breadcrumbs — Pill Style
   ========================================================= */

.breadcrumb-trail,
.newsmatic-breadcrumb,
#breadcrumbs {
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}

.breadcrumb-trail a,
.newsmatic-breadcrumb a,
#breadcrumbs a {
    text-decoration: none;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.breadcrumb-trail a:hover,
.newsmatic-breadcrumb a:hover,
#breadcrumbs a:hover {
    opacity: 1;
}

/* =========================================================
   Pagination — Pill Numbered
   ========================================================= */

.page-numbers,
.newsmatic-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    border-radius: var(--nm-radius-pill) !important;
    transition: var(--nm-transition) !important;
    font-weight: 600;
    font-size: 14px;
}

.page-numbers:not(.current):hover {
    transform: translateY(-2px);
    box-shadow: var(--nm-shadow-sm);
}

.newsmatic-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 32px 0;
}

/* =========================================================
   Author Box — Card Style
   ========================================================= */

.author-profile-wrap,
.vcard,
.newsmatic-author-box {
    border-radius: var(--nm-radius) !important;
    overflow: hidden;
    transition: box-shadow 0.28s ease;
}

.author-profile-wrap:hover,
.newsmatic-author-box:hover {
    box-shadow: var(--nm-shadow-md) !important;
}

.author .avatar,
.newsmatic-author-box .avatar {
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,.08);
    transition: transform 0.3s ease;
}

.newsmatic-author-box:hover .avatar {
    transform: scale(1.04);
}

/* =========================================================
   Category / Archive Page — Header
   ========================================================= */

.page-header {
    margin-bottom: 28px;
}

.page-header .page-title {
    margin-bottom: 8px;
}

.archive-description {
    font-size: 15px;
    opacity: 0.7;
    line-height: 1.65;
}

/* =========================================================
   Mobile-First Responsive Improvements
   ========================================================= */

/* Ensure minimum touch target size of 44px on interactive controls only */
button,
[role="button"],
input[type="submit"],
input[type="button"] {
    min-height: 44px;
}

/* Nav menu items: min height for tap targets */
.main-navigation .menu-item > a,
.main-navigation .sub-menu .menu-item > a {
    min-height: 44px;
}

/* Better nav on mobile */
@media (max-width: 768px) {
    /* Prevent horizontal overflow */
    .newsmatic-container,
    .site-content,
    #page {
        overflow-x: hidden;
    }

    /* Larger body text on mobile for readability */
    body {
        font-size: 16px;
    }

    /* Cards: full width on very small screens */
    .news-list-wrap article,
    .news-grid-wrap article {
        margin-bottom: var(--nm-gap-sm);
    }

    /* Entry title sizing */
    h1.entry-title {
        font-size: clamp(1.35rem, 5vw, 2rem);
    }

    h2, h3 {
        font-size: clamp(1.1rem, 4vw, 1.5rem);
    }

    /* Better post spacing */
    .entry-content {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .nm-gap-sm { gap: 12px; }

    .page-header {
        margin-bottom: 20px;
    }
}

/* =========================================================
   Search Form Enhancement
   ========================================================= */

.search-form,
.newsmatic-search-form {
    position: relative;
}

.search-form input[type="search"],
.newsmatic-search-form input[type="search"] {
    border-radius: var(--nm-radius-pill) !important;
    padding-right: 48px !important;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.search-form input[type="search"]:focus,
.newsmatic-search-form input[type="search"]:focus {
    box-shadow: 0 0 0 3px rgba(var(--global-preset-theme-color-rgb, 230,57,70), 0.18) !important;
    outline: none;
}

.search-submit {
    border-radius: var(--nm-radius-pill) !important;
}

/* =========================================================
   Widget Title — Subtle Animation
   ========================================================= */

.widget-title {
    position: relative;
}

/* =========================================================
   Loading Skeleton / Image Lazy Placeholder
   ========================================================= */

img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% auto;
}

/* =========================================================
   Improved Hover Effects on Navigation Menus
   ========================================================= */

.main-navigation ul li a {
    transition: color 0.2s ease;
}

.main-navigation ul ul {
    animation: nmDropdown 0.2s ease;
}

@keyframes nmDropdown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Post Navigation (prev/next) — Better Style
   ========================================================= */

.post-navigation {
    margin: 32px 0;
    padding: 20px;
    border-radius: var(--nm-radius);
    background: rgba(0,0,0,.02);
    border: 1px solid rgba(0,0,0,.06);
}

.post-navigation .nav-links {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.post-navigation a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: var(--nm-radius-sm);
    transition: background 0.2s ease;
    max-width: 45%;
}

.post-navigation a:hover {
    background: rgba(0,0,0,.05);
}

.post-navigation .nav-subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    display: flex;
    align-items: center;
    gap: 4px;
}

.post-navigation .nav-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

/* =========================================================
   Dark Mode Overrides
   ========================================================= */

.dark_bk {
    --nm-card-bg: rgba(255,255,255,.04);
}

.dark_bk .nm-social-share {
    background: rgba(255,255,255,.05);
    border-color: rgba(255,255,255,.08);
}

.dark_bk .nm-share-btn--copy {
    background: rgba(255,255,255,.1);
    color: #e2e8f0;
}

.dark_bk .post-navigation {
    background: rgba(255,255,255,.04);
    border-color: rgba(255,255,255,.08);
}

.dark_bk img[loading="lazy"] {
    background: linear-gradient(90deg, #1e293b 25%, #263347 50%, #1e293b 75%);
}

/* =========================================================
   Focus Visible Accessibility
   ========================================================= */

:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 3px;
}
