/* ==========================================================================
   Exam window, result & solution fixes (loaded after gep-exam.css)
   ========================================================================== */

/* ── Tables inside questions, passages, solutions ─────────────────────────
   Before: width:100% + "overflow-wrap:anywhere" → short words were split in
   the middle ("Questio|n") on phones and wide gaps appeared on desktop.
   Now a table takes the width its content needs; if it is wider than the
   screen it scrolls sideways inside its own box instead of breaking words. */
html body .gep-q-content table,
html body .gep-q-text-wrapper table,
html body .gep-passage-content table,
html body #gep-passage-body table,
html body .gep-exp-body table,
html body .gep-qr-text table,
html body .gep-result-wrap table {
	width: auto !important;
	max-width: 100% !important;
	table-layout: auto !important;
	display: table !important;
	border-collapse: collapse;
}
html body .gep-q-content table :is(td, th),
html body .gep-q-text-wrapper table :is(td, th),
html body .gep-passage-content table :is(td, th),
html body #gep-passage-body table :is(td, th),
html body .gep-exp-body table :is(td, th),
html body .gep-qr-text table :is(td, th),
html body .gep-result-wrap table :is(td, th) {
	overflow-wrap: normal !important;
	word-break: normal !important;
	hyphens: manual !important;
	white-space: normal !important;
	vertical-align: top;
	/* Tables pasted from Word/Docs carry width:50% etc. on every cell, which
	   stretched two short columns across the whole screen. Content decides. */
	width: auto !important;
	min-width: 0 !important;
}
html body :is(.gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, .gep-exp-body, .gep-qr-text, .gep-result-wrap) table col { width: auto !important; }
html body .gep-table-scroll > table { width: auto !important; }
html body .gep-table-wrap {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 8px 0;
}
html body .gep-table-wrap > table { margin: 0 !important; }
/* Question text: wrap long words only when they really do not fit */
html body .gep-q-text-wrapper,
html body .gep-option-text,
html body .gep-q-content { word-break: normal !important; overflow-wrap: break-word !important; }

/* ── Question palette ───────────────────────────────────────────────────── */
html body .gep-palette-grid {
	display: grid !important;
	grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)) !important;
	gap: 6px !important;
	justify-items: stretch;
}
html body .gep-palette-grid .gep-palette-btn {
	width: 100% !important;
	min-width: 0 !important;
	aspect-ratio: 1 / 1;
	height: auto !important;
	margin: 0 !important;
	padding: 0 !important;
}
html body .gep-palette-section-title {
	text-align: center !important;
	font-size: 15px !important;
	font-weight: 800 !important;
	color: var(--gep-c-text, #0f172a) !important;
	letter-spacing: .02em !important;
	margin: 14px 0 10px !important;
	text-transform: none !important;
}
html body .gep-palette-subtitle { text-align: center; font-size: 14px !important; font-weight: 700 !important; }

/* Desktop: the edge button now hides / shows the palette (no full screen) */
@media (min-width: 993px) {
	html body .gep-exam-sidebar.gep-pal-hidden { width: 0 !important; min-width: 0 !important; padding: 0 !important; border: 0 !important; }
	html body .gep-exam-sidebar.gep-pal-hidden > *:not(.gep-sidebar-collapse-toggle) { display: none !important; }
	html body .gep-exam-layout.gep-pal-hidden { grid-template-columns: minmax(0, 1fr) 0 !important; }
	html body .gep-sidebar-collapse-toggle .toggle-icon { font-size: 16px; font-weight: 900; }
}

/* ── One fixed scroll arrow (replaces the arrows that jumped around) ────── */
html body #gep-floating-scroll-btns,
html body #gep-scroll-to-options-btn { display: none !important; }
#gep-fixed-scroll-btn {
	position: fixed;
	right: 18px;
	bottom: calc(var(--gep-footer-h, 64px) + 14px);
	z-index: 900;
	width: 44px; height: 44px;
	border-radius: 50%;
	border: 0;
	background: #4f46e5;
	color: #fff;
	font-size: 20px;
	font-weight: 900;
	box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
	cursor: pointer;
	display: none;
	align-items: center; justify-content: center;
}
#gep-fixed-scroll-btn.is-visible { display: inline-flex; }
@media (min-width: 993px) { #gep-fixed-scroll-btn { right: calc(var(--gep-sidebar-w, 300px) + 22px); } }
body.gep-pal-hidden-body #gep-fixed-scroll-btn { right: 30px; }
@media (max-width: 992px) { #gep-fixed-scroll-btn { bottom: 120px; right: 14px; } }

/* ── Passage (phone): no empty strip on top, header never covers the text ── */
@media (max-width: 992px) {
	html body #gep-active-passage-pane { padding-top: 0 !important; }
	html body #gep-active-passage-pane #gep-passage-toggle {
		position: relative !important; top: auto !important; margin-top: 0 !important;
	}
}
html body #gep-active-passage-pane { position: relative; }
#gep-passage-view-btn {
	position: absolute; bottom: 10px; right: 12px; z-index: 60 !important;
	box-shadow: 0 4px 12px rgba(15, 23, 42, .15);
	padding: 5px 10px; border-radius: 8px; border: 1px solid #c7d2fe;
	background: #eef2ff; color: #3730a3; font-weight: 800; font-size: 12px; cursor: pointer;
}
#gep-active-passage-pane.collapsed #gep-passage-view-btn { display: none; }
#gep-passage-modal {
	position: fixed; inset: 0; z-index: 100050; background: rgba(15, 23, 42, .6);
	display: none; align-items: stretch; justify-content: center; padding: 12px;
}
#gep-passage-modal.open { display: flex; }
#gep-passage-modal .gpm-box {
	background: #fff; color: #0f172a; width: min(900px, 100%); border-radius: 16px;
	display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
#gep-passage-modal .gpm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #e2e8f0; font-weight: 800; }
#gep-passage-modal .gpm-head button { border: 0; background: #f1f5f9; border-radius: 10px; padding: 6px 12px; font-weight: 800; cursor: pointer; }
#gep-passage-modal .gpm-body { flex: 1; overflow-y: auto; padding: 18px 20px; font-size: 18px; line-height: 1.8; -webkit-overflow-scrolling: touch; }
#gep-passage-modal .gpm-body .en-text:not(.active), #gep-passage-modal .gpm-body .hi-text:not(.active) { display: none; }
:root[data-gep-theme="dark"] #gep-passage-modal .gpm-box { background: #111827; color: #e5e7eb; }
:root[data-gep-theme="dark"] #gep-passage-modal .gpm-head { border-color: #1f2937; }
:root[data-gep-theme="dark"] #gep-passage-modal .gpm-head button { background: #1f2937; color: #e5e7eb; }
:root[data-gep-theme="dark"] #gep-passage-view-btn { background: rgba(99,102,241,.2); color: #c7d2fe; border-color: rgba(99,102,241,.5); }

/* Instructions: test-language box in dark mode */
:root[data-gep-theme="dark"] .gep-test-lang-choice { background: rgba(99,102,241,.14) !important; border-color: rgba(99,102,241,.4) !important; color: #e0e7ff !important; }
:root[data-gep-theme="dark"] .gep-test-lang-choice div { color: #c7d2fe !important; }

/* ── Test series overview: readable in dark mode ────────────────────────── */
:root[data-gep-theme="dark"] .gep-series-title,
:root[data-gep-theme="dark"] .gep-series-category-section h3,
:root[data-gep-theme="dark"] .gep-series-category-section [style*="color: #0f172a"],
:root[data-gep-theme="dark"] .gep-series-category-section [style*="color: #1e293b"] { color: #e5e7eb !important; }
:root[data-gep-theme="dark"] .gep-series-category-section h3 { border-bottom-color: #334155 !important; }

/* Table scroll-shadows were painted with white — visible as white bars in dark mode */
:root[data-gep-theme="dark"] .gep-table-scroll {
	background:
		linear-gradient(to right, #111827 30%, rgba(17,24,39,0)) left center / 24px 100% no-repeat local,
		linear-gradient(to left,  #111827 30%, rgba(17,24,39,0)) right center / 24px 100% no-repeat local,
		linear-gradient(to right, rgba(0,0,0,.45), rgba(0,0,0,0)) left center / 14px 100% no-repeat scroll,
		linear-gradient(to left,  rgba(0,0,0,.45), rgba(0,0,0,0)) right center / 14px 100% no-repeat scroll !important;
}
:root[data-gep-theme="dark"] .gep-q-content table :is(td, th),
:root[data-gep-theme="dark"] .gep-passage-content table :is(td, th),
:root[data-gep-theme="dark"] #gep-passage-body table :is(td, th) { border-color: #334155 !important; color: #e5e7eb !important; background: transparent !important; }
:root[data-gep-theme="dark"] .gep-q-content table th { background: #1f2937 !important; }

/* Dark mode: question / solution tables were dark text on a dark page
   (cells carry their own dark colour from the editor / Word paste). */
:root[data-gep-theme="dark"] :is(.gep-result-wrap, .gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, .gep-exp-body, .gep-qr-text, #gep-passage-modal) table :is(td, th) {
	color: #e5e7eb !important;
	background-color: transparent !important;
	border-color: #334155 !important;
}
:root[data-gep-theme="dark"] :is(.gep-result-wrap, .gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, .gep-exp-body, .gep-qr-text, #gep-passage-modal) table :is(td, th) * {
	color: inherit !important;
	background-color: transparent !important;
}
:root[data-gep-theme="dark"] :is(.gep-result-wrap, .gep-q-content, .gep-q-text-wrapper) table th,
:root[data-gep-theme="dark"] :is(.gep-result-wrap, .gep-q-content, .gep-q-text-wrapper) table tr:first-child td { background-color: rgba(148, 163, 184, .08) !important; }

/* ── Palette spacing on laptops: less empty space around the numbers ───── */
@media (min-width: 993px) {
	html body #gep-exam-sidebar:not(.gep-pal-hidden) { padding: 14px 12px !important; }
	html body #gep-exam-sidebar .gep-palette-legend { margin: 4px 0 6px !important; padding: 8px 0 !important; }
	html body #gep-exam-sidebar .gep-palette-grid-container { padding: 2px 2px 6px !important; }
	html body #gep-exam-sidebar .gep-palette-section-title { margin: 6px 0 8px !important; }
	html body #gep-exam-sidebar .gep-palette-grid { margin: 0 0 14px !important; gap: 6px !important; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)) !important; }
	html body #gep-exam-sidebar .gep-sidebar-bottom-actions { padding: 8px 2px 0 !important; }
}

/* Outer border of question tables during the test (solutions already had one) */
html body :is(.gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, #gep-passage-modal) table {
	border: 1px solid #cbd5e1 !important;
	border-collapse: collapse !important;
	/* gep-exam.css gave tables overflow:hidden + radius; with collapsed borders
	   that clipped the outer half of the border, so no frame was visible. */
	overflow: visible !important;
	border-radius: 0 !important;
}
html body .gep-table-scroll, html body .gep-table-wrap { padding: 1px; }
html body :is(.gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, #gep-passage-modal) table :is(td, th) {
	border: 1px solid #e2e8f0 !important;
}
:root[data-gep-theme="dark"] :is(.gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, #gep-passage-modal) table { border-color: #475569 !important; }
:root[data-gep-theme="dark"] :is(.gep-q-content, .gep-q-text-wrapper, .gep-passage-content, #gep-passage-body, #gep-passage-modal) table :is(td, th) { border-color: #334155 !important; }

/* ── Passage: tables and images in proper boxes (exam, popup, solutions) ─── */
html body :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) img {
	display: block;
	max-width: 100% !important;
	height: auto !important;
	margin: 10px 0;
	padding: 4px;
	border: 1px solid #cbd5e1;
	border-radius: 10px;
	background: #fff;
}
:root[data-gep-theme="dark"] :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) img { border-color: #475569; background: #0b1220; }
html body :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) table {
	border: 1px solid #cbd5e1 !important;
	border-collapse: collapse !important;
	overflow: visible !important;
	margin: 10px 0 !important;
	width: auto !important;
	max-width: 100% !important;
}
html body :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) table :is(td, th) {
	border: 1px solid #e2e8f0 !important;
	padding: 8px 12px !important;
	width: auto !important;
	word-break: normal !important;
	overflow-wrap: normal !important;
}
:root[data-gep-theme="dark"] :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) table { border-color: #475569 !important; }
:root[data-gep-theme="dark"] :is(.gep-passage-content, #gep-passage-body, #gep-passage-modal .gpm-body, .gep-rr-passage, .gep-passage-box, .gep-qr-passage-column) table :is(td, th) { border-color: #334155 !important; color: #e5e7eb !important; background: transparent !important; }

/* Rich passage text (admin full editor): headings, lists, quotes keep their shape
   inside the exam passage pane, the phone "View" popup and the result page. */
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) :is(h1, h2, h3, h4) {
  font-weight: 800; line-height: 1.3; margin: 0.9em 0 0.45em; color: inherit;
}
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) h1 { font-size: 1.45em; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) h2 { font-size: 1.3em; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) h3 { font-size: 1.15em; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) h4 { font-size: 1.05em; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) ul { list-style: disc !important; padding-left: 1.5em !important; margin: 0.5em 0 !important; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) ol { list-style: decimal !important; padding-left: 1.5em !important; margin: 0.5em 0 !important; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) li { display: list-item !important; margin: 0.2em 0; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) blockquote { border-left: 3px solid var(--gep-c-border, #cbd5e1); margin: 0.6em 0; padding: 0.2em 0 0.2em 0.9em; }
html body :is(#gep-passage-body, .gep-passage-content, #gep-passage-modal, .gep-qr-passage-column) :is(strong, b) { font-weight: 800; }
