/* The annotated reading view — ported from the prototype's render.py. */

.reading-wrap {
  display: flex; gap: 2.5rem; align-items: flex-start;
  padding-top: 1.6rem; padding-bottom: 3rem;
}
.reading-wrap main { flex: 1 1 62%; min-width: 0; }
.reading-wrap aside {
  flex: 1 1 38%; min-width: 260px; max-width: 400px;
  position: sticky; top: 1rem;
  max-height: calc(100vh - 2rem); overflow-y: auto;
}

.doc {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-width: 68ch;
}

.doc-header { max-width: 68ch; margin-bottom: 1.4rem; }
.doc-header h1 {
  font-size: 1.7rem; line-height: 1.3; margin: 0 0 0.4rem;
  text-wrap: balance;
}
.doc-header .byline {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.84rem; color: var(--muted);
}

mark {
  background: transparent; color: inherit; cursor: pointer;
  border-radius: 2px; padding: 1px 2px;
}
mark.lex,
mark.ann { background: var(--mark-bg); box-shadow: inset 0 -2px 0 var(--mark); }
mark.active { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- annotation cards ---- */

.cards {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.84rem; line-height: 1.55;
}
.card {
  border: 1px solid var(--border); background: var(--card);
  border-radius: 10px; padding: 0.85rem 1rem; margin-bottom: 0.8rem;
}
.card.hidden { display: none; }
.card h3 {
  margin: 0 0 0.4rem; font-size: 1rem; line-height: 1.35;
  font-family: Charter, Georgia, serif;
}
.card p { margin: 0.4rem 0; }
.card b { font-weight: 600; }
.card ul { margin: 0.35rem 0; padding-left: 1.15rem; }
.card li { margin: 0.2rem 0; }
.card details summary {
  cursor: pointer; font-weight: 600; font-size: 0.78rem; color: var(--muted);
}
.card .entry-link { font-size: 0.78rem; }
.card-actions {
  display: flex; gap: 0.4rem; margin-top: 0.6rem;
  opacity: 0; transition: opacity 0.15s ease;
}
.card:hover .card-actions,
.card:focus-within .card-actions { opacity: 1; }
@media (hover: none) { .card-actions { opacity: 1; } }

/* ---- legend / progress ---- */

.legend {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.82rem; color: var(--muted);
  display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.key { display: inline-flex; align-items: center; gap: 0.45em; }
.key .swatch {
  width: 1.6em; height: 1em; border-radius: 3px;
  background: var(--mark-bg); box-shadow: inset 0 -2px 0 var(--mark);
}

.progress {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 10px;
  padding: 0.6rem 0.9rem; margin-bottom: 0.8rem;
}
.progress .bar {
  height: 4px; background: var(--border); border-radius: 2px;
  overflow: hidden; margin-top: 0.45rem;
}
.progress .bar > span {
  display: block; height: 100%; background: var(--mark);
  transition: width 0.3s ease;
}

/* ---- annotation composer ---- */

.composer-popover {
  position: absolute; z-index: 50; width: min(24rem, calc(100vw - 1rem));
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.9rem 1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.84rem;
}
.composer label {
  display: block; font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); margin: 0.6rem 0 0.25rem;
}
.composer label .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }
.composer textarea,
.composer select {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.55rem;
}
.composer textarea { resize: vertical; }
.composer textarea:focus-visible,
.composer select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.composer-quote {
  margin: 0; padding: 0.35rem 0 0.35rem 0.7rem;
  border-left: 3px solid var(--mark); color: var(--muted);
  font-family: Charter, Georgia, serif; font-size: 0.88rem;
  max-height: 5.5rem; overflow-y: auto;
}
.composer-error {
  margin: 0.6rem 0 0; color: var(--danger); font-size: 0.78rem;
}
.composer-actions {
  display: flex; align-items: center; gap: 0.4rem; margin-top: 0.8rem;
}
.composer-actions .spacer { flex: 1; }
.composer-actions .hint { font-size: 0.72rem; color: var(--muted); }

@media (max-width: 800px) {
  .reading-wrap { flex-direction: column; }
  .reading-wrap aside { position: static; max-height: none; max-width: none; }
}
