@layer fonts, imports;

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap') layer(fonts);
@import url('algolia.css') layer(imports);

/* Variables */
:root {
  /* Dimensions */
  --wrapper-size-max: 81em;
  --link-underline-size: 2px;
  --gap-default: 1em;
  --spacer-default: calc(var(--gap-default) * 2);
  
  /* Colors */
  --ts3d-lt-blue: #00aeff;
  --ts3d-dk-blue: #006098;
  --ts3d-lt-grey: #979898;
  --ts3d-dk-grey: #58585b;
  --he-logo: #009693;
  --hc-logo: #4477ac;
  --hp-logo: #26c8aa;
  --hv-logo: #55abdf;
  --hl-logo: #668ec9;
  --hnp-logo: #6fa7db;
  --ceetron-logo: #861c3e;
  --ceesam-logo: #651e3e;
  --content-bg: #efefef;
  --text-color-default: #333;
  --text-color-inverted: #fff;
  --link-color-default: var(--ts3d-dk-blue);
  --link-color-hover: var(--ts3d-lt-blue);
  --link-color-inverted: var(--ts3d-lt-blue);
  --link-color-inverted-hover: var(--text-color-inverted);
  
  /* Miscellaneous */
  --transition-default: .15s ease-in-out;
  --sidebar-transition-timing: .35s ease;
}

/* Search styles */
.tingle-modal-box {
  border-radius: .5em !important;
}

input.aa-Input {
  border-radius: .25em;
  border: 1px solid var(--link-color-hover);
  padding: 1ch 3ch;
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;

  &,
  &:focus {
    box-shadow: none;
  }
}

/* Global styles */
body {
  margin: 0;
  padding: 0;
  background: url('../images/cityscape.jpg');
  background-repeat: no-repeat;
  background-position: left top;
  background-color: var(--content-bg);
  background-size: 100vh;
  color: var(--text-color-default);
  font-family: 'Open Sans', Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.35;
  
  &:has(aside.is-open),
  &.tingle-enabled {
    overflow: hidden;
    
    /* Prevent UI shift by adding margin equal to scrollbar */
    main {
      margin-right: var(--scrollbar-width);
    }
    
    .overlay,
    .tingle-modal {
      z-index: 98; /* 1 level below <aside> */
      background: rgb(0, 0, 0, .35) !important;
      backdrop-filter: blur(2px) !important;
    }
  }
}

a {
  position: relative;
  color: var(--link-color-default);
  text-decoration: none;
  transition: var(--transition-default);

  &:hover {
    color: var(--link-color-hover);
  }

  &::before,
  &::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    z-index: -1;
    border-bottom-width: 2px;
    border-bottom-style: solid;
    transition: var(--transition-default);
  }
  
  &::before {
    border-bottom-color: var(--link-color-default);
  }

  &::after {
    border-bottom-color: var(--link-color-hover);
    transform: scaleX(0);
    transform-origin: 0;
  }

  &:hover::after {
    transform: scaleX(1);
  }
}

figure {
  margin: var(--gap-default) 0;
}

img {
  max-width: 100%;
}

button {
  cursor: pointer;
}

/* Utility classes */
.wrapper {
  max-width: var(--wrapper-size-max);
  margin: 0 auto;
}

.headline {
  font-size: 1em;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: .125ch;

  &.lg {
    font-size: 1.125em;
  }

  &.wide {
    letter-spacing: .25ch;
  }
}

/* Primary item styles */
main {
  position: relative;
  z-index: 1;

  header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: end;
    gap: clamp(var(--gap-default), 1.5vw, var(--spacer-default));
    margin: 2ch 1ch;
    border-radius: .5em;
    background: #fff;
    padding: 1ch 2ch;
    z-index: 99; /* always on top of everything in the main page */
    transition: var(--transition-default);

    &.is-stuck {
      margin: 0 0 2ch;
      padding: 1ch 3ch;
      border-radius: 0;
      box-shadow: 0 .125em .5em .25em rgba(0, 0, 0, .15);
    }

    nav {
      display: none;
      margin: auto;

      a {
        &, &:hover {
          color: var(--text-color-default);
        }

        &::before {
          border-bottom-color: transparent;
        }
      }

      ul {
        list-style: none;
        display: flex;
        gap: clamp(var(--gap-default), 5vw, var(--spacer-default));
        margin: 0;
        padding: 0;
      }
    }

    button {
      margin: 0;
      color: var(--link-color-default);
      transition: var(--transition-default);
      width: 1.5em;
      aspect-ratio: 1;
      border: none;
      background: none;
      font-size: 2em;
    
      &:hover {
        color: var(--link-color-hover);
      }
    }

    .ts3d-logo {
      margin-right: auto;
    }

    #entersearch {
      all: unset;
    }
  }
}

aside {
  position: fixed;
  left: 100vw;
  top: 0;
  height: 100vh;
  transform: translateX(0);
  transition: var(--sidebar-transition-timing);
  overflow-y: auto;
  white-space: nowrap;
  z-index: 99;

  &.is-open {
    box-shadow: 0 0 1rem rgba(0, 0, 0, .25);
    transform: translateX(-100%);
  }

  nav {
    padding: var(--spacer-default);
    line-height: 2;
    background: radial-gradient(
      circle at 50% 25%,
      hsl(from var(--ts3d-dk-grey) h s calc(l * .75)),
      hsl(from var(--ts3d-dk-grey) h s calc(l * .5)));
  }

  .headline {
    color: var(--ts3d-lt-blue);
    border-bottom: 1px solid var(--ts3d-dk-grey);
  }

  button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 1.5em;
    aspect-ratio: 1;
    font-size: 2em;
    color: var(--text-color-inverted);
    background: none;
    border: 1px dotted transparent;
    transition: var(--transition-default);

    &:hover {
      border-color: var(--text-color-inverted);
    }
  }

  a {
    font-weight: 700;
    z-index: 1;
    
    &, &:hover {
      color: var(--text-color-inverted);
    }

    &::before {
      border-bottom-color: var(--link-color-hover);
    }

    &:hover::after {
      border-bottom-color: var(--text-color-inverted);
    }
  }

  ul {
    margin: 0 0 var(--spacer-default);
    padding: 0;
    list-style: none;

    h2:first-child {
      margin-top: 0;
    }
  }
}

footer {
  display: grid;
  gap: clamp(var(--gap-default), 2vw, var(--spacer-default));
  margin-top: var(--spacer-default);
  padding: var(--spacer-default);
  background: var(--text-color-default);
  color: var(--text-color-inverted);
  line-height: 2;

  a {
    font-size: 1.125em;
    z-index: 1;
    
    &, &:hover {
      color: var(--text-color-inverted);
    }

    &:hover::after {
      border-bottom-color: var(--text-color-inverted);
    }
  }
  
  ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  section {
    display: flex;
    flex-direction: column;
    gap: var(--gap-default);

    > *:first-child {
      margin: 0;
    }

    p {
      margin: 0;
      font-size: .75em;
    }

    .headline {
      font-size: 1em;
      border-bottom: 1px solid var(--ts3d-dk-grey);
    }

    &.connect{
      img {
        width: clamp(7.5em, 100%, 15em);
      }

      a {
        &::before,
        &::after {
          all: unset;
        }
      }
    }
  }

  .footer__socials {
    display: flex;
    gap: calc(var(--gap-default) / 2);
    justify-content: start;

    a {
      display: inline-flex;
      justify-content: center;
      align-items: center;
      width: 2em;
      font-size: 1.25em;
      font-weight: 100;
      border: var(--link-underline-size) solid var(--link-color-inverted);
      border-radius: 50%;
      aspect-ratio: 1;

      + a {
        margin-left: .5ch;
      }

      &:hover {
        border-color: var(--link-color-inverted-hover);
      }
    }
  }

  .footer__brand, form {
    margin-top: var(--gap-default);
  }

  .footer__brand a {
    display: inline-block;
    white-space: nowrap;
    font-size: 1em;
    color: var(--link-color-inverted);

    &:not(:last-child)::after {
      content: ' | ';
      color: var(--link-color-inverted-hover);
      font-weight: normal;
    }

    &:hover {
      color: var(--link-color-inverted-hover);
    }
  }

  form {
    display: flex;
    flex-wrap: wrap;
    
    .headline {
      flex: 1 0 100%;
      border: none;
    }

    input, button {
      display: flex;
      align-items: center;
      padding: 1ch;
      border: none;
    }

    input {
      flex: 1;
      min-width: 0;
      border-radius: .25ch 0 0 .25ch;
    }

    button {
      text-transform: uppercase;
      letter-spacing: .25ch;
      color: var(--text-color-inverted);
      background: var(--link-color-inverted);
      border-radius: 0 .25ch .25ch 0;
      transition: var(--transition-default);

      &:hover {
        background: var(--ts3d-dk-blue);
      }
    }
  }
}

.overlay {
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0);
  transition: var(--sidebar-transition-timing);
}

.banner {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--ts3d-lt-blue);
  border-bottom: 1px solid rgba(0, 0, 0, .25);

  button {
    padding: 1ch 2ch;
    border-radius: 0;
    border: none;
    background: var(--ts3d-dk-blue);
    color: var(--link-color-inverted);
    transition: var(--transition-default);

    &:hover {
      color: var(--text-color-inverted);
    }

    &.prev {
      order: 1;
    }

    &.next {
      order: 3;
    }
  }

  article {
    order: 2;
    flex-grow: 1;
    padding: 1ch 2ch;
    color: var(--text-color-inverted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    i {
      margin-right: 1ch;
    }
  }
}

.hero {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  padding: var(--gap-default) var(--spacer-default);
  color: var(--text-color-inverted);
  text-align: center;

  h1 {
    margin-top: 0;
    font-size: clamp(1.5em, 7.5vw, 3rem);
  }

  > * {
    margin-left: auto;
    margin-right: auto;
    max-width: 75ch;
  }
}

div[role="content"] {
  container-name: content;
  container-type: inline-size;
  max-width: var(--wrapper-size-max);
  margin: 0 auto;
}

.cards section {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--spacer-default);
  background: #fff;

  &.data {
    grid-area: data;
  }

  &.graphics {
    grid-area: graphics;
  }

  &.simulation {
    grid-area: simulation;
  }

  h2 {
    order: 2;
    margin: var(--spacer-default) 0;
    font-size: 1.125em;
    font-weight: normal;
    color: var(--ts3d-dk-grey);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .125ch;
  }
  
  img {
    order: 1;
  }

  article {
    order: 3;

    + article {
      margin-top: var(--spacer-default);
    }
  }
}

.card {
  figure {
    margin: 0;

    img {
      width: clamp(10rem, 75%, 15rem);
    }

    figcaption {
      margin: 1em 0;
      font-size: 1em;
      font-style: italic;
    }
  }

  ul {
    margin: 0;
    padding: 0 0 0 1em;
  }
}

/* Extra item styles */
.extra {
  --img-size: clamp(var(--spacer-default), 15vw, calc(var(--spacer-default) * 2));

  position: relative;
  display: grid;
  grid-template-areas:
    'img'
    'title'
    'block1'
    'block2';
  grid-template-rows: var(--img-size);
  grid-auto-rows: auto;
  gap: var(--gap-default);
  padding: var(--spacer-default);
  padding-top: 0;
  color: var(--text-color-inverted);
  background: var(--text-color-default);

  &::before {
    content: '';
    display: flex;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: var(--img-size);
    background: url('../images/desktop-diagram.jpg');
    background-size: cover;
    background-position: center 35vw;
  }

  &.blocks-3 {
    grid-template-areas:
      'img'
      'title'
      'block1'
      'block2'
      'block3';
  }

  h2 {
    grid-area: title;
    margin: 0 0 .75em;
    font-size: clamp(1.5rem, 3.5vw, 2.5rem);
    line-height: 1;
  }

  article {
    &:first-of-type {
      grid-area: block1;

      + article {
        grid-area: block2;

        + article {
          grid-area: block3;
        }
      }
    }

    ul {
      margin: 0;
      padding: 0 0 0 var(--gap-default);
    }
  }

  a {
    color: var(--link-color-inverted);

    &:hover {
      color: var(--link-color-inverted-hover);
    }
  }
}

/* Container and media queries */

@container content (max-width: 41.99em) {
  .cards section:not(:last-of-type)::after {
    content: '';
    position: absolute;
    left: var(--spacer-default);
    right: var(--spacer-default);
    bottom: 0;
    border-bottom: var(--link-underline-size) solid var(--ts3d-dk-blue);
    transform: translateY(calc(var(--link-underline-size) * -1));
  }
}

@container content (min-width: 42em) {
  .cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      'data graphics'
      'simulation graphics';
    gap: 1em;
  }

  .extra {
    grid-column-gap: var(--spacer-default);

    &:not(.blocks-3) {
      grid-template-areas:
        'img title'
        'img block1'
        'img block2';
      grid-template-rows: auto;
      grid-template-columns: 1fr 2fr;
      padding-top: var(--spacer-default);

      &::before {
        bottom: 0;
        width: calc((100% / 3) - var(--gap-default));
        clip-path: polygon(0 0, calc(100% - var(--img-size)) 0, 100% 50%, calc(100% - var(--img-size)) 100%, 0 100%);
      }
    }

    &.blocks-3 {
      grid-template-areas:
      'img img'
      'title title'
      'block1 block2'
      'block3 .';
      grid-template-columns: repeat(2, 1fr);

      &::before {
        height: var(--img-size);
      }
    }
  }
}

@container content (min-width: 65em) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
    grid-template-areas: 'data graphics simulation';
  }

  .extra {
    grid-template-areas:
      'img title title'
      'img block1 block2';
    grid-template-columns: repeat(3, 1fr);
    grid-column-gap: calc(var(--spacer-default) * 2);

    &.blocks-3 {
      grid-template-areas:
        'img title title title'
        'img block1 block2 block3';
      grid-template-rows: auto;
      grid-template-columns: repeat(4, 1fr);
      padding-top: var(--spacer-default);

      &::before {
        bottom: 0;
        width: calc(25% - var(--gap-default));
        height: unset;
        clip-path: polygon(0 0, calc(100% - var(--img-size)) 0, 100% 50%, calc(100% - var(--img-size)) 100%, 0 100%);
        background-position: center;
      }
    }
  }
}

@media (max-width: 31.99em) {
  main header {
    margin: 0;
    padding: 1ch;
    border-radius: 0;
    gap: 0;

    &.is-stuck {
      padding: 1ch;
    }

    img {
      max-width: 75%;
    }

    button {
      font-size: 1.5em;
    }
  }
}

@media (min-width: 25em) {
  footer {
    --grid-cols: 2;
    --grid-start: 1;
    --grid-span: 2;
    grid-template-columns: repeat(var(--grid-cols), 1fr);

    > *:last-child {
      grid-column: var(--grid-start) / span var(--grid-span);
    }
  }
}

@media (min-width: 37.5em) {
  footer {
    --grid-cols: 3;
    --grid-start: 2;
    --grid-span: 2;
  }
}

@media (min-width: 42em) {
  body {
    background-size: calc(100vw - var(--scrollbar-width));
    background-repeat: repeat-x;
  }
}

@media (min-width: 50em) {
  footer {
    --grid-start: 3;
    --grid-span: 1;
  }
}

@media (min-width: 62.5em) {
  main header nav {
    display: flex;
  }

  footer {
    --grid-cols: 5;
    --grid-start: 5;
  }
}
