/* ============================================================
   NoticiasDe — Portal Público
   ============================================================ */

:root {
  --orange:  #f89935;
  --bg:      #fef3e6;
  --card:    #ffffff;
  --text:    #2a1a00;
  --muted:   #9a7550;
  --border:  #f0d9b0;
  --shadow:  0 2px 10px rgba(0,0,0,0.07);
  --radius:  8px;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Cabecera ─────────────────────────────────────────────── */
.pueblo-header {
  text-align: center;
  padding: 1.75rem 1rem 1.25rem;
  border-bottom: 3px solid var(--orange);
  background: var(--bg);
}

.pueblo-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 900;
  color: var(--orange);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.pueblo-header .subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ── Contenido principal ──────────────────────────────────── */
main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ── Grid de noticias ─────────────────────────────────────── */
.noticias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.noticias-grid .noticia-hero {
  grid-column: 1 / -1;
}

/* ── Tarjetas ─────────────────────────────────────────────── */
.noticia-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.noticia-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(248,153,53,0.15);
}

.noticia-content {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.noticia-card img {
  width: calc(100% + 2.2rem);
  margin: -1.1rem -1.1rem 1rem;
  max-width: none;
  height: 190px;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 0.3s;
}

.noticia-card:hover img { transform: scale(1.03); }

/* Noticia principal (hero) */
.noticia-hero img { height: 360px; }

@media (min-width: 600px) {
  .noticia-hero img { height: 420px; }
  .noticia-hero h3  { font-size: 1.35rem; }
}

/* Metadatos */
.noticia-meta { margin-bottom: 0.45rem; }

.noticia-date {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--orange);
}

/* Ocultar información secundaria */
.reading-time,
.source-badge { display: none; }

.noticia-card h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.noticia-resumen {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Acciones */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.btn-leer-mas {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--orange);
  text-decoration: none;
  transition: opacity 0.2s;
}

.btn-leer-mas:hover { opacity: 0.7; }

.btn-load-more {
  display: inline-block;
  padding: 0.65rem 2.25rem;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-load-more:hover { opacity: 0.85; transform: scale(1.02); }

.card-share-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #25d366;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.card-share-btn:hover { background: #25d366; color: #fff; border-color: #25d366; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,10,0,0.72);
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem 1rem 3rem;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-content {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 760px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.2s;
}

.modal-close:hover { background: var(--border); }

.modal-date {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--orange);
  margin-bottom: 0.4rem;
}

.modal-title {
  font-size: clamp(1.15rem, 3vw, 1.6rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  padding-right: 2.5rem;
}

.modal-reading-time,
#modalSourceName { display: none; }

.modal-body { padding: 1.25rem 1.75rem; }

.modal-image {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 1.25rem;
  display: block;
}

.modal-text p {
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.75;
  color: #3a2a10;
}

.modal-text p:last-child { margin-bottom: 0; }

.modal-footer-share {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.75rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg);
}

.share-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: opacity 0.2s;
  font-family: var(--font);
}

.share-btn:hover       { opacity: 0.82; }
.share-btn svg         { width: 15px; height: 15px; flex-shrink: 0; }
.share-btn.whatsapp    { background: #25d366; color: #fff; }
.share-btn.twitter     { background: #000;    color: #fff; }
.share-btn.copy        { background: var(--border); color: var(--text); }
.share-btn.copy.copied { background: #27ae60; color: #fff; }

.modal-source {
  padding: 0.5rem 1.75rem 0.85rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
}

.modal-source a { color: var(--orange); text-decoration: none; word-break: break-all; }
.modal-source a:hover { text-decoration: underline; }

/* ── Pie de página ────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

footer p { margin-bottom: 0.2rem; }
footer p:last-child { margin-bottom: 0; }

.admin-link a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.admin-link a:hover { opacity: 1; }

/* ── Volver arriba ────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  background: var(--orange);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 500;
  box-shadow: 0 4px 12px rgba(248,153,53,0.4);
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover   { opacity: 0.85; }

/* ── Skeleton ─────────────────────────────────────────────── */
.skeleton-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.skeleton {
  background: linear-gradient(90deg, #f7e5c8 25%, #eed9a8 50%, #f7e5c8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.skeleton-img        { height: 190px; display: block; border-radius: 0; width: 100%; }
.skeleton-title      { height: 15px; margin: 1rem 1.1rem 0.5rem; width: 85%; }
.skeleton-title-short { height: 15px; margin: 0 1.1rem 0.9rem; width: 55%; }
.skeleton-text       { height: 12px; margin: 0 1.1rem 0.4rem; }
.skeleton-text-short  { height: 12px; margin: 0 1.1rem; width: 65%; }

/* ── Estado vacío ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
  grid-column: 1 / -1;
}

.empty-state h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.empty-state p  { font-size: 0.9rem; max-width: 400px; margin: 0 auto; }

/* ── Responsive ───────────────────────────────────────────── */

/* ── Tablet (≤ 768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
  .noticias-grid { gap: 1rem; }
  .noticia-hero img { height: 280px; }
  .modal-overlay { padding: 1rem 0.75rem 2rem; }
  .modal-content { border-radius: 8px; }
}

/* ── Móvil (≤ 480px) ──────────────────────────────────────── */
@media (max-width: 480px) {
  /* Cabecera */
  .pueblo-header { padding: 1.25rem 1rem 1rem; }
  .pueblo-header h1 { font-size: clamp(1.5rem, 8vw, 2rem); }
  .pueblo-header .subtitle { font-size: 0.82rem; }

  /* Grid */
  main { padding: 1rem 0.75rem 2rem; }
  .noticias-grid { gap: 0.75rem; }
  .noticias-grid .noticia-hero { grid-column: auto; }
  .noticia-hero img { height: 220px; }
  .noticia-card img { height: 170px; }

  /* Tarjetas */
  .noticia-content { padding: 0.9rem; }
  .noticia-card h3 { font-size: 0.95rem; }

  /* Modal: desliza desde abajo (sheet) */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-content { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
  .modal-header { padding: 1.25rem 1rem 0.75rem; }
  .modal-body { padding: 1rem; }
  .modal-footer-share { padding: 0.75rem 1rem; gap: 0.4rem; }
  .modal-source { padding: 0.4rem 1rem 0.75rem; }
  .modal-title { font-size: clamp(1.05rem, 5vw, 1.3rem); padding-right: 2.5rem; }
  .modal-image { max-height: 240px; }

  /* Compartir */
  .share-btn { padding: 0.45rem 0.7rem; font-size: 0.75rem; }

  /* Botón volver arriba */
  .back-to-top { bottom: 1rem; right: 1rem; width: 38px; height: 38px; font-size: 1.1rem; }

  /* Footer */
  footer { font-size: 0.78rem; padding: 1rem; }
}

/* ── Móvil pequeño (≤ 360px) ─────────────────────────────── */
@media (max-width: 360px) {
  .pueblo-header h1 { font-size: 1.4rem; }
  .noticia-card img { height: 150px; }
  .modal-image { max-height: 180px; }
}
