@use "../../base";

/// @access private
@mixin styles {
  .govuk-panel {
    @include base.govuk-font($size: 36);

    box-sizing: border-box;

    margin-bottom: base.govuk-spacing(3);
    padding: base.govuk-spacing(7) - base.$govuk-border-width;

    border: base.$govuk-border-width solid transparent;
    color: base.govuk-functional-colour(text);

    text-align: center;

    @media #{base.govuk-until-breakpoint(tablet)} {
      padding: base.govuk-spacing(4) - base.$govuk-border-width;

      // Support IE (autoprefixer doesn't add this as it's not a prefix)
      word-wrap: break-word;

      // This is an if-all-else-fails attempt to stop long words from
      // overflowing the container on very narrow viewports by forcing them to
      // break and wrap instead. This overflowing is more likely to happen when
      // user increases text size on a mobile eg. using iOS Safari text resize
      // controls.
      //
      // The overflowing is a particular problem with the panel component since
      // it uses white text: when the text overflows the container, it is
      // invisible on the white (page) background. When the text in our other
      // components overflow, the user might have to scroll horizontally to view
      // it but the the text remains legible.
      overflow-wrap: break-word;
    }
  }

  .govuk-panel__title {
    @include base.govuk-font-size($size: 48);
    @include base.govuk-typography-weight-bold;
    margin-top: 0;
    margin-bottom: base.govuk-spacing(6);
  }

  // Remove bottom spacing from anything at the end of the Panel's content
  // to stop the Panel's padding spacing from becoming too large.
  .govuk-panel__title:last-child,
  .govuk-panel__body > :last-child,
  .govuk-panel__actions > :last-child {
    margin-bottom: 0;
  }

  // On larger screens if the Panel actions have a button group,
  // then we want to adjust the spacing a bit to avoid the button group
  // making the Panel's padding spacing being too large.
  @media #{base.govuk-from-breakpoint(tablet)} {
    .govuk-panel__actions > .govuk-button-group:last-child {
      margin-bottom: -1 * base.govuk-spacing(2);
    }
  }

  // When the panel shows some actions, make sure they have some spacing
  // from the panel's content
  .govuk-panel__body:not(:last-child) {
    margin-bottom: base.govuk-spacing(7);
  }

  .govuk-panel--confirmation {
    --govuk-text-colour: #{base.govuk-functional-colour(inverse-text)};
    background: base.govuk-functional-colour(success);
  }

  .govuk-panel--interruption {
    --govuk-text-colour: #{base.govuk-functional-colour(inverse-text)};
    background: base.govuk-functional-colour(brand);
    text-align: left;

    // Smaller title to go alongside smaller body text.
    .govuk-panel__title {
      @include base.govuk-font-size($size: 36);
      margin-bottom: base.govuk-spacing(3);
    }
  }

  @media print {
    .govuk-panel {
      --govuk-text-colour: inherit;
      border-color: currentcolor;
      background: none;
    }
  }
}

