/* =============================================
   CodeToFun — News (/news)
   Mobile-first editorial listing
   Uses home.css for header/footer; this file is content-only.
   ============================================= */

.news-page {
  background: #fff;
  color: #111;
  overflow-x: clip;
}

.news-main {
  padding: 0 0 calc(2.5rem + env(safe-area-inset-bottom, 0px));
}

.news-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.35rem max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
}

/* ---------- Title / lead / breadcrumb (mobile base) ---------- */
.news-page-title {
  margin: 0 auto 0.65rem;
  text-align: center;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1.75rem, 7.5vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: #111;
  text-wrap: balance;
}

.news-lead {
  max-width: 40rem;
  margin: 0 auto 1rem;
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: #555;
  text-wrap: pretty;
}

.news-breadcrumb {
  margin: 0 auto 1.15rem;
}

.news-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.25rem 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: #6b6b6b;
}

.news-breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: 0.4rem;
  color: #bbb;
}

.news-breadcrumb a {
  color: #2563eb;
  text-decoration: none;
  padding: 0.15rem 0;
}

.news-breadcrumb a:hover {
  text-decoration: underline;
}

.news-breadcrumb [aria-current="page"] {
  color: #111;
  font-weight: 500;
}

/* ---------- Category filters: horizontal snap scroll on mobile ---------- */
.news-filters-wrap {
  position: relative;
  margin: 0 -1rem 1.15rem;
  padding: 0;
}

.news-filters-wrap::before,
.news-filters-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0.35rem;
  width: 1.25rem;
  z-index: 1;
  pointer-events: none;
}

.news-filters-wrap::before {
  left: 0;
  background: linear-gradient(90deg, #fff 20%, transparent);
}

.news-filters-wrap::after {
  right: 0;
  background: linear-gradient(270deg, #fff 20%, transparent);
}

.news-filters {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0.45rem;
  max-width: none;
  margin: 0;
  padding: 0.15rem 1rem 0.55rem;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 1rem;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.news-filters::-webkit-scrollbar {
  display: none;
}

.news-filters > li {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.news-filter-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  margin: 0;
  padding: 0.5rem 0.95rem;
  border: none;
  border-radius: 999px;
  background: #f0f0f0;
  color: #111;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, color 0.18s ease;
}

.news-filter-btn:active {
  background: #e4e4e4;
}

.news-filter-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.news-filter-btn.is-active {
  background: #111;
  color: #fff;
}

.news-filter-btn.is-active:active {
  background: #222;
}

/* "All" chip — default control, visually distinct from category chips */
.news-filter-btn--all {
  background: #fff;
  color: #0f172a;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1.5px solid #2563eb;
  box-shadow: 0 1px 0 rgba(37, 99, 235, 0.12);
  padding-inline: 1.1rem;
}

.news-filter-btn--all:active {
  background: #eff6ff;
}

.news-filter-btn--all.is-active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.news-filter-btn--all.is-active:active {
  background: #1d4ed8;
}

/* ---------- Results + pagination bar ---------- */
.news-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0.85rem 0;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 1.25rem;
}

.news-results-meta {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #555;
  font-variant-numeric: tabular-nums;
}

.news-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  width: 100%;
}

.news-pager-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 2.5rem;
  min-width: 6.5rem;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.45rem;
  background: #fff;
  color: #111;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease, opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.news-pager-btn:active:not(:disabled) {
  background: #f8fafc;
}

.news-pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.news-pager-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.news-pager-sep {
  display: none;
}

/* ---------- Section heading ---------- */
.news-section-title {
  margin: 0 0 1.15rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #111;
}

/* ---------- Article grid: 1 col mobile ---------- */
.news-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 0.45rem;
}

.news-card[hidden] {
  display: none !important;
}

.news-card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  color: inherit;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0.45rem;
}

.news-card-link:focus-visible .news-card-media {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.news-card-link:active .news-card-title {
  color: #2563eb;
}

.news-card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 0.4rem;
  background: #f3f3f3;
  margin-bottom: 0.75rem;
}

.news-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-card-media .news-card-image--contain {
  object-fit: contain;
  background: #f4fff7;
}

.news-card-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: #111;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card-date {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  color: #6b6b6b;
}

.news-card-tag {
  display: inline-flex;
  align-self: flex-start;
  margin-top: auto;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: #f0f0f0;
  color: #222;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  pointer-events: none;
}

.news-empty {
  display: none;
  margin: 1.5rem 0 0;
  padding: 1.75rem 1rem;
  text-align: center;
  color: #555;
  font-size: 0.9375rem;
  border: 1px dashed #ddd;
  border-radius: 0.5rem;
}

.news-empty.is-visible {
  display: block;
}

.news-toolbar--bottom {
  margin-top: 1.75rem;
  margin-bottom: 0;
}

/* ---------- Small phones landscape / slightly wider phones ---------- */
@media (min-width: 480px) {
  .news-shell {
    padding-top: 1.6rem;
  }

  .news-lead {
    font-size: 1rem;
  }

  .news-grid {
    gap: 1.75rem;
  }

  .news-section-title {
    font-size: 1.5rem;
  }
}

/* ---------- Tablet: 2 columns ---------- */
@media (min-width: 640px) {
  .news-shell {
    padding: 2rem 1.25rem 0;
  }

  .news-filters-wrap {
    margin: 0 auto 1.35rem;
  }

  .news-filters-wrap::before,
  .news-filters-wrap::after {
    display: none;
  }

  .news-filters {
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
    scroll-snap-type: none;
    max-width: 58rem;
    margin: 0 auto;
    padding: 0;
    gap: 0.5rem 0.55rem;
  }

  .news-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1.5rem;
  }

  .news-results-meta {
    font-size: 0.875rem;
  }

  .news-pager {
    width: auto;
    justify-content: flex-end;
    gap: 0.15rem;
  }

  .news-pager-btn {
    min-width: 0;
    min-height: 2.25rem;
    border: none;
    border-radius: 0.25rem;
    padding: 0.35rem 0.55rem;
    background: transparent;
  }

  .news-pager-sep {
    display: block;
    width: 1px;
    height: 0.9rem;
    background: #d4d4d4;
    margin: 0 0.15rem;
  }

  .news-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem 1.25rem;
  }

  .news-toolbar--bottom {
    margin-top: 2.25rem;
  }
}

/* ---------- Large tablet / small desktop: 3 columns ---------- */
@media (min-width: 768px) {
  .news-main {
    padding-bottom: 3.5rem;
  }

  .news-shell {
    padding: 2.75rem 1.5rem 0;
  }

  .news-page-title {
    margin-bottom: 0.85rem;
  }

  .news-lead {
    margin-bottom: 1.15rem;
    font-size: 1.05rem;
  }

  .news-breadcrumb {
    margin-bottom: 1.35rem;
  }

  .news-breadcrumb ol {
    font-size: 0.875rem;
  }

  .news-filters-wrap {
    margin-bottom: 1.5rem;
  }

  .news-section-title {
    margin-bottom: 1.35rem;
    font-size: 1.65rem;
  }

  .news-card-title {
    font-size: 1.05rem;
  }
}

@media (min-width: 960px) {
  .news-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem 1.35rem;
  }
}

/* ---------- Desktop: 4 columns ---------- */
@media (min-width: 1120px) {
  .news-shell {
    padding-top: 3.25rem;
  }

  .news-section-title {
    font-size: 1.875rem;
  }

  .news-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2.25rem 1.35rem;
  }
}

/* ---------- Hover effects only when a real pointer can hover ---------- */
@media (hover: hover) and (pointer: fine) {
  .news-filter-btn:hover {
    background: #e4e4e4;
  }

  .news-filter-btn.is-active:hover {
    background: #222;
  }

  .news-filter-btn--all:hover {
    background: #eff6ff;
    border-color: #1d4ed8;
  }

  .news-filter-btn--all.is-active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
  }

  .news-pager-btn:hover:not(:disabled) {
    color: #2563eb;
  }

  .news-card {
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .news-card:hover {
    transform: translateY(-4px);
  }

  .news-card-media {
    box-shadow: 0 0 0 0 transparent;
    transition:
      box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .news-card-media img {
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .news-card-title {
    transition: color 0.2s ease;
  }

  .news-card-tag {
    transition: background 0.2s ease, color 0.2s ease;
  }

  .news-card-link:hover .news-card-media {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  }

  .news-card-link:hover .news-card-media img {
    transform: scale(1.045);
  }

  .news-card-link:hover .news-card-title {
    color: #2563eb;
  }

  .news-card-link:hover .news-card-tag {
    background: #e8f0fe;
    color: #1d4ed8;
  }
}

@media (prefers-reduced-motion: reduce) {
  .news-card,
  .news-card-media,
  .news-card-media img,
  .news-card-title,
  .news-card-tag,
  .news-filter-btn,
  .news-pager-btn {
    transition: none !important;
  }

  .news-card:hover {
    transform: none;
  }

  .news-card-link:hover .news-card-media img {
    transform: none;
  }
}
