/*
 * Native details elements styled exactly like Anzhiyu's hideToggle
 * Copy of the exact CSS used by hideToggle tag
 */

/* Base container styling - exactly like hideToggle */
details:not(.toggle):not(.hide-block):not(.hide-inline) {
  margin-bottom: 20px;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
}

/* Summary styled like toggle-button */
details:not(.toggle):not(.hide-block):not(.hide-inline) > summary {
  padding: 6px 15px;
  background: #f0f0f0;
  color: #1f2d3d;
  cursor: pointer;
  list-style: none;
  outline: none;
  user-select: none;
  border-radius: 8px;
  margin: 0;
  display: flex;
  align-items: center;
  font-weight: 500;
}

/* Add arrow icon matching hideToggle behavior */
details:not(.toggle):not(.hide-block):not(.hide-inline) > summary::before {
  content: "▶";
  margin-right: 8px;
  font-size: 12px;
  transition: transform 0.2s ease;
  color: #1f2d3d;
  flex-shrink: 0;
}

details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > summary::before {
  transform: rotate(90deg);
}

/* Hide default markers */
details:not(.toggle):not(.hide-block):not(.hide-inline)
  > summary::-webkit-details-marker,
details:not(.toggle):not(.hide-block):not(.hide-inline) > summary::marker {
  display: none;
}

/* Open state - background changes like hideToggle */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open] {
  border-color: #5b9bd5;
}

details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > summary {
  background: #5b9bd5;
  color: white;
}

details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > summary::before {
  color: white;
}

/* Content elements get vertical margins only, horizontal margins come from wrapper */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > *:not(summary) {
  margin: 16px 24px !important; /* Natural vertical margins, wrapper horizontal margins */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* Override elements that need different vertical margins */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > p {
  margin: 16px 24px !important; /* Standard paragraph spacing */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

/* First element after summary gets proper top margin */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > *:not(summary):first-child {
  margin-top: 30px !important;
}

/* Last element gets proper bottom margin */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > *:not(summary):last-child {
  margin-bottom: 30px !important;
}

/* Fix summary padding - remove unwanted margins */
details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > summary {
  margin: 0 !important;
  padding: 6px 15px !important;
}

/* Dark theme support */
[data-theme="dark"]
  details:not(.toggle):not(.hide-block):not(.hide-inline)
  > summary {
  background: #2c2c2c;
  color: #e6e6e6;
}

[data-theme="dark"]
  details:not(.toggle):not(.hide-block):not(.hide-inline)
  > summary::before {
  color: #e6e6e6;
}

[data-theme="dark"]
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > summary {
  background: #787878;
  color: white;
}

[data-theme="dark"]
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
  > summary::before {
  color: white;
}

/* Mobile responsive */
@media (max-width: 768px) {
  details:not(.toggle):not(.hide-block):not(.hide-inline) {
    margin-bottom: 16px;
  }

  details:not(.toggle):not(.hide-block):not(.hide-inline) > summary {
    padding: 5px 12px;
    font-size: 14px;
  }

  /* Fix summary padding in mobile */
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > summary {
    margin: 0 !important;
    padding: 5px 12px !important;
  }

  /* Mobile content elements get vertical margins only, horizontal margins from wrapper */
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
    > *:not(summary) {
    margin: 14px 16px !important; /* Natural vertical margins, wrapper horizontal margins */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  /* Mobile paragraphs get standard spacing */
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open] > p {
    margin: 14px 16px !important; /* Standard mobile paragraph spacing */
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
  }

  /* Mobile - first element after summary gets proper top margin */
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
    > *:not(summary):first-child {
    margin-top: 20px !important;
  }

  /* Mobile - last element gets proper bottom margin */
  details:not(.toggle):not(.hide-block):not(.hide-inline)[open]
    > *:not(summary):last-child {
    margin-bottom: 20px !important;
  }
}