@use '../mixins/css3/borders';
@use '../mixins/css3/text-decorators' as decorators;
@use '../variables' as vars;
@use '../color-vars' as colors;

@layer utilities {
  .h-full {
    height: 100%;
  }

  .w-full {
    width: 100%;
  }

  .h-vh {
    height: 100vh;
  }

  .w-vw {
    width: 100vw;
  }

  .h-svh {
    height: 100svh;
  }

  .w-svw {
    width: 100svw;
  }

  .max-h-full {
    max-height: 100%;
  }

  .max-w-full {
    max-width: 100%;
  }

  .aspect-video {
    aspect-ratio: 16/9;
  }

  .relative {
    position: relative;
  }

  .absolute {
    position: absolute;
  }

  .absolute-top {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
  }

  .absolute-bottom {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .fixed {
    position: fixed;
  }

  .fixed-top {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
  }

  .fixed-bottom {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
  }

  .sticky {
    position: sticky;
  }

  .sticky-top {
    position: sticky;
    top: 0;
    z-index: 1020;
  }

  .sticky-bottom {
    position: sticky;
    bottom: 0;
    z-index: 1020;
  }

  .float-start {
    float: left;
  }

  .float-end {
    float: right;
  }

  .float-none {
    float: none;
  }

  .overflow-auto {
    overflow: auto;
  }

  .overflow-hidden {
    overflow: hidden;
  }

  .overflow-x-auto {
    overflow-x: auto;
  }

  .overflow-x-hidden {
    overflow-x: hidden;
  }

  .overflow-y-auto {
    overflow-y: auto;
  }

  .overflow-y-hidden {
    overflow-y: hidden;
  }

  .rounded-0 {
    border-radius: 0;
  }

  .rounded-t-0 {
    @include borders.top-radius(0);
  }

  .rounded-b-0 {
    @include borders.bottom-radius(0);
  }

  .rounded-s-0 {
    @include borders.start-radius(0);
  }

  .rounded-e-0 {
    @include borders.end-radius(0);
  }

  .font-weight-bold {
    font-weight: vars.$font-weight-bold;
  }

  .font-weight-bolder {
    font-weight: vars.$font-weight-boldest;
  }

  .font-weight-semibold {
    font-weight: vars.$font-weight-semibold;
  }

  .font-weight-medium {
    font-weight: vars.$font-weight-medium;
  }

  .font-weight-normal {
    font-weight: vars.$font-weight-normal;
  }

  .font-weight-light {
    font-weight: vars.$font-weight-light;
  }

  .border {
    border: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-thin {
    border: thin solid;
  }

  .border-t {
    border-top: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-b {
    border-bottom: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-tb {
    border-top: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
    border-bottom: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-s {
    border-left: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-e {
    border-right: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-se {
    border-left: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
    border-right: 1px solid var(--#{vars.$prefix}border-color, var(--border-translucent));
  }

  .border-0 {
    border: 0;
  }

  .border-t-0 {
    border-top: 0;
  }

  .border-b-0 {
    border-bottom: 0;
  }

  .border-s-0 {
    border-left: 0;
  }

  .border-e-0 {
    border-right: 0;
  }

  .border-none {
    border: none;
  }

  .mx-auto {
    margin-left: auto;
    margin-right: auto;
  }

  .mx-0 {
    margin-right: 0;
    margin-left: 0;
  }

  .my-0 {
    margin-top: 0;
    margin-bottom: 0;
  }

  .ms-auto {
    margin-left: auto;
  }

  .ms-0 {
    margin-left: 0;
  }

  .mt-0 {
    margin-top: 0;
  }

  .me-auto {
    margin-right: auto;
  }

  .me-0 {
    margin-right: 0;
  }

  .mb-0 {
    margin-bottom: 0;
  }

  .px-0 {
    padding-right: 0;
    padding-left: 0;
  }

  .py-0 {
    padding-top: 0;
    padding-bottom: 0;
  }

  .ps-0 {
    padding-left: 0;
  }

  .pe-0 {
    padding-right: 0;
  }

  .pt-0 {
    padding-top: 0;
  }

  .pb-0 {
    padding-bottom: 0;
  }

  .select-none {
    user-select: none;
  }

  .caret-up {
    width: 0;
    height: 0;
    border-left: var(--#{vars.$prefix}caret-size) solid transparent;
    border-right: var(--#{vars.$prefix}caret-size) solid transparent;
    border-bottom: var(--#{vars.$prefix}caret-size) solid currentColor;
    display: inline-block;
  }

  .caret-down {
    width: 0;
    height: 0;
    border-left: var(--#{vars.$prefix}caret-size) solid transparent;
    border-right: var(--#{vars.$prefix}caret-size) solid transparent;
    border-top: var(--#{vars.$prefix}caret-size) solid currentColor;
    display: inline-block;
  }

  .#{vars.$prefix}link {
    cursor: pointer;
  }

  .#{vars.$prefix}shadow-0 {
    box-shadow: none;
  }

  .#{vars.$prefix}shadow {
    box-shadow:
      0 1px 2px 0 oklch(0.369 0.007 240.019 / 0.35),
      0 1px 4px 3px oklch(0.369 0.007 240.019 / 0.05);
  }

  .#{vars.$prefix}shadow-1 {
    box-shadow: vars.$z-depth-1-half;
  }

  .#{vars.$prefix}shadow-2 {
    box-shadow: vars.$z-depth-2;
  }

  .#{vars.$prefix}shadow-3 {
    box-shadow: vars.$z-depth-3;
  }

  .#{vars.$prefix}shadow-4 {
    box-shadow: vars.$z-depth-4;
  }

  .#{vars.$prefix}shadow-5 {
    box-shadow: vars.$z-depth-5;
  }

  .#{vars.$prefix}hover-shadow {
    box-shadow: none;
    transition: vars.$transition-hoverable;

    &:hover {
      box-shadow: vars.$z-depth-2;
    }
  }

  .text-start {
    text-align: start;
  }

  .text-center {
    text-align: center;
  }

  .text-end {
    text-align: end;
  }

  .text-justify {
    text-align: justify;
  }

  // Create utilities for global CSS variables
  //--------------------------------------------------
  .text-bg-surface {
    background-color: var(--background);
    color: var(--foreground);
  }

  .text-bg-surface-secondary {
    background-color: var(--background-secondary);
    color: var(--foreground-secondary);
  }

  .text-bg-surface-tertiary {
    background-color: var(--background-tertiary);
    color: var(--foreground-tertiary);
  }

  @include decorators.decorate-color(
    'subtle',
    var(--foreground-subtle),
    $background: false,
    $border: false
  );

  @include decorators.decorate-color(
    'subtle-secondary',
    var(--foreground-subtle-secondary),
    $background: false,
    $border: false
  );

  @include decorators.decorate-color(
    'subtle-tertiary',
    var(--foreground-subtle-tertiary),
    $background: false,
    $border: false
  );
}

// Prevent overridden by Bootstrap or TailwindCSS
.rounded {
  border-radius: var(--#{vars.$prefix}radius);
}

.rounded-circle {
  border-radius: #{vars.$radius-circle};
}

.rounded-pill {
  border-radius: var(--#{vars.$prefix}radius-pill);
}
