/**
 * AI summary card. Uses the theme's custom properties with fallbacks so it
 * also renders sensibly under another theme.
 */
.ai-summary {
  margin: 0 0 1.75rem;
  border: 1px solid rgba(0, 82, 57, 0.16);
  border-radius: var(--radius-md, 0.5rem);
  background: linear-gradient(135deg, #f4f9f7 0%, #fbfdfc 60%, #fffdf5 100%);
  color: var(--gmu-dark-gray, #3b3b3b);
}

.ai-summary__header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
  list-style: none;
  border-radius: inherit;
  font-family: var(--font-heading, sans-serif);
  -webkit-user-select: none;
  user-select: none;
}

.ai-summary__header::-webkit-details-marker {
  display: none;
}

.ai-summary__header:focus-visible {
  outline: 2px solid var(--gmu-primary-green, #005239);
  outline-offset: 2px;
}

.ai-summary__icon {
  flex: none;
  color: var(--gmu-primary-green, #005239);
}

.ai-summary__label {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--gmu-primary-green, #005239);
}

.ai-summary__badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 82, 57, 0.08);
  color: var(--gmu-green-dark, #003d29);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.ai-summary__chevron {
  flex: none;
  margin-left: auto;
  color: var(--gmu-primary-green, #005239);
  transition: transform 150ms ease-in-out;
}

.ai-summary__details[open] .ai-summary__chevron {
  transform: rotate(180deg);
}

.ai-summary__body {
  padding: 0 1rem 0.9rem;
}

/* Doubled class beats the theme's `article .node__content p` prose rules. */
.ai-summary .ai-summary__text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--gmu-dark-gray, #3b3b3b);
}

.ai-summary .ai-summary__note {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #5c5c5c;
}

@media (prefers-reduced-motion: reduce) {
  .ai-summary__chevron {
    transition: none;
  }
}

@media print {
  .ai-summary {
    display: none;
  }
}

/* ── "Being written" effect ─────────────────────────────────────────────
   The full text is always in the page. JS wraps each word and reveals them
   in order, so nothing moves and assistive tech reads it normally. */
.ai-summary__word {
  opacity: 0;
  transition: opacity 160ms ease-out;
}

.ai-summary__word.is-written {
  opacity: 1;
}

/* Zero-width marker that follows the last written word. */
.ai-summary__caret {
  position: relative;
  display: inline-block;
  width: 0;
  height: 1em;
  vertical-align: -0.12em;
}

.ai-summary__caret::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--gmu-primary-green, #005239);
  animation: ai-summary-caret 700ms steps(2, start) infinite;
}

.ai-summary .ai-summary__note {
  transition: opacity 300ms ease-out;
}

.ai-summary__details.is-generating .ai-summary__note {
  opacity: 0;
}

/* The sparkle icon moves only while the text is being written. */
.ai-summary__spark {
  transform-box: fill-box;
  transform-origin: center;
}

.ai-summary__details.is-generating .ai-summary__spark--big {
  animation: ai-summary-spark-big 900ms ease-in-out infinite;
}

.ai-summary__details.is-generating .ai-summary__spark--small {
  animation: ai-summary-spark-small 900ms ease-in-out infinite;
}

@keyframes ai-summary-spark-big {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(0.72) rotate(45deg); }
}

@keyframes ai-summary-spark-small {
  0%, 100% { transform: scale(0.55) rotate(0deg); opacity: 0.35; }
  50% { transform: scale(1.25) rotate(-45deg); opacity: 1; }
}

@keyframes ai-summary-caret {
  to { visibility: hidden; }
}
