/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#tab-preview-panel {
  --panel-width: 280px;
  --panel-padding: 0;
  --tab-note-text-background: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.3));
  --tab-note-text-border-color: transparent;
  @media (prefers-contrast) {
    --tab-note-text-background: transparent;
    --tab-note-text-border-color: var(--border-color-card);
  }
  /* stylelint-disable-next-line media-query-no-invalid */
  @media not -moz-pref("browser.tabs.notes.enabled") {
    pointer-events: none;
  }
}

.tab-preview-text-container {
  padding: var(--space-small);
}

.tab-preview-title {
  overflow: hidden;
  -webkit-line-clamp: 2;
  font-weight: var(--heading-font-weight);
}

.tab-preview-uri {
  color: var(--text-color-deemphasized);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tab-preview-pid-activeness {
  color: var(--text-color-deemphasized);
  display: flex;
  justify-content: space-between;
}

.tab-preview-thumbnail-container {
  width: 264px;
  margin: 0 auto var(--space-small);
  overflow: hidden;

  &.hide-thumbnail {
    display: none;
  }
  @media (width < 640px) {
    display: none;
  }
  > canvas {
    display: block;
    width: 100%;
    animation: tab-hover-preview-fadein 0.2s ease;
    border: 1px solid var(--border-color-deemphasized);
    border-radius: var(--border-radius-medium);
    box-sizing: border-box;
  }
}

.tab-preview-add-note {
  --box-border-color: transparent;
  --box-padding: var(--space-medium);
  margin: 0 var(--space-small) var(--space-small);

  &[hidden] {
    display: none;
  }
}

.tab-preview-note-container {
  font: menu;
  position: relative;
  margin: 0 var(--space-small) var(--space-small);
  padding: var(--space-small);
  border-radius: var(--border-radius-medium);
  background-color: var(--tab-note-text-background);
  border: var(--border-width) solid var(--tab-note-text-border-color);

  &[hidden] {
    display: none;
  }
}

.tab-preview-note-text {
  overflow-wrap: break-word;

  #tab-preview-panel:not([note-expanded]) & {
    /* Set by Javascript */
    --tab-note-expand-toggle-width: 0;

    --gradient-width: 40px;
    --gradient-offset: 10px;
    --gradient-direction: right;

    overflow: hidden;
    -webkit-line-clamp: 10;

    mask:
      /* Mask 1: make all lines except the last visible (by default,
       * unmasked portions of an element are invisible, which is why
       * this is needed). Mask 2: Fade out the end of the last line */
      linear-gradient(black) 0 0 / 100% calc(100% - 1lh) no-repeat,
      linear-gradient(
          to var(--gradient-direction),
          black calc(100% - var(--tab-note-expand-toggle-width) - var(--gradient-width) - var(--gradient-offset)),
          transparent calc(100% - var(--tab-note-expand-toggle-width) - var(--gradient-offset))
        )
        0 100% / 100% 1lh no-repeat;

    &:dir(rtl) {
      --gradient-direction: left;
    }
  }
}

.tab-preview-note-expand {
  display: none;
  text-decoration: underline;
  cursor: pointer;
  position: absolute;
  /* position at bottom-end of containing box, using the same padding as the
   * containing box */
  inset-block-end: 0;
  inset-inline-end: 0;
  padding: var(--space-small);

  #tab-preview-panel[note-overflow]:not([note-expanded]) & {
    display: block;
  }
}

@keyframes tab-hover-preview-fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 100;
  }
}

#tabgroup-panel-content {
  max-width: var(--menuitem-max-width);

  & toolbarbutton.active-tab {
    font-weight: var(--font-weight-semibold);
  }
}
