/* 
  FORK OF Simple.css
  https://github.com/kevquirk/simple.css/wiki/Getting-Started-With-Simple.css
  https://simplecss.org/demo
*/

/* Global variables. */
:root {
  /* Set sans-serif & mono fonts */
  --serif-font: TODO;
  --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
    "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
    "Helvetica Neue", sans-serif;
  --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
  --standard-border-radius: 5px;

  /* Default (light) theme */
  --bg: #fff;
  --accent-bg: #F5F5F5; /* Tailwinds Neutral Gray 100 */
  --text: #212121;
  --text-light: #585858;
  --border: #898EA4;
  --accent: #0d47a1;
  --accent-hover: #1266e2;
  --accent-text: var(--bg);
  --disabled: #efefef;
  --code: #d81b60;
  --preformatted: #444;
  --marked: #ffdd33;
}

*, 
*::before, 
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;  /* Reset box-sizing */
}

html {
  font-size: 16px;               /* This is the reference for 1rem */
  font-family: var(--sans-font); /* Set the font globally */
  scroll-behavior: smooth;
}

body {
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.5;
}

/* ------------------------- Separators ------------------------- */

hr {
  width: 100%;
  border-width: 1px;
  border-style: solid none none;
  background-color: var(--border);
  margin: 2rem auto;
  /*
  border: none;
  background: var(--border);
  width: 100%;
  height: 1px;
  margin: 2rem auto;
  */
}
hr.dotted {
  width: 45px;
  background: none;
  border-width: 5px;
  border-style: dotted none none;
  /* border-color: var(--border); */
  /* margin: 2rem auto; */
}

/* ------------------------- Headers ------------------------- */

h1 { font-size: 2rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; }
h5 { font-size: 0.83rem; }
h6 { font-size: 0.67rem; }

h1, h2, h3, h4, h5, h6 {
  margin-top: 1.25em;
  margin-bottom: 0.625em;
  line-height: 1.1;           /* Fix line height when title wraps */
  overflow-wrap: break-word;  /* Prevent long strings from overflowing container */
}
p {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  overflow-wrap: break-word;  /* Prevent long strings from overflowing container */
}

/* ------------------------- Lists ------------------------- */

/* Remove margin below paragraphs that come just before a list */
p:has(+ ol),
p:has(+ ul),
p:has(+ dl) {
  margin-bottom: 0;
}

ol, ul {
  padding-inline-start: 40px;
  margin: 1rem 0;
}
@media (max-width: 405px) {
  ol, ul {
    padding-inline-start: 25px;
  }
}

dt {
  font-weight: bold;
  color: var(--text-light);
}

dd {
  margin-inline-start: 20px;
  margin-bottom: 1rem;
}


/* ------------------------- Text Formatting ------------------------- */

mark {
  padding: 2px 5px;
  border-radius: var(--standard-border-radius);
  background-color: var(--marked);
  color: black;
}
mark a {
  color: #0d47a1;
}
del {
  color: #f44336;
}
ins {
  color: #04AA6D;
  text-decoration: none;
}

/* Set the cursor to '?' on an abbreviation and style the abbreviation
   to show that there is more information underneath */
abbr {
  cursor: help;                    /* set the cursor to '?' */
  text-decoration-line: underline; /* style to show that there is more information */
  text-decoration-style: dotted;
  position: relative;              /* needed for the tooltip to work */
}
/* Add tooltip on hover */
abbr::after {
  content: attr(data-tooltip); /* Use a custom attribute to avoid browser's default tooltip */
  position: absolute;
  left: 50%;
  bottom: 125%; /* Position the tooltip above the abbr */
  transform: translateX(-50%);
  background-color: black;
  color: white;
  font-size: 0.8rem;      /* Used to be 12px */
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease-in-out;
  z-index: 10;
}
abbr:hover::after {
  opacity: 1;
  visibility: visible;
}

  /* TODO: check code from PICO CSS for Abbr */
  /*
  @media (hover: hover) and (pointer: fine) {
    [data-tooltip]:focus::after,
    [data-tooltip]:focus::before,
    [data-tooltip]:hover::after,
    [data-tooltip]:hover::before {
        --pico-tooltip-slide-to: translate(-50%, -0.25rem);
        transform: translate(-50%, 0.75rem);
        animation-duration: 0.2s;
        animation-fill-mode: forwards;
        animation-name: tooltip-slide;
        opacity: 0;
    }
    [data-tooltip]:focus::after,
    [data-tooltip]:hover::after {
        --pico-tooltip-caret-slide-to: translate(-50%, 0rem);
        transform: translate(-50%, -0.25rem);
        animation-name: tooltip-caret-slide;
    }
    @keyframes tooltip-slide {
      to {
          transform: var(--pico-tooltip-slide-to);
          opacity: 1;
      }
    }
  }
  */

/* Prevent superscripts & subscripts from affecting line-height. */
sup, sub {
  vertical-align: baseline;
  position: relative;
}
sup {
  top: -0.4em;
}
sub { 
  top: 0.3em;
}

blockquote {
  margin-inline-start: 2rem;
  margin-inline-end: 0;
  margin-block: 2rem;
  padding: 0.4rem 0.8rem;
  /* background-color: var(--accent-bg); */
  border-inline-start: 4px solid var(--accent);
  color: var(--text-light);
  font-style: normal;
}
blockquote > p {
  margin: 0;
}

cite {
  color: var(--text-light);
  font-size: 0.9rem;
  font-style: italic;
}


/* ------------------------- Alerts  ------------------------- */
/* https://www.w3schools.com/HOWTO/howto_js_alert.asp */
/* Used with paragraph or div */

.alert {
  color: white;
  background-color: #f44336; /* Red */
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--standard-border-radius);
}
.alert.success {
  background-color: #04AA6D;
}
.alert.info {
  background-color: #2196F3;
}
.alert.warning {
  background-color: #ff9800;
}


/* ------------------------- Code Elements ------------------------- */

code,
pre,
pre span,
kbd {
  font-family: var(--mono-font);
  font-size: 1rem;
  color: var(--preformatted);
}

code {
  color: var(--code);
}

kbd {
  border: 1px solid var(--preformatted);
  border-bottom: 3px solid var(--preformatted);
  border-radius: var(--standard-border-radius);
  padding: 0.1rem 0.4rem;
  margin-right: 0.1rem;
}

pre {
  padding: 1rem 0;
  max-width: 100%;
  overflow: auto;
  
  /* Similar to details & progress */
  background-color: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: var(--standard-border-radius);
  margin-bottom: 1rem;
}

pre:has(code) {
  padding: 0; /* Fix embedded code within pre */
  background-color: #2b2b2b; 
  code {
    color: #f06292;
  }
}

/* ------------------------- Summary Accordian ------------------------- */

summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: bold;
  padding: 0.7rem 1rem;
  margin: -0.7rem -1rem;
  word-break: break-all;
}
details { /* Similar to pre & progress */
  padding: 0.7rem 1rem;
  background-color: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: var(--standard-border-radius);
  margin-bottom: 1rem;
}
details[open] > summary + * {
  margin-top: 0;
}
details[open] > summary {
  margin-bottom: 0.5rem;
}
details[open] > :last-child {
  margin-bottom: 0;
}

/* ------------------------- Figures ------------------------- */

figure {
  width: max-content;
  margin: 1rem auto;
  display: block;
  overflow-x: auto;
}
figcaption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 1rem;
}
  
/* ------------------------- Tables ------------------------- */

table {
  text-align: justify;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}
td, th {
  padding: 0.5em;
  border-bottom: 1px solid #f1f1f1;
}
tr:nth-child(even) {
  /* Set every other cell slightly darker. Improves readability. */
  background-color: var(--accent-bg);
}

figure > table {
  width: max-content;
  margin: 0;
}
table + figcaption {
}

/* ------------------------- Media ------------------------- */

img,
video {
  max-width: 100%;
  height: auto;
  border-radius: var(--standard-border-radius);
}

figure > img,
figure > picture > img {
  display: block;
  margin-inline: auto;
}

img.border {
    border: 1px solid gray;
}

img.shadow {
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);
    
    /* Fix to prevent shadow from getting cropped. */
    margin-top: 10px;         /* Add margin = shadow amount */
    margin-bottom: 10px;      /* Add margin = shadow amount */
    width: calc(100% - 20px); /* Deducted 2X the shadow amount from width */
    /* todo: switch to max-width ? */
}

/* ------------------------- Links & Buttons ------------------------- */

a,
a:visited {
  color: var(--accent);
}

a:hover {
  text-decoration: none;
}

button,
.button,
a.button, /* extra specificity to override a */
input[type="submit"],
input[type="reset"],
input[type="button"] {
  border: 1px solid var(--accent);
  background-color: var(--accent);
  color: var(--accent-text);
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  line-height: normal;
}

.button[aria-disabled="true"], 
input:disabled,
textarea:disabled,
select:disabled,
button[disabled] {
  cursor: not-allowed;
  background-color: var(--disabled);
  border-color: var(--disabled);
  color: var(--text-light);
}

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

button:enabled:hover,
.button:not([aria-disabled="true"]):hover,
input[type="submit"]:enabled:hover,
input[type="reset"]:enabled:hover,
input[type="button"]:enabled:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  cursor: pointer;
}

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

/* ------------------------- Forms ------------------------- */

/* Reset default appearance */
textarea,
select,
input,
progress {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

textarea,
select,
input,
button,
.button {
  font-size: inherit;
  font-family: inherit;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--standard-border-radius);
  box-shadow: none;
  max-width: 100%;
  display: inline-block;
}
textarea,
select,
input {
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
}
label {
  display: block;
}
textarea:not([cols]) {
  width: 100%;
}


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

/* Add arrow to drop-down */
select:not([multiple]) {
  background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
    linear-gradient(135deg, var(--text) 51%, transparent 49%);
  background-position: calc(100% - 15px), calc(100% - 10px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 25px;
}
*[dir="rtl"] select:not([multiple]) {
  background-position: 10px, 15px;
}

/* 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;
}

input[type="radio"] {
  border-radius: 100%;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: var(--accent);
}

input[type="checkbox"]:checked::after {
  /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
  content: " ";
  width: 0.18em;
  height: 0.32em;
  border-radius: 0;
  position: absolute;
  top: 0.05em;
  left: 0.17em;
  background-color: transparent;
  border-right: solid var(--bg) 0.08em;
  border-bottom: solid var(--bg) 0.08em;
  font-size: 1.8em;
  transform: rotate(45deg);
}
input[type="radio"]:checked::after {
  /* creates a colored circle for the checked radio button  */
  content: " ";
  width: 0.25em;
  height: 0.25em;
  border-radius: 100%;
  position: absolute;
  top: 0.125em;
  background-color: var(--bg);
  left: 0.125em;
  font-size: 32px;
}

/* 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;
}

/* TODO: copy styling from https://x4qtf8.csb.app/
/* Redo range field; FIX radio field in HTML */


/* ------------------------- Progress Bar ------------------------- */
/* Declarations are repeated because you cannot combine vendor-specific selectors */
/* Replaced styling with the one from: 
    https://verpex.com/blog/website-tips/how-to-style-a-progress-bar-using-css */

progress[value] {
  --progress-color: blue;     /* the progress color */
  --progress-bg: lightgrey;   /* the background color */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  width: 200px;
  margin: 0 10px;
  border-radius: 10em;
  background: var(--progress-bg);
}
progress[value]::-webkit-progress-bar {
  border-radius: 10em;
  background: var(--progress-bg);
}
progress[value]::-webkit-progress-value {
  border-radius: 10em;
  background: var(--progress-color);
}
progress[value]::-moz-progress-bar {
  border-radius: 10em;
  background: var(--progress-color);
}

/*
  TODO: add styling for "progress:indeterminate"
  ISSUE: the corners don't follow rounding.
  ISSUE: there's no moving element like in Mozilla docs:
         https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate

  progress[value]:indeterminate {
    border-radius: 10em;
    background: var(--progress-bg);
  }
  progress[value]:indeterminate::-moz-progress-bar {
    border-radius: 10em;
    background: var(--progress-bg);
  }
*/


/* ------------------------- Dialog Popup -------------------------
  Credit: 
  https://developer.mozilla.org/en-US/play (demo)
  https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog 
*/

dialog::backdrop {
  /* background-color: black; */
  background-image: linear-gradient(
    45deg,
    magenta,
    rebeccapurple,
    dodgerblue,
    green
  );
  opacity: 0.75;
}

dialog {
  background-color: var(--bg);
  max-width: 640px;
  padding: 1rem;
  margin: auto;
  border: none;
  /* border: 1px solid var(--border); 
  box-shadow: 2px 4px var(--border); */
  border-radius: var(--standard-border-radius);
}

@media only screen and (max-width: 720px) {
  dialog {
    max-width: 100%;
    margin: auto 1em;
  }
}


/* --------------------------------------------------------------------------- */
/* Mobile Mode */
/* --------------------------------------------------------------------------- */
  

/* --------------------------------------------------------------------------- */
/* Print Mode */
/* --------------------------------------------------------------------------- */

@media print {
  /* @page doesn't work so doing html instead */
  html {
    margin: 1cm;
    background: none !important;
  }
  body {
    display: block;
  }

  /* Hide header, nav, and footer */
  body header,
  body nav,
  body footer,
  .breadcrumbs {
    display: none;
  }
  article {
    border: none;
    padding: 0;
  }

  a[href^="http"]::after {
    /* content: " <" attr(href) ">";  *//* Show contents of links */
    content: none !important;           /* Do NOT show contents of links */
  }
  abbr[title]:after {
    content: " (" attr(title) ")";
  }
  a {
    text-decoration: none;
  }
  p {
    widows: 3;
    orphans: 3;
  }
  hr {
    border-top: 1px solid var(--border);
  }
  mark {
    border: 1px solid var(--border);
  }
  pre, table, figure, img, svg {
    break-inside: avoid;
  }
  pre code {
    white-space: pre-wrap;
  }
}
