/**
 * Charl Product Accordions — frontend styles v1.1.0
 *
 * Accordion rows + size guide modal.
 */

/* ---- Accordions ---------------------------------------------------------- */

.cpa-accordions {
	margin: 24px 0 0;
	border-top: 1px solid #d0cece;
}

.cpa-accordion-item {
	border-bottom: 1px solid #d0cece;
}

/* ---- Row wrapper (trigger + optional SIZE GUIDE button) ------------------ */
/* A <button> cannot contain another <button>, so SIZE GUIDE is a sibling.   */

.cpa-accordion-row {
	display: flex;
	align-items: center;
}

.cpa-accordion-trigger {
	display: flex;
	align-items: center;
	flex: 1;
	padding: 16px 0;
	background: none;
	border: none;
	cursor: pointer;
	text-align: left;
	gap: 12px;
	min-width: 0; /* allow flex shrink */
}

.cpa-accordion-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.cpa-accordion-label {
	flex: 1;
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: inherit;
}

/* ---- Size guide button (sibling of trigger, inside .cpa-accordion-row) -- */

.cpa-size-guide-btn {
	flex-shrink: 0;
	font-size: 11px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 2px;
	background: none;
	border: none;
	cursor: pointer;
	color: inherit;
	padding: 0 0 0 12px;
	white-space: nowrap;
}

.cpa-size-guide-btn:hover       { opacity: 0.7; }

.cpa-size-guide-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---- + / − icon ---------------------------------------------------------- */

.cpa-accordion-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 16px;
	height: 16px;
	position: relative;
}

.cpa-accordion-icon::before,
.cpa-accordion-icon::after {
	content: '';
	position: absolute;
	background-color: currentColor;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.cpa-accordion-icon::before {
	width: 14px;
	height: 1px;
}

.cpa-accordion-icon::after {
	width: 1px;
	height: 14px;
}

.cpa-accordion-trigger[aria-expanded="true"] .cpa-accordion-icon::after {
	transform: rotate(90deg);
	opacity: 0;
}

/* ---- Panel --------------------------------------------------------------- */

.cpa-accordion-panel {
	overflow: hidden;
	max-height: 0;
	transition: max-height 0.3s ease;
}

.cpa-accordion-content {
	padding: 0 0 20px;
	font-size: 14px;
	line-height: 1.65;
	color: inherit;
}

.cpa-accordion-content p:first-child { margin-top: 0; }
.cpa-accordion-content p:last-child  { margin-bottom: 0; }

.cpa-accordion-content ul,
.cpa-accordion-content ol {
	padding-left: 20px;
	margin: 8px 0;
}

.cpa-accordion-content li { margin-bottom: 4px; }

.cpa-accordion-content a {
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* =========================================================================
   Inline SIZE GUIDE link (in the Size label row of the variations table)
   ========================================================================= */

/*
 * The button is output after the variations table and moved into the
 * Size label <td> by JS. The label cell becomes a flex row so the
 * label text and the SIZE GUIDE link sit side by side.
 */

.cpa-label-cell-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.cpa-inline-size-guide {
	flex-shrink: 0;
	font-size: 11px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 2px;
	background: none;
	border: none;
	cursor: pointer;
	color: inherit;
	padding: 0;
	white-space: nowrap;
}

.cpa-inline-size-guide:hover       { opacity: 0.7; }
.cpa-inline-size-guide:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* =========================================================================
   Size guide modal
   ========================================================================= */

/* ---- Overlay ------------------------------------------------------------- */

.cpa-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 99999;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 40px 16px;
	overflow-y: auto;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.cpa-modal-overlay:not([hidden]) {
	opacity: 1;
}

/* Keep the overlay in the DOM but invisible/inert when hidden */
.cpa-modal-overlay[hidden] {
	display: none;
}

/* ---- Inner panel --------------------------------------------------------- */

.cpa-modal-inner {
	background: #fff;
	width: 100%;
	max-width: 600px;
	max-height: calc(100vh - 80px);
	overflow-y: auto;
	position: relative;
	transform: translateY(16px);
	transition: transform 0.25s ease;
}

.cpa-modal-overlay:not([hidden]) .cpa-modal-inner {
	transform: translateY(0);
}

/* ---- Header -------------------------------------------------------------- */

.cpa-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 24px 24px 16px;
	border-bottom: 1px solid #e8e6e6;
	position: sticky;
	top: 0;
	background: #fff;
	z-index: 1;
}

.cpa-modal-title {
	margin: 0;
	font-size: 18px;
	font-weight: 400;
	letter-spacing: 0.02em;
}

.cpa-modal-close {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 22px;
	line-height: 1;
	color: inherit;
	padding: 4px 6px;
	opacity: 0.7;
	transition: opacity 0.15s;
}

.cpa-modal-close:hover       { opacity: 1; }
.cpa-modal-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---- Body ---------------------------------------------------------------- */

.cpa-modal-body {
	padding: 24px;
}

/* ---- Measurements table -------------------------------------------------- */

.cpa-modal-table {
	margin-bottom: 24px;
	overflow-x: auto; /* horizontal scroll on narrow screens */
}

.cpa-modal-table table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}

.cpa-modal-table th,
.cpa-modal-table td {
	padding: 8px 12px;
	text-align: left;
	border-bottom: 1px solid #e8e6e6;
}

.cpa-modal-table th {
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.cpa-modal-table tr:last-child td { border-bottom: none; }

/* ---- Diagram image ------------------------------------------------------- */

.cpa-modal-diagram {
	margin-bottom: 24px;
	border: 1px solid #e8e6e6;
	padding: 16px;
}

.cpa-modal-diagram img {
	display: block;
	width: 100%;
	height: auto;
}

/* ---- Notes --------------------------------------------------------------- */

.cpa-modal-notes {
	font-size: 13px;
	line-height: 1.65;
	color: #555;
}

.cpa-modal-notes p:first-child { margin-top: 0; }
.cpa-modal-notes p:last-child  { margin-bottom: 0; }

/* ---- Reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.cpa-accordion-panel,
	.cpa-accordion-icon::after,
	.cpa-modal-overlay,
	.cpa-modal-inner { transition: none; }
}
