/* Council of Traditions. Quiet page, readable passages. System fonts only. */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --paper: #f6f2e9;
  --surface: #fffdf8;
  --ink: #23211c;
  --soft: #6a655a;
  --rule: #e2dccd;
  --button: #2f3a34;
  --button-ink: #f6f2e9;
  --focus: #3f5f86;

  --stoic: #46596f;
  --daoist: #4a6649;
  --confucian: #80612f;
  --heraclitean: #984b36;
  --jungian: #694d72;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15140f;
    --surface: #1d1c16;
    --ink: #e9e4d8;
    --soft: #a59f90;
    --rule: #302e25;
    --button: #dcd6c7;
    --button-ink: #1a1914;
    --focus: #9db8da;

    --stoic: #9fb3c9;
    --daoist: #a3c0a1;
    --confucian: #d1b381;
    --heraclitean: #e0a08c;
    --jungian: #c3a8cc;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 40rem;
  margin: 0 auto;
  padding: calc(1.75rem + env(safe-area-inset-top)) calc(1.25rem + env(safe-area-inset-right))
    calc(2.5rem + env(safe-area-inset-bottom)) calc(1.25rem + env(safe-area-inset-left));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- masthead ------------------------------------------------------------------ */

.masthead h1 {
  margin: 0 0 1.5rem;
  font: 400 0.8125rem/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--soft);
}

/* --- asking -------------------------------------------------------------------- */

.ask textarea {
  display: block;
  width: 100%;
  min-height: 8.5rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 1.1875rem/1.5 var(--serif);
  resize: vertical;
  field-sizing: content;
}
.ask textarea::placeholder { color: var(--soft); opacity: 1; }
.ask textarea:focus-visible { outline-offset: 0; border-radius: 14px; }

.primary {
  display: block;
  width: 100%;
  margin-top: 0.875rem;
  padding: 0.9375rem 1rem;
  border: 0;
  border-radius: 14px;
  background: var(--button);
  color: var(--button-ink);
  font: 500 1.0625rem/1.2 var(--sans);
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary:disabled { opacity: 0.45; cursor: default; }

.status { margin-top: 1rem; color: var(--soft); font-size: 0.9375rem; }
.status p { margin: 0; }
.note { color: var(--soft); font-size: 0.8125rem; line-height: 1.45; }
.status .note { margin-top: 0.375rem; }

.progress {
  height: 3px;
  margin-top: 0.625rem;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}
.progress div {
  width: 0;
  height: 100%;
  background: var(--soft);
  transition: width 0.3s ease-out;
}

.link {
  padding: 0.375rem 0;
  border: 0;
  background: none;
  color: var(--soft);
  font: 0.875rem/1.3 var(--sans);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.25em;
  cursor: pointer;
}
.link:hover { color: var(--ink); }
a.link { display: inline-block; margin-left: 1rem; }
a.link[hidden] { display: none; }

/* --- the council ---------------------------------------------------------------- */

.council { margin-top: 2.25rem; scroll-margin-top: 1rem; }
.council[aria-busy="true"] { opacity: 0.55; transition: opacity 0.2s; }

.card {
  --voice: var(--soft);
  margin-top: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--surface);
}
.card:first-child { margin-top: 0; }
.tradition-stoic { --voice: var(--stoic); }
.tradition-daoist { --voice: var(--daoist); }
.tradition-confucian { --voice: var(--confucian); }
.tradition-heraclitean { --voice: var(--heraclitean); }
.tradition-jungian { --voice: var(--jungian); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.card-head h2 {
  margin: 0;
  font: 600 0.75rem/1.2 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--voice);
}

.strength {
  margin: 0;
  font: 0.75rem/1.2 var(--sans);
  letter-spacing: 0.04em;
  color: var(--soft);
}
.strength::before {
  content: "";
  display: inline-block;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-right: 0.4375rem;
  border: 1px solid var(--soft);
  border-radius: 50%;
  vertical-align: 0.03em;
}
.strength-strong::before { background: var(--soft); }

.card.is-quiet { background: none; border-style: dashed; padding-bottom: 1.25rem; }
.card.is-quiet .card-head { margin-bottom: 0.375rem; }
.quiet { margin: 0; font: italic 1.0625rem/1.5 var(--serif); color: var(--soft); }

/* The stored text. Line breaks are the text's own. */
.verbatim {
  font: 1.125rem/1.62 var(--serif);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.verbatim .mark { display: none; }

.passage { cursor: pointer; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.passage.is-folded {
  max-height: 17rem;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
}
.read-on { margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--soft); }

.around:empty { display: none; }
.neighbour { margin: 0.875rem 0; padding-left: 0.875rem; border-left: 2px solid var(--rule); }
.neighbour .verbatim { font-size: 1rem; color: var(--soft); }
.neighbour-ref {
  margin: 0 0 0.125rem;
  font: 0.6875rem/1.3 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--soft);
}

.source { margin: 0.875rem 0 0; font-size: 0.875rem; line-height: 1.4; color: var(--soft); }
.source cite { font-style: normal; font-weight: 600; color: var(--ink); }
.source-detail { margin: 0.125rem 0 0; font-size: 0.8125rem; line-height: 1.4; color: var(--soft); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

.more .hit { margin-top: 1.25rem; padding-top: 1.125rem; border-top: 1px solid var(--rule); }
.more .hit > .strength { margin-bottom: 0.625rem; }
.more .actions { border-top: 0; padding-top: 0; margin-top: 0.375rem; }

/* --- foot ----------------------------------------------------------------------- */

.foot {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  color: var(--soft);
  font-size: 0.8125rem;
}
.foot p { margin: 0; }

/* --- sheets: the chapter view and About ------------------------------------------ */

.sheet {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}
.sheet::backdrop { background: var(--paper); }
.sheet[open] { display: flex; flex-direction: column; }

.sheet-head {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) calc(1.25rem + env(safe-area-inset-right)) 0.75rem
    calc(1.25rem + env(safe-area-inset-left));
  border-bottom: 1px solid var(--rule);
}
.sheet-title { min-width: 0; }
.sheet-title h2 { margin: 0; font: 600 0.9375rem/1.3 var(--sans); }
.sheet-title p { margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--soft); }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1.25rem calc(1.25rem + env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom))
    calc(1.25rem + env(safe-area-inset-left));
}
.sheet-body > * { max-width: 37.5rem; margin-left: auto; margin-right: auto; }

.reader-passage { margin-bottom: 1.5rem; scroll-margin: 4rem; }
.reader-passage.is-hit {
  padding: 0.875rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}

.prose h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.375rem;
  font: 600 0.75rem/1.2 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
}
.prose h3:first-child { margin-top: 0; }
.prose p, .prose ul { margin-top: 0; margin-bottom: 0.75rem; font-size: 0.9375rem; line-height: 1.55; }
.prose ul { padding-left: 1.125rem; }
.prose li { margin-bottom: 0.25rem; }
.prose .note { font-size: 0.8125rem; }

.noscript { max-width: 40rem; margin: 2rem auto; padding: 0 1.25rem; color: var(--soft); }

@media (min-width: 40rem) {
  .page { padding-top: 3.5rem; }
  .primary { width: auto; min-width: 14rem; padding-left: 2rem; padding-right: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
