/**
 * Admonitions (Callouts)
 * Styled callout boxes for highlighting important information
 */

/* Base Admonition Styles */
.admonition {
  position: relative;
  margin-block: 1.5rem;
  padding: 1rem 1.25rem;
  border-inline-start: 4px solid var(--color-border);
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  /* Increased from --border-radius-large (8px → 12px) */
  background-color: var(--color-bg-secondary);
  box-shadow: var(--elevation-card);
  transition: all var(--transition-base);
  overflow: hidden;
}

/* Blob background animation for admonitions - Palette-aware */
.admonition::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 180%;
  height: 180%;
  background: radial-gradient(circle at 35% 35%,
      color-mix(in srgb, var(--blob-color-1) 7%, transparent) 0%,
      color-mix(in srgb, var(--blob-color-2) 5%, transparent) 30%,
      color-mix(in srgb, var(--blob-color-3) 3%, transparent) 55%,
      transparent 70%);
  border-radius: 50%;
  animation: blob-morph var(--blob-duration-medium) ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.admonition:hover::before {
  opacity: 0.8;
}

.admonition>* {
  position: relative;
  z-index: 1;
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, black, white)) {
  .admonition::before {
    background: radial-gradient(circle at 35% 35%,
        rgba(59, 130, 246, 0.07) 0%,
        rgba(76, 175, 80, 0.05) 30%,
        rgba(255, 152, 0, 0.03) 55%,
        transparent 70%);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .admonition::before {
    animation: none !important;
  }
}

/* Auto-apply gradient border to admonitions */
.admonition::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  padding: 1px;
  background: var(--gradient-border);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.3;
  z-index: 0;
}

.admonition.gradient-border {
  border-inline-start: 4px solid var(--color-primary);
}

.admonition:hover {
  box-shadow: var(--elevation-card-hover);
  transform: translate3d(0, -1px, 0);
}

/* Admonitions with icons */
.admonition:has(.admonition-icon) {
  padding-inline-start: 3rem;
}

/* Admonition Title */
.admonition-title {
  margin: 0 0 0.75rem 0;
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: var(--letter-spacing-normal);

}

/* Admonition Title */
.admonition-title::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* Admonition Content */
.admonition>p {
  margin: 0.75rem 0;
}

.admonition>p:first-of-type {
  margin-top: 0;
}

.admonition>p:last-child {
  margin-bottom: 0;
}

/* Remove top margin from first element after title */
.admonition-title+* {
  margin-top: 0;
}

/* Spacing for other direct children */
.admonition>*:not(.admonition-title):not(p) {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.admonition>*:not(.admonition-title):first-of-type {
  margin-top: 0;
}

.admonition>*:last-child {
  margin-bottom: 0;
}

/* List styling in admonitions */
.admonition ul,
.admonition ol {
  padding-inline-start: var(--space-8);
  margin: 0.75rem 0;
}

.admonition ul:first-child,
.admonition ol:first-child {
  margin-top: 0;
}

.admonition ul {
  list-style-type: disc;
}

.admonition ol {
  list-style-type: decimal;
}

.admonition li {
  margin: var(--space-1) 0;
}

/* Code blocks in admonitions */
.admonition pre {
  margin: 0.75rem 0;
}

.admonition pre:first-child {
  margin-top: 0;
}

.admonition pre:last-child {
  margin-bottom: 0;
}

.admonition code {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .admonition code {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ============================================
   ADMONITION TYPES
   ============================================ */

/* Note / Info */
.admonition.note,
.admonition.info {
  border-inline-start-color: var(--color-info-border);
  background-color: var(--color-info-bg);
}

.admonition.note .admonition-title,
.admonition.info .admonition-title {
  color: var(--color-info-text);
}

.admonition.note .admonition-title::before,
.admonition.info .admonition-title::before {
  content: 'ℹ️';
  font-size: var(--text-lg);
}

[data-theme="dark"] .admonition.note,
[data-theme="dark"] .admonition.info {
  background-color: var(--color-info-bg);
  border-inline-start-color: var(--color-info-border);
}

[data-theme="dark"] .admonition.note .admonition-title,
[data-theme="dark"] .admonition.info .admonition-title {
  color: var(--color-info-text);
}

/* Tip / Success */
.admonition.tip,
.admonition.success {
  border-inline-start-color: var(--color-success-border);
  background-color: var(--color-success-bg);
}

.admonition.tip .admonition-title,
.admonition.success .admonition-title {
  color: var(--color-success-text);
}

.admonition.tip .admonition-title::before {
  content: '💡';
  font-size: var(--text-lg);
}

.admonition.success .admonition-title::before {
  content: '✅';
  font-size: var(--text-lg);
}

[data-theme="dark"] .admonition.tip,
[data-theme="dark"] .admonition.success {
  background-color: var(--color-success-bg);
  border-inline-start-color: var(--color-success-border);
}

[data-theme="dark"] .admonition.tip .admonition-title,
[data-theme="dark"] .admonition.success .admonition-title {
  color: var(--color-success-text);
}

/* Warning / Caution */
.admonition.warning,
.admonition.caution {
  border-inline-start-color: var(--color-warning-border);
  background-color: var(--color-warning-bg);
}

.admonition.warning .admonition-title,
.admonition.caution .admonition-title {
  color: var(--color-warning-text);
}

.admonition.warning .admonition-title::before,
.admonition.caution .admonition-title::before {
  content: '⚠️';
  font-size: var(--text-lg);
}

[data-theme="dark"] .admonition.warning,
[data-theme="dark"] .admonition.caution {
  background-color: var(--color-warning-bg);
  border-inline-start-color: var(--color-warning-border);
}

[data-theme="dark"] .admonition.warning .admonition-title,
[data-theme="dark"] .admonition.caution .admonition-title {
  color: var(--color-warning-text);
}

/* Danger / Error */
.admonition.danger,
.admonition.error {
  border-inline-start-color: var(--color-error-border);
  background-color: var(--color-error-bg);
}

.admonition.danger .admonition-title,
.admonition.error .admonition-title {
  color: var(--color-error-text);
}

.admonition.danger .admonition-title::before,
.admonition.error .admonition-title::before {
  content: '🛑';
  font-size: var(--text-lg);
}

[data-theme="dark"] .admonition.danger,
[data-theme="dark"] .admonition.error {
  background-color: var(--color-error-bg);
  border-inline-start-color: var(--color-error-border);
}

[data-theme="dark"] .admonition.danger .admonition-title,
[data-theme="dark"] .admonition.error .admonition-title {
  color: var(--color-error-text);
}

/* Example */
.admonition.example {
  border-inline-start-color: #8b5cf6;
  /* violet-500 */
  background-color: #f5f3ff;
  /* violet-50 */
}

.admonition.example .admonition-title {
  color: #7c3aed;
  /* violet-600 */
}

.admonition.example .admonition-title::before {
  content: '📝';
  font-size: var(--text-lg);
}

[data-theme="dark"] .admonition.example {
  border-inline-start-color: #a78bfa;
  /* violet-400 */
  background-color: rgba(139, 92, 246, 0.1);
}

[data-theme="dark"] .admonition.example .admonition-title {
  color: #c4b5fd;
  /* violet-300 */
}

/* ============================================
   COLLAPSIBLE ADMONITIONS
   ============================================ */

.admonition.collapsible {
  cursor: pointer;
}

.admonition.collapsible .admonition-title::after {
  content: '▼';
  margin-inline-start: auto;
  font-size: var(--text-sm);
  transition: transform var(--transition-fast) var(--ease-out);
}

.admonition.collapsible.collapsed .admonition-title::after {
  transform: rotate(-90deg);
}

.admonition.collapsible.collapsed>*:not(.admonition-title) {
  display: none;
}

/* ============================================
   NESTED ADMONITIONS
   ============================================ */

.admonition .admonition {
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
  .admonition {
    padding: var(--space-3) var(--space-4);
    margin: var(--space-4) 0;
  }

  .admonition-title {
    font-size: var(--text-sm);
  }
}

/* Further reduce padding on very small screens */
@media (max-width: 399px) {
  .admonition {
    padding: var(--space-2) var(--space-3);
    margin: var(--space-3) 0;
  }
}
