/*
 * YouTube Creator Toolkit — shared base styles.
 * Loaded on every page that has at least one ytk_* shortcode.
 * No frameworks, no external fonts — system font stack only.
 */

.ytk-tool {
	/* --ytk-accent is intentionally NOT set here. It cascades down from
	   :root (written by YTK_Assets::print_instance_style_overrides() based
	   on the Settings → YouTube Toolkit accent color), or from an inline
	   style="--ytk-accent:...” on this element when a shortcode sets its
	   own accent="" attribute. Every var(--ytk-accent) usage below carries
	   its own #0e9594 fallback in case neither of those is present. */
	--ytk-accent-ink: #ffffff;
	--ytk-bg: #ffffff;
	--ytk-surface: #f6f7f8;
	--ytk-surface-hover: #eef0f2;
	--ytk-border: #e3e6e8;
	--ytk-text: #16181d;
	--ytk-text-muted: #5c636b;
	--ytk-success: #0a8a3f;
	--ytk-success-bg: #eaf7ef;
	--ytk-danger: #c9382b;
	--ytk-danger-bg: #fbebe9;
	--ytk-warning: #a8660a;
	--ytk-warning-bg: #fdf2e2;
	--ytk-radius: 14px;
	--ytk-radius-sm: 8px;
	--ytk-shadow: 0 1px 2px rgba(16, 18, 20, 0.06), 0 8px 24px rgba(16, 18, 20, 0.06);
	--ytk-focus-ring: 0 0 0 3px rgba(14, 149, 148, 0.35);
	--ytk-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ytk-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	box-sizing: border-box;
	max-width: 780px;
	margin: 1.5em 0;
	padding: 28px;
	background: var(--ytk-bg);
	color: var(--ytk-text);
	border: 1px solid var(--ytk-border);
	border-radius: var(--ytk-radius);
	box-shadow: var(--ytk-shadow);
	font-family: var(--ytk-font);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

.ytk-tool[data-ytk-theme="dark"] {
	--ytk-bg: #16181d;
	--ytk-surface: #1f2228;
	--ytk-surface-hover: #282c33;
	--ytk-border: #2e323a;
	--ytk-text: #edeff2;
	--ytk-text-muted: #9aa1ab;
	--ytk-success: #3fcb7b;
	--ytk-success-bg: rgba(63, 203, 123, 0.12);
	--ytk-danger: #f0685a;
	--ytk-danger-bg: rgba(240, 104, 90, 0.14);
	--ytk-warning: #e0a232;
	--ytk-warning-bg: rgba(224, 162, 50, 0.14);
	--ytk-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
	.ytk-tool[data-ytk-theme="auto"] {
		--ytk-bg: #16181d;
		--ytk-surface: #1f2228;
		--ytk-surface-hover: #282c33;
		--ytk-border: #2e323a;
		--ytk-text: #edeff2;
		--ytk-text-muted: #9aa1ab;
		--ytk-success: #3fcb7b;
		--ytk-success-bg: rgba(63, 203, 123, 0.12);
		--ytk-danger: #f0685a;
		--ytk-danger-bg: rgba(240, 104, 90, 0.14);
		--ytk-warning: #e0a232;
		--ytk-warning-bg: rgba(224, 162, 50, 0.14);
		--ytk-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
	}
}

.ytk-tool *,
.ytk-tool *::before,
.ytk-tool *::after {
	box-sizing: inherit;
}

/*
 * The browser's built-in [hidden]{display:none} rule has low specificity,
 * so any of our own classes that set `display` (.ytk-grid, .ytk-row,
 * .ytk-badge, .ytk-tabs, .ytk-checkbox-row, etc.) will silently win the
 * cascade and keep a "hidden" element visible — e.g. a loading skeleton
 * stuck on screen forever. This rule guarantees [hidden] always wins
 * inside a tool, regardless of what other classes are on the element.
 */
.ytk-tool [hidden] {
	display: none !important;
}

.ytk-tool__title {
	margin: 0 0 20px;
	font-size: 1.35em;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.ytk-tool__credit {
	margin: 20px 0 0;
	font-size: 0.8em;
	color: var(--ytk-text-muted);
	text-align: center;
}

.ytk-tool__credit a {
	color: inherit;
}

/* ---------- Layout helpers ---------- */

.ytk-field {
	margin-bottom: 16px;
}

.ytk-row {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.ytk-row > * {
	flex: 1 1 200px;
}

.ytk-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 16px;
}

/* ---------- Form elements ---------- */

.ytk-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
	font-size: 0.9em;
}

.ytk-help-text {
	margin: 6px 0 0;
	font-size: 0.85em;
	color: var(--ytk-text-muted);
}

.ytk-input,
.ytk-select,
.ytk-textarea {
	display: block;
	width: 100%;
	padding: 12px 14px;
	font-family: inherit;
	font-size: 1em;
	color: var(--ytk-text);
	background: var(--ytk-bg);
	border: 1.5px solid var(--ytk-border);
	border-radius: var(--ytk-radius-sm);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	min-height: 44px;
}

.ytk-textarea {
	min-height: 96px;
	resize: vertical;
	font-family: var(--ytk-font-mono);
	font-size: 0.92em;
}

.ytk-input:focus,
.ytk-select:focus,
.ytk-textarea:focus {
	outline: none;
	border-color: var(--ytk-accent, #0e9594);
	box-shadow: var(--ytk-focus-ring);
}

.ytk-input--error {
	border-color: var(--ytk-danger);
}

.ytk-checkbox-row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
}

.ytk-checkbox-row input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--ytk-accent, #0e9594);
}

fieldset.ytk-fieldset {
	margin: 0 0 16px;
	padding: 14px 16px;
	border: 1.5px solid var(--ytk-border);
	border-radius: var(--ytk-radius-sm);
}

fieldset.ytk-fieldset legend {
	padding: 0 6px;
	font-weight: 600;
	font-size: 0.9em;
}

/* ---------- Buttons ---------- */

.ytk-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 10px 18px;
	font-family: inherit;
	font-size: 0.95em;
	font-weight: 600;
	color: var(--ytk-text);
	background: var(--ytk-surface);
	border: 1.5px solid var(--ytk-border);
	border-radius: var(--ytk-radius-sm);
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
	text-decoration: none;
	line-height: 1.2;
}

.ytk-btn:hover {
	background: var(--ytk-surface-hover);
}

.ytk-btn:active {
	transform: translateY(1px);
}

.ytk-btn:focus-visible {
	outline: none;
	box-shadow: var(--ytk-focus-ring);
}

.ytk-btn--primary {
	background: var(--ytk-accent, #0e9594);
	border-color: var(--ytk-accent, #0e9594);
	color: var(--ytk-accent-ink);
}

.ytk-btn--primary:hover {
	filter: brightness(1.06);
	background: var(--ytk-accent, #0e9594);
}

.ytk-btn--ghost {
	background: transparent;
}

.ytk-btn--sm {
	min-height: 36px;
	padding: 6px 12px;
	font-size: 0.85em;
}

.ytk-btn--block {
	width: 100%;
}

.ytk-btn[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
}

.ytk-btn.is-copied {
	background: var(--ytk-success-bg);
	border-color: var(--ytk-success);
	color: var(--ytk-success);
}

/* ---------- Tabs ---------- */

.ytk-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 16px;
	border-bottom: 1.5px solid var(--ytk-border);
}

.ytk-tab {
	padding: 10px 16px;
	min-height: 44px;
	font-family: inherit;
	font-size: 0.9em;
	font-weight: 600;
	color: var(--ytk-text-muted);
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	cursor: pointer;
	margin-bottom: -1.5px;
}

.ytk-tab:hover {
	color: var(--ytk-text);
}

.ytk-tab[aria-selected="true"] {
	color: var(--ytk-accent, #0e9594);
	border-bottom-color: var(--ytk-accent, #0e9594);
}

.ytk-tab:focus-visible {
	outline: none;
	box-shadow: var(--ytk-focus-ring);
	border-radius: 4px;
}

/* ---------- Cards / results ---------- */

.ytk-card {
	padding: 14px;
	background: var(--ytk-surface);
	border: 1px solid var(--ytk-border);
	border-radius: var(--ytk-radius-sm);
}

/* ---------- Badges & states ---------- */

.ytk-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	font-size: 0.82em;
	font-weight: 700;
	border-radius: 999px;
}

.ytk-badge--success {
	color: var(--ytk-success);
	background: var(--ytk-success-bg);
}

.ytk-badge--danger {
	color: var(--ytk-danger);
	background: var(--ytk-danger-bg);
}

.ytk-badge--warning {
	color: var(--ytk-warning);
	background: var(--ytk-warning-bg);
}

.ytk-notice {
	padding: 12px 14px;
	margin: 0 0 16px;
	font-size: 0.9em;
	border-radius: var(--ytk-radius-sm);
	border: 1px solid var(--ytk-border);
	background: var(--ytk-surface);
}

.ytk-notice--error {
	color: var(--ytk-danger);
	background: var(--ytk-danger-bg);
	border-color: transparent;
}

.ytk-notice--warning {
	color: var(--ytk-warning);
	background: var(--ytk-warning-bg);
	border-color: transparent;
}

.ytk-notice--success {
	color: var(--ytk-success);
	background: var(--ytk-success-bg);
	border-color: transparent;
}

.ytk-empty-state {
	padding: 18px;
	color: var(--ytk-text-muted);
	font-size: 0.92em;
	text-align: center;
	border: 1.5px dashed var(--ytk-border);
	border-radius: var(--ytk-radius-sm);
}

.ytk-checklist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ytk-checklist li {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 0.92em;
}

.ytk-checklist .ytk-check-icon {
	flex: none;
	width: 18px;
	height: 18px;
	margin-top: 1px;
}

.ytk-checklist .is-pass .ytk-check-icon {
	color: var(--ytk-success);
}

.ytk-checklist .is-fail .ytk-check-icon {
	color: var(--ytk-danger);
}

/* ---------- Progress bar ---------- */

.ytk-progress {
	height: 8px;
	background: var(--ytk-surface);
	border-radius: 999px;
	overflow: hidden;
	border: 1px solid var(--ytk-border);
}

.ytk-progress__bar {
	height: 100%;
	width: 0%;
	background: var(--ytk-success);
	transition: width 0.15s ease, background-color 0.15s ease;
}

.ytk-progress__bar.is-amber {
	background: var(--ytk-warning);
}

.ytk-progress__bar.is-red {
	background: var(--ytk-danger);
}

.ytk-count-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-top: 6px;
	font-size: 0.85em;
	color: var(--ytk-text-muted);
}

/* ---------- Spinner ---------- */

.ytk-spinner {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2.5px solid var(--ytk-border);
	border-top-color: var(--ytk-accent, #0e9594);
	border-radius: 50%;
	animation: ytk-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.ytk-spinner {
		animation-duration: 1.6s;
	}
}

.ytk-skeleton {
	background: linear-gradient(90deg, var(--ytk-surface) 25%, var(--ytk-surface-hover) 37%, var(--ytk-surface) 63%);
	background-size: 400% 100%;
	animation: ytk-shimmer 1.4s ease infinite;
	border-radius: var(--ytk-radius-sm);
}

@keyframes ytk-shimmer {
	0% {
		background-position: 100% 50%;
	}
	100% {
		background-position: 0 50%;
	}
}

/* ---------- Utility ---------- */

.ytk-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ytk-text-muted {
	color: var(--ytk-text-muted);
}

.ytk-mt-0 {
	margin-top: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
	.ytk-tool {
		padding: 18px;
		border-radius: 10px;
	}

	.ytk-row {
		flex-direction: column;
	}

	.ytk-row > * {
		flex-basis: auto;
	}
}
