/* Colors ----------------------------------------------------------- */
:root {
	--body-background: #F3EBDA;
	--body-foreground: #000000;
	--cell-background: #FEFEFE;
	--cell-foreground: #222222;
	--header-background: #CCCCCC;
	--header-foreground: #000000;
	--cell-border: #6E7B6A;
	--utils-background: #F8F4E9;
	--utils-foreground: #000000;
    --heading: #6E7B6A;
	--error: #cb2f43;
	--link: #1E4B8A;
}

body {
	background-color: var(--body-background);
	color: var(--body-foreground);
	font-family: sans-serif;
	font-weight: 400;
	margin: 0;
}

h1, h2, h3 {
	margin-bottom: 0;
	line-height: 1;
	color: var(--heading);
}

p {
	margin: 0.5rem 0;
}

a {
	color: var(--link);
	cursor: pointer;
}

h1:first-of-type {
	margin-top: -1.5rem;
}

textarea {
	font-family: monospace;
	font-size: inherit;
	border: 1px solid var(--cell-border);
}

main #sheet {
	margin-left: 2.5rem;
}

/* When sidebar is open, push sheet right */
main:has(> #utils:open) #sheet {
	margin-left: min(21rem, 80vw);
}

/* Utility Sidebar -------------------------------------------------- */

#utils {
	background-color: var(--utils-background);
	color: var(--utils-foreground);
	position: fixed;
	height: 100vh;
	top: 0;
	padding: 1rem 0.5rem;
	border-right: 1px solid var(--cell-border);
}

#utils summary {
	font-size: 24px;
	display: flex;
	flex-direction: row;
	justify-content: end;
	cursor: zoom-in;
}

#utils:open summary {
	cursor: zoom-out;
}

#utils:open {
	width: 20rem;
	max-width: 80vw;
	overflow-y: scroll;
	padding-bottom: 3rem;
}

#customFunctions,
#csv {
	width: 100%;
	resize: vertical;
	white-space: pre;
	overflow-wrap: normal;
	overflow: scroll;
}

#customErrors {
	color: var(--error);
}

/* Spreadsheet ------------------------------------------------------ */

#sheet {	
	display: grid;
	grid-template-columns: repeat(27, 1fr); /* 26 cols + row header */
	grid-template-rows: repeat(101, auto); /* 100 rows + col header */
	margin: 0px;
}

/* column header */
.h {
	width: 100px;
	resize: horizontal;
	text-align: center;
}

/* row header */
.rh {
	width: 40px;
	min-height: 1.2rem;
	resize: vertical;
	text-align: center;	
	display: flex;
	justify-content: center;
	align-items: center;
}

/* top-left corner bit */
.rh:first-of-type {
	resize: none;
}

.cell,
.h,
.rh {
	background: var(--cell-background);
	color: var(--cell-foreground);
	font: inherit;
	outline: none;
	border: none;
	overflow: hidden;
	border-right: 1px solid var(--cell-border);
	border-bottom: 1px solid var(--cell-border);
	padding: 3px 3px 1px 3px;
}

.h,
.rh {
	background-color: var(--header-background);
	color: var(--header-foreground);
	font-weight: bold;
}
