:root {
  color-scheme: light;
  --bg: #ffffff;
  --soft: #f6f5f1;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #66706b;
  --border: #ebe8e1;
  --accent: #2e7d6b;
  --accent-soft: #e6f2ee;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(29 35 33 / 0.04), 0 6px 18px rgb(29 35 33 / 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.site-header, main, .site-footer {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* Masthead */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 28px 20px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.brand-logo { height: 48px; width: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--serif); font-size: 2.1rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.strapline { font-family: var(--serif); font-style: italic; color: var(--accent); font-size: 1.15rem; line-height: 1.3; }
.tagline { color: var(--muted); font-size: 0.95rem; text-wrap: balance; }
.header-link { color: var(--muted); text-decoration: none; font-weight: 500; }
.header-link:hover { color: var(--accent); }

/* Category tiles */
.tiles {
  list-style: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(118px, 1fr);
  gap: 12px;
  margin: 20px 0 0;
  padding: 0 0 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}
.tiles li { scroll-snap-align: start; }
.tile {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--soft);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile img, .tile .picture-fallback { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.tile .picture-fallback { font-size: 2rem; }
.tile-name { padding: 8px 10px 10px; font-weight: 600; font-size: 0.92rem; text-align: center; }

/* Pictures */
.picture { display: block; width: 100%; object-fit: cover; background: var(--soft); }
.picture-fallback {
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  background: color-mix(in oklab, var(--cat, var(--accent)), white 82%);
}

.section-title {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin: 40px 0 16px;
}

/* Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 20px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card > .picture { aspect-ratio: 3 / 2; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.card-category {
  color: color-mix(in oklab, var(--cat, var(--accent)), black 15%);
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
}
.card-title { margin: 0; font-family: var(--serif); font-size: 1.2rem; line-height: 1.3; }
.card-summary { margin: 0; flex: 1; color: #3b4440; }
.card-title-link { color: var(--text); text-decoration: none; }
.card-title-link:hover { color: var(--accent); }
.card .headline-meta { margin: 0; }

/* Featured */
.featured { margin-top: 28px; }
.card-featured { display: grid; grid-template-columns: 1fr; }
.card-featured > .picture { aspect-ratio: 16 / 9; }
.card-featured .card-body { padding: 22px 24px 26px; }
.card-featured .card-title { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.card-featured .card-summary { font-size: 1.05rem; }
.card-featured .headline-meta { font-size: 0.9rem; }
@media (min-width: 800px) {
  .card-featured { grid-template-columns: 1.2fr 1fr; }
  .card-featured > .picture { aspect-ratio: auto; height: 100%; min-height: 320px; }
  .card-featured .card-body { justify-content: center; padding: 32px; }
}

/* Today's headlines */
.headlines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px 24px;
}
.headline { display: flex; gap: 14px; align-items: flex-start; }
.headline > .picture { flex: none; width: 76px; height: 76px; border-radius: 12px; font-size: 1.6rem; }
.headline-title {
  color: var(--text);
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.headline-title:hover { color: var(--accent); }
.headline-meta { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; }
.source-pill {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 4px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Misc */
.more, .empty { text-align: center; margin: 36px 0; }
.more-button {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.flash { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); }
.about { max-width: 65ch; margin-inline: auto; }
.about h1 { font-family: var(--serif); }
.site-footer { padding-block: 40px; margin-top: 40px; border-top: 1px solid var(--border); color: var(--muted); }

/* "Over 2 months old" note on older stories */
.age-text { color: #8a5a00; font-weight: 600; }

/* Header links */
.header-links { display: flex; gap: 18px; }

/* Good Cloud */
.cloud-intro { color: var(--muted); max-width: 60ch; }
.cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 18px;
  margin: 24px auto 0;
  padding: 48px 32px;
  max-width: 960px;
  border-radius: 48px;
  background: radial-gradient(circle at 50% 40%, #fff8e6 0%, #eef7f3 55%, #ffffff 100%);
  box-shadow: var(--shadow);
}
.word { font-family: var(--serif); font-weight: 700; line-height: 1.1; }
.w1 { font-size: 1rem; opacity: 0.85; }
.w2 { font-size: 1.35rem; }
.w3 { font-size: 1.8rem; }
.w4 { font-size: 2.4rem; }
.w5 { font-size: 3.2rem; }
.c0 { color: #2e7d6b; } .c1 { color: #c2410c; } .c2 { color: #be185d; } .c3 { color: #15803d; }
.c4 { color: #1d4ed8; } .c5 { color: #a16207; } .c6 { color: #7e22ce; } .c7 { color: #0e7490; }

/* "Back to Good News" link on About and Good Cloud */
.back-link { display: inline-block; margin-top: 24px; font-weight: 600; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* Back-to-top arrow: always shown without JavaScript, otherwise once the page is scrolled */
.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 10;
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.4rem; font-weight: 700;
  text-decoration: none; box-shadow: var(--shadow);
  transition: opacity 0.2s ease, translate 0.2s ease, visibility 0.2s;
}
.to-top-ready .to-top:not(.is-shown) { opacity: 0; visibility: hidden; translate: 0 12px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  .to-top { transition: none; }
  html { scroll-behavior: auto; }
}

/* Share menu in the footer */
.site-footer { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; }
.share summary {
  cursor: pointer; list-style: none; font-weight: 600; color: var(--accent);
  padding: 6px 14px; border: 1px solid var(--accent); border-radius: 999px;
}
.share summary::-webkit-details-marker { display: none; }
.share-menu { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 12px 0 0; }
.share-menu a, .share-copy {
  display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem;
  text-decoration: none; cursor: pointer;
}
.share-menu a:hover, .share-copy:hover { border-color: var(--accent); color: var(--accent); }

/* Phones: give the name and strapline the full width, links on their own row */
.header-link { white-space: nowrap; }
@media (max-width: 560px) {
  .masthead { flex-wrap: wrap; padding-block: 20px 14px; }
  .header-links { width: 100%; }
}
