/* ---------- reset & base ---------- */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  display: flex;
  background: #ffffff;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* ---------- panels ---------- */

#sidebar {
  width: 300px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  background: #fafaf9;
  border-right: 1px solid #e6e4e0;
}

#content {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
}

/* ---------- sidebar: filter ---------- */

.filter {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #e6e4e0;
  position: sticky;
  top: 0;
  background: #fafaf9;
}

.filter label {
  display: block;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a857c;
  margin-bottom: 0.4rem;
}

.filter select {
  width: 100%;
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid #d6d3cd;
  border-radius: 3px;
  background: #ffffff;
  color: #1a1a1a;
}

/* ---------- sidebar: list ---------- */

#aphorism-list {
  padding: 0.5rem 0 2rem;
}

.book-header {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a857c;
  padding: 1.1rem 1.25rem 0.4rem;
}

.aphorism-entry {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: #3a372f;
  padding: 0.3rem 1.25rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aphorism-entry:hover {
  background: #f1efeb;
}

.aphorism-entry.selected {
  background: #ecdfd0;
  color: #1a1a1a;
}

.aphorism-entry .num {
  display: inline-block;
  min-width: 2.2em;
  color: #8a857c;
  font-variant-numeric: tabular-nums;
}

.aphorism-entry.selected .num {
  color: #6b5535;
}

.aphorism-entry:focus-visible,
.filter select:focus-visible {
  outline: 2px solid #6b5535;
  outline-offset: -2px;
}

/* ---------- main content ---------- */

#aphorism-view {
  font-family: "Lora", Georgia, serif;
  max-width: 38rem;
  margin: 0 auto;
  padding: 5rem 2.5rem 7rem;
}

#aphorism-view .number {
  font-size: 0.875rem;
  color: #8a857c;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.6rem;
}

#aphorism-view h1 {
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.25;
  margin-bottom: 1.75rem;
}

#aphorism-view .body {
  font-size: 1.0625rem;
  line-height: 1.75;
}

#aphorism-view .body em {
  font-style: italic;
}

#aphorism-view .themes {
  margin-bottom: 2rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: #8a857c;
}

.theme-link {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: #d6d3cd;
  text-underline-offset: 3px;
}

.theme-link:hover {
  color: #6b5535;
  text-decoration-color: #6b5535;
}

.theme-link:focus-visible {
  outline: 2px solid #6b5535;
  outline-offset: 2px;
}

#aphorism-view .not-found {
  color: #8a857c;
  font-style: italic;
}

/* ---------- contents toggle (mobile only) ---------- */

#contents-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3a372f;
  background: #ffffff;
  border: 1px solid #d6d3cd;
  border-radius: 3px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

#contents-toggle:focus-visible {
  outline: 2px solid #6b5535;
  outline-offset: 2px;
}

/* ---------- mobile layout ---------- */

@media (max-width: 768px) {
  #contents-toggle {
    display: block;
  }

  #sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(320px, 85vw);
    z-index: 10;
    /* darkens the page behind the open panel without an extra element */
    box-shadow: 0 0 0 100vmax rgba(26, 26, 26, 0.2);
  }

  #sidebar.open {
    display: block;
  }

  .filter {
    padding-top: 3.4rem; /* clear the fixed Contents button */
  }

  #aphorism-view {
    padding: 4.75rem 1.5rem 5rem;
  }
}
