/*
Theme Name: The Trend
Theme URI: https://example.com/the-trend
Author: Your Name
Author URI: https://example.com
Description: Fast pop culture news aggregator — WordPress powered
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: the-trend
Tags: news, magazine, blog, responsive
*/

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red: #E11C24;
  --red-hover: #c4161d;
  --white: #FFFFFF;
  --bg: #F4F4F5;
  --charcoal: #1A1A1A;
  --gray-700: #3A3A3C;
  --gray-500: #6B6B70;
  --gray-300: #D1D1D6;
  --gray-200: #E5E5EA;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--charcoal);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; transition: color 0.2s ease; }
a:hover { color: var(--red); }
img { max-width: 100%; height: auto; display: block; }

/* WordPress Core Classes */
.aligncenter { display: block; margin: 1rem auto; }
.alignleft { float: left; margin: 0.5rem 1rem 0.5rem 0; }
.alignright { float: right; margin: 0.5rem 0 0.5rem 1rem; }
.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 0.85rem; color: var(--gray-500); margin-top: 0.5rem; }
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== STICKY HEADER ===== */
.app-header {
  position: sticky; top: 0; z-index: 1050;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.65rem 1rem;
  backdrop-filter: blur(12px);
}
.brand {
  font-weight: 800; font-size: 1.55rem; letter-spacing: -0.03em;
  display: inline-flex; align-items: baseline;
}
.brand .the { color: var(--charcoal); }
.brand .trend { color: var(--red); }
.brand .dot { color: var(--red); }
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.header-timestamp {
  font-size: 0.72rem; font-weight: 500; color: var(--gray-500); text-align: right;
}

/* ===== TICKER CATEGORY BAR ===== */
.category-bar {
  position: sticky; top: 52px; z-index: 1040;
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  padding: 0.55rem 0; overflow: hidden;
}
.ticker-wrap { width: 100%; overflow: hidden; white-space: nowrap; }
.ticker {
  display: inline-flex; animation: ticker-scroll 35s linear infinite;
  will-change: transform;
}
.ticker:hover { animation-play-state: paused; }
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.cat-pill {
  display: inline-flex; align-items: center; margin: 0 0.35rem;
  padding: 0.4rem 1.05rem; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; white-space: nowrap;
  cursor: pointer; border: 1.5px solid var(--gray-300);
  background: var(--white); color: var(--gray-700);
  transition: all .18s ease; user-select: none;
}
.cat-pill:hover, .cat-pill.active {
  border-color: var(--red); color: var(--white); background: var(--red);
  box-shadow: 0 2px 8px rgba(225,28,36,.30);
}

/* ===== MAIN CONTENT ===== */
.main-content { padding: 1rem 0 3rem; }

/* ===== CAROUSEL ===== */
.carousel-wrap { margin-bottom: 1.25rem; overflow: hidden; }
.carousel-track {
  display: flex; gap: 1rem; animation: carousel-scroll 28s linear infinite;
  padding: 0 1rem; will-change: transform;
}
.carousel-track:hover { animation-play-state: paused; }
@keyframes carousel-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.carousel-item { flex: 0 0 85%; max-width: 85%; }
@media (min-width: 576px) { .carousel-item { flex: 0 0 48%; max-width: 48%; } }
@media (min-width: 768px) { .carousel-item { flex: 0 0 31%; max-width: 31%; } }

/* ===== CARD ===== */
.card-feed {
  background: var(--white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
  display: block; height: 100%;
}
.card-feed:hover {
  box-shadow: var(--shadow-card-hover); transform: translateY(-2px); cursor: pointer;
}
.card-feed:active { transform: scale(0.99); }

.card-img-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9;
  overflow: hidden; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--gray-200);
}
.card-img-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; transition: transform .35s ease;
}
.card-feed:hover .card-img-wrap img { transform: scale(1.03); }

.card-body { padding: 0.95rem 1.1rem 1.1rem; }
.source-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--red); background: rgba(225,28,36,.07);
  padding: 0.22rem 0.6rem; border-radius: 4px; margin-bottom: 0.55rem;
}
.card-title {
  font-size: 1.08rem; font-weight: 700; line-height: 1.32;
  color: var(--charcoal); margin-bottom: 0.45rem;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-summary {
  font-size: 0.85rem; font-weight: 400; line-height: 1.55;
  color: var(--gray-700); display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 0.85rem;
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; color: var(--gray-500); font-weight: 500;
}
.card-arrow {
  position: absolute; top: 0.75rem; right: 0.75rem;
  background: var(--red); color: var(--white);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
  box-shadow: 0 2px 8px rgba(225,28,36,.35);
  opacity: 0; transform: translate(4px, -4px);
  transition: all .2s ease; z-index: 2;
}
.card-feed:hover .card-arrow { opacity: 1; transform: translate(0, 0); }

/* ===== GRID & LABELS ===== */
.section-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--gray-500);
  padding: 0.5rem 1rem 0.3rem; margin-bottom: 0.3rem;
}
.card-grid {
  display: grid; grid-template-columns: 1fr; gap: 1rem; padding: 0 1rem;
}
@media (min-width: 768px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 1.15rem; }
  .main-content { max-width: 820px; margin: 0 auto; padding: 0 1rem; }
  .app-header { padding: 0.7rem 1.5rem; }
  .brand { font-size: 1.75rem; }
}
@media (min-width: 1024px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); gap: 1.35rem; }
  .main-content { max-width: 1100px; }
}

/* ===== SCROLL TO TOP ===== */
.scroll-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--red); color: var(--white); border: none;
  box-shadow: 0 4px 14px rgba(225,28,36,.35);
  font-size: 1.2rem; cursor: pointer; display: none;
  align-items: center; justify-content: center; z-index: 1100;
  transition: transform .2s ease, opacity .25s ease;
}
.scroll-top.visible { display: flex; opacity: 1; }
.scroll-top:hover { transform: scale(1.08); }

/* ===== FOOTER ===== */
.app-footer {
  text-align: center; padding: 2rem 1rem;
  font-size: 0.72rem; color: var(--gray-500); font-weight: 500;
}
.app-footer a { color: var(--red); font-weight: 700; }

/* ===== FOCUS ===== */
:focus-visible {
  outline: 2.5px solid var(--red); outline-offset: 2px; border-radius: 4px;
}

/* ===== SINGLE POST ===== */
.article-container {
  display: grid; grid-template-columns: 1fr; gap: 1.5rem;
  padding: 1.5rem 1rem 3rem; max-width: 1200px; margin: 0 auto;
}
.main-article {
  background: var(--white); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.featured-image-wrap {
  width: 100%; aspect-ratio: 16/9; overflow: hidden;
  background: var(--gray-200); position: relative;
}
.featured-image-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.category-tag {
  position: absolute; top: 1rem; left: 1rem;
  background: var(--red); color: var(--white);
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  padding: 0.35rem 0.85rem; border-radius: 6px;
}
.article-content { padding: 1.75rem 1.25rem; }
@media (min-width: 768px) {
  .article-content { padding: 2rem 2rem; }
  .article-title { font-size: 2.1rem; }
}
.article-header {
  margin-bottom: 1.5rem; padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--gray-200);
}
.article-title {
  font-size: 1.8rem; font-weight: 800; line-height: 1.2;
  color: var(--charcoal); margin-bottom: 1rem; letter-spacing: -0.02em;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem;
  font-size: 0.85rem; color: var(--gray-500); font-weight: 500;
}
.author-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(225,28,36,.08); color: var(--red);
  padding: 0.3rem 0.7rem; border-radius: 6px;
  font-size: 0.8rem; font-weight: 600;
  border: 1px solid rgba(225,28,36,.2);
}
.article-body {
  font-size: 1.05rem; line-height: 1.75; color: var(--gray-700);
}
.article-body p { margin-bottom: 1.25rem; }
.article-body p:first-of-type {
  font-size: 1.15rem; font-weight: 500; color: var(--charcoal);
}
.article-body strong { color: var(--charcoal); font-weight: 700; }
.article-tags {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 2rem; padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
}
.tag {
  font-size: 0.75rem; font-weight: 600; color: var(--gray-500);
  background: var(--bg); padding: 0.3rem 0.7rem;
  border-radius: 4px; border: 1px solid var(--gray-200);
}
.tag:hover { background: var(--red); color: var(--white); border-color: var(--red); }

/* ===== SIDEBAR ===== */
.sidebar { position: relative; }
@media (min-width: 992px) {
  .article-container { grid-template-columns: 1fr 380px; gap: 2rem; padding: 2rem; }
  .sidebar { position: sticky; top: 120px; height: fit-content; }
}
.sidebar-title {
  font-size: 1.1rem; font-weight: 700; color: var(--charcoal);
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--red);
  display: flex; align-items: center; gap: 0.5rem;
}
.sidebar-title::before {
  content: ""; width: 4px; height: 20px;
  background: var(--red); border-radius: 2px;
}
.sidebar-post {
  display: flex; gap: 0.85rem; padding: 0.85rem;
  background: var(--white); border-radius: var(--radius-md);
  margin-bottom: 0.75rem; border: 1px solid var(--gray-200);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.sidebar-post:hover { border-color: var(--red); }
.sidebar-post-image {
  width: 80px; height: 60px; border-radius: var(--radius-sm);
  overflow: hidden; flex-shrink: 0; background: var(--gray-200);
}
.sidebar-post-image img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.sidebar-post-content { flex: 1; min-width: 0; }
.sidebar-post-category {
  font-size: 0.65rem; font-weight: 700; color: var(--red);
  text-transform: uppercase; margin-bottom: 0.2rem;
}
.sidebar-post-title {
  font-size: 0.85rem; font-weight: 600; line-height: 1.35;
  color: var(--charcoal); display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sidebar-post-meta {
  font-size: 0.7rem; color: var(--gray-500); margin-top: 0.3rem;
}

/* ===== BACK BUTTON ===== */
.back-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; font-weight: 600; color: var(--gray-700);
  padding: 0.4rem 0.8rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300); background: var(--white);
}
.back-btn:hover { border-color: var(--red); color: var(--red); }

/* ===== CATEGORY SCROLL (Single) ===== */
.category-scroll {
  display: flex; gap: 0.5rem; padding: 0 1rem;
  overflow-x: auto; scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }

/* ===== MOBILE VIEWPORT FIX ===== */
:root {
  --vh: 1vh; /* JS will override this on mobile */
}

/* Use --vh for full-height calculations if needed */
.full-height-mobile {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
}

/* Improve touch targets for mobile */
@media (max-width: 767px) {
  .cat-pill {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
  }
  
  .card-feed:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
  
  /* Prevent accidental zoom on inputs */
  input, textarea, select {
    font-size: 16px;
  }
}

/* Loading skeleton for new cards */
.card-feed.is-loading {
  position: relative;
  overflow: hidden;
}
.card-feed.is-loading::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, 
    var(--gray-200) 0%, 
    var(--white) 50%, 
    var(--gray-200) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  pointer-events: none;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@media (max-width: 767px) {
  /* Show hint when user scrolls near bottom but no more posts */
  #infiniteScrollEnd {
    animation: none;
  }
  
  /* Optional: subtle bounce when reaching end */
  .home-feed.reached-end {
    overscroll-behavior-y: contain; /* Prevents bounce on iOS */
  }
}