/* Global */

:root {
	--primary: #0f766e;
	--primary-hover: #115e59;
	--primary-light: #ccfbf1;
	--primary-dark: #134e4a;
	--error: #a71f1f;
	--error-hightlight: #ffa7a7;
}

* {
	box-sizing: border-box;
	font-family: Inter, "Segoe UI", sans-serif;
}

html,
body {
	overflow: hidden;
	width: 100%;
	height: 100%;
}

h1,
h2,
div,
footer,
body {
	margin: 0;
	padding: 0;
}

h1 {
	font-size: 1.8rem;
}

h2 {
	font-size: 1.2rem;
}

hr {
	margin: 15px 0;
}

p::first-letter,
span::first-letter {
	text-transform: capitalize;
}

input[type="range"] {
	margin: 0.4rem 0;
	width: 100%;
	appearance: none;
	border-radius: 8px;
	border: 1px solid #d1d5db;
}

input:checked {
	background-color: var(--primary);
}

button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

button:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

.button-primary {
	border: 1px solid var(--primary);
	border-radius: 8px;
	padding: 0.4rem 1.5rem;
	background: var(--primary);
	color: white;
	font-weight: 600;
	cursor: pointer;
}

.button-primary:not(:disabled):hover {
	background: var(--primary-hover);
	border-color: var(--primary-hover);
}

.button-secondary {
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 0.4rem 1.5rem;
	background: white;
	color: #374151;
	font-weight: 600;
	cursor: pointer;
}

.button-secondary:not(:disabled):hover {
	background: #f3f4f6;
}

.button-primary:not(:disabled):active {
	background: var(--primary-dark);
	border-color: var(--primary-dark);
}

.button-secondary:not(:disabled):active {
	background: #e5e7eb;
}

.input-label {
	display: block;
	margin-bottom: 0.4rem;
	font-size: 0.85rem;
	font-weight: 600;
	color: #374151;
}

.slider {
	width: 100%;
	height: 0.5rem;
	background: #e5e7eb;
	outline: none;
	cursor: pointer;
	appearance: none;
}

.icon {
	display: inline-block;
	width: 24px;
	height: 24px;
	vertical-align: middle;

	mask-size: contain;
	mask-repeat: no-repeat;
	mask-position: center;
}

#container {
	display: flex;
	width: 100vw;
	height: 100vh;
}

/* Control Panel */

#control-panel {
	position: relative;
	overflow-y: auto;
	padding: 5px;
	width: 28%;
	border-right: 3px solid black;
	padding: 1vw;
	scrollbar-width: none;
}

/* Title */

#control-panel-header {
	padding: 0.5rem 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

#settings-button {
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: white;
	cursor: pointer;
	padding: 0;
}

#settings-button:hover {
	color: var(--primary-dark);
}

.icon-settings {
	width: 2.2rem;
	height: 2.2rem;
	color: var(--primary);

	background-color: var(--primary);

	mask-image: url("assets/settings.svg");
}

.icon-settings:hover {
	background-color: var(--primary-hover);
}

/* Matrix Input */

#matrix-input-container {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
}

#matrix-input-grid {
	display: grid;
	grid-template-columns: repeat(2, 6rem);
	grid-template-rows: repeat(2, 2.5rem);
	gap: 0.4rem;
}

#matrix-input-grid input {
	width: 6rem;
	height: 2.5rem;
	text-align: center;
	font-size: 1rem;
	font-family: inherit;
	border: 1px solid #ccc;
	border-radius: 0.35rem;
	outline: none;
}

#matrix-input-grid input:focus {
	border-color: #555;
}

#matrix-input-grid input:focus::placeholder {
	color: transparent;
}

#matrix-input-grid input.highlight {
	color: var(--error);
	background-color: var(--error-hightlight);
}

#matrix-input-grid input.highlight::placeholder {
	color: var(--error);
}

.matrix-bracket {
	width: 0.6rem;
	height: 5.7rem;
	position: relative;
}

#matrix-bracket-left {
	border-left: 2px solid black;
	border-top: 2px solid black;
	border-bottom: 2px solid black;
}

#matrix-bracket-right {
	border-right: 2px solid black;
	border-top: 2px solid black;
	border-bottom: 2px solid black;
}

.error-message {
	min-height: 1.1rem;
	margin-top: 0.5rem;
	font-size: 0.78rem;
	font-weight: 500;
	color: var(--error);
	line-height: 1.3;
}

/* Matrix Input - Buttons */

#matrix-btns {
	display: flex;
	align-items: center;
	justify-content: space-between;
	/* gap: 1rem; */
}

#matrix-btns span {
	display: flex;
	gap: 1rem;
}

/* Preset Transformations */

#example-transformations-container {
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	margin-top: 1.25rem;
}

#preset-transformations {
	position: relative;
	width: 100%;
	padding: 0.65rem 2.2rem 0.65rem 0.75rem;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background-color: white;
	cursor: pointer;
	appearance: none;
}

#preset-transformations:hover {
	background-color: #f9fafb;
}

#preset-transformations:focus {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
	border-color: var(--primary);
}

/* Animation Controls */

.animation-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.animation-toggle {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
}

.animation-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-slider {
	position: absolute;
	inset: 0;
	cursor: pointer;
	border-radius: 24px;
	background-color: #ccc;
	transition: 0.2s;
}

.toggle-slider::before {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	left: 3px;
	top: 3px;
	border-radius: 50%;
	background-color: white;
	transition: 0.2s;
}

.animation-toggle input:checked + .toggle-slider {
	background-color: var(--primary);
}

.animation-toggle input:checked + .toggle-slider::before {
	transform: translateX(20px);
}

.animation-controls {
	border: none;
	padding: 0;
	margin: 0;
	min-width: 0;
}

.animation-controls.disabled {
	opacity: 0.5;
}

.animation-controls.disabled button,
.animation-controls.disabled input {
	cursor: not-allowed;
}

#animation-btns {
	padding-top: 0.7rem;
	padding-bottom: 0.3rem;
	display: flex;
	align-items: center;
	justify-content: left;
	gap: 1rem;
}

#animation-controls-container {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
}

#animation-btns {
	display: grid;
	grid-template-columns: repeat(2, 50%);
	gap: 0.5rem;
}

#slider-control {
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
}

#slider-scale {
	display: flex;
	justify-content: space-between;
	font-size: 0.75rem;
	color: #6b7280;
}

/*  */

.slider::-webkit-slider-thumb {
	appearance: none;
	width: 1rem;
	height: 1rem;
	border-radius: 50%;
	border: 2px solid var(--primary);
	background: white;
	cursor: pointer;
}

.slider::-webkit-slider-thumb:hover {
	background: #eff6ff;
}

.slider::-webkit-slider-thumb:active {
	background: #dbeafe;
}

.slider::-moz-range-thumb {
	width: 1rem;
	height: 1rem;
	border-radius: 50%;
	border: 2px solid var(--primary);
	background: white;
	cursor: pointer;
}

.slider::-moz-range-track {
	height: 0.35rem;
	border-radius: 999px;
	background: #e5e7eb;
}

.slider:focus-visible::-webkit-slider-thumb {
	background: var(--primary);
}
.slider:focus-visible::-moz-range-thumb {
	background: var(--primary);
}

.slider:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.slider:disabled::-webkit-slider-thumb {
	opacity: 0.5;
	cursor: not-allowed;
}

.slider:disabled::-moz-range-thumb {
	opacity: 0.5;
	cursor: not-allowed;
}

.slider:disabled::-moz-range-track {
	opacity: 0.5;
}

#slider-control:has(.slider:disabled) .input-label,
#slider-control:has(.slider:disabled) #slider-scale {
	opacity: 0.5;
}

/* Transformation Information */

/* .info-row {
    display: grid;
    grid-template-columns: 7rem auto;
    column-gap: 0.75rem;
	grid-template-rows: 1rem;
    padding: 0.25rem 0;
} */

.transformation-info {
	margin-top: 0.7rem;
	position: relative;
	padding: 1rem;
	border: 1px solid var(--border-colour);
	border-radius: 0.5rem;
	background: var(--panel-colour);
}

.transformation-info h3 {
	margin: 0 0 0.75rem;
	font-size: 1rem;
	font-weight: 600;
}

.info-row {
	display: grid;
	grid-template-columns: 7rem auto;
	column-gap: 0.75rem;
	align-items: center;
	min-height: 1.8rem;
}

.info-label {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	font-weight: 500;
}

.info-value {
	text-align: left;
	font-variant-numeric: tabular-nums;
}

.info-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 1.25rem;
	height: 1.25rem;
	padding: 0;

	border: 0;
	border-radius: 50%;

	background: white;
	color: black;

	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1;

	cursor: pointer;
}

.info-button:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

.info-popup {
	position: fixed;
	z-index: 1000;

	width: 20rem;
	max-width: calc(100vw - 2rem);

	padding: 1rem;

	border: 1px solid black;
	border-radius: 0.5rem;

	background-color: white;
	box-shadow: 0 0.4rem 1rem rgb(0 0 0 / 15%);
}
.info-popup[hidden] {
	display: none;
}

.info-popup-title {
	margin: 0 1.5rem 0.5rem 0;
	font-size: 0.95rem;
	font-weight: 600;
}

.info-popup-text {
	margin: 0;
	line-height: 1.5;
	font-size: 0.85rem;
}

.info-popup-close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;

	border: 0;
	background: transparent;

	color: var(--text-colour);
	font-size: 1.1rem;
	cursor: pointer;
}

/* Properties Panel */

#properties-panel-header {
	padding: 0.5rem 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

#close-properties-panel {
	width: 2.8rem;
	height: 2.8rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: white;
	font-size: 2rem;
	font-weight: 600;
	cursor: pointer;
	color: grey;
}

#close-properties-panel:hover {
	color: dark;
}

.property-row {
	display: grid;
	grid-template-columns: 40% auto;
	align-items: center;
	min-height: 1.8rem;
}

.property-label {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-weight: 500;
}

.property-value {
	text-align: left;
	font-variant-numeric: tabular-nums;
}

/* Settings Panel */

#settings-panel {
	position: absolute;
	inset: 0;
	z-index: 10;
	background: white;
	padding: 1rem;
	overflow-y: auto;
	/* scrollbar-color: var(--primary); */
	scrollbar-width: thin;
	opacity: 1;
	pointer-events: auto;
	transition: opacity 0.12s ease;
}

#settings-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

#settings-panel-header h2 {
	margin: 0;
	font-size: 1.1rem;
}

#back-button {
	border: none;
	background: transparent;
	color: #374151;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	padding: 0.4rem 0;
}

#back-button:hover {
	color: var(--primary);
}

#settings-panel section {
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
	margin-top: 1.2rem;
}

#settings-panel section h3 {
	margin: 0;
	font-size: 0.95rem;
	font-weight: 700;
	color: #111827;
}

.setting-toggle {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	width: 100%;
	padding: 0.55rem 0.65rem;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	background: white;
	color: #374151;
	font-size: 0.9rem;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
}

.setting-toggle:hover {
	background: #f9fafb;
	border-color: var(--primary);
}

.setting-toggle.active {
	background: var(--primary-light);
	border-color: var(--primary);
	color: var(--primary-dark);
}

.toggle-indicator {
	width: 0.9rem;
	height: 0.9rem;
	border: 1.5px solid #d1d5db;
	border-radius: 50%;
	background: white;
}

.setting-toggle.active .toggle-indicator {
	border-color: var(--primary);
	background: var(--primary);
}

.setting-toggle:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

.reset-settings-button {
	width: 100%;
	padding: 12px;
	border: 1px solid #b42318;
	border-radius: 8px;
	background: white;
	color: #b42318;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.reset-settings-button:hover {
	background: #fef3f2;
}

.reset-settings-button:active {
	background: #fee4e2;
}

/* Footer */

#control-panel-footer {
	position: relative;
	width: 100%;
	opacity: 80%;
	font-size: 15px;
}

/* Canvas */

#viewport {
	position: relative;
	flex: 1;
	min-width: 0;
	height: 100vh;
	overflow: hidden;
}

#main-canvas {
	display: block;
	width: 100%;
	height: 100%;
	/* cursor: grab; */
}

#camera-controls {
	position: absolute;
	top: 1rem;
	right: 1rem;

	display: flex;
	gap: 0.5rem;

	z-index: 5;
}

.icon-home {
	background-color: black;
	mask-image: url("assets/house.svg");
}

#canvas-controls {
	position: absolute;
	top: 1rem;
	left: 1rem;

	display: flex;
	gap: 0.5rem;

}

.icon-mouse-pointer {
	background-color: black;
	mask-image: url("assets/mouse-pointer.svg");
}

.icon-grab {
	background-color: black;
	mask-image: url("assets/grab.svg");
}

.icon-vector-polygon {
	background-color: black;
	mask-image: url("assets/vector-polygon.svg");
}

.icon-undo {
	background-color: black;
	mask-image: url("assets/undo.svg");
}

.icon-redo {
	background-color: black;
	mask-image: url("assets/redo.svg");
}


.canvas-btn {
	width: 2.9rem;
	height: 2.9rem;
	
	display: grid;
	align-items: center;
	justify-content: center;

	border: 1px solid gray;
	border-radius: 8px;
	background: white;

	font-size: 1.5rem;
	font-weight: 700;
}

.canvas-btn:hover {
	background: #f3f4f6;
	cursor: default;
}

.canvas-btn:hover .icon {
	background-color: #3a3a3a;
}

.canvas-btn:active {
	background: #e5e7eb;
}

.canvas-btn.active {
	background: var(--primary-light);
}

.canvas-btn.active .icon {
	background: var(--primary-dark);
}

.canvas-btn.active:hover {
	cursor: default;
}

.canvas-btn:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}
