/* ─────────────────────────────────────────────────────────────
   AI News Daily — Newspaper Stylesheet
   ───────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,800;0,900;1,700&family=Inter:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

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

:root {
  --ink:        #1a1a2e;
  --ink-light:  #444456;
  --ink-faint:  #888899;
  --paper:      #f5f2ec;
  --paper-dark: #ede9e0;
  --rule:       #1a1a2e;
  --rule-light: #e0e0e8;
  --red:        #c0152a;
  --col-gap:    2rem;

  /* ST-style font stack */
  --font-headline: 'Playfair Display', Georgia, serif;
  --font-body:     'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-serif:    'Source Serif 4', Georgia, serif;
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --ink:        #e8e8f0;
  --ink-light:  #aaaabc;
  --ink-faint:  #55556a;
  --paper:      #0f0f1a;
  --paper-dark: #17172a;
  --rule:       #e8e8f0;
  --rule-light: #252538;
  --red:        #e8455a;
  color-scheme: dark;
}
[data-theme="dark"] body      { background: var(--paper); }
[data-theme="dark"] .masthead { background: var(--paper); }
[data-theme="dark"] .section-nav { background: var(--paper); }
[data-theme="dark"] .site-footer { background: #060610; }

.theme-toggle {
  background: none;
  border: 1px solid var(--rule-light);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  color: var(--ink-faint);
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.4;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }

html { font-size: 16px; }

.masthead-title,
.featured-main h2,
.article-card h3 {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Masthead ── */
.masthead {
  background: var(--paper);
  border-bottom: 3px solid var(--rule);
  padding: 1rem 2rem 0.8rem;
  text-align: center;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule-light);
  padding-bottom: 0.5rem;
  margin-bottom: 0.7rem;
  font-weight: 500;
}

.masthead-top span { flex: 1; }
.masthead-top span:nth-child(2) { text-align: center; }
.masthead-top span:last-child  { text-align: right; }

.masthead-title {
  font-family: var(--font-headline);
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink);
  margin: 0.2rem 0 0.35rem;
  text-transform: uppercase;
}

.masthead-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  margin-bottom: 0.6rem;
}

/* ── Navigation ── */
.section-nav {
  border-top: 1px solid var(--rule-light);
  border-bottom: 1px solid var(--rule-light);
  margin: 0;
  background: var(--paper);
}

.section-nav ul {
  display: flex;
  justify-content: center;
  list-style: none;
  gap: 0;
  flex-wrap: wrap;
}

.section-nav ul li a {
  display: block;
  padding: 0.6rem 1.4rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink);
  transition: color 0.15s;
  border-bottom: 3px solid transparent;
}

.section-nav ul li a:hover { color: var(--red); text-decoration: none; border-bottom-color: var(--red); }
.section-nav ul li a.active { color: var(--red); border-bottom-color: var(--red); }

/* ── Market ticker strip ── */
.market-strip {
  background: var(--paper-dark);
  border-bottom: 1px solid var(--rule-light);
  padding: 0.35rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.market-strip::-webkit-scrollbar { display: none; }

.market-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.market-item .m-label {
  color: var(--ink-faint);
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}
.market-item .m-price { color: var(--ink); }
.market-item .m-change { font-size: 0.68rem; }
.market-item .up   { color: #22a865; }
.market-item .down { color: var(--red); }

[data-theme="dark"] .market-item .up { color: #3dd68c; }

/* ── Breaking ticker ── */
.ticker-bar {
  background: var(--red);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  min-height: 2rem;
}

.ticker-label {
  background: #8b0011;
  padding: 0 1rem;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.15em;
  position: relative;
  z-index: 2;
  align-self: stretch;
  display: flex;
  align-items: center;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-content {
  padding: 0 2rem;
  white-space: nowrap;
  animation: ticker 90s linear infinite;
  font-weight: 500;
  letter-spacing: 0.05em;
  line-height: 2rem;
  display: inline-block;
}

@keyframes ticker {
  0%   { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

/* ── Page layout ── */
.page-wrap {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Section heading ── */
.section-heading {
  text-align: left;
  padding: 1.2rem 0 0.6rem;
  border-bottom: 2px solid var(--rule);
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.section-heading .edition-line {
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.2rem;
  font-family: var(--font-body);
}

/* ── Loading state (skeleton) ── */
.loading-state {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule-light);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  margin-bottom: 1.8rem;
  border-right: 1px solid var(--rule-light);
  padding-right: 2rem;
}
.skeleton-card:nth-child(3n) { border-right: none; padding-right: 0; }

.skeleton-line {
  display: block;
  height: 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.55rem;
  background: linear-gradient(90deg, var(--paper-dark) 25%, var(--rule-light) 50%, var(--paper-dark) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-line.title  { height: 1rem; width: 90%; }
.skeleton-line.title2 { height: 1rem; width: 70%; margin-bottom: 0.8rem; }
.skeleton-line.short  { width: 45%; }
.skeleton-line.badge  { height: 0.55rem; width: 30%; margin-bottom: 0.7rem; }
.skeleton-line.img    { height: 140px; margin-bottom: 0.6rem; width: 100%; }

/* Inline summary skeleton while AI generates */
.summary-skeleton {
  border-left: 2px solid var(--rule-light);
  padding-left: 0.6rem;
  margin: 0.4rem 0 0.7rem;
  min-height: 1.2rem;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--paper-dark) 25%, var(--rule-light) 50%, var(--paper-dark) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  color: transparent;
  user-select: none;
}

/* ── Error state ── */
.error-state {
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.9rem;
  color: var(--red);
  font-family: var(--font-body);
}

/* ── Featured article ── */
.featured-strip {
  border-bottom: 1px solid var(--rule-light);
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--col-gap);
}

.featured-main {
  border-right: 1px solid var(--rule-light);
  padding-right: var(--col-gap);
}

.featured-main .article-tag {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 0.2rem 0.6rem;
  margin-bottom: 0.7rem;
}

.featured-main h2 {
  font-family: var(--font-headline);
  font-size: clamp(1.7rem, 3.2vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.7rem;
  letter-spacing: -0.01em;
}

.featured-main h2 a:hover { text-decoration: underline; }

.featured-main .article-deck {
  font-size: 1rem;
  color: var(--ink-light);
  margin-bottom: 0.8rem;
  line-height: 1.6;
  font-family: var(--font-serif);
}

.featured-main .article-body {
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 0.8rem;
  font-family: var(--font-body);
  color: var(--ink-light);
}

.featured-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  margin-bottom: 0.8rem;
}

.featured-side {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.featured-strip.no-feat-img {
  grid-template-columns: 3fr 2fr;
}

.featured-strip.no-feat-img .featured-main h2 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

/* ── Main article grid ── */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 var(--col-gap);
  border-top: 1px solid var(--rule-light);
  padding-top: 1.5rem;
}

.articles-grid .article-card {
  border-right: 1px solid var(--rule-light);
  padding-right: var(--col-gap);
  margin-bottom: 1.8rem;
}

.articles-grid .article-card:nth-child(3n) {
  border-right: none;
  padding-right: 0;
}

/* ── Article card (shared) ── */
.article-card { position: relative; }

.article-card .article-source-badge {
  font-size: 0.6rem;
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--rule-light);
  padding-bottom: 0.3rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.article-card h3 {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.4rem;
  font-size: 0.97rem;
  color: var(--ink);
}

.article-card h3 a:hover { color: var(--red); text-decoration: none; }

.article-card .article-desc {
  font-size: 0.8rem;
  color: var(--ink-light);
  line-height: 1.6;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--font-body);
}

/* AI-generated 50-word summary */
.article-summary {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--ink);
  line-height: 1.65;
  border-left: 2px solid var(--red);
  padding-left: 0.6rem;
  margin: 0.4rem 0 0.7rem;
  font-family: var(--font-body);
}

.article-card .article-meta {
  font-size: 0.63rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-family: var(--font-body);
}

.article-card .article-meta span { display: flex; align-items: center; gap: 0.25rem; }

.article-card .thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  margin-bottom: 0.6rem;
  border: 1px solid var(--rule-light);
}

/* Featured side cards (smaller) */
.featured-side .article-card h3 { font-size: 0.92rem; }

.featured-side .article-card {
  border-bottom: 1px solid var(--rule-light);
  padding-bottom: 1rem;
}

.featured-side .article-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* ── Read state ── */
.article-card.is-read {
  opacity: 0.45;
  transition: opacity 0.2s;
}
.article-card.is-read:hover {
  opacity: 0.75;
}
.article-card.is-read .article-source-badge::after {
  content: ' · ✓ read';
  color: var(--ink-faint);
  font-style: italic;
}

/* ── Read more link ── */
.read-more {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red);
}

.read-more::after { content: ' →'; }

/* ── Pull quote ── */
.pull-quote {
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--rule-light);
  margin: 1.5rem 0;
  padding: 1rem 0.5rem;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
}

/* ── Divider ornament ── */
.ornament-divider {
  text-align: center;
  color: var(--rule-light);
  font-size: 1rem;
  margin: 1rem 0;
  letter-spacing: 0.5em;
  user-select: none;
}

/* ── Footer ── */
.site-footer {
  background: var(--ink);
  color: #ccc;
  text-align: center;
  padding: 1.5rem;
  margin-top: 3rem;
  font-size: 0.7rem;
  font-family: 'Libre Baskerville', serif;
  letter-spacing: 0.05em;
}

.site-footer a { color: #aaa; text-decoration: underline; }

.fetched-at {
  font-size: 0.65rem;
  color: var(--ink-faint);
  font-style: italic;
  text-align: right;
  margin: 0.5rem 0 1.5rem;
}

/* ── Home page sections ── */
.home-section {
  border-bottom: 2px solid var(--rule);
  margin-bottom: 2rem;
  padding-bottom: 1.8rem;
}

.home-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1.2rem 0 0.6rem;
  border-bottom: 2px solid var(--rule);
  margin-bottom: 1.4rem;
}

.section-heading-row h2 {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.section-heading-row h2 a { color: inherit; }
.section-heading-row h2 a:hover { text-decoration: none; color: var(--ink); }

.section-heading-row .edition-line {
  font-size: 0.65rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.15rem;
  font-family: var(--font-body);
}

.section-see-all {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red);
  white-space: nowrap;
}
.section-see-all::after { content: ' →'; }
.section-see-all:hover { text-decoration: none; color: var(--ink); }

.home-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--col-gap);
}

.home-grid .article-card:first-child {
  border-right: 1px solid var(--rule-light);
  padding-right: var(--col-gap);
}

.home-grid .article-card:nth-child(2) {
  border-right: 1px solid var(--rule-light);
  padding-right: var(--col-gap);
}

.home-grid .home-featured h3 {
  font-size: 1.05rem;
  font-family: var(--font-headline);
  font-weight: 700;
  line-height: 1.25;
}

/* ── Filter chips ── */
.filter-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule-light);
  margin-bottom: 1.4rem;
}
.filter-chip {
  padding: 0.22rem 0.8rem;
  border: 1px solid var(--rule-light);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: none;
  color: var(--ink-faint);
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-chip:hover { color: var(--ink); border-color: var(--ink); }
.filter-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ── Ad slots ── */
.ad-slot {
  background: var(--paper-dark);
  border: 1px solid var(--rule-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-slot--leaderboard { width: 100%; min-height: 90px; margin: 0.8rem 0; }
.ad-slot--in-article  { width: 100%; min-height: 100px; margin: 1.5rem 0; }
.ad-slot--rectangle   { width: 300px; min-height: 250px; margin: 1rem auto; }

/* ── Card hover lift ── */
.articles-grid .article-card,
.featured-side .article-card { transition: transform 0.15s; }
.articles-grid .article-card:hover,
.featured-side .article-card:hover { transform: translateY(-2px); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .loading-state { grid-template-columns: repeat(2, 1fr); }
  .featured-strip { grid-template-columns: 1fr; }
  .featured-main { border-right: none; padding-right: 0; border-bottom: 1px solid var(--rule-light); padding-bottom: 1.2rem; margin-bottom: 1.2rem; }
  .articles-grid { grid-template-columns: repeat(2, 1fr); }
  .articles-grid .article-card { border-right: 1px solid var(--rule-light); }
  .articles-grid .article-card:nth-child(3n) { border-right: 1px solid var(--rule-light); padding-right: var(--col-gap); }
  .articles-grid .article-card:nth-child(2n) { border-right: none; padding-right: 0; }

  .home-grid { grid-template-columns: 1fr 1fr; }
  .home-grid .article-card:first-child { grid-column: 1 / -1; border-right: none; padding-right: 0; border-bottom: 1px solid var(--rule-light); padding-bottom: 1rem; margin-bottom: 0.5rem; }
  .home-grid .article-card:nth-child(2) { border-right: 1px solid var(--rule-light); padding-right: var(--col-gap); }
}

@media (max-width: 600px) {
  .loading-state { grid-template-columns: 1fr; }
  .masthead { padding: 0.8rem 1rem 0.6rem; }
  .masthead-top { flex-direction: column; gap: 0.25rem; text-align: center; }
  .masthead-top span { text-align: center !important; }
  .articles-grid { grid-template-columns: 1fr; }
  .articles-grid .article-card { border-right: none; padding-right: 0; }
  .articles-grid .article-card:nth-child(2n) { border-right: none; }
  .page-wrap { padding: 0 0.75rem; }
  :root { --col-gap: 1rem; }

  .home-grid { grid-template-columns: 1fr; }
  .home-grid .article-card { border-right: none !important; padding-right: 0 !important; }
  .section-heading-row { flex-direction: column; gap: 0.4rem; align-items: flex-start; }
}
