/* =========================================================
   EL PERIÓDICO DE HOY — Main Stylesheet v1.1
   Optimized for Core Web Vitals: LCP, CLS, TBT
   ========================================================= */

/* --- FONT FACE (self-hosted Space Grotesk variable) --- */
@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/SpaceGrotesk-Variable.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* --- RESET & BASE --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0f;
  --bg-card:   #111118;
  --bg-hover:  #1a1a28;
  --red:       #e8002d;
  --red-dim:   #a0001f;
  --text:      #f0f0f0;
  --text-muted:#8a8a9a;
  --border:    #222230;
  --font:      'Space Grotesk', system-ui, sans-serif;
  --max-w:     1200px;
  --radius:    4px;
  --gap:       1.5rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* CLS fix: explicit dimensions on all media */
img, video, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--red); }
ul { list-style: none; }

/* --- LAYOUT --- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1rem;
}

.site-main { padding-block: 2rem; }

#content-wrapper {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--gap);
  align-items: start;
}

@media (max-width: 900px) {
  #content-wrapper { grid-template-columns: 1fr; }
}

/* --- TOP BAR --- */
.top-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: .35rem 0;
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.top-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-date { text-transform: uppercase; }
.top-bar-lang { display: flex; gap: .35rem; }
.top-bar-lang a {
  color: var(--text-muted);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: color .2s, border-color .2s;
}
.top-bar-lang a:hover,
.top-bar-lang a.active { color: var(--red); border-color: var(--red); }

/* --- SITE HEADER --- */
.site-header {
  background: var(--bg);
  border-bottom: 2px solid var(--red);
  padding: .75rem 0;
  position: relative;
}
/* Scan line accent */
.site-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232,0,45,.4), transparent);
  pointer-events: none;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* --- LOGO --- */
.site-logo a, .logo-link { display: flex; align-items: center; text-decoration: none; }
/* CLS fix: reserve space for logo */
.site-logo svg { height: 44px; width: 220px; }
.site-logo .custom-logo { height: 44px; width: auto; max-width: 220px; object-fit: contain; }

/* --- NAVBAR --- */
.primary-menu-wrapper nav { display: flex; align-items: center; }
.primary-menu { display: flex; gap: 0; flex-wrap: nowrap; }
.primary-menu li { position: relative; }
.primary-menu li a {
  display: block;
  padding: .5rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text);
  transition: color .2s;
  white-space: nowrap;
}
.primary-menu li a:hover,
.primary-menu li.current-menu-item > a { color: var(--red); }

/* Dropdown */
.primary-menu li ul {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--red);
  min-width: 180px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .15s, transform .15s;
  z-index: 100;
}
.primary-menu li:hover > ul,
.primary-menu li:focus-within > ul {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.primary-menu li ul li a {
  padding: .5rem 1rem;
  font-size: .78rem;
  border-bottom: 1px solid var(--border);
}
.primary-menu li ul li:last-child a { border-bottom: none; }

/* Search toggle */
.nav-search-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text); padding: .4rem;
  display: flex; align-items: center;
  transition: color .2s;
}
.nav-search-toggle:hover { color: var(--red); }
.nav-search-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }

/* Search box */
.search-box {
  display: none;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 0;
}
.search-box.open { display: block; }
.search-box form { display: flex; gap: .5rem; }
.search-box input[type="search"] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem .75rem;
  font-family: var(--font);
  font-size: .9rem;
  border-radius: var(--radius);
  outline: none;
}
.search-box input[type="search"]:focus { border-color: var(--red); }
.search-box button[type="submit"] {
  background: var(--red); border: none; color: #fff;
  padding: .5rem 1rem; cursor: pointer;
  border-radius: var(--radius);
  font-family: var(--font); font-size: .85rem;
  font-weight: 600; letter-spacing: .04em;
}

/* --- HAMBURGER --- */
.mobile-nav-toggle {
  display: none; background: none; border: none;
  cursor: pointer; padding: .4rem;
  flex-direction: column; gap: 5px; color: var(--text);
  /* CLS fix: explicit size */
  width: 32px; height: 32px; justify-content: center;
}
.mobile-nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: currentColor;
  transition: transform .25s, opacity .25s;
}
@media (max-width: 768px) {
  .mobile-nav-toggle { display: flex; }
  .header-inner { flex-wrap: wrap; }
  .primary-menu-wrapper { display: none; width: 100%; order: 4; }
  .primary-menu-wrapper.open { display: block; }
  .primary-menu { flex-direction: column; }
  .primary-menu li ul { position: static; opacity: 1; pointer-events: auto; transform: none; border: none; margin-left: 1rem; }
}

/* --- BREAKING BAR (static) --- */
.ticker-bar {
  background: var(--red);
  color: #fff;
  padding: .4rem 0;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker-label {
  background: #fff;
  color: var(--red);
  padding: 0 .5rem;
  font-size: .72rem;
  letter-spacing: .08em;
  border-radius: 2px;
  margin-right: .75rem;
}

/* --- HERO --- */
.hero-section { margin-bottom: 2rem; }

/* CLS fix: aspect-ratio + explicit intrinsic size prevents layout shift */
.hero-post {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: block;
  /* Fixed aspect ratio so browser reserves space before image loads */
  aspect-ratio: 16 / 7;
  contain: layout paint style;
}
.hero-post img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* LCP optimization: no transition on the hero image */
  transition: none;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.88) 0%, rgba(0,0,0,.3) 60%, transparent 100%);
  pointer-events: none;
}
.hero-body {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 1.5rem 2rem 2rem;
  z-index: 1;
}
.hero-category {
  display: inline-block;
  background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .2rem .6rem; border-radius: 2px;
  margin-bottom: .6rem;
}
.hero-title {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  font-weight: 700; line-height: 1.15; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
  margin-bottom: .75rem;
}
.hero-meta { font-size: .75rem; color: rgba(255,255,255,.65); letter-spacing: .03em; }
.hero-meta span + span::before { content: ' · '; }

@media (max-width: 600px) {
  .hero-body { padding: 1rem 1rem 1.25rem; }
  .hero-post { aspect-ratio: 4/3; }
}

/* --- POSTS GRID --- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

/* CLS fix: cards have contain + fixed thumb ratio so no shift on image load */
.entry-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  contain: layout paint style;
  transition: border-color .2s;
}
.entry-item:hover { border-color: var(--red); }

/* CLS fix: aspect-ratio on thumb container */
.entry-item .entry-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
}
.entry-item .entry-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.entry-item .entry-body {
  padding: .9rem 1rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.entry-category {
  font-size: .67rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--red); margin-bottom: .35rem;
}
.entry-title {
  font-size: clamp(.9rem, 1.8vw, 1.05rem);
  font-weight: 700; line-height: 1.3;
  color: var(--text); margin-bottom: .5rem; flex: 1;
}
.entry-title a { color: inherit; }
.entry-title a:hover { color: var(--red); }
.entry-date { font-size: .7rem; color: var(--text-muted); letter-spacing: .03em; }

/* --- SECTION HEADINGS --- */
.section-heading {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .65rem;
}
.section-heading h2 {
  font-size: .85rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--text);
}
.section-heading::before {
  content: ''; display: block;
  width: 3px; height: 1.1rem;
  background: var(--red); border-radius: 2px; flex-shrink: 0;
}

/* --- SIDEBAR --- */
.widget-area { position: sticky; top: 1rem; }
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.2rem;
  contain: layout paint style;
}
.widget-title {
  font-size: .78rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--red); margin-bottom: .85rem;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}

/* Most Viewed Widget */
.most-viewed-list { display: flex; flex-direction: column; gap: .65rem; }
.most-viewed-item {
  display: flex; gap: .65rem; align-items: flex-start;
  padding-bottom: .65rem; border-bottom: 1px solid var(--border);
}
.most-viewed-item:last-child { border-bottom: none; padding-bottom: 0; }
.most-viewed-num {
  font-size: 1.4rem; font-weight: 700; color: var(--border);
  line-height: 1; min-width: 1.8rem;
}
/* CLS fix: fixed size thumb container */
.most-viewed-thumb-link {
  display: block; width: 64px; height: 48px; flex-shrink: 0; overflow: hidden;
}
.most-viewed-thumb-link img {
  width: 64px; height: 48px; object-fit: cover; border-radius: 2px;
}
.most-viewed-title {
  font-size: .78rem; font-weight: 600; line-height: 1.3; color: var(--text);
}
.most-viewed-title a:hover { color: var(--red); }
.most-viewed-date { font-size: .67rem; color: var(--text-muted); margin-top: .2rem; }

.widget-period-toggle { display: flex; gap: .35rem; margin-bottom: .9rem; }
.widget-period-toggle button {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font);
  font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; padding: .3rem .4rem;
  cursor: pointer; border-radius: 2px;
  transition: color .15s, border-color .15s;
}
.widget-period-toggle button.active { border-color: var(--red); color: var(--red); }

/* --- SINGLE POST --- */
/* CLS fix: aspect-ratio on hero */
.single-hero {
  position: relative; margin-bottom: 2rem;
  border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16 / 6;
  background: var(--bg-card);
  contain: layout paint;
}
.single-hero img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.single-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 60%);
}

.post-header { margin-bottom: 1.5rem; }
.post-category {
  display: inline-block; background: var(--red); color: #fff;
  font-size: .67rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; padding: .2rem .6rem;
  border-radius: 2px; margin-bottom: .7rem;
}
.post-title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700; line-height: 1.2; color: var(--text); margin-bottom: .75rem;
}
.post-meta {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  font-size: .75rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding-block: .65rem;
}
.post-meta .meta-author { color: var(--text); font-weight: 600; }

.post-content {
  font-size: 1.02rem; line-height: 1.75;
  color: #d8d8e8; max-width: 720px;
}
.post-content p { margin-bottom: 1.1rem; }
.post-content h2 {
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  margin: 2rem 0 .75rem; padding-left: .75rem;
  border-left: 3px solid var(--red);
}
.post-content h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 1.5rem 0 .5rem; }
.post-content a { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }
.post-content blockquote {
  border-left: 3px solid var(--red); margin: 1.5rem 0;
  padding: .75rem 1.25rem; background: var(--bg-card);
  color: var(--text-muted); font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}
/* CLS fix: inline images need width/height attrs — WordPress adds them automatically */
.post-content img { border-radius: var(--radius); margin-block: 1.5rem; height: auto; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.post-content ul li { list-style: disc; }
.post-content ol li { list-style: decimal; }
.post-content li { margin-bottom: .4rem; }

/* --- RELATED POSTS --- */
.related-section { margin-top: 2.5rem; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* --- PAGINATION --- */
.pagination {
  display: flex; justify-content: center; gap: .4rem;
  margin-top: 2rem; flex-wrap: wrap;
}
.pagination .page-numbers {
  display: flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 .5rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .82rem; color: var(--text);
  transition: border-color .15s, color .15s;
}
.pagination .page-numbers:hover,
.pagination .page-numbers.current { border-color: var(--red); color: var(--red); }

/* --- FOOTER --- */
.site-footer {
  background: var(--bg-card); border-top: 2px solid var(--red);
  padding-top: 2.5rem; margin-top: 3rem;
}
.footer-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem; padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.footer-credits {
  padding-block: 1.2rem; text-align: center;
  font-size: .72rem; color: var(--text-muted); letter-spacing: .03em;
}
.footer-credits a { color: var(--red); }

/* --- 404 --- */
.error-404 { text-align: center; padding: 4rem 1rem; }
.error-code { font-size: 7rem; font-weight: 700; color: var(--red); line-height: 1; opacity: .2; }
.error-404 h2 { font-size: 1.5rem; margin-bottom: 1rem; }

/* --- ARCHIVE --- */
.archive-header { padding: 1.5rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.archive-title { font-size: 1.3rem; font-weight: 700; }
.archive-title span { color: var(--red); }

/* --- SEARCH --- */
.search-header { margin-bottom: 1.5rem; font-size: 1rem; color: var(--text-muted); }
.search-header span { color: var(--text); font-weight: 700; }

/* --- COMMENTS --- */
.comments-area { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.comments-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.comment-list { display: flex; flex-direction: column; gap: 1rem; }
.comment-body { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.comment-author { font-size: .82rem; font-weight: 700; margin-bottom: .3rem; }
.comment-meta { font-size: .72rem; color: var(--text-muted); margin-bottom: .5rem; }
.comment-content { font-size: .9rem; line-height: 1.6; }
.comment-form-wrapper { margin-top: 1.5rem; }
.comment-form input,
.comment-form textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font); font-size: .9rem;
  padding: .6rem .8rem; border-radius: var(--radius); margin-bottom: .75rem; outline: none;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--red); }
.comment-form textarea { min-height: 120px; resize: vertical; }
.comment-form .submit-btn {
  background: var(--red); border: none; color: #fff;
  font-family: var(--font); font-size: .85rem; font-weight: 700;
  letter-spacing: .06em; padding: .65rem 1.5rem; cursor: pointer;
  border-radius: var(--radius); text-transform: uppercase; transition: background .2s;
}
.comment-form .submit-btn:hover { background: var(--red-dim); }

/* --- UTILITY --- */
.screen-reader-text {
  clip: rect(1px,1px,1px,1px); height: 1px;
  overflow: hidden; position: absolute; width: 1px; word-wrap: normal;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--red-dim); }

/* --- PRINT --- */
@media print {
  .site-header, .site-footer, .widget-area, .ticker-bar, .top-bar { display: none; }
  body { background: #fff; color: #000; }
  .post-content { max-width: 100%; }
}
