/* CSS Variables for dynamic theme customization */
:root {
	--text-color: #FFFFFF; /* Text color for prompter display */
	--bg-color: #000000; /* Background color for prompter display */
	--font-size: 60px; /* Font size for prompter text */
	--highlight-color: #FF0000; /* Color for center highlight line */
}

/* Base body styling and layout */
body {
	margin: 0;
	font-family: 'Meiryo', 'Hiragino Kaku Gothic ProN', sans-serif;
	background-color: #f0f0f0;
	color: #333;
	display: flex;
	flex-direction: column;
	height: 100vh;
	overflow: hidden; /* Prevent scrollbars during prompter mode */
}

/* Control panel container - visible in setup mode */
.controls {
	padding: 15px;
	background-color: #fff;
	border-bottom: 1px solid #ccc;
	flex-shrink: 0;
	overflow-y: auto; /* Allow scrolling if content is too tall */
}

/* Grid layout for control elements */
.controls-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 10px;
	align-items: center;
}

/* Individual control group styling */
.control-group {
	display: flex;
	flex-direction: column;
}

/* Label styling for controls */
.control-group label {
	margin-bottom: 5px;
	font-size: 14px;
	font-weight: 500;
}

/* Script input textarea styling */
textarea {
	width: 100%;
	height: 100px;
	box-sizing: border-box;
	font-size: 16px;
	padding: 5px;
	border: 1px solid #ccc;
	border-radius: 4px;
	resize: vertical; /* Allow vertical resizing only */
	font-family: inherit;
}

/* Interactive element cursor styling */
input[type="range"],
input[type="color"],
button {
	cursor: pointer;
}

/* Main button container */
.main-buttons {
	display: flex;
	gap: 10px;
	margin-top: 10px;
	flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Button base styling */
button {
	padding: 10px 15px;
	font-size: 16px;
	border: none;
	border-radius: 5px;
	background-color: #007bff;
	color: white;
	transition: background-color 0.2s ease;
	min-width: 100px; /* Ensure consistent button sizes */
}

/* Button hover effects */
button:hover {
	background-color: #0056b3;
}

/* Reset button specific styling */
button#reset-button {
	background-color: #6c757d;
}

button#reset-button:hover {
	background-color: #5a6268;
}

/* Main prompter container - hidden by default */
.prompter-container {
	flex-grow: 1;
	background-color: var(--bg-color);
	color: var(--text-color);
	font-size: var(--font-size);
	line-height: 1.5;
	overflow: hidden;
	position: relative;
	display: none; /* Initially hidden until prompter starts */
	transition: transform 0.3s ease;
}

/* Mirror mode transformation */
.prompter-container.mirrored {
	transform: scaleX(-1); /* Flip horizontally for teleprompter mirror setup */
}

/* Scrolling text content container */
.prompter-content {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	padding: 50vh 20px; /* Top/bottom padding centers first and last lines */
	transform: translateY(0);
	transition: transform linear;
	white-space: pre-wrap; /* Preserve line breaks and spacing */
}

/* Counter-transform text when mirrored to maintain readability */
.prompter-content.mirrored p {
	transform: scaleX(-1);
}

/* Individual paragraph styling in prompter */
.prompter-content p {
	margin: 0;
	padding: 0;
	transition: opacity 0.3s ease;
}

/* Center highlight line for reading guidance */
.highlight-line {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 3px;
	background-color: var(--highlight-color);
	transform: translateY(-50%);
	opacity: 0.7;
	z-index: 5;
}

/* Gradient overlay for visual fade effect */
.prompter-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(
			to bottom,
			var(--bg-color) 0%,
			transparent 30%,
			transparent 70%,
			var(--bg-color) 100%
	);
	pointer-events: none; /* Allow clicks to pass through */
	z-index: 1;
}

/* Timer display in prompter mode */
.prompter-info {
	position: fixed;
	top: 10px;
	right: 20px;
	font-size: 24px;
	color: var(--text-color);
	background-color: rgba(0, 0, 0, 0.5);
	padding: 5px 15px;
	border-radius: 5px;
	z-index: 10;
	font-family: 'Courier New', monospace; /* Monospace for consistent timer display */
}

/* End of speech notification */
.end-guide {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 24px;
	color: var(--text-color);
	background-color: rgba(0, 0, 0, 0.8);
	padding: 20px 40px;
	border-radius: 10px;
	text-align: center;
	display: none;
	z-index: 20;
	max-width: 80%;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Countdown display before speech starts */
.countdown-display {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 120px;
	color: var(--text-color);
	background-color: rgba(0, 0, 0, 0.6);
	padding: 40px 80px;
	border-radius: 20px;
	text-align: center;
	display: none;
	z-index: 20;
	text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
	font-weight: bold;
	border: 3px solid var(--text-color);
}

/* Estimated reading time display */
.estimated-time {
	margin-top: 10px;
	padding: 10px;
	background-color: #e9ecef;
	border-radius: 5px;
	font-size: 14px;
	color: #333;
	border-left: 4px solid #007bff;
}

/* Color preview section for theme testing */
.color-preview {
	margin-top: 5px;
	padding: 20px;
	border: 1px solid #ccc;
	border-radius: 5px;
	text-align: center;
	font-size: 20px;
	transition: all 0.3s ease;
	line-height: 1.5;
	overflow: hidden;
	max-height: 150px;
	font-weight: 500;
}

/* Main heading styling */
h1 {
	font-size: 18px;
	margin: 0 0 15px 0;
	color: #333;
	font-weight: 600;
}

/* Usage information text */
.main-info {
	margin-top: 10px;
	font-size: 12px;
	color: #666;
	font-style: italic;
}

/* Range input styling for better appearance */
input[type="range"] {
	width: 100%;
	height: 8px;
	border-radius: 4px;
	background: #ddd;
	outline: none;
	opacity: 0.7;
	transition: opacity 0.2s;
}

input[type="range"]:hover {
	opacity: 1;
}

/* Color input styling */
input[type="color"] {
	width: 50px;
	height: 35px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
	.controls-grid {
		grid-template-columns: 1fr; /* Single column on mobile */
	}

	.main-buttons {
		flex-direction: column; /* Stack buttons vertically */
	}

	button {
		width: 100%; /* Full width buttons on mobile */
	}

	.prompter-info {
		font-size: 18px; /* Smaller timer on mobile */
		top: 5px;
		right: 10px;
	}

	.countdown-display {
		font-size: 80px; /* Smaller countdown on mobile */
		padding: 20px 40px;
	}

	.end-guide {
		font-size: 18px; /* Smaller end guide on mobile */
		padding: 15px 25px;
	}
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	.controls {
		border-bottom: 2px solid #000;
	}

	button {
		border: 2px solid #000;
	}

	.highlight-line {
		height: 5px;
		opacity: 1;
	}
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	.prompter-content {
		transition: none;
	}

	.prompter-container {
		transition: none;
	}

	button {
		transition: none;
	}

	.color-preview {
		transition: none;
	}
}