/* KoreAves — Interpretation Aid Modal Styles
 * Mineral-paper aesthetic, responsive touch & keyboard accessible.
 * Colors reference the canonical design-system tokens (design-system/tokens/color.css)
 * so this modal matches the rest of the site's editorial palette exactly.
 */

.interpretation-help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(24, 28, 25, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.interpretation-help-dialog {
  background-color: var(--ka-color-paper-surface, #ffffff);
  color: var(--ka-color-ink-primary, #181c19);
  border: 1px solid var(--ka-color-rule-subtle, #cfcac0);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(24, 28, 25, 0.16);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ka-font-hangul-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
}

.help-modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--ka-color-rule-hairline, #e2ded5);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background-color: var(--ka-color-paper-raised, #fbfbfa);
}

.help-header-title-group {
  flex: 1;
}

.help-modal-title {
  margin: 0 0 6px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ka-color-ink-primary, #181c19);
  letter-spacing: -0.01em;
}

.help-modal-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ka-color-ink-quiet, #616b64);
  line-height: 1.4;
}

.help-modal-close-btn {
  background: none;
  border: 1px solid var(--ka-color-rule-subtle, #cfcac0);
  border-radius: 4px;
  color: var(--ka-color-ink-secondary, #3b433d);
  font-size: 1.2rem;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}

.help-modal-close-btn:hover,
.help-modal-close-btn:focus-visible {
  background-color: var(--ka-color-paper-sunken, #edebe4);
  color: var(--ka-color-ink-primary, #181c19);
  outline: 2px solid var(--ka-color-focus-ring, #163626);
}

.help-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}

.help-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ka-color-ink-quiet, #616b64);
  margin: 0 0 10px 0;
}

.help-item-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-item-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background-color: var(--ka-color-paper-surface, #ffffff);
  border: 1px solid var(--ka-color-rule-hairline, #e2ded5);
  border-radius: 6px;
  padding: 12px 14px;
}

.help-item-glyph {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ka-color-evidence-present-ink, #163626);
  background-color: var(--ka-color-evidence-present-tint, #eaf1ed);
  border: 1px solid var(--ka-color-evidence-present-border, #a3c2b1);
  border-radius: 4px;
  padding: 4px 8px;
  white-space: nowrap;
  min-width: 48px;
  text-align: center;
}

/* Spatial help symbols use the exact map category fills, not generic
   evidence-card colours, so the dialog key visually matches the polygons. */
.interpretation-help-overlay--spatial .help-item-row:nth-child(1) .help-item-glyph {
  color: transparent;
  background-color: var(--ka-color-map-region-present, #2d5a44);
  border-color: var(--ka-color-map-region-selected, #163626);
}

.interpretation-help-overlay--spatial .help-item-row:nth-child(2) .help-item-glyph {
  color: transparent;
  background-color: var(--ka-color-map-region-none, #e2ded4);
  border-color: var(--ka-color-map-coastline, #c8c2b5);
}

.help-item-content {
  flex: 1;
}

.help-item-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ka-color-ink-primary, #181c19);
  margin-bottom: 4px;
}

.help-item-desc {
  font-size: 0.825rem;
  color: var(--ka-color-ink-secondary, #3b433d);
  line-height: 1.45;
}

.help-guardrails-section {
  background-color: var(--ka-color-annotation-caution-fill, #fdf8ee);
  border: 1px solid var(--ka-color-rule-hairline, #e2ded5);
  border-radius: 6px;
  padding: 14px 16px;
}

.help-guardrails-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-guardrail-item {
  font-size: 0.8rem;
  color: var(--ka-color-ink-secondary, #3b433d);
  line-height: 1.45;
}

.help-modal-footer {
  padding: 14px 24px;
  background-color: var(--ka-color-paper-raised, #fbfbfa);
  border-top: 1px solid var(--ka-color-rule-hairline, #e2ded5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.help-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.help-provenance-link,
.help-reference-link {
  font-size: 0.8rem;
  color: var(--ka-color-link, #244837);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.help-provenance-link:hover,
.help-provenance-link:focus-visible,
.help-reference-link:hover,
.help-reference-link:focus-visible {
  color: var(--ka-color-link-hover, #12241b);
}

.help-dismiss-btn {
  background-color: var(--ka-color-evidence-present-fill, #244837);
  color: var(--ka-color-ink-inverse, #f7f6f2);
  border: none;
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.help-dismiss-btn:hover,
.help-dismiss-btn:focus-visible {
  background-color: var(--ka-color-evidence-present-ink, #163626);
  outline: 2px solid var(--ka-color-focus-ring, #163626);
}

/* Contextual Help Trigger (Demoted from prominent CTA to ⓘ affordance beside title) */
.interpretation-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--ka-color-ink-quiet, #616b64);
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
  box-sizing: border-box;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.interpretation-trigger:hover {
  background-color: var(--ka-color-paper-sunken, #edebe4);
  color: var(--ka-color-ink-primary, #181c19);
}
.interpretation-trigger:focus-visible {
  outline: 2px solid var(--ka-color-focus-ring, #163626);
  outline-offset: 1px;
}

.help-icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: inherit;
}

@media (max-width: 768px) {
  .interpretation-help-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .interpretation-help-dialog {
    max-height: 85vh;
    border-radius: 12px 12px 0 0;
    border-bottom: none;
  }

  .help-modal-header {
    padding: 16px 18px 12px;
  }

  .help-modal-body {
    padding: 16px 18px;
  }

  .help-modal-footer {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 18px;
  }

  .help-dismiss-btn {
    align-self: flex-end;
  }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .help-modal-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
}


@media (prefers-reduced-motion: reduce) {
  .interpretation-help-overlay,
  .interpretation-help-dialog,
  .help-modal-close-btn,
  .help-dismiss-btn,
  .interpretation-trigger {
    transition-duration: 0s;
    animation-duration: 0s;
    scroll-behavior: auto;
  }

  .interpretation-help-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Ownership: InterpretationHelp owns help/disclosure control affordance. */
.help-modal-close-btn {
  border: 1px solid var(--ka-control-edge);
  box-shadow: var(--ka-control-press-inset);
  transition: var(--ka-control-transition);
}
.help-modal-close-btn:hover { border-color: var(--ka-control-edge-strong); }
.help-modal-close-btn:active { transform: translateY(1px); box-shadow: var(--ka-control-active-inset); }
.help-dismiss-btn { box-shadow: var(--ka-control-press-inset); transition: var(--ka-control-transition); }
.help-dismiss-btn:active { transform: translateY(1px); box-shadow: var(--ka-control-active-inset); }
.interpretation-trigger,
.evidence-key-help-btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}
.interpretation-trigger:hover,
.evidence-key-help-btn:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ka-color-ink-primary, #181c19);
}
