/*!
 * TNHA 查證筆記 widget — public/widgets/notes.css
 * All rules scoped under .tnha-notes to avoid leaking into the Duda page.
 * Palette matches public/widgets/insights.css (secondary #2d7a3a per PR #160 fix).
 */
.tnha-notes {
  --tnha-notes-primary: #74B74E;
  --tnha-notes-secondary: #2d7a3a;
  --tnha-notes-bg: #FFFBF4;
  --tnha-notes-surface: #FFF0E0;
  --tnha-notes-text: #2C2C2C;
  --tnha-notes-muted: #8A8A7E;
  --tnha-notes-border: #EDE0CE;
  --tnha-notes-warning: #D97706;
  box-sizing: border-box;
  max-width: 100%;
  color: var(--tnha-notes-text);
  font-size: 16px;
  line-height: 1.6;
}
.tnha-notes,
.tnha-notes *,
.tnha-notes *::before,
.tnha-notes *::after {
  box-sizing: border-box;
}

.tnha-notes__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* skeleton */
.tnha-notes__skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tnha-notes__skel-row {
  height: 72px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--tnha-notes-surface) 25%, #fff7ea 37%, var(--tnha-notes-surface) 63%);
  background-size: 400% 100%;
  animation: tnha-notes-shimmer 1.4s ease infinite;
}
@keyframes tnha-notes-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* error / empty */
.tnha-notes__error {
  padding: 32px 16px;
  text-align: center;
  background: var(--tnha-notes-surface);
  border-radius: 12px;
}
.tnha-notes__error-text {
  margin: 0 0 12px;
  color: var(--tnha-notes-text);
  font-weight: 600;
}
.tnha-notes__error-link {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--tnha-notes-primary);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.tnha-notes__error-link:hover {
  background: var(--tnha-notes-secondary);
}
.tnha-notes__empty {
  padding: 24px 8px;
  color: var(--tnha-notes-muted);
  text-align: center;
}

/* hero + explanation */
.tnha-notes__hero-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--tnha-notes-secondary);
}
.tnha-notes__explain-toggle {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--tnha-notes-surface);
  border: 1px solid var(--tnha-notes-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--tnha-notes-secondary);
  cursor: pointer;
  margin-bottom: 8px;
}
.tnha-notes__explain-body {
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px dashed var(--tnha-notes-border);
  border-radius: 12px;
  font-size: 14px;
}
.tnha-notes__explain-body p {
  margin: 0 0 10px;
}
.tnha-notes__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tnha-notes__legend-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.tnha-notes__legend-item .tnha-notes__badge {
  flex-shrink: 0;
}
.tnha-notes__legend-desc {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 14px;
  color: var(--tnha-notes-text);
}

/* tag filters */
.tnha-notes__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tnha-notes__tag-btn {
  border: 1px solid var(--tnha-notes-border);
  background: #fff;
  color: var(--tnha-notes-text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.tnha-notes__tag-btn.is-active {
  background: var(--tnha-notes-primary);
  border-color: var(--tnha-notes-primary);
  color: #fff;
  font-weight: 700;
}
.tnha-notes__tag-btn:hover:not(.is-active) {
  border-color: var(--tnha-notes-primary);
}

/* list + row */
.tnha-notes__list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tnha-notes__row {
  border: 1px solid var(--tnha-notes-border);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  transition: box-shadow .2s ease, background-color .6s ease;
}
.tnha-notes__row.is-highlight {
  background-color: #FFF6D8;
  box-shadow: 0 0 0 3px var(--tnha-notes-primary);
}
.tnha-notes__row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--tnha-notes-muted);
}
.tnha-notes__date {
  font-weight: 600;
}
.tnha-notes__badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: #E9F5E1;
  color: var(--tnha-notes-secondary);
}
.tnha-notes__badge.is-partial {
  background: #FDF0DC;
  color: var(--tnha-notes-warning);
}
.tnha-notes__badge.is-pending {
  background: #EDEDED;
  color: #6B6B6B;
}
.tnha-notes__title {
  display: block;
  font-size: 17px;
  font-weight: 700;
  color: var(--tnha-notes-text);
  text-decoration: none;
  margin-bottom: 6px;
  word-break: break-word;
}
a.tnha-notes__title:hover {
  color: var(--tnha-notes-secondary);
  text-decoration: underline;
}
.tnha-notes__lede {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--tnha-notes-text);
}
.tnha-notes__row-tags {
  margin: 0;
  font-size: 12px;
  color: var(--tnha-notes-muted);
}

.tnha-notes__more {
  margin-top: 20px;
  text-align: center;
}
.tnha-notes__more-link {
  display: inline-block;
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid var(--tnha-notes-primary);
  color: var(--tnha-notes-secondary);
  text-decoration: none;
  font-weight: 700;
}
.tnha-notes__more-link:hover {
  background: var(--tnha-notes-primary);
  color: #fff;
}

/* focus visibility for keyboard nav */
.tnha-notes button:focus-visible,
.tnha-notes a:focus-visible {
  outline: 2px solid var(--tnha-notes-secondary);
  outline-offset: 2px;
}

/* small screens */
@media (max-width: 480px) {
  .tnha-notes {
    font-size: 15px;
  }
  .tnha-notes__tags {
    gap: 6px;
  }
  .tnha-notes__tag-btn {
    font-size: 12px;
    padding: 5px 12px;
  }
}
