/*
 * 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/.
 */

/** Zen Decks - ONLY USED FOR SPLIT VIEWS, DO NOT USE THIS CLASS FOR ANY OTHER PURPOSE **/

#tabbrowser-tabpanels[zen-split-view='true'] {
  display: flex;
  flex-direction: row;
  margin-top: calc(var(--zen-split-column-gap) * -1);
}

#tabbrowser-tabpanels[zen-split-view='true'] > *:not([zen-split='true']) {
  flex: 0;
  margin: 0;
}
#zen-splitview-dropzone {
  border-radius: var(--zen-native-inner-radius);
  transition: inset ease-out 0.08s;
  display: none;
  background-color: color-mix(in srgb, var(--zen-colors-secondary) 30%, transparent 70%);
}
#zen-splitview-dropzone[enabled='true'] {
  display: initial;
}

#tabbrowser-tabpanels[zen-split-view='true'] > [zen-split='true'],
#zen-splitview-dropzone {
  flex: 1;
  margin: var(--zen-split-column-gap) var(--zen-split-row-gap) !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  position: absolute !important;
  overflow: hidden;

  & .dialogStack {
    /* Fix for issue https://github.com/zen-browser/desktop/issues/7564 */
    position: absolute;
  }
}

#zen-splitview-dropzone {
  margin-top: 0 !important;
}

#tabbrowser-tabpanels[zen-split-view='true']:not([zen-split-resizing]) > [zen-split='true'] {
  transition: inset 0.09s ease-out !important;
  & browser {
    transition: opacity 0.2s ease-out !important;
  }
}

#tabbrowser-tabpanels[zen-split-view='true'] .browserSidebarContainer.deck-selected {
  &:not(.zen-glance-overlay) {
    outline: 1px solid var(--zen-primary-color) !important;
  }

  &.zen-glance-overlay {
    flex: 1;
    margin-top: calc(var(--zen-element-separation) / 2);
    z-index: 1;
  }
}

#tabbrowser-tabbox:has(#tabbrowser-tabpanels[zen-split-view='true']) {
  :root[zen-no-padding='true'] & {
    --zen-element-separation: 8px;
  }

  --zen-split-row-gap: var(--zen-element-separation);
  --zen-split-column-gap: calc(var(--zen-element-separation) + 1px);
  margin-right: calc(-1 * var(--zen-split-column-gap));
}

:root:not([customizing]) #zen-splitview-overlay {
  margin-top: calc(var(--zen-split-column-gap) * -1);
}

#tabbrowser-tabpanels[zen-split-view] {
  .zen-split-view-splitter {
    display: inherit;
  }
}

#zen-splitview-overlay-wrapper {
  position: absolute;
  pointer-events: none;
  padding: inherit;
  inset: 0;
}

#zen-splitview-overlay {
  position: relative;
  flex: 1;
  z-index: 2;
}

.zen-split-view-splitter {
  visibility: inherit;
  -moz-subtree-hidden-only-visually: 0;
  position: absolute;
  pointer-events: all;
}

.zen-split-view-splitter[orient='horizontal'] {
  height: var(--zen-split-column-gap);
  cursor: ns-resize;
}

.zen-view-splitter-header-container {
  position: absolute;
  top: calc(var(--zen-split-column-gap) / -2);
  left: 50%;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  transform: translateX(-50%);
  pointer-events: none;
}

.zen-view-splitter-header {
  display: flex;
  align-items: center;
  position: fixed;
  padding: 0.4rem 0.6rem 0.2rem 0.6rem;
  border-radius: var(--zen-native-content-radius);
  background-color: light-dark(rgba(255, 255, 255, 1), rgba(0, 0, 0, 1));
  box-shadow: 0 0 0 1px var(--button-primary-border-color);
  gap: 0.8rem;
  transform: translateX(-50%);
  box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

:root:not([inDOMFullscreen='true'])
  .browserSidebarContainer:hover
  .zen-view-splitter-header-container,
.zen-view-splitter-header-container:hover {
  pointer-events: all;
  opacity: 1;
  transition-delay: 0.2s;
}

.zen-view-splitter-header-container toolbarbutton {
  display: flex;
  -moz-context-properties: fill, fill-opacity;
  border-radius: var(--tab-border-radius);
  color: inherit;
  fill: currentColor;
  width: 16px;
  height: 16px;
  cursor: pointer;
  appearance: none;
  outline: none;
  color: var(--button-primary-bgcolor);
  border-top-left-radius: 0;
  border-top-right-radius: 0;

  & image {
    width: 14px;
    height: 14px;
  }

  &.zen-tab-unsplit-button image {
    height: 10px;
    width: 10px;
  }

  &.zen-tab-rearrange-button {
    cursor: move;

    & image {
      transform: rotate(90deg);
    }
  }
}

#zen-split-view-fake-browser {
  position: absolute;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--zen-native-inner-radius);
  box-shadow: var(--zen-big-shadow);
  overflow: hidden;

  &[side='right'] {
    right: 0;

    &[has-split-view='true'] {
      right: var(--zen-element-separation);
    }
  }

  &::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3.5rem;
    pointer-events: none;
    height: 3.5rem;
    background: var(--zen-split-view-fake-icon);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.8;
    transition: opacity 0.2s;
    transition-delay: 0.1s;

    @starting-style {
      opacity: 0;
    }
  }

  &.fade-out::after {
    opacity: 0;
    transition-delay: 0s;
  }
}
