/* Summary Box Enhanced Styles */
:root {
  --sbb-border: #e6e6e6;
  --sbb-bg: #fbfbfb;
  --sbb-heading: #333333;
  --sbb-text: #555555;
  --sbb-radius: 12px;
  --sbb-padding: 24px;
  --sbb-accent: #0073aa;
  --sbb-shadow: 0 6px 18px rgba(20,20,20,0.06);
}

/* Container */
.summary-box-block {
  border: 1px solid var(--sbb-border);
  padding: var(--sbb-padding);
  border-radius: var(--sbb-radius);
  background: var(--sbb-bg);
  margin: 40px 0;
  box-sizing: border-box;
  box-shadow: var(--sbb-shadow);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  will-change: transform;
}

/* Hover and focus affordance for editors and interactive themes */
.summary-box-block:hover,
.summary-box-block:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(20,20,20,0.08);
  border-color: #d1d1d1; /* FIX: Darker border so it doesn't vanish */
}

/* Heading as label */
.summary-box-block h2.wp-block-heading,
.summary-box-block h3.wp-block-heading {
  margin-top: 0 !important;
  margin-bottom: 12px !important;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  font-weight: 700;
  border-bottom: 1px solid rgba(224,224,224,1);
  padding-bottom: 12px;
  color: var(--sbb-heading);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Optional small accent dot before heading */
.summary-box-block h2.wp-block-heading::before,
.summary-box-block h3.wp-block-heading::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sbb-accent);
  display: inline-block;
  transform: translateY(-1px);
}

/* Body text */
.summary-box-block p,
.summary-box-block li {
  margin: 0 0 0.75rem 0;
  line-height: 1.6;
  color: var(--sbb-text);
  font-size: 1rem;
}

/* Lists inside summary */
.summary-box-block ul,
.summary-box-block ol {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
}

/* Small meta row */
.summary-box-block .sbb-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  font-size: 0.9rem;
  color: #666;
}

/* Editor visual refinement */
.editor-styles-wrapper .summary-box-block {
  border-style: dashed;
  background: #ffffff;
  outline: 1px solid transparent;
}

/* --- ADDED: Lighter Placeholder for Editor --- */
.summary-box-block [data-rich-text-placeholder]::before {
  color: #ccc !important; /* Soft light grey */
  opacity: 1;
}

/* Focus outline for keyboard users */
.summary-box-block:focus-within {
  outline: 3px solid rgba(0,115,170,0.12);
  outline-offset: 4px;
}


/* Responsive adjustments */
@media (max-width: 720px) {
  :root { --sbb-padding: 18px; }
  .summary-box-block { margin: 28px 0; }
  .summary-box-block h2.wp-block-heading,
  .summary-box-block h3.wp-block-heading { padding-bottom: 10px; }
}

/* Print friendly */
@media print {
  .summary-box-block {
    box-shadow: none;
    border: 1px solid #ddd;
    background: #fff;
    page-break-inside: avoid;
  }
  .summary-box-block h2.wp-block-heading::before { display: none; }
  
  /* NEW: Force details block to reveal hidden content when printing */
  details.collapsible-box-block > *:not(summary) {
    display: block !important;
  }
  /* NEW: Hide the open/close arrow when printing */
  .collapsible-summary::after {
    display: none !important;
  }
}

/* Mobile: allow horizontal scrolling for wide inner content */
@media (max-width: 720px) {
  .summary-box-block {
    overflow-x: hidden; 
  }

  .summary-box-block > *:not(.sbb-meta),
  .summary-box-block .wp-block-group__inner-container,
  .summary-box-block .wp-block-column,
  .summary-box-block .wp-block-table,
  .summary-box-block pre,
  .summary-box-block code,
  .summary-box-block img {
    display: block;
    max-width: 100%;
  }

  .summary-box-block .wp-block-table,
  .summary-box-block pre,
  .summary-box-block code {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* =========================================
   Collapsible Box Specific Styles
   ========================================= */

/* The <details> element inherits from .summary-box-block, 
   so we just need to style the <summary> element and interactions */

.collapsible-box-block {
  /* Prevent padding collapse from <details> */
  padding: 0; 
}

/* 1. Tighter, smaller summary bar */
.collapsible-summary {
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sbb-heading);
  background-color: rgba(0, 0, 0, 0.04); /* Adds the 'Inline Spoilers' light grey header contrast */
  border-bottom: 1px solid rgba(0, 0, 0, 0.05); /* Separator line */
  cursor: pointer;
  list-style: none; 
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  outline: none;
  gap: 15px;
}

/* Make sure the editor doesn't double-pad since we added the inner wrapper */
.editor-styles-wrapper .collapsible-box-block-editor {
  padding: 0;
}

/* Hide default triangle in WebKit (Safari/Chrome) */
.collapsible-summary::-webkit-details-marker {
  display: none;
}

/* Custom CSS Toggle Arrow */
.collapsible-summary::after {
  content: "▼"; 
  font-size: 0.7em;
  color: var(--sbb-accent);
  transition: transform 0.2s ease;
  flex-shrink: 0; /* Prevents the arrow from getting squished by long text */
}

/* Rotate arrow when details is open */
.collapsible-box-block[open] .collapsible-summary::after {
  transform: rotate(180deg);
}

/* Focus state for accessibility */
.collapsible-summary:focus {
  background-color: rgba(0,0,0,0.02);
}

/* 2. Fix the Mobile View */
@media (max-width: 720px) {
  .collapsible-summary {
    padding: 12px 16px; /* Even smaller spacing on mobile */
    font-size: 1rem;
  }
}

/* Add breathing room to the hidden content area */
.collapsible-content {
  padding: 16px 20px 24px 20px; /* Top, Right, Bottom, Left */
}

/* Ensure the content padding shrinks slightly on mobile to match the header */
@media (max-width: 720px) {
  .collapsible-content {
    padding: 12px 16px 20px 16px;
  }
}

/* Force the backend editor to respect the inner content padding */
.editor-styles-wrapper .collapsible-content {
  padding: 16px 20px 24px 20px !important;
}

@media (max-width: 720px) {
  .editor-styles-wrapper .collapsible-content {
    padding: 12px 16px 20px 16px !important;
  }
}