/* ==========================================================================
   Pulse — News Portal
   ========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #14171c;
  --text-muted: #5b6470;
  --border: #e2e5ea;
  --brand: #d61f2c;
  --brand-2: #ff5a5f;
  --accent: #0b5fff;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 40px rgba(16, 24, 40, .12);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 1200px;
  --header-h: 68px;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242e;
  --text: #e8ebef;
  --text-muted: #98a1ad;
  --border: #2a303b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------- Top utility bar ---------------------------- */
.topbar {
  background: var(--text);
  color: var(--bg);
  font-size: .8rem;
}
[data-theme="dark"] .topbar { background: #000; }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
}
.topbar-date { letter-spacing: .02em; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-link { opacity: .85; }
.topbar-link:hover { opacity: 1; text-decoration: underline; }
.theme-toggle {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  color: inherit;
  transition: transform .2s ease;
}
.theme-toggle:hover { transform: scale(1.08); }

/* ---------------------------- Header ------------------------------------ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--header-h);
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em;
}
.brand-mark {
  color: var(--brand);
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: var(--brand);
  border-radius: 9px;
  color: #fff;
}
.brand-text { color: var(--text); }
.brand-dot { color: var(--brand); }

.primary-nav { margin-left: auto; }
.nav-list {
  display: flex; gap: 4px; list-style: none; margin: 0; padding: 0;
}
.nav-list a {
  padding: 8px 13px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease;
}
.nav-list a:hover { background: var(--surface-2); color: var(--text); }
.nav-list a.active { color: var(--brand); }

.header-actions { display: flex; align-items: center; gap: 12px; }
.search-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: var(--text);
  transition: background .15s ease;
}
.search-toggle:hover { background: var(--surface-2); }
.search-toggle[aria-expanded="true"] { background: var(--surface-2); border-color: var(--brand); }

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: .9rem;
  transition: transform .12s ease, box-shadow .2s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(214, 31, 44, .35);
}
.btn-primary:hover { background: #b81824; box-shadow: 0 6px 20px rgba(214, 31, 44, .45); }
.btn-block { width: 100%; }

/* Search bar */
.search-bar {
  max-height: 0;
  overflow: hidden;
  transition: max-height .28s ease;
  border-top: 1px solid transparent;
}
.search-bar.open {
  max-height: 80px;
  border-top: 1px solid var(--border);
}
.search-bar .container {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.search-input {
  flex: 1;
  padding: 12px 18px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}
.search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(214,31,44,.15); }
.search-count { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}
.nav-toggle span {
  width: 24px; height: 2px; background: var(--text); border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------------------------- Ticker ------------------------------------ */
.ticker {
  display: flex; align-items: center;
  background: var(--brand);
  color: #fff;
  height: 42px;
  overflow: hidden;
}
.ticker-label {
  flex: 0 0 auto;
  background: rgba(0,0,0,.25);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .78rem;
  padding: 0 16px;
  height: 100%;
  display: grid; place-items: center;
}
.ticker-viewport { flex: 1; overflow: hidden; }
.ticker-track {
  list-style: none;
  margin: 0; padding: 0;
  display: inline-flex;
  white-space: nowrap;
  animation: ticker 45s linear infinite;
}
.ticker-track:hover { animation-play-state: paused; }
.ticker-track li {
  padding: 0 28px;
  display: inline-flex; align-items: center; gap: 10px;
  font-size: .92rem; font-weight: 500;
}
.ticker-track li::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.7);
  flex: 0 0 auto;
}
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Filter banner */
.filter-banner {
  background: var(--accent);
  color: #fff;
}
.filter-banner .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 40px; font-size: .9rem;
}
.filter-clear {
  background: rgba(255,255,255,.2);
  border: none; color: #fff;
  padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: .8rem;
}
.filter-clear:hover { background: rgba(255,255,255,.35); }

/* ---------------------------- Main layout ------------------------------- */
.main { padding: 26px 20px 60px; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  gap: 16px;
  margin-bottom: 34px;
}
.hero-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.hero-card-main { min-height: 380px; display: flex; flex-direction: column; justify-content: flex-end; }
.hero-side { display: grid; gap: 16px; }
.hero-card-small { min-height: 182px; display: flex; flex-direction: column; justify-content: flex-end; cursor: pointer; }
.hero-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.hero-media {
  position: absolute; inset: 0;
  background: var(--grad);
}
.hero-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.78) 0%, rgba(0,0,0,.25) 45%, rgba(0,0,0,.05) 100%);
}
.hero-body, .hero-card-small > * { position: relative; z-index: 1; padding: 18px; }
.hero-card-small .hero-media { position: absolute; }
.hero-title {
  color: #fff; font-size: 2rem; line-height: 1.15; margin: 0 0 8px;
  font-weight: 800; letter-spacing: -.02em;
}
.hero-title-sm { color: #fff; font-size: 1.12rem; line-height: 1.25; margin: 0 0 8px; font-weight: 700; }
.hero-excerpt { color: rgba(255,255,255,.85); margin: 0 0 12px; font-size: .98rem; max-width: 60ch; }
.hero-meta { color: rgba(255,255,255,.75); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-meta .dot { opacity: .6; }

.chip {
  position: relative; z-index: 1;
  align-self: flex-start;
  background: var(--brand);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 10px;
  border-radius: 999px;
}
.chip-accent { position: absolute; top: 16px; left: 16px; z-index: 2; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 34px;
  align-items: start;
}

.section-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.section-title {
  font-size: 1.35rem; font-weight: 800; margin: 0; letter-spacing: -.01em;
  position: relative; padding-left: 14px;
}
.section-title::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 22px; background: var(--brand); border-radius: 3px;
}
.section-rule { flex: 1; height: 1px; background: var(--border); }

/* Article grid */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  cursor: pointer;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card-media {
  position: relative;
  height: 170px;
  background: var(--grad, var(--surface-2));
  overflow: hidden;
}
.card-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.15), transparent 60%);
}
.card-cat {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  background: rgba(255,255,255,.92);
  color: #111;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 10px; border-radius: 999px;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 1.08rem; font-weight: 700; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.01em; }
.card:hover .card-title { color: var(--brand); }
.card-excerpt { color: var(--text-muted); font-size: .9rem; margin: 0 0 14px; flex: 1; }
.card-meta { color: var(--text-muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-meta .dot { opacity: .5; }
.card-tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: .72rem; color: var(--text-muted);
  background: var(--surface-2);
  padding: 3px 9px; border-radius: 999px;
}
.tag:hover { color: var(--brand); background: var(--border); }

.no-results { text-align: center; color: var(--text-muted); padding: 60px 0; font-size: 1.05rem; }

/* ---------------------------- Sidebar ----------------------------------- */
.sidebar { display: grid; gap: 24px; position: sticky; top: calc(var(--header-h) + 20px); }
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.widget-title {
  font-size: 1.05rem; font-weight: 800; margin: 0 0 16px;
  display: flex; align-items: center; gap: 8px;
}
.widget-title::before { content: ""; width: 5px; height: 18px; background: var(--brand); border-radius: 3px; }
.widget-desc { color: var(--text-muted); font-size: .9rem; margin: 0 0 14px; }

/* Trending */
.trending-list { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.trending-list li {
  counter-increment: t;
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.trending-list li:last-child { border-bottom: none; padding-bottom: 0; }
.trending-list li:first-child { padding-top: 0; }
.trending-num {
  font-size: 1.6rem; font-weight: 800; line-height: 1;
  color: var(--brand); opacity: .85; min-width: 26px;
}
.trending-body { flex: 1; }
.trending-title { font-weight: 600; font-size: .95rem; line-height: 1.3; margin: 0 0 4px; }
.trending-title:hover { color: var(--brand); cursor: pointer; }
.trending-meta { font-size: .78rem; color: var(--text-muted); }

/* Most read */
.mostread-list { list-style: none; margin: 0; padding: 0; }
.mostread-list li {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.mostread-list li:last-child { border-bottom: none; padding-bottom: 0; }
.mostread-list li:first-child { padding-top: 0; }
.mostread-thumb {
  flex: 0 0 64px; height: 52px; border-radius: 8px;
  background: var(--grad, var(--surface-2));
}
.mostread-body { flex: 1; min-width: 0; }
.mostread-title { font-weight: 600; font-size: .9rem; line-height: 1.25; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mostread-title:hover { color: var(--brand); cursor: pointer; }
.mostread-meta { font-size: .75rem; color: var(--text-muted); }

/* Newsletter */
.widget-newsletter {
  background: linear-gradient(135deg, #101827, #1d2a44);
  border: none; color: #fff;
}
.widget-newsletter .widget-title { color: #fff; }
.widget-newsletter .widget-title::before { background: var(--brand-2); }
.widget-newsletter .widget-desc { color: rgba(255,255,255,.75); }
.newsletter-form { display: grid; gap: 10px; }
.newsletter-input {
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff;
  font-size: .92rem; outline: none;
}
.newsletter-input::placeholder { color: rgba(255,255,255,.5); }
.newsletter-input:focus { border-color: var(--brand-2); }
.newsletter-msg { font-size: .85rem; margin: 10px 0 0; min-height: 1em; color: #7CFFB2; }
.newsletter-msg.error { color: #ff9a9a; }

/* Weather */
.weather-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.weather-icon { font-size: 2.2rem; }
.weather-info { display: flex; flex-direction: column; }
.weather-info strong { font-size: 1.4rem; }
.weather-info span { font-size: .82rem; color: var(--text-muted); }
.weather-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.weather-mini div { font-size: .72rem; color: var(--text-muted); }
.weather-mini .d { font-size: 1.1rem; }
.weather-mini .t { color: var(--text); font-weight: 600; }

/* ---------------------------- Footer ------------------------------------ */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 30px;
  padding: 46px 20px;
}
.footer-about p { color: var(--text-muted); font-size: .9rem; max-width: 40ch; margin-top: 14px; }
.brand-footer { font-size: 1.3rem; }
.brand-footer .brand-mark { width: 30px; height: 30px; }
.footer-col h4 { margin: 0 0 14px; font-size: .95rem; font-weight: 800; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.footer-links a { color: var(--text-muted); font-size: .9rem; }
.footer-links a:hover { color: var(--brand); }
.social { display: flex; gap: 10px; }
.social-link {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%;
  font-weight: 700; color: var(--text-muted);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.social-link:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--border); }
.footer-bottom .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 18px; padding-bottom: 18px; font-size: .82rem; color: var(--text-muted);
}
.footer-legal a { color: var(--text-muted); margin: 0 4px; }
.footer-legal a:hover { color: var(--brand); }

/* Back to top */
.back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; background: var(--brand); color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
  z-index: 60;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: #b81824; }

/* ---------------------------- Responsive -------------------------------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(2, 1fr); align-items: start; }
  .hero { grid-template-columns: 1fr; }
  .hero-card-main { min-height: 320px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  :root { --header-h: 60px; }
  .nav-toggle { display: flex; order: -1; }
  .primary-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height .3s ease;
    box-shadow: var(--shadow);
  }
  .primary-nav.open { max-height: 420px; }
  .nav-list { flex-direction: column; padding: 10px; gap: 2px; }
  .nav-list a { display: block; padding: 12px 14px; }
  .btn-subscribe { display: none; }
  .brand { font-size: 1.3rem; }
  .grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.5rem; }
  .sidebar { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; padding-top: 34px; }
  .footer-bottom .container { flex-direction: column; gap: 8px; }
  .topbar-date { display: none; }
}
