/* ============================================================
   Daily News — Elderly-Friendly Google News Style
   Base font: 18px | Headlines: 24-32px | High contrast
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #1a73e8;
  --blue-dark:   #1557b0;
  --blue-light:  #e8f0fe;
  --text:        #202124;
  --text-muted:  #5f6368;
  --bg:          #f1f3f4;
  --card-bg:     #ffffff;
  --border:      #dadce0;
  --red:         #d93025;
  --green:       #188038;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(0,0,0,.12);
  --shadow-hover:0 4px 16px rgba(0,0,0,.18);
  --header-h:    68px;
  --font:        'Google Sans', 'Segoe UI', Arial, sans-serif;
}

html { font-size: 18px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background:  var(--bg);
  color:       var(--text);
  line-height: 1.6;
  min-height:  100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Header / Navigation ──────────────────────────────────── */
.site-header {
  position:   sticky;
  top:        0;
  z-index:    100;
  height:     var(--header-h);
  background: var(--card-bg);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  display:    flex;
  align-items: center;
  padding:    0 24px;
  gap:        16px;
}

.site-logo {
  display:    flex;
  align-items: center;
  gap:        10px;
  font-size:  1.5rem;
  font-weight: 700;
  color:      var(--blue);
  white-space: nowrap;
  flex-shrink: 0;
}

.site-logo svg {
  width: 36px; height: 36px; flex-shrink: 0;
}

.header-date {
  font-size:  0.95rem;
  color:      var(--text-muted);
  flex-grow:  1;
  text-align: right;
  white-space: nowrap;
}

/* ── Category tab bar ─────────────────────────────────────── */
.category-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }

.category-tabs {
  display:   flex;
  padding:   0 16px;
  gap:       4px;
  min-width: max-content;
}

.cat-btn {
  padding:       10px 20px;
  border:        none;
  background:    transparent;
  font-family:   var(--font);
  font-size:     1rem;
  font-weight:   500;
  color:         var(--text-muted);
  cursor:        pointer;
  border-bottom: 3px solid transparent;
  transition:    color .15s, border-color .15s;
  white-space:   nowrap;
}
.cat-btn:hover  { color: var(--blue); }
.cat-btn.active {
  color:        var(--blue);
  border-color: var(--blue);
  font-weight:  700;
}

/* ── Main layout ──────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin:    0 auto;
  padding:   24px 16px 48px;
}

/* ── Section heading ──────────────────────────────────────── */
.section-heading {
  font-size:   1.4rem;
  font-weight: 700;
  color:       var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue);
  display:     inline-block;
}

/* ── News grid ────────────────────────────────────────────── */
.news-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap:                   20px;
  margin-bottom:         32px;
}

/* ── Article card ─────────────────────────────────────────── */
.news-card {
  background:    var(--card-bg);
  border-radius: var(--radius);
  box-shadow:    var(--shadow);
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
  cursor:        pointer;
  transition:    box-shadow .2s, transform .2s;
  text-decoration: none;
  color:         inherit;
}
.news-card:hover {
  box-shadow: var(--shadow-hover);
  transform:  translateY(-2px);
  text-decoration: none;
}
.news-card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

/* Card image */
.card-img-wrap {
  position:       relative;
  width:          100%;
  padding-bottom: 56.25%; /* 16:9 */
  overflow:       hidden;
  background:     var(--bg);
  flex-shrink:    0;
}
.card-img-wrap img {
  position:   absolute;
  inset:      0;
  width:      100%;
  height:     100%;
  object-fit: cover;
  transition: transform .3s;
}
.news-card:hover .card-img-wrap img {
  transform: scale(1.03);
}

/* Category colour-coded placeholder when no image */
.card-img-placeholder {
  position:    absolute;
  inset:       0;
  display:     flex;
  align-items: center;
  justify-content: center;
  font-size:   3rem;
}

/* Card body */
.card-body {
  padding:       16px 18px 20px;
  flex-grow:     1;
  display:       flex;
  flex-direction: column;
  gap:           8px;
}

.card-meta {
  display:     flex;
  align-items: center;
  gap:         8px;
  flex-wrap:   wrap;
}

.category-badge {
  font-size:     0.75rem;
  font-weight:   700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding:       3px 9px;
  border-radius: 20px;
  background:    var(--blue-light);
  color:         var(--blue-dark);
  white-space:   nowrap;
}

.card-source {
  font-size:  0.85rem;
  color:      var(--text-muted);
}

.card-time {
  font-size:  0.85rem;
  color:      var(--text-muted);
  margin-left: auto;
}

.card-title {
  font-size:   1.2rem;
  font-weight: 700;
  line-height: 1.35;
  color:       var(--text);
}

.card-summary {
  font-size:  1rem;
  color:      var(--text-muted);
  line-height: 1.55;
  /* clamp to 3 lines */
  display:            -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow:           hidden;
}

.card-read-more {
  margin-top: auto;
  font-size:  0.95rem;
  font-weight: 600;
  color:      var(--blue);
}

/* ── Load more button ─────────────────────────────────────── */
.load-more-wrap {
  text-align: center;
  margin-top: 8px;
}

.btn-load-more {
  padding:       14px 40px;
  font-family:   var(--font);
  font-size:     1.05rem;
  font-weight:   600;
  background:    var(--blue);
  color:         #fff;
  border:        none;
  border-radius: 28px;
  cursor:        pointer;
  box-shadow:    var(--shadow);
  transition:    background .15s, box-shadow .15s;
}
.btn-load-more:hover {
  background:  var(--blue-dark);
  box-shadow:  var(--shadow-hover);
}
.btn-load-more:disabled {
  background: var(--text-muted);
  cursor:     not-allowed;
}

/* ── Status messages ──────────────────────────────────────── */
.status-msg {
  text-align:  center;
  padding:     48px 16px;
  color:       var(--text-muted);
  font-size:   1.1rem;
}
.status-msg.error { color: var(--red); }

.spinner {
  display:    inline-block;
  width:      40px;
  height:     40px;
  border:     4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation:  spin .7s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Last updated bar ─────────────────────────────────────── */
.last-updated {
  text-align:  center;
  font-size:   0.9rem;
  color:       var(--text-muted);
  margin-bottom: 16px;
}

/* ════════════════════════════════════════════════════════════
   Article detail page
   ════════════════════════════════════════════════════════════ */
.article-page {
  max-width:  820px;
  margin:     0 auto;
  padding:    28px 16px 64px;
}

.btn-back {
  display:     inline-flex;
  align-items: center;
  gap:         6px;
  padding:     10px 20px;
  font-family: var(--font);
  font-size:   1rem;
  font-weight: 600;
  color:       var(--blue);
  background:  var(--blue-light);
  border:      none;
  border-radius: 24px;
  cursor:      pointer;
  margin-bottom: 24px;
  transition:  background .15s;
}
.btn-back:hover { background: #d2e3fc; text-decoration: none; }

.article-category-badge {
  display:      inline-block;
  font-size:    0.8rem;
  font-weight:  700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding:      4px 12px;
  border-radius: 20px;
  background:   var(--blue-light);
  color:        var(--blue-dark);
  margin-bottom: 14px;
}

.article-title {
  font-size:   2rem;
  font-weight: 800;
  line-height: 1.25;
  color:       var(--text);
  margin-bottom: 14px;
}

.article-meta {
  display:     flex;
  align-items: center;
  gap:         12px;
  font-size:   0.95rem;
  color:       var(--text-muted);
  margin-bottom: 24px;
  flex-wrap:   wrap;
}
.article-meta .sep { color: var(--border); }

.article-hero {
  width:         100%;
  max-height:    480px;
  object-fit:    cover;
  border-radius: var(--radius);
  margin-bottom: 28px;
  box-shadow:    var(--shadow);
}

.article-hero-placeholder {
  width:         100%;
  height:        260px;
  border-radius: var(--radius);
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     5rem;
  margin-bottom: 28px;
  background:    var(--bg);
}

.article-summary {
  font-size:     1.15rem;
  font-weight:   500;
  line-height:   1.6;
  color:         var(--text);
  background:    var(--blue-light);
  border-left:   4px solid var(--blue);
  padding:       14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 28px;
}

.article-body {
  font-size:   1.1rem;
  line-height: 1.75;
  color:       var(--text);
}
.article-body p {
  margin-bottom: 1.2em;
}
.article-body p:last-child {
  margin-bottom: 0;
}

.article-footer {
  margin-top:  36px;
  padding-top: 20px;
  border-top:  1px solid var(--border);
  font-size:   0.95rem;
  color:       var(--text-muted);
}

/* ── Category colour maps ─────────────────────────────────── */
.cat-world         { background: #e8f0fe; color: #1a73e8; }
.cat-us-news       { background: #fce8e6; color: #c5221f; }
.cat-health        { background: #e6f4ea; color: #137333; }
.cat-science       { background: #fef7e0; color: #b06000; }
.cat-technology    { background: #f3e8fd; color: #7627bb; }
.cat-business      { background: #e6f4ea; color: #188038; }
.cat-entertainment { background: #fce8e6; color: #c5221f; }
.cat-sports        { background: #e8f0fe; color: #1557b0; }
.cat-weather       { background: #e0f7ff; color: #007fb3; }

/* placeholder icon backgrounds mirror badge colours */
.ph-world         { background: #e8f0fe; }
.ph-us-news       { background: #fce8e6; }
.ph-health        { background: #e6f4ea; }
.ph-science       { background: #fef7e0; }
.ph-technology    { background: #f3e8fd; }
.ph-business      { background: #e6f4ea; }
.ph-entertainment { background: #fce8e6; }
.ph-sports        { background: #e8f0fe; }
.ph-weather       { background: #e0f7ff; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  html { font-size: 17px; }

  .site-header { padding: 0 14px; }
  .site-logo   { font-size: 1.25rem; }
  .header-date { display: none; }

  .news-grid {
    grid-template-columns: 1fr;
  }

  .article-title { font-size: 1.5rem; }
  .article-body  { font-size: 1.05rem; }
}

@media (min-width: 900px) {
  .news-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
