/* Shared library atlas. Loaded after each page's own styles. */
html { scroll-padding-top: 4.6rem; scroll-padding-bottom: 4.8rem; }
html[data-pillar="shruti"] {
  --pillar: #D97706;
  --pillar-bright: #D97706;
  --pillar-soft: rgba(217, 119, 6, 0.14);
}
html[data-pillar="darsana"] {
  --pillar: #4F46E5;
  --pillar-bright: #2563EB;
  --pillar-soft: rgba(79, 70, 229, 0.12);
}
html[data-pillar="itihasa"] {
  --pillar: #DC2626;
  --pillar-bright: #DC2626;
  --pillar-soft: rgba(220, 38, 38, 0.12);
}
html[data-pillar="purana"] {
  --pillar: #0D9488;
  --pillar-bright: #0D9488;
  --pillar-soft: rgba(13, 148, 136, 0.14);
}

html[data-pillar="shruti"] .bar,
html[data-pillar="darsana"] .bar,
html[data-pillar="itihasa"] .bar,
html[data-pillar="purana"] .bar,
html[data-pillar="shruti"] .atlas-toolsbar,
html[data-pillar="darsana"] .atlas-toolsbar,
html[data-pillar="itihasa"] .atlas-toolsbar,
html[data-pillar="purana"] .atlas-toolsbar {
  border-top: 3px solid var(--pillar);
  border-bottom-color: var(--pillar);
}
html[data-pillar="shruti"] .bar-menu > summary,
html[data-pillar="darsana"] .bar-menu > summary,
html[data-pillar="itihasa"] .bar-menu > summary,
html[data-pillar="purana"] .bar-menu > summary {
  border-color: var(--pillar);
  color: var(--pillar);
}
html[data-pillar="shruti"] .bar-panel a[aria-current="true"],
html[data-pillar="darsana"] .bar-panel a[aria-current="true"],
html[data-pillar="itihasa"] .bar-panel a[aria-current="true"],
html[data-pillar="purana"] .bar-panel a[aria-current="true"] {
  box-shadow: inset 3px 0 0 var(--pillar);
}

.atlas-tools, .atlas-toolsbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.atlas-tools { margin-left: auto; flex: 0 0 auto; }
.atlas-toolsbar {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 0.45rem 1rem;
  background: rgba(253, 246, 233, 0.96);
  border-bottom: 1px solid rgba(44, 34, 26, 0.12);
}
.atlas-tools button, .atlas-toolsbar button, .atlas-step button {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  border-radius: 999px;
  border: 1px solid rgba(44, 34, 26, 0.22);
  background: #fffaf3;
  color: #2c221a;
  padding: 0.28rem 0.65rem;
  cursor: pointer;
}
.atlas-open {
  border-color: var(--pillar, #b5451d) !important;
  color: var(--pillar, #b5451d) !important;
}
.atlas-open[aria-expanded="true"] {
  background: var(--pillar, #b5451d);
  color: #fffaf3 !important;
}
.atlas-tools button:focus-visible,
.atlas-toolsbar button:focus-visible,
.atlas-step a:focus-visible,
.atlas-step button:focus-visible,
.atlas-crumbs a:focus-visible,
.atlas-panel a:focus-visible,
.atlas-search-panel a:focus-visible,
.atlas-search-panel input:focus-visible {
  outline: 2px solid var(--pillar, #b5451d);
  outline-offset: 2px;
}

.atlas-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.35rem;
  margin: 0;
  padding: 0.45rem 1rem 0.55rem;
  font-size: 0.92rem;
  line-height: 1.35;
}
.atlas-crumbs a { text-decoration: none; font-weight: 650; }
.atlas-crumbs [aria-current="page"] {
  color: var(--pillar, #2c221a);
  font-weight: 750;
}
.atlas-crumbs .atlas-sep { color: rgba(44, 34, 26, 0.4); }

/* The pill bar already says Home, this shelf, and the chapter. Hide the copy under it, and the in-page path and pager. */
html[data-shelf="readings"] .where,
html[data-shelf="readings"] nav.step,
html[data-shelf="katha"] .where,
html[data-shelf="katha"] nav.step { display: none; }

/* The chapter pill is already in the top bar. The bottom bar is only previous and next. */
html[data-shelf="readings"] .atlas-step,
html[data-shelf="katha"] .atlas-step {
  grid-template-columns: 1fr 1fr;
}
html[data-shelf="readings"] .atlas-step .next,
html[data-shelf="katha"] .atlas-step .next { grid-column: 2; }
html[data-shelf="readings"] .atlas-step a,
html[data-shelf="katha"] .atlas-step a {
  line-height: 1.25;
  max-width: 100%;
}

.bridge {
  margin: 0.9rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--pillar, #b5451d);
  border-radius: 0.45rem;
  background: var(--pillar-soft, rgba(181, 69, 29, 0.08));
}

.atlas-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 18, 0.46);
}
.atlas-drawer, .atlas-search {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.atlas-search { z-index: 50; }
.atlas-drawer[hidden], .atlas-search[hidden] { display: none; }
.atlas-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(24rem, 92vw);
  overflow: auto;
  background: #fffaf3;
  color: #2c221a;
  box-shadow: -16px 0 40px rgba(44, 34, 26, 0.18);
  padding: 0.85rem 0.9rem 2rem;
}
.atlas-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}
.atlas-head, .atlas-search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.atlas-fold { margin: 0.15rem 0; }
.atlas-fold > summary {
  cursor: pointer;
  font-weight: 750;
  padding: 0.38rem 0.4rem 0.38rem 0.55rem;
  border-radius: 0.35rem;
  list-style: none;
}
.atlas-fold > summary::-webkit-details-marker { display: none; }
.atlas-fold > summary::before { content: "▸ "; font-weight: 500; }
.atlas-fold[open] > summary::before { content: "▾ "; }
.atlas-fold[data-pillar="shruti"] > summary { box-shadow: inset 3px 0 0 #D97706; }
.atlas-fold[data-pillar="darsana"] > summary { box-shadow: inset 3px 0 0 #4F46E5; }
.atlas-fold[data-pillar="itihasa"] > summary { box-shadow: inset 3px 0 0 #DC2626; }
.atlas-fold[data-pillar="purana"] > summary { box-shadow: inset 3px 0 0 #0D9488; }
.atlas-kids { margin: 0 0 0.25rem 0.7rem; }
.atlas-panel a, .atlas-search-panel a {
  display: block;
  padding: 0.32rem 0.45rem;
  border-radius: 0.35rem;
  color: #2c221a;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.35;
}
.atlas-panel a.atlas-current {
  background: var(--pillar-soft, #ead9bf);
  box-shadow: inset 3px 0 0 var(--pillar, #b5451d);
}
.atlas-search-panel {
  position: relative;
  width: min(36rem, calc(100% - 1.5rem));
  margin: 12vh auto 0;
  background: #fffaf3;
  color: #2c221a;
  border-radius: 0.8rem;
  box-shadow: 0 18px 50px rgba(44, 34, 26, 0.28);
  padding: 0.85rem;
}
.atlas-search-panel input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 1.05rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(44, 34, 26, 0.2);
  background: #fff;
  color: #2c221a;
}
.atlas-results { list-style: none; margin: 0.55rem 0 0; padding: 0; max-height: min(50vh, 22rem); overflow: auto; }
.atlas-results li { margin: 0; }
.atlas-results a small {
  display: block;
  font-weight: 500;
  color: #6d5646;
}
.atlas-results a[aria-selected="true"] { background: var(--pillar-soft, rgba(181, 69, 29, 0.1)); }
.atlas-hint { margin: 0.35rem 0 0; font-size: 0.88rem; color: #6d5646; }

.atlas-step {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem calc(0.4rem + env(safe-area-inset-bottom));
  background: #fdf6e9;
  border-top: 3px solid var(--pillar, rgba(44, 34, 26, 0.16));
  box-shadow: 0 -8px 18px rgba(44, 34, 26, 0.06);
  font-size: 0.92rem;
}
.atlas-step a, .atlas-step button.atlas-toc {
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}
.atlas-step .prev { justify-self: start; }
.atlas-step .next { justify-self: end; text-align: right; }
.atlas-step .atlas-muted { opacity: 0.38; font-weight: 650; }
.atlas-step .narrow { display: none; }
body.atlas-has-step { padding-bottom: 4.8rem; }
body.atlas-has-step main { padding-bottom: 1.2rem; }
body.atlas-lock { overflow: hidden; }

@media (max-width: 640px) {
  .atlas-step { font-size: 0.82rem; padding-left: 0.4rem; padding-right: 0.4rem; }
  .atlas-step .wide { display: none; }
  .atlas-step .narrow { display: inline; }
  .atlas-tools button, .atlas-toolsbar button { padding: 0.28rem 0.5rem; }
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body {
  background: #1c1612;
  color: #f3e6d4;
}
html[data-theme="dark"] .bar,
html[data-theme="dark"] .atlas-toolsbar,
html[data-theme="dark"] .side {
  background: rgba(28, 22, 18, 0.96);
  color: #f3e6d4;
}
html[data-theme="dark"] .atlas-step {
  background: #1c1612;
  color: #f3e6d4;
}
html[data-theme="dark"] .atlas-panel,
html[data-theme="dark"] .atlas-search-panel,
html[data-theme="dark"] .bar-panel,
html[data-theme="dark"] .bar-menu > summary,
html[data-theme="dark"] .card,
html[data-theme="dark"] .bridge,
html[data-theme="dark"] .atlas-tools button,
html[data-theme="dark"] .atlas-toolsbar button,
html[data-theme="dark"] .atlas-step button {
  background: #2a221c;
  color: #f3e6d4;
  border-color: rgba(243, 230, 212, 0.18);
}
html[data-theme="dark"] .deva {
  color: #ddcbb8;
  font-weight: 400;
}
html[data-theme="dark"] h1 .deva,
html[data-theme="dark"] h2 .deva,
html[data-theme="dark"] h3 .deva {
  color: inherit;
  font-weight: 500;
}
html[data-theme="dark"] a { color: #f0b089; }
html[data-theme="dark"] .card { color: #f3e6d4; }
html[data-theme="dark"] .card strong,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .bar-book,
html[data-theme="dark"] .bar-panel a,
html[data-theme="dark"] .atlas-panel a,
html[data-theme="dark"] .atlas-search-panel a { color: #f6ead8; }
html[data-theme="dark"] .bar-home,
html[data-theme="dark"] .bar-books,
html[data-theme="dark"] .atlas-hint,
html[data-theme="dark"] .atlas-results a small,
html[data-theme="dark"] .atlas-crumbs .atlas-sep { color: #d7c4b4; }
html[data-theme="dark"] .atlas-search-panel input {
  background: #1c1612;
  color: #f3e6d4;
  border-color: rgba(243, 230, 212, 0.22);
}
html[data-theme="dark"] .atlas-open[aria-expanded="true"] { color: #1c1612 !important; }

/* Nepali Readings and Household stories: Home, the shelf, and the chapter
   are one row of pills. The plain book link stays in the page so the bottom
   stepper can still find it. */
html[data-shelf="readings"] .bar > .bar-sep,
html[data-shelf="readings"] .bar > a.bar-book,
html[data-shelf="katha"] .bar > .bar-sep,
html[data-shelf="katha"] .bar > a.bar-book,
html[data-shelf="katha"] .bar > a.bar-books { display: none; }
html[data-shelf="readings"] .bar-home,
html[data-shelf="katha"] .bar-home {
  flex: 0 0 auto;
  padding: 0.32rem 0.75rem;
  border: 1px solid rgba(181, 69, 29, 0.35);
  border-radius: 999px;
  background: #fffaf3;
  color: #b5451d;
  font-weight: 700;
}
html[data-shelf="readings"] .bar-shelf > summary,
html[data-shelf="katha"] .bar-shelf > summary {
  max-width: 16rem;
}
html[data-shelf="readings"] .bar-menu > .bar-panel,
html[data-shelf="katha"] .bar-menu > .bar-panel {
  left: 0;
  right: auto;
}
/* A longer work sits under its writer: a small caption, then a smaller bulleted title. */
html[data-shelf="readings"] .bar-panel .bar-season,
html[data-shelf="katha"] .bar-panel .bar-season {
  padding: 0.42rem 0.65rem 0.02rem 1.2rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}
html[data-shelf="readings"] .bar-panel a.bar-work,
html[data-shelf="katha"] .bar-panel a.bar-work {
  margin-left: 1.35rem;
  padding: 0.2rem 0.55rem 0.2rem 0.15rem;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
}
html[data-shelf="readings"] .bar-panel a.bar-work:not([aria-current="true"]),
html[data-shelf="katha"] .bar-panel a.bar-work:not([aria-current="true"]) {
  color: #5c4638;
}
html[data-shelf="readings"] .bar-panel a.bar-work::before,
html[data-shelf="katha"] .bar-panel a.bar-work::before {
  content: "• ";
  color: #8a3414;
}
html[data-theme="dark"][data-shelf="readings"] .bar-panel a.bar-work:not([aria-current="true"]),
html[data-theme="dark"][data-shelf="katha"] .bar-panel a.bar-work:not([aria-current="true"]) {
  color: #d7c4b4;
}
html[data-theme="dark"][data-shelf="readings"] .bar-panel a.bar-work::before,
html[data-theme="dark"][data-shelf="katha"] .bar-panel a.bar-work::before {
  color: #f0b089;
}
html[data-shelf="katha"] .bar-sections > .bar-panel {
  left: auto;
  right: 0;
}
html[data-theme="dark"][data-shelf="readings"] .bar-home,
html[data-theme="dark"][data-shelf="katha"] .bar-home {
  background: #2a221c;
  color: #f3e6d4;
  border-color: rgba(243, 230, 212, 0.18);
}

/* Household stories: the six doors sit in one dropdown pill, the sections of
   that page sit in the next dropdown pill, then English / नेपाली. */
html[data-shelf="katha"] .lang-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex: 0 0 auto;
}
html[data-shelf="katha"] .lang-switch button {
  font: inherit;
  font-size: 0.95rem;
  color: #5c4636;
  background: transparent;
  border: 1px solid #c4b09a;
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  cursor: pointer;
}
html[data-shelf="katha"] .lang-switch button[aria-pressed="true"] {
  color: #8a3414;
  background: #ead9bf;
  border-color: #ead9bf;
  font-weight: 650;
}
html[data-shelf="katha"]:not([data-katha="ne"]) .lang-ne { display: none; }
html[data-shelf="katha"][data-katha="ne"] .lang-en { display: none; }
html[data-shelf="katha"] .katha-lang-label { display: none; }
html[data-shelf="katha"]:not([data-katha="ne"]) figure.plate figcaption .deva { display: none; }
html[data-shelf="katha"][data-katha="ne"] figure.plate figcaption { font-size: 0; }
html[data-shelf="katha"][data-katha="ne"] figure.plate figcaption .deva {
  display: block;
  margin-top: 0;
  font-size: 1rem;
}
html[data-shelf="katha"] .door-group { margin: 1.8rem 0 0.4rem; }
html[data-shelf="katha"] .door-part { margin-top: 1.4rem; }
html[data-shelf="katha"] .year-stories > article.door-part {
  margin-top: 2.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(181, 69, 29, 0.22);
}
html[data-shelf="katha"] .year-list {
  list-style: none;
  margin: 0.4rem 0 1.4rem;
  padding: 0;
}
html[data-shelf="katha"] .year-list > li {
  margin: 0;
  border-top: 1px solid rgba(181, 69, 29, 0.18);
}
html[data-shelf="katha"] .year-list > li:last-child {
  border-bottom: 1px solid rgba(181, 69, 29, 0.18);
}
html[data-shelf="katha"] .year-list > li > a {
  display: inline-block;
  margin: 0.7rem 0;
  font-weight: 650;
}
html[data-shelf="katha"] .year-list > li > p {
  margin: 0 0 0.85rem;
}
html[data-shelf="katha"] .door-part,
html[data-shelf="katha"] .door-group,
html[data-shelf="katha"] .door-part h1[id],
html[data-shelf="katha"] .door-part h2[id],
html[data-shelf="katha"] .door-part h3[id] { scroll-margin-top: 5.5rem; }
html[data-theme="dark"][data-shelf="katha"] .lang-switch button {
  background: #2a221c;
  color: #f3e6d4;
  border-color: rgba(243, 230, 212, 0.18);
}
html[data-theme="dark"][data-shelf="katha"] .lang-switch button[aria-pressed="true"] {
  background: #ead9bf;
  color: #2c221a;
  border-color: #ead9bf;
}
