/**
 * Grouvel - Styles de l'agrégateur de news (news.html)
 * Couvre : layout, skeletons de chargement, filtres, liste d'articles.
 */

:root {
  color-scheme: light dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family, "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif);
  background: var(--color-bg-gradient);
  color: var(--color-text-primary);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
header {
  text-align: center;
  padding: 36px 16px 12px;
}
h1 {
  font-size: 2.6rem;
  margin: 0;
  color: var(--color-text-primary);
}
header p {
  margin: 0.8em auto 1.6em;
  max-width: 680px;
  color: var(--color-text-secondary);
  font-size: 1.05rem;
}
.header-actions {
  display: flex;
  gap: 0.8em;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
a.back, button.refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.6em 1.5em;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.25s ease-in-out;
  box-shadow: var(--shadow-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}
a.back:hover, button.refresh:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}
button.refresh:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
button.refresh.loading .refresh-icon {
  animation: spin 0.8s linear infinite;
}

main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

section#news {
  background: var(--color-bg-white);
  border-radius: 18px;
  padding: 2.2em;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(128,128,128,0.1);
}
section#news h2 {
  margin-top: 0;
  text-align: center;
  color: var(--color-text-primary);
  font-size: 2rem;
}
section#news .intro {
  text-align: center;
  color: var(--color-text-secondary);
  margin: 0.4em 0 1.6em;
  font-size: 1rem;
}
.notice {
  text-align: center;
  margin-bottom: 1em;
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
}
.notice.err {
  color: var(--color-error);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 122, 255, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton-item {
  background: var(--color-bg-white);
  border-radius: 14px;
  padding: 0 0 1em;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  overflow: hidden;
}
.skeleton-thumb, .skeleton-title, .skeleton-meta {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
.skeleton-thumb {
  aspect-ratio: 16 / 9;
  width: 100%;
  margin-bottom: 0.9em;
}
.skeleton-title, .skeleton-meta {
  border-radius: 4px;
  margin-left: 1.1em;
  margin-right: 1.1em;
}
.skeleton-title {
  height: 1.1em;
  width: 85%;
  margin-bottom: 0.6em;
}
.skeleton-title--short {
  width: 60%;
}
.skeleton-meta {
  height: 0.9em;
  width: 40%;
}
.feed-progress {
  display: flex;
  gap: 0.4em;
  justify-content: center;
  margin-bottom: 0.8em;
  flex-wrap: wrap;
}
.feed-progress-text {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}
.feed-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
  transition: background 0.3s ease;
}
.feed-dot.loading {
  background: #007aff;
  animation: pulse 1s infinite;
}
.feed-dot.done {
  background: #34c759;
}
.feed-dot.error {
  background: #ff3b30;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@media (prefers-color-scheme: dark) {
  .skeleton-item {
    background: var(--color-bg-card, #1e1e2e);
    border-color: rgba(255,255,255,0.06);
  }
  .skeleton-thumb, .skeleton-title, .skeleton-meta {
    background: linear-gradient(90deg, #2a2a3a 25%, #353548 50%, #2a2a3a 75%);
    background-size: 200% 100%;
  }
  .feed-dot {
    background: #3a3a4a;
  }
  input.news-search {
    border-color: rgba(255,255,255,0.15);
  }
  .news-thumb-wrap {
    background: #2a2a3a;
  }
  .news-card:hover,
  .news-featured:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  }
}
/* === Barre de recherche === */
.news-controls {
  position: relative;
  max-width: 480px;
  margin: 0 auto 1.2em;
}
.news-search-icon {
  position: absolute;
  left: 0.9em;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  opacity: 0.7;
}
input.news-search {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.7em 1em 0.7em 2.6em;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(128,128,128,0.3);
  background: var(--color-bg-white);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input.news-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
input.news-search::placeholder {
  color: var(--color-text-muted);
}

/* === Onglets thématiques === */
.news-themes {
  display: none;
  flex-wrap: wrap;
  gap: 0.5em;
  justify-content: center;
  align-items: center;
  margin: 0 0 1.5em;
}
.news-theme-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 1em;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-text-disabled);
  background: transparent;
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.news-theme-tab:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.news-theme-tab.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}
.news-theme-tab.active:hover {
  background: var(--color-primary-hover);
}

/* === Article « À la une » === */
.news-featured {
  margin-bottom: 1.6em;
}
.news-featured[hidden] {
  display: none;
}
.news-featured .news-card--hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: stretch;
}
.news-card--hero .news-thumb-wrap {
  aspect-ratio: auto;
  height: 100%;
  min-height: 240px;
}
.news-card--hero .news-thumb,
.news-card--hero .news-thumb-placeholder {
  height: 100%;
}
.news-card--hero .news-card-body {
  padding: 1.6em;
  gap: 0.7em;
  justify-content: center;
}
.news-card--hero .news-card-title {
  font-size: 1.5rem;
  line-height: 1.25;
}
.news-card--hero .news-excerpt {
  font-size: 1rem;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

/* === Grille de cartes === */
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2em;
}
.news-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  border: 1px solid rgba(128,128,128,0.1);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, opacity 0.2s ease;
}
.news-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
}
.news-thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
  background: var(--color-bg-light);
}
.news-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.news-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  opacity: 0.85;
}
.news-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  padding: 1em 1.1em 1.1em;
  flex: 1;
}
.news-card-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--color-text-primary);
  text-decoration: none;
}
.news-card-title:hover {
  color: var(--color-primary);
  text-decoration: underline;
}
.news-excerpt {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--color-text-secondary);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.news-card.is-read {
  opacity: 0.55;
}
.news-card.is-read .news-card-title {
  color: var(--color-text-muted);
  font-weight: 600;
}
.news-empty {
  grid-column: 1 / -1;
  padding: 1.2em;
  border-radius: 12px;
  background: var(--color-bg-white);
  border: 1px dashed rgba(128,128,128,0.3);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}
.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  align-items: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: auto;
}

/* === Bouton « Charger plus » === */
.news-loadmore-wrap {
  text-align: center;
  margin-top: 1.6em;
}
.news-loadmore {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7em 1.8em;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.news-loadmore:hover {
  background: var(--color-primary);
  color: #fff;
  transform: translateY(-2px);
}
.news-loadmore[hidden] {
  display: none;
}
.news-source {
  padding: 0.25em 0.7em;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  letter-spacing: 0.01em;
}
.source-note {
  margin-top: 1.8em;
  font-size: 0.88rem;
  text-align: center;
  color: var(--color-text-muted);
}
footer {
  text-align: center;
  padding: 20px 10px 28px;
  font-size: 0.9rem;
  color: var(--color-text-disabled);
}

@media (max-width: 640px) {
  section#news {
    padding: 1.4em 1.1em;
  }
  /* Grille en une seule colonne */
  .news-list {
    grid-template-columns: 1fr;
    gap: 1em;
  }
  /* Le hero s'empile (image au-dessus du texte) */
  .news-featured .news-card--hero {
    grid-template-columns: 1fr;
  }
  .news-card--hero .news-thumb-wrap {
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
  }
  .news-card--hero .news-card-body {
    padding: 1.1em;
  }
  .news-card--hero .news-card-title {
    font-size: 1.25rem;
  }
  /* Onglets : défilement horizontal au lieu de retour à la ligne */
  .news-themes {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.3em;
  }
  .news-themes::-webkit-scrollbar {
    display: none;
  }
  .news-theme-tab {
    min-height: 44px;
    font-size: 0.88rem;
  }
  input.news-search {
    font-size: 16px; /* évite le zoom auto iOS */
    min-height: 44px;
  }
  .news-loadmore {
    width: 100%;
    min-height: 44px;
  }
  header {
    padding-top: 28px;
    padding-bottom: 8px;
  }
  h1 {
    font-size: 2rem;
  }
}
