:root
{
    margin: 0;
    padding: 0;
    --primary-bg-colour: #131313;
    --ui-bg-colour: #000000;
    --label-colour: #eeeeee;
    --input-text-colour: #a2a2a2;
    --slider-fg-colour: #4d4d4d;
    --slider-bg-colour: #303030;
    --open-close-controls: #282829;
    --border-colour: #3e3e3e;
    --ui-height: 300px;
    font-size: 8.94px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Prevent scrolling on the body */
}

body
{
    font-family: 'neue-haas-unica', sans-serif;
    font-weight: 400;
    font-style: normal;
    overscroll-behavior-x: none !important; /* Ensure this property is set */
    overflow-x: hidden !important; /* Prevent horizontal scrolling */
    transform: translateZ(0); /* Force hardware acceleration which can help with blur effects */
}

main
{
    display: block;
    position: static;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: var(--primary-bg-colour);
}

p
{
    color: var(--label-colour);
}

canvas
{
    display: block;
    position: absolute;
    z-index: 0;
    margin: 0 auto; /* Center horizontally with auto margins */
    padding: 0;
    left: 50%;
    transform: translate(-50%, -50%); /* Center using transform */
    top: 50%;
    border: none;
}

canvas#defaultCanvas0.p5Canvas
{
    z-index: 0;
    opacity: 1 !important;
    position: absolute;
    left: 50%;
    top: 50%;
}

canvas.p5Canvas 
{
    opacity: 1 !important;
    background-color: transparent !important;
}

.disclaimer
{
    text-align: inherit;
    font-size: 10px;
    line-height: 12px;
    letter-spacing: -1%;
    color: #58595B;
    position: absolute;
    z-index: 1001;
    left: 8px;
    bottom: 8px;
}

.ui
{
    margin: 0;
    padding: 0;
    width: 245px;
    position: absolute;
    z-index: 19;
    top: 8px;
    right: 8px;
    background-color: rbg(40, 40, 40, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: var(--label-colour);
    text-align: center;
    max-height: calc(100vh - 33px); /* Adjust the max height to fit within the viewport */
    overflow-y: auto; /* Enable vertical scrolling */
}

/* 
    ====================================================
    ============ FOCUS STYLES BEGIN HERE ===============
    ====================================================
*/
.ui:focus,
.ui *:focus 
{
    outline: none;
}

.closeControls:focus,
.closeControls *:focus 
{
    outline: none;
}

/* 
    ====================================================
    ============ FOCUS STYLES END HERE =================
    ====================================================
*/
::marker
{
    font-size: 7px;
}

details
{
    position: relative;
    border: none;
    list-style: none ; /* Hide the default marker */
}

details summary::-webkit-details-marker 
{
    display:none;
}

summary
{
    background-color: rgba(40, 40, 41, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    height: 20px;
    line-height: 20px;
    cursor: pointer;
    position: relative;
}

summary:hover
{
    background-color: rgba(40, 40, 41, 0.7);
}

.sub-menu-components
{
    text-align: left;
}

.sub-menu-components summary
{
    display: block;
}

.sub-menu-components summary::before
{
    margin-right: 5px;
    display: inline-block;
    vertical-align: top;
    font-size: 5px;
    content: '\25B6'; /* Unicode for Black Right-pointing Triangle */
}

.sub-menu-components details[open] > summary::before 
{
    transform: rotate(90deg);
}

/* 
    ====================================================
    ====== HTML INPUT ELEMENT STYLES BEGIN HERE ========
    ====================================================
*/

input
{
    font-size: inherit;
}

input[type=number]::-webkit-inner-spin-button 
{
    -webkit-appearance: none;
}

input[type=number] 
{
    -moz-appearance: textfield; /* Firefox */
}

input[type=number]::-ms-clear,
input[type=number]::-ms-expand 
{
    display: none; /* Internet Explorer and Edge */
}

/* 
    ====================================================
    ======= HTML INPUT ELEMENT STYLES END HERE =========
    ====================================================
*/

.input-component
{
    padding-left: 10px;
    height: 27px;
    line-height: 27px;
    cursor: pointer !important;
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--border-colour);
}

.output-component
{
    background-color: var(--ui-bg-colour);
    border-bottom: 1px solid var(--border-colour);
    padding-left: 10px;
    height: 27px;
    line-height: 27px;
    cursor: pointer !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.colour-component
{
    padding-left: 10px;
    height: 27px;
    line-height: 27px;
    cursor: pointer !important;
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--border-colour);
}

.content-component
{
    padding-left: 10px;
    height: 27px;
    line-height: 27px;
    cursor: pointer !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.text-control
{
    border-bottom: 1px solid var(--border-colour);
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: baseline;
    gap: 25px;
}

.text-control label 
{
    flex: 0 0 auto; /* Prevent the label from growing or shrinking */
}

.text-control input
{
    flex: 1 1 auto; /* Allow the input to grow and shrink */
    height: 17px;
    margin-right: 4px;
    border: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
}

.text-area-control
{
    border-bottom: 1px solid var(--border-colour);
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    height: 54px;
    padding-top: 5px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: flex-start;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: baseline;
    gap: 11px;
}

.text-area-control label 
{
    flex: 0 0 auto; /* Prevent the label from growing or shrinking */
}

.text-area-control textarea
{
    flex: 1 1 auto; /* Allow the input to grow and shrink */
    height: 44px;
    margin-right: 4px;
    border: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    font-style: inherit;
    resize: none;
}

/* 
    ====================================================
    ============= RANGE STYLES BEGIN HERE ==============
    ====================================================
*/

.range-control
{
    border-bottom: 1px solid var(--border-colour);
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 4px; /* Adjust gap between elements as needed */
}

.range-control label 
{
    flex: 0 0 auto; /* Prevent the label from growing or shrinking */
}

.range-control input
{
    flex: 1 1 auto; /* Allow the input to grow and shrink */
    height: 17px;
    margin-right: 4px;
    border: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
}

.range-control input[type="range"] 
{
    flex: 1 1 auto; /* Allow the range input to grow and shrink */
    height: 17px;
    margin-right: 0px;
    border: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
    --thumb-height: 17px;
	--track-height: 17px;
	--track-color: var(--slider-bg-colour);
	--brightness-hover: 180%;
	--brightness-down: 80%;
	--clip-edges: 1px;
}

input[type="range"].win10-thumb 
{
    margin-left: 37.5px;
    width: 100px;
    color: var(--slider-fg-colour);
	--thumb-height: 17px;
	--thumb-width: 0px;
	--clip-edges: 0.0px;
    vertical-align: middle;
    cursor: grab;
}

.range-control input[type="number"] 
{
    flex: 1 1 auto; /* Set a fixed width for the number input */
    height: 15px; /* 17px is target height but need to -2px to result in a height of 17px; not sure why */
    width: 20px;
    border: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
}

input[type="range"] 
{
	position: relative;
	background: #fff0;
	overflow: hidden;
}

input[type="range"]:active 
{
	cursor: ew-resize;
}

input[type="range"]:disabled 
{
	filter: grayscale(1);
	opacity: 0.3;
	cursor: not-allowed;
}

/* === WebKit specific styles === */
input[type="range"],
input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-thumb 
{
	-webkit-appearance: none;
	transition: all ease 100ms;
	height: var(--thumb-height);
}

input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-thumb 
{
	position: relative;
}

input[type="range"]::-webkit-slider-thumb 
{
	--thumb-radius: calc((var(--thumb-height) * 0.5) - 1px);
	--clip-top: calc((var(--thumb-height) - var(--track-height)) * 0.5 - 0.5px);
	--clip-bottom: calc(var(--thumb-height) - var(--clip-top));
	--clip-further: calc(100% + 1px);
	--box-fill: calc(-100vmax - var(--thumb-width, var(--thumb-height))) 0 0
		100vmax currentcolor;

	width: var(--thumb-width, var(--thumb-height));
	background: linear-gradient(currentcolor 0 0) scroll no-repeat left center /
		50% calc(var(--track-height) + 1px);
	background-color: currentcolor;
	box-shadow: var(--box-fill);
	border-radius: var(--thumb-width, var(--thumb-height));
    border-radius: 0;

	filter: brightness(100%);
	clip-path: polygon(
		100% -1px,
		var(--clip-edges) -1px,
		0 var(--clip-top),
		-100vmax var(--clip-top),
		-100vmax var(--clip-bottom),
		0 var(--clip-bottom),
		var(--clip-edges) 100%,
		var(--clip-further) var(--clip-further)
	);
}

input[type="range"]:hover::-webkit-slider-thumb 
{
	filter: brightness(var(--brightness-hover));
	cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb 
{
	filter: brightness(var(--brightness-down));
	cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track 
{
	background: linear-gradient(var(--track-color) 0 0) scroll no-repeat center /
		100% calc(var(--track-height) + 1px);
}

input[type="range"]:disabled::-webkit-slider-thumb 
{
	cursor: not-allowed;
}

/* === Firefox specific styles === */
input[type="range"],
input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-thumb 
{
	appearance: none;
	transition: all ease 100ms;
	height: var(--thumb-height);
}

input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-thumb,
input[type="range"]::-moz-range-progress 
{
	background: #fff0;
}

input[type="range"]::-moz-range-thumb 
{
	background: currentcolor;
	border: 0;
	width: var(--thumb-width, var(--thumb-height));
	border-radius: var(--thumb-width, var(--thumb-height));
	cursor: grab;
}

input[type="range"]:active::-moz-range-thumb 
{
	cursor: ew-resize;
}

input[type="range"]::-moz-range-track 
{
	width: 100%;
	background: var(--track-color);
}

input[type="range"]::-moz-range-progress 
{
	appearance: none;
	background: currentcolor;
	transition-delay: 30ms;
}

input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-progress 
{
	height: calc(var(--track-height) + 1px);
	border-radius: var(--track-height);
}

input[type="range"]::-moz-range-thumb,
input[type="range"]::-moz-range-progress 
{
	filter: brightness(100%);
}

input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:hover::-moz-range-progress 
{
	filter: brightness(var(--brightness-hover));
}

input[type="range"]:active::-moz-range-thumb,
input[type="range"]:active::-moz-range-progress 
{
	filter: brightness(var(--brightness-down));
}

input[type="range"]:disabled::-moz-range-thumb 
{
	cursor: not-allowed;
} 
/* 
    ====================================================
    ============= RANGE STYLES END HERE ================
    ====================================================
*/

/* 
    ====================================================
    ============= CHECKBOX STYLES BEGIN HERE ===========
    ====================================================
*/

.playback-toggle
{
    border-bottom: 1px solid var(--border-colour);
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: baseline;
    gap: 25px;
}

input[type="checkbox"] 
{
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 17px;
    height: 17px;
    border: none;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

input[type="checkbox"]::before 
{
    content: '\23F8'; /* Unicode for pause symbol */
    font-size: 12px; /* Adjust font size as needed */
    color: var(--label-colour);
    display: flex;
    align-items: center;
    justify-content: center;
}

input[type="checkbox"]:checked::before 
{
    content: '\23F5'; /* Unicode for play/forward/next symbol */
    font-size: 12px; /* Adjust font size as needed */
    color: var(--label-colour);
}

.difference-toggle
{
    border-bottom: 1px solid var(--border-colour);
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 20px; /* Adjust to line up checkbox and colour pickers */
}

/* Override styles for the difference toggle to display the default checkbox */
input[type="checkbox"]#difference-toggle {
    cursor: pointer;
    align-items: center;
    justify-content: center;
    background-color: var(primary-bg-colour);
    border: 1px solid var(--border-colour);
    width: 11px;
    height: 11px;
}

input[type="checkbox"]#difference-toggle::before {
    content: none;
    align-items: center;
    justify-content: center;
}

input[type="checkbox"]#difference-toggle:checked::before {
    color: var(--label-colour);
    font-size: 9px;
    content: '✓'; /* Unicode for a straight checkmark */
}

/* 
    ====================================================
    ============= CHECKBOX STYLES END HERE =============
    ====================================================
*/

.direction-dropdown {
    background-color: var(--ui-bg-colour);
    border-bottom: 1px solid var(--border-colour);
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 28px;
    position: relative; /* Ensure the container is positioned relatively */
}

.text-align-dropdown {
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 25.5px;
    position: relative; /* Ensure the container is positioned relatively */
}

.select-container {
    position: relative;
    display: inline-block;
}

.select-container select {
    height: 17px;
    border: none;
    appearance: none;
    background-color: var(--slider-bg-colour);
    color: var(--input-text-colour);
    text-align: left;
    padding-left: 4px;
    padding-bottom: 1px; /* adjust vertical centering of arrows */
    font-size: 10px;
    background-image: url('select_icon.svg'); /* Set the SVG as a background image */
    background-repeat: no-repeat;
    background-position: right 3px center; /* Adjust position as needed */
    background-size: 8px 8px; /* Adjust size as needed */
}

/* target the direction dropdown */
.direction-dropdown .select-container select {
    width: 37px; /* Set the desired width for the text-align dropdown */
}

/* target the text-align dropdown */
.text-align-dropdown .select-container select {
    width: 100px; /* Set the desired width for the text-align dropdown */
}

/* Cross-browser select styling */
.select-container select {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0; /* Ensure corners are square */
}

/* Safari-specific select styling */
@media not all and (min-resolution:.001dpcm) { 
    @supports (-webkit-appearance:none) {
        .select-container select {
            border-radius: 0;
            -webkit-border-radius: 0;
        }
    }
}

#text-color-code,
#bg-color-code {
    display: inline-block;
    position: absolute;
    top: 46%; /* Adjust as needed */
    left: 66%; /* Adjust as needed */
    transform: translate(-50%, -50%); /* Center the span element */
    z-index: 2;
    color: var(--label-colour); /* Ensure the text color is visible */
    text-align: center;
}

/*
    ====================================================
    ============= COLOUR STYLES BEGIN HERE =============
    ====================================================
*/
.colour-control
{
    border-bottom: 1px solid var(--border-colour);
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 48px;
    position: relative;
}

.bg-colour-control
{
    gap: 19px;
}

.colour-control label {
    flex: 0 0 auto; /* Prevent the label from growing or shrinking */
}

.colour-control input
{
    flex: 1 1 auto; /* Allow the input to grow and shrink */
    height: 17px;
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--input-text-colour);
    text-align: left;
    padding: 0;
    margin-right: 4px;
}

input[type="color"] {
	-webkit-appearance: none;
	border: 1px solid var(--slider-bg-colour);
	width: 16px;
	height: 17px;
}
input[type="color"]::-webkit-color-swatch-wrapper {
	padding: 0;
}
input[type="color"]::-webkit-color-swatch {
	border: none;
}

#axis-colour-code,
#circle-colour-code,
#bg-colour-code {
    display: inline-block;
    position: absolute;
    top: 46%; /* Adjust as needed */
    left: 66%; /* Adjust as needed */
    transform: translate(-50%, -50%); /* Center the span element */
    z-index: 2;
    color: var(--label-colour); /* Ensure the text color is visible */
    text-align: center;
}

/* Cross-browser color input styling */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none; /* Standard version of -webkit-appearance */
    background-color: transparent;
    border: none;
    width: 16px;
    height: 17px;
    padding: 0;
    cursor: pointer;
}

/* Webkit (Chrome, Safari, newer Edge) specific styles */
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 0;
}

/* Firefox specific styles */
input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 0;
}

/* Remove focus outline */
input[type="color"]:focus {
    outline: none;
}

/*
    ====================================================
    ============= COLOUR STYLES END HERE ===============
    ====================================================
*/

/* 
    ====================================================
    ========== CONTENT CONTROL STYLES BEGIN HERE ========
    ====================================================
*/

.content-control
{
    border-bottom: 1px solid var(--border-colour);
    height: 27px;
    padding-left: 18px;
    display: flex;
    flex-direction: row;
    align-content: center;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 9px;
}

.content-control label {
    flex: 0 0 auto; /* Prevent the label from growing or shrinking */
    cursor: pointer;
    color: var(--label-colour);
    border-radius: 3px; /* Optional: Add border radius for better appearance */
}

.content-control input[type="file"] {
    display: none; /* Hide the default file input */
}

.content-control img {
    display: none; /* Hide the thumbnail by default */
    width: 50px; /* Adjust width as needed */
    height: 50px; /* Adjust height as needed */
    object-fit: cover; /* Ensure the image covers the area */
    margin-left: 10px; /* Adjust margin as needed */
}

.content-control #file-name {
    flex: 1 1 auto; /* Allow the span to grow and shrink */
    color: var(--input-text-colour);
}

/* 
    ====================================================
    ========== CONTENT CONTROL STYLES END HERE =========
    ====================================================
*/

.top-control-component
{
    /*border-top: 1px solid var(--border-colour);*/
    border-top: none;
}

.bottom-control-component
{
    border-bottom: 1px solid var(--border-colour);
    background-color: var(--ui-bg-colour);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* 
    ====================================================
    ========== CLOSE BUTTON STYLES BEGIN HERE ==========
    ====================================================
*/

.closeControls
{
    margin: 0;
    width: 245px;
    height: 20px;
    position: absolute;
    z-index: 100;
    top: var(--ui-height) !important;
    right: 8px;
    background-color: rgba(40, 40, 41, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    text-align: center;
    border: none;
    bottom: auto;
}

.closeControls:hover
{
    background-color: rgba(40, 40, 41, 0.7);
}

.closeControls button:hover
{
    cursor: pointer;
}

button
{
    width: inherit;
    height: inherit;
    font-size: inherit;
    background: none; /* Remove the default button background */
    color: var(--label-colour);
    border: none;
}

button.controlsbtnClose {
    width: 100%;
    height: 100%;
    background-color: transparent;
    color: var(--label-colour);
    border: none;
    cursor: pointer;
}

/* 
    ====================================================
    =========== CLOSE BUTTON STYLES END HERE ===========
    ====================================================
*/

@media (prefers-color-scheme: dark) 
{
	html 
    {
		background-color: #000;
	}

	html::before 
    {
		background: radial-gradient(circle at center, #101112, #000);
	}

	input[type="range"] 
    {
		/*color: #f07167;*/
		--track-color: var(--slider-bg-colour);
	}

	input[type="range"].win10-thumb 
    {
		color: var(slider-fg-color);
	}
}

@media screen and (max-width: 700px) {
    .ui
    {   
        position: fixed;
        top: 8px;
        left: 50%;
        transform: translate(-50%, 0%);
        right: auto; /* Reset right property */
    }

    .closeControls {
        top: calc(100% + 8px); /* Position it directly underneath the .ui div */
        left: 50%;
        transform: translateX(-50%);
        right: auto; /* Reset right property */
    }
  }