/* global variables. */
:root {
  	/* set sans-serif & mono fonts */
  	--sans-font: sans-serif;
  	--mono-font: monospace;

 	 /* default (light) theme */
  	--bg: #fff;
 	--accent-bg: #f5f7ff;
  	--text: #212121;
  	--text-light: #585858;
  	--border: #898EA4;
  	--accent: #0076f6;
  	--code: #d81b60;
  	--preformatted: #444;
  	--marked: #ffdd33;
  	--disabled: #efefef;
}

/* dark theme */
@media (prefers-color-scheme: dark) {
  	:root {
  		color-scheme: dark;
    	--bg: #212121;
    	--accent-bg: #2b2b2b;
    	--text: #dcdcdc;
    	--text-light: #ababab;
    	--accent: #0076f6;
    	--code: #f06292;
    	--preformatted: #ccc;
    	--disabled: #111;
  	}
}

/* reset box-sizing */
*, *::before, *::after {
	box-sizing: border-box;
}

/* reset default appearance */
html {
  	/* set the font globally */
  	font-family: var(--mono-font);
  	scroll-behavior: smooth;
  	-webkit-text-size-adjust: 100%; /* prevent mobile safari font scaling in landscape while allowing user zoom */
}

/* make the body a nice central block */
body {
  	color: var(--text);
  	background-color: var(--bg);
  	font-size: 1.15rem;
  	line-height: 1.5;
  	display: grid;
  	grid-template-columns: 1fr min(45rem, 90%) 1fr;
 	margin: 0;
 	padding-bottom: 1rem;
 	padding-top: 1rem;
}

body > * {
  	grid-column: 2;
}

body > footer {
  	padding-top: 1rem;
  	color: var(--text-light);
  	font-size: 0.9rem;
  	text-align: center;
}

/* format headers */
h1 {
  	font-size: 3rem;
}

h2 {
  	font-size: 2.6rem;
}

h3 {
  	font-size: 2rem;
}

h4 {
  	font-size: 1.44rem;
}

/* prevent long strings from overflowing container */
p, h1, h2, h3, h4, h5, h6 {
  	overflow-wrap: break-word;
}

main p {
  	text-align: justify;
}

/* Fix line height when title wraps */
h1,
h2,
h3 {
  	line-height: 1.1;
}

/* reduce header size on mobile */
@media only screen and (max-width: 720px) {
  	h1 {
    	font-size: 2.5rem;
  	}

  	h2 {
    	font-size: 2.1rem;
  	}

  	h3 {
    	font-size: 1.75rem;
  	}

  	h4 {
    	font-size: 1.25rem;
  	}
}

/* format links & buttons */
a,
a:visited {
  	color: var(--accent);
}

a:hover {
  	text-decoration: none;
}

button,
[role="button"],
input[type="submit"],
input[type="reset"],
input[type="button"],
label[type="button"] {
  	border: none;
  	border-radius: 5px;
  	background-color: var(--accent);
  	font-size: 1rem;
  	color: #fff; /* changed from var(--bg) */
  	padding: 0.7rem 0.9rem;
  	margin: 0.5rem 0;
}

button[disabled],
[role="button"][aria-disabled="true"],
input[type="submit"][disabled],
input[type="reset"][disabled],
input[type="button"][disabled],
input[type="checkbox"][disabled],
input[type="radio"][disabled],
select[disabled] {
  	cursor: not-allowed;
}

input:disabled,
textarea:disabled,
select:disabled,
button[disabled] {
  	cursor: not-allowed;
  	background-color: var(--disabled);
  	color: var(--text-light)
}

input[type="range"] {
  	padding: 0;
}

button:enabled:hover,
[role="button"]:not([aria-disabled="true"]):hover,
input[type="submit"]:enabled:hover,
input[type="reset"]:enabled:hover,
input[type="button"]:enabled:hover,
label[type="button"]:hover {
  	filter: brightness(1.4);
  	cursor: pointer;
}

button:focus-visible:where(:enabled, [role="button"]:not([aria-disabled="true"])),
input:enabled:focus-visible:where(
  	[type="submit"],
  	[type="reset"],
  	[type="button"]
) {
  	outline: 2px solid var(--accent);
 	outline-offset: 1px;
}

fieldset {
  	border: 1px solid var(--border);
  	padding: 1rem;
  	border-radius: 5px;
  	margin-bottom: 1rem;
}

/* format forms */
textarea,
select,
input {
  	font-size: inherit;
  	font-family: inherit;
  	padding: 0.5rem;
  	margin-bottom: 0.5rem;
  	color: var(--text);
  	background-color: var(--bg);
  	border: 1px solid var(--border);
  	border-radius: 5px;
  	box-shadow: none;
  	max-width: 100%;
  	display: inline-block;
}

label {
  	display: inline-block;
}

textarea:not([cols]) {
  	width: 100%;
}

/* checkbox and radio button style */
input[type="checkbox"],
input[type="radio"] {
  	vertical-align: middle;
  	position: relative;
  	width: min-content;
}

input[type="checkbox"] + label,
input[type="radio"] + label {
  	display: inline-block;
}

/* makes input fields wider on smaller screens */
@media only screen and (max-width: 720px) {
  	textarea,
 	select,
  	input {
    	width: 100%;
  	}
}

/* set a height for color input */
input[type="color"] {
  	height: 2.5rem;
  	padding:  0.2rem;
}

/* do not show border around file selector button */
input[type="file"] {
  	border: 0;
}

/* Misc body elements */
hr {
  	border: none;
	height: 1px;
  	background: var(--border);
  	margin: 1rem auto;
}

img {
  	max-width: 100%;
  	height: auto;
  	border-radius: 5px;
}