:root {
  --gray-1: hsl(0, 0%, 100%); /* bg */
  --gray-2: hsl(0, 0%, 96%); /* well */
  --gray-3: hsl(0, 0%, 88%); /* border light */
  --gray-4: hsl(0, 0%, 80%); /* border dark */
  --gray-5: hsl(0, 0%, 40%); /* secondary */
  --gray-6: hsl(0, 0%, 15%); /* body */
  --gray-7: hsl(0, 0%, 10%); /* title */
  --outline: hsla(0, 0%, 0%, 5%);
  --yellow: #feedb9;
  --brightness: 0.95;
  --transition: all 0.15s ease;
  --font-sans: Inter, sans-serif;
  --font-mono: monospace;
  --underline-offset: 2px;

  font-size: 16px;
  font-family: var(--font-sans);
  /* https://rsms.me/inter/#features */
  font-feature-settings:
    'ss01' 1,
    'ss04' 1,
    'calt' 1;
  font-weight: 400;
  line-height: 1.625;
  text-rendering: optimizeLegibility;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gray-1: hsl(0, 0%, 5%);
    --gray-2: hsl(0, 0%, 10%);
    --gray-3: hsl(0, 0%, 20%);
    --gray-4: hsl(0, 0%, 30%);
    --gray-5: hsl(0, 0%, 60%);
    --gray-6: hsl(0, 0%, 88%);
    --gray-7: hsl(0, 0%, 96%);
    --outline: hsla(0, 0%, 100%, 10%);
    --yellow: #473514;
    --brightness: 0.8;
    --underline-offset: 3px;
  }
}

@supports (font-variation-settings: normal) {
  :root {
    font-family: InterVariable, sans-serif;
  }
}

/* Reset */

* {
  margin: 0;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Base typography and interactive elements */

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

p {
  text-wrap: pretty;
}

h1,
h2,
h3,
h4 {
  color: var(--gray-7);
  font-weight: 600;
  text-wrap: balance;
}

h1 {
  font-size: 2rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.375;
}

h3 {
  font-size: 1rem;
  line-height: 1.5;
}

h4 {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: underline solid transparent 1px;
  text-underline-offset: var(--underline-offset);
  transition: var(--transition);
}

a:active {
  text-decoration-color: currentColor;
}

@media (hover: hover) {
  a:hover {
    text-decoration-color: currentColor;
  }
}

/* Layout */

html {
  scroll-behavior: smooth;
}

body {
  color: var(--gray-6);
  background: var(--gray-1);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 1rem;
  padding: 0.75rem;
  width: 100%;

  @media (min-width: 40rem) {
    padding-inline: 1rem;
  }

  h1 {
    font-size: 1rem;
    line-height: 1.5;
  }

  nav {
    display: flex;
    gap: 0.5rem;
  }

  a {
    display: inline-block;
    color: var(--gray-7);
    line-height: 1.5;
    padding: 0.5rem;
  }

  a[aria-current='page'] {
    text-decoration-color: currentColor;
  }
}

main {
  padding: 1.25rem;
  margin: max(3dvw, 1rem) auto;
  width: 100%;
  max-width: 48rem;

  @media (min-width: 40rem) {
    padding: 1.5rem;
  }

  &.wide {
    max-width: 78rem;
  }
}

.footer {
  color: var(--gray-5);
  font-size: 0.875rem;
  margin-top: auto;
  padding-top: 3rem;
  padding-bottom: 2rem;
  text-align: center;
}

.callout {
  display: flex;
  gap: 0.75rem;
  background-color: var(--yellow);
  border-radius: 0.25rem;
  line-height: 1.5;
  padding: 1rem 1.25rem;
  margin-block: 3rem;

  p {
    margin-block: 0;
  }

  a {
    text-decoration-color: currentColor;
  }
}

/* Project list */

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.5rem 2rem;
}

.project-list-title {
  margin-bottom: 1rem;
}

.project-item {
  position: relative;
}

.project-item-link {
  position: absolute;
  inset: 0;
  z-index: 100;
  text-decoration: none;
}

.project-item-image {
  aspect-ratio: 16 / 9;
  background-color: var(--gray-2);
  border-radius: 0.25rem;
  color: transparent;
  display: block;
  object-fit: cover;
  transition: var(--transition);
  width: 100%;
}

.project-item-title {
  color: var(--gray-7);
  font-weight: 500;
  line-height: 1.5;
  margin-top: 0.5rem;
  text-decoration: underline solid transparent 1px;
  text-underline-offset: var(--underline-offset);

  &::after {
    content: '→';
    opacity: 0;
    transition: var(--transition);
  }
}

.project-item-date {
  color: var(--gray-5);
  font-size: 0.875rem;
  line-height: 1.25;
  margin-top: 0.25rem;
  margin-bottom: 0;
  transition: var(--transition);
}

.project-item:active {
  .project-item-image {
    filter: brightness(var(--brightness));
  }
  .project-item-title::after {
    opacity: 1;
    margin-left: 0.25rem;
  }
  .project-item-date {
    color: var(--gray-7);
  }
}

@media (hover: hover) {
  .project-item:hover {
    .project-item-image {
      filter: brightness(var(--brightness));
    }
    .project-item-title::after {
      opacity: 1;
      margin-left: 0.25rem;
    }
    .project-item-date {
      color: var(--gray-7);
    }
  }
}

/* Project page */

.project-header {
  margin-bottom: 3rem;
}

.project-subtitle {
  color: var(--gray-5);
  display: block;
  font-size: 1.25rem;
  line-height: 1.375;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.project-description {
  display: grid;
  align-items: baseline;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 2rem;

  @media (min-width: 40rem) {
    grid-template-columns: 2fr 1fr;
    gap: 6rem;
  }
}

.poriect-description-primary {
  > *:not(:first-child) {
    margin-top: 1.625rem;
  }
}

.project-description-secondary {
  color: var(--gray-5);
  font-size: 0.875rem;
  line-height: 1.625rem;

  > *:not(:first-child) {
    margin-top: 1.625rem;
  }
}

.project-content {
  margin-bottom: 6rem;
}

.project-content p:not(.is-pswp) {
  max-width: 45rem;
  margin-inline: auto;
}

.project-content p.is-pswp {
  margin-top: 3rem;
  margin-bottom: 0;

  a {
    cursor: zoom-in;
    text-decoration: none;
  }
}

/* Photoswipe */

.pswp__button svg {
  padding: 8px;
  border-radius: 999px;
  background-color: var(--gray-6);
  stroke: var(--gray-1);
}

.pswp__img {
  border-radius: 0;
  cursor: auto;
}

/* Post list */

.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-direction: column;
  gap: 0.25rem;
  border-bottom: 1px solid var(--gray-3);
  line-height: 1.5;
  padding: 1rem 0;
  position: relative;

  @media (min-width: 40rem) {
    flex-direction: row;
  }

  &:last-child {
    border-bottom: none;
  }
}

.post-item-link {
  position: absolute;
  inset: 0;
  z-index: 100;
  text-decoration: none;
  border-radius: 0.25rem;
}

.post-item-title {
  color: var(--gray-7);
  font-weight: 500;
  text-decoration: underline solid transparent 1px;
  text-underline-offset: var(--underline-offset);

  &::after {
    content: '→';
    opacity: 0;
    transition: var(--transition);
  }
}

.post-item-description {
  margin-top: 0.25rem;
  margin-bottom: 0;
  text-decoration: none;
  transition: var(--transition);
}

.post-item-date {
  color: var(--gray-5);
  font-size: 0.875rem;
  text-decoration: none;
  transition: var(--transition);
}

.post-item:active {
  .post-item-title::after {
    opacity: 1;
    margin-left: 0.25rem;
  }
  .post-item-description,
  .post-item-date {
    color: var(--gray-7);
  }
}

@media (hover: hover) {
  .post-item:hover {
    .post-item-title::after {
      opacity: 1;
      margin-left: 0.25rem;
    }
    .post-item-description,
    .post-item-date {
      color: var(--gray-7);
    }
  }
}

/* Post page */

.post-header {
  display: grid;
  text-align: center;
  margin-bottom: 3rem;
}

.post-date {
  color: var(--gray-5);
  font-size: 0.875rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

.post-description {
  color: var(--gray-5);
  font-size: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
  line-height: 1.375;
}

.post-image {
  margin-top: 3rem;

  @media (min-width: 60rem) {
    margin-inline: -5rem;
  }

  img {
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background-color: var(--gray-2);
    border-radius: 0.25rem;
    color: transparent;
    margin: 0 auto;
  }

  p {
    color: var(--gray-5);
    display: block;
    font-size: 0.875rem;
    font-style: normal;
    line-height: 1.5;
    margin-top: 0.5rem;
  }

  a:not(:hover, :active) {
    text-decoration-color: var(--gray-4);
  }
}

.post-content {
  margin-bottom: 4rem;
}

.heading-anchor:hover .heading-anchor-link,
.heading-anchor:focus-within .heading-anchor-link {
  opacity: 1;
  pointer-events: all;
}

.heading-anchor-link {
  color: var(--gray-5);
  display: inline-block;
  font-weight: 400;
  font-size: 0.95em;
  margin-left: 0.333em;
  opacity: 0;
  pointer-events: none;
  text-decoration: none;

  &:hover {
    color: var(--gray-7);
  }
}

.pagination {
  display: flex;
  gap: 1rem 3rem;
  justify-content: space-between;
  flex-wrap: wrap;
  border-top: 1px solid var(--gray-3);
  padding-top: 3rem;
}

.pagination-item {
  flex: 1 1 auto;
  max-width: 20rem;
  line-height: 1.5;

  span {
    display: block;
    color: var(--gray-5);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
  }
}

.pagination-item--next {
  text-align: right;
  margin-left: auto;
}

/* 404 */

.notfound {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;

  span {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  h1 {
    margin-bottom: 1.5rem;
  }

  a {
    background-color: var(--gray-7);
    border-radius: 0.25rem;
    color: var(--gray-1);
    font-weight: 500;
    padding: 0.5rem 1rem;
    text-decoration: none;
  }

  a:active {
    background-color: var(--gray-6);
  }

  @media (hover: hover) {
    a:hover {
      background-color: var(--gray-6);
    }
  }
}
