/* Cosmas Indicopleustes Book II reader — scoped to this page. */

.cosmas-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cosmas-skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 20;
  transform: translateY(-200%);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  padding: 0.5rem 0.85rem;
  border-radius: 0.35rem;
  text-decoration: none;
}

.cosmas-skip:focus,
.cosmas-skip:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--thf-link);
  outline-offset: 2px;
}

body.has-v1-sidebar:has(.cosmas-page),
body.has-v1-sidebar:has(.cosmas-page) .wrapper,
body.has-v1-sidebar:has(.cosmas-page) .content-wrapper,
html[data-theme="dark"] body.has-v1-sidebar:has(.cosmas-page),
html[data-theme="dark"] body.has-v1-sidebar:has(.cosmas-page) .wrapper,
html[data-theme="dark"] body.has-v1-sidebar:has(.cosmas-page) .content-wrapper,
body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page),
body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page) .wrapper,
body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page) .content-wrapper,
html[data-theme="dark"] body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page),
html[data-theme="dark"] body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page) .wrapper,
html[data-theme="dark"] body.is-pwa-standalone.has-v1-sidebar:has(.cosmas-page) .content-wrapper {
  background: var(--thf-bg);
  color: var(--thf-text);
}

.cosmas-content-wrapper {
  box-sizing: border-box;
  padding: 1rem 1rem 3rem;
}

body.is-pwa-standalone .cosmas-content-wrapper,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-content-wrapper {
  padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
}

.cosmas-page,
html[data-theme="dark"] .cosmas-page,
body.is-pwa-standalone .cosmas-page,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-page {
  max-width: 78rem;
  margin: 0 auto;
  background: var(--thf-bg);
  color: var(--thf-text);
}

.cosmas-header,
.cosmas-toolbar,
.cosmas-toc,
.cosmas-section,
.cosmas-pending,
.cosmas-footnotes,
html[data-theme="dark"] .cosmas-header,
html[data-theme="dark"] .cosmas-toolbar,
html[data-theme="dark"] .cosmas-toc,
html[data-theme="dark"] .cosmas-section,
html[data-theme="dark"] .cosmas-pending,
html[data-theme="dark"] .cosmas-footnotes,
body.is-pwa-standalone .cosmas-header,
body.is-pwa-standalone .cosmas-toolbar,
body.is-pwa-standalone .cosmas-toc,
body.is-pwa-standalone .cosmas-section,
body.is-pwa-standalone .cosmas-pending,
body.is-pwa-standalone .cosmas-footnotes,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-header,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-toolbar,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-toc,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-section,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-pending,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-footnotes {
  background: var(--thf-surface);
  color: var(--thf-text);
  border: 1px solid var(--thf-border);
}

.cosmas-header,
.cosmas-toolbar,
.cosmas-toc,
.cosmas-section,
.cosmas-pending,
.cosmas-footnotes {
  border-radius: 0.75rem;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.cosmas-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--thf-text-2);
}

.cosmas-page h1,
.cosmas-page h2,
.cosmas-page h3,
html[data-theme="dark"] .cosmas-page h1,
html[data-theme="dark"] .cosmas-page h2,
html[data-theme="dark"] .cosmas-page h3,
body.is-pwa-standalone .cosmas-page h1,
body.is-pwa-standalone .cosmas-page h2,
body.is-pwa-standalone .cosmas-page h3,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-page h1,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-page h2,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-page h3 {
  color: var(--thf-heading);
  font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif;
}

.cosmas-page h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.2;
}

.cosmas-lede,
.cosmas-editorial,
.cosmas-modern-help,
.cosmas-toc-empty,
.cosmas-pending p,
.cosmas-footnotes-lede,
.cosmas-footnotes-pending,
.cosmas-footnote-meta {
  color: var(--thf-text-2);
  line-height: 1.65;
}

.cosmas-lede {
  margin: 0 0 1rem;
  max-width: 46rem;
}

.cosmas-credits {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.cosmas-credit-label {
  display: inline-block;
  margin-right: 0.4rem;
  font-weight: 700;
  color: var(--thf-heading);
}

.cosmas-pd,
.cosmas-pending-pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--thf-border);
  background: var(--thf-surface-2);
  color: var(--thf-text-2);
  font-size: 0.78rem;
}

.cosmas-editorial {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--thf-surface-2);
  border-radius: 0.5rem;
  color: var(--thf-text);
}

.cosmas-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  align-items: center;
}

.cosmas-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--primary-btn-bg);
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  text-decoration: none;
  font-weight: 650;
}

.cosmas-btn-secondary {
  background: var(--thf-surface-2);
  color: var(--thf-text);
  border-color: var(--thf-border);
}

.cosmas-btn-disabled {
  opacity: 0.62;
  cursor: not-allowed;
  pointer-events: none;
}

.cosmas-pending-hint {
  color: var(--thf-text-2);
  font-size: 0.9rem;
}

.cosmas-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 0.85rem;
}

.cosmas-view-toggle {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.cosmas-view-toggle legend {
  padding: 0;
  margin-bottom: 0.45rem;
  font-weight: 700;
  color: var(--thf-heading);
}

.cosmas-view-toggle [role="radiogroup"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.cosmas-view-toggle label,
.cosmas-modern-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--thf-border);
  background: var(--thf-surface-2);
  color: var(--thf-text);
  cursor: pointer;
}

.cosmas-view-toggle label:has(input:checked),
html[data-theme="dark"] .cosmas-view-toggle label:has(input:checked),
body.is-pwa-standalone .cosmas-view-toggle label:has(input:checked),
html[data-theme="dark"] body.is-pwa-standalone .cosmas-view-toggle label:has(input:checked) {
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  border-color: var(--primary-btn-bg);
}

.cosmas-view-toggle input,
.cosmas-modern-toggle input {
  accent-color: var(--primary-btn-bg);
}

.cosmas-modern-help {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
}

.cosmas-reader[data-view="greek"] .cosmas-modern-toggle,
.cosmas-reader[data-view="english"] .cosmas-modern-toggle,
.cosmas-page:has(#cosmas-view-greek:checked) .cosmas-modern-toggle,
.cosmas-page:has(#cosmas-view-english:checked) .cosmas-modern-toggle {
  display: none;
}

.cosmas-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.cosmas-layout > *,
.cosmas-col {
  min-width: 0;
}

.cosmas-page {
  overflow-wrap: anywhere;
}

@media (max-width: 899px) {
  .cosmas-toolbar {
    position: static;
  }
}

.cosmas-toc h2,
.cosmas-section-head h2,
.cosmas-col h3,
.cosmas-pending h2 {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
}

.cosmas-toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
}

.cosmas-toc a,
.cosmas-section-anchor,
.cosmas-page a {
  color: var(--thf-link);
}

.cosmas-toc a {
  display: inline-block;
  max-width: 16rem;
  padding: 0.45rem 0.7rem;
  border-radius: 0.45rem;
  border: 1px solid var(--thf-border);
  background: var(--thf-surface-2);
  color: var(--thf-text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cosmas-toc a:hover,
.cosmas-toc a:focus-visible,
.cosmas-toc a[aria-current="true"] {
  outline: 2px solid var(--thf-link);
  outline-offset: 2px;
  color: var(--thf-heading);
  background: var(--thf-surface);
}

.cosmas-page a:focus-visible,
.cosmas-page button:focus-visible,
.cosmas-page input:focus-visible,
.cosmas-page [role="radio"]:focus-visible {
  outline: 2px solid var(--thf-link);
  outline-offset: 2px;
}

.cosmas-section:target,
.cosmas-footnote:target,
.cosmas-footnotes:target {
  outline: 2px solid var(--thf-link);
  outline-offset: 3px;
}

.cosmas-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-bottom: 0.75rem;
}

.cosmas-section-anchor {
  text-decoration: none;
}

.cosmas-source-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--thf-text-2);
  font-size: 0.92rem;
}

.cosmas-align-warn,
html[data-theme="dark"] .cosmas-align-warn,
body.is-pwa-standalone .cosmas-align-warn,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-align-warn {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--thf-link);
  background: var(--thf-surface-2);
  color: var(--thf-text);
  border-radius: 0 0.4rem 0.4rem 0;
}

.cosmas-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.cosmas-col,
html[data-theme="dark"] .cosmas-col,
body.is-pwa-standalone .cosmas-col,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-col {
  background: var(--thf-surface-2);
  color: var(--thf-text);
  border: 1px solid var(--thf-border);
  border-radius: 0.6rem;
  padding: 0.9rem 1rem 1.05rem;
}

.cosmas-greek,
.cosmas-english,
.cosmas-modern {
  margin: 0;
  max-width: 42em;
}

.cosmas-greek {
  font-family: "Palatino Linotype", Palatino, "Times New Roman", Georgia, serif;
  font-size: 1.2rem;
  line-height: 1.9;
  white-space: pre-wrap;
}

.cosmas-english,
.cosmas-modern,
.cosmas-modern-pending {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--thf-text);
}

.cosmas-uncertain,
html[data-theme="dark"] .cosmas-uncertain,
body.is-pwa-standalone .cosmas-uncertain,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-uncertain {
  background: var(--thf-surface);
  color: inherit;
  border-bottom: 2px dotted var(--thf-link);
  padding: 0 0.12em;
  border-radius: 0.15rem;
}

.cosmas-modern-pending {
  margin: 0;
  color: var(--thf-text-2);
  font-style: italic;
}

.cosmas-notes {
  margin: 0.9rem 0 0;
  padding-left: 1.2rem;
  color: var(--thf-text-2);
}

.cosmas-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 1rem 0 0;
}

.cosmas-stats div {
  background: var(--thf-surface);
  border: 1px solid var(--thf-border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
}

.cosmas-stats dt {
  color: var(--thf-text-2);
  font-size: 0.8rem;
}

.cosmas-stats dd {
  margin: 0;
  color: var(--thf-heading);
  font-weight: 700;
}

.cosmas-col-modern {
  display: none;
}

.cosmas-toc-notes {
  margin: 0.75rem 0 0;
}

.cosmas-toc-notes a {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  border-radius: 0.45rem;
  border: 1px solid var(--thf-border);
  background: var(--thf-surface-2);
  color: var(--thf-text);
  text-decoration: none;
}

.cosmas-toc-notes a:hover,
.cosmas-toc-notes a:focus-visible,
.cosmas-toc-notes a[aria-current="true"] {
  outline: 2px solid var(--thf-link);
  outline-offset: 2px;
  color: var(--thf-heading);
  background: var(--thf-surface);
}

.cosmas-footnotes summary {
  cursor: pointer;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  font-weight: 700;
  color: var(--thf-heading);
}

.cosmas-footnotes summary:focus-visible {
  outline: 2px solid var(--thf-link);
  outline-offset: 2px;
}

.cosmas-footnotes-lede,
.cosmas-footnotes-pending {
  margin: 0.75rem 0 0;
}

.cosmas-footnote-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.cosmas-footnote,
html[data-theme="dark"] .cosmas-footnote,
body.is-pwa-standalone .cosmas-footnote,
html[data-theme="dark"] body.is-pwa-standalone .cosmas-footnote {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid var(--thf-border);
  background: var(--thf-surface-2);
  color: var(--thf-text);
}

.cosmas-footnote-num {
  font-weight: 700;
  text-decoration: none;
  color: var(--thf-link);
}

.cosmas-footnote-body {
  grid-column: 2;
  margin: 0;
  white-space: pre-wrap;
  color: var(--thf-text);
  line-height: 1.7;
}

.cosmas-footnote-meta {
  grid-column: 2;
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
}

.cosmas-page:has(#cosmas-view-greek:checked) .cosmas-col-english,
.cosmas-page:has(#cosmas-view-english:checked) .cosmas-col-greek,
.cosmas-page[data-view="greek"] .cosmas-col-english,
.cosmas-page[data-view="english"] .cosmas-col-greek {
  display: none;
}

.cosmas-page:has(#cosmas-view-parallel:checked):has(#cosmas-modern:checked) .cosmas-col-modern,
.cosmas-page[data-view="parallel"][data-modern="on"] .cosmas-col-modern {
  display: block;
}

@media (min-width: 900px) {
  .cosmas-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    align-items: start;
  }

  .cosmas-toc {
    position: sticky;
    top: 6.5rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
  }

  .cosmas-toc ol {
    display: grid;
    gap: 0.35rem;
    overflow: visible;
  }

  .cosmas-toc a {
    max-width: none;
    white-space: normal;
  }

  .cosmas-page:has(#cosmas-view-parallel:checked) .cosmas-columns,
  .cosmas-page[data-view="parallel"] .cosmas-columns {
    grid-template-columns: 1fr 1fr;
  }

  .cosmas-page:has(#cosmas-view-parallel:checked):has(#cosmas-modern:checked) .cosmas-columns,
  .cosmas-page[data-view="parallel"][data-modern="on"] .cosmas-columns {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cosmas-page,
  .cosmas-toc a {
    scroll-behavior: auto;
  }
}

/* A quiet modern reading mode; source gaps remain in the text itself. */
.cosmas-page[data-view="modern"] .cosmas-col-greek,
.cosmas-page[data-view="modern"] .cosmas-col-english,
.cosmas-page[data-view="modern"] .cosmas-align-warn,
.cosmas-page[data-view="modern"] .cosmas-section[data-has-modern="no"],
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-col-greek,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-col-english,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-align-warn,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-section[data-has-modern="no"] { display: none; }
.cosmas-page[data-view="modern"] .cosmas-col-modern,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-col-modern { display: block; }
.cosmas-page[data-view="modern"] .cosmas-columns,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-columns { grid-template-columns: minmax(0, 1fr); }
.cosmas-page[data-view="modern"] .cosmas-modern,
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-modern { max-width: 72ch; font-size: 1.12rem; line-height: 1.85; }
.cosmas-page:has(#cosmas-view-modern:checked) .cosmas-modern-toggle { display: none; }
.cosmas-editorial-details { margin-top: 1rem; font-size: .9rem; }
.cosmas-editorial-details > summary { cursor: pointer; color: var(--thf-text-muted, #687385); padding: .5rem 0; }

/* Separate everyday-English edition: one readable column or a Greek comparison. */
.cosmas-col-plain { display: none; }
.cosmas-page[data-view="plain"] .cosmas-col-greek,
.cosmas-page[data-view="plain"] .cosmas-col-english,
.cosmas-page[data-view="plain"] .cosmas-col-modern,
.cosmas-page[data-view="plain"] .cosmas-align-warn,
.cosmas-page[data-view="plain"] .cosmas-section[data-has-plain="no"],
.cosmas-page[data-view="plain"] .cosmas-footnotes,
.cosmas-page[data-view="plain"] .cosmas-toc-notes,
.cosmas-page[data-view="plain-parallel"] .cosmas-col-english,
.cosmas-page[data-view="plain-parallel"] .cosmas-col-modern,
.cosmas-page[data-view="plain-parallel"] .cosmas-align-warn,
.cosmas-page[data-view="plain-parallel"] .cosmas-section[data-has-plain="no"],
.cosmas-page[data-view="plain-parallel"] .cosmas-footnotes,
.cosmas-page[data-view="plain-parallel"] .cosmas-toc-notes { display: none; }
.cosmas-page[data-view="plain"] .cosmas-col-plain,
.cosmas-page[data-view="plain-parallel"] .cosmas-col-plain { display: block; }
.cosmas-page[data-view="plain"] .cosmas-columns,
.cosmas-page[data-view="plain-parallel"] .cosmas-columns { grid-template-columns: minmax(0, 1fr); }
.cosmas-page[data-view="plain-parallel"] .cosmas-col-greek { order: 1; }
.cosmas-page[data-view="plain-parallel"] .cosmas-col-plain { order: 2; }
.cosmas-plain { max-width: 72ch; font-size: 1.12rem; line-height: 1.85; }
.cosmas-plain p { margin: 0 0 1em; }
.cosmas-plain p:last-child { margin-bottom: 0; }
@media (min-width: 900px) {
  .cosmas-page[data-view="plain-parallel"] .cosmas-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
