//
// Copyright © 2021 Anticrm Platform Contributors.
// 
// Licensed under the Eclipse Public 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 https://www.eclipse.org/legal/epl-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.
//

/* CLEAR */
a {
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  color: var(--theme-content-accent-color);
  outline: none;
  &:hover {
    color: var(--theme-caption-color);
    text-decoration: underline;
  }
  &:active {
    color: var(--theme-content-accent-color);
    text-decoration: underline;
  }
  &:visited { color: var(--theme-caption-color); }
}
button {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0;
  font-size: inherit;
  background-color: transparent;
  border: 1px solid transparent;
  outline: none;
  cursor: pointer;
  user-select: none;
}
input {
  min-width: 0;
  font: inherit;
  background-color: transparent;
  outline: none;
  color: var(--theme-caption-color);
}
audio, canvas, embed, iframe, img, object, svg, video {
  display: block;
  vertical-align: middle;
}
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus
input:-webkit-autofill, 
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--theme-caption-color);
  transition: background-color 5000s ease-in-out 0s;
  background: transparent;
}

table, caption, tbody, tfoot, thead, tr, th, td {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: middle;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Common */
* {
  --modal-padding: 1.5rem;
}

p:first-child { margin-block-start: 0; } // First and last padding
p:last-child { margin-block-end: 0; }

/* Flex */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-grow { flex-grow: 1; }
.flex-no-shrink { flex-shrink: 0; }
.flex-nowrap {
  display: flex;
  flex-wrap: nowrap;
}
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-stretch {
  display: flex;
  align-items: stretch;
}
.flex-row-center {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}
.flex-row-top {
  display: flex;
  align-items: flex-start;
}
.flex-row-reverse {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
}
.flex-reverse {
  flex-direction: row-reverse;
}
.flex-col {
  display: flex;
  flex-direction: column;
}
.flex-col-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flex-col-stretch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.safari-gap-1 {
  & > * { margin-right: .25rem; }
  & > *:last-child { margin-right: 0; }
  &.reverse {
    flex-direction: row-reverse;
    & > :last-child { margin-right: .25rem; }
    & > :first-child { margin-right: 0; }
  }
}
.safari-gap-2 {
  & > * { margin-right: .5rem; }
  & > *:last-child { margin-right: 0; }
  &.reverse {
    flex-direction: row-reverse;
    & > :last-child { margin-right: .5rem; }
    & > :first-child { margin-right: 0; }
  }
}

/* --------- */
.sm-tool-icon {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  width: fit-content;
  color: var(--theme-caption-color);
  cursor: pointer;
  .icon {
    margin-right: .25rem;
    color: var(--theme-content-dark-color);
  }
  &:hover .icon { color: var(--theme-caption-color); }
}

/* Margins & Paddings */
.step-lr25 + .step-lr25 { margin-left: .25rem; }
.step-lr75 + .step-lr75 { margin-left: .75rem; }
.step-tb75 + .step-tb75 { margin-top: .75rem; }

.ml-1 { margin-left: .25rem; }
.ml-2 { margin-left: .5rem; }
.ml-3 { margin-left: .75rem; }
.ml-4 { margin-left: 1rem; }
.ml-6 { margin-left: 1.5rem; }
.mr-1 { margin-right: .25rem; }
.mr-2 { margin-right: .5rem; }
.mr-3 { margin-right: .75rem; }
.mr-4 { margin-right: 1rem; }
.mr-6 { margin-right: 1.5rem; }
.mr-8 { margin-right: 2rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-9 { margin-top: 2.25rem; }
.mt-10 { margin-top: 2.5rem; }
.mt-14 { margin-top: 3.5rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }

/* --------- */
.relative { position: relative; }
.abs-lt-content {
  position: absolute;
  top: var(--modal-padding);
  left: var(--modal-padding);
}
.abs-rt-content {
  position: absolute;
  top: var(--modal-padding);
  right: var(--modal-padding);
}
.abs-lb-content {
  position: absolute;
  bottom: var(--modal-padding);
  left: var(--modal-padding);
}
.abs-rb-content {
  position: absolute;
  bottom: var(--modal-padding);
  right: var(--modal-padding);
}
.abs-full-content {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.vScroll {
  flex-grow: 1;
  overflow-x: hidden;
  overflow-y: auto;
}

.h-full { height: 100%; }
.w-full { width: 100%;  }
.min-w-0 { min-width: 0; }
.min-h-0 { min-height: 0; }
.clear-mins {
  min-width: 0;
  min-height: 0;
}
.square-36 { width: 2.25rem; height: 2.25rem; }

/* --------- */
.svg-x-small {
  width: 0.857em;
  height: 0.857em;
}

.svg-small {
  width: 1.143em;
  height: 1.143em;
}
.svg-medium {
  width: 1.429em;
  height: 1.429em;
}
.svg-large {
  width: 1.715em;
  height: 1.715em;
}
.svg-small, .svg-medium, .svg-large { flex-shrink: 0; }

.svg-mask {
  position: absolute;
  width: 0;
  height: 0;
}

.hover-trans {
  color: var(--theme-content-trans-color);
  cursor: pointer;
  &:hover { color: var(--theme-caption-color); }
  &:active { color: var(--theme-content-accent-color); }
}

/* Link */
a.no-line {
  text-decoration: none;
  color: var(--theme-caption-color);
  &:hover { color: var(--theme-caption-color); }
  &:active { color: var(--theme-content-accent-color); }
  &:visited { color: var(--theme-caption-color); }
}
.cursor-pointer { cursor: pointer; }

/* Text */
.small-text { font-size: .75rem; }
.fs-title {
  font-weight: 500;
  font-size: 1rem;
  color: var(--theme-caption-color);
  user-select: none;
}
.trans-title {
  text-transform: uppercase;
  font-weight: 600;
  font-size: .75rem;
  color: var(--theme-content-trans-color);
  user-select: none;
}
.fs-bold { font-weight: 500; }

.over-underline {
  cursor: pointer;
  &:hover { text-decoration: underline; }
}

.hidden-text {
  position: absolute;
  visibility: hidden;
  overflow: hidden;
  white-space: pre-wrap;
}
.overflow-label {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  user-select: none;
  min-width: 0;
}

.lines-limit-2, .lines-limit-4 {
  min-width: 0;
  overflow: hidden;
  visibility: visible;
  display: -webkit-box;
  /* autoprefixer: ignore next */
  -webkit-box-orient: vertical;
}
.lines-limit-2 {
  -webkit-line-clamp: 2;
  line-clamp: 2;  
}
.lines-limit-4 {
  -webkit-line-clamp: 4;
  line-clamp: 4;  
}

.focused-button {
  background-color: var(--theme-button-bg-focused);
  border: 1px solid transparent;

  & > .icon { color: var(--theme-content-trans-color); }
  &.selected {
    background-color: var(--theme-button-bg-focused);
    border: 1px solid var(--theme-bg-accent-color);
  }
  &:hover {
    background-color: var(--theme-button-bg-pressed);
    border: 1px solid var(--theme-bg-accent-color);
    & > .icon { color: var(--theme-caption-color); }
  }
  &:focus {
    border: 1px solid var(--primary-button-focused-border);
    box-shadow: 0 0 0 3px var(--primary-button-outline);
    & > .icon { color: var(--theme-caption-color); }
  }
}

.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.whitespace-nowrap { white-space: nowrap; }

.scroll-m-10::-webkit-scrollbar-track { margin: 2.5rem; }

/* Backgrounds & Colors */
.background-theme-bg-color { background-color: var(--theme-bg-color); }
.background-highlight-red { background-color: var(--highlight-red); }
.background-button-bg-enabled { background-color: var(--theme-button-bg-enabled); }
.background-menu-divider { background-color: var(--theme-menu-divider); }
.background-primary-color { background-color: var(--primary-button-enabled); }

.content-color { color: var(--theme-content-color); }
.content-trans-color { color: var(--theme-content-trans-color); }
.content-accent-color { color: var(--theme-content-accent-color); }
.content-dark-color { color: var(--theme-content-dark-color); }
.caption-color { color: var(--theme-caption-color); }

.red-color { color: var(--highlight-red); }

.border-primary-button { border-color: var(--primary-button-border); }
.border-button-enabled { border: 1px solid var(--theme-button-border-enabled); }
.bottom-divider { border-bottom: 1px solid var(--theme-menu-divider); }
