/**
 * CDSWerx Accordion Widget Styles
 *
 * Uses native <details>/<summary> elements.
 * Per-item icon toggle: .icon-normal (closed) / .icon-active (open).
 * Smart CSS: auto border-collapse, first/last radius, hover inheritance.
 *
 * @package CDSWerx_Widget_Library
 * @since   2.12.0
 */

/* ============================================
   Container
   ============================================ */

.cdswerx-accordion {
	display: flex;
	flex-direction: column;
	gap: 0;
}

/* ============================================
   Item (<details>)
   ============================================ */

.cdswerx-accordion__item {
	border: 1px solid #e0e0e0;
	border-style: solid;
}

/* Auto border-collapse: remove doubled border between stacked items */
.cdswerx-accordion__item + .cdswerx-accordion__item {
	border-top: 0;
}

/*
 * Border-radius: dual-target strategy via Elementor selector.
 *
 * The PHP control sets border-radius on BOTH:
 *   - .cdswerx-accordion__item  → each item (visible when gap > 0)
 *   - .cdswerx-accordion        → wrapper with overflow:hidden (clips stacked items' outer corners)
 *
 * Stacked (no gap): wrapper clips first/last item outer corners automatically.
 * Gapped: each item renders its own radius; wrapper has no visual effect.
 * No CSS hacks, no !important, no JS needed.
 */

/* ============================================
   Header (<summary>)
   ============================================ */

.cdswerx-accordion__header {
	display: flex;
	align-items: center;
	cursor: pointer;
	padding: 15px 20px;
	border: 0 solid transparent;
	list-style: none;         /* Remove Firefox marker */
	user-select: none;
	transition: background-color 0.25s ease, color 0.25s ease,
	            border-color 0.25s ease, border-radius 0.25s ease;
}

/* Remove marker in all browsers */
.cdswerx-accordion__header::-webkit-details-marker,
.cdswerx-accordion__header::marker {
	display: none;
	content: '';
}

/* Icon on the right: title takes remaining space, icon floats right */
.cdswerx-accordion__header.cdswerx-accordion__icon-pos-right {
	justify-content: space-between;
}

/* Icon on the left: icon first, title fills remaining space */
.cdswerx-accordion__header.cdswerx-accordion__icon-pos-left {
	flex-direction: row;
}

/* ============================================
   Title / Label
   ============================================ */

.cdswerx-accordion__title {
	margin: 0;
	padding: 0;
	flex: 1;                  /* Always stretches to fill header — no margin hacks needed */
	font-weight: 600;
}

/* ============================================
   Icon Toggle
   ============================================ */

.cdswerx-accordion__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 14px;
	line-height: 1;
	transition: color 0.25s ease;
}

/* Left icon spacing */
.cdswerx-accordion__icon-pos-left .cdswerx-accordion__icon {
	margin-right: 10px;
}

/* Right icon spacing */
.cdswerx-accordion__icon-pos-right .cdswerx-accordion__icon {
	margin-left: 10px;
}

/* Show normal icon by default, hide active icon */
.cdswerx-accordion__icon .cdswerx-accordion__icon-active {
	display: none;
}

.cdswerx-accordion__icon .cdswerx-accordion__icon-normal {
	display: inline-flex;
}

/* When open: swap to active icon */
.cdswerx-accordion__item[open] .cdswerx-accordion__icon .cdswerx-accordion__icon-normal {
	display: none;
}

.cdswerx-accordion__item[open] .cdswerx-accordion__icon .cdswerx-accordion__icon-active {
	display: inline-flex;
}

/* SVG sizing */
.cdswerx-accordion__icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

/* ============================================
   Title Prefix Indicator
   ============================================ */

.cdswerx-accordion__prefix {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	gap: 5px;
	margin-right: 10px;
	line-height: 1;
	transition: color 0.25s ease, background-color 0.25s ease;
}

.cdswerx-accordion__prefix-number,
.cdswerx-accordion__prefix-text {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: color 0.25s ease, background-color 0.25s ease;
}

.cdswerx-accordion__prefix-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	transition: color 0.25s ease, background-color 0.25s ease;
}

.cdswerx-accordion__prefix-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

/* ============================================
   Content
   ============================================ */

.cdswerx-accordion__content {
	border: 0 solid transparent;
	/* Default divider line between header and content */
	border-top-width: 1px;
	border-top-color: #e0e0e0;
	box-sizing: border-box;
	height: 0;
	overflow: hidden;
	visibility: hidden;
	/* Easing matches the show-effect keyframes (same cubic-bezier, same 500ms) so
	   the height grow and the content move/fade animate in lockstep. Previously the
	   height used `ease` while the effect used this curve — the two ran on different
	   curves simultaneously, which read as choppy/disjointed. */
	transition: height 0.5s cubic-bezier(0.26, 0.69, 0.37, 0.96);
}

.cdswerx-accordion__content-inner {
	padding: 15px 20px;
	position: relative;
	backface-visibility: hidden;
	transform: translateZ(0);
	transform-origin: top center;
}

.cdswerx-accordion__item[open] > .cdswerx-accordion__content {
	visibility: visible;
}

.cdswerx-accordion__content p:last-child {
	margin-bottom: 0;
}

/* List / marker base styles for this widget's WYSIWYG content live in the shared
   stylesheet assets/css/wysiwyg-content.css (handle cdswerx-wysiwyg-content,
   loaded as a dependency of this file). Rendered markup carries the generic
   `cds-wysiwyg*` hooks next to the BEM classes (WYSIWYG_List_Styles_Trait).
   The per-widget copies that used to live here were removed after #87 —
   do not re-add them. */

/* ============================================
   Editor Placeholder (Add Widget mode)
   ============================================ */

.cdswerx-trimodal-widget-placeholder {
	padding: 20px;
	background: #f0f4ff;
	border: 2px dashed #a0b4e8;
	border-radius: 4px;
	color: #5a6fa0;
	font-size: 13px;
	text-align: center;
}

/* ============================================
   Editor Notice (no items / no query)
   ============================================ */

.cdswerx-accordion-notice {
	padding: 12px 16px;
	background: #fff8e1;
	border: 1px solid #ffe082;
	border-radius: 4px;
	color: #795548;
	font-size: 13px;
}

/* ============================================
   Show Effects
   Applied via JS: .cdswerx-is-opening on <details>
   Triggered on open; class removed on animationend
   ============================================ */

.cdswerx-accordion[data-show-effect="fade"] .cdswerx-accordion__item.cdswerx-is-opening .cdswerx-accordion__content-inner {
	animation: cdswerx-acc-fade-in 500ms cubic-bezier(0.26, 0.69, 0.37, 0.96) forwards;
}

.cdswerx-accordion[data-show-effect="move-up"] .cdswerx-accordion__item.cdswerx-is-opening .cdswerx-accordion__content-inner {
	animation: cdswerx-acc-move-up 500ms cubic-bezier(0.26, 0.69, 0.37, 0.96) forwards;
}

.cdswerx-accordion[data-show-effect="zoom-in"] .cdswerx-accordion__item.cdswerx-is-opening .cdswerx-accordion__content-inner {
	animation: cdswerx-acc-zoom-in 500ms cubic-bezier(0.26, 0.69, 0.37, 0.96) forwards;
}

.cdswerx-accordion[data-show-effect="zoom-out"] .cdswerx-accordion__item.cdswerx-is-opening .cdswerx-accordion__content-inner {
	animation: cdswerx-acc-zoom-out 500ms cubic-bezier(0.26, 0.69, 0.37, 0.96) forwards;
}

.cdswerx-accordion[data-show-effect="fall-perspective"] .cdswerx-accordion__item.cdswerx-is-opening .cdswerx-accordion__content-inner {
	animation: cdswerx-acc-fall-perspective 500ms cubic-bezier(0.26, 0.69, 0.37, 0.96) forwards;
}

@keyframes cdswerx-acc-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes cdswerx-acc-move-up {
	from { opacity: 0; transform: translateY(25px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes cdswerx-acc-zoom-in {
	from { opacity: 0; transform: scale(0.75); }
	to   { opacity: 1; transform: scale(1); }
}

@keyframes cdswerx-acc-zoom-out {
	from { opacity: 0; transform: scale(1.1); }
	to   { opacity: 1; transform: scale(1); }
}

@keyframes cdswerx-acc-fall-perspective {
	from {
		opacity: 0;
		transform: perspective(1000px) translateY(50px) translateZ(-300px) rotateX(-35deg);
	}
	to {
		opacity: 1;
		transform: perspective(1000px) translateY(0) translateZ(0) rotateX(0deg);
	}
}
