/* ===========================
   InfotecLive - styles.css (home layout + theme, 3x3 fijo)
   =========================== */

/* Tipografías serias tipo periódico */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700;900&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #555;
  --border: #e5e7eb;
  --brand: #0f766e;
  --brand-ink: #0b4e49;
  --accent: #000000;     /* Ahora todos los links son negros */
  --accent-weak: #f0f0f0;
  font-family: 'Source Sans 3', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- BARRA SUPERIOR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.topbar-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.topbar-link {
  color: #111;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 10px;
  border-radius: 4px;
  transition: background-color .15s ease, transform .1s ease;
}
.topbar-link:hover {
  background: var(--accent-weak);
  transform: translateY(-1px);
}
.topbar-link.active { background: #000; color: #fff; }

/* ---------- HEADER: logo + buscador ---------- */
.brand-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center; /* Logo centrado */
  position: relative;
}
.brand img {
  display: block;
  max-height: 56px;
}

/* buscador alineado a la derecha del contenedor */
.search-form {
  position: absolute;
  right: 16px; /* alineado con el padding del container */
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 220px;
}
.search-form button {
  padding: 8px 12px;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

/* Responsive: en móviles el buscador baja debajo del logo */
@media (max-width: 640px){
  .brand-inner{
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 8px;
    justify-items: center;
  }
  .search-form{
    position: static;
    width: 100%;
    max-width: 520px;
    justify-content: center;
  }
  .search-form input{ flex: 1 1 auto; min-width: 0; width: 70%; }
}

/* ---------- LAYOUT PRINCIPAL ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

/* ---------- TITULARES DE SECCIÓN ---------- */
.container > h1,
.home-main h1,
.home-aside h2 {
  font-family: 'Merriweather', Georgia, serif;
  color: #111;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.home-main h1 { font-size: 1.6rem; margin: 6px 0 14px; }
.home-aside h2 { font-size: 1.2rem; margin: 0 0 12px; }
.container > h1 { font-size: 2rem; margin: 8px 0 18px; }

/* ---------- CAJAS DE CONTENIDO ---------- */
.content-surface,
.home-main,
.home-aside,
.grid {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.home-main,
.home-aside { padding: 14px; }
.grid { padding: 8px; }

/* -------- HOME LAYOUT (dos columnas) -------- */
.home-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.home-main  { flex: 0 0 72%; }
.home-aside { flex: 1; }

@media (max-width: 960px) {
  .home-layout { flex-direction: column; }
  .home-main, .home-aside { flex: none; width: 100%; }
}

/* -------- GRID -------- */
.grid { display: grid; gap: 18px; }
.grid-3x3-lg { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-3x3-lg { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .grid-3x3-lg { grid-template-columns: 1fr; } }

/* -------- TARJETAS -------- */
.card-lg {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card-lg:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}
.card-media-wrap {
  width: 100%;
  aspect-ratio: 16/9;
  background: #eee;
  overflow: hidden;
}
.card-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-body { padding: 12px 14px 16px; }
.card-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 1.2rem;
  margin: 6px 0 8px;
  line-height: 1.3;
  color: #111;
}
.card-lg .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.card-lg .excerpt {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -------- ASIDE: lista vertical -------- */
.news-list-compact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.news-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: background-color .15s ease, transform .15s ease;
}
.news-item:hover { background: #f9f9f9; transform: translateY(-1px); }

.news-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  padding: 6px 8px;
}
.news-row .thumb {
  width: 64px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: #eee;
  flex-shrink: 0;
}
.news-meta { display: flex; flex-direction: column; justify-content: center; }
.news-title { font-size: 0.9rem; font-weight: 600; color: #111; line-height: 1.3; }
.news-sub { font-size: 0.8rem; color: var(--muted); }
.news-sub .chip {
  background: #eee;
  color: #111;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-right: 6px;
}

/* ---------- PAGINACIÓN ---------- */
.pagination {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 24px 0 8px;
}
.pagination a {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #111;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color .15s ease, transform .1s ease;
  text-decoration: none;
}
.pagination a:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}
.pagination a[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

/* ---------- FOOTER ---------- */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- BACKGROUNDS TEMÁTICOS ---------- */
body.theme-home {
  background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_home.png") repeat center top / 500px auto;
}
body.theme-cat-tecnologia { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_tecnologia.png") repeat center top / 500px auto; }
body.theme-cat-deportes { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_deportes.png") repeat center top / 500px auto; }
body.theme-cat-actualidad { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_actualidad.png") repeat center top / 500px auto; }
body.theme-cat-politica { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_politica.png") repeat center top / 500px auto; }
body.theme-cat-videojuegos { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_videojuegos.png") repeat center top / 500px auto; }
body.theme-cat-ciencia { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_ciencia.png") repeat center top / 500px auto; }
body.theme-cat-economia { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_economia.png") repeat center top / 500px auto; }
body.theme-cat-cine-tv { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_cine.png?v=1") repeat center top / 500px auto; }
body.theme-cat-salud { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_salud.png") repeat center top / 500px auto; }
body.theme-cat-entretenimiento { background: url("https://nsfdrozplielcaukfmwj.supabase.co/storage/v1/object/public/news-covers/background_entretenimiento.png") repeat center top / 500px auto; }
/* Apagar los fondos de todas las páginas con tema */
body[class^="theme-cat-"],
body.theme-home {
  background-color: rgba(255,255,255,0.75); /* capa blanca encima */
  background-blend-mode: lighten;           /* mezcla imagen + blanco */
}

/* ============================================
   PÁGINA DE ARTÍCULO (tipografía, hero, media)
   ============================================ */

.post{
  max-width: 860px;
  margin: 0 auto;
  padding: 4px 0 40px;
}
.post .breadcrumb{
  font-size: .9rem;
  color: var(--muted);
  margin: 4px 0 10px;
}
.post .breadcrumb a{ color: var(--muted); }
.post h1{
  font-family: 'Merriweather', Georgia, serif;
  font-weight: 900;
  letter-spacing: -0.01em;
  font-size: 2rem;
  line-height: 1.2;
  color: #111;
  margin: 10px 0 6px;
}
.post .meta{
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 14px;
}

/* Hero MUCHO más pequeño */
.post > figure{
  width: 100%;
  height: clamp(180px, 26vw, 340px); /* tamaño controlado */
  aspect-ratio: 21/9;
  overflow: hidden;
  border-radius: 12px;
  background: #eee;
  margin: 0 0 16px;
}
.post > figure img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 640px){
  .post{ padding: 2px 0 32px; }
  .post h1{ font-size: 1.6rem; }
  .post > figure{
    height: clamp(140px, 36vw, 240px);
    aspect-ratio: auto; /* prioridad al alto */
  }
}

/* Cuerpo del artículo */
.post .content{
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
  margin-top: 2px;
}
.post .content p{ margin: 0 0 1.1em; }
.post .content h2{
  font-family: 'Merriweather', Georgia, serif;
  font-weight: 700;
  font-size: 1.5rem;
  margin: 1.5em 0 .6em;
}
.post .content h3{
  font-family: 'Merriweather', Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  margin: 1.2em 0 .5em;
}

/* Imágenes y figuras dentro del contenido */
.post .content img{
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
  border-radius: 8px;
}
.post .content figure{ margin: 1rem 0; }

/* Listas, citas y tablas */
.post .content ul,
.post .content ol{ padding-left: 1.25rem; }
.post .content blockquote{
  border-left: 4px solid var(--border);
  padding: .75rem 1rem;
  background: #fafafa;
  color: #333;
  margin: 1rem 0;
}
.post .content table{
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .95rem;
  overflow-x: auto;
  display: block;
}
.post .content th,
.post .content td{
  border: 1px solid var(--border);
  padding: .5rem .6rem;
  white-space: normal;
}

/* Código y pre */
.post .content code{
  background: #f3f4f6;
  padding: .15rem .35rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.post .content pre{
  background: #0b0b0b;
  color: #e5e7eb;
  padding: 1rem;
  overflow: auto;
  border-radius: 8px;
}

/* Media embebido (por defecto) */
.post .content iframe,
.post .content video{
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  display: block;
  border: 0;
  border-radius: 8px;
}

/* --------- ADICIONES ÚTILES (faltaban) --------- */

/* Pies de foto */
.post .content figcaption{
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
}

/* Helpers de ratio para no forzar 16:9 si no quieres
   Uso: <div class="ratio ratio-4x3"><iframe ...></iframe></div> */
.ratio { position: relative; width: 100%; }
.ratio > iframe, .ratio > video, .ratio > embed {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; border-radius: 8px;
}
.ratio-16x9 { padding-top: 56.25%; }
.ratio-4x3  { padding-top: 75%; }
