#footer {
  background: var(--jct-black);
  color: var(--jct-white);
  text-align: left;
}
#footer a {
  color: currentColor;
}

#footer .footer-inner {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: auto 1fr auto;
  column-gap: 16px;
  min-height: 100vh;
  padding: 0 16px 16px;
  box-sizing: border-box;
}

/* Column 1, top: logo */
#footer .footer-logo {
  grid-column: 1 / 2;
  grid-row: 1;
  margin-top: 16px;
  min-width: 0;
  max-width: 164px;
}
#footer .footer-logo svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 164px;
  max-height: 187px;
  fill: var(--jct-white);
}
#footer .footer-logo img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 164px;
  max-height: 187px;
}

/* Cols 4-8, top: sisältölohkot */
#footer .footer-sisaltolohkot {
  grid-column: 4 / 9;
  grid-row: 1;
  margin-top: 32px;
}
#footer .footer-sisaltolohko {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  column-gap: 16px;
  padding: 40px 0;
}
#footer .footer-sisaltolohko:first-child {
  padding-top: 0;
}
#footer .footer-sisaltolohko:last-child {
  padding-bottom: 0;
}
#footer .footer-sisaltolohko:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: -16px;
  height: 1px;
  background: var(--jct-white);
}
#footer .footer-sisaltolohko-otsikko {
  grid-column: 1 / 3;
  font: var(--h3);
  margin: 0;
  padding: 0;
}
#footer .footer-sisaltolohko-sisalto {
  grid-column: 3 / 5;
  font: var(--body2);
}
#footer .footer-sisaltolohko-sisalto a {
  text-decoration: underline;
}
#footer .footer-sisaltolohko-sisalto a:not([href^="mailto:"])::after {
  content: " →";
}

/* Column 1, bottom: media */
#footer .footer-media {
  grid-column: 1 / 2;
  grid-row: 3;
  align-self: end;
  min-width: 0;
}
#footer .footer-media video,
#footer .footer-media img {
  display: block;
  width: 567px;
  height: 335px;
  max-width: none;
  object-fit: cover;
}
#footer .footer-media--video {
  grid-column: 1 / 4;
}
#footer .footer-media--video video {
  width: 100%;
  height: auto;
  max-width: none;
  aspect-ratio: 567 / 335;
}

/* Col 4, bottom: copyright */
#footer #copyright {
  grid-column: 4 / 5;
  grid-row: 3;
  align-self: end;
  font: var(--body2);
}

/* Col 6, bottom: social links */
#footer .footer-socmed {
  grid-column: 6 / 7;
  grid-row: 3;
  align-self: end;
}
#footer .socmed-follow {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#footer .socmed-follow li {
  display: block;
}
#footer .socmed-follow a {
  display: flex;
  align-items: center;
  gap: 8px;
}
#footer .socmed-follow svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

@media (max-width: 1024px) {
  #footer .footer-inner {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto;
    padding-top: 16px;
  }

  /* Row 1: logo top-left, socmed top-right */
  #footer .footer-logo {
    grid-column: 1 / 2;
    grid-row: 1;
    min-width: 111px;
    max-width: 111px;
    margin-top: 0;
    margin-bottom: 40px;
  }
  #footer .footer-socmed {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-self: end;
    align-self: start;
  }
  #footer .socmed-follow {
    gap: 24px;
  }

  /* Row 2: sisältölohkot, under the logo/socmed row, stacked and left-aligned */
  #footer .footer-sisaltolohkot {
    grid-column: 1 / 3;
    grid-row: 2;
    margin-top: 20px;
  }
  #footer .footer-sisaltolohko {
    grid-template-columns: 1fr;
    padding: 20px 0;
  }
  #footer .footer-sisaltolohko:last-child {
    padding-bottom: 20px;
  }
  #footer .footer-sisaltolohko-otsikko,
  #footer .footer-sisaltolohko-sisalto {
    grid-column: 1 / 2;
    text-align: left;
  }
  #footer .footer-sisaltolohko-otsikko {
    font: var(--h4);
    padding-bottom: 20px;
  }
  #footer .footer-sisaltolohko-sisalto {
    font: var(--body4);
  }
  /* strokes stay within the grid at mobile, respecting both l/r paddings instead of bleeding right */
  #footer .footer-sisaltolohko:not(:first-child)::before {
    right: 0;
  }
  #footer .footer-sisaltolohko:last-child::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--jct-white);
  }

  /* Row 3 (flexible): copyright, not otherwise specified so it sits above the media bar */
  #footer #copyright {
    grid-column: 1 / 3;
    grid-row: 3;
    align-self: start;
    font: var(--body4);
    padding: 20px 0;
  }

  /* Row 4: media, full-bleed edge to edge and flush with the bottom of the screen */
  #footer .footer-media {
    grid-column: 1 / 3;
    grid-row: 4;
    align-self: end;
    margin: 0 -16px -16px;
    width: calc(100% + 32px);
  }
  #footer .footer-media video,
  #footer .footer-media img {
    width: 100%;
  }
}
