/*
 * File: css/student_games.css
 * Purpose: Styling for StudentGames (secure/classes/460__student_games.php).
 * Bright/playful palette deliberately distinct from the site's maroon/gold
 * chrome -- this is a kids' game surface, not a content page.
 */

.sg-set, .sg-game {
	font-family: inherit;
	max-width: 720px;
	margin: 1rem auto;
}

/* ---- Menu of games in a set ---- */
.sg-menu {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: center;
}

.sg-menu-card {
	position: relative;
	background: #fff9e8;
	border: 3px solid #f4c542;
	border-radius: 18px;
	padding: 1rem 1.2rem;
	width: 220px;
	text-align: center;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.sg-menu-card h4 {
	margin: 0.2rem 0 0.4rem;
	color: #2b6cb0;
}

.sg-menu-card p {
	font-size: 0.85rem;
	color: #555;
	min-height: 2.4em;
}

/* Attempted badge: small, corner-anchored, doesn't compete with the card's
   own content the way a banner or full-card overlay would. */
.sg-menu-attempted-badge {
	position: absolute;
	top: -10px;
	right: -10px;
	width: 26px;
	height: 26px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #38a169;
	color: #fff;
	border: 2px solid #fff9e8;
	border-radius: 50%;
	font-size: 0.9rem;
	font-weight: 700;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* .sg-menu-card p already sets min-height/color/font-size for the
   description -- this needs to out-specificity that, not just override it. */
.sg-menu-card p.sg-menu-recent-score {
	font-size: 0.8rem;
	font-weight: 700;
	color: #2f855a;
	min-height: 0;
	margin: -0.2rem 0 0.5rem;
}

.sg-play-btn {
	background: #38a169;
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: 0.5rem 1.4rem;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
}

.sg-play-btn:hover {
	background: #2f855a;
}

/* ---- A single game ---- */
.sg-game {
	position: relative;
	background: #f0f8ff;
	border-radius: 20px;
	padding: 1.2rem;
	padding-bottom: 2.4rem; /* room for the corner reset button, clear of feedback text */
	border: 3px solid #63b3ed;
}

/* Deliberately tucked away from Submit (small, muted, corner-anchored) so
   an accidental tap can't wipe out progress the way a same-size button
   sitting right next to Submit could. */
.sg-corner-reset-btn {
	position: absolute;
	bottom: 0.5rem;
	right: 0.7rem;
	background: transparent;
	border: 1px solid #a0aec0;
	color: #718096;
	border-radius: 999px;
	padding: 0.2rem 0.65rem;
	font-size: 0.7rem;
	cursor: pointer;
	opacity: 0.7;
}

.sg-corner-reset-btn:hover {
	opacity: 1;
	border-color: #718096;
}

.sg-back-btn {
	background: none;
	border: none;
	color: #2b6cb0;
	font-size: 0.9rem;
	cursor: pointer;
	padding: 0;
	margin-bottom: 0.5rem;
}

.sg-title {
	text-align: center;
	color: #2b6cb0;
	margin: 0 0 0.6rem;
}

.sg-score-bar {
	display: flex;
	justify-content: space-between;
	font-weight: 700;
	font-size: 1.1rem;
	margin-bottom: 0.8rem;
	color: #444;
}

.sg-timer-display {
	color: #c53030;
}

.sg-reference {
	text-align: center;
	margin-bottom: 1rem;
}

.sg-reference-img {
	max-width: 160px;
	max-height: 160px;
	border-radius: 14px;
	border: 3px solid #f4c542;
	background: #fff;
	padding: 6px;
}

.sg-play-audio-btn, .sg-option-audio-btn {
	background: #ecc94b;
	border: none;
	border-radius: 999px;
	padding: 0.4rem 0.9rem;
	font-size: 1rem;
	cursor: pointer;
	margin-top: 0.5rem;
}

/* ---- Instruction panel, between the reference and the options: calls
   attention to itself (color + icon) without competing with the game
   content -- soft fill, no heavy border/shadow, modest font size. ---- */
.sg-instruction {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	max-width: 90%;
	margin: 0 auto 1rem;
	padding: 0.5rem 1rem;
	background: #fffaf0;
	border-radius: 999px;
	font-size: 0.95rem;
	font-weight: 600;
	color: #975a16;
	text-align: center;
}

.sg-instruction::before {
	content: "👉";
	font-size: 1rem;
	flex: none;
}

.sg-options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.8rem;
	justify-content: center;
	margin-bottom: 1rem;
}

.sg-option {
	background: #fff;
	border: 3px solid #cbd5e0;
	border-radius: 14px;
	padding: 0.6rem;
	width: 120px;
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.sg-option:hover {
	transform: translateY(-2px);
	border-color: #63b3ed;
}

.sg-option.selected {
	border-color: #38a169;
	background: #e6fffa;
}

.sg-option img {
	max-width: 100%;
	max-height: 90px;
}

/* ---- Text field on a reference/option: overlaid on the image when one
   exists, otherwise a standalone styled box (see mediaHtml() in JS). ---- */
.sg-media {
	position: relative;
	display: inline-block;
}

.sg-media-text-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(255, 255, 255, 0.88);
	border-radius: 10px;
	/* Fixed units, not em -- padding must not scale with the item's own
	   font-size (e.g. a 15rem letter shouldn't drag in ~7rem of padding). */
	padding: 2px 8px;
	font-weight: 700;
	color: #2b6cb0;
	/* Unitless line-height also scales with font-size, and a font's default
	   ("normal") leading is often much taller still for complex scripts --
	   both look like extra padding around the glyph. Pin it to the glyph. */
	line-height: 1;
	/* line-height:1 still leaves the font's own ascent/descent allocation
	   (e.g. reserved space above a Telugu base letter for vowel signs it
	   isn't using) -- trim the box to the font's visual metrics instead.
	   Progressive enhancement: unsupported browsers just ignore this. */
	text-box-trim: trim-both;
	text-box-edge: cap alphabetic;
	white-space: nowrap;
	pointer-events: none;
}

.sg-reference .sg-media-text-overlay {
	font-size: 2.2rem;
}

.sg-option .sg-media-text-overlay {
	font-size: 1.3rem;
}

.sg-media-text-only {
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 100%;
	background: linear-gradient(135deg, #fff9e8, #ffe9b3);
	border: 3px solid #f4c542;
	border-radius: 14px;
	padding: 0.6rem;
	font-weight: 700;
	color: #2b6cb0;
	line-height: 1;
	text-box-trim: trim-both;
	text-box-edge: cap alphabetic;
	text-align: center;
	word-break: break-word;
}

.sg-reference .sg-media-text-only {
	font-size: 2.4rem;
	min-width: 160px;
	min-height: 160px;
}

.sg-option .sg-media-text-only {
	font-size: 1.5rem;
	width: 100%;
	min-height: 90px;
}

.sg-submit-btn, .sg-reset-btn {
	display: block;
	margin: 0 auto 0.6rem;
	background: #2b6cb0;
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: 0.6rem 2rem;
	font-size: 1.05rem;
	font-weight: 700;
	cursor: pointer;
}

.sg-submit-btn:disabled {
	opacity: 0.6;
	cursor: default;
}

.sg-reset-btn {
	background: #a0aec0;
}

.sg-feedback {
	text-align: center;
	font-size: 1.2rem;
	font-weight: 700;
	min-height: 1.6em;
}

.sg-feedback-correct {
	color: #2f855a;
}

.sg-feedback-incorrect {
	color: #c53030;
}

.sg-game-over {
	text-align: center;
}

.sg-game-over h4 {
	color: #2b6cb0;
	font-size: 1.4rem;
}

.sg-result-emoji {
	font-size: 5rem;
	line-height: 1;
	margin: 0.4rem 0;
}

.sg-result-emoji-sad {
	cursor: pointer;
	animation: sg-shake 0.6s ease-in-out infinite;
}

.sg-result-emoji-happy, .sg-result-emoji-perfect {
	animation: sg-bounce 0.9s ease-in-out infinite;
}

.sg-result-emoji-perfect {
	cursor: pointer;
}

.sg-result-message {
	font-size: 1.2rem;
	font-weight: 700;
	color: #2f855a;
	margin: 0 0 0.4rem;
}

@keyframes sg-shake {
	0%, 100% { transform: rotate(0deg); }
	25% { transform: rotate(-8deg); }
	75% { transform: rotate(8deg); }
}

@keyframes sg-bounce {
	0%, 100% { transform: translateY(0); }
	50% { transform: translateY(-14px); }
}
