/**
 * Samaya Tabs / Accordion
 *
 * BEM conventions:
 *   Block:     .smya-tabs
 *   Elements:  .smya-tabs__*
 *   Modifiers: .smya-tabs--align-*, .smya-tabs__tab--has-image
 *   States:    .is-active
 *
 * The accordion "breakpoint" is injected inline per-instance, so this
 * stylesheet only contains the default (desktop) appearance + the
 * accordion-trigger base styles used once the inline media query fires.
 */

.smya-tabs {
	/* Public CSS custom properties (set inline per-instance via shortcode). */
	--smya-tablist-max-width: none;
	--smya-tab-height: 220px;
	--smya-tab-gap: 12px;
	--smya-arrow-size: 35px;
	--smya-body-border: 2px solid #b4bcc7;
	--smya-body-bg: #fff;
	--smya-body-radius: 10px;
	--smya-body-padding: 1.5rem;
	--smya-accordion-height: 64px;
	/* Global accordion-title background (mobile only).
	   Intentionally left as `initial`/`none` so the per-tab image
	   (via --smya-trigger-bg) shows through when not overridden. */
	--smya-accordion-bg-color: transparent;
	--smya-accordion-bg-image: none;
	/* Overridden inline by the shortcode; matches PHP / VC default. */
	--smya-tab-content-color: #333333;

	display: block;
	width: 100%;
}

.smya-tabs *,
.smya-tabs *::before,
.smya-tabs *::after {
	box-sizing: border-box;
}

/* Screen-reader-only helper – mirrors the WP core `.screen-reader-text`. */
.smya-tabs .screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}

/* -------------------------------------------------------------------------
 * Tab list (desktop)
 * ------------------------------------------------------------------------- */
.smya-tabs__tablist {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--smya-tab-gap);
	margin-bottom: 0;
	max-width: var(--smya-tablist-max-width);
	/* Alignment is applied via margin-left/right below so it keeps
	   working once `max-width` constrains the tablist width. */
	margin-left: 0;
	margin-right: auto;
}

.smya-tabs--align-center .smya-tabs__tablist {
	margin-left: auto;
	margin-right: auto;
}

.smya-tabs--align-right .smya-tabs__tablist {
	margin-left: auto;
	margin-right: 0;
}

.smya-tabs__tab {
	appearance: none;
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	/* `flex: 1 1 0` with a fixed basis keeps every tab at exactly the
	   same width regardless of its active state. */
	flex: 1 1 0;
	font: inherit;
	min-width: 0;
	padding: 1rem;
	position: relative;
	text-align: left;
	transition: color 0.2s ease;
}

.smya-tabs__tab:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* -------------------------------------------------------------------------
 * Shared appearance for image-backed triggers.
 * NOTE: we deliberately do NOT set `display` here – the tab button is
 * always visible on desktop, while the accordion trigger's visibility
 * is controlled by the inline per-instance media query. Keeping display
 * logic out of this block prevents mobile rules leaking into desktop.
 * ------------------------------------------------------------------------- */
.smya-tabs__tab--has-image,
.smya-tabs__accordion-trigger--has-image {
	background-image: var(--smya-trigger-bg, none);
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
	border-radius: 10px;
	color: #fff;
	overflow: hidden;
}

.smya-tabs__tab--has-image {
	align-items: flex-end;
	display: flex;
	height: var(--smya-tab-height);
}

.smya-tabs__accordion-trigger--has-image {
	align-items: flex-end;
}

/* Tabs without images still honour the configured height so the
   tablist stays visually consistent. */
.smya-tabs__tab:not(.smya-tabs__tab--has-image) {
	height: var(--smya-tab-height);
}

.smya-tabs__tab--has-image .smya-tabs__label,
.smya-tabs__accordion-trigger--has-image .smya-tabs__label {
	position: relative;
	z-index: 1;
	width: 100%;
}

/* -------------------------------------------------------------------------
 * Desktop active / inactive states.
 * Inactive tabs keep their image visible but hide the label until active.
 * ------------------------------------------------------------------------- */
.smya-tabs__tab .smya-tabs__label-text {
	opacity: 0;
	transform: translateY(0.5rem);
	transition: opacity 0.25s ease, transform 0.25s ease;
	visibility: hidden;
}

.smya-tabs__tab.is-active .smya-tabs__label-text {
	opacity: 1;
	transform: translateY(0);
	visibility: visible;
}

/* -------------------------------------------------------------------------
 * Accordion trigger (mobile – revealed via inline media query)
 * ------------------------------------------------------------------------- */
.smya-tabs__accordion-trigger {
	align-items: center;
	appearance: none;
	background: transparent;
	border: 0;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	color: inherit;
	cursor: pointer;
	display: none;
	font: inherit;
	justify-content: space-between;
	padding: 0.875rem 1rem;
	position: relative;
	text-align: left;
	width: 100%;
}

.smya-tabs__accordion-trigger--has-image {
	border-top: 0;
	padding: 1rem;
}

.smya-tabs__accordion-trigger::after {
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	content: "";
	display: inline-block;
	height: 0.5rem;
	margin-left: 0.75rem;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
	width: 0.5rem;
}

.smya-tabs__accordion-trigger--has-image::after {
	position: absolute;
	right: 1rem;
	top: 50%;
	transform: translateY(-50%) rotate(45deg);
	z-index: 2;
}

.smya-tabs__accordion-trigger.is-active::after {
	transform: rotate(-135deg);
}

.smya-tabs__accordion-trigger--has-image.is-active::after {
	transform: translateY(-50%) rotate(-135deg);
}

.smya-tabs__panel + .smya-tabs__panel .smya-tabs__accordion-trigger:not(.smya-tabs__accordion-trigger--has-image) {
	margin-top: 0;
}

/* -------------------------------------------------------------------------
 * Labels (shared by tabs + accordion triggers)
 * ------------------------------------------------------------------------- */
.smya-tabs__label {
	align-items: center;
	display: inline-flex;
	gap: 0.5rem;
}

.smya-tabs__label-text {
	display: inline-flex;
	flex-direction: column;
	text-align: left;
}

.smya-tabs__title {
	font-weight: 600;
}

/* -------------------------------------------------------------------------
 * Panels
 * ------------------------------------------------------------------------- */
.smya-tabs__panels {
	background-color: var(--smya-body-bg);
	border: var(--smya-body-border);
	border-radius: var(--smya-body-radius);
	display: block;
	margin-top: var(--smya-tab-gap);
	padding: var(--smya-body-padding);
	position: relative;
}

/* -------------------------------------------------------------------------
 * Active-tab arrow
 *
 * Horizontally centered on the active tab via `--smya-arrow-x`.
 * The bottom of the arrow box aligns with the top of the panels’
 * positioning box (`top: 0` + translateY(-100%)).
 *
 * The white strip (::before) hides the body border where the arrow meets
 * the panel edge.
 * ------------------------------------------------------------------------- */
.smya-tabs__arrow {
	background-color: #fff;
	background-position: center bottom;
	background-repeat: no-repeat;
	background-size: contain;
	height: var(--smya-arrow-size);
	left: var(--smya-arrow-x, 50%);
	pointer-events: none;
	position: absolute;
	top: 0;
	transform: translate(-50%, -100%);
	transition: left 0.25s ease;
	width: var(--smya-arrow-size);
	z-index: 2;
}

.smya-tabs__arrow::before {
	background-color: var(--smya-body-bg);
	bottom: 0;
	content: "";
	height: 2px;
	left: 0;
	position: absolute;
	right: 0;
	transform: translateY(100%);
	z-index: -1;
}

.smya-tabs__panels--has-arrow {
	/* Tablist gap + full arrow height so the arrow sits above the panel top. */
	margin-top: calc(var(--smya-tab-gap) + var(--smya-arrow-size));
}

.smya-tabs__panel {
	display: none;
}

.smya-tabs__panel.is-active {
	display: block;
}

.smya-tabs__panel[hidden] {
	display: none;
}

.smya-tabs__panel-inner {
	padding: 0;
}

.smya-tabs__body {
	color: var(--smya-tab-content-color, #333333);
}

.smya-tabs__body > :first-child {
	margin-top: 0;
}

.smya-tabs__body > :last-child {
	margin-bottom: 0;
}

