@use "~Theme/int.scss";

.canvas {
  display: grid;
  grid-template-areas: "title title title"
    "ylabel yaxis chart"
    "empty empty xaxis"
    "empty empty xlabel";
  grid-template-columns: auto 40px 1fr;
  grid-template-rows: auto 1fr 1.6em auto;
  position: relative;
  height: 100%;

  &.noAxes {
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto 1fr auto auto;
  }

  &.static {
    aspect-ratio: 1;

    @include int.is-desktop {
      aspect-ratio: 16 / 9;
    }
  }
}

.title {
  grid-area: title;
  text-align: center;
  padding-bottom: int.$spacing-2;

  @include int.title();
}

.chart {
  grid-area: chart;
  width: 0;
  min-width: 100%;
  height: 0;
  min-height: 100%;
}

.xlabel {
  grid-area: xlabel;
  text-align: center;

  @include int.sans($size: "300", $weight: "bold", $role: "label");
}

.xaxis {
  grid-area: xaxis;
  position: relative;
}

.ylabel {
  grid-area: ylabel;
  text-align: center;
  writing-mode: vertical-lr;
  transform: rotate(180deg);

  @include int.sans($size: "300", $weight: "bold", $role: "label");
}

.yaxis {
  position: relative;
  grid-area: yaxis;
}

.xaxisTick {
  position: absolute;
  top: 4px;
  left: calc((1px * var(--margin)) + ((100% - (var(--margin) * 2px)) * var(--x)));
  transform: translateX(-50%);
  color: int.$warmgray-80;
}

.yaxisTick {
  position: absolute;
  top: calc((1px * var(--margin)) + ((100% - (var(--margin) * 2px)) * var(--y)));
  right: 4px;
  transform: translateY(-50%);
  color: int.$warmgray-80;
}

.annotations {
  grid-area: chart;
  width: 100%;
  height: 100%;
  position: relative;

  .text {
    position: absolute;
    top: calc((1px * var(--margin)) + ((100% - (var(--margin) * 2px)) * var(--y)));
    left: calc((1px * var(--margin)) + ((100% - (var(--margin) * 2px)) * var(--x)));
    transform: rotate(var(--rotate, 0deg)) translate(0px, -50%);
    transform-origin: left top;
    color: var(--color, #{int.$warmgray-100});

    &.center {
      transform: rotate(var(--rotate, 0deg)) translate(-50%, -50%);
    }

    &.right {
      transform: rotate(var(--rotate, 0deg)) translate(-100%, -50%);
    }
  }
}
