/*
Copyright 2019-2026 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

@use '@carbon/react/scss/config' as *;
@use '@carbon/react/scss/theme' as *;
@use '@carbon/react/scss/type' as *;

.tkn--tasks {
  // for legacy layout we need to flex the tasks
  // but for the new tab layout in a narrow window
  // we need to allow the tabs to appear horizontally
  // across the top of the container
  &:not(:has(> .#{$prefix}--tabs, > .tkn--step-details:first-child)) {
    display: flex;
    flex-wrap: nowrap;
    min-block-size: calc(100vb - 16rem);
    align-items: stretch;
  }

  .tkn--step-details {
    background-color: $layer;
    flex-grow: 1;
    padding-inline-start: 1rem;
  }

  .#{$prefix}--data-table {
    td {
      background-color: $layer-02;
      border-block-start-color: $layer-02;
    }
    tr:hover td {
      background-color: $layer-hover;
    }
  }

  > .#{$prefix}--css-grid {
    padding-inline: 0;
  }
}

.#{$prefix}--snippet--multi {
  overflow-x: auto
}

.tkn--task-logs {
  .#{$prefix}--accordion__heading {
    position: sticky;
    inset-block-start: calc(6.9rem + var(--tkn-global-header-offset));
    background-color: $layer-01;
    // this needs to be lower than the run header to prevent it bleeding through
    // popovers or other menus such as the log settings
    z-index: 4995;

    &:focus, &:hover {
      // prevent Carbon from reverting to position: relative
      position: sticky;
    }
  }

  .#{$prefix}--accordion__title {
    display: flex;
    align-items: center;

    .tkn--step-name {
      flex-grow: 1;
    }

    .tkn--step-duration {
      @include type-style('helper-text-01');
      margin-inline-end: 0.5rem;
    }

    svg {
      margin-inline-end: 0.5rem;
    }
  }

  .#{$prefix}--accordion__content {
    padding-inline-end: 1rem;

    .tkn--step-definition {
      margin-block-end: 0.75rem;

      summary {
        @include type-style('helper-text-01');
      }

      .#{$prefix}--snippet--multi {
        inline-size: auto;
      }
    }
  }
}

.tkn--step-details.tkn--taskrun--maximized {
  position: fixed;
  inset: 0;
  z-index: 9999;
  block-size: 100vb;
  overflow: auto;

  // need to include units here otherwise breaks calc()
  --tkn-global-header-offset: 0rem;
}

.tkn--task-skipped {
  @include type-style('body-compact-01');
}

.tkn--toolbar {
  font-family: 'IBM Plex Sans', sans-serif;

  .#{$prefix}--btn--icon-only {
    inline-size: var(--cds-layout-size-height-local);
  }
}
