/*
 * Take My Quiz – frontend-styling.
 * Alt er innkapslet under .tmq-quiz og styrt av --tmq-*-variabler, slik at
 * Elementor-widgeten (fase 9) kan overstyre uten å røre denne filen.
 * Fallback-designet er bevisst nøytralt – ikke et endelig design.
 */

.tmq-quiz {
	/* Godkjente fallback-verdier (CLAUDE.md, designvalg 2026-07-04). */
	--tmq-bg: #f6f7f9;
	--tmq-surface: #ffffff;
	--tmq-text: #1f2933;
	--tmq-accent: #3b6ea5;
	--tmq-accent-text: #ffffff;
	--tmq-border: #d4d9e0;
	--tmq-radius: 8px;
	--tmq-gap: 16px;
	--tmq-section-gap: 24px;
	--tmq-max-width: 720px;
	--tmq-gold: #d4a943;
	--tmq-silver: #9aa5b1;
	--tmq-bronze: #b0713f;
	--tmq-podium-text: #ffffff;
	--tmq-error: #b3261e;
	--tmq-min-height: 620px;

	background: var( --tmq-bg );
	border-radius: var( --tmq-radius );
	box-sizing: border-box;
	color: var( --tmq-text );
	/* Stabil vindushøyde på alle skjermer: quizen hopper ikke i størrelse
	   mellom start-, spørsmåls- og resultatskjermen. Kortere innhold
	   midtstilles; høyere innhold får vokse (kuttes aldri). */
	display: flex;
	flex-direction: column;
	/* Fonten arves fra temaet – ingen egen font. */
	font-family: inherit;
	justify-content: center;
	margin: 0 auto;
	/* Aldri bredere enn siden/kolonnen quizen ligger i, uansett hva
	   maks bredde-innstillingen sier. */
	max-width: min( var( --tmq-max-width ), 100% );
	min-height: var( --tmq-min-height );
	padding: var( --tmq-section-gap );
}

.tmq-quiz *,
.tmq-quiz *::before,
.tmq-quiz *::after {
	box-sizing: inherit;
}

.tmq-quiz .tmq-screen {
	margin: 0;
	width: 100%;
}

/* ------------------------------------------------------------------ *
 * Startskjermen
 * ------------------------------------------------------------------ */

.tmq-quiz .tmq-screen--start {
	text-align: center;
}

.tmq-quiz .tmq-welcome-text {
	line-height: 1.6;
	margin: 0 auto var( --tmq-section-gap );
	max-width: 56ch;
	overflow-wrap: break-word;
}

.tmq-quiz .tmq-button,
.tmq-quiz .tmq-start-button {
	background: var( --tmq-accent );
	border: 0;
	border-radius: var( --tmq-radius );
	color: var( --tmq-accent-text );
	cursor: pointer;
	display: inline-block;
	font-family: inherit;
	font-size: 1.1em;
	font-weight: 700;
	letter-spacing: 0.04em;
	padding: 14px 40px;
	transition: filter 0.15s ease, transform 0.15s ease;
}

.tmq-quiz .tmq-button:hover {
	filter: brightness( 1.1 );
}

.tmq-quiz .tmq-button:focus-visible {
	outline: 3px solid var( --tmq-accent );
	outline-offset: 3px;
}

/* ------------------------------------------------------------------ *
 * Spørsmålsskjermen
 * ------------------------------------------------------------------ */

.tmq-quiz .tmq-progress {
	background: var( --tmq-border );
	border-radius: 999px;
	height: 8px;
	overflow: hidden;
}

.tmq-quiz .tmq-progress-bar {
	background: var( --tmq-accent );
	border-radius: 999px;
	height: 100%;
	transition: width 0.3s ease;
	width: 0;
}

.tmq-quiz .tmq-progress-label {
	font-size: 0.85em;
	margin: 8px 0 var( --tmq-section-gap );
	opacity: 0.75;
}

.tmq-quiz .tmq-question-text {
	color: var( --tmq-text );
	font-size: 1.4em;
	line-height: 1.35;
	margin: 0 0 var( --tmq-section-gap );
	outline: none;
}

.tmq-quiz .tmq-answer-grid {
	display: grid;
	gap: var( --tmq-gap );
	/* Alltid 2×2 – også på mobil (prosjektplan 6.2). minmax(0, 1fr) hindrer
	   at lange tekster presser kolonnene bredere enn containeren. */
	grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
}

.tmq-quiz .tmq-answer {
	background: var( --tmq-surface );
	border: 1px solid var( --tmq-border );
	border-radius: var( --tmq-radius );
	color: var( --tmq-text );
	cursor: pointer;
	font-family: inherit;
	font-size: 1em;
	line-height: 1.4;
	min-height: 80px;
	min-width: 0;
	padding: 18px 16px;
	text-align: center;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
	/* Temaer/Elementor setter ofte nowrap på knapper – teksten SKAL brytes
	   over flere linjer inne i boksen. */
	white-space: normal;
	word-break: break-word;
}

.tmq-quiz .tmq-answer:hover {
	border-color: var( --tmq-accent );
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.08 );
	transform: translateY( -1px );
}

.tmq-quiz .tmq-answer:focus-visible {
	border-color: var( --tmq-accent );
	outline: 3px solid var( --tmq-accent );
	outline-offset: 2px;
}

.tmq-quiz .tmq-answer--selected {
	border-color: var( --tmq-accent );
	box-shadow: inset 0 0 0 2px var( --tmq-accent );
}

.tmq-quiz .tmq-back-button {
	background: none;
	border: 0;
	color: var( --tmq-accent );
	cursor: pointer;
	display: block;
	font-family: inherit;
	font-size: 0.95em;
	margin-top: var( --tmq-section-gap );
	padding: 8px 0;
	text-decoration: underline;
}

.tmq-quiz .tmq-back-button:focus-visible {
	outline: 3px solid var( --tmq-accent );
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Resultatskjermen (lasteanimasjon i fase 6; podium kommer i fase 8)
 * ------------------------------------------------------------------ */

.tmq-quiz .tmq-loading {
	padding: var( --tmq-section-gap ) 0;
	text-align: center;
}

.tmq-quiz .tmq-spinner {
	animation: tmq-spin 0.9s linear infinite;
	border: 4px solid var( --tmq-border );
	border-radius: 50%;
	border-top-color: var( --tmq-accent );
	display: inline-block;
	height: 40px;
	width: 40px;
}

@keyframes tmq-spin {
	to {
		transform: rotate( 360deg );
	}
}

.tmq-quiz .tmq-loading-text {
	margin: var( --tmq-gap ) 0 0;
}

.tmq-quiz .tmq-result-content {
	text-align: center;
}

.tmq-quiz .tmq-result-title {
	font-size: 1.4em;
	margin: 0 0 8px;
}

.tmq-quiz .tmq-result-notice {
	background: var( --tmq-surface );
	border: 1px solid var( --tmq-border );
	border-radius: var( --tmq-radius );
	font-size: 0.9em;
	margin: 0 auto var( --tmq-gap );
	max-width: 56ch;
	padding: 10px 14px;
}

.tmq-quiz .tmq-result-intro {
	line-height: 1.6;
	margin: 0 auto var( --tmq-gap );
	max-width: 56ch;
	overflow-wrap: break-word;
	white-space: pre-line;
}

/* ------------------------------------------------------------------ *
 * Podium (fase 8): 3. plass venstre, 1. plass høyest i midten, 2. høyre.
 * Horisontal også på mobil – skaleres ned, stables aldri.
 * ------------------------------------------------------------------ */

.tmq-quiz .tmq-podium {
	align-items: flex-end;
	display: flex;
	gap: var( --tmq-gap );
	justify-content: center;
	margin: var( --tmq-section-gap ) 0;
	min-height: 380px;
	position: relative;
}

.tmq-quiz .tmq-confetti {
	height: 100%;
	left: 0;
	pointer-events: none;
	position: absolute;
	top: 0;
	width: 100%;
	z-index: 0;
}

.tmq-quiz .tmq-podium-slot {
	align-items: center;
	display: flex;
	flex: 0 1 160px;
	flex-direction: column;
	justify-content: flex-end;
	min-width: 0;
	opacity: 0;
	position: relative;
	transform: translateY( 40px );
	transition: opacity 0.3s ease, transform 0.5s cubic-bezier( 0.34, 1.56, 0.64, 1 );
	z-index: 1;
}

.tmq-quiz .tmq-podium-slot--shown {
	opacity: 1;
	transform: none;
}

.tmq-quiz .tmq-podium-name {
	font-weight: 700;
	margin-bottom: 8px;
	text-align: center;
	word-break: break-word;
}

.tmq-quiz .tmq-podium-bar {
	align-items: center;
	border-radius: var( --tmq-radius ) var( --tmq-radius ) 0 0;
	color: var( --tmq-podium-text );
	display: flex;
	height: 0;
	justify-content: center;
	overflow: hidden;
	transition: height 0.5s cubic-bezier( 0.34, 1.56, 0.64, 1 );
	width: 100%;
}

.tmq-quiz .tmq-podium-placement {
	font-size: 1.8em;
	font-weight: 800;
	text-shadow: 0 1px 2px rgba( 0, 0, 0, 0.25 );
}

.tmq-quiz .tmq-podium-bar--1 {
	background: var( --tmq-gold );
}

.tmq-quiz .tmq-podium-bar--2 {
	background: var( --tmq-silver );
}

.tmq-quiz .tmq-podium-bar--3 {
	background: var( --tmq-bronze );
}

/* Høyere, mer avlange søyler med tydelig størrelsesforskjell 1 > 2 > 3. */
.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--1 {
	height: 260px;
}

.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--2 {
	height: 190px;
}

.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--3 {
	height: 130px;
}

.tmq-quiz .tmq-podium-link {
	font-size: 0.85em;
	margin-top: 10px;
	padding: 8px 18px;
	text-decoration: none;
}

.tmq-quiz .tmq-restart-button {
	font-size: 1em;
	opacity: 0;
	padding: 12px 32px;
	transition: opacity 0.3s ease;
	visibility: hidden;
}

.tmq-quiz .tmq-restart-button--visible {
	opacity: 1;
	visibility: visible;
}

.tmq-quiz .tmq-result-error {
	color: var( --tmq-error );
	font-weight: 600;
	margin: 0 0 var( --tmq-gap );
}

.tmq-quiz .tmq-retry-button {
	font-size: 1em;
	padding: 10px 28px;
}

/* ------------------------------------------------------------------ *
 * Lead-skjermen (valgfritt navn/e-post før resultatet)
 * ------------------------------------------------------------------ */

.tmq-quiz .tmq-screen--lead {
	margin: 0 auto;
	max-width: 420px;
	text-align: center;
}

.tmq-quiz .tmq-lead-title {
	font-size: 1.4em;
	margin: 0 0 8px;
	outline: none;
}

.tmq-quiz .tmq-lead-intro {
	margin: 0 0 var( --tmq-section-gap );
}

/* Honeypot: flyttes ut av syne, ikke display:none (enkelte bots hopper over det). */
.tmq-quiz .tmq-hp-field {
	left: -9999px;
	position: absolute;
	top: auto;
}

.tmq-quiz .tmq-lead-label {
	display: block;
	font-weight: 600;
	text-align: left;
}

.tmq-quiz .tmq-lead-label input {
	background: var( --tmq-surface );
	border: 1px solid var( --tmq-border );
	border-radius: var( --tmq-radius );
	color: var( --tmq-text );
	display: block;
	font-family: inherit;
	font-size: 1em;
	margin-top: 4px;
	padding: 10px 12px;
	width: 100%;
}

.tmq-quiz .tmq-lead-label input:focus-visible {
	border-color: var( --tmq-accent );
	outline: 3px solid var( --tmq-accent );
	outline-offset: 1px;
}

.tmq-quiz .tmq-lead-error {
	color: var( --tmq-error );
	font-weight: 600;
}

.tmq-quiz .tmq-lead-buttons {
	align-items: center;
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: var( --tmq-gap );
}

.tmq-quiz .tmq-lead-submit {
	font-size: 1em;
	padding: 12px 32px;
}

.tmq-quiz .tmq-lead-skip {
	background: none;
	border: 0;
	color: var( --tmq-accent );
	cursor: pointer;
	font-family: inherit;
	font-size: 0.95em;
	padding: 6px;
	text-decoration: underline;
}

.tmq-quiz .tmq-lead-skip:focus-visible {
	outline: 3px solid var( --tmq-accent );
	outline-offset: 2px;
}

/* Hjelpetekst i Elementor-editoren når ingen quiz er valgt. */
.tmq-widget-placeholder {
	background: #f6f7f9;
	border: 1px dashed #d4d9e0;
	border-radius: 8px;
	color: #1f2933;
	padding: 24px;
	text-align: center;
}

/* ------------------------------------------------------------------ *
 * Mindre skjermer og redusert bevegelse
 * ------------------------------------------------------------------ */

@media ( max-width: 480px ) {
	/*
	 * På mobil styres den stabile vindusstørrelsen av et fast bredde/høyde-
	 * forhold (fra Henriks iPhone-utsnitt 1090×1570, høyde ≈ 1,44 × bredde)
	 * i stedet for basens min-height. VIKTIG: min-height må være `auto` (IKKE
	 * 0) – ratio-høyden på en boks med auto høyde virker gjennom nettopp den
	 * automatiske minimumsstørrelsen, så `0` slår den av og høyden kollapser
	 * til innholdet. Flex-sentreringen arves fra basen.
	 */
	.tmq-quiz {
		aspect-ratio: 1090 / 1570;
		min-height: auto;
		padding: var( --tmq-gap );
	}

	.tmq-quiz .tmq-question-text {
		font-size: 1.2em;
	}

	.tmq-quiz .tmq-answer {
		font-size: 0.9em;
		/* Høye bokser med rom for tekst over 2–4 linjer. */
		min-height: 104px;
		padding: 12px 10px;
	}

	/* Pallen forblir horisontal på mobil – kun skalert ned (plan 6.3). */
	.tmq-quiz .tmq-podium {
		gap: 8px;
		min-height: 270px;
	}

	.tmq-quiz .tmq-podium-slot {
		flex-basis: 32%;
	}

	.tmq-quiz .tmq-podium-name {
		font-size: 0.8em;
	}

	.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--1 {
		height: 170px;
	}

	.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--2 {
		height: 125px;
	}

	.tmq-quiz .tmq-podium-slot--shown .tmq-podium-bar--3 {
		height: 90px;
	}

	.tmq-quiz .tmq-podium-placement {
		font-size: 1.4em;
	}

	.tmq-quiz .tmq-podium-link {
		font-size: 0.75em;
		padding: 6px 12px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.tmq-quiz *,
	.tmq-quiz *::before,
	.tmq-quiz *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
