/* Homepage and shared reader refinements. Keep the existing library routes and artwork. */
:root { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171c25;
  --white: #202732;
  --cream: #2a3342;
  --ink: #f2e9db;
  --muted: #c2bbaf;
  --teal: #a7c8df;
  --green: #a7c8df;
  --gold: #c5a46b;
  --gold-dark: #e0bd82;
  --line: #465160;
  --shadow: 0 14px 35px #090b123d;
}

.navright .theme-toggle {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 8px;
}
.theme-toggle svg { width: 21px; height: 21px; }
.theme-toggle:hover { background: var(--cream); }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
.footer-brand { display: flex; align-items: center; gap: 9px; font: 700 23px Georgia, serif; color: var(--ink); margin-bottom: 8px; }
.footer-brand svg { width: 17px; height: 24px; flex: none; color: var(--gold-dark); }

.home-hero, .home-hero .herogrid { min-height: 0; }
.home-hero .herogrid {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  max-width: 1160px;
  gap: clamp(12px, 4vw, 58px);
  align-items: center;
}
.home-hero .herocopy { grid-area: 1 / 1; padding: 38px 0; }
.home-hero-art { grid-area: 1 / 2; width: 100%; justify-self: center; align-self: center; }
.home-hero .herocopy h1 { font-size: clamp(2.45rem, 5vw, 4rem); }
.home-hero .herocopy h1 em { white-space: normal; }
.home-hero .jesus-art {
  position: static;
  min-width: 0;
  display: block;
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  justify-self: center;
  align-self: end;
  opacity: 1;
  pointer-events: auto;
  border-radius: 8px;
  mask-image: none;
}
.home-hero .gospel-hero-link { min-height: 44px; align-items: center; }
.home-library { max-width: 1160px; padding-top: 25px; padding-bottom: 35px; }
.home-library-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 13px; }
.home-library-heading h2 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.1rem); }
.library-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.library-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.library-tile:hover { color: var(--ink); border-color: var(--gold-dark); box-shadow: var(--shadow); }
.library-tile img { display: block; width: 100%; height: auto; aspect-ratio: 2.2; object-fit: cover; background: var(--cream); }
.library-tile-copy { display: grid; gap: 4px; padding: 12px 14px 15px; }
.library-tile-copy strong { font: 700 clamp(1.04rem, 2vw, 1.2rem)/1.22 Georgia, serif; }
.library-tile-copy > span { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.library-tile:nth-child(5) img { object-position: center 37%; }
.library-tile:last-child { grid-column: span 2; display: grid; grid-template-columns: 1fr 1fr; background: var(--cream); }
.library-tile:last-child img { height: 100%; }
.library-tile:last-child .library-tile-copy { align-content: center; }
.library-tile:last-child .library-tile-copy > span { color: var(--gold-dark); font-weight: 700; }
.home-study-links { display: flex; flex-wrap: wrap; gap: 0 20px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 6px; }
.home-study-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: .9rem; color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }

.article { padding: clamp(19px, 4vw, 44px); }
.article > p, .article section > p, .article section > ul, .article section > ol {
  max-width: 68ch;
  font-size: clamp(1rem, .94rem + .25vw, 1.1rem);
  line-height: 1.77;
  color: var(--ink);
}
.article :where(h2, h3) { text-wrap: pretty; }
.article section + section { margin-top: clamp(22px, 3vw, 36px); }
.article p a:not(.chip), .article li a:not(.chip) { text-underline-offset: .2em; }
.chapter-table-wrap { scrollbar-color: var(--muted) var(--cream); }
:where(a, button, input, select, summary):focus-visible { outline: 2px solid var(--gold-dark); outline-offset: 3px; }

[data-theme="dark"] :is(.topbar, .article, .contentcard, .panel, .sidenav, .phone-tabs, .mobile-menu, .searchbar,
  .history-era-nav, .history-event > details, .timeitem details, .gospel-expand, .bible-quicklinks a, .bible-timeline li a,
  .topic-category-nav a, .compare-top, .compare-col, .figline, .field, select, .outline, .empty, .app-instructions,
  .free-verse-article, .personality-question, .lab-surface, .lab-tile, .dialog, .answer, .quizbox, .facttable) {
  background: var(--white);
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] :is(.footer, .pagehero, .readingnote, .callout, .info-card, .study-glance, .study-comparison thead, .study-comparison tbody th,
  .chapter-table thead, .bible-timeline, .bible-key, .bible-verse, .bible-lightbox, .bible-lightbox button,
  .gospel-scripture, .chip, .tags span, .history-development, .history-related > a, .history-event > details[open] > summary,
  .mobile-menu a, .phone-tab.selected, .notice, .quiz-feedback, .personality-opts button, .free-verse-quote, .free-verse-notice, .adslot) {
  background: var(--cream);
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] .navlinks a { color: var(--muted); }
[data-theme="dark"] .navlinks a:is(.active, :hover) { color: var(--ink); }
[data-theme="dark"] .home-hero .gospel-hero-link { background: var(--white); border-color: var(--line); }
[data-theme="dark"] .home-hero .gospel-hero-link:hover { background: var(--cream); }
[data-theme="dark"] .studio-hero h1 { color: var(--ink); }
[data-theme="dark"] .studio-hero p { color: var(--muted); }
[data-theme="dark"] .free-verse-grid section { background: var(--cream); border-color: var(--line); }
[data-theme="dark"] :is(.free-verse-grid p, .free-verse-notice p) { color: var(--muted); }
[data-theme="dark"] .free-verse-grid a { color: var(--teal); }
[data-theme="dark"] .home-hero { background: linear-gradient(110deg, #202733, #2d2a34); }
[data-theme="dark"] :is(.studio-hero, .gospel-hero) { background: linear-gradient(115deg, #1b2230, #302838); }
[data-theme="dark"] :is(.brand small, .breadcrumbs, .herocopy p, .pagehero p, .contentcard p, .figline small,
  .timeitem details p, .history-overview > p, .study-meta, .study-source-note, .compare-col p, .sidenav a,
  .bible-reading-meta, .bible-citations, .bible-painting figcaption, .gospel-painting figcaption, .phone-tab) { color: var(--muted); }
[data-theme="dark"] :is(.breadcrumbs a, .kicker, .eyebrow, .cardfoot, .timeyear, .compare-col label,
  .facttable th, .gospel-scripture .eyebrow, .gospel-hero-link, .phone-tab.selected) { color: var(--gold-dark); }
[data-theme="dark"] :is(.source-link, .article a:not(.btn):not(.chip), .study-scripture) { color: var(--teal); }
[data-theme="dark"] :is(.bible-article h3, .bible-notes summary, .bible-verse blockquote,
  .gospel-expand > summary, .gospel-scripture strong) { color: var(--ink); }
[data-theme="dark"] .gospel-scripture strong { box-shadow: none; }
[data-theme="dark"] :is(.sidenav a, .facttable th, .facttable td, .chapter-table th, .chapter-table td,
  .study-comparison th, .study-comparison td) { border-color: var(--line); }
[data-theme="dark"] .searchbar input { background: transparent; color: var(--ink); }
[data-theme="dark"] .searchbar input::placeholder { color: var(--muted); opacity: 1; }
[data-theme="dark"] .primary { color: var(--paper); }
[data-theme="dark"] .primary:hover { background: var(--teal); }
[data-theme="dark"] .goldbtn { color: #211a13; }

@media (max-width: 820px) {
  .library-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-tile:last-child { grid-column: 1 / -1; grid-template-columns: minmax(120px, 1fr) 2fr; }
  .library-tile:last-child img { max-height: 125px; }
}
@media (max-width: 700px) {
  .home-hero, [data-theme="dark"] .home-hero { background: var(--hero-mobile-surface, #f5ebde); }
  [data-theme="dark"] .home-hero { --hero-mobile-surface: #252731; }
  .home-hero .herogrid { gap: 0; grid-template-columns: minmax(0, 1fr); padding-inline: 0; }
  .home-hero-art { grid-area: 1 / 1; position: relative; width: 100%; }
  .home-hero-art::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    height: 22px;
    background: linear-gradient(transparent, var(--hero-mobile-surface, #f5ebde));
    pointer-events: none;
  }
  .home-hero .jesus-art {
    max-height: none;
    border-radius: 0;
  }
  .home-hero .herocopy {
    grid-area: 2 / 1;
    padding: 0 max(18px, env(safe-area-inset-right)) 22px max(18px, env(safe-area-inset-left));
  }
  .home-hero .herocopy h1 { font-size: clamp(2.05rem, 8.7vw, 2.65rem); margin-top: 10px; text-wrap: balance; }
  .home-hero .searchbar { margin-top: 15px; }
  .home-hero .gospel-hero-link { margin-top: 10px; }
  .home-library { padding-top: 18px; padding-bottom: 24px; }
  .library-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .library-tile-copy { padding: 9px 10px 12px; }
  .library-tile:last-child { grid-template-columns: minmax(100px, 1fr) 1fr; }
  .library-tile:last-child img { max-height: 98px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
