/**
 * 820.31.57 - Learning Annotation UI
 * Bridge Log, selection popover, and annotation review surfaces.
 */

.learning-annotation-ui {
  box-sizing: border-box;
  font-family: var(--font-body, "Source Sans 3", system-ui, sans-serif);
}

.learning-annotation-log-button {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2500;
  min-height: 42px;
  max-width: min(220px, calc(100vw - 32px));
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(201, 165, 92, 0.56);
  border-radius: 8px;
  background: rgba(24, 24, 22, 0.94);
  color: var(--gold, #c9a55c);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
}

.learning-annotation-log-button:hover,
.learning-annotation-log-button:focus-visible {
  border-color: var(--gold, #c9a55c);
  color: #f4d98a;
  outline: none;
}

.learning-annotation-log-button.learning-annotation-pulse {
  animation: learning-annotation-pulse 0.9s ease;
}

@keyframes learning-annotation-pulse {
  0% { transform: translateY(0); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38); }
  45% { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(201, 165, 92, 0.26); }
  100% { transform: translateY(0); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38); }
}

.learning-annotation-popover {
  position: fixed;
  z-index: 2600;
  display: none;
  max-height: min(80vh, 620px);
  overflow: auto;
  padding: 0.9rem;
  border: 1px solid rgba(201, 165, 92, 0.38);
  border-radius: 8px;
  background: rgba(21, 23, 22, 0.98);
  color: var(--text-primary, #f4efe2);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
}

.learning-annotation-popover.visible {
  display: block;
}

.learning-annotation-header,
.learning-annotation-panel-header,
.learning-annotation-card-footer,
.learning-annotation-panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.learning-annotation-kicker {
  color: var(--gold, #c9a55c);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.learning-annotation-title {
  margin-top: 0.1rem;
  font-family: var(--font-display, "EB Garamond", serif);
  font-size: 1.18rem;
  font-weight: 600;
}

.learning-annotation-icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(201, 165, 92, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #f4efe2);
  cursor: pointer;
}

.learning-annotation-icon-btn:hover,
.learning-annotation-icon-btn:focus-visible {
  border-color: var(--gold, #c9a55c);
  outline: none;
}

.learning-annotation-snippet {
  margin: 0.75rem 0;
  padding: 0.72rem 0.8rem;
  border-left: 3px solid var(--gold, #c9a55c);
  border-radius: 6px;
  background: rgba(201, 165, 92, 0.08);
  color: var(--text-primary, #f4efe2);
  font-family: var(--font-display, "EB Garamond", serif);
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.learning-annotation-mode-details {
  margin: 0.75rem 0;
}

.learning-annotation-mode-details summary {
  color: var(--text-secondary, #d8d0c1);
  cursor: pointer;
  font-weight: 700;
}

.learning-annotation-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.learning-annotation-mode {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  min-height: 36px;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-primary, #f4efe2);
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1.15;
}

.learning-annotation-mode:hover,
.learning-annotation-mode:focus-within {
  border-color: rgba(201, 165, 92, 0.5);
}

.learning-annotation-mode input {
  flex: 0 0 auto;
  accent-color: var(--gold, #c9a55c);
}

.learning-annotation-mode span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.learning-annotation-note-label {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--text-secondary, #d8d0c1);
  font-size: 0.78rem;
  font-weight: 700;
}

.learning-annotation-note-label textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text-primary, #f4efe2);
  padding: 0.65rem;
  font: inherit;
}

.learning-annotation-note-label textarea:focus {
  border-color: var(--gold, #c9a55c);
  outline: none;
}

.learning-annotation-status {
  min-height: 1.2rem;
  margin-top: 0.5rem;
  color: var(--gold, #c9a55c);
  font-size: 0.78rem;
}

.learning-annotation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.learning-annotation-primary,
.learning-annotation-secondary,
.learning-annotation-danger {
  min-height: 36px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.learning-annotation-primary {
  border: 1px solid var(--gold, #c9a55c);
  background: var(--gold, #c9a55c);
  color: #17130e;
}

.learning-annotation-secondary {
  border: 1px solid rgba(201, 165, 92, 0.34);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary, #f4efe2);
}

.learning-annotation-danger {
  border: 1px solid rgba(239, 68, 68, 0.48);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

.learning-annotation-primary:focus-visible,
.learning-annotation-secondary:focus-visible,
.learning-annotation-danger:focus-visible {
  outline: 2px solid rgba(201, 165, 92, 0.45);
  outline-offset: 2px;
}

.learning-annotation-primary:disabled,
.learning-annotation-secondary:disabled,
.learning-annotation-danger:disabled {
  cursor: default;
  opacity: 0.52;
}

.learning-annotation-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2700;
  display: none;
  width: min(480px, 100vw);
  height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) 16px;
  overflow-y: auto;
  border-left: 1px solid rgba(201, 165, 92, 0.32);
  background: rgba(17, 19, 18, 0.985);
  color: var(--text-primary, #f4efe2);
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.5);
}

.learning-annotation-panel.visible {
  display: block;
}

.learning-annotation-panel h2,
.learning-annotation-panel h3 {
  margin: 0;
  font-family: var(--font-display, "EB Garamond", serif);
}

.learning-annotation-panel h2 {
  font-size: 1.55rem;
}

.learning-annotation-panel h3 {
  margin: 1.05rem 0 0.55rem;
  color: var(--gold, #c9a55c);
  font-size: 1.05rem;
}

.learning-annotation-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 1rem 0;
}

.learning-annotation-stat {
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.learning-annotation-stat strong,
.learning-annotation-stat span {
  display: block;
}

.learning-annotation-stat strong {
  color: var(--gold, #c9a55c);
  font-size: 1.05rem;
}

.learning-annotation-stat span {
  color: var(--text-muted, #9e9585);
  font-size: 0.68rem;
  line-height: 1.1;
}

.learning-annotation-panel-actions {
  margin-bottom: 0.6rem;
}

.learning-annotation-list {
  display: grid;
  gap: 0.6rem;
}

.learning-annotation-card {
  padding: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left-width: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.learning-annotation-card.obstacle {
  border-left-color: #f59e0b;
}

.learning-annotation-card.refresh {
  border-left-color: #60a5fa;
}

.learning-annotation-card.bridge {
  border-left-color: #34d399;
}

.learning-annotation-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  color: var(--text-muted, #9e9585);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.learning-annotation-card blockquote {
  margin: 0.5rem 0;
  color: var(--text-primary, #f4efe2);
  font-family: var(--font-display, "EB Garamond", serif);
  font-size: 1.02rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.learning-annotation-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.learning-annotation-chip {
  padding: 0.22rem 0.42rem;
  border-radius: 8px;
  background: rgba(201, 165, 92, 0.1);
  color: #f0d68b;
  font-size: 0.68rem;
  font-weight: 700;
}

.learning-annotation-note {
  margin: 0.55rem 0 0;
  color: var(--text-secondary, #d8d0c1);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.learning-annotation-card-footer {
  margin-top: 0.65rem;
}

.learning-annotation-card-footer .learning-annotation-secondary,
.learning-annotation-card-footer .learning-annotation-danger {
  min-height: 32px;
  padding: 0.36rem 0.55rem;
}

.learning-annotation-sync-state {
  margin-right: auto;
  color: var(--text-muted, #9e9585);
  font-size: 0.72rem;
}

.learning-annotation-empty {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.learning-annotation-empty-title {
  color: var(--gold, #c9a55c);
  font-weight: 700;
}

.learning-annotation-empty p {
  margin: 0.35rem 0 0;
  color: var(--text-secondary, #d8d0c1);
}

@media (max-width: 720px) {
  .learning-annotation-popover {
    left: 12px !important;
    right: 12px;
    width: auto !important;
    max-height: 72vh;
  }

  .learning-annotation-mode-grid,
  .learning-annotation-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .learning-annotation-panel {
    width: 100vw;
    border-left: 0;
  }

  .learning-annotation-log-button {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}
