/* Modern Academic Style CSS for Wavefronts Playground */

/* Base Styles & Variables */
:root {
	--primary-color: #2c3e50;
	--secondary-color: #3498db;
	--accent-color: #8e44ad;
	--success-color: #27ae60;
	--danger-color: #e74c3c;
	--light-gray: #f8f9fa;
	--medium-gray: #e9ecef;
	--dark-gray: #6c757d;
	--border-radius: 8px;
	--box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
	--box-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
	--transition: all 0.3s ease;
	--academic-font: 'Times New Roman', Times, serif;
	--sans-font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: var(--sans-font);
	line-height: 1.6;
	color: #333;
	background-color: #fefefe;
	padding: 20px;
	max-width: 1600px;
	margin: 0 auto;
}

/* Typography */
h1,
h2,
h3,
h4 {
	font-family: var(--academic-font);
	font-weight: 600;
	color: var(--primary-color);
	margin-bottom: 0.75rem;
}

h1 {
	font-size: 2.5rem;
	text-align: center;
	margin-bottom: 1rem;
	border-bottom: 2px solid var(--medium-gray);
	padding-bottom: 1rem;
}

h2 {
	font-size: 1.75rem;
}

h3 {
	font-size: 1.4rem;
}

h4 {
	font-size: 1.1rem;
}

p {
	margin-bottom: 1rem;
}

strong {
	color: var(--primary-color);
	font-weight: 600;
}

em {
	font-style: italic;
}

/* Container Layout */
.container {
	display: flex;
	flex-direction: column;
	gap: 2rem;
}

/* Header Section */
header {
	background: white;
	padding: 2rem;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
	margin-bottom: 1rem;
}

.description {
	font-size: 1.1rem;
	color: #555;
	margin-bottom: 1.5rem;
	text-align: center;
	max-width: 900px;
	margin-left: auto;
	margin-right: auto;
}

.paper-reference {
	background-color: var(--light-gray);
	border-left: 4px solid var(--secondary-color);
	padding: 1.5rem;
	border-radius: var(--border-radius);
	margin-top: 1.5rem;
}

blockquote {
	font-style: italic;
	color: #555;
	margin-bottom: 1.5rem;
	padding-right: 1rem;
}

.paper-details {
	display: flex;
	gap: 1.5rem;
	flex-wrap: wrap;
	justify-content: center;
	margin-top: 1.5rem;
}

.detail-card {
	background: white;
	padding: 1.25rem;
	border-radius: var(--border-radius);
	flex: 1;
	min-width: 250px;
	max-width: 350px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	border-top: 3px solid var(--secondary-color);
}

.detail-card h4 {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.75rem;
}

/* Main Layout */
.main-layout {
	display: grid;
	grid-template-columns: 1fr 320px 1fr;
	gap: 2rem;
	min-height: 600px;
}

.left-panel,
.center-panel,
.right-panel {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
	/* This ensures panels don't expand beyond their allocated space */
	min-width: 0;
}

/* Panel Headers */
.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: var(--primary-color);
	color: white;
	padding: 1rem 1.5rem;
	border-radius: var(--border-radius);
}

.panel-title {
	color: white;
	margin: 0;
	font-size: 1.4rem;
}

.info-icon {
	background: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: help;
	font-size: 0.9rem;
}

/* Input Groups */
.input-group {
	background: white;
	padding: 1.5rem;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
}

.input-group label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.5rem;
	color: var(--primary-color);
}

.input-group input {
	width: 100%;
	padding: 0.75rem;
	border: 1px solid var(--medium-gray);
	border-radius: 4px;
	font-size: 1rem;
	margin-bottom: 1.25rem;
	transition: var(--transition);
}

.input-group input:focus {
	outline: none;
	border-color: var(--secondary-color);
	box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.conditional-label {
	display: none;
}

/* Center Panel - Controls */
.control-card {
	background: white;
	padding: 1.5rem;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
}

.control-title {
	text-align: center;
	margin-bottom: 1.5rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--medium-gray);
}

.lie-type-selector h4 {
	margin-bottom: 1rem;
}

.lie-type-buttons {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.lie-type-option {
	border: 2px solid var(--medium-gray);
	border-radius: var(--border-radius);
	padding: 1rem;
	cursor: pointer;
	transition: var(--transition);
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.lie-type-option:hover {
	border-color: var(--secondary-color);
	background-color: rgba(52, 152, 219, 0.05);
}

.lie-type-option input[type="radio"] {
	margin: 0;
}

.lie-type-label {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.lie-type-label strong {
	font-size: 1.1rem;
}

.lie-type-label small {
	color: var(--dark-gray);
	font-size: 0.85rem;
}

.action-buttons {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.btn {
	padding: 0.875rem 1.25rem;
	border: none;
	border-radius: var(--border-radius);
	font-weight: 600;
	cursor: pointer;
	transition: var(--transition);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	font-size: 0.95rem;
}

.btn.primary {
	background-color: var(--secondary-color);
	color: white;
}

.btn.primary:hover {
	background-color: #2980b9;
	transform: translateY(-2px);
	box-shadow: var(--box-shadow);
}

.btn.success {
	background-color: var(--success-color);
	color: white;
}

.btn.success:hover {
	background-color: #219653;
	transform: translateY(-2px);
	box-shadow: var(--box-shadow);
}

.btn.danger {
	background-color: var(--danger-color);
	color: white;
}

.btn.danger:hover {
	background-color: #c0392b;
	transform: translateY(-2px);
	box-shadow: var(--box-shadow);
}

/* Diagram Containers - FIXED: Proper width constraint and scrolling */
.diagram-container {
	background: white;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 400px;
	/* CRITICAL: Constrain width and prevent expansion */
	width: 100%;
	max-width: 100%;
	position: relative;
}

.diagram-header {
	background: var(--light-gray);
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--medium-gray);
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
	/* Prevent header from shrinking */
}

.diagram-title {
	margin: 0;
	font-size: 1.3rem;
}

.click-hint {
	font-size: 0.85rem;
	color: var(--dark-gray);
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

/* Diagram Area with Fixed Dimensions and Scroll - COMPLETELY FIXED */
.diagram {
	flex: 1;
	padding: 1.5rem;
	/* Force scrollbars when content overflows */
	overflow: auto;
	max-height: 500px;
	min-height: 300px;
	/* Constrain width to parent */
	width: 100%;
	/* Important: Contain the content */
	contain: content;
	/* Enable both scrolling directions */
	overflow-x: auto;
	overflow-y: auto;
	/* This ensures the scroll container is properly sized */
	box-sizing: border-box;
}

/* Container for the diagram - this is the key fix */
.signed-young-diagram {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	/* CRITICAL FIX: This container should NOT expand beyond diagram width */
	width: auto;
	min-width: 0;
	/* Allow shrinking */
	max-width: 100%;
	/* Prevent expanding beyond parent */
}

/* Row Styles - Fixed for horizontal scrolling */
.row {
	display: flex;
	gap: 0.5rem;
	flex-wrap: nowrap;
	min-height: 50px;
	transition: var(--transition);
	padding: 0.5rem;
	border-radius: 4px;
	/* Prevent rows from shrinking or expanding container */
	flex-shrink: 0;
	/* Allow row to be as wide as its content but contained by parent */
	width: fit-content;
	min-width: 100%;
	/* Make row at least as wide as the diagram */
	/* Ensure row doesn't push container wider */
	box-sizing: border-box;
}

.row:hover {
	background-color: rgba(52, 152, 219, 0.05);
}

.row.selected {
	background-color: rgba(52, 152, 219, 0.1);
	border: 2px solid var(--secondary-color);
}

/* Box Styles with Hover Effect - FIXED for light inner/strong boundary */
.box {
	width: 50px;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: bold;
	font-size: 1.2rem;
	border-radius: 6px;
	transition: var(--transition);
	position: relative;
	cursor: pointer;
	flex-shrink: 0;
	/* Prevent boxes from shrinking */
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
	/* Light inner, strong boundary */
	background-color: rgba(255, 255, 255, 0.95);
	border-width: 3px;
	border-style: solid;
}

.box:hover {
	transform: scale(1.4);
	z-index: 10;
	box-shadow: var(--box-shadow-hover);
}

/* Plus boxes with light blue interior and strong blue border */
.box.plus {
	background-color: rgba(173, 216, 230, 0.3);
	color: #2c5282;
	border-color: #3498db;
	border-width: 3px;
}

.box.plus:hover {
	background-color: rgba(173, 216, 230, 0.6);
	border-color: #2980b9;
}

/* Minus boxes with light red interior and strong red border */
.box.minus {
	background-color: rgba(255, 200, 200, 0.3);
	color: #c53030;
	border-color: #e74c3c;
	border-width: 3px;
}

.box.minus:hover {
	background-color: rgba(255, 200, 200, 0.6);
	border-color: #c0392b;
}

.box sub {
	position: absolute;
	bottom: 2px;
	right: 2px;
	font-size: 0.6rem;
	opacity: 0.9;
	color: #666;
}

/* Custom scrollbar styling for better UX */
.diagram::-webkit-scrollbar {
	height: 12px;
	width: 12px;
}

.diagram::-webkit-scrollbar-track {
	background: var(--light-gray);
	border-radius: 6px;
}

.diagram::-webkit-scrollbar-thumb {
	background: var(--dark-gray);
	border-radius: 6px;
	border: 3px solid var(--light-gray);
}

.diagram::-webkit-scrollbar-thumb:hover {
	background: #555;
}

.diagram::-webkit-scrollbar-corner {
	background: var(--light-gray);
}

/* For Firefox */
.diagram {
	scrollbar-width: thin;
	scrollbar-color: var(--dark-gray) var(--light-gray);
}

/* Annotation Overlay */
.annotation-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: none;
	z-index: 100;
}

.annotation-overlay.active {
	display: block;
}

.annotation-display {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: white;
	border-radius: var(--border-radius);
	box-shadow: var(--box-shadow-hover);
	width: 90%;
	max-width: 500px;
	z-index: 101;
	display: none;
}

.annotation-display.active {
	display: block;
}

.annotation-display-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1.25rem;
	border-bottom: 1px solid var(--medium-gray);
	background: var(--primary-color);
	color: white;
	border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.annotation-display-title {
	margin: 0;
	color: white;
	font-size: 1.3rem;
}

.annotation-display-close {
	background: none;
	border: none;
	color: white;
	font-size: 1.8rem;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: var(--transition);
}

.annotation-display-close:hover {
	background: rgba(255, 255, 255, 0.2);
}

.annotation-display-content {
	padding: 1.5rem;
	max-height: 400px;
	overflow: auto;
	font-family: 'Courier New', monospace;
	background-color: #f8f9fa;
	border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Responsive Design */
@media (max-width: 1200px) {
	.main-layout {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto auto;
		gap: 1.5rem;
	}

	.center-panel {
		order: -1;
	}

	.paper-details {
		flex-direction: column;
		align-items: center;
	}

	.detail-card {
		width: 100%;
		max-width: 100%;
	}
}

@media (max-width: 768px) {
	body {
		padding: 10px;
	}

	h1 {
		font-size: 2rem;
	}

	.main-layout {
		gap: 1rem;
	}

	.lie-type-buttons {
		grid-template-columns: 1fr;
	}

	.diagram-header {
		flex-direction: column;
		gap: 0.5rem;
		align-items: flex-start;
	}

	.box {
		width: 40px;
		height: 40px;
		font-size: 1rem;
	}

	.annotation-display {
		width: 95%;
	}
}

/* Print Styles */
@media print {

	.btn,
	.info-icon,
	.click-hint,
	.annotation-overlay,
	.annotation-display {
		display: none !important;
	}

	.diagram {
		overflow: visible !important;
		max-height: none !important;
	}

	.box:hover {
		transform: none !important;
	}
}