import { css } from 'lit';
import componentStyles from '../../styles/component.styles.mjs';

const styles = css`
  ${componentStyles}

  :host {
    --divider-width: max(2px, var(--flow-ui-divider-width));
    --divider-hit-area: 12px;
    --color: var(--flow-ui-divider-color);

    display: block;
  }

  .divider {
    height: 100%;
    display: flex;
    position: relative;
    background-color: var(--color);
  }

  :host(:not([vertical])) .divider {
    width: var(--divider-width);
  }

  :host([vertical]) .divider {
    height: var(--divider-width);
  }

  .divider-highlight {
    width: 100%;
    height: 100%;
    background-color: var(--flow-ui-divider-color-active);
    transition: transform var(--flow-ui-transition-fast) ease-in-out;
    transition-delay: var(--flow-ui-transition-x-fast);
    transform: scale(0);
  }

  :host([dragging]) .divider-highlight,
  .divider:hover .divider-highlight {
    transform: scale(1);
  }

  .divider:focus {
    outline: none;
  }

  :host([disabled]) .divider {
    cursor: not-allowed;
  }

  :host([hidden]) .divider {
    pointer-events: none;
  }

  :host([dragging]) {
    transition: none;
  }

  /* Horizontal */
  :host(:not([vertical], [disabled])) .divider {
    cursor: col-resize;
  }

  :host(:not([vertical])) .divider::after {
    display: flex;
    content: '';
    position: absolute;
    height: 100%;
    left: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);
    width: var(--divider-hit-area);
    z-index: 1000;
  }

  /* Vertical */
  :host([vertical]:not([disabled])) .divider {
    cursor: row-resize;
  }

  :host([vertical]) .divider::after {
    content: '';
    position: absolute;
    width: 100%;
    top: calc(var(--divider-hit-area) / -2 + var(--divider-width) / 2);
    height: var(--divider-hit-area);
    z-index: 1;
  }
`;

export { styles as default };
