/*
Theme Name: Pulse News
Theme URI: https://example.com/pulse-news
Author: Pulse Themes
Author URI: https://example.com
Description: A premium, Google Discover–ready news magazine theme with breaking ticker, category homepage, infinite scroll, AdSense slots, SEO schema, dark mode, and Core Web Vitals–focused performance.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: pulse-news
Tags: news, magazine, blog, custom-logo, custom-menu, featured-images, infinite-scroll, rtl-language-support, theme-options, translation-ready, dark-mode, two-columns, right-sidebar
*/

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
  --pn-font-sans: "Figtree", system-ui, -apple-system, sans-serif;
  --pn-font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --pn-bg: #f5f7fa;
  --pn-surface: #ffffff;
  --pn-text: #0f172a;
  --pn-muted: #64748b;
  --pn-border: #e2e8f0;
  --pn-accent: #c8102e;
  --pn-accent-hover: #a50d25;
  --pn-ticker: #0f172a;
  --pn-ticker-text: #f8fafc;
  --pn-link: #0369a1;
  --pn-radius: 2px;
  --pn-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --pn-max: 1200px;
  --pn-gap: 1.5rem;
  --pn-header-h: 64px;
  color-scheme: light;
}

[data-theme="dark"] {
  --pn-bg: #0b1220;
  --pn-surface: #141c2b;
  --pn-text: #e8eef7;
  --pn-muted: #94a3b8;
  --pn-border: #243044;
  --pn-accent: #f0435d;
  --pn-accent-hover: #ff6b80;
  --pn-ticker: #020617;
  --pn-link: #7dd3fc;
  --pn-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* ==========================================================================
   Reset & Base (CWV-friendly)
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--pn-font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--pn-text);
  background: var(--pn-bg);
  text-rendering: optimizeLegibility;
}

img,
picture,
video,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

img {
  content-visibility: auto;
}

a {
  color: var(--pn-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--pn-accent);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--pn-font-display);
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.6em;
  color: var(--pn-text);
}

p { margin: 0 0 1em; }

ul, ol { margin: 0 0 1em; padding-left: 1.25em; }

button,
input,
select,
textarea {
  font: inherit;
}

/* Skip link */
.pn-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: var(--pn-accent);
  color: #fff;
  padding: 0.75rem 1rem;
}
.pn-skip-link:focus {
  left: 0;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.pn-container {
  width: min(100% - 2rem, var(--pn-max));
  margin-inline: auto;
}

.pn-site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.pn-main {
  flex: 1;
  padding: 1.5rem 0 3rem;
}

.pn-layout {
  display: grid;
  gap: var(--pn-gap);
}

@media (min-width: 960px) {
  .pn-layout.has-sidebar {
    grid-template-columns: 1fr 320px;
    align-items: start;
  }
}

.pn-content > *:first-child { margin-top: 0; }

/* ==========================================================================
   Header
   ========================================================================== */
.pn-header {
  background: var(--pn-surface);
  border-bottom: 1px solid var(--pn-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.pn-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--pn-header-h);
}

.pn-logo {
  font-family: var(--pn-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--pn-text);
  text-decoration: none;
}
.pn-logo:hover { color: var(--pn-accent); }
.pn-logo img { max-height: 40px; width: auto; }

.pn-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  background: var(--pn-surface);
  color: var(--pn-text);
  cursor: pointer;
}
@media (min-width: 900px) {
  .pn-nav-toggle { display: none; }
}

.pn-primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0 1rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
}
.pn-primary-nav.is-open ul {
  display: flex;
}
@media (min-width: 900px) {
  .pn-primary-nav ul {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.25rem;
    padding: 0;
  }
}

.pn-primary-nav a {
  color: var(--pn-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.pn-primary-nav a:hover,
.pn-primary-nav .current-menu-item > a {
  color: var(--pn-accent);
}

.pn-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pn-theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  background: transparent;
  color: var(--pn-text);
  cursor: pointer;
}

/* ==========================================================================
   Breaking News Ticker
   ========================================================================== */
.pn-ticker {
  background: var(--pn-ticker);
  color: var(--pn-ticker-text);
  overflow: hidden;
  font-size: 0.9rem;
}

.pn-ticker__inner {
  display: flex;
  align-items: stretch;
  min-height: 40px;
}

.pn-ticker__label {
  flex-shrink: 0;
  background: var(--pn-accent);
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
}

.pn-ticker__track {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
}

.pn-ticker__list {
  display: flex;
  gap: 2.5rem;
  list-style: none;
  margin: 0;
  padding: 0 1rem;
  white-space: nowrap;
  animation: pn-ticker-scroll 40s linear infinite;
  will-change: transform;
}

.pn-ticker__list:hover { animation-play-state: paused; }

.pn-ticker__list a {
  color: var(--pn-ticker-text);
  text-decoration: none;
  font-weight: 500;
}
.pn-ticker__list a:hover { text-decoration: underline; }

@keyframes pn-ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .pn-ticker__list { animation: none; flex-wrap: wrap; white-space: normal; }
}

/* ==========================================================================
   Sections & Cards
   ========================================================================== */
.pn-section {
  margin-bottom: 2.5rem;
}

.pn-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--pn-text);
  padding-bottom: 0.5rem;
}

.pn-section__title {
  font-size: 1.25rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pn-section__more {
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--pn-accent);
}

.pn-grid {
  display: grid;
  gap: 1.25rem;
}
.pn-grid--2 { grid-template-columns: 1fr; }
.pn-grid--3 { grid-template-columns: 1fr; }
.pn-grid--featured {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .pn-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .pn-grid--3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .pn-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .pn-grid--featured {
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: auto auto;
  }
  .pn-grid--featured .pn-card:first-child {
    grid-row: 1 / span 2;
  }
}

.pn-card {
  background: var(--pn-surface);
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  overflow: hidden;
  box-shadow: var(--pn-shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  contain: content;
}

.pn-card__media {
  aspect-ratio: 16 / 9;
  background: var(--pn-border);
  overflow: hidden;
}
.pn-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pn-grid--featured .pn-card:first-child .pn-card__media {
  aspect-ratio: 16 / 10;
}

.pn-card__body {
  padding: 1rem 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.pn-card__cat {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pn-accent);
  text-decoration: none;
}

.pn-card__title {
  font-size: 1.05rem;
  margin: 0;
}
.pn-card__title a {
  color: var(--pn-text);
  text-decoration: none;
}
.pn-card__title a:hover { color: var(--pn-accent); }

.pn-grid--featured .pn-card:first-child .pn-card__title {
  font-size: 1.45rem;
}

.pn-card__meta {
  font-size: 0.8rem;
  color: var(--pn-muted);
  margin-top: auto;
}

.pn-card__excerpt {
  font-size: 0.95rem;
  color: var(--pn-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Trending list */
.pn-trending {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: trend;
}
.pn-trending li {
  counter-increment: trend;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--pn-border);
}
.pn-trending li::before {
  content: counter(trend, decimal-leading-zero);
  font-family: var(--pn-font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--pn-accent);
  line-height: 1.2;
}
.pn-trending a {
  color: var(--pn-text);
  text-decoration: none;
  font-weight: 600;
}
.pn-trending a:hover { color: var(--pn-accent); }

/* ==========================================================================
   Single / Archive
   ========================================================================== */
.pn-entry-header {
  margin-bottom: 1.5rem;
}
.pn-entry-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 0.5rem;
}
.pn-entry-meta {
  color: var(--pn-muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}
.pn-entry-meta a { color: inherit; }

.pn-featured-image {
  margin: 0 0 1.5rem;
  border-radius: var(--pn-radius);
  overflow: hidden;
}
.pn-featured-image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.pn-entry-content {
  font-size: 1.125rem;
  line-height: 1.75;
}
.pn-entry-content > *:first-child { margin-top: 0; }
.pn-entry-content h2 { margin-top: 1.75em; font-size: 1.5rem; }
.pn-entry-content h3 { margin-top: 1.5em; font-size: 1.25rem; }
.pn-entry-content figure { margin: 1.5rem 0; }
.pn-entry-content blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  border-left: 4px solid var(--pn-accent);
  color: var(--pn-muted);
  font-style: italic;
}

.pn-ad-slot {
  margin: 1.5rem 0;
  text-align: center;
  min-height: 90px;
  background: var(--pn-surface);
  border: 1px dashed var(--pn-border);
  border-radius: var(--pn-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pn-muted);
  font-size: 0.8rem;
}
.pn-ad-slot--header { margin: 1rem 0; min-height: 90px; }
.pn-ad-slot--inarticle { margin: 2rem 0; min-height: 250px; }
.pn-ad-slot--sidebar { min-height: 250px; margin-bottom: 1.25rem; }

/* ==========================================================================
   Sidebar / Widgets
   ========================================================================== */
.pn-sidebar .widget {
  background: var(--pn-surface);
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--pn-shadow);
}
.pn-sidebar .widget-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--pn-text);
}

.pn-newsletter {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.pn-newsletter input[type="email"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  background: var(--pn-bg);
  color: var(--pn-text);
}
.pn-newsletter button {
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: var(--pn-radius);
  background: var(--pn-accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.pn-newsletter button:hover { background: var(--pn-accent-hover); }
.pn-newsletter__msg {
  font-size: 0.85rem;
  color: var(--pn-muted);
  margin: 0;
}

/* ==========================================================================
   Infinite scroll
   ========================================================================== */
.pn-posts-feed {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 640px) {
  .pn-posts-feed { grid-template-columns: repeat(2, 1fr); }
}

.pn-load-more,
.pn-infinite-status {
  text-align: center;
  margin: 2rem 0 1rem;
  grid-column: 1 / -1;
}
.pn-load-more button {
  padding: 0.85rem 1.75rem;
  border: 2px solid var(--pn-text);
  background: transparent;
  color: var(--pn-text);
  font-weight: 700;
  border-radius: var(--pn-radius);
  cursor: pointer;
}
.pn-load-more button:hover {
  background: var(--pn-text);
  color: var(--pn-bg);
}
.pn-infinite-status[hidden] { display: none; }

/* ==========================================================================
   Author
   ========================================================================== */
.pn-author-box {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--pn-surface);
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  margin: 2rem 0;
}
@media (min-width: 640px) {
  .pn-author-box {
    grid-template-columns: 96px 1fr;
    align-items: start;
  }
}
.pn-author-box img {
  border-radius: 50%;
  width: 96px;
  height: 96px;
  object-fit: cover;
}
.pn-author-box h2,
.pn-author-box h3 { margin: 0 0 0.35rem; font-size: 1.15rem; }
.pn-author-box p { margin: 0; color: var(--pn-muted); }

/* ==========================================================================
   Search / Archive headers
   ========================================================================== */
.pn-page-header {
  margin-bottom: 1.5rem;
}
.pn-page-header h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: 0.35rem;
}
.pn-page-header p {
  color: var(--pn-muted);
  margin: 0;
}

.pn-search-form {
  display: flex;
  gap: 0.5rem;
  max-width: 480px;
  margin-bottom: 1.5rem;
}
.pn-search-form input {
  flex: 1;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  background: var(--pn-surface);
  color: var(--pn-text);
}
.pn-search-form button {
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: var(--pn-radius);
  background: var(--pn-accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.pn-footer {
  background: var(--pn-surface);
  border-top: 1px solid var(--pn-border);
  padding: 2.5rem 0 1.5rem;
  margin-top: auto;
}
.pn-footer__grid {
  display: grid;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .pn-footer__grid { grid-template-columns: 2fr 1fr 1fr; }
}
.pn-footer__copy {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pn-border);
  font-size: 0.85rem;
  color: var(--pn-muted);
  text-align: center;
}

/* ==========================================================================
   Pagination fallback
   ========================================================================== */
.pn-pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}
.pn-pagination a,
.pn-pagination span {
  display: inline-flex;
  min-width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 0.65rem;
  border: 1px solid var(--pn-border);
  border-radius: var(--pn-radius);
  text-decoration: none;
  color: var(--pn-text);
  background: var(--pn-surface);
}
.pn-pagination .current {
  background: var(--pn-accent);
  border-color: var(--pn-accent);
  color: #fff;
}

/* Screen reader */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}
