/**
 * Youth Growth AI MCQ — public base stylesheet.
 * Mobile-first, theme-agnostic (relies on the theme's own font-family/
 * color scheme where sensible, and only sets its own tokens for
 * things the theme won't provide). Loaded on every page (small
 * footprint); feature-specific stylesheets (ygam-quiz.css) load only
 * where needed — see includes/class-ygam-assets.php.
 */

:root {
	--ygam-primary: #1a73e8;
	--ygam-primary-dark: #0f52ba;
	--ygam-success: #1a7a1a;
	--ygam-danger: #b02a2a;
	--ygam-warning: #a35c00;
	--ygam-border: #e0e0e0;
	--ygam-bg-muted: #f7f8fa;
	--ygam-text-muted: #5f6368;
	--ygam-radius: 8px;
	--ygam-spacing: 16px;
}

/* ---------------------------------------------------------------
   Accessibility helpers
--------------------------------------------------------------- */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ygam-page a:focus-visible,
.ygam-page button:focus-visible,
.ygam-page input:focus-visible,
.ygam-page select:focus-visible,
.ygam-page textarea:focus-visible {
	outline: 3px solid var(--ygam-primary);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------
   Layout primitives
--------------------------------------------------------------- */
.ygam-page * {
	box-sizing: border-box;
}

.ygam-section-title {
	margin: 32px 0 16px;
	font-size: 1.25rem;
}

.ygam-loading {
	color: var(--ygam-text-muted);
	font-style: italic;
	padding: 12px 0;
}

.ygam-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 16px;
	margin: 16px 0;
}

@media (min-width: 600px) {
	.ygam-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 960px) {
	.ygam-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

.ygam-stat-box {
	background: var(--ygam-bg-muted);
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	padding: 16px;
}

.ygam-stat-value {
	display: block;
	font-size: 1.75rem;
	font-weight: 700;
	color: var(--ygam-primary);
}

.ygam-stat-label {
	font-size: 0.85rem;
	color: var(--ygam-text-muted);
}

/* ---------------------------------------------------------------
   Buttons
--------------------------------------------------------------- */
.ygam-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 20px;
	border-radius: var(--ygam-radius);
	font-weight: 600;
	text-decoration: none;
	border: 1px solid transparent;
	cursor: pointer;
	font-size: 0.95rem;
	min-height: 44px; /* touch target size */
	transition: background-color 0.15s ease, transform 0.05s ease;
}

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

.ygam-btn-primary {
	background: var(--ygam-primary);
	color: #fff;
}

.ygam-btn-primary:hover {
	background: var(--ygam-primary-dark);
	color: #fff;
}

.ygam-btn-secondary {
	background: #fff;
	border-color: var(--ygam-border);
	color: #202124;
}

.ygam-btn-danger {
	background: var(--ygam-danger);
	color: #fff;
}

/* ---------------------------------------------------------------
   Forms
--------------------------------------------------------------- */
.ygam-form-row {
	margin-bottom: 16px;
}

.ygam-form-row label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
}

.ygam-form-row input,
.ygam-form-row select,
.ygam-form-row textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	font-size: 1rem;
	min-height: 44px;
}

.ygam-form-row textarea {
	min-height: 88px;
}

/* ---------------------------------------------------------------
   Toolbar / filters
--------------------------------------------------------------- */
.ygam-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 20px;
}

.ygam-toolbar select,
.ygam-toolbar input {
	min-height: 40px;
	padding: 6px 10px;
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
}

/* ---------------------------------------------------------------
   Tables (responsive: switch to stacked cards under 600px)
--------------------------------------------------------------- */
.ygam-table {
	width: 100%;
	border-collapse: collapse;
}

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

@media (max-width: 599px) {
	.ygam-table thead {
		display: none;
	}
	.ygam-table,
	.ygam-table tbody,
	.ygam-table tr,
	.ygam-table td {
		display: block;
		width: 100%;
	}
	.ygam-table tr {
		margin-bottom: 12px;
		border: 1px solid var(--ygam-border);
		border-radius: var(--ygam-radius);
		padding: 8px 0;
	}
	.ygam-table td {
		border: none;
		padding: 6px 12px;
	}
}

/* ---------------------------------------------------------------
   Pagination
--------------------------------------------------------------- */
.ygam-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 16px;
}

.ygam-pagination button {
	min-width: 40px;
	min-height: 40px;
}

/* ---------------------------------------------------------------
   Notices
--------------------------------------------------------------- */
.ygam-notice {
	background: var(--ygam-bg-muted);
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	padding: 16px;
	margin: 16px 0;
}

.ygam-notice-login {
	text-align: center;
}

/* ---------------------------------------------------------------
   Home template
--------------------------------------------------------------- */
.ygam-home-hero {
	text-align: center;
	padding: 32px 16px;
}

.ygam-home-title {
	font-size: 1.5rem;
	margin-bottom: 8px;
}

@media (min-width: 768px) {
	.ygam-home-title {
		font-size: 2rem;
	}
}

.ygam-home-subtitle {
	color: var(--ygam-text-muted);
	max-width: 620px;
	margin: 0 auto 20px;
}

.ygam-home-quicklinks {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
}

.ygam-subject-grid,
.ygam-notes-grid,
.ygam-certificate-grid,
.ygam-mocktest-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr;
	gap: 14px;
}

@media (min-width: 600px) {
	.ygam-subject-grid,
	.ygam-notes-grid,
	.ygam-certificate-grid,
	.ygam-mocktest-list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 960px) {
	.ygam-subject-grid,
	.ygam-notes-grid,
	.ygam-certificate-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

.ygam-subject-tile,
.ygam-note-card,
.ygam-certificate-card,
.ygam-mocktest-item {
	display: block;
	background: #fff;
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	padding: 16px;
	text-decoration: none;
	color: inherit;
}

.ygam-badge {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 12px;
	font-size: 0.75rem;
	font-weight: 600;
}

.ygam-badge-success { background: #e6f4ea; color: var(--ygam-success); }
.ygam-badge-warning { background: #fff4e5; color: var(--ygam-warning); }
.ygam-badge-danger  { background: #fdeaea; color: var(--ygam-danger); }
.ygam-badge-info    { background: #e8f0fe; color: var(--ygam-primary); }

/* ---------------------------------------------------------------
   Dashboard
--------------------------------------------------------------- */
.ygam-dashboard-columns {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
	margin: 24px 0;
}

@media (min-width: 900px) {
	.ygam-dashboard-columns {
		grid-template-columns: 1fr 1fr;
	}
}

.ygam-badge-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

/* ---------------------------------------------------------------
   AI chat/doubt
--------------------------------------------------------------- */
.ygam-ai-chat-window {
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	overflow: hidden;
}

.ygam-ai-chat-log {
	max-height: 400px;
	overflow-y: auto;
	padding: 16px;
	background: var(--ygam-bg-muted);
}

.ygam-ai-chat-message {
	margin-bottom: 12px;
	padding: 10px 14px;
	border-radius: var(--ygam-radius);
	max-width: 85%;
}

.ygam-ai-chat-message.user {
	background: var(--ygam-primary);
	color: #fff;
	margin-left: auto;
}

.ygam-ai-chat-message.assistant {
	background: #fff;
	border: 1px solid var(--ygam-border);
}

.ygam-ai-chat-form {
	display: flex;
	gap: 8px;
	padding: 12px;
	border-top: 1px solid var(--ygam-border);
}

.ygam-ai-chat-form textarea {
	flex: 1;
	min-height: 44px;
	border: 1px solid var(--ygam-border);
	border-radius: var(--ygam-radius);
	padding: 10px;
	resize: vertical;
}

.ygam-ai-unavailable {
	background: #fff4e5;
	color: var(--ygam-warning);
	padding: 14px;
	border-radius: var(--ygam-radius);
}

/* Bank Transfer details table on the payment panel. */
.ygam-bank-details {
	width: 100%;
	border-collapse: collapse;
	margin: 8px 0 12px;
	font-size: 0.92rem;
}

.ygam-bank-details th,
.ygam-bank-details td {
	text-align: left;
	padding: 8px 10px;
	border-bottom: 1px solid #e3e6ee;
	vertical-align: top;
}

.ygam-bank-details th {
	width: 42%;
	color: #667;
	font-weight: 600;
}

.ygam-bank-details td {
	font-weight: 600;
	word-break: break-word;
}

.ygam-bank-details tr:last-child th,
.ygam-bank-details tr:last-child td { border-bottom: 0; }

@media (max-width: 480px) {
	.ygam-bank-details th { width: 46%; }
	.ygam-bank-details th,
	.ygam-bank-details td { padding: 7px 6px; font-size: 0.86rem; }
}


/* Catalog: All / Purchased sections */
.ygam-catalog-section { margin: 1.5rem 0 2rem; }
.ygam-catalog-section-title { margin: 0 0 0.75rem; font-size: 1.15rem; }
.ygam-catalog-more-wrap { text-align: center; margin-top: 1rem; }
.ygam-catalog-more-btn { font-size: 1.05rem !important; padding: 0.65rem 1.4rem !important; }
.ygam-purchased-badge { background: #0a7; color: #fff; }
.ygam-catalog-purchased-section { border-top: 1px solid #e2e8f0; padding-top: 1.25rem; }

/* ===================================================================
 * Cross-device safety net for every plugin screen.
 * Deliberately scoped to the plugin's own containers so nothing here
 * can affect the surrounding theme.
 * =================================================================== */

/* Consistent text scaling on iOS when the phone is rotated: without
   this, Safari inflates text after a portrait->landscape rotation. */
[class*="ygam-"] {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

/* Long words, URLs, Hindi+English mixed strings and wide tables are the
   usual causes of a sideways-scrolling page on a phone. */
.ygam-dashboard,
.ygam-course-tests-only,
.ygam-cd-section,
.ygam-test-series,
.ygam-tt-card {
	min-width: 0;
	max-width: 100%;
	overflow-wrap: break-word;
}

.ygam-table-wrap,
.ygam-cd-section table,
.ygam-dashboard table {
	max-width: 100%;
}

.ygam-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* Any image the plugin renders scales down rather than overflowing. */
[class*="ygam-"] img {
	max-width: 100%;
	height: auto;
}

/* Buttons and links the student taps stay at the 44px minimum touch
   target on touch devices, without changing their look on desktop. */
@media (hover: none) and (pointer: coarse) {
	.ygam-btn,
	.ygam-home-link,
	.ygam-tt-toggle,
	.ygam-tt-selbtn,
	.ygam-tt-viewbtn {
		min-height: 44px;
	}
}

/* Tablet portrait: the plugin's card grids look sparse at one column
   and cramped at three, so two columns is the right middle. */
@media (min-width: 641px) and (max-width: 899px) {
	.ygam-course-grid,
	.ygam-cards-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ---------------------------------------------------------------------
 * My Bookmarked Questions (student dashboard)
 * ---------------------------------------------------------------------
 * Reads the same bookmark flag the quiz runner writes. Laid out as a
 * plain list that stacks on a phone — no extra statistics cards, since
 * the brief was explicitly to avoid decorative dashboard sections.
 * ------------------------------------------------------------------ */
.ygam-bm-count {
	font-size: 0.85em;
	color: #667;
	font-weight: 400;
	margin-left: 6px;
}

.ygam-bm-empty {
	color: #667;
	background: #f7f8fa;
	border: 1px solid #e3e6ee;
	border-radius: 8px;
	padding: 14px;
}

.ygam-bm-groups {
	list-style: none;
	margin: 0 0 14px;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 8px;
}

.ygam-bm-groups li {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	background: #f6f8fc;
	border: 1px solid #e3e6ee;
	border-radius: 8px;
	padding: 8px 12px;
	font-size: 0.9rem;
}

.ygam-bm-gpath { color: #33384a; }
.ygam-bm-gcount { font-weight: 700; color: #1a3a6b; }

.ygam-bm-practice-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 0 0 14px;
}

.ygam-bm-practice-status,
.ygam-bm-status { font-size: 0.88rem; color: #667; }

.ygam-bm-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 10px;
}

.ygam-bm-item {
	background: #fff;
	border: 1px solid #e3e6ee;
	border-radius: 8px;
	padding: 12px 14px;
}

.ygam-bm-q { line-height: 1.5; margin-bottom: 4px; }
.ygam-bm-path { font-size: 0.82rem; color: #787c82; margin-bottom: 8px; }

.ygam-bm-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.ygam-bm-actions .ygam-btn {
	min-height: 40px;
	padding: 8px 12px;
	font-size: 0.88rem;
}

@media ( max-width: 640px ) {
	.ygam-bm-groups { grid-template-columns: 1fr; }

	/* Both actions on one line, each a comfortable touch target. */
	.ygam-bm-actions .ygam-btn { flex: 1 1 auto; min-height: 44px; }
	.ygam-bm-practice-row .ygam-btn { width: 100%; min-height: 44px; }
}

/* ---------------------------------------------------------------------
 * PWA install banner ("Add to Home Screen")
 * ---------------------------------------------------------------------
 * A bar pinned to the bottom of the viewport — never a modal and never
 * an overlay on the page's own controls, so it cannot swallow a tap
 * meant for something else. It is not rendered at all on quiz, mock
 * test or payment screens (see public/js/ygam-pwa-install.js).
 * ------------------------------------------------------------------ */
.ygam-pwa-banner {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9000;
	background: #fff;
	border-top: 1px solid #e3e6ee;
	box-shadow: 0 -4px 20px rgba(16, 24, 40, 0.1);
	/* Starts off-screen and slides up, so it never flashes in place. */
	transform: translateY(110%);
	transition: transform 0.25s ease;
	/* Clears the iPhone home indicator. */
	padding-bottom: env(safe-area-inset-bottom, 0);
}

.ygam-pwa-banner.is-visible {
	transform: translateY(0);
}

@media ( prefers-reduced-motion: reduce ) {
	.ygam-pwa-banner { transition: none; }
}

.ygam-pwa-banner-inner {
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: 960px;
	margin: 0 auto;
	padding: 12px 16px;
}

.ygam-pwa-icon {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 9px;
}

.ygam-pwa-text {
	flex: 1 1 auto;
	margin: 0;
	font-size: 0.92rem;
	line-height: 1.45;
	color: #22263a;
}

.ygam-pwa-actions {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
}

.ygam-pwa-banner button {
	min-height: 44px;
	padding: 10px 16px;
	border-radius: 8px;
	font-size: 0.92rem;
	font-weight: 600;
	cursor: pointer;
	border: 1px solid transparent;
	font-family: inherit;
}

.ygam-pwa-install {
	background: var(--ygam-primary, #1a73e8);
	color: #fff;
}

.ygam-pwa-install:hover { background: var(--ygam-primary-dark, #0f52ba); }
.ygam-pwa-install:disabled { opacity: 0.6; cursor: default; }

.ygam-pwa-dismiss {
	background: transparent;
	color: #5a6079;
	border-color: #dfe3ec;
}

.ygam-pwa-dismiss:hover { background: #f4f6fb; }

@media ( max-width: 600px ) {
	/* Stacked on a phone: the text gets a full line to itself and the
	   two buttons share the next one, so neither is squeezed below a
	   comfortable touch target at 320px. */
	.ygam-pwa-banner-inner {
		flex-wrap: wrap;
		padding: 12px;
		gap: 10px;
	}

	.ygam-pwa-text {
		flex: 1 1 100%;
		order: 2;
		font-size: 0.88rem;
	}

	.ygam-pwa-icon { order: 1; }

	.ygam-pwa-actions {
		order: 3;
		flex: 1 1 100%;
		gap: 8px;
	}

	.ygam-pwa-actions button { flex: 1 1 auto; }
}

/* ---------------------------------------------------------------
   Dashboard header — Home and Log Out beside the heading.

   Home is the control a student reaches for after finishing a test,
   and it used to be left to whatever small breadcrumb link the theme
   drew above the page. On a phone that is a few pixels of text. This
   gives it the same size and weight as every other YGAM button, with
   a touch target that clears the 44px minimum on every screen.
   --------------------------------------------------------------- */

.ygam-dashboard-header-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.ygam-dashboard-header-row h2 {
	margin: 0;
}

.ygam-dashboard-header-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ygam-dashboard-header-actions .ygam-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	/* A comfortable touch target. 46px rather than exactly 44 so the
	   button still clears the minimum once a theme's own line-height
	   or border is added on top. */
	min-height: 46px;
	padding: 11px 20px;
	font-size: 1rem;
	font-weight: 600;
}

.ygam-dashboard-home-icon {
	font-size: 1.15em;
	line-height: 1;
}

@media (max-width: 600px) {
	/* The heading takes the full width and the two buttons share the
	   row beneath it, each big enough to hit without aiming. */
	.ygam-dashboard-header-row {
		flex-direction: column;
		align-items: stretch;
	}

	.ygam-dashboard-header-actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.ygam-dashboard-header-actions .ygam-btn {
		width: 100%;
	}
}
