/*
 * Wavefronts Playground — main stylesheet.
 *
 * Academic-styled layout for diagram input, controls, and output panels.
 * Theme overrides at the bottom re-skin the palette to match the suite shell.
 */

/* ── Design tokens ──────────────────────────────────────────────── */
: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;
}

/* ── Reset & body ───────────────────────────────────────────────── */
* {
	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;
}

.suite-nav {
	display: flex;
	gap: 8px;
	justify-content: center;
	flex-wrap: wrap;
	margin-bottom: 1rem;
}

.suite-nav a {
	display: inline-block;
	text-decoration: none;
	border: 2px solid #2f2f2f;
	border-radius: 8px;
	padding: 6px 10px;
	color: #1f1f1f;
	background: #fff;
	font-weight: 700;
	font-size: 0.9rem;
}

.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 grid layout ───────────────────────────────────────────── */
.main-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 170px 170px minmax(0, 1fr);
	grid-template-areas:
		"leftInput control control rightInput"
		"leftDiagram leftDiagram rightDiagram rightDiagram";
	column-gap: 2rem;
	row-gap: 1.5rem;
	min-height: 600px;
}

.left-input-panel,
.right-input-panel,
.left-diagram-panel,
.right-diagram-panel {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.left-input-panel { grid-area: leftInput; }
.right-input-panel { grid-area: rightInput; }
.left-diagram-panel { grid-area: leftDiagram; }
.right-diagram-panel { grid-area: rightDiagram; }

.center-panel {
	grid-area: control;
	display: flex;
	justify-content: center;
	align-items: stretch;
	align-self: start;
	min-width: 0;
}

.center-panel .control-card {
	width: 100%;
	height: 100%;
}

/* ── 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;
}

/* ── Control panel ──────────────────────────────────────────────── */
.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 {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.lie-type-select {
	width: 100%;
	padding: 0.7rem 0.8rem;
	border: 2px solid var(--medium-gray);
	border-radius: var(--border-radius);
	font-size: 0.95rem;
	background: #fff;
}

.parameter-size-row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.parameter-size-row label {
	margin: 0;
	white-space: nowrap;
	font-weight: 600;
	color: var(--primary-color);
}

.parameter-size-input {
	width: 88px;
	padding: 0.7rem 0.8rem;
	border: 2px solid var(--medium-gray);
	border-radius: var(--border-radius);
	font-size: 0.95rem;
	background: #fff;
}

.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.small {
	padding: 0.25rem 0.75rem;
	font-size: 0.85rem;
}

.btn.secondary {
	background-color: var(--dark-gray);
	color: white;
}

.btn.secondary:hover {
	background-color: #5a6268;
}

.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 ─────────────────────────────────────────── */
.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;
	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;
}

.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 ───────────────────────────────────────────────── */
.diagram {
	flex: 1;
	padding: 1.5rem;
	overflow: auto;
	max-height: 500px;
	min-height: 300px;
	width: 100%;
	contain: content;
	overflow-x: auto;
	overflow-y: auto;
	box-sizing: border-box;
}

.signed-young-diagram {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	width: auto;
	min-width: 0;
	max-width: 100%;
}

.row {
	display: flex;
	gap: 0.5rem;
	flex-wrap: nowrap;
	min-height: 50px;
	transition: var(--transition);
	padding: 0.5rem;
	border-radius: 4px;
	flex-shrink: 0;
	width: fit-content;
	min-width: 100%;
	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 cells ──────────────────────────────────────────────────── */
.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;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
	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);
}

.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;
}

.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 ───────────────────────────────────────────── */
.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);
}

.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);
}

/* ── Diagram editor modal ───────────────────────────────────────── */
.diagram-editor-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: none;
	z-index: 200;
}

.diagram-editor-overlay.active {
	display: block;
}

.diagram-editor {
	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: 700px;
	max-height: 80vh;
	display: none;
	flex-direction: column;
	z-index: 201;
}

.diagram-editor.active {
	display: flex;
}

.diagram-editor-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--medium-gray);
	background: var(--primary-color);
	color: white;
	border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.diagram-editor-title {
	margin: 0;
	color: white;
	font-size: 1.3rem;
}

.diagram-editor-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);
}

.diagram-editor-close:hover {
	background: rgba(255, 255, 255, 0.2);
}

.diagram-editor-content {
	padding: 1.5rem;
	overflow-y: auto;
	flex: 1;
}

.editor-rows {
	margin-bottom: 1rem;
}

.editor-row-item {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1rem;
	padding: 0.75rem;
	background: var(--light-gray);
	border-radius: 4px;
}

/* ── Editor Lie-type selector ───────────────────────────────────── */
.editor-lie-type {
	margin-bottom: 1.5rem;
	padding: 0.5rem;
	background: var(--light-gray);
	border-radius: 4px;
	display: flex;
	align-items: center;
	gap: 1rem;
}

.editor-lie-type label {
	font-weight: 600;
	color: var(--primary-color);
}

.editor-lie-type select {
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--medium-gray);
	border-radius: 4px;
	font-size: 0.95rem;
}

/* ── Editor error message ───────────────────────────────────────── */
.editor-error {
	margin-top: 1rem;
	padding: 0.75rem;
	background-color: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	font-weight: 500;
	display: none;
}

.row-length-control {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.row-length-value {
	min-width: 40px;
	text-align: center;
	font-weight: bold;
}

.sign-toggle {
	min-width: 40px;
	padding: 0.25rem 0.5rem;
	font-weight: bold;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 1.1rem;
}

.sign-toggle.plus {
	background-color: #2d7ff9;
	color: #ffffff;
	border: 2px solid #2f2f2f;
}

.sign-toggle.minus {
	background-color: #d64545;
	color: #ffffff;
	border: 2px solid #2f2f2f;
}

.add-row {
	width: 100%;
	margin-top: 1rem;
}

.diagram-editor-footer {
	display: flex;
	justify-content: flex-end;
	gap: 1rem;
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--medium-gray);
	background: var(--light-gray);
	border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* ── Responsive breakpoints ─────────────────────────────────────── */
@media (max-width: 1200px) {
	.main-layout {
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"leftInput rightInput"
			"control control"
			"leftDiagram rightDiagram";
		gap: 1.5rem;
	}

	.center-panel .control-card {
		width: min(100%, 420px);
	}

	.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 {
		grid-template-columns: 1fr;
		grid-template-areas:
			"leftInput"
			"rightInput"
			"control"
			"leftDiagram"
			"rightDiagram";
		gap: 1rem;
	}

	.diagram-header {
		flex-direction: column;
		gap: 0.5rem;
		align-items: flex-start;
	}

	.box {
		width: 40px;
		height: 40px;
		font-size: 1rem;
	}

	.annotation-display,
	.diagram-editor {
		width: 95%;
	}
}

/* ── Print styles ───────────────────────────────────────────────── */
@media print {

	.btn,
	.info-icon,
	.click-hint,
	.annotation-overlay,
	.annotation-display,
	.diagram-editor-overlay,
	.diagram-editor {
		display: none !important;
	}

	.diagram {
		overflow: visible !important;
		max-height: none !important;
	}

	.box:hover {
		transform: none !important;
	}
}

/* ── Theme override (suite palette) ─────────────────────────────── */
:root {
	--primary-color: #1f1f1f;
	--secondary-color: #1d6f5f;
	--accent-color: #f4d35e;
	--success-color: #1d6f5f;
	--danger-color: #b00020;
	--light-gray: #fffaf0;
	--medium-gray: #e9decb;
	--dark-gray: #4f4f4f;
	--border-radius: 10px;
	--box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.12);
	--box-shadow-hover: 10px 10px 0 rgba(0, 0, 0, 0.15);
	--transition: all 0.24s ease;
	--academic-font: Georgia, "Times New Roman", serif;
	--sans-font: Georgia, "Times New Roman", serif;
}

body {
	background:
		radial-gradient(circle at 10% 20%, #e7f6f2 0, transparent 35%),
		radial-gradient(circle at 90% 80%, #fde2c9 0, transparent 30%),
		#f3efe5;
	color: var(--primary-color);
	max-width: 1800px;
}

header,
.input-group,
.control-card,
.diagram-container,
.detail-card {
	background: #fff;
	border: 2px solid #2f2f2f;
	box-shadow: var(--box-shadow);
	border-radius: var(--border-radius);
}

header {
	background: var(--light-gray);
}

h1 {
	letter-spacing: 0.03em;
	border-bottom: 2px solid #2f2f2f;
}

.paper-reference {
	background: #fff;
	border: 2px solid #2f2f2f;
	border-left: 6px solid var(--secondary-color);
}

.panel-header,
.diagram-editor-header,
.annotation-display-header {
	background: #fff;
	color: var(--primary-color);
	border: 2px solid #2f2f2f;
}

.panel-title,
.diagram-editor-title,
.annotation-display-title {
	color: var(--primary-color);
}

.info-icon {
	background: #f3efe5;
	border: 1px solid #2f2f2f;
	color: var(--primary-color);
}

input,
select,
.input-group input,
.editor-lie-type select {
	border: 2px solid #2f2f2f;
	border-radius: 8px;
	background: #fff;
}

.btn {
	border: 2px solid #2f2f2f;
	border-radius: 8px;
	font-weight: 700;
	transform: none;
	box-shadow: none;
}

.btn.primary,
.btn.success {
	background: var(--secondary-color);
	color: #fff;
}

.btn.primary:hover,
.btn.success:hover {
	background: #165547;
	transform: none;
	box-shadow: none;
}

.btn.secondary {
	background: #666;
	color: #fff;
}

.btn.danger {
	background: var(--danger-color);
	color: #fff;
}

.diagram-header {
	background: #fffaf0;
	border-bottom: 2px solid #2f2f2f;
}

.row:hover {
	background-color: rgba(29, 111, 95, 0.08);
}

.row.selected {
	background-color: rgba(29, 111, 95, 0.16);
	border: 2px solid var(--secondary-color);
}

.box {
	border: 2px solid #2f2f2f;
	border-radius: 6px;
	box-shadow: none;
}

.box.plus {
	background: #cfe0ff;
	color: #0f2a60;
	border-color: #2f2f2f;
}

.box.minus {
	background: #ffd0d0;
	color: #5c1414;
	border-color: #2f2f2f;
}

.box sub {
	color: #1f1f1f;
	opacity: 0.9;
}

.annotation-display-content,
.editor-row-item,
.editor-lie-type,
.diagram-editor-footer {
	background: #fffaf0;
}