/*
 * faq.css — S8, audience tabs over an accordion.
 *
 * Written no-JS-first: every panel shows and every answer is readable until
 * faq.js takes over. Only then do the tabs start hiding panels.
 */

.faq__head {
	max-width: 44rem;
	margin-bottom: var(--s-12);
}

.faq__title {
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--fs-h2);
	font-weight: 500;
	line-height: var(--lh-heading);
	text-wrap: balance;
}

.faq__tablist {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-2);
	margin-bottom: var(--s-8);
}

.faq__tab {
	min-height: 44px;
	padding: var(--s-2) var(--s-6);
	background: transparent;
	border: 1px solid var(--line);
	border-radius: var(--radius-pill);
	font-family: var(--font-body);
	font-size: var(--fs-body);
	font-weight: 600;
	color: var(--muted);
	cursor: pointer;
	transition:
		background-color var(--dur-fast) var(--ease),
		border-color var(--dur-fast) var(--ease),
		color var(--dur-fast) var(--ease);
}

.faq__tab:hover {
	color: var(--ink);
	border-color: var(--ink);
}

.faq__tab[aria-selected="true"] {
	background: var(--koivu);
	border-color: var(--koivu);
	color: #fff;
}

/* JS hides the inactive panels; without it they simply stack. */
.faq__panel[hidden] {
	display: none;
}

.faq__item {
	border-bottom: 1px solid var(--line);
}

.faq__item:first-child {
	border-top: 1px solid var(--line);
}

.faq__question {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--s-6);
	padding-block: var(--s-6);
	font-family: var(--font-display);
	font-size: clamp(1.125rem, 1.6vw, 1.375rem);
	line-height: var(--lh-heading);
	cursor: pointer;
	list-style: none;
	transition: color var(--dur-fast) var(--ease);
}

.faq__question::-webkit-details-marker {
	display: none;
}

.faq__question:hover {
	color: var(--koivu-dark);
}

.faq__chevron {
	flex-shrink: 0;
	color: var(--koivu);
	transition: transform var(--dur-fast) var(--ease);
}

.faq__item[open] .faq__chevron {
	transform: rotate(180deg);
}

.faq__answer {
	padding-bottom: var(--s-6);
	max-width: 68ch;
	color: var(--text-muted);
}

.faq__answer p {
	margin: 0;
}

/* The open transition: content slides down instead of snapping. */
@media (prefers-reduced-motion: no-preference) {
	.faq__item[open] .faq__answer {
		animation: faqOpen var(--dur-fast) var(--ease);
	}

	@keyframes faqOpen {
		from { opacity: 0; transform: translateY(-6px); }
		to { opacity: 1; transform: none; }
	}
}

.faq__all {
	margin: var(--s-12) 0 0;
	max-width: none;
}

/*
 * The birch leaf (brief 04 §2): replaces the idea of a static line next to the
 * open question with the logo's own leaf mark, sitting in the left gutter and
 * dropping to whichever question is open. One shared element per list/panel —
 * faq-leaf.js moves it, it never appears without JS. Needs room to the left,
 * so it only shows once the container is wide enough to have a real gutter.
 */
.faq__list,
.faq__panel {
	position: relative;
}

.faq__leaf {
	display: none;
}

@media (min-width: 1024px) {
	.faq__leaf {
		display: block;
		position: absolute;
		top: 0;
		left: -2rem;
		width: 20px;
		height: auto;
		opacity: 0;
		pointer-events: none;
		transform: translateY(0) rotate(-10deg);
		transition: opacity var(--dur-fast) var(--ease);
	}

	.faq__leaf.is-active {
		opacity: 1;
	}

	@media (prefers-reduced-motion: no-preference) {
		.faq__leaf {
			transition:
				transform 0.5s var(--ease),
				opacity var(--dur-fast) var(--ease);
		}
	}
}

/* ---- The Usein kysytyt PAGE: tab rail left, answers right ----
 *
 * Scoped to .faq--page so the homepage preview keeps its horizontal pills.
 * No-JS still works: without faq.js every panel is visible and they simply
 * stack in the right-hand column.
 */

/* The rail CTA exists only on the page, and only earns its place on wide
   screens — below that the closing CTA band already covers it. */
.faq-rail-cta {
	display: none;
}

@media (min-width: 1024px) {
	.faq--page .faq__tabs {
		display: grid;
		grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
		column-gap: clamp(var(--s-12), 5vw, var(--s-24));
	}

	/* The rail sticks under the fixed header while the answers scroll. */
	.faq--page .faq__rail {
		grid-column: 1;
		grid-row: 1 / span 9;
		align-self: start;
		position: sticky;
		top: calc(104px + var(--s-8));
	}

	.faq--page .faq__panel {
		grid-column: 2;
	}

	/* Pills become a quiet vertical list with a hairline spine. */
	.faq--page .faq__tablist {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		border-left: 1px solid var(--line);
	}

	.faq--page .faq__tab {
		min-height: 0;
		padding: var(--s-3) 0 var(--s-3) var(--s-6);
		background: none;
		border: 0;
		border-left: 2px solid transparent;
		border-radius: 0;
		margin-left: -1px; /* the 2px marker sits ON the hairline spine */
		text-align: left;
		font-family: var(--font-display);
		font-size: 1.25rem;
		font-weight: 500;
		color: var(--muted);
	}

	.faq--page .faq__tab:hover {
		color: var(--ink);
		border-color: transparent;
		border-left-color: var(--line);
	}

	.faq--page .faq__tab[aria-selected="true"] {
		background: none;
		border-color: transparent;
		border-left-color: var(--koivu);
		color: var(--ink);
	}

	.faq--page .faq-rail-cta {
		display: block;
		margin-top: var(--s-12);
		padding: var(--s-6);
		background: var(--bg-alt);
		border-radius: var(--radius);
	}

	.faq-rail-cta__title {
		margin: 0 0 var(--s-2);
		font-family: var(--font-display);
		font-size: 1.25rem;
		font-weight: 500;
	}

	.faq-rail-cta__text {
		margin: 0 0 var(--s-4);
		font-size: var(--fs-small);
		color: var(--text-muted);
	}

	.faq-rail-cta__actions {
		margin: 0;
	}
}
