/* ===================================================
   The drAIgonling Gazette — Victorian Newspaper Theme
   Light + Dark themes, responsive mobile layout
   =================================================== */

:root {
  --paper: #faf8f2;
  --paper-dark: #f0ece2;
  --ink: #1a1611;
  --ink-light: #3d362c;
  --ink-mid: #6b604f;
  --ink-faint: #9e9283;
  --ink-ghost: #c4baa8;
  --rule: #6b604f;
  --rule-light: #c5b99d;
  --rule-heavy: #4a4035;
  --gold: #9e7c2e;
  --fire: #c44a1a;
  --error-bg: #fdf0ed;
  --max-width: 1280px;
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body: 'Lora', 'Georgia', serif;
  --font-accent: 'IM Fell English', 'Georgia', serif;
  --font-gothic: 'UnifrakturCook', cursive;
  --transition: 0.15s ease;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --paper: #1a1814;
  --paper-dark: #141210;
  --ink: #d4cbb8;
  --ink-light: #bfb5a0;
  --ink-mid: #9e9283;
  --ink-faint: #7a7063;
  --ink-ghost: #4a4438;
  --rule: #5a5045;
  --rule-light: #3d362e;
  --rule-heavy: #8a7e6e;
  --gold: #c9a23e;
  --fire: #e06030;
  --error-bg: #2a1a14;
}
[data-theme="dark"] .masthead-dragon { filter: sepia(1) brightness(1.2) invert(1); }
[data-theme="dark"] .art-image-wrap img { filter: brightness(0.9); }
[data-theme="dark"] .headline-image-wrap img { filter: brightness(0.9); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--paper); color: var(--ink); line-height: 1.55; min-height: 100vh; transition: background 0.3s ease, color 0.3s ease; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* ---- Corner title ---- */
.corner-title {
  position: fixed; top: 0.4rem; left: 0.6rem;
  font-family: var(--font-accent); font-size: 0.65rem;
  color: var(--ink-ghost); letter-spacing: 0.08em;
  z-index: 100; text-transform: uppercase;
}

/* ---- Masthead ---- */
.masthead {
  text-align: center;
  padding: 0.8rem 1rem 0.4rem;
  border-bottom: 3px solid var(--rule-heavy);
  max-width: var(--max-width); margin: 0 auto;
}
.masthead::after { content: ''; display: block; height: 1px; background: var(--rule-heavy); margin-top: 2px; }
.masthead-date { font-family: var(--font-accent); font-style: italic; font-size: 0.8rem; color: var(--ink-mid); letter-spacing: 0.1em; }
.masthead-title { font-family: var(--font-gothic); font-size: 3rem; font-weight: 700; color: var(--ink); line-height: 1; margin: 0.15rem 0 0.1rem; letter-spacing: 0.02em; }
.masthead-sub { font-family: var(--font-accent); font-style: italic; font-size: 0.85rem; color: var(--ink-mid); }
.ai-note { font-size: 0.7rem; color: var(--ink-ghost); letter-spacing: 0.03em; }
.masthead-rule { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.masthead-rule::before, .masthead-rule::after { content: ''; flex: 1; height: 1px; background: var(--rule); }
.masthead-dragon { width: 22px; height: 22px; opacity: 0.5; filter: sepia(1) brightness(0.4); }

/* ---- Theme toggle ---- */
.theme-toggle {
  background: none; border: 1px solid var(--rule-light);
  color: var(--ink-mid); cursor: pointer;
  font-size: 0.95rem; padding: 0.15rem 0.4rem;
  border-radius: 2px; transition: var(--transition);
  line-height: 1; display: flex; align-items: center;
}
.theme-toggle:hover { color: var(--gold); border-color: var(--gold); }

/* ---- Nav bar (unified) ---- */
.nav-bar {
  border-bottom: 2px solid var(--rule);
  max-width: var(--max-width); margin: 0 auto;
  display: flex; justify-content: center; flex-wrap: wrap;
  padding: 0.25rem 0;
}
.nav-link {
  font-family: var(--font-accent); font-size: 0.875rem;
  padding: 0.25rem 0.75rem; color: var(--ink-mid);
  cursor: pointer; transition: var(--transition);
  border-right: 1px solid var(--rule-light); white-space: nowrap;
}
.nav-link:last-child { border-right: none; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); font-weight: 700; }

/* ---- Page wrapper ---- */
.page-wrapper { max-width: var(--max-width); margin: 0 auto; padding: 0 1rem; }

/* ---- Ticker ---- */
.ticker-bar {
  border-bottom: 1px solid var(--rule);
  overflow: hidden; white-space: nowrap;
  padding: 0.3rem 0;
  max-width: var(--max-width); margin: 0 auto;
  background: var(--paper-dark);
}
.ticker-track { display: inline-flex; animation: ticker-scroll 140s linear infinite; gap: 1.2rem; padding-left: 100%; }
.ticker-item {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: var(--font-accent); font-style: italic; font-size: 0.8rem;
  color: var(--ink-faint); flex-shrink: 0;
}
.ticker-item:hover { color: var(--ink-mid); }
.ticker-cat { font-weight: 700; font-style: normal; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.05em; color: var(--ink-mid); }
.ticker-sep { color: var(--rule-light); margin: 0 0.3rem; font-size: 0.5rem; }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* ---- Headlines — newspaper front-page layout ---- */
.headline-section {
  padding: 0.6rem 0 0.5rem;
  border-bottom: 2px solid var(--rule-heavy);
}

/* Two-column feature: main story (left 3fr) + sidebar (right 2fr) */
.headline-feature {
  display: grid; grid-template-columns: 3fr 2fr;
}

/* Main story — prominent, with large image */
.headline-main {
  padding-right: 0.75rem;
  border-right: 1px solid var(--rule);
}
.headline-main-cat {
  font-family: var(--font-accent); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--fire);
}
.headline-main-title {
  font-family: var(--font-display); font-size: 1.75rem; font-weight: 900;
  line-height: 1.12; color: var(--ink); margin: 0.15rem 0;
}
.headline-main-title .fire { color: var(--fire); }
.headline-main-annotation {
  font-size: 1rem; color: var(--ink-light); line-height: 1.5;
  margin-top: 0.3rem;
}
.headline-main-meta {
  font-family: var(--font-accent); font-style: italic; font-size: 0.75rem;
  color: var(--ink-faint); margin-top: 0.25rem;
  display: flex; align-items: center; gap: 0.3rem;
}
.headline-main-meta .entry-date { margin-left: 0.3rem; }

.headline-image-wrap { border: 1px solid var(--rule-light); overflow: hidden; margin: 0.4rem 0; max-height: 280px; }
.headline-image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Sidebar stories — stacked vertically */
.headline-sidebar {
  display: flex; flex-direction: column;
}
.headline-sidebar-item {
  padding: 0.5rem 0 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rule-light);
  display: block; cursor: pointer;
  transition: background var(--transition);
}
.headline-sidebar-item:last-child { border-bottom: none; }
.headline-sidebar-item:hover { background: var(--paper-dark); }
.headline-sidebar-cat {
  font-family: var(--font-accent); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-faint); margin-bottom: 0.1rem;
}
.headline-sidebar-title {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  line-height: 1.2; color: var(--ink);
}
.headline-sidebar-title .fire { color: var(--fire); }
.headline-sidebar-snippet {
  font-size: 0.875rem; color: var(--ink-mid); line-height: 1.4;
  margin-top: 0.15rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.headline-sidebar-meta {
  font-family: var(--font-accent); font-style: italic; font-size: 0.7rem;
  color: var(--ink-ghost); margin-top: 0.2rem;
  display: flex; align-items: center; gap: 0.3rem;
}
.headline-sidebar-meta .entry-date { margin-left: 0.3rem; }

/* ---- Three-column broadsheet ---- */
.broadsheet {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}
.broadsheet-col { padding: 0.3rem 0.75rem; border-right: 1px solid var(--rule); }
.broadsheet-col:first-child { padding-left: 0; }
.broadsheet-col:last-child { border-right: none; padding-right: 0; }

/* ---- Category section ---- */
.cat-section { margin-bottom: 1rem; border-bottom: 1px solid var(--rule-light); padding-bottom: 0.5rem; }
.cat-section:last-child { border-bottom: none; margin-bottom: 0; }
.cat-header { display: flex; align-items: baseline; gap: 0.3rem; padding-bottom: 0.2rem; border-bottom: 2px solid var(--rule); margin-bottom: 0.4rem; }
.cat-icon { font-size: 0.9rem; }
.cat-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); }
.cat-count { font-family: var(--font-accent); font-style: italic; font-size: 0.7rem; color: var(--ink-ghost); margin-left: auto; }

/* ---- Mid-hype entry ---- */
.entry-mid { display: block; padding: 0.35rem 0; border-bottom: 1px dotted var(--rule-light); cursor: pointer; transition: background var(--transition); }
.entry-mid:last-child { border-bottom: none; }
.entry-mid:hover { background: var(--paper-dark); margin: 0 -0.4rem; padding: 0.35rem 0.4rem; }
.entry-mid-title { font-family: var(--font-display); font-weight: 700; line-height: 1.25; color: var(--ink); }
.entry-mid-title .fire { color: var(--fire); }

.entry-mid.tier-hot .entry-mid-title { font-size: 1.1rem; }
.entry-mid.tier-hot .entry-mid-snippet {
  font-size: 0.9rem; color: var(--ink-light); line-height: 1.45;
  margin-top: 0.15rem;
}
.entry-mid.tier-upper .entry-mid-title { font-size: 1.05rem; }
.entry-mid.tier-upper .entry-mid-snippet {
  font-size: 0.875rem; color: var(--ink-mid); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 0.1rem;
}
.entry-mid.tier-lower .entry-mid-title { font-size: 0.95rem; }
.entry-mid.tier-lower .entry-mid-snippet { display: none; }
.entry-mid-meta { font-family: var(--font-accent); font-style: italic; font-size: 0.7rem; color: var(--ink-ghost); margin-top: 0.08rem; display: flex; align-items: center; gap: 0.3rem; }

/* ---- Entry date badge ---- */
.entry-date {
  font-family: var(--font-accent); font-style: normal;
  font-size: 0.65rem; font-weight: 700;
  color: var(--gold); letter-spacing: 0.03em;
  text-transform: lowercase;
}

/* ---- Latest feed (chronological view) ---- */
.latest-feed { max-width: 780px; margin: 0 auto; padding: 0.5rem 0; }
.latest-day { margin-bottom: 1rem; }
.latest-day-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.4rem; padding-top: 0.2rem;
}
.latest-day-label {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  text-transform: capitalize; color: var(--ink); white-space: nowrap;
}
.latest-day-rule { flex: 1; height: 1px; background: var(--rule); }

.latest-entry {
  display: flex; gap: 0.6rem; padding: 0.4rem 0.3rem;
  border-bottom: 1px dotted var(--rule-light);
  cursor: pointer; transition: background var(--transition);
}
.latest-entry:last-child { border-bottom: none; }
.latest-entry:hover { background: var(--paper-dark); margin: 0 -0.3rem; padding: 0.4rem 0.6rem; }
.latest-entry-hot { border-left: 2px solid var(--gold); padding-left: 0.5rem; }

.latest-entry-time {
  font-family: var(--font-accent); font-size: 0.75rem;
  color: var(--ink-faint); white-space: nowrap;
  padding-top: 0.15rem; min-width: 2.5rem;
}
.latest-entry-body { flex: 1; min-width: 0; }
.latest-entry-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.05rem; line-height: 1.25; color: var(--ink);
}
.latest-entry-title .fire { color: var(--fire); }
.latest-entry-annotation {
  font-size: 0.9rem; color: var(--ink-mid); line-height: 1.4;
  margin-top: 0.1rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.latest-entry-meta {
  font-family: var(--font-accent); font-style: italic;
  font-size: 0.7rem; color: var(--ink-ghost);
  margin-top: 0.1rem; display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap;
}
.latest-entry-cat { font-style: normal; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; font-size: 0.6rem; letter-spacing: 0.04em; }
.latest-entry-sep { color: var(--rule-light); }
.latest-entry-score { color: var(--gold); font-style: normal; font-weight: 700; }

/* ---- Art of the Week (inset in column) ---- */
.art-section {
  border: 2px solid var(--rule);
  margin-bottom: 1rem;
  padding: 0.6rem;
  background: var(--paper-dark);
}
.art-image-wrap { width: 100%; margin-bottom: 0.4rem; }
.art-image-wrap img { width: 100%; height: auto; }
.art-placeholder {
  width: 100%; height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); font-size: 2rem; color: var(--ink-ghost);
}
.art-info { font-family: var(--font-accent); }
.art-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); margin-bottom: 0.15rem; }
.art-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; line-height: 1.2; color: var(--ink); }
.art-artist { font-style: italic; font-size: 0.85rem; color: var(--ink-mid); margin-top: 0.1rem; }
.art-artist a { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }
.art-desc { font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.2rem; line-height: 1.4; font-style: italic; }

/* ---- Ornament ---- */
.ornament { text-align: center; padding: 0.4rem 0; font-size: 0.85rem; color: var(--rule); letter-spacing: 0.4em; }

/* ---- Footer ---- */
.site-footer {
  border-top: 2px solid var(--rule-heavy);
  max-width: var(--max-width); margin: 0.75rem auto 0;
  padding: 0.4rem 1rem; text-align: center;
}
.footer-text { font-family: var(--font-accent); font-style: italic; font-size: 0.75rem; color: var(--ink-faint); }
.footer-text a { color: var(--gold); }

/* ---- Loading & Empty ---- */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 200px; gap: 0.5rem; color: var(--ink-faint); font-family: var(--font-accent); font-style: italic; }
.loading-spinner { width: 24px; height: 24px; border: 2px solid var(--rule-light); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--ink-faint); font-family: var(--font-accent); font-style: italic; }
.empty-state-icon { font-size: 2rem; margin-bottom: 0.3rem; }
.error-banner { background: var(--error-bg); color: var(--fire); padding: 0.4rem 0.75rem; border: 1px solid rgba(196,74,26,0.2); font-size: 0.9rem; margin: 0.5rem 0; font-family: var(--font-accent); }

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet: 3 cols → 2 cols */
@media (max-width: 960px) {
  .broadsheet { grid-template-columns: 1fr 1fr; }
  .broadsheet-col:nth-child(2) { border-right: none; }
}

/* Mobile */
@media (max-width: 768px) {
  .corner-title { display: none; }

  /* Masthead compact */
  .masthead { padding: 0.5rem 0.6rem 0.3rem; }
  .masthead-title { font-size: 2.2rem; }
  .masthead-sub { display: none; }
  .masthead-rule { margin-top: 0.2rem; }

  /* Nav: horizontal scroll, no wrap */
  .nav-bar {
    flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0.25rem 0.5rem; gap: 0;
    scrollbar-width: none;
  }
  .nav-bar::-webkit-scrollbar { display: none; }
  .nav-link { padding: 0.25rem 0.6rem; font-size: 0.8rem; flex-shrink: 0; }

  /* Latest feed mobile */
  .latest-feed { padding: 0.3rem 0; }
  .latest-entry { padding: 0.5rem 0.3rem; min-height: 2.75rem; }
  .latest-entry-title { font-size: 1rem; }

  /* Ticker smaller */
  .ticker-item { font-size: 0.75rem; }
  .ticker-cat { font-size: 0.6rem; }

  /* Headlines: stack to single column on mobile */
  .headline-feature { grid-template-columns: 1fr; }
  .headline-main { padding-right: 0; border-right: none; border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; margin-bottom: 0.3rem; }
  .headline-main-title { font-size: 1.4rem; }
  .headline-sidebar-item { padding-left: 0; }

  /* Broadsheet: single column stack */
  .broadsheet { grid-template-columns: 1fr; }
  .broadsheet-col { border-right: none; padding: 0; border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; margin-bottom: 0.3rem; }
  .broadsheet-col:last-child { border-bottom: none; margin-bottom: 0; }

  /* Entries: larger touch targets */
  .entry-mid { padding: 0.5rem 0; min-height: 2.75rem; }
  .entry-mid-title { font-size: 1rem !important; }
  .entry-mid-meta { font-size: 0.7rem; }

  /* Art section: full-bleed */
  .art-section { margin: 0 -0.6rem 1rem; padding: 0.8rem; border-left: none; border-right: none; }

  .page-wrapper { padding: 0 0.6rem; }
  .site-footer { padding: 0.3rem 0.6rem; }
}

/* Small mobile */
@media (max-width: 480px) {
  .masthead { padding: 0.4rem 0.5rem 0.25rem; }
  .masthead-title { font-size: 1.8rem; }
  .masthead-date { font-size: 0.7rem; }
  .headline-main-title { font-size: 1.2rem; }
  .headline-main-annotation { font-size: 0.875rem; }
  .nav-link { font-size: 0.75rem; padding: 0.2rem 0.4rem; }
  .cat-title { font-size: 0.85rem; }
  .page-wrapper { padding: 0 0.4rem; }
}
