import { css } from '@tesseract-design/goofy-goober';

export interface BlobBaseArgs {
  border: boolean,
  block: boolean,
}

export const Root = ({
  block,
}: BlobBaseArgs) => css.cx(
  css`
    vertical-align: middle;
    position: relative;
    border-radius: 0.25rem;
    font-family: var(--font-family-base, sans-serif);
    max-width: 100%;
    overflow: hidden;
    min-height: 20rem;
    min-width: 20rem;
    &:focus-within {
      --color-accent: var(--color-hover, red);
    }
    & > span {
      border-color: var(--color-accent, blue);
      box-sizing: border-box;
      display: inline-block;
      border-width: 0.125rem;
      border-style: solid;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border-radius: inherit;
      z-index: 2;
      pointer-events: none;
      transition-property: border-color;
    }
    & > span::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      content: '';
      border-radius: 0.125rem;
      opacity: 0.5;
      pointer-events: none;
      box-shadow: 0 0 0 0 var(--color-accent, blue);
      transition-property: box-shadow;
      transition-duration: 150ms;
      transition-timing-function: linear;
    }
    &:focus-within > span::before {
      box-shadow: 0 0 0 0.375rem var(--color-accent, blue);
    }
  `,
  css.dynamic({
    display: block ? 'block' : 'inline-block',
  }),
);

export const Border = ({
  border
}: BlobBaseArgs): string => css.cx(
  css.if (border) (
    css`
      border-color: var(--color-accent, blue);
      box-sizing: border-box;
      display: inline-block;
      border-width: 0.125rem;
      border-style: solid;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border-radius: inherit;
      pointer-events: none;
      z-index: 10;
      &::before {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        content: '';
        border-radius: 0.125rem;
        opacity: 0.5;
        pointer-events: none;
      }
    `
  ),
);


export const LabelWrapper = ({
  border,
}: BlobBaseArgs): string => css.cx(
  css`
    color: var(--color-accent, blue);
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bolder;
    z-index: 1;
    pointer-events: none;
    transition-property: color;
    line-height: 0.65;
    user-select: none;
    font-size: 0.725em;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  `,
  css.if (border) (
    css`
      background-color: var(--color-background, white);
    `
  ),
)
