@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Noto Sans TC Regular'), local('NotoSansTC-Regular'), url(/https/writingjavascript.com/fonts/oswald-v35-latin-regular.woff2) format('woff2');
}

@font-face {
  font-family: 'Noto Sans TC';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Noto Sans TC Regular'), local('NotoSansTC-Regular'), url(/https/writingjavascript.com/fonts/noto-sans-tc-v10-latin-regular.woff2) format('woff2');
}

@font-face {
  font-family: 'Noto Sans TC';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Noto Sans TC Regular'), local('NotoSansTC-Regular'), url(/https/writingjavascript.com/fonts/noto-sans-tc-v10-latin-700.woff2) format('woff2');
}

:root {
  --font-size: 20px;
  --font-family: 'Noto Sans TC', 'Open Sans', Roboto, sans-serif;
  --font-family-heading: Oswald, 'Open Sans', Roboto, sans-serif;
  --line-height: 1.5;

  --color-font: #000;
  --color-frame: #000;
  --color-font-inverted: #fff;
  --color-font-light: #4e4e4e;
  --color-background: #fff;
  --color-background-inverted: #1f1e29;
  --color-background-inverted-shadow: #999;
  --color-background-darker: #ececec;
  --color-background-light: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-font: #ccc;
    --color-frame: #3e3e3e;
    --color-font-inverted: #ccc;
    --color-font-light: #aaa;
    --color-background: #000;
    --color-background-inverted: #222;
    --color-background-inverted-shadow: #191919;
    --color-background-darker: #000;
    --color-background-light: #222;
  }
}

.language-javascript .hljs-comment,
.language-javascript .hljs-deletion,
.language-javascript .hljs-code,
.language-javascript .hljs-number,
.language-javascript .hljs-symbol,
.language-javascript .hljs-bullet {
  color: #fa9f9f;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-background);
}

html {
  justify-content: center;
  display: flex;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--color-font);
  max-width: 68em;
  padding: 1em;
  overflow-x: hidden;
}

p, h1, h2, h3, h4, h5, h6 {
  word-wrap: break-word;
}

h1, h2, h3, h4, h5, h6, th {
  font-family: var(--font-family-heading);
  font-weight: normal;
}

a {
  color: var(--color-font);
}

img {
  max-width: 100%;
  object-fit: contain;
}

table {
  border-collapse: collapse;
}

@media (max-width: 600px) {
  table {
    font-size: 0.7em;
  }
}

table th {
  text-align: left;
  font-size: 1.2em;
}

table tr:nth-child(odd) {
  background: var(--color-background-light);
}

table thead tr:nth-child(odd) {
  background: var(--color-background);
}

table th, table td {
  padding: 0.5em 1em;
}

main {
  max-width: calc(100vw - 2em);
  margin-top: 3em;
}

pre {
  color: var(--color-font-inverted);
  background: var(--color-background-inverted);
  overflow: auto;
  border-radius: 0.5em;
  box-shadow: 0 0.2em 0.4em var(--color-background-inverted-shadow);
  padding: 1.5em;
  font-size: 0.8em;
}

pre code {
  display: inline-block;
  margin-right: 1.5em;
}

p code {
  background: var(--color-background-darker);
  padding: 0.2em;
  margin: -0,2em;
  border-radius: 0.3em;
}

.lazy-image {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.lazy-image > img {
  position: absolute;
  opacity: 0;
}

.display--inline {
  display: inline;
}

.list--unstyled {
  list-style-type: none;
  padding: 0;
}

.link {
  text-decoration: underline;
}

.link--undecorated {
  text-decoration: none;
}

.link--tag {
  display: inline-block;
  padding: 0.8em 0.25em 0.9em 0.25em;
  margin: -0.8em 0 0 -0.25em;
}

.grid {
  display: grid;
  grid-gap: 2em;
}

.main-menu {
  display: flex;
  justify-content: space-between;
}

.main-menu__logotype {
  display: flex;
  align-items: center;
  margin: 0;
}

.main-menu__logotype__text {
  margin-left: 1em;
  font-size: 2.5rem;
  color: var(--color-font-light);
  font-family: var(--font-family-heading);
  position: relative;
  top: -2px;
}

.main-menu__logotype__text h1 {
  font-size: 2.5rem;
  color: var(--color-font-light);
  font-family: var(--font-family-heading);
}

@media (max-width: 600px) {
  .main-menu__logotype__image {
    width: 75px;
    height: 75px;
  }

  .main-menu__logotype__text {
    font-size: 1.5em;
  }
}

.main-menu ul {
  display: inline-block;
  list-style-type: none;
  padding: 0;
}

.main-menu ul li {
  display: inline-block;
}

.main-menu ul li a {
  padding: 1em;
}

.main-menu ul li a:first-child {
  padding-left: 0;
}

.main-menu ul li a:last-child {
  padding-right: 0;
}

.post--listed a {
  padding: 1em;
  margin: -1em;
  transition: background 0.25s ease-in-out;
  border-radius: 0.3em;
  display: grid;
  grid-column-gap: 1em;
  grid-template-rows: max-content;
  grid-template-columns: 128px auto;
  grid-template-areas:  "post-image post-title"
                        "post-image post-date"
                        "post-image post-description";
}

@media (max-width: 600px) {
  .post--listed a {
    grid-template-areas:  "post-image post-title"
                          "post-image post-date"
                          "post-description post-description";
  }
}

@media (max-width: 1000px) {
  .other-posts .post--listed a {
    grid-template-areas:  "post-image post-title"
                          "post-image post-date"
                          "post-description post-description";
  }
}

.post--listed a:hover {
  background: var(--color-background-light);
}

.post__image {
  grid-area: post-image;
  width: 128px;
  height: 128px;
  border-radius: 0.5em;
  box-shadow: 0 0.2em 0.4em var(--color-background-inverted-shadow);
  background: var(--color-background-inverted);
  overflow: hidden;
}

@media (max-width: 359px) {
  .post--listed a {
    grid-template-columns: 64px auto;
  }

  .post__image {
    grid-area: post-image;
    width: 64px !important;
    height: 64px !important;
  }
}

.post__title {
  grid-area: post-title;
  margin: 0;
  margin-top: -0.3em;
}

.post__date {
  grid-area: post-date;
  margin: 0;
  color: var(--color-font-light);
}

.post__description {
  grid-area: post-description;
  margin-top: 1em;
  margin-bottom: 0;
}

.post__title a {
  text-decoration: none;
}

.post__footer {
  display: flex;
  justify-content: space-between;
}

.post__footer nav {
  max-width: 50%;
}

@media (max-width: 600px) {
  .post__footer {
    display: block;
    overflow: hidden;
  }

  .post__footer nav {
    max-width: 100%;
  }
}

.author {
  display: grid;
  grid-template-columns: 73px auto;
  grid-gap: 1em;
  max-width: 100%;
}

.author--custom {
  grid-template-columns: 90px auto;
}

.author__image {
  border-left: 2px solid var(--color-frame);
  border-top: 2px solid var(--color-frame);
  border-top-left-radius: 0.3em;
  padding-bottom: 0.5em;
  padding-right: 13em;
  margin-right: -13em;
}

.author--custom .author__image {
  padding-right: 16em;
  margin-right: -16em;
}

.author--custom .author__image img {
  object-fit: cover;
  border-bottom-right-radius: 1em;
  filter: contrast(1.5) saturate(1) sepia(0.3);
}

.author__name {
  display: block;
  font-size: 1.5em;
  font-family: var(--font-family-heading);
  margin-top: 1.5em;
}

.author--custom .author__name {
  margin-top: 1em;
}

.author__contact,
.author__title {
  font-size: 0.9em;
  display: block;
}

@media (max-width: 600px) {
  .author__meta {
    font-size: 0.7em;
  }
}

.other-posts {
  margin-top: 2em;
}

.other-posts__container {
  display: grid;
  grid-template-columns: auto auto;
  grid-gap: 2em;
}

@media (max-width: 600px) {
  .other-posts__container {
    grid-template-columns: auto;
  }
}

.other-posts__container a {
  text-decoration: none;
}
