/* ==========================================================
   TechRivio News - main stylesheet
   ========================================================== */

:root {
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --bg: #ffffff;
    --surface: #f4f6fa;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --header-bg: #ffffff;
    --footer-bg: #0b1220;
    --footer-text: #cbd5e1;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(15, 23, 42, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --container: 1240px;
}

html[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #17223b;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #26324d;
    --header-bg: #0f172a;
    --footer-bg: #070d1a;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
ul, ol { padding-left: 1.2em; }

.screen-reader-text {
    position: absolute !important; clip: rect(1px, 1px, 1px, 1px);
    width: 1px; height: 1px; overflow: hidden; white-space: nowrap;
}
.skip-link {
    position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff; padding: 10px 16px; z-index: 1000;
}
.skip-link:focus { left: 8px; top: 8px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 820px; padding-top: 40px; padding-bottom: 40px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 999px;
    padding: 11px 22px; font-weight: 600; cursor: pointer; font-size: 15px; font-family: inherit;
}
.btn:hover { background: var(--accent-dark); color: #fff; }
.btn-small { padding: 6px 16px; font-size: 13px; }

.icon-btn {
    background: transparent; border: 0; color: var(--text); width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer;
}
.icon-btn:hover { background: var(--surface); color: var(--accent); }

/* ---------- Consent bar ---------- */
.consent-bar {
    background: #0b1220; color: #e2e8f0; font-size: 13px; padding: 8px 20px;
    display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap;
}
.consent-bar[hidden] { display: none; }
.consent-bar a { text-decoration: underline; }

/* ---------- Progress bar ---------- */
.progress-bar {
    position: fixed; left: 0; top: 0; height: 3px; width: 0; background: var(--accent); z-index: 999; transition: width .1s linear;
}

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--header-bg); border-bottom: 1px solid var(--border); }
.site-header.is-scrolled { box-shadow: var(--shadow); }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); font-size: 13px; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 34px; gap: 16px; }
.topbar .menu { list-style: none; display: flex; gap: 18px; margin: 0; padding: 0; }
.topbar-social, .footer-social { display: flex; gap: 14px; flex-wrap: wrap; }
.topbar-social a, .footer-social a { color: var(--muted); font-weight: 500; }
.topbar-social a:hover, .footer-social a:hover { color: var(--accent); }

.mainbar-inner { display: flex; align-items: center; gap: 24px; min-height: 70px; }
.site-branding { flex: 0 0 auto; }
.site-branding .custom-logo { max-height: 46px; width: auto; }
.site-title { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.site-title:hover { color: var(--accent); }

.primary-nav { flex: 1 1 auto; }
.primary-nav .menu { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.primary-nav .menu > li { position: relative; }
.primary-nav .menu > li > a {
    display: block; padding: 10px 12px; font-weight: 600; font-size: 15px; border-radius: 8px; white-space: nowrap;
}
.primary-nav .menu > li > a:hover,
.primary-nav .menu > li.current-menu-item > a,
.primary-nav .menu > li.current-cat > a { color: var(--accent); background: var(--surface); }

.primary-nav .sub-menu {
    list-style: none; margin: 0; padding: 8px; position: absolute; left: 0; top: 100%; min-width: 210px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; transform: translateY(6px); transition: .18s ease;
}
.primary-nav li:hover > .sub-menu, .primary-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: none; }
.primary-nav .sub-menu a { display: block; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.primary-nav .sub-menu a:hover { background: var(--surface); }

.header-tools { display: flex; gap: 4px; margin-left: auto; }
.menu-toggle { display: none; }
.i-sun { display: none; }
html[data-theme="dark"] .i-sun { display: block; }
html[data-theme="dark"] .i-moon { display: none; }

/* ---------- Search overlay ---------- */
.search-overlay {
    position: fixed; inset: 0; background: rgba(8, 13, 25, .94); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.search-overlay[hidden] { display: none; }
.search-overlay-inner { width: 100%; max-width: 680px; }
.search-close { position: absolute; right: 20px; top: 20px; color: #fff; font-size: 34px; width: 52px; height: 52px; }
.search-close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.search-hint { color: #94a3b8; text-align: center; font-size: 14px; margin-top: 14px; }

.search-form { display: flex; gap: 8px; width: 100%; }
.search-field {
    flex: 1; min-width: 0; padding: 13px 18px; border: 1px solid var(--border); border-radius: 999px;
    font-size: 16px; font-family: inherit; background: var(--bg); color: var(--text);
}
.search-field:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search-submit {
    background: var(--accent); color: #fff; border: 0; padding: 0 22px; border-radius: 999px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.search-submit:hover { background: var(--accent-dark); }

/* ---------- Sections ---------- */
.section { padding: 28px 0; }
.section-title { font-size: 22px; font-weight: 800; margin-bottom: 18px; position: relative; padding-left: 14px; }
.section-title::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 4px; border-radius: 4px; background: var(--accent); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.view-more { font-size: 14px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.view-more:hover { text-decoration: underline; }

/* ---------- Meta / badges ---------- */
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .7; }
.byline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar-img { border-radius: 50%; width: 28px; height: 28px; }

.cats { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cat-badge {
    display: inline-block; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; padding: 3px 9px; border-radius: 6px; line-height: 1.5;
}
.cat-badge:hover { background: var(--accent-dark); color: #fff; }

.thumb-placeholder { display: block; width: 100%; height: 100%; min-height: 80px; background: linear-gradient(135deg, var(--surface), var(--border)); }

/* ---------- Hero ---------- */
.hero { padding-top: 24px; }
.hero-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.hero-side { display: grid; grid-template-rows: 1fr 1fr; gap: 20px; }

.overlay-card { position: relative; overflow: hidden; border-radius: var(--radius); background: #0b1220; min-height: 240px; height: 100%; }
.hero-main .overlay-card { min-height: 480px; }
.overlay-media, .overlay-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.overlay-media img { transition: transform .5s ease; }
.overlay-card:hover .overlay-media img { transform: scale(1.04); }
.overlay-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.82) 100%); pointer-events: none; }
.overlay-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px; z-index: 2; color: #fff; }
.overlay-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.overlay-card.is-big .overlay-title { font-size: 32px; font-weight: 800; }
.overlay-title a:hover { color: #fff; text-decoration: underline; }
.overlay-excerpt { margin: 0 0 12px; color: #e2e8f0; font-size: 15px; max-width: 640px; }
.overlay-body .meta, .overlay-body .byline { color: #cbd5e1; }
.overlay-body .byline a:hover { color: #fff; }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.card { background: var(--bg); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.card-media { display: block; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.card:hover .card-media img { transform: scale(1.05); }
.card-body { padding: 14px 2px 4px; }
.card-title { font-size: 19px; font-weight: 700; margin: 0 0 8px; }

.row-card { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.row-card:last-child { border-bottom: 0; }
.row-media { flex: 0 0 88px; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--surface); }
.row-media img { width: 100%; height: 100%; object-fit: cover; }
.row-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }

/* Featured stories row */
.featured-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.featured-grid .row-card { border-bottom: 0; padding: 0; }

/* Category block */
.cat-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; margin-top: 8px; }
.cat-list { display: flex; flex-direction: column; }
.cat-list .row-card:first-child { padding-top: 0; }

/* ---------- Layout with sidebar ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; padding-top: 36px; padding-bottom: 48px; }

.archive-header { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.archive-title { font-size: 32px; font-weight: 800; margin: 0 0 8px; }
.archive-title span { color: var(--accent); }
.archive-desc { color: var(--muted); }

.sidebar .widget { background: var(--surface); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; }
.widget-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar ul li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.sidebar ul li:last-child { border-bottom: 0; }
.sidebar .search-form { flex-direction: column; }
.sidebar .search-submit { padding: 11px 22px; }

/* ---------- Pagination ---------- */
.pagination { margin-top: 36px; }
.pagination .nav-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pagination .page-numbers {
    min-width: 42px; height: 42px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: 14px;
}
.pagination .page-numbers.current, .pagination .page-numbers:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Single post ---------- */
.single-header { margin-bottom: 22px; }
.single-title { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 14px; }
.post-image { margin: 0 0 28px; }
.post-image img { width: 100%; border-radius: var(--radius); }
.post-image figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }

.entry-content { font-size: 18px; line-height: 1.8; overflow-wrap: break-word; }
.entry-content > * + * { margin-top: 1.1em; margin-bottom: 0; }
.entry-content h2 { font-size: 28px; margin-top: 1.8em; }
.entry-content h3 { font-size: 22px; margin-top: 1.6em; }
.entry-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.entry-content img { border-radius: 10px; }
.entry-content blockquote {
    border-left: 4px solid var(--accent); margin-left: 0; padding: 4px 0 4px 20px; color: var(--muted); font-style: italic;
}
.entry-content table { width: 100%; border-collapse: collapse; font-size: 16px; display: block; overflow-x: auto; }
.entry-content th, .entry-content td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.entry-content th { background: var(--surface); }
.entry-content pre { background: #0b1220; color: #e2e8f0; padding: 16px; border-radius: 10px; overflow-x: auto; font-size: 15px; }
.entry-content code { background: var(--surface); padding: 2px 6px; border-radius: 5px; font-size: .9em; }
.entry-content pre code { background: transparent; padding: 0; }
.page-links { margin-top: 24px; }

.single-footer { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: grid; gap: 16px; }
.tags a {
    display: inline-block; background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; margin: 0 4px 6px 0;
}
.tags a:hover { background: var(--accent); color: #fff; }
.tags-label { font-weight: 700; margin-right: 6px; }
.share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.share-label { font-weight: 700; margin-right: 4px; }
.share a, .share-copy {
    border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600;
    background: transparent; color: var(--text); cursor: pointer; font-family: inherit;
}
.share a:hover, .share-copy:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.author-box { display: flex; gap: 18px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 22px; margin-top: 32px; }
.author-box .avatar-img { width: 72px; height: 72px; flex: 0 0 72px; }
.author-name { font-weight: 800; margin: 0 0 4px; font-size: 17px; }
.author-bio { margin: 0; color: var(--muted); font-size: 15px; }

.related { margin-top: 44px; }

/* ---------- Comments ---------- */
.comments-area { margin-top: 44px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 28px; }
.comment-list .children { list-style: none; padding-left: 28px; }
.comment-body { padding: 16px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.comment-author .avatar { border-radius: 50%; float: left; margin-right: 12px; }
.comment-metadata { font-size: 12px; color: var(--muted); }
.comment-form label { display: block; font-weight: 600; margin-bottom: 4px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 15px; background: var(--bg); color: var(--text);
}
.comment-form .submit { background: var(--accent); color: #fff; border: 0; padding: 12px 24px; border-radius: 999px; font-weight: 700; cursor: pointer; }
.comment-form .submit:hover { background: var(--accent-dark); }

/* ---------- Page / 404 ---------- */
.page-title { font-size: 38px; font-weight: 800; margin-bottom: 24px; }
.not-found { text-align: center; padding: 80px 20px; max-width: 640px; }
.nf-code { font-size: 96px; font-weight: 900; color: var(--accent); line-height: 1; margin: 0; }
.not-found .search-form { margin: 24px 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--footer-bg); color: var(--footer-text); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 40px; padding-top: 52px; padding-bottom: 36px; }
.site-footer .site-title { color: #fff; font-size: 26px; }
.site-footer .custom-logo { max-height: 44px; width: auto; }
.footer-about p { margin: 14px 0; max-width: 360px; font-size: 15px; }
.footer-col h4 { color: #fff; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.footer-menu, .footer-menu ul { list-style: none; margin: 0; padding: 0; }
.footer-menu li { padding: 5px 0; font-size: 15px; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .footer-social a { color: #94a3b8; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .08); font-size: 14px; }
.footer-bottom-inner { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; padding-bottom: 18px; gap: 12px; }
.to-top { background: var(--accent); color: #fff; border: 0; border-radius: 50%; width: 38px; height: 38px; cursor: pointer; font-size: 18px; }
.to-top:hover { background: var(--accent-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .featured-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }
    .mainbar-inner { gap: 10px; }
    .primary-nav {
        position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 86vw); background: var(--bg); z-index: 400;
        padding: 70px 18px 24px; overflow-y: auto; transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow);
    }
    body.menu-open .primary-nav { transform: none; }
    body.menu-open::before { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 300; }
    .primary-nav .menu { flex-direction: column; gap: 2px; }
    .primary-nav .menu > li > a { padding: 12px; }
    .primary-nav .sub-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding: 0 0 0 14px; }
    .site-branding { margin: 0 auto 0 4px; }
    .hero-grid { grid-template-columns: 1fr; }
    .hero-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
    .hero-main .overlay-card { min-height: 380px; }
    .overlay-card.is-big .overlay-title { font-size: 26px; }
    .cat-grid { grid-template-columns: 1fr; }
    .card-grid, .card-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
    .single-title { font-size: 32px; }
}

@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .topbar { display: none; }
    .hero-side { grid-template-columns: 1fr; }
    .hero-side .overlay-card { min-height: 220px; }
    .hero-main .overlay-card { min-height: 340px; }
    .overlay-body { padding: 16px; }
    .overlay-card.is-big .overlay-title { font-size: 22px; }
    .overlay-excerpt { display: none; }
    .featured-grid, .card-grid, .card-grid.cols-2, .card-grid.cols-3 { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 28px; }
    .single-title { font-size: 26px; }
    .entry-content { font-size: 17px; }
    .page-title, .archive-title { font-size: 26px; }
    .author-box { flex-direction: column; text-align: center; }
    .footer-bottom-inner { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
