/* Annotations / Marginalia */

.annotation-anchor {
  background: rgba(255, 255, 0, 0.2);
  border-bottom: 1px dotted rgba(46, 139, 87, 0.3);
  cursor: pointer;
  color: inherit;
  transition: background 0.2s ease;
}

.annotation-anchor:hover {
  background: rgba(46, 139, 87, 0.15);
}

/* Popover */
.annotation-popover {
  position: fixed;
  z-index: 9999;
  width: 320px;
  background: var(--bg, #fff);
  border: 1px solid var(--base03, #8a8a8a);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  font-family: var(--font-monospace, monospace);
  font-size: 14px;
  line-height: 1.5;
}

.annotation-popover__arrow {
  position: absolute;
  top: -6px;
  left: 50%;
  margin-left: -6px;
  width: 12px;
  height: 12px;
  background: var(--bg, #fff);
  border-left: 1px solid var(--base03, #8a8a8a);
  border-top: 1px solid var(--base03, #8a8a8a);
  transform: rotate(45deg);
}

.annotation-popover__quote {
  padding: 12px 12px 8px;
  font-size: 13px;
  color: var(--off-fg, #1f1f1f);
  border-bottom: 1px solid var(--base02, #f2f2f2);
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
  word-break: break-word;
}

.annotation-popover__form {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.annotation-popover__input,
.annotation-popover__textarea {
  font-family: var(--font-monospace, monospace);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--base03, #8a8a8a);
  background: var(--bg, #fff);
  color: var(--fg, #000);
  outline: none;
  transition: border-color 0.15s ease;
}

.annotation-popover__input:focus,
.annotation-popover__textarea:focus {
  border-color: var(--logo, #2E8B57);
}

.annotation-popover__textarea {
  resize: vertical;
  min-height: 60px;
}

.annotation-popover__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.annotation-popover__submit,
.annotation-popover__cancel {
  font-family: var(--font-monospace, monospace);
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid var(--base03, #8a8a8a);
  background: var(--bg, #fff);
  color: var(--fg, #000);
  cursor: pointer;
  transition: background 0.15s ease;
}

.annotation-popover__submit:hover,
.annotation-popover__cancel:hover {
  background: var(--base02, #f2f2f2);
}

.annotation-popover__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.annotation-popover__error {
  color: #c62828;
  font-size: 12px;
  padding: 4px 0;
}

.annotation-popover__success {
  color: var(--logo, #2E8B57);
  font-size: 13px;
  padding: 8px 12px;
  text-align: center;
}

/* Sidebar */
.annotations-sidebar {
  margin-top: 1rem;
}

.annotations-sidebar__header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  text-transform: lowercase;
  color: var(--muted, #8a8a8a);
}

.annotations-sidebar__empty {
  font-size: 13px;
  color: var(--muted, #8a8a8a);
  line-height: 1.5;
}

.annotation-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--base02, #f2f2f2);
  cursor: default;
  transition: background 0.15s ease;
}

.annotation-item:last-child {
  border-bottom: none;
}

.annotation-item--highlighted {
  background: rgba(46, 139, 87, 0.08);
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
}

.annotation-item__meta {
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.annotation-item__name {
  font-weight: 600;
  color: var(--fg, #000);
}

.annotation-item__date {
  color: var(--muted, #8a8a8a);
}

.annotation-item__quote {
  font-size: 12px;
  color: var(--off-fg, #1f1f1f);
  margin: 0 0 4px;
  padding-left: 8px;
  border-left: 2px solid var(--base03, #8a8a8a);
  line-height: 1.4;
}

.annotation-item__comment {
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
  color: var(--fg, #000);
}

/* Section below page content */
.annotations-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--base03, #8a8a8a);
}

/* Left-side annotation panel */
.annotation-panel {
  position: fixed;
  z-index: 1000;
  top: 50%;
  transform: translateY(-50%);
  width: 15rem;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg, #fff);
  border: 1px solid var(--base03, #8a8a8a);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  font-family: var(--font-monospace, monospace);
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
}

.annotation-panel__close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted, #8a8a8a);
  padding: 0;
  line-height: 1;
}

.annotation-panel__close:hover {
  color: var(--fg, #000);
}

.annotation-panel__meta {
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.annotation-panel__name {
  font-weight: 600;
  color: var(--fg, #000);
}

.annotation-panel__date {
  color: var(--muted, #8a8a8a);
}

.annotation-panel__quote {
  font-size: 12px;
  color: var(--off-fg, #1f1f1f);
  margin: 0 0 6px;
  padding-left: 8px;
  border-left: 2px solid var(--logo, #2E8B57);
  line-height: 1.4;
}

.annotation-panel__comment {
  font-size: 13px;
  margin: 0;
  line-height: 1.5;
  color: var(--fg, #000);
}

@media (min-width: 64rem) {
  .annotation-panel {
    left: max(0.75rem, calc((100vw - 64rem) / 2 - 17rem));
  }
}

@media (max-width: 63.999rem) {
  .annotation-panel {
    left: 0.75rem;
    width: calc(100vw - 1.5rem);
    max-width: 20rem;
  }
}

@media (max-width: 45rem) {
  .annotation-panel {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 50vh;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}
