/* City and Coffee theme overrides. */

/* monogram avatar (used instead of stock portraits for sources) */
.avatar.avatar--mono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--band, #e7eaef);
  color: var(--ink, #15181e);
  font-family: "Archivo", sans-serif;
  font-weight: 800;
  font-size: 1rem;
  flex: 0 0 auto;
}
.op-card .avatar.avatar--mono,
.article-author .avatar.avatar--mono { background: rgba(255, 255, 255, .12); color: #fff; }

/* article page: excerpt / source note */
.source-note {
  border: 1px solid var(--rule, #d2d7de);
  background: var(--paper, #f4f5f7);
  padding: 1.25rem 1.4rem;
  margin: 2rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: center;
  justify-content: space-between;
}
.source-note p { margin: 0; font-size: .95rem; color: #444b56; }
.source-note b { color: var(--ink, #15181e); }
.source-note .btn { text-decoration: none; color: #fff; }

.license-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: .18rem .5rem;
  color: var(--ink-3);
  line-height: 1;
}

/* listing pages (desk / search) */
.pager {
  display: flex;
  gap: .5rem;
  align-items: center;
  justify-content: center;
  margin: 2.5rem 0 .5rem;
  font-family: "IBM Plex Mono", monospace;
}
.pager a,
.pager span.pg {
  display: inline-block;
  padding: .45rem .85rem;
  border: 1px solid var(--rule, #d2d7de);
  color: var(--ink, #15181e);
  text-decoration: none;
  font-size: .85rem;
}
.pager a:hover { border-color: var(--press, #c8102e); color: var(--press, #c8102e); }
.pager span.pg { background: var(--press, #c8102e); border-color: var(--press, #c8102e); color: #fff; }
.pager .disabled { opacity: .4; pointer-events: none; }

.empty-note {
  padding: 3rem 1rem;
  text-align: center;
  color: #5b6472;
  font-family: "Archivo", sans-serif;
}

/* search result rows */
.result-row { margin-bottom: 1.6rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--rule, #d2d7de); }
.result-row:last-child { border-bottom: 0; }
.result-row .meta { margin: .35rem 0; }

/* article hero fills frame if source image is portrait-ish */
.article-cover .frame img { width: 100%; height: 100%; object-fit: cover; }

/* masthead nameplate = City and Coffee logo — as-is on the band (no plate) */
.nameplate .np-logo {
  display: block;
  width: 300px;
  max-width: 100%;
  height: auto;
  margin: .3rem auto 0;
}
/* dark mode: warm newsprint cream (light mode keeps cool paper tones) */
html.dark .masthead {
  background:
    repeating-linear-gradient(0deg, rgba(33, 33, 33, .014) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #f8f4ec 0%, #f3ede1 100%);
}
html.dark .nameplate .sub { color: #7a7061; }
@media (max-width: 860px) {
  .nameplate .np-logo { margin-left: 0; }
}
@media (max-width: 640px) {
  .nameplate .np-logo { width: 180px; }
}

/* masthead is logo-only now: keep it centered */
.masthead-inner { display: flex; justify-content: center; }
@media (max-width: 860px) {
  .masthead-inner { justify-content: flex-start; }
}

/* =====================================================================
   THEME-AWARE OVERRIDES
   Rules that use only CSS vars work in both themes. Anything with a
   hardcoded dark colour is scoped under html.dark so light mode keeps
   the original broadsheet look.
   ===================================================================== */

/* buttons — magenta primary like FabZone CTAs */
.btn { background: var(--press); border-color: var(--press); color: #fff; }
.btn:hover { background: var(--press-d); border-color: var(--press-d); color: #fff; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn--ghost:hover { background: var(--press); border-color: var(--press); color: #fff; }

/* hairline rules read correctly in both themes */
.briefs, .rail-head { border-top-color: var(--rule); }
.side-title { border-bottom-color: var(--rule); }
.nav-bar { border-top-color: var(--rule); }

/* newsletter inputs */
.news-input { border-color: var(--rule); }
.news-input:focus { border-color: var(--press); }
.news-input.invalid { border-color: var(--press); }

/* share hover */
.share-btn:hover { background: var(--press); border-color: var(--press); color: #fff; }

/* small surfaces — var-driven so they adapt */
.license-chip { background: transparent; color: var(--ink-3); }
.source-note { background: var(--band); border-color: var(--rule); }
.source-note p { color: var(--ink-2); }
.source-note b { color: var(--ink); }
.empty-note { color: var(--ink-3); }
.avatar.avatar--mono { background: var(--band); color: var(--ink); }
.article-author { background: var(--band); }

/* ---------------- theme toggle button ---------------- */
.theme-toggle .ic-sun { display: none; }
html.dark .theme-toggle .ic-sun { display: block; }
html.dark .theme-toggle .ic-moon { display: none; }

/* =====================================================================
   PAGE RAIL (main column + right sidebar) — desk / search / article
   ===================================================================== */

.page-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: start;
  margin-top: 1.2rem;
}
.page-main { min-width: 0; }
.page-side {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: sticky;
  top: 5.5rem;
}

/* article rail: body column keeps its readable max-width */
.article-rail { margin-top: 0; }
.article-rail .article-body { max-width: 780px; }
.article-rail .page-side { position: static; }

@media (max-width: 980px) {
  .page-rail { grid-template-columns: 1fr; }
  /* Flatten sidebar children into the rail so ads can sit top/bottom
     of the page on mobile: ad3 top, content middle, ad2 bottom. */
  .page-side {
    display: contents;
  }
  .page-side > .ad-block[data-ad-slot="ad3"] { order: -2; }
  .page-main { order: 0; }
  .page-side > .side-block { order: 1; }
  .page-side > .ad-block[data-ad-slot="ad2"] { order: 2; }
}

/* ---------------- ad slots (CNC-style) ---------------- */
.ad-block { margin: 0 0 .5rem; }
.ad-figure {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 3px;
  padding: .5rem;
}
html.dark .ad-figure {
  /* light pad even in dark theme — many creatives have near-black backgrounds */
  background: #ececee;
  border-color: #d4d4d8;
}
.ad-figure a { display: inline-block; line-height: 0; }
.ad-figure img { max-width: 100%; height: auto; }
.ad-cap {
  margin-top: .5rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ink-3);
}
/* CNC "Ad" sidebar heading — bold title + accent underline */
.ad-head {
  position: relative;
  display: flex;
  align-items: center;
  height: 2.5rem;
  margin-bottom: 1.6rem;
  border-bottom: 2px solid var(--rule);
}
.ad-head h3 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin: 0;
}
.ad-head-bar {
  position: absolute;
  bottom: -2px;
  left: 0;
  height: 2px;
  width: 30px;
  background: var(--press);
}

/* dashed placeholder fallback (when ads.json is missing/empty) */
.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 250px;
  padding: 1rem;
  border: 1px dashed var(--rule);
  background: var(--card);
  text-align: center;
}
.ad-slot .ad-label {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ad-slot .ad-body { width: 100%; min-height: 90px; }

/* latest-list — same rhythm as trend-list */
.latest-list .dateline { font-variant-numeric: tabular-nums; }

/* =====================================================================
   DARK-THEME EXTRAS — scoped to html.dark so light mode is untouched
   ===================================================================== */

html.dark body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(124, 24, 114, .22), transparent 60%),
    radial-gradient(900px 420px at -10% 10%, rgba(88, 28, 135, .18), transparent 55%),
    var(--paper);
}

/* dark slabs stay near-black (not light --ink) */
html.dark .topbar { background: #0e0c14; color: #b7b1c4; }
html.dark .topbar a { color: #b7b1c4; }
html.dark .topbar a:hover { color: #fff; }
html.dark .skip-link { background: #0e0c14; }
html.dark .searchbar { background: #0e0c14; }
html.dark .ticker { background: #0e0c14; }
html.dark .site-footer { background: #0e0c14; }
html.dark .foot-tag { background: #1a1625; border-color: #2a2438; color: #d0c8e0; }
html.dark .foot-recent li a { border-bottom-color: #1e1a2a; }

/* frames — purple→magenta gradient plate behind images */
html.dark .frame { background: linear-gradient(135deg, #2a1040 0%, #4c1259 55%, #701557 100%); }
html.dark .frame::after { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }

/* nav stuck shadow */
html.dark .nav-bar.is-stuck { box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .8); }

/* opinion band — deep purple gradient */
html.dark .opinion {
  background: linear-gradient(120deg, #150d22 0%, #241033 50%, #3a1145 100%);
}
html.dark .opinion .sec-head h2::before { background: var(--press); }
html.dark .opinion .sec-head .rule { background: #3a3150; }
html.dark .op-card h3 a:hover { color: #f9a8d4; }
html.dark .op-divide .op-card, html.dark .op-lead { border-color: #3a3150; }

/* gallery caption accents */
html.dark .gallery .cap .k { color: #f9a8d4; }
html.dark .gallery a::after { background: linear-gradient(to top, rgba(8, 6, 14, .78), transparent 55%); }

/* newsletter band */
html.dark .news { background: linear-gradient(180deg, var(--band) 0%, #161222 100%); }
html.dark .news-input.invalid { background: #2a1020; }

/* article reading colour */
html.dark .article-body { color: #d7d2e0; }

/* ---------- blog language chips ---------- */
.lang-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.lang-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .38rem .85rem;
  background: var(--card);
  transition: border-color .15s, color .15s, background .15s;
}
.lang-chips .chip b {
  font-weight: 600;
  color: var(--ink-3);
}
.lang-chips .chip:hover {
  border-color: var(--press);
  color: var(--press);
  text-decoration: none;
}
.lang-chips .chip:hover b {
  color: var(--press);
}
.lang-chips .chip.is-on {
  background: var(--press);
  border-color: var(--press);
  color: #fff;
}
.lang-chips .chip.is-on b {
  color: rgba(255, 255, 255, .85);
}

/* ---------- blog inline search ---------- */
.blog-search {
  margin: 1.25rem 0 0;
  max-width: 420px;
}
.blog-search input {
  width: 100%;
  font-family: var(--sans);
  font-size: .95rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .6rem .85rem;
  outline: none;
  transition: border-color .15s;
}
.blog-search input:focus {
  border-color: var(--press);
}

/* AI-generated image badge on cards */
.ai-badge {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 2;
  display: inline-block;
  font-family: var(--mono);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  padding: .15rem .4rem;
  border-radius: 2px;
  pointer-events: none;
}
