/* Colors and base sizes */

:root {
  /* Standard widget theme. Should stand out from the page a little bit but not a lot. It's okay for
   * some widgets to use a different theme, but they should be things that are supposed to stand
   * out, like toast messages or submit buttons. */
  --widget-background-color: ghostwhite;
  --widget-border-color: lightgrey;
  --widget-border-radius: 4px;
  --widget-padding: 8px;

  /* Form theme. */
  --form-optional-color: darkblue;
  --form-placeholder-color: grey;
  --form-required-color: darkred;
  --form-submit-button-background-color: darkgreen;
  --form-submit-button-hover-background-color: green;
  --form-submit-button-color: white;
  --form-textarea-min-height: 20vh;

  /* Link theme. */
  --link-color: seagreen;
  --link-color-hover: olivedrab;
  --link-color-visited: olive;

  /* Toast theme. */
  --toast-error-background-color: lightcoral;
  --toast-error-border-color: crimson;
  --toast-warning-background-color: palegoldenrod;
  --toast-warning-border-color: gold;
  --toast-message-background-color: lightblue;
  --toast-message-border-color: dodgerblue;

  /* Dialog theme. */
  --dialog-width: 80%;
}

/* Fonts */

/*! Generated by Font Squirrel (https://www.fontsquirrel.com) on September 2, 2024 */
@font-face {
    font-family: 'CMU Serif Roman';
    src:
      url('/static/fonts/cmu/cmunrm-webfont.woff2') format('woff2'),
      url('/static/fonts/cmu/cmunrm-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

/* Resets */

html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, pre {
  margin: 0;
  padding: 0;
}

html {
  font-family: 'CMU Serif Roman';
  line-height: 1.5;
}

input[type="button"], input[type="submit"], button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* High-level site layout - header, main, and footer
 *
 * Keep the header and footer static, and let the content fill the rest of the space so we are
 * always at least 1 browser window high
 */

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > header {
  flex: 0 0 auto;
}

body > main {
  flex: 1;
}

body > footer {
  flex: 0 0 auto;
}

/* Give the main content area some padding so that on small screens the text doesn't run up against
 * the edge of the browser window */

main {
  box-sizing: border-box;
  padding: 0 1rem;
}

/* Add margins to the main content area past a certain screen size (over 1024px is typical for
 * desktop) */

main {
  width: 100%;
  margin: 0 auto;
}

@media screen and (min-width: 1025px) {
  main {
    width: 1024px;
  }
}

/* Good baseline for block element vertical margins */

h2, h3, h4, h5, h6, p, ul, ol, pre {
  margin: 1rem 0;
}

/* Headings should get progressively smaller */

h1 {
  /* Page level headings additionally get a bottom border and a bit of a margin underneath. */
  border-bottom: 1px solid var(--widget-border-color);
  font-size: 2rem;
  margin: 2rem 0;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1rem;
}

h5 {
  font-size: 0.9rem;
}

h6 {
  font-size: 0.8rem;
}

/* List items should be indented a little bit so the bullets don't stick out awkwardly */

li {
  margin-left: 2rem;
}

/* Paragraphs should be justified and hyphenated to prevent ragged right edges */

p {
  hyphens: auto;
  text-align: justify;
}

/* Links get custom colors, but for a11y we keep the extra decoration and normal/hover/visited
 * states distinct */

a {
  color: var(--link-color);
  transition: color 0.3s ease;
}

a:hover {
  color: var(--link-color-hover);
}

a:visited {
  color: var(--link-color-visited);
}

/* Forms */

form {
  border: 2px solid var(--widget-border-color);
  border-radius: var(--widget-border-radius);
  padding: var(--widget-padding);
}

form div {
  justify-content: center;
  column-gap: 1rem;
  row-gap: 1rem;
  margin: 1rem 0;
}

form label, form input, form textarea {
  display: block;
}

form label {
  /* Don't line break between the actual label text and the "(Required)" or "(Optional)"
   * indicators */
  white-space: nowrap;
}

form input, form textarea {
  background-color: var(--widget-background-color);
  border: 1px solid var(--widget-border-color);
  border-radius: var(--widget-border-radius);
  box-sizing: border-box;
  font-family: sans-serif;
  font-size: 0.8rem;
  padding: var(--widget-padding);
  width: 100%;
}

form input::placeholder, form textarea::placeholder {
  color: var(--form-placeholder-color);
}

form textarea {
  min-height: var(--form-textarea-min-height);
  resize: vertical;
}

form input[type="submit"] {
  background-color: var(--form-submit-button-background-color);
  color: var(--form-submit-button-color);
  font-size: 1.1rem;
  margin: 0 auto;
  padding: 16px;
  transition: background-color 0.5s;
  width: 50%;
}

form input[type="submit"]:hover {
  background-color: var(--form-submit-button-hover-background-color);
}

/* Site header */

body > header {
  box-sizing: border-box;
  margin: 2rem 0;
  padding: 0 1rem;
}

body > header > div {
  padding-bottom: 0.5rem;
  text-align: center;
}

body > header > div > a {
  font-size: 2rem;
  font-variant: small-caps;
  font-weight: bold;
}

body > header > div > a:visited {
  color: var(--link-color);
}

body > header > div > a:hover {
  color: var(--link-color-hover);
}


/* Site footer */

body > footer {
  background: var(--widget-background-color);
  font-size: 0.75rem;
  text-align: center;
  border-top: 1px solid var(--widget-border-color);
  margin-top: 4rem;
  padding: 0.5rem;
}

body > footer p {
  margin: 0.5rem auto;
  width: 100%;
  text-align: center;
}

body > footer hr {
  color: ghostwhite;
  width: 3rem;
}

@media screen and (min-width: 481px) {
  body > footer p {
    width: 480px;
  }
}

/* Sticky bar */

#sticky {
  background: ghostwhite;
  border: 1px solid lightgrey;
  border-radius: 4px;
  font-family: sans-serif;
  position: absolute;
  top: 0;
  right: 0;
  margin: 8px;
}

@media screen and (min-width: 1025px) {
  #sticky {
    position: fixed;
  }
}

#sticky ul {
  display: flex;
  list-style: none;
  margin: 0;
}

#sticky li {
  border-left: 1px solid lightgrey;
  flex: 0 0 auto;
  margin: 0;
  padding: 8px;
}

#sticky li:first-child {
  border-left: none;
}

#sticky a {
  text-decoration: none;
}

#sticky a:visited {
  color: var(--link-color);
}

#sticky a:hover {
  color: var(--link-color-hover);
}

/* Tag lists */

.tags {
  display: flex;
  list-style: none;
}

.inline-tags {
  display: inline-flex;
  list-style: none;
  margin: 0;
}

.tags li,
.inline-tags li {
  background: ghostwhite;
  border: 1px solid lightgrey;
  flex: 0 0 auto;
  font-family: monospace;
  font-size: 0.6rem;
  margin-left: 8px;
  padding: 4px;
}

.tags li:first-child,
.inline-tags li:first-child {
  margin-left: 0;
}

.tags a:visited,
.inline-tags a:visited {
  color: var(--link-color);
}

.tags a:hover,
.inline-tags a:hover {
  color: var(--link-color-hover);
}

/* Toasts */

.toast {
  border-radius: 4px;
  font-family: sans-serif;
  padding: 1rem;
}

.toast-error {
  background: var(--toast-error-background-color);
  border: 1px solid var(--toast-error-border-color);
}

.toast-warning {
  background: var(--toast-warning-background-color);
  border: 1px solid var(--toast-warning-border-color);
}

.toast-message {
  background: var(--toast-message-background-color);
  border: 1px solid var(--toast-message-border-color);
}

/* Tables */

table {
  border-collapse: collapse;
  margin: 1rem auto;
  width: 90%;
}

caption {
  caption-side: bottom;
  font-size: 0.6rem;
  font-style: italic;
  padding: 0.5rem;
}

thead {
  background: var(--widget-background-color);
}

td, th {
  border: 1px solid var(--widget-border-color);
  border-radius: var(--widget-border-radius);
  padding: var(--widget-padding);
  overflow: scroll;
  text-align: center;
}

/* Code */

code {
  background: ghostwhite;
  border: 1px solid lightgrey;
  font-size: 0.6rem;
  padding: 4px;
}

/* Buttons */

button {
  background: ghostwhite;
  border: 1px solid lightgrey;
  border-radius: 4px;
  font-size: 0.8rem;
  padding: 4px;
}

button:hover {
  background: lightgrey;
}

button:active {
  background: silver;
}

/* Section headers (with buttons in them) */

section > header {
  align-items: center;
  gap: var(--widget-padding);
  display: flex;
  margin: 1rem 0;
}

section > header > h2,
section > header > h3,
section > header > h4,
section > header > h5,
section > header > h6,
section > header > button {
  flex: 0 0 auto;
  margin: 0;
}

/* Dialogs */

dialog {
  border: 1px solid var(--widget-border-color);
  border-radius: var(--widget-border-radius);
  width: var(--dialog-width);
}

dialog > h2 {
  border-bottom: 1px solid var(--widget-border-color);
  margin-top: 0;
}
