/* dark mode by default */
:root {
  color-scheme: dark;
  /* see https://stackoverflow.com/a/53336754/1614140 for more info on filters */
  --icon-filter: invert(99%) sepia(3%) saturate(384%) hue-rotate(236deg) brightness(115%) contrast(73%);
  transition: background 0.3s ease, color 0.3s ease, border 0.3s ease;
}

:root[data-theme="light"] {
  color-scheme: light;
  --icon-filter: invert(32%) sepia(0%) saturate(2%) hue-rotate(199deg) brightness(95%) contrast(85%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* see https://stackoverflow.com/a/53336754/1614140 for more info on filters */
  --icon-filter: invert(99%) sepia(3%) saturate(384%) hue-rotate(236deg) brightness(115%) contrast(73%);
}

body {
  background: light-dark(#f5f5f5, #222);
  color: light-dark(#222, #f5f5f5);
}

a {
  color: light-dark(#06e, #8cf);
}

/* Maple Mono font */
@font-face {
  font-family: "Maple Mono";
  src: url("/assets/fonts/MapleMonoNormal-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Maple Mono";
  src: url("/assets/fonts/MapleMonoNormal-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "Maple Mono";
  src: url("/assets/fonts/MapleMonoNormal-Italic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
}

/* Courier Prime font */
@font-face {
  font-family: "Courier Prime";
  src: url("/assets/fonts/courierprime-regular.woff2") format("woff2")
       url("/assets/fonts/courierprime-regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "Courier Prime";
  src: url("/assets/fonts/courierprime-bold.woff2") format("woff2")
       url("/assets/fonts/courierprime-bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Maple Mono", monospace;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header, footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: light-dark(#fff, #111);
  z-index: 100;
}

header {
  border-bottom: 2px solid light-dark(#ddd, #000);
}

footer {
  border-top: 2px solid light-dark(#ddd, #000);
}

.site-title {
  font-family: "Courier Prime", "Maple Mono";
  font-weight: 700;
}

nav a {
  margin-left: 1rem;
  text-decoration: none;
  color: light-dark(#333, #f5f5f5);
}

nav a:hover {
  text-decoration: underline;
}

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
  flex: 1;  /* stretch vertically to fill, i.e., push footer to bottom */
}

h1, h2, h3 {
  font-family: "Courier Prime", "Maple Mono";
  font-weight: 700;
}

/* custom icons (might be unnecessary)*/
.icon {
  width: 1rem;
  height: 1rem;
  filter: var(--icon-filter);
}

/* avatar on homepage */
div.avatar {
  width: 15rem;            /* circle size */
  aspect-ratio: 1/1;       /* square */
  border-radius: 50%;      /* makes it a circle */
  overflow: hidden;        /* crops the image into the circle */
  border: 5px solid light-dark(#cb9885, #a3705c);  /* circle border */
  margin: 0 auto;
}

div.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;       /* ensures the image fills the circle */
  display: block;
}

/* callouts */
.callout {
  --icon: url("/assets/icons/info.svg"); /* default */
  position: relative;
  padding: 1rem 1rem 1rem 2.5rem;
  background: light-dark(#f6f7fa, #282828);
  border-left: 4px solid light-dark(#6c7280, #878b93);
  margin: 1rem 0;
  color: light-dark(#2b2f36, #e3e3e3);
}

/* pseudo-element for the icon */
.callout::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 1rem;
  width: 1rem;
  height: 1rem;

  /* mask technique */
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;

  background: currentColor; /* icon inherits text color */
}

.callout-date {
  --icon: url("/assets/icons/calendar.svg");
}

.callout-quote {
  --icon: url("/assets/icons/quote.svg");
}

/* cards */
.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid light-dark(#ddd, #444);
  padding: 1rem;
  border-radius: 0.5rem;
  position: relative;
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: light-dark(#555, #aaa);
  font-size: 0.9rem;
}

.card:hover {
  border-color: light-dark(#aaa, #888);
}

.card a {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  width: 20px;                 /* size of the icon */
  height: 20px;
}

#theme-toggle {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 2px solid light-dark(#ddd, #1f2937);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

#theme-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.5rem;
}

.socials .icon {
  width: 1.5rem;
  height: 1.5rem;
  margin-left: 0.5rem;
}

/* default is dark mode, so hide it's icon */
.icon-dark {
  display: none;
}
.icon-light {
  display: inline;
}

/* if light mode active, flip the icon states */
:root[data-theme="light"] .icon-light {
  display: none;
}
:root[data-theme="light"] .icon-dark {
  display: inline;
}
