/* Global */
:root {
  --white: #fff;
  --gray: #616d7e;
  --black: #000;
  --red: #eb4747;
  --baseline-step: 0.625em;
}

@font-face {
  font-family: "mad-sans-fill-bold";
  src: url("../fonts/mad-sans-fill-bold.eot");
  src:
    url("../fonts/mad-sans-fill-bold.eot?#iefix") format("embedded-opentype"),
    url("../fonts/mad-sans-fill-bold.woff2") format("woff2"),
    url("../fonts/mad-sans-fill-bold.woff") format("woff"),
    url("../fonts/mad-sans-fill-bold.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "mad-sans-fill-bold-italic";
  src: url("../fonts/mad-sans-fill-bold-italic.eot");
  src:
    url("../fonts/mad-sans-fill-bold-italic.eot?#iefix")
      format("embedded-opentype"),
    url("../fonts/mad-sans-fill-bold-italic.woff2") format("woff2"),
    url("../fonts/mad-sans-fill-bold-italic.woff") format("woff"),
    url("../fonts/mad-sans-fill-bold-italic.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "mad-sans-fill-bold";
  width: 100vw;
  height: auto;
  font-size: 1em;
  line-height: 1.25;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(235, 71, 71, 0) 0,
    rgba(235, 71, 71, 0) calc(var(--baseline-step) - 1px),
    rgba(235, 71, 71, 0.45) calc(var(--baseline-step) - 1px),
    rgba(235, 71, 71, 0.45) var(--baseline-step)
  );
  transition: opacity 0.15s ease;
}

body.show-baseline-grid::before {
  opacity: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

main {
  margin: 19px 20px auto 20px;
}

nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: 20px;
  width: 100%;
  height: auto;
  margin-top: -4px;
  margin-bottom: 20px;
}

.project {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-column-gap: 20px;
  justify-content: space-between;
  width: 100%;
}

.project:not(:first-of-type) {
  margin-top: 92px;
}

.project:first-of-type {
  margin-top: 75px;
}

img {
  background: lightgray;
  width: 100%;
  justify-self: center;
  margin-bottom: 20px;
}

article img:last-of-type {
  margin-bottom: 0;
}

.caption {
  position: fixed;
  width: auto;
  grid-column: 1 / span 2;
  padding-left: 40px;
  margin-right: 60px;
  color: #616d7e;
}

.mobile-caption {
  display: none;
}

.menu {
  position: fixed;
  width: auto;
  text-align: right;
  right: 60px;
  z-index: 4;
}

.menu a {
  display: inline-block;
  transform: translateY(3px);
}

.work-title {
  font-family: "mad-sans-fill-bold-italic";
  display: block;
  padding-left: 20px;
}

.work-title::first-line {
  text-indent: -20px;
}

.port {
  width: 70%;
}

.land {
  width: 100%;
}

.slash {
  margin-left: 4px;
  margin-right: 4px;
}

.gray-slash {
  margin-right: 54px;
}

.back-to-top {
  position: fixed;
  bottom: 21px;
  right: 60px;
  color: #616d7e;
  z-index: 1;
}

#info,
#mail {
  margin-left: 12.375px;
}

/* Links */
a:link,
a:visited {
  color: #616d7e;
  text-decoration: none;
}

a:hover {
  cursor: pointer;
}

a.active {
  color: #eb4747;
}

.menu a:link,
.menu a:visited,
.back-to-top {
  color: #616d7e;
}

.menu a.active {
  color: #eb4747;
}

a:link.external {
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover.external {
  color: #616d7e;
  text-decoration: none;
}

.menu a:hover,
.back-to-top:hover {
  color: #000;
}

.back-to-top:hover {
  cursor: pointer;
}

/* Skeleton placeholder */
.placeholder {
  background-color: #e0e0e0;
  height: 300px;
  width: 100%;
  margin-bottom: 20px;
}

/* Media Queries */
@media (max-width: 900px) {
  .project {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  :root {
    --baseline-step: 12px;
  }

  body {
    font-size: 1.125em;
    line-height: 1.375em;
  }

  nav {
    display: block;
    margin-bottom: 0;
  }

  .menu {
    display: block;
    position: initial;
    text-align: left;
    padding-top: 2px;
  }

  .active,
  #info,
  #mail {
    margin: 0;
  }

  .caption {
    display: none;
  }

  .mobile-caption {
    display: block;
    position: initial;
    transform: translateY(-2px);
    margin-bottom: 18px;
    color: var(--gray);
  }

  .mobile-caption .caption-date {
    display: inline-block;
    transform: translateY(1px);
  }

  .mobile-caption .work-title {
    transform: translateY(1px);
  }

  .mobile-caption .caption-description {
    display: block;
    line-height: calc(var(--baseline-step) * 2);
    transform: translateY(1px);
  }

  .project:first-of-type {
    margin-top: 0;
  }

  .project {
    display: grid;
    grid-template-columns: 1fr;
    grid-column-gap: 20px;
    width: 100%;
  }

  .project:not(:first-of-type) {
    margin-top: 0;
  }

  /* ✅ MOBILE: apply only to portrait images + portrait placeholders */
  .project img.port,
  .project .placeholder.port {
    margin-left: 20px; /* align left edge with title indent */
    margin-right: 20px; /* equal space on the right */
    width: calc(100% - 40px); /* subtract both margins */
    justify-self: start;
    margin-bottom: var(--baseline-step);
  }

  img:not(:last-child) {
    margin-bottom: var(--baseline-step);
  }

  /* ✅ MOBILE: make spacing after the last image consistent */
  article img:last-of-type {
    margin-bottom: var(--baseline-step); /* same vertical rhythm before next caption */
  }

  article {
    margin-bottom: 20px;
  }

  nav {
    margin-bottom: 25px;
  }

  .menu a {
    display: block;
    width: max-content;
    padding: 0;
    line-height: calc(var(--baseline-step) * 2);
    transform: none;
  }

  .menu a + a {
    margin-top: 0;
  }

  .back-to-top {
    right: 20px;
  }

}
