/* Typing Trainer page – fit in 100vh; JS may apply scale when content overflows */
.typing-trainer-page .site-main {
	max-width: none;
	padding: 0.75rem 1rem 0.5rem;
	height: 100vh;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-sizing: border-box;
	overflow: hidden;
}

.typing-trainer-page .typing-trainer-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.5rem, 2vh, 1.5rem);
	flex: 1 1 auto;
	min-height: 0;
	justify-content: center;
	transform-origin: top center;
	position: relative;
}

/* ----- How to type link ----- */
.typing-trainer-actions {
	width: 100%;
	max-width: 640px;
	display: flex;
	justify-content: center;
}

.typing-trainer-btn {
	display: inline-block;
	padding: 0.6rem 1.2rem;
	font-size: 0.95rem;
	font-weight: 600;
	text-decoration: none;
	border-radius: 10px;
	border: none;
	cursor: pointer;
	transition: transform 0.15s, box-shadow 0.15s;
}
.typing-trainer-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.typing-trainer-btn:focus {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
}
.typing-trainer-btn-how {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	color: #fff;
}
.typing-trainer-btn-history {
	background: linear-gradient(135deg, #64748b, #475569);
	color: #fff;
}

/* Typing interface – white text area, compact for 100vh */
.typing-interface {
	width: 100%;
	max-width: 640px;
	flex-shrink: 0;
	border-radius: 20px;
	overflow: hidden;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
}

.typing-interface__top {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.6rem 1rem;
	background: #f8fafc;
	border-bottom: 1px solid #e2e8f0;
}

.typing-interface__label {
	font-size: 0.875rem;
	color: #6b7280;
	font-weight: 500;
	flex-shrink: 0;
}

.typing-interface__progress-wrap {
	flex: 1;
	min-width: 0;
}

/* Progress line */
.typing-interface__progress-track {
	position: relative;
	height: 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.08);
	overflow: hidden;
}

.typing-interface__progress-fill {
	height: 100%;
	width: 0%;
	border-radius: 999px;
	background: linear-gradient(90deg, #4ade80, #22c55e);
	transition: width 0.2s ease-out, background 0.2s ease-out;
}

/* Only a small part at the end turns red when there's a mistake */
.typing-interface__progress-fill.has-mistake {
	background: linear-gradient(to right, #4ade80 0%, #22c55e 78%, #ef4444 100%);
}

.typing-interface__wpm {
	font-size: 0.875rem;
	font-weight: 600;
	color: #374151;
	flex-shrink: 0;
	min-width: 4ch;
	text-align: right;
}

/* Text display area – solid white; input is overlaid and hidden */
.typing-interface__text-area {
	position: relative;
	padding: 1rem 1.25rem;
	background: #fff;
	border-radius: 0 0 20px 20px;
	min-height: 100px;
}

.typing-display {
	font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
	font-size: 1.25rem;
	line-height: 1.7;
	color: #4b5563;
	word-break: keep-all;
	overflow-wrap: normal;
	margin-bottom: 0.75rem;
	min-height: 2.2em;
}

.typing-display__word {
	white-space: nowrap;
}

.typing-display__typed {
	color: #111827;
}

.typing-display__typed .correct {
	color: #059669;
}

.typing-display__typed .incorrect {
	color: #dc2626;
	background: rgba(220, 38, 38, 0.1);
	border-radius: 2px;
	border-bottom: 2px solid #dc2626;
}

/* Wrong space: same style as other wrong chars, just visible width */
.typing-display__typed .incorrect-space {
	display: inline-block;
	min-width: 0.35em;
	border-radius: 2px;
	border-bottom: 2px solid #dc2626;
}

.typing-display__cursor {
	display: inline-block;
	width: 2px;
	height: 1.1em;
	vertical-align: text-bottom;
	background: #4b5563;
	margin-left: 1px;
}

.typing-display__remaining {
	color: #9ca3af;
}

/* Input moved off-screen so it stays fully typeable; click on text area focuses it */
.typing-input {
	position: absolute;
	left: -9999px;
	top: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	border: none;
	outline: none;
	opacity: 1;
}

.typing-interface__text-area {
	/* Clickable area to focus the off-screen input */
	cursor: text;
}

/* Keyboard and hands – scale to fit 100vh (larger share of viewport) */
.hands-and-keyboard {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0;
	width: 100%;
	max-width: 920px;
	flex: 1 1 auto;
	min-height: 0;
	max-height: min(72vh, 520px);
}

.hands-and-keyboard .keyboard-wrap {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	max-height: 75%;
}

.hands-and-keyboard .keyboard-tray {
	max-height: 100%;
	width: 100%;
}

.hands-and-keyboard .typing-keyboard {
	width: 100%;
	height: auto;
	max-height: min(50vh, 320px);
	object-fit: contain;
}

.hands-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp(1rem, 3vw, 2rem);
	width: 100%;
	margin-top: -0.25rem;
	flex-shrink: 0;
}

.hand {
	width: clamp(110px, 18vw, 185px);
	height: auto;
	max-height: min(26vh, 165px);
	flex-shrink: 0;
	object-fit: contain;
}

.hand-finger {
	transition: fill 0.25s ease, filter 0.25s ease, stroke 0.25s ease;
}

.hand-finger.active {
	stroke-width: 1;
	filter: drop-shadow(0 0 8px currentColor);
}
#left-pinky.active, #right-pinky.active { fill: #ec4899; stroke: #db2777; }
#left-ring.active, #right-ring.active { fill: #8b5cf6; stroke: #7c3aed; }
#left-middle.active, #right-middle.active { fill: #3b82f6; stroke: #2563eb; }
#left-index.active, #right-index.active { fill: #10b981; stroke: #059669; }
#left-thumb.active, #right-thumb.active { fill: #f97316; stroke: #ea580c; }

/* Keyboard – tray and keys tilt together like a keyboard lying on a surface */
.keyboard-wrap {
	width: 100%;
	max-width: 920px;
	perspective: 1000px;
	perspective-origin: 50% 50%;
	display: flex;
	justify-content: center;
}

.keyboard-tray {
	width: 100%;
	max-width: 920px;
	max-height: 100%;
	background: linear-gradient(165deg, #4a5058 0%, #3d4248 45%, #363b40 100%);
	border-radius: 14px 14px 24px 24px;
	padding: 0.5rem 0.5rem 1rem;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
	transform: rotateX(18deg);
	transform-origin: center center;
	transform-style: preserve-3d;
}

.typing-keyboard {
	width: 100%;
	height: auto;
	display: block;
	transform-origin: center center;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
	border-radius: 8px;
}

.typing-keyboard .key {
	cursor: default;
	transition: fill 0.2s ease, filter 0.2s ease;
	fill: #f5f5f5;
}

/* Only when a finger must click: that finger’s keys get a visible tint; the key to press gets full color */
.keyboard-wrap.next-finger-left-pinky .typing-keyboard .key[data-finger="left-pinky"],
.keyboard-wrap.next-finger-right-pinky .typing-keyboard .key[data-finger="right-pinky"] { fill: #fbcfe8; }
.keyboard-wrap.next-finger-left-ring   .typing-keyboard .key[data-finger="left-ring"],
.keyboard-wrap.next-finger-right-ring  .typing-keyboard .key[data-finger="right-ring"] { fill: #ddd6fe; }
.keyboard-wrap.next-finger-left-middle .typing-keyboard .key[data-finger="left-middle"],
.keyboard-wrap.next-finger-right-middle .typing-keyboard .key[data-finger="right-middle"] { fill: #bfdbfe; }
.keyboard-wrap.next-finger-left-index  .typing-keyboard .key[data-finger="left-index"],
.keyboard-wrap.next-finger-right-index .typing-keyboard .key[data-finger="right-index"] { fill: #a7f3d0; }
.keyboard-wrap.next-finger-left-thumb  .typing-keyboard .key[data-finger="left-thumb"],
.keyboard-wrap.next-finger-right-thumb .typing-keyboard .key[data-finger="right-thumb"] { fill: #fed7aa; }

/* The key(s) to press: full finger color + glow (per key by data-finger so Shift+letter both show) */
.typing-keyboard .key.next-key[data-finger="left-pinky"],
.typing-keyboard .key.next-key[data-finger="right-pinky"] { fill: #ec4899 !important; filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.5)); }
.typing-keyboard .key.next-key[data-finger="left-ring"],
.typing-keyboard .key.next-key[data-finger="right-ring"] { fill: #8b5cf6 !important; filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.5)); }
.typing-keyboard .key.next-key[data-finger="left-middle"],
.typing-keyboard .key.next-key[data-finger="right-middle"] { fill: #3b82f6 !important; filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5)); }
.typing-keyboard .key.next-key[data-finger="left-index"],
.typing-keyboard .key.next-key[data-finger="right-index"] { fill: #10b981 !important; filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.5)); }
.typing-keyboard .key.next-key[data-finger="left-thumb"],
.typing-keyboard .key.next-key[data-finger="right-thumb"] { fill: #f97316 !important; filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.5)); }

.typing-keyboard .key-labels {
	pointer-events: none;
}

/* Hide sidebar on this template */
.typing-trainer-page + #secondary,
.typing-trainer-page + .widget-area {
	display: none;
}

.typing-trainer-page .site-main {
	width: 100%;
}

/* ----- Result modal (after each round) ----- */
.tytype-result-modal {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}
.tytype-result-modal[data-open="true"] {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}
.tytype-result-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	cursor: pointer;
}
.tytype-result-modal-box {
	position: relative;
	width: 100%;
	max-width: 380px;
	background: #fff;
	border-radius: 20px;
	box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
	padding: 1.75rem 1.5rem;
	text-align: center;
}
.tytype-result-modal-title {
	margin: 0 0 1.25rem;
	font-size: 1.5rem;
	font-weight: 700;
	color: #111;
}
.tytype-result-modal-stats {
	display: flex;
	justify-content: center;
	gap: 1.5rem;
	margin-bottom: 1rem;
}
.tytype-result-stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
}
.tytype-result-stat-value {
	font-size: 1.5rem;
	font-weight: 700;
	color: #0f172a;
}
.tytype-result-stat-label {
	font-size: 0.8rem;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}
.tytype-result-stars {
	margin-bottom: 1.5rem;
	font-size: 2rem;
	letter-spacing: 0.2em;
	color: #cbd5e1;
}
.tytype-result-star.earned {
	color: #f59e0b;
}
.tytype-result-modal-actions {
	display: flex;
	gap: 0.75rem;
	justify-content: center;
	flex-wrap: wrap;
}
.tytype-result-btn {
	padding: 0.65rem 1.25rem;
	font-size: 1rem;
	font-weight: 600;
	border-radius: 10px;
	border: none;
	cursor: pointer;
	transition: transform 0.15s, box-shadow 0.15s;
}
.tytype-result-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.tytype-result-btn:focus {
	outline: 2px solid #3b82f6;
	outline-offset: 2px;
}
.tytype-result-btn-again {
	background: #f1f5f9;
	color: #334155;
}
.tytype-result-btn-next {
	background: linear-gradient(135deg, #3b82f6, #2563eb);
	color: #fff;
}

/* History modal list */
.tytype-history-modal-box {
	max-width: 520px;
}
.tytype-history-list {
	max-height: 55vh;
	overflow-y: auto;
	margin-bottom: 1rem;
	text-align: left;
}
.tytype-history-empty {
	margin: 0;
	padding: 1rem;
	color: #64748b;
	font-size: 0.95rem;
}
.tytype-history-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	padding: 0.75rem 0;
	border-bottom: 1px solid #e2e8f0;
}
.tytype-history-row:last-child {
	border-bottom: none;
}
.tytype-history-row-text {
	flex: 1 1 100%;
	font-size: 0.9rem;
	color: #334155;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.tytype-history-row-stats {
	font-size: 0.8rem;
	color: #64748b;
}
.tytype-history-replay {
	flex-shrink: 0;
}

/* Learn Blind Typing modal (same as homepage) */
.typing-trainer-page .tytype-modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1.5rem;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}
.typing-trainer-page .tytype-modal[data-open="true"] {
	display: flex;
	opacity: 1;
	visibility: visible;
}
.typing-trainer-page .tytype-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	cursor: pointer;
}
.typing-trainer-page .tytype-modal-box {
	position: relative;
	width: 100%;
	max-width: 520px;
	max-height: 90vh;
	overflow: auto;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
	padding: 1.5rem 1.75rem;
}
.typing-trainer-page .tytype-modal-close {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	width: 36px;
	height: 36px;
	padding: 0;
	font-size: 1.5rem;
	line-height: 1;
	color: #6b7280;
	background: none;
	border: none;
	cursor: pointer;
	border-radius: 8px;
	transition: color 0.2s, background 0.2s;
}
.typing-trainer-page .tytype-modal-close:hover {
	color: #111;
	background: #f3f4f6;
}
.typing-trainer-page .tytype-modal-title {
	margin: 0 2rem 1rem 0;
	font-size: 1.5rem;
	font-weight: 700;
	color: #111;
}
.typing-trainer-page .tytype-modal-content {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}
.typing-trainer-page .tytype-modal-img {
	width: 100%;
	height: auto;
	border-radius: 10px;
	object-fit: cover;
}
.typing-trainer-page .tytype-modal-img-placeholder {
	width: 100%;
	height: 200px;
	background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
	border-radius: 10px;
}
.typing-trainer-page .tytype-modal-text {
	font-size: 0.95rem;
	line-height: 1.6;
	color: #374151;
}
.typing-trainer-page .tytype-modal-text p {
	margin: 0 0 0.75rem 0;
}
.typing-trainer-page .tytype-modal-text p:last-child {
	margin-bottom: 0;
}
.typing-trainer-page .tytype-modal-link {
	color: #2563eb;
	font-weight: 600;
	text-decoration: none;
}
.typing-trainer-page .tytype-modal-link:hover {
	text-decoration: underline;
}
