@import url("../vendor/fontawesome/css/all.css");
@import url("./buttons.css");

/**********************/
/* Variables
/**********************/

html {
  --details-background-color: rgba(0, 0, 0, 0.03);
  --summary-background-color: rgba(0, 0, 0, 0.05);
  --summary-hover-color: rgba(0, 0, 0, 0.4);
}

html.dark {
  --details-background-color: rgba(255, 255, 255, 0.03);
  --summary-background-color: rgba(255, 255, 255, 0.05);
  --summary-hover-color: rgba(255, 255, 255, 0.4);
}

/**********************/
/* HEADER
/**********************/

header {
  margin: 0 0 2rem 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  background: var(--primary-color);
  padding: 2rem 0 2rem;
  width: 100%;
}

header > h1,
header > h2 {
  color: white;
  line-height: 1.5;
  margin: auto;
  border: none;
}

header > h1 {
  font-size: 3rem;
  margin: 0 auto;
  padding: 0;
}

header > h2 {
  font-size: 2rem;
  margin: 0 auto;
  padding: 0;
  font-family: inherit;
  font-weight: normal;
}

header nav {
  margin-bottom: 0.5rem;
}

/**********************/
/* H1/H2 in non-header
/**********************/

h1 {
  font-size: 1.5rem;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

h2 {
  font-size: 1.25rem;
  margin-top: 2em;
  font-family: inherit;
}

hr {
  margin-top: 2rem;
}

details input {
  box-sizing: border-box;
  width: 100%;
}

/********************************/
/*       Actual content         */
/********************************/

html {
  width: 100%;
  height: 100dvh;
  position: relative;
  accent-color: var(--accent3);
}

body.index {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  background: var(--background-color);
  color: var(--foreground-color);
  text-align: justify;
  margin: auto;
  min-width: 100%;
  max-width: 100%;
  height: unset;
  min-height: 100vh;
  line-height: 1.3; /* It is said 1.5 improves readability */
}

main {
  min-height: 100%;
  width: 50rem;
  max-width: 100%;
  box-sizing: border-box;
  padding: 1rem;
  margin: auto;
}

footer {
  inset: 0;
  border-top: 1px solid var(--shade4);
  font-style: italic;
  font-size: 1rem;
  margin: 2rem 0 0 0;
}

footer p {
  display: inline-block;
  width: 100%;
  margin: 0;
  padding: 0.5em;
  line-height: 2em;
  text-align: center;
  box-sizing: border-box;
}

a {
  color: var(--accent5-fg);
  text-decoration: none;
}

a:hover {
  text-shadow: none;
  text-decoration: underline;
  border: none;
}

del {
  text-decoration-line: line-through;
  text-decoration-thickness: 0.3em;
  text-decoration-color: var(--redish);
}

/*********************************************
 * Detail boxes
 *********************************************/

div.media > figure {
  box-sizing: border-box;
  margin: auto;
  width: 100%;
}

details {
  box-sizing: border-box;
  margin-top: 20px;
  padding: 1em;
  padding-bottom: 0;
  border-radius: 10px;
  background: var(--details-background-color);
}
details[open] {
  padding-bottom: 1em;
}

details summary {
  box-sizing: border-box;
  width: auto;
  margin-left: -1em;
  margin-right: -1em;
  margin-top: -1em;
  margin-bottom: 0em;
  padding: 4px;
  padding-left: 0.5rem;
  border-radius: 8px;
  background: var(--summary-background-color);
  border: none;
  outline: none;
  cursor: pointer;
  font-weight: normal;
  font-size: 1em;
}

details[open] > summary {
  margin-bottom: 1em;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

details summary:hover {
  background-color: var(--summary-hover-color);
  color: var(--background-color);
}

details input {
  box-sizing: border-box;
  font-size: 1.25em;
  width: 100%;
}

/*********************************************
 * TABLES
 *********************************************/

table.search td {
  vertical-align: top;
}
table.search td span {
  line-height: 1.3;
}

body.index table {
  display: table;
  width: 100%;
  margin: auto;
  border-collapse: collapse;
  border-spacing: 2px;
  text-align: center;
  margin-bottom: 1em;
  line-height: 1.5em;
  border-top: 1px solid var(--shade4);
  border-bottom: 1px solid var(--shade4);
}

body.index table caption {
  margin: 10px 0px 0px 0px;
  line-height: 1.2;
  font-style: italic;
  font-size: 0.8em;
  text-align: center;
  caption-side: bottom;
}

body.index table th {
  font-weight: bold;
}

body.index table th {
  border-bottom: 1px solid var(--shade4);
}

body.index table th,
body.index table td {
  text-align: left;
  padding: 0.2em;
  line-height: 2;
}

body.index table th[align="center"],
body.index table td[align="center"] {
  text-align: center;
}

body.index table th[align="right"],
body.index table td[align="right"] {
  text-align: right;
}

body.index table tbody tr:last-child th,
body.index table tbody tr:last-child td {
  border-bottom: none;
}

body.index table :is(p, span) {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
  vertical-align: middle;
}

/* column with icons should be as small as possible */
body.index table tr td:has(.icons) {
  width: 1%;
}

p {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

a,
button,
input,
select,
h2,
tr,
summary,
textarea,
.progress,
.icons {
  transition: outline-offset 0.1s ease !important;
  outline-offset: 30px;
  &:focus-visible {
    outline: solid 3px var(--focus-color) !important;
    outline-offset: -1px !important;
  }
  &:active {
    outline-offset: -3px !important;
  }
}

.german {
  display: none;
}

html[lang="de"] .german {
  display: unset;
}

html[lang="de"] .english {
  display: none;
}

details.howto[lang="en"] .english {
  display: unset !important;
}

details.howto[lang="de"] .english {
  display: none !important;
}

details.howto[lang="de"] .german {
  display: unset !important;
}

details.howto[lang="en"] .german {
  display: none !important;
}

a.handout-link {
  display: inline-block;
  vertical-align: bottom;
  position: relative;
  width: 1em;
  height: 1em;
}

a.handout-link::before {
  display: block;
  position: absolute;
  content: "";
  top: 0;
  left: 5%;
  width: 0.8em;
  height: 0.45em;
  background-color: var(--accent5-fg);
  border-radius: 2px;
}

a.handout-link::after {
  display: block;
  position: absolute;
  content: "";
  bottom: 0;
  left: 5%;
  width: 0.8em;
  height: 0.45em;
  background-color: var(--accent5-fg);
  border-radius: 2px;
}

a.handout-link:hover::before,
a.handout-link:hover::after {
  background-color: var(--accent5);
}

.icons {
  font-size: 1.25rem;
  display: inline-flex;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: center;
  justify-content: space-evenly;
  align-items: center;
  border-radius: 0.2em;
  padding: 0;
  line-height: 1;
  gap: 1em;
  & > a {
    width: 1em;
    height: 1em;
    border-radius: 0.1em;
    line-height: 1em;
    padding: 0.2em;
  }
  & > a[href$="deck.html"] {
    order: 1;
  }
  & > a[href$="deck.html?handout"] {
    order: 2;
  }
  & > a[href$="deck.html?a11y"] {
    order: 3;
  }
  & > a[href$="deck.pdf"] {
    order: 4;
  }
  & > .progress {
    order: 5;
  }
}

.icons a[href$="deck.html"],
.icons a[href$="deck.html?handout"] {
  position: relative;
  &::after,
  &::before {
    display: block;
    position: absolute;
    content: "";
    width: 0.9em;
    height: 0.5em;
    left: 50%;
    top: 50%;
    background-color: var(--accent5-fg);
    border-radius: 0.15em;
    box-sizing: border-box;
    box-shadow: var(--background-color) 0.07em 0.07em;
  }
}
.icons a[href$="deck.html?handout"] {
  &::after {
    translate: -50% -110%;
  }
  &::before {
    translate: -50% 10%;
  }
}
.icons a[href$="deck.html"] {
  & > i.fa-html5 {
    display: none;
  }
  &::after {
    translate: -60% -80%;
  }
  &::before {
    translate: -30% -30%;
  }
}

/* hide empty lists */
section[data-items="0"] {
  display: none;
}

.index details {
  position: relative;
  & select {
    position: absolute;

    /* size should fit top-right corner of select-summary */
    right: 0;
    top: 0;
    height: 30px;
    font-size: 24px;
    border-radius: 0;
    border-top-right-radius: 8px;
    padding: 0;
    padding-left: 4px;

    outline: none;
    border: none;
    background: none;
    cursor: pointer;

    /* remove browser-specific appearance */
    -webkit-appearance: none;
    appearance: none;

    /* Add arrow icon. Source: https://material.io/tools/icons/?icon=keyboard_arrow_down&style=baseline */
    padding-right: 24px;
    background-image: url('data:image/svg+xml;charset=utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" xml:space="preserve"><path d="M7.41,8.59L12,13.17l4.59-4.58L18,10l-6,6l-6-6L7.41,8.59z"/><path fill="none" d="M0,0h24v24H0V0z"/></svg>');
    background-position: center right;
    background-repeat: no-repeat;

    &:hover {
      background-color: var(--greenish);
    }
  }
  & li {
    margin-bottom: 0.5em;
  }
}

/* markers can not have a right padding */
details.howto > summary::marker {
  content: "";
}

details[role="search"] > summary::marker {
  content: "";
}

details[role="search"] > summary::before {
  content: "\f002";
  font-family: "Font Awesome 7 Free";
  font-weight: 900;
  color: var(--greenish);
  padding-right: 0.5rem;
}

details.howto > summary::before {
  content: "\3f";
  font-family: "Font Awesome 7 Free";
  font-weight: 900;
  color: var(--greenish);
  padding-right: 0.5rem;
}

details.chatty {
  & summary::marker {
    content: "";
  }
  & summary::before {
    content: "\f544";
    font-family: "Font Awesome 7 Free";
    font-weight: 900;
    color: var(--greenish);
    padding-right: 0.5rem;
  }
}
