/*--------------------------------------------------------*/
/*            Default variables and sections              */
/*--------------------------------------------------------*/

:root {
  /* Typography: augmented fourth scale (1.414) */
  --font-2xs: 0.7rem;
  --font-xs: 0.8rem;
  --font-s: 1rem; /* 16px */
  --font-m: 1.414rem; /* 23px */
  --font-l: 1.999rem; /* 32px */
  --font-xl: 2.827rem; /* 45px */
  --font-2xl: 3.998rem; /* 64px */
  /* Spacings */
  --space-xs: 8px; /* 0.5rem */
  --space-s: 16px; /* 1rem */
  --space-m: 24px;
  --space-l: 32px; /* 2rem */
  --space-xl: 40px;
  --space-2xl: 48px; /* 3rem */
  --space-3xl: 56px;
  --space-4xl: 64px; /* 4rem */
  --space-5xl: 80px; /* 5rem */
  /* Colors */
  --white: hsl(0, 0%, 97%);
  --white-blue: hsl(235, 31%, 76%); /* --white on --blue-dark, opacity 70% */
  --black: hsl(236, 100%, 10%);
  --red: hsl(0, 100%, 46%);
  --red-light: hsl(0, 100%, 66%);
  --blue: hsl(236, 100%, 47%);
  --blue-white: hsl(236, 87%, 62%); /* --blue on --white, opacity 70% */
  --blue-dark: hsl(236, 100%, 25%);
  --yellow: hsl(50, 100%, 60%);
  /* Other */
  --screen-sm: 370px;
  --screen-md: 768px;
  --screen-lg: 1200px;
  --article-width: 600px;
  --side-width: calc((100vw - var(--article-width)) / 2);
  --line-thickness: 1px;
}

/* GENERAL TAGS */
html {
  font-size: 16px;
  --font-mono: ui-monospace, "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;
  --color-bg: var(--white);
  --color-text: var(--blue);
  --color-text-subtle: var(--blue-white);
  --color-text-highlight: var(--yellow);
  --color-accent: var(--red);
}
body {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--font-s);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
}
main {
  width: 100%;
  padding: var(--space-l) var(--space-m);
  flex: 1 0 auto; /* makes sure index.html main takes all available space */
}
header {
  width: 100%;
}
footer {
  position: relative;
  width: 100%;
  text-align: center;
  padding-top: var(--space-m);
}

/* NAV */
nav {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
#menu-button {
  margin: var(--space-xs);
}
#menu-button::after {
  content: "\00A0⊙"/ "";
  color: var(--color-accent);
  font-size: 1.3rem;
}
#menu {
  text-align: center;
  /* Reset */
  list-style: none;
  margin: 0 var(--space-s);
  padding: 0;
}
#menu li {
  display: inline-block;
  margin: var(--space-xs);
}
#menu-button.js-enabled {
  display: inline-block;
}
#menu.js-enabled {
  display: none;
}
#menu.expanded {
  display: inline-block;
}
#menu .icon {
  background-color: var(--color-accent);
  height: 1em;
  width: 1em;
  display: inline-block;
  position: relative;
  top: 0.1em;
}

/* BACKGROUND DECORATION: lines */
.bg-deco {
  z-index: -100;
  background-color: var(--color-accent);
}
.deco-vert-1,
.deco-vert-2 {
  position: fixed;
  mask: no-repeat url("/public/img/meta/20231127-vertical-line.svg");
  width: 9px;
  height: 100%;
}
.deco-vert-1 {
  left: 0;
}
.deco-vert-2 {
  right: -1px;
  transform: rotate(180deg);
}
.deco-horiz-1,
.deco-horiz-2 {
  position: relative;
  mask: no-repeat url("/public/img/meta/horizontal-line.svg");
  width: 100%;
  height: 15px;
}
.deco-horiz-2 {
  margin-top: var(--space-s);
  transform: rotate(180deg);
}

/* DIALOGS */
dialog {
  background: var(--color-bg);
  color: var(--color-text);
  width: 100%;
  padding: var(--space-2xl) var(--space-m) var(--space-m) var(--space-m);
}
dialog[open]::backdrop {
  background-color: rgb(0 0 0 / 0.3);
}
dialog .close-button {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  border: none;
  box-shadow: none;
}

/* ACCESSIBILITY */
/* Not visible, but read by screen reader */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
/* Skip to content button (before nav) */
#skip-to-content {
  z-index: 2;
  position: absolute;
  transform: translateY(-280%);
  transition: transform 0.3s;
  margin: 0.5rem;
  /* Removes default link styles */
  border: none;
}
#skip-to-content:focus {
  transform: translateY(20%);
}

/*--------------------------------------------------------*/
/*                   Shared components                    */
/*--------------------------------------------------------*/

/* Intro: centered paragraph at the top of a page */
.intro {
  max-width: var(--article-width);
  margin-block: var(--space-2xl);
  text-align: center;
}

/* Post header: page/post title and meta info */
.post-header {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-2xl);
  max-width: var(--screen-md);
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
}

/* Headline row: page H1 + optional icon */
.headline-row {
  display: flex;
  align-items: center;
  gap: var(--space-m);
}
.headline-row .icon {
  background-color: var(--yellow);
  height: 3.5rem;
  width: 3.5rem;
}

/* For list-filter-selector.njk */
.posts-filter {
  margin-block: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  text-align: center; /* ensures that centered in mobile as well */
}

/* TYPOGRAPHY & CONTENT FLOW */
/* Regular vertical margins */
p,
ul,
ol,
h2,
.h2,
h3,
.h3 {
  margin-block: 1rem;
}
/* Bigger vertical margins */
aside,
blockquote,
pre,
figure, 
table,
p > img /* images not in <figure> that appear in Markdown files only (blog posts) */ {
  margin-block: 2rem;
}

/* Tables */
table {
  border-collapse: collapse;
}
table thead {
  border-bottom: 1px solid var(--color-text);
}
table tbody tr {
  border-bottom: 1px solid var(--color-text);
}
table tbody tr td {
  padding: var(--font-2xs);
}

/* Image flow */
img + img {
  margin-top: 1rem;
}
figcaption {
  margin-top: var(--space-xs);
  font-style: italic;
  /* below similar to .label */
  font-size: var(--font-2xs);
}

/* Headings: size and flow */
h1,
h2,
h3,
.h1,
.h2,
.h3 {
  font-weight: bold;
  text-transform: capitalize;
}
h1,
.h1 {
  font-size: var(--font-xl);
  line-height: 1.1;
  font-style: italic;
  text-transform: uppercase;
}
h2,
.h2 {
  font-size: var(--font-m);
  line-height: 1.2;
  margin-top: 3rem;
  text-transform: uppercase;
}
h3,
.h3 {
  font-size: var(--font-s);
  line-height: 1.4;
  margin-top: 2rem;
}
/* Body text flow */
li {
  margin-bottom: 0.5rem;
}
/* Small labels */
.label {
  text-transform: uppercase;
  font-size: var(--font-2xs);
  letter-spacing: 0.1em;
}
/* Blockquotes */
blockquote {
  position: relative;
  margin-right: 0;
  margin-left: 2rem;
  font-size: var(--font-xs);
}
blockquote > p::before {
  content: "";
  border-left: 0.5rem solid;
  position: absolute;
  height: 1.5rem;
  left: -2rem;
  top: 0;
}
/* Pre and code tags */
pre {
  overflow: auto;
  padding: var(--space-m);
  background-color: var(--black);
  color: var(--white);
}
code,
kbd {
  font-size: var(--font-xs);
  font-weight: bold;
}
*:not(pre) > code,
kbd {
  background-color: var(--color-text);
  color: var(--color-bg);
  padding: 0.05em 0.3em;
}
/* Cite tag */
cite {
  text-transform: uppercase;
  letter-spacing: -0.03em;
  font-size: 0.9em;
}
/* Divider */
hr {
  color: var(--color-text);
  border: none;
  margin-block: 3rem;
  display: flex;
  justify-content: center;
  font-size: 1rem;
}
hr::before {
  /* \002B is a plus sign */
  content: "\002B\00a0\002B\00a0\002B"/ "";
  color: var(--color-text-subtle);
}
/* Aside */
aside {
  font-size: smaller;
  border: solid 1px var(--color-text-subtle);
  padding: 2rem;
}
/* cancels normal typography margins */
aside :first-child {
  margin-top: 0rem;
}
aside :last-child {
  margin-bottom: 0rem;
}
/* ~striked-through text~ styles and accessibility */
del {
  text-decoration-thickness: var(--line-thickness);
}
del::before,
del::after {
  clip-path: inset(100%);
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}
del::before {
  content: " [start of strikethrough text] ";
}
del::after {
  content: " [end of strikethrough text] ";
}
/* Lists without bullets (i.e. posts page) */
.nobullet,
.nobullet > li {
  padding: 0;
  list-style: none;
}
/* Details */
details summary {
  cursor: pointer;
}
/* Buttons */
button,
.button {
  display: inline-block;
  cursor: pointer;
  font: inherit;
  width: max-content;
  text-decoration: none;
  padding: 0.1em 0.6em;
  color: var(--color-text);
  background-color: transparent;
  border: var(--line-thickness) solid var(--color-text);
  transition: transform 0.1s ease-in-out;
  box-shadow: 2px 2px;
}
button:hover,
button:focus,
.button:hover,
.button:focus {
  text-decoration: none;
  background-color: var(--color-text-highlight);
  box-shadow: 1px 1px;
  transform: translate(1px, 1px);
}
/* Normal links */
a,
.secondary-link {
  color: var(--color-text);
  background-image: linear-gradient(
    120deg,
    var(--color-text-highlight),
    var(--color-text-highlight)
  );
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 105% 0;
  transition: background-size 0.125s ease-in;
  text-underline-offset: 0.3em;
}
a {
  text-decoration: var(--line-thickness) underline;
}
.secondary-link {
  text-decoration: none;
  line-height: 1.1;
}
a:hover,
a:focus,
.secondary-link:hover,
.secondary-link:focus {
  background-size: 100% 100%;
  text-decoration: var(--line-thickness) underline;
}
a:focus,
.secondary-link:focus {
  outline: 1px solid;
}
.secondary-link,
.secondary-link:hover,
.secondary-link:focus {
  text-transform: uppercase;
  font-weight: bold;
  /* reset styles */
  border: none;
  padding: 0;
  box-shadow: none;
  transform: none;
}
/* Card link (i.e. media page) */
.card-link {
  overflow: hidden;
  /* Reset link styles */
  background: none;
  border: none;
}
.card-link > div {
  background-color: var(--red);
  height: 100%;
}
.card-link:hover img,
.card-link:focus img {
  mix-blend-mode: screen;
  filter: grayscale(100%) brightness(0.5) blur(1px);
}
/* External links */
a[href*="//"]:not([href*="clarale.com"])::after, .external-link::after
{
  content: "\00A0\2197"/ "";
}
/* Forms */
input[type="checkbox"] {
  margin-right: 0.25rem;
}
/* Footnotes */
.footnotes {
  font-size: var(--font-xs);
}
.footnote-ref > a {
  text-decoration: none;
}

/* UTILS */
/* Hide visibly and from screen-reader */
.hide {
  display: none;
}
/* Limit content width and make smaller (i.e. for articles) */
.center {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--article-width);
}
/* Make text smaller */
.subtle {
  /* font styles smaller than body */
  font-size: var(--font-xs);
}
/* .post-rows and .post-rows-with-label (with date) */
.post-rows > li .subtle,
.post-rows-with-label > li .subtle {
  display: block;
  margin-top: 0.25rem;
}
.post-rows-with-label > li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-direction: column;
  margin-bottom: 1.5rem;
}
.post-rows-with-label > li .label {
  min-width: 5em;
  color: var(--color-text-subtle);
}
/* To make filters work */
.post-rows-with-label > li[hidden],
.post-rows > li[hidden] {
  display: none;
}
/* Highlight text (reverse colors) */
.highlight {
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.25em 0.5em;
  font-size: var(--font-xs);
  vertical-align: text-bottom;
}
/* Divide list: add subtle divider slash between items */
.divide-list > *:not(:last-child)::after {
  content: " / ";
  color: var(--color-text-subtle);
}

/*--------------------------------------------------------*/
/*               Custom pages or elements                 */
/*--------------------------------------------------------*/

/* SEARCH-DIALOG */
#search-dialog form {
  margin-bottom: var(--space-2xl);
}
#search-dialog form > div {
  display: flex;
  gap: var(--space-xs);
}
#search-dialog form #search-input {
  width: 100%;
}

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

/* DARK MODE */

@media (prefers-color-scheme: dark) {
  html {
    --color-bg: var(--blue-dark);
    --color-text: var(--white);
    --color-text-subtle: var(--white-blue);
    --color-accent: var(--red-light);
  }
  a:hover,
  a:active,
  a:focus {
    color: var(--color-bg);
  }
  button:hover,
  .button:hover,
  button:active,
  .button:active,
  button:focus,
  .button:focus {
    color: var(--color-bg);
    box-shadow: 2px 2px var(--color-bg); /* only change color */
  }
}

/* BIGGER THAN MOBILE */

@media only screen and (min-width: 370px) {
  /* GENERAL TAGS */
  html {
    font-size: 18px;
  }
  main {
    padding-left: var(--space-2xl);
    padding-right: var(--space-2xl);
  }
  footer {
    padding-bottom: var(--space-s);
  }
  /* BACKGROUND DECORATION */
  .deco-vert-1 {
    left: var(--space-s);
  }
  .deco-vert-2 {
    right: var(--space-s);
  }
  /* UTILS */
  .post-rows-with-label > li {
    flex-direction: row;
  }
}
@media only screen and (min-width: 768px) {
  /* GENERAL TAGS */
  main {
    padding-left: var(--space-2xl);
    padding-right: var(--space-2xl);
  }
  /* NAV */
  /* On bigger screens, do not hide menu items */
  nav {
    flex-direction: row;
  }
  #menu-button.js-enabled {
    display: none;
  }
  #menu.js-enabled,
  #menu.expanded {
    display: unset;
  }
  /* DIALOGS */
  /* Add extra margins of bigger screens */
  dialog {
    margin-top: var(--space-s);
    margin-bottom: var(--space-s);
  }
  /* TYPOGRAPHY */
  h1,
  .h1 {
    font-size: var(--font-2xl);
  }
  .label,
  figcaption {
    font-size: var(--font-xs);
  }
}
@media only screen and (min-width: 1200px) {
  /* FOOTNOTES */
  /* Display at the bottom of the page on desktop */
  .footnote-item {
    position: absolute;
    right: 0;
    padding-right: var(--space-2xl);
    width: calc(var(--side-width) - var(--space-2xl));
  }
  .footnote-item > p {
    /* Avoids misalignment of footnote */
    margin-top: 0;
  }
  .footnotes-sep {
    display: none;
  }
}
