/* Hero */
section#hero {
  & .wrap {
    position: relative;

    & p {
      position: absolute;
      top: calc(var(--header-height) + 20px);
      right: var(--inline-padding);
      z-index: 1;
      font-size: 50px;
      font-weight: 200;
      color: var(--color-secondary);
      line-height: 1.2;
      translate: 0 5px;
      opacity: 0;
      animation:
        fadeIn var(--duration-200) ease-out forwards,
        returnTranslate var(--duration-200) ease-out forwards;
      animation-delay: 100ms;

      &::before {
        content: "";
        position: absolute;
        z-index: -1;
        display: block;
        width: 130%;
        aspect-ratio: 1;
        border-radius: 900px;
        background-color: rgba(0, 0, 0, 0.2);
        filter: blur(80px);
        top: 50%;
        left: 45%;
        translate: -50% -60%;

        /* Safari-specific fix for blur effect */
        @supports (-webkit-hyphens: none) {
          background-color: rgba(0, 0, 0, 0.5);
        }
      }
    }
  }

  & .hero-img {
    margin: auto;
    max-width: var(--max-site-width);
    height: 100%;
    overflow: hidden;

    /* One visual image element across all breakpoints */
    & picture,
    & img {
      display: block;
      width: 100%;
    }

    & img {
      height: 875px;
      object-fit: cover;
      object-position: 50% 50%;
    }
  }

  @media (max-width: 1460px) {
    & .hero-img img {
      /* Matches previous "large" framing */
      object-position: 60% 0%;
      height: unset;
      aspect-ratio: 1.8;
    }

    & .wrap p {
      top: calc(var(--header-height) + 10px);
      right: 5%;
      font-size: 36px;
    }
  }

  @media (max-width: 1200px) {
    & .hero-img img {
      height: 670px;
      aspect-ratio: unset;
    }

    & .wrap p {
      font-size: 30px;

      &::before {
        background-color: rgba(0, 0, 0, 0.3);
      }
    }
  }

  @media (max-width: 1000px) {
    & .hero-img img {
      /* Matches previous mobile crop */
      object-position: 50% 80%;
      height: unset;
      aspect-ratio: 1.5;
    }

    & .wrap p {
      top: calc(var(--header-height) + 20px);

      &::before {
        background-color: rgba(0, 0, 0, 0.2);
      }
    }
  }

  @media (max-width: 800px) {
    & .hero-img img {
      height: 520px;
      aspect-ratio: unset;
    }

    & .wrap p {
      font-size: 24px;
    }
  }

  @media (max-width: 630px) {
    & .hero-img img {
      height: unset;
      aspect-ratio: 1.2;
    }
  }

  @media (max-width: 530px) {
    & .wrap p {
      top: calc(var(--header-height) + 0px);
    }
  }

  @media (max-width: 450px) {
    & .wrap p {
      font-size: 20px;

      &::before {
        width: 120%;
        translate: -50% -55%;
      }
    }
  }
}

/* Qualities */

section#qualities .wrap {
  display: grid;
  grid-template-columns: 6fr 7fr;
  align-items: stretch;
  gap: 80px;
  padding-block: 100px;

  & img.qualities-img {
    object-fit: none;
    object-position: right;
    border-radius: 10px;
    translate: 0 5px;
    opacity: 0;
    animation:
      fadeIn var(--duration-200) ease-out forwards,
      returnTranslate var(--duration-200) ease-out forwards;
    animation-delay: 100ms;
  }

  & div {
    & h1 {
      margin-block: 30px;
    }

    & h1,
    & > p {
      translate: 0 5px;
      opacity: 0;
      animation:
        fadeIn var(--duration-200) ease-out forwards,
        returnTranslate var(--duration-200) ease-out forwards;

      &:nth-child(1) {
        animation-delay: 150ms;
      }

      &:nth-child(2),
      &:nth-child(3) {
        animation-delay: 175ms;
      }
    }

    & .grid {
      margin-block: 30px;
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 30px;

      & ul {
        display: flex;
        flex-direction: column;
        gap: 20px;

        & li {
          display: flex;
          align-items: flex-start;
          gap: 20px;
          list-style: none;
          translate: 0 5px;
          opacity: 0;
          animation:
            fadeIn var(--duration-200) ease-out forwards,
            returnTranslate var(--duration-200) ease-out forwards;

          &:nth-child(1) {
            animation-delay: 200ms;
          }

          &:nth-child(2) {
            animation-delay: 225ms;
          }

          &:nth-child(3) {
            animation-delay: 250ms;
          }

          &:nth-child(4) {
            animation-delay: 275ms;
          }

          & img {
            margin-top: 6px;
            width: 24px;
            height: 24px;
            flex-shrink: 0;
          }

          & p {
            font-weight: 500;
          }
        }
      }
    }
  }

  @media (max-width: 1460px) {
    gap: 40px;
    grid-template-columns: 1fr;
    padding-block: 60px 80px;

    & img.qualities-img {
      order: 2;
      object-fit: cover;
      animation-delay: 200ms;
    }

    & div h1 {
      margin-top: 0;
    }

    & div {
      max-width: 1000px;

      & .grid ul li {
        gap: 15px;

        & img {
          margin-top: 3px;
        }
      }
    }
  }

  @media (max-width: 800px) {
    & img.qualities-img {
      aspect-ratio: 1;
    }

    & div {
      & .grid {
        grid-template-columns: 1fr;
        gap: 20px;

        & ul {
          & li {
            gap: 10px;

            &:nth-child(1) {
              animation-delay: 200ms;
            }

            &:nth-child(2) {
              animation-delay: 210ms;
            }

            &:nth-child(3) {
              animation-delay: 220ms;
            }

            &:nth-child(4) {
              animation-delay: 230ms;
            }

            & img {
              width: 20px;
              height: 20px;
            }
          }

          &:nth-child(2) li {
            &:nth-child(1) {
              animation-delay: 240ms;
            }

            &:nth-child(2) {
              animation-delay: 250ms;
            }

            &:nth-child(3) {
              animation-delay: 260ms;
            }
          }
        }
      }
    }
  }

  @media (max-width: 650px) {
    & img.qualities-img {
      object-fit: cover;
      aspect-ratio: unset;
    }
  }

  @media (max-width: 530px) {
    padding-block: 50px;

    & div .grid ul li img {
      margin-top: 1px;
    }
  }
}

/* Energy */

section#energy .wrap {
  display: grid;
  grid-template-columns: 5fr 6fr;
  gap: 60px;
  padding-block: 80px 100px;

  & h1,
  & > div > p,
  & ul li,
  & #animated-schema-svg {
    translate: 0 5px;
    opacity: 0;
    animation:
      fadeIn var(--duration-200) ease-out forwards,
      returnTranslate var(--duration-200) ease-out forwards;
  }

  & h1 {
    margin-block: 60px 30px;
    animation-delay: 150ms;
  }

  & > div > p {
    animation-delay: 175ms;
  }

  & ul {
    margin-top: 30px;

    & li {
      margin-bottom: 20px;
      display: flex;
      align-items: flex-start;
      gap: 20px;
      list-style: none;

      &:nth-child(1) {
        animation-delay: 200ms;
      }

      &:nth-child(2) {
        animation-delay: 220ms;
      }

      &:nth-child(3) {
        animation-delay: 240ms;
      }

      & img {
        margin-top: 6px;
        width: 24px;
        height: 24px;
        flex-shrink: 0;
      }

      p {
        font-weight: 300;

        & b {
          font-weight: 500;
        }
      }
    }
  }

  #animated-schema-svg {
    animation-delay: 200ms;
  }

  @media (max-width: 1460px) {
    padding-block: 60px 80px;

    & h1 {
      margin-top: 10px;
    }
  }

  @media (max-width: 1200px) {
    grid-template-columns: 1fr;
    & ul li {
      gap: 15px;

      & img {
        margin-top: 3px;
      }
    }
  }

  @media (max-width: 800px) {
    padding-block: 40px 60px;
    gap: 30px;

    & ul li {
      gap: 10px;

      & img {
        margin-top: 0;
      }
    }
  }
}

/* Flexibility */

section#flexibility .wrap {
  display: grid;
  grid-template-columns: 8fr 6fr;
  gap: 80px;
  padding-block: 100px;

  & h1,
  & p,
  & .button,
  & #flexibility-slider {
    translate: 0 5px;
    opacity: 0;
    animation:
      fadeIn var(--duration-200) ease-out forwards,
      returnTranslate var(--duration-200) ease-out forwards;
  }

  & h1 {
    margin-block: 30px;
    animation-delay: 100ms;
  }

  & p {
    margin-bottom: 30px;
    max-width: 700px;

    &:nth-of-type(1) {
      animation-delay: 120ms;
    }

    &:nth-of-type(2) {
      animation-delay: 140ms;
    }

    &:nth-of-type(3) {
      animation-delay: 160ms;
    }
  }

  & #flexibility-slider {
    animation-delay: 100ms;
  }

  & button,
  & .button {
    margin-top: 30px;
    animation-delay: 180ms;
  }

  &[data-no-animation] * {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
  }

  & #flexibility-slider .splide-controls {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 40px;

    & button {
      width: 51px;
      height: 51px;
      padding: 0;
      font-weight: 300;
      background-color: #c1c7d3;
      border: 1px solid #c1c7d3;
      outline-offset: 3px;
      cursor: pointer;
      touch-action: manipulation;
      transition:
        background-color 0ms,
        scale 100ms cubic-bezier(0.4, 0, 0.2, 1);

      & * {
        touch-action: manipulation;
      }

      & b {
        color: var(--color-secondary);
        font-weight: 600;
      }

      &.active {
        border-color: var(--color-primary);
        background-color: var(--color-primary);
      }

      @media (hover: hover) and (pointer: fine) {
        &:hover {
          border-color: var(--color-primary);
          background-color: var(--color-primary);
        }
      }

      &.arrow {
        background-color: transparent;

        & svg {
          width: 100%;
          height: 100%;
          fill: #c1c7d3;
        }

        @media (hover: hover) and (pointer: fine) {
          &:hover {
            border-color: #c1c7d3;
            background-color: #c1c7d3;

            & svg {
              fill: var(--color-secondary);
            }
          }
        }
      }
    }
  }

  @media (max-width: 1200px) {
    padding-block: 60px 80px;
    grid-template-columns: 1fr;

    & h1 {
      margin-top: 10px;
    }

    & p {
      max-width: 1000px;
      margin-bottom: 15px;
    }

    & #flexibility-slider {
      animation-delay: 200ms;
    }
  }

  @media (max-width: 800px) {
    padding-block: 60px 40px;

    & #flexibility-slider .splide-controls {
      padding-block: 20px 40px;
      gap: 25px;

      & button {
        margin-top: 0;
        width: 40px;
        height: 40px;
      }
    }
  }

  @media (max-width: 600px) {
    gap: 50px;

    & button,
    & .button {
      margin-top: 20px;
    }
  }

  @media (max-width: 450px) {
    & button,
    & .button {
      margin-top: 10px;
    }

    & #flexibility-slider .splide-controls {
      padding-block: 0 30px;
      gap: 15px;

      & button {
        width: 35px;
        height: 35px;
      }
    }
  }
}

/* Interactive schema */

section#vyber-bytu {
  overflow: hidden;
  overflow: clip;

  & .wrap {
    & h1 {
      padding-block: 60px 0;
    }

    & .badge {
      position: absolute;
      top: 60%;
      right: 2%;
      width: 20%;
      aspect-ratio: 1;
      background-color: var(--color-primary);
      border-radius: 999px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;

      & span {
        display: block;
        text-align: center;
        font-size: clamp(10px, 2.4vw, 36px);
        font-weight: 400;
        color: #d9d9d9;
        letter-spacing: 1px;
        line-height: 1;
      }
    }
  }

  & .interactive-vizu {
    display: block;
    margin: auto;
    width: var(--max-site-width);

    & .commercial,
    & .floor {
      cursor: pointer;
      outline: none;

      & path {
        fill: rgba(255, 255, 255, 0);
        transition: fill var(--duration-200);
        animation: floorFlash 5s infinite;
      }

      &:hover path,
      &:focus-visible path {
        fill: rgba(255, 255, 255, 0.4);
      }

      &:focus-visible path {
        stroke: var(--color-primary);
        stroke-width: 2px;
        vector-effect: non-scaling-stroke;
      }

      &:nth-of-type(2) path {
        animation-delay: 0.2s;
      }

      &:nth-of-type(3) path {
        animation-delay: 0.4s;
      }

      &:nth-of-type(4) path {
        animation-delay: 0.6s;
      }

      &.commercial path {
        animation-delay: 0.8s;
      }
    }

    &:has(.commercial:hover, .commercial:focus) path,
    &:has(.floor:hover, .floor:focus) path {
      animation: none !important;
    }
  }

  @media (max-width: 1460px) {
    & .wrap .badge {
      right: 5%;
    }
  }

  @media (max-width: 700px) {
    & .wrap {
      z-index: 1;

      & h1 {
        max-width: 250px;
      }

      & .badge {
        top: 50%;
      }
    }
  }

  @media (max-width: 600px) {
    & .wrap {
      & h1 {
        padding-block: 40px 80px;
      }

      & .badge {
        top: 30%;
        width: 23%;
      }
    }

    .interactive-vizu {
      scale: 1.4;
      translate: 5% -15%;
    }
  }
}

@keyframes floorFlash {
  25% {
    fill: rgba(255, 255, 255, 0);
  }
  30% {
    fill: rgba(255, 255, 255, 0.4);
  }
  40% {
    fill: rgba(255, 255, 255, 0);
  }
}

/* Animations feel glonky in FF */
/* @-moz-document url-prefix() {
  section#vyber-bytu .interactive-vizu * {
    animation: none !important;
  }
} */

/* Map */

section#map {
  --map-height: 600px;
  height: calc(var(--map-height) - 16px);
  overflow: hidden;

  & #mapbox {
    margin: auto;
    width: 100%;
    max-width: var(--max-site-width);
    height: var(--map-height);

    & .leaflet-popup-content {
      font-size: var(--font-size-text);
    }
    & .leaflet-popup-close-button {
      font-size: var(--font-size-text);
      font-family: "Manrope", Sans-Serif;
    }

    & .map-fallback {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }

  @media (max-width: 1460px) {
    --map-height: 400px;
  }

  @media (max-width: 800px) {
    --map-height: 300px;
    & #mapbox {
      & .leaflet-popup-content {
        margin: 8px 24px 8px 10px;
      }
    }
  }
}

section#timeline .wrap {
  padding-block: 160px;
  padding-inline: var(--inline-padding);

  & [hidden] {
    display: none;
  }

  & svg {
    display: block;
    width: 100%;
    stroke-linecap: round;

    .timeline-line {
      fill: none;
      stroke: #c1c7d3;
      stroke-width: 3.5px;

      & .filled {
        stroke: #363637;
      }

      .timeline-progress {
        stroke-dasharray: 1;
        stroke-dashoffset: 1;
      }

      .timeline-progress-dot {
        fill: #363637;
        stroke: none;
      }
    }

    .timeline-milestones path {
      fill: #c1c7d3;
      transition: fill var(--duration-200);

      &.filled {
        fill: #363637;
      }
    }
  }

  @media (max-width: 1000px) {
    padding-block: 100px;
  }

  /* Vertical layout */
  @media (max-aspect-ratio: 4/5) {
    padding: 100px;

    & #timeline-vertical {
      max-width: 400px;
      margin: auto;
    }
  }

  @media (max-width: 800px) {
    padding-block: 100px;

    /* Vertical layout */
    @media (max-aspect-ratio: 4/5) {
      padding: 80px 60px;
    }
  }
}

section#gallery {
  & .wrap {
    width: 100%;
    padding-inline: var(--inline-padding);
    aspect-ratio: 2.5;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(10, 1fr);
    row-gap: 20px;
    column-gap: 30px;

    & button {
      width: 100%;
      height: 100%;
      display: block;
      background-color: transparent;
      border-radius: 10px;
      padding: 0;
      outline-offset: 2px;

      &.top-leftest {
        grid-column: 1;
        grid-row: 1/5;
      }

      &.top-left {
        grid-column: 2;
        grid-row: 1/5;
      }

      &.top-middle {
        grid-column: 3 / 5;
        grid-row: 1/6;
      }

      &.right {
        grid-column: 5 / 7;
        grid-row: 1 / 11;
      }

      &.bottom-left {
        grid-column: 1 / 3;
        grid-row: 5/11;
      }

      &.bottom-middle {
        grid-column: 3 / 5;
        grid-row: 6/11;
      }

      & > div {
        width: 100%;
        height: 100%;
        border-radius: 10px;
        overflow: hidden;

        & > img {
          width: 100%;
          height: 100%;
          object-fit: cover;
          cursor: zoom-in;
          rotate: 0.1deg; /* FF bug fix */
          transition: var(--duration-400);

          @media (hover: hover) and (pointer: fine) {
            &:hover {
              filter: saturate(1.1);
              scale: 1.05;
            }
          }
        }
      }
    }

    @media (max-width: 800px) {
      grid-template-columns: repeat(2, 1fr);
      grid-template-rows: auto auto;
      aspect-ratio: unset;
      gap: 20px;

      * {
        grid-column: unset !important;
        grid-row: unset !important;
        aspect-ratio: unset !important;
      }

      *:nth-child(n + 3) {
        grid-column: 1 / -1 !important;
        width: 100%;
        aspect-ratio: 2 !important;
      }
    }
  }
}

section#kontakt {
  padding-block: 140px;

  & form {
    position: relative;

    & h1 {
      font-size: min(36px, var(--font-size-h1));
      text-align: center;
    }

    & p {
      margin-inline: auto;
      margin-block: 20px 40px;
      max-width: 700px;
      font-size: 28px;
      text-align: center;
    }

    & input#name {
      position: absolute;
      height: 0;
      width: 0;
      overflow: hidden;
      left: -9999px;
    }

    & .input-wrap {
      position: relative;
      width: 100%;
      max-width: 500px;
      margin: auto;

      & input {
        width: 100%;
        height: 65px;
        padding-right: 60px;
      }

      & button {
        position: absolute;
        right: 16px;
        top: 12px;
        width: 41px;
        height: 41px;
        padding: 0;
        display: grid;
        place-items: center;
        border-radius: 50%;
        border: none;
        cursor: pointer;
        overflow: hidden;
        outline-offset: 2px;

        & img {
          grid-area: 1/1;
          width: 100%;
          height: 100%;
          fill: white;
          pointer-events: none;
          transition: translate var(--duration-200) cubic-bezier(0.785, 0.135, 0.15, 0.86);

          &:first-child {
            translate: -150% 0;
          }
        }

        @media (hover: hover) and (pointer: fine) {
          &:hover img {
            &:first-child {
              translate: 0 0;
            }

            &:nth-child(2) {
              translate: 150% 0;
            }
          }
        }

        & .loading {
          display: none;
          width: 24px;
          height: 24px;
          border-radius: 50%;
          border: 2px solid rgba(255, 255, 255, 0.15);
          border-top-color: var(--color-secondary);
          animation: rotate 750ms linear infinite;
        }

        &:disabled {
          background-color: var(--color-primary-hover);

          & img {
            display: none;
          }

          & .loading {
            display: block;
          }
        }
      }
    }

    & #error-msg {
      display: none;
      margin-bottom: 0;
      font-size: var(--font-size-text);
      text-align: center;
      color: crimson;

      & a {
        color: inherit;
        text-decoration: none;

        @media (hover: hover) and (pointer: fine) {
          &:hover {
            text-decoration: underline;
          }
        }
      }
    }

    &.error {
      & #error-msg {
        display: block;
      }
    }

    & #success-msg {
      display: none;
      position: absolute;
      inset: 0;
      z-index: 1;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding-inline: var(--inline-padding);
      background-color: var(--color-secondary);

      & > * {
        translate: 0 5px;
        opacity: 0;
        animation:
          fadeIn var(--duration-200) ease-out forwards,
          returnTranslate var(--duration-200) ease-out forwards;

        &:nth-child(1) {
          animation-delay: 0ms;
        }

        &:nth-child(2) {
          animation-delay: 50ms;
        }
      }
    }

    &.success {
      & #success-msg {
        display: flex;
      }
    }
  }

  @media (max-width: 800px) {
    padding-block: 100px;

    & form {
      & h1 {
        font-size: 28px;
      }

      & p {
        font-size: 24px;
      }

      & .input-wrap {
        & input {
          width: 100%;
          height: 55px;
          font-size: 24px;
          padding: 8px 55px 8px 20px;
        }

        & button {
          width: 35px;
          height: 35px;
          top: 10px;
          right: 12px;
        }
      }
    }
  }

  @media (max-width: 530px) {
    & form {
      & h1 {
        font-size: 24px;
      }

      & p {
        margin-bottom: 20px;
      }
      & .input-wrap {
        & input {
          font-size: 20px;
        }
      }
    }
  }
}
