/**
 * Tundra Guardrails Video Gate.
 *
 * Two scopes, not one.
 *
 * #tundra-guardrails is the block as it sits on the page. #tgg-portal is a bare
 * host appended to <body> on load, which the dialog is moved into — see the long
 * comment in tgg.js for why. Both scopes need the same variables and the same
 * component rules, so every selector is written :is(#tundra-guardrails, #tgg-portal).
 *
 * :is() takes the specificity of its most specific argument, so these rules keep
 * the (1,1,0) they had when they were plain id-scoped selectors. That matters:
 * Divi ships id-scoped rules for inputs and buttons, and dropping to class-only
 * specificity would hand it the cascade.
 */

#tundra-guardrails.tgg,
#tgg-portal {
	--tgg-ink: #12232e;
	--tgg-muted: #6b7780;
	--tgg-line: #dfe4e7;
	--tgg-accent: #0b3c5d;
	--tgg-accent-dark: #082a41;
	--tgg-bg: #f7f9fa;

	color: var(--tgg-ink);
}

#tundra-guardrails.tgg {
	max-width: 900px;
	margin: 0 auto;
	padding: 8px 0 4px;
}

/* The host is a hook, not a box: it must never occupy space in the page flow. */
#tgg-portal {
	margin: 0;
	padding: 0;
	border: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__head {
	margin-bottom: 20px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__title {
	margin: 0 0 8px;
	font-size: 28px;
	line-height: 1.25;
	color: var(--tgg-ink);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__lede {
	margin: 0;
	font-size: 16px;
	line-height: 1.6;
	color: var(--tgg-muted);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__h3 {
	margin: 0 0 10px;
	font-size: 20px;
	line-height: 1.3;
	color: var(--tgg-ink);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__copy {
	margin: 0 0 18px;
	font-size: 15px;
	line-height: 1.65;
	color: #33444f;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__muted {
	color: var(--tgg-muted);
	font-size: 15px;
	margin: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__fine {
	margin: 14px 0 0;
	font-size: 13px;
	line-height: 1.6;
	color: var(--tgg-muted);
}

/* --- players ---------------------------------------------------------- */

:is(#tundra-guardrails, #tgg-portal) .tgg__player {
	position: relative;
	background: #000;
	border-radius: 6px;
	overflow: hidden;
	line-height: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__video {
	display: block;
	width: 100%;
	height: auto;
	max-height: 70vh;
	background: #000;
}

/* --- gate panels ------------------------------------------------------ */

:is(#tundra-guardrails, #tgg-portal) .tgg__gate {
	margin-top: 22px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__panel {
	background: var(--tgg-bg);
	border: 1px solid var(--tgg-line);
	border-radius: 6px;
	padding: 26px 26px 28px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__panel[hidden] {
	display: none;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__panel--status {
	border-left: 4px solid var(--tgg-accent);
}

:is(#tundra-guardrails, #tgg-portal)[data-state="approved"] .tgg__panel {
	background: transparent;
	border: 0;
	padding: 0;
}

/* --- modal ------------------------------------------------------------ */

:is(#tundra-guardrails, #tgg-portal) .tgg__modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px 16px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__modal[hidden] {
	display: none;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 10, 20, 27, 0.62 );
	animation: tgg-fade 0.18s ease-out;
}

/*
 * Height is capped against the small viewport unit where it is supported, so a
 * phone's collapsing address bar cannot push the submit button off the bottom.
 * The 100vh line above it stays as the fallback for anything that predates svh.
 */
:is(#tundra-guardrails, #tgg-portal) .tgg__modal__box {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: calc( 100vh - 48px );
	max-height: calc( 100svh - 48px );
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 24px 60px rgba( 10, 20, 27, 0.34 );
	animation: tgg-rise 0.2s ease-out;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__modal__box .tgg__panel {
	background: transparent;
	border: 0;
	border-radius: 0;
	padding: 34px 34px 32px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__modal__close {
	position: absolute;
	top: 8px;
	right: 10px;
	z-index: 2;
	width: 38px;
	height: 38px;
	padding: 0;
	font-size: 26px;
	line-height: 1;
	color: var(--tgg-muted);
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__modal__close:hover,
:is(#tundra-guardrails, #tgg-portal) .tgg__modal__close:focus {
	color: var(--tgg-ink);
	background: #f0f2f4;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__copy--lead {
	font-size: 16px;
	line-height: 1.6;
	color: var(--tgg-ink);
	padding-right: 28px;
}

@keyframes tgg-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes tgg-rise {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: none; }
}

/* Locks background scrolling while the dialog is open. */
body.tgg-modal-open {
	overflow: hidden;
}

/* --- forms ------------------------------------------------------------ */

:is(#tundra-guardrails, #tgg-portal) .tgg__form {
	margin: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__form--grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px 18px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__field {
	margin-bottom: 14px;
	min-width: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__form--grid .tgg__field {
	margin-bottom: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__field--wide {
	grid-column: 1 / -1;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__field label {
	display: block;
	margin-bottom: 5px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--tgg-ink);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__field input,
:is(#tundra-guardrails, #tgg-portal) .tgg__field select,
:is(#tundra-guardrails, #tgg-portal) .tgg__field textarea {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	padding: 11px 13px;
	font-size: 15px;
	font-family: inherit;
	line-height: 1.4;
	color: var(--tgg-ink);
	background: #fff;
	border: 1px solid #c8d0d5;
	border-radius: 4px;
	box-shadow: none;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__field input:focus,
:is(#tundra-guardrails, #tgg-portal) .tgg__field select:focus,
:is(#tundra-guardrails, #tgg-portal) .tgg__field textarea:focus {
	outline: none;
	border-color: var(--tgg-accent);
	box-shadow: 0 0 0 3px rgba( 11, 60, 93, 0.14 );
}

:is(#tundra-guardrails, #tgg-portal) .tgg__code {
	max-width: 220px;
	font-size: 26px;
	letter-spacing: 0.32em;
	text-align: center;
	font-family: Menlo, Consolas, monospace;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* --- buttons ---------------------------------------------------------- */

:is(#tundra-guardrails, #tgg-portal) .tgg__btn {
	display: inline-block;
	margin: 4px 10px 0 0;
	padding: 13px 26px;
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.2;
	color: #fff;
	background: var(--tgg-accent);
	border: 0;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.15s ease;
	text-decoration: none;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn:hover,
:is(#tundra-guardrails, #tgg-portal) .tgg__btn:focus {
	background: var(--tgg-accent-dark);
	color: #fff;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn[disabled] {
	opacity: 0.6;
	cursor: default;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__panel--cta {
	text-align: center;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__panel--cta .tgg__copy {
	max-width: 560px;
	margin-left: auto;
	margin-right: auto;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn--lg {
	margin-top: 6px;
	padding: 16px 38px;
	font-size: 17px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn--ghost {
	color: var(--tgg-accent);
	background: transparent;
	border: 1px solid var(--tgg-accent);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn--ghost:hover {
	color: #fff;
	background: var(--tgg-accent);
}

/* "Would you like to learn more?" — shown when the presentation finishes. */
:is(#tundra-guardrails, #tgg-portal) .tgg__ask {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid #e3e6e8;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__ask-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 10px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__ask-buttons .tgg__btn {
	margin: 0;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__btn.is-chosen {
	background: var(--tgg-accent-dark);
	box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--tgg-accent-dark);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__ask-thanks {
	margin: 12px 0 0;
	font-weight: 600;
	color: var(--tgg-accent);
}

:is(#tundra-guardrails, #tgg-portal) .tgg__link {
	margin: 4px 14px 0 0;
	padding: 0;
	font-size: 14px;
	font-family: inherit;
	color: var(--tgg-accent);
	background: none;
	border: 0;
	cursor: pointer;
	text-decoration: underline;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__link[disabled] {
	opacity: 0.5;
	cursor: default;
}

/* --- messages --------------------------------------------------------- */

:is(#tundra-guardrails, #tgg-portal) .tgg__error {
	margin: 12px 0 0;
	padding: 10px 13px;
	font-size: 14px;
	line-height: 1.5;
	color: #7d2626;
	background: #fdf1f1;
	border: 1px solid #f0cfcf;
	border-radius: 4px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__error[hidden] {
	display: none;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__notice {
	margin: 16px 0;
	padding: 14px 16px;
	font-size: 14px;
	border-radius: 4px;
}

:is(#tundra-guardrails, #tgg-portal) .tgg__notice--warn {
	color: #7a5b12;
	background: #fdf7e6;
	border: 1px solid #efe0b5;
}

/* --- small screens ---------------------------------------------------- */

@media ( max-width: 620px ) {
	:is(#tundra-guardrails, #tgg-portal) .tgg__title { font-size: 23px; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__panel { padding: 20px 18px 22px; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__form--grid { grid-template-columns: 1fr; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__btn { width: 100%; margin-right: 0; text-align: center; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__code { max-width: 100%; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__modal { padding: 12px 10px; }
	:is(#tundra-guardrails, #tgg-portal) .tgg__modal__box .tgg__panel { padding: 30px 20px 24px; }
}
