/* Typing Master By PLH — front-end styles
   Rebuilt to match pakistanlawhub.com's actual design system: colors,
   fonts (Cormorant Garamond / Outfit), shadows, radii, and the site's
   existing 4-colour "pillar card" pattern, reused here for the tiers. */

.tm-wrap {
	--teal:       #0d9488;
	--teal-dark:  #0f766e;
	--teal-deep:  #115e59;
	--teal-light: #ccfbf1;
	--teal-pale:  #f0fdfa;
	--accent:     #f59e0b;
	--accent-lt:  #fef3c7;
	--indigo:     #6366f1;
	--indigo-lt:  #eef2ff;
	--rose:       #f43f5e;
	--rose-lt:    #fff1f2;
	--sky:        #0ea5e9;
	--sky-lt:     #f0f9ff;
	--success:    #059669;
	--text-h:     #0f172a;
	--text-b:     #374151;
	--text-m:     #6b7280;
	--text-lt:    #9ca3af;
	--white:      #ffffff;
	--off-white:  #f8fafb;
	--border:     #e5e7eb;
	--border-t:   #99f6e4;
	--shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
	--shadow-md:  0 4px 16px rgba(13,148,136,0.10), 0 2px 6px rgba(0,0,0,0.06);
	--shadow-lg:  0 12px 40px rgba(13,148,136,0.14), 0 4px 16px rgba(0,0,0,0.08);
	--r:          12px;

	max-width: 880px;
	margin: 0 auto;
	font-family: 'Outfit', sans-serif;
	font-size: 16px;
	color: var(--text-b);
	line-height: 1.6;
}

.tm-wrap h2, .tm-wrap h3 {
	font-family: 'Cormorant Garamond', serif;
	color: var(--text-h);
}

.tm-btn {
	display: inline-block;
	background: var(--teal);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 12px 22px;
	font-weight: 600;
	font-family: 'Outfit', sans-serif;
	text-decoration: none;
	cursor: pointer;
	font-size: 15px;
	box-shadow: 0 2px 8px rgba(13,148,136,0.3);
	transition: transform .2s, box-shadow .2s;
}

.tm-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 16px rgba(13,148,136,0.4);
	color: #fff;
}

.tm-btn-ghost {
	background: transparent;
	color: var(--text-b);
	border: 1.5px solid var(--border);
	box-shadow: none;
}

.tm-btn-ghost:hover {
	border-color: var(--teal);
	color: var(--teal);
	transform: none;
	box-shadow: none;
}

.tm-login-gate {
	text-align: center;
	padding: 44px 20px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	background: var(--off-white);
}

/* ---------------------------------------------------------- Lesson list */

.tm-tier {
	position: relative;
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: 28px;
	margin-bottom: 22px;
	background: #fff;
	overflow: hidden;
	box-shadow: var(--shadow-sm);
}

/* Four tier colours reusing the site's own category-card gradients. */
.tm-tier[data-tier="beginner"]     { background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #a7f3d0; }
.tm-tier[data-tier="beginner"]::after     { background: var(--teal); }
.tm-tier[data-tier="intermediate"] { background: linear-gradient(135deg, #eef2ff, #e0e7ff); border-color: #c7d2fe; }
.tm-tier[data-tier="intermediate"]::after { background: var(--indigo); }
.tm-tier[data-tier="advanced"]     { background: linear-gradient(135deg, #fffbeb, #fef3c7); border-color: #fde68a; }
.tm-tier[data-tier="advanced"]::after     { background: var(--accent); }
.tm-tier[data-tier="master"]       { background: linear-gradient(135deg, #fff1f2, #ffe4e6); border-color: #fecdd3; }
.tm-tier[data-tier="master"]::after       { background: var(--rose); }

.tm-tier::after {
	content: '';
	position: absolute;
	top: 0; right: 0;
	width: 80px; height: 80px;
	border-radius: 0 16px 0 80px;
	opacity: .15;
}

.tm-tier-locked {
	opacity: .6;
	filter: grayscale(.4);
}

.tm-tier-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	position: relative;
}

.tm-tier-head h3 {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 700;
}

.tm-lock-badge {
	font-size: 12.5px;
	color: #92400e;
	background: rgba(255,255,255,.75);
	border: 1px solid #fde68a;
	padding: 4px 12px;
	border-radius: 20px;
	font-family: 'Outfit', sans-serif;
}

.tm-tier-desc {
	color: var(--text-m);
	margin: 8px 0 18px;
	position: relative;
	max-width: 640px;
}

.tm-lesson-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 12px;
	position: relative;
}

.tm-lesson-card {
	display: flex;
	flex-direction: column;
	gap: 4px;
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 14px 16px;
	text-decoration: none;
	color: inherit;
	background: rgba(255,255,255,.9);
	box-shadow: var(--shadow-sm);
	transition: transform .2s, box-shadow .2s, border-color .2s;
}

.tm-lesson-card:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-md);
	border-color: var(--border-t);
}

.tm-lesson-card.tm-done {
	background: #fff;
	border-color: #a7f3d0;
}

.tm-lesson-num {
	font-size: 12px;
	color: var(--text-lt);
}

.tm-lesson-title {
	font-weight: 600;
	color: var(--text-h);
}

.tm-lesson-cta {
	color: var(--teal-dark);
	font-size: 13px;
	font-weight: 600;
}

.tm-lesson-best {
	color: var(--success);
	font-size: 13px;
	font-weight: 600;
}

/* ------------------------------------------------------- Lesson screen */

.tm-lesson-header h2 {
	margin: 6px 0;
	font-size: 1.9rem;
	font-weight: 700;
}

.tm-tier-pill {
	display: inline-block;
	background: var(--teal-pale);
	color: var(--teal-deep);
	padding: 4px 12px;
	border-radius: 20px;
	font-size: 12.5px;
	font-weight: 600;
	font-family: 'Outfit', sans-serif;
}

.tm-instructions {
	color: var(--text-b);
}

.tm-targets {
	font-size: 13.5px;
	color: var(--text-m);
}

.tm-stats-bar {
	display: flex;
	gap: 12px;
	margin: 20px 0;
}

.tm-stat {
	flex: 1;
	text-align: center;
	background: var(--off-white);
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 12px 6px;
}

.tm-stat-val {
	display: block;
	font-family: 'Cormorant Garamond', serif;
	font-size: 26px;
	font-weight: 700;
	color: var(--teal-deep);
	font-variant-numeric: tabular-nums;
}

.tm-stat-label {
	font-size: 11px;
	color: var(--text-m);
	text-transform: uppercase;
	letter-spacing: .05em;
	font-family: 'Outfit', sans-serif;
}

.tm-text-display {
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
	font-size: 20px;
	line-height: 1.9;
	background: #fff;
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 22px;
	cursor: text;
	user-select: none;
	box-shadow: var(--shadow-sm);
}

.tm-char {
	color: #c4c9d1;
}

.tm-char.tm-correct {
	color: var(--success);
}

.tm-char.tm-incorrect {
	color: #fff;
	background: var(--rose);
	border-radius: 2px;
}

.tm-char.tm-current {
	border-bottom: 2px solid var(--teal);
}

.tm-hidden-input {
	position: absolute;
	opacity: 0;
	height: 1px;
	width: 1px;
	pointer-events: none;
}

/* ------------------------------------------------------ Keyboard guide */

.tm-keyboard-guide {
	margin: 24px auto 8px;
	max-width: 640px;
	user-select: none;
}

.tm-kb-row {
	display: flex;
	justify-content: center;
	gap: 5px;
	margin-bottom: 5px;
}

.tm-kb-key {
	width: 38px;
	height: 38px;
	border: 1px solid var(--border);
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-family: monospace;
	background: #fff;
	transition: background .08s, transform .08s;
}

.tm-kb-space {
	width: 260px;
}

.tm-kb-key.tm-kb-active {
	background: var(--teal);
	color: #fff;
	transform: translateY(1px);
	border-color: var(--teal-dark);
	box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}

/* Subtle permanent finger colour-coding using the site's palette. */
.tm-finger-L5, .tm-finger-R5 { border-top: 3px solid var(--rose); }
.tm-finger-L4, .tm-finger-R4 { border-top: 3px solid var(--accent); }
.tm-finger-L3, .tm-finger-R3 { border-top: 3px solid var(--sky); }
.tm-finger-L2, .tm-finger-R2 { border-top: 3px solid var(--teal); }

.tm-finger-hint {
	text-align: center;
	font-weight: 600;
	color: var(--teal-deep);
	min-height: 20px;
	font-size: 14px;
	font-family: 'Outfit', sans-serif;
}

/* ------------------------------------------------------- Result panel */

.tm-result-panel {
	margin-top: 26px;
	padding: 26px;
	border-radius: 16px;
	border: 1px solid var(--border);
	text-align: center;
	box-shadow: var(--shadow-sm);
}

.tm-result-panel.tm-passed {
	background: linear-gradient(135deg, #ecfdf5, #d1fae5);
	border-color: #a7f3d0;
}

.tm-result-panel.tm-failed {
	background: var(--rose-lt);
	border-color: #fecdd3;
}

.tm-result-panel h3 {
	font-size: 1.6rem;
}

.tm-result-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 14px;
	margin: 18px 0;
}

.tm-result-grid span {
	display: block;
	font-family: 'Cormorant Garamond', serif;
	font-size: 26px;
	font-weight: 700;
	color: var(--text-h);
}

.tm-result-grid label {
	font-size: 12px;
	color: var(--text-m);
}

.tm-result-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
	margin-top: 12px;
}

/* -------------------------------------------------------- Dashboard */

.tm-dash-summary {
	display: flex;
	gap: 16px;
	margin-bottom: 26px;
}

.tm-dash-stat {
	flex: 1;
	text-align: center;
	background: var(--teal-pale);
	border: 1px solid var(--border-t);
	border-radius: var(--r);
	padding: 20px;
}

.tm-dash-stat span {
	display: block;
	font-family: 'Cormorant Garamond', serif;
	font-size: 30px;
	font-weight: 700;
	color: var(--teal-deep);
}

.tm-dash-stat label {
	font-size: 12.5px;
	color: var(--text-m);
}

.tm-dash-tier-row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}

.tm-dash-tier-name {
	width: 120px;
	font-weight: 600;
	flex-shrink: 0;
	color: var(--text-h);
}

.tm-dash-bar {
	flex: 1;
	background: var(--border);
	border-radius: 999px;
	height: 10px;
	overflow: hidden;
}

.tm-dash-bar-fill {
	height: 100%;
	background: linear-gradient(90deg, var(--teal-dark), var(--teal));
}

.tm-dash-tier-count {
	font-size: 13px;
	color: var(--text-m);
	width: 60px;
	text-align: right;
	flex-shrink: 0;
}

/* ------------------------------------------------------- Leaderboard */

.tm-lb-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 18px;
}

.tm-lb-tab {
	background: var(--off-white);
	border: 1px solid var(--border);
	border-radius: 20px;
	padding: 8px 18px;
	font-weight: 600;
	cursor: pointer;
	font-size: 14px;
	font-family: 'Outfit', sans-serif;
	color: var(--text-b);
	transition: all .2s;
}

.tm-lb-tab.tm-active {
	background: var(--teal);
	color: #fff;
	border-color: var(--teal);
	box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}

.tm-lb-table {
	width: 100%;
	border-collapse: collapse;
	background: #fff;
	border-radius: var(--r);
	overflow: hidden;
	box-shadow: var(--shadow-sm);
}

.tm-lb-table th {
	background: var(--off-white);
	font-family: 'Outfit', sans-serif;
	font-size: 12.5px;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--text-m);
}

.tm-lb-table th, .tm-lb-table td {
	padding: 12px 14px;
	border-bottom: 1px solid var(--border);
	text-align: left;
}

.tm-lb-table tr.tm-top3 {
	background: var(--accent-lt);
	font-weight: 700;
}

.tm-lb-your-rank {
	margin-top: 16px;
	font-weight: 600;
	color: var(--teal-deep);
	font-family: 'Outfit', sans-serif;
}

/* ------------------------------------------------------------ Mobile */

@media (max-width: 640px) {
	.tm-text-display {
		font-size: 16px;
	}
	.tm-kb-key {
		width: 26px;
		height: 30px;
		font-size: 11px;
	}
	.tm-kb-space {
		width: 160px;
	}
	.tm-result-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	.tm-stats-bar {
		flex-wrap: wrap;
	}
	.tm-stat {
		min-width: 40%;
	}
}


/* ==================================================================
   v1.1 fixes and additions
   ================================================================== */

/* Practice text must preserve its own spacing. Without this, HTML
   collapses runs of spaces and drops a space that lands at a line
   break, so the visible text stopped matching the text being scored. */
.tm-text-display {
	white-space: pre-wrap;
	overflow-wrap: break-word;
	word-break: normal;
}

/* The capture textarea is absolutely positioned; anchoring it to the
   lesson wrapper stops it escaping to the top-left of the document on
   themes that don't create a containing block. */
.tm-lesson-screen {
	position: relative;
}

.tm-hidden-input {
	top: 0;
	left: 0;
}

.tm-back-link {
	display: inline-block;
	margin-bottom: 10px;
	font-size: 14px;
	color: var(--text-m);
	text-decoration: none;
	font-family: 'Outfit', sans-serif;
}

.tm-back-link:hover {
	color: var(--teal);
}

.tm-start-hint {
	margin: 10px 0 0;
	font-size: 14px;
	color: var(--text-m);
	text-align: center;
}

.tm-start-hint[hidden] {
	display: none;
}

/* Panels shown in place of the typing screen: no lesson chosen, lesson
   missing, tier locked, or an editor preview. */
.tm-notice {
	background: var(--white);
	border: 1px solid var(--border);
	border-left: 4px solid var(--teal);
	border-radius: var(--r);
	padding: 24px 26px;
	box-shadow: var(--shadow-sm);
}

.tm-notice h3 {
	margin: 0 0 8px;
	font-size: 24px;
}

.tm-notice p {
	margin: 0 0 12px;
	color: var(--text-b);
}

.tm-notice p:last-child {
	margin-bottom: 0;
}

.tm-notice-info {
	border-left-color: var(--indigo);
	background: var(--indigo-lt);
}

.tm-login-gate {
	background: var(--white);
	border: 1px solid var(--border);
	border-radius: var(--r);
	padding: 24px 26px;
	text-align: center;
	box-shadow: var(--shadow-sm);
}

.tm-next-btn {
	background: var(--teal-dark);
}

.tm-result-panel[hidden] {
	display: none;
}
