/*************************************************
  CSS RESET:
  https://www.joshwcomeau.com/css/custom-css-reset/
**************************************************/

*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}
input,
button,
textarea,
select {
  font: inherit;
}
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/**
 * Prevent `sub` and `sup` affecting `line-height` in all browsers.
 */

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}
sup {
  top: -0.5em;
}
sub {
  bottom: -0.25em;
}

#root,
#__next {
  isolation: isolate;
}

/* Remove headline styles */
h1,
h2,
h3,
h4,
.h1,
.h2,
.h3,
.h4 {
  font-weight: unset;
}

/* From https://piccalil.li/blog/a-modern-css-reset/ */
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/*************************************************
  OUR CUSTOM CSS
*************************************************/

:root {
  /* Typography: major third scale (1.250) */
  --font-xs: 0.7rem;
  --font-s: 1rem;
  --font-m: 1.25rem;
  --font-l: 1.563rem;
  --font-xl: 1.953rem;
  --font-2xl: 2.441rem;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  --font-sans: Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif;
  /* Spacings */
  --space-xs: 10px;
  --space-s: 20px;
  --space-m: 30px;
  --space-l: 40px;
  /* Colors */
  --white: rgb(249, 249, 252);
  --white-lighter: rgb(251, 251, 254);
  --black: rgb(28, 27, 34);
  --black-lighter: rgb(39, 39, 39);
  --grey-on-white: #6d6d6d;
  --grey-on-black: #a7a7a7;
  /* Other */
  --width-content: 650px;
  --width-content-large: 1200px;
  --border-radius: 5px;
  --box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 5px 0px,
    rgba(0, 0, 0, 0.1) 0px 0px 1px 0px;
  --text-decoration-underline: underline 0.03em;
}

/*** Big blocks ***/

html {
  font-size: 18px;
  font-family: var(--font-serif);
  --color-bg: var(--white);
  --color-bg-alt: var(--white-lighter);
  --color-text: var(--black);
  --color-subtle: var(--grey-on-white);
}
body {
  font-size: var(--font-s);
  line-height: 1.6;
  background-color: var(--color-bg);
  color: var(--color-text);
  margin-bottom: var(--space-l);
}
footer {
  margin-top: 3rem;
}

/* Nav */
nav ul {
  display: flex;
  flex-direction: row;
  gap: var(--space-s);
  color: var(--color-subtle);
  justify-content: center;
}
/* Links in various nav */
nav a,
#reader-back-to-top {
  font-family: var(--font-sans);
  font-size: var(--font-xs);
  font-weight: bold;
  text-decoration: none;
}
nav a:hover,
nav a:focus,
.nav-selected,
#reader-back-to-top:hover,
#reader-back-to-top:focus {
  color: var(--color-text);
  text-decoration: var(--text-decoration-underline);
  text-underline-position: under;
}

/*** Text flow ***/

h1,
h2,
h3,
.h1,
.h2,
.h3 {
  line-height: 1.25;
  margin: 2rem 0 1rem 0;
}
h1,
.h1 {
  font-size: var(--font-xl);
  text-align: center;
}
h2,
.h2 {
  font-size: var(--font-m);
}
h3,
.h3 {
  font-size: var(--font-s);
}
p,
ul,
ol {
  margin: 1rem 0;
}
li {
  margin: 0.5rem 0;
}
figcaption {
  font-size: var(--font-xs);
  color: var(--color-subtle);
  text-align: center;
}
img {
  border-radius: var(--border-radius);
  margin: 1rem 0;
  height: auto;
  font-style: italic; /* Style alt tags */
}
iframe {
  width: 100%;
}
img,
iframe {
  background-color: var(--color-bg-alt);
  box-shadow: var(--box-shadow) inset;
}
form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
input {
  width: fit-content;
}
hr::before {
  content: "\2217\00A0\2217\00A0\2217";
  color: var(--color-subtle);
}
hr {
  margin: 2rem auto;
  border: none;
  text-align: center;
}
pre {
  overflow: scroll;
  margin: 2rem 0;
  padding: var(--space-s);
  border-radius: var(--border-radius);
  background-color: var(--color-bg-alt);
  box-shadow: var(--box-shadow);
}
code {
  font-size: var(--font-xs);
}
kbd {
  font-size: var(--font-xs);
  background: var(--color-text);
  color: var(--color-bg);
  padding: 0.25em 0.5em;
  border-radius: 2px;
  vertical-align: text-bottom;
}
blockquote {
  font-style: italic;
  margin: 2rem 0;
  padding-left: var(--space-m);
  border-left: solid 1px;
  color: var(--color-subtle);
}
cite {
  font-style: italic;
}
a {
  color: inherit;
  text-underline-offset: 0.2em;
}
a:visited:hover,
a:visited:focus,
a:hover,
a:focus {
  color: var(--color-text);
}
button,
input[type="submit"] {
  cursor: pointer;
}

/* Action buttons: positioning */

.action-buttons-wrapper {
  display: flex;
  gap: var(--space-s);
  margin: 0;
}
.action-buttons-wrapper button {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-subtle);
  /* Reset button styles */
  border: 0;
  padding: 0;
  background-color: transparent;
}

/* Action buttons: icon behavior */
.action-buttons-wrapper button > .icon {
  width: 24px;
  height: 24px;
  mask-position: center;
  mask-repeat: no-repeat;
  background-color: var(--color-subtle);
  /* make icon non-clickable */
  pointer-events: none;
}
.action-buttons-wrapper button:hover,
.action-buttons-wrapper button:focus {
  color: var(--color-text);
}
.action-buttons-wrapper button:hover > .icon,
.action-buttons-wrapper button:focus > .icon {
  background-color: var(--color-text);
}

/* Action buttons: label behavior */
.action-buttons-wrapper button .button-label {
  z-index: 2;
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  /* same styles as .label */
  white-space: nowrap;
  font-size: var(--font-xs);
  font-family: var(--font-sans);
  font-weight: bold;
}
.action-buttons-wrapper button:hover .button-label,
.action-buttons-wrapper button:focus-visible .button-label {
  opacity: 1;
  color: var(--color-text);
}

/* Action buttons: state change */
/* Favorite button */
#button-favorite[aria-pressed="false"] > .icon {
  mask-image: url("/public/heart-outline.svg");
}
#button-favorite[aria-pressed="true"] > .icon {
  mask-image: url("/public/heart-filled.svg");
  background-color: tomato;
}
/* Archive button */
#button-archive[aria-pressed="false"] > .icon {
  mask-image: url("/public/box-outline.svg");
}
#button-archive[aria-pressed="true"] > .icon {
  mask-image: url("/public/box-filled.svg");
  background-color: var(--color-text);
}
/* Delete, note, highlight, copy buttons */
#button-delete > .icon {
  mask-image: url("/public/trash-outline.svg");
}
#button-note > .icon {
  mask-image: url("/public/feather-outline.svg");
}
#button-highlight > .icon {
  mask-image: url("/public/pen-outline.svg");
}
#button-copy > .icon {
  mask-image: url("/public/link-outline.svg");
}

/**********************************************/
/* Utils 
/**********************************************/

.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Center content in a column */

.center {
  margin-left: auto;
  margin-right: auto;
  max-width: var(--width-content);
  padding: 0 var(--space-s);
}

/* Truncate text */

.truncate {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  overflow: hidden;
  /* to set a text line limit, add the following code line to your element (replace "2" accordingly) */
  /* -webkit-line-clamp: 2; */
  /* optionally add a padding-bottom as well to avoid underlines getting cut */
  /* padding-bottom: 2px; */
}

/* List with no styles */

.ul-styles-none {
  list-style-type: none;
  padding: 0;
}
.ul-styles-none > li {
  margin: 0;
}

/* Discreet labels */

.label {
  color: var(--color-subtle);
  white-space: nowrap;
  font-size: var(--font-xs);
  font-family: var(--font-sans);
  font-weight: bold;
  text-decoration: none;
}

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

@media (prefers-color-scheme: dark) {
  html {
    --color-bg: var(--black);
    --color-bg-alt: var(--black-lighter);
    --color-text: var(--white);
    --color-subtle: var(--grey-on-black);
  }
}

@media only screen and (min-width: 768px) {
  html {
    font-size: 20px;
  }

  /* Text flow */
  h3,
  .h3 {
    font-size: var(--font-m);
  }
}

@media only screen and (min-width: 1000px) {
  /* Text flow */
  h1,
  .h1 {
    font-size: var(--font-2xl);
  }
  h2,
  .h2 {
    font-size: var(--font-l);
  }
}
