/* Enhanced Water theme variables */
:root {
	--water-title-bg: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 100%);
	--water-title-text: #0c4a6e;
	--water-content-bg: #ffffff;
	--water-border: #93c5fd;
	--water-accent: #0ea5e9;
	--water-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
	--water-shadow-hover: 0 4px 12px rgba(14, 165, 233, 0.15);
	--water-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base typography for all toggles (Sphinx + raw HTML) */


.toggle-details,
details:not(.toggle-details) {
	font-family: 'Inter', sans-serif;
	color: #374151;
	font-size: 0.75rem; /* single source of truth for size */
}

/* Header (summary) styling */
.toggle-details summary,
details:not(.toggle-details) > summary {
	background: transparent;
	color: var(--water-title-text);
	border: none;
	border-radius: 0;
	padding: 0;
	font-size: inherit !important;
	font-weight: normal;
	cursor: pointer;
	transition: var(--water-transition);
	box-shadow: none;
	position: relative;
	overflow: hidden;
}

/* Closed vs open background */
details:not(.toggle-details):not([open]) > summary,
.toggle-details:not([open]) summary {
	background: transparent;
	box-shadow: none;
}

/* Hover feedback */
details:not(.toggle-details) > summary:hover,
.toggle-details summary:hover {
	background: transparent;
	box-shadow: none;
	transform: none;
}

/* Add subtle animation on open */
.toggle-details[open] summary,
details[open]:not(.toggle-details) > summary {
	background: transparent;
	box-shadow: none;
}

/* Ensure the pointer cursor also appears over inner elements (text, icons) */
.toggle-details summary *,
details:not(.toggle-details) > summary * {
	cursor: pointer;
}

/* For Sphinx admonition-based toggles */
.admonition.toggle > .admonition-title,
.admonition.toggle > .admonition-title * {
	cursor: pointer;
}

/* Content container (square border). Remove square when flagged with no-square */
.toggle-details > *:not(summary),
details:not(.toggle-details) > *:not(summary) {
	background-color: var(--water-content-bg);
	border: 1px solid var(--water-border);
	border-radius: 0.375rem;
	padding: 0.75rem 1rem;
	margin-top: 0.25rem;
	margin-bottom: 1rem;
	font-size: inherit !important;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
	transition: var(--water-transition);
	position: relative;
}

/* Remove borders from expanded toggle content - plain variant */
.toggle-details[open] > *:not(summary),
details[open]:not(.toggle-details) > *:not(summary) {
    border: none;
    border-radius: 0;
    margin-top: 0;
    background: transparent;
    box-shadow: none;
    padding-left: 1.5em;
}

.toggle-details[open] summary,
details[open]:not(.toggle-details) > summary {
    border-radius: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}

/* No square variant: apply class "no-square" to details element */
details.no-square > *:not(summary) {
	border: none !important;
	background: transparent !important;
	padding: 0.25rem 0 0 0;
}

/* Align no-square subtoggles spacing with list items */
li > details.no-square > *:not(summary) {
	padding: 0;           /* no extra inner padding */
	margin: 0;            /* remove extra gap under summary */
}

/* Keep nested list indentation but remove extra top margin */
li > details.no-square > ul,
li > details.no-square > ol {
	margin: 0;            /* align with list line spacing */
	padding-left: 1.2em;  /* standard list indent */
}

/* Lists inside toggles (numbers and text the same size) */
.toggle-details ul,
.toggle-details ol,
details:not(.toggle-details) ul,
details:not(.toggle-details) ol,
.toggle-details ul li,
.toggle-details ol li,
details:not(.toggle-details) ul li,
details:not(.toggle-details) ol li {
	font-size: inherit !important;
}

/* Nested details inside list items should look inline with siblings */
li > details:not(.toggle-details) {
	margin: 0.5rem 0;
}

/* Add minimum spacing between list items containing toggles */
ul li:has(> details),
ol li:has(> details) {
	margin-bottom: 0.5rem;
}

/* Fallback for browsers that don't support :has() */
@supports not (selector(:has(*))) {
	ul li > details:first-child:last-child,
	ol li > details:first-child:last-child {
		margin-bottom: 0.5rem;
	}
}

/* Consistent spacing for all items inside toggle content */
.toggle-details > *:not(summary) > *,
details:not(.toggle-details) > *:not(summary) > * {
	margin-bottom: 0.5rem !important;
}

/* Specific spacing for list items in toggle content */
.toggle-details ul li,
.toggle-details ol li,
details:not(.toggle-details) ul li,
details:not(.toggle-details) ol li {
	margin-bottom: 0.5rem !important;
}

/* Consistent spacing for paragraphs and other elements */
.toggle-details p,
.toggle-details div,
.toggle-details pre,
.toggle-details blockquote,
details:not(.toggle-details) p,
details:not(.toggle-details) div,
details:not(.toggle-details) pre,
details:not(.toggle-details) blockquote {
	margin-bottom: 0.5rem !important;
}

/* Ensure nested lists maintain consistent spacing */
.toggle-details ul ul li,
.toggle-details ol ol li,
.toggle-details ul ol li,
.toggle-details ol ul li,
details:not(.toggle-details) ul ul li,
details:not(.toggle-details) ol ol li,
details:not(.toggle-details) ul ol li,
details:not(.toggle-details) ol ul li {
	margin-bottom: 0.5rem !important;
}

/* Override any conflicting margins for the last child to maintain consistency */
.toggle-details > *:not(summary) > *:last-child,
details:not(.toggle-details) > *:not(summary) > *:last-child {
	margin-bottom: 0.5rem !important;
}

/* Ensure minimum separation between toggle elements */
.toggle-details,
details:not(.toggle-details) {
	margin-bottom: 0.7rem !important; /* Space between consecutive toggles */
	margin-top: 0.5rem !important; /* Ensure top spacing as well */
}

/* Specific spacing for consecutive details elements */
details + details,
.toggle-details + .toggle-details,
details + .toggle-details,
.toggle-details + details {
	margin-top: 0.7rem !important; /* Force space between consecutive toggles */
}

/* Handle spacing in raw HTML blocks */
div.raw-html details,
div[class*="raw"] details {
	margin-top: 0.75rem !important;
	margin-bottom: 0.7rem !important;
}

/* Additional spacing for nested toggles to prevent overlap */
.toggle-details .toggle-details,
.toggle-details details:not(.toggle-details),
details:not(.toggle-details) .toggle-details,
details:not(.toggle-details) details:not(.toggle-details) {
	margin-top: 0.75rem !important;
	margin-bottom: 0.75rem !important;
}

/* Ensure spacing is maintained when toggles are open */
.toggle-details[open],
details[open]:not(.toggle-details) {
	margin-bottom: 0.7rem !important; /* Match closed state spacing */
}

/* Special handling for toggles inside list items */
li > .toggle-details,
li > details:not(.toggle-details) {
	margin-top: 0.5rem !important;
	margin-bottom: 0.75rem !important;
}

/* Prevent overlap in deeply nested scenarios */
.toggle-details .toggle-details .toggle-details,
details:not(.toggle-details) details:not(.toggle-details) details:not(.toggle-details) {
	margin-top: 0.5rem !important;
	margin-bottom: 0.5rem !important;
}
li > details:not(.toggle-details) > summary {
	background: transparent !important;
	border: none !important;
	padding: 0;
	display: inline;
    position: relative;
}
li > details:not(.toggle-details) > summary:hover {
	background-color: #f3f4f6 !important;
}

/* Hide default markers for all details elements to use custom arrows */
details > summary::-webkit-details-marker,
.toggle-details > summary::-webkit-details-marker { 
    display: none; 
}
details > summary::marker,
.toggle-details > summary::marker { 
    content: ''; 
}

/* Replace list bullet/number with a chevron arrow for items that contain a sub-toggle */
ul li:has(> details),
ol li:has(> details) {
    list-style: none !important; /* hide default marker */
}

/* Fallback for browsers that don't support :has() - using a more specific selector */
@supports not (selector(:has(*))) {
    ul li > details:first-child:last-child,
    ol li > details:first-child:last-child {
        list-style: none !important;
    }
}

/* Additional fallback - remove list style from any li containing details */
li > details {
    list-style: none !important;
}

/* Ensure parent li also has no list style */
ul li:has(details),
ol li:has(details),
ul li > details,
ol li > details {
    list-style-type: none !important;
}

/* More specific targeting for nested list items with details */
ul li details,
ol li details {
    list-style: none !important;
}

li:has(details) {
    list-style: none !important;
}

/* Enhanced chevron arrow for all toggle summaries - smaller size with better visibility */
.toggle-details > summary::before,
details:not(.toggle-details) > summary::before {
    content: '';
    display: inline-block;
    width: 0.5em;
    height: 0.5em;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    margin-right: 0.75em;
    margin-left: 0.1em;
    vertical-align: middle;
    position: relative;
    transform: rotate(-45deg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    transform-origin: center;
}

/* Enhanced chevron hover effect */
.toggle-details summary:hover::before,
details:not(.toggle-details) > summary:hover::before {
    opacity: 0.9;
    transform: rotate(-45deg) scale(1.05);
}

/* Rotate chevron when toggle is open - ensure full visibility */
.toggle-details[open] > summary::before,
details[open]:not(.toggle-details) > summary::before {
    transform: rotate(45deg);
    opacity: 0.9;
}

/* Enhanced open state chevron hover */
.toggle-details[open] summary:hover::before,
details[open]:not(.toggle-details) > summary:hover::before {
    transform: rotate(45deg) scale(1.05);
}

/* Special positioning for nested toggles (inside list items) */
li > details:not(.toggle-details) > summary::before {
    position: absolute !important;
    left: -1.5em; /* Better horizontal alignment with other list elements */
    top: 0.4em; /* Improved vertical centering with text */
    margin-right: 0; /* override the general margin */
    display: block !important; /* override inline-block */
}

/* Also remove the bullet for the actual list item that wraps a no-square details */
ul li:has(> details.no-square),
ol li:has(> details.no-square) {
    list-style: none !important;
}

/* Fallback for browsers that don't support :has() */
@supports not (selector(:has(*))) {
    ul li > details.no-square,
    ol li > details.no-square {
        list-style: none !important;
    }
}

/* Code block wrapping inside toggles */
.toggle-details pre,
.toggle-details code,
details:not(.toggle-details) pre,
details:not(.toggle-details) code {
    white-space: pre-wrap !important; /* Allow wrapping while preserving formatting */
    word-wrap: break-word !important; /* Break long words if needed */
    overflow-wrap: break-word !important; /* Modern property for word breaking */
    word-break: break-all !important; /* Break anywhere if needed */
}

/* Specific handling for code blocks inside toggle content */
.toggle-details > *:not(summary) pre,
.toggle-details > *:not(summary) code,
details:not(.toggle-details) > *:not(summary) pre,
details:not(.toggle-details) > *:not(summary) code {
    max-width: 100% !important;
    overflow: visible !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Handle inline code within toggles */
.toggle-details p code,
.toggle-details li code,
.toggle-details div code,
details:not(.toggle-details) p code,
details:not(.toggle-details) li code,
details:not(.toggle-details) div code {
    white-space: normal !important; /* Allow normal wrapping for inline code */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Enhanced visual styling for better aesthetics */
/* Add subtle glow effect on focus */
.toggle-details summary:focus,
details:not(.toggle-details) > summary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2), var(--water-shadow-hover);
}

/* Add a subtle shine effect */
.toggle-details summary::after,
details:not(.toggle-details) > summary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.6s;
    pointer-events: none;
}

.toggle-details summary:hover::after,
details:not(.toggle-details) > summary:hover::after {
    left: 100%;
}

/* Improve text readability and spacing */
.toggle-details summary,
details:not(.toggle-details) > summary {
    line-height: 1.4;
    letter-spacing: 0.025em;
}

/* Add subtle border radius animation */
.toggle-details,
details:not(.toggle-details) {
    transition: var(--water-transition);
}

/* Enhanced content styling */
.toggle-details > *:not(summary) *,
details:not(.toggle-details) > *:not(summary) * {
    line-height: 1.6;
}

/* Style for better visual hierarchy */
.toggle-details > *:not(summary) h1,
.toggle-details > *:not(summary) h2,
.toggle-details > *:not(summary) h3,
.toggle-details > *:not(summary) h4,
.toggle-details > *:not(summary) h5,
.toggle-details > *:not(summary) h6,
details:not(.toggle-details) > *:not(summary) h1,
details:not(.toggle-details) > *:not(summary) h2,
details:not(.toggle-details) > *:not(summary) h3,
details:not(.toggle-details) > *:not(summary) h4,
details:not(.toggle-details) > *:not(summary) h5,
details:not(.toggle-details) > *:not(summary) h6 {
    color: var(--water-title-text);
    margin-top: 0;
    margin-bottom: 0.75rem;
}

/* Beautiful styling for layout section headers - minimalist compact non-interactive design */
/* Enhanced styling for layout section separators */
.layout-section,
.layout-header,
p.layout-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-left: 2px solid var(--water-accent);
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
    margin: 1rem 0 0.75rem 0;
    font-weight: 500;
    color: var(--water-title-text);
    box-shadow: 0 1px 3px rgba(14, 165, 233, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
    position: relative;
    font-size: 0.75rem;
    letter-spacing: 0.015em;
    line-height: 1.3;
    overflow: hidden;
    cursor: default;
}

.layout-section::before,
.layout-header::before,
p.layout-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--water-accent) 0%, rgba(14, 165, 233, 0.3) 80%, transparent 100%);
    border-radius: 0.375rem 0.375rem 0 0;
}

/* Remove dot indicator for plain design */
.layout-section::after,
.layout-header::after,
p.layout-header::after {
    content: '';
    display: none;
}

/* No hover effects for plain layout headers - non-interactive */

/* Alternative approach - style paragraphs that contain specific layout text patterns */
/* This uses a more general approach for better browser compatibility */

/* Target specific paragraph patterns that appear before widget sections */
/* Using adjacent sibling selector for paragraphs before raw HTML blocks */
div.raw-html:has(details) {
    margin-top: 1rem;
}

/* Style for section dividers between widget groups - compact */
.widget-section-divider {
    background: linear-gradient(135deg, #fefefe 0%, #f9fafb 100%);
    border: 1px solid #f3f4f6;
    border-left: 2px solid #6b7280;
    border-radius: 0.1875rem;
    padding: 0.25rem 0.5rem;
    margin: 0.375rem 0 0.25rem 0;
    font-weight: 500;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    font-size: 0.7rem;
    position: relative;
    transition: var(--water-transition);
    overflow: hidden;
}

.widget-section-divider::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 3px;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, #6b7280 0%, rgba(107, 114, 128, 0.3) 70%, transparent 100%);
}

/* Minimal hover effect for plain widget dividers */
.widget-section-divider:hover {
    border-left-width: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

/* Mobile responsive design for compact plain layout headers */
@media screen and (max-width: 768px) {
    .layout-section,
    .layout-header,
    p.layout-header {
        padding: 0.3rem 0.625rem;
        margin: 0.75rem 0 0.5rem 0;
        font-size: 0.7rem;
        border-radius: 0.1875rem;
    }
    
    .layout-section::after,
    .layout-header::after,
    p.layout-header::after {
        right: 0.5rem;
        font-size: 0.7rem;
    }
    
    .widget-section-divider {
        padding: 0.2rem 0.375rem;
        margin: 0.25rem 0 0.1875rem 0;
        font-size: 0.65rem;
    }
    
    /* No hover effects on mobile - layout headers are non-interactive */
}

@media screen and (max-width: 480px) {
    .layout-section,
    .layout-header,
    p.layout-header {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
        border-left-width: 2px;
        margin: 0.25rem 0 0.1875rem 0;
    }
    
    .layout-section::after,
    .layout-header::after,
    p.layout-header::after {
        display: none; /* Hide decorative elements on small screens */
    }
    
    .widget-section-divider {
        padding: 0.1875rem 0.375rem;
        font-size: 0.6rem;
        border-left-width: 1px;
        margin: 0.1875rem 0 0.125rem 0;
    }
}

/* Typography improvements for plain design */
.layout-section,
.layout-header,
p.layout-header {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.widget-section-divider {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout headers are non-interactive - no focus states needed */

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    .layout-section,
    .layout-header,
    p.layout-header,
    .widget-section-divider,
    .layout-section::after,
    .layout-header::after,
    p.layout-header::after {
        transition: none;
    }
}

/* Print styles */
@media print {
    .layout-section,
    .layout-header,
    p.layout-header,
    .widget-section-divider {
        box-shadow: none;
        background: transparent;
        border-left: 3px solid #000000;
        color: #000000;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .layout-section::before,
    .layout-header::before,
    p.layout-header::before,
    .layout-section::after,
    .layout-header::after,
    p.layout-header::after,
    .widget-section-divider::after {
        display: none;
    }
}

/* -------------------------------------------------- */
/* Custom styling for Info-Feature index toggle headers */
.info-feature-toggle details > summary,
.info-feature-toggle .toggle-details > summary {
    background: #55abe4;
    color: #ffffff;
    font-size: 6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Center arrow vertically inside the new bigger header */
.info-feature-toggle details > summary::before,
.info-feature-toggle .toggle-details > summary::before {
    top: 0.15em; /* Improved vertical centering of arrow */
}

/* Hover effect: slightly lighter blue */
.info-feature-toggle details > summary:hover,
.info-feature-toggle .toggle-details > summary:hover {
    background: transparent !important;
}

/* -------------------------------------------------- */
/* Bigger font for project type headers inside <summary> */
.info_feture_project_type {
    font-size: 0.95rem;
    font-weight: 500;
}

/* -------------------------------------------------- */
/* Bigger font for toctree list items inside toggles */
.toggle-details ul li > a,
.toggle-details ol li > a,
.info-feature-toggle ul li > a {
    font-size: 0.85rem !important; /* Increase from 0.75rem */
    line-height: 1.5;
}
