@charset "utf-8";

body {
  overflow-x: hidden;
  user-select: none;
}

header {
  .checkbox-label-container {
    display: flex;
    gap: 2px;
    margin-left: auto;
  }

  .size-radio-label-container {
    display: flex;
    gap: 2px;
    margin-left: 8px;

    .size-radio-label {
      width: 32px;
    }
  }
}

main {
  padding: 8px 0 32px;
}

.hero-section {
  h1 {
    margin-top: 16px;
  }

  .num-text {
    margin-top: 16px;
  }
}

.main-top-section {
  padding-top: 16px;

  .add-text {
    margin-top: 4px;
  }

  .tier-list {
    display: grid;
    grid-template-columns: auto 1fr;
    border: 1px solid var(--color-border);
    width: calc(100% - 28px);
    margin-top: 4px;

    &:empty {
      display: none;
    }
  }

  .tier-item {
    position: relative;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;

    &+& {
      .tier-main-container {
        border-top: 1px solid var(--color-border);
      }
    }

    &.active {
      .tier-main-container-inner {
        z-index: 101;
        pointer-events: none;
        outline: 1px solid #fff;
      }
    }
  }

  .tier-main-container {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
  }

  .tier-main-container-inner {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
  }

  .tier-label-container {
    display: grid;
    border-right: 1px solid var(--color-border);
  }

  .tier-label {
    display: grid;
    place-items: center;
    text-align: center;
    min-width: 48px;
    padding: 2px 4px;
    color: #2f2f2f;
    font-size: 14px;
    white-space: nowrap;

    @media (width < 1200px) {
      min-width: max(3.8vw, 32px);
      font-size: max(1.2vw, 0.75rem);
    }
  }

  .tier-list.slim {
    .tier-label {
      width: 48px;

      @media (width < 1200px) {
        width: max(3.8vw, 32px);
      }
    }
  }

  .tier-menu-btn-container {
    position: absolute;
    right: -32px;
    width: 32px;
    height: 100%;
    display: grid;
    place-items: center;
  }

  .tier-menu-btn {
    all: unset;
    box-sizing: border-box;
    color: var(--color);
    width: 30px;
    height: 30px;
    border-radius: 50%;

    @media (hover: hover) {
      &:hover {
        background-color: #fff1;
      }
    }

    .bi {
      display: grid;
      place-items: center;
    }
  }
}

.pin-bottom-container {
  margin-top: 4px;
}

.book-card-img-container-outer,
.void-card-img-container-outer {
  border: 1px solid var(--color-border);
}

.book-card-img-container-outer {
  margin-right: 28px;
}

.void-card-img-container-outer {
  margin: 4px 28px 0 0;

  &.hidden {
    display: none;
  }
}

.void-card-img-container {
  .card-img {
    opacity: 0.3;

    &.active {
      opacity: calc(0.3 * 0.3);
    }
  }
}

.void-checkbox-label {
  margin-top: 4px;
}

.card-img-container {
  display: grid;
  align-content: start;
  background: #1f1f1f;

  &:empty::before {
    content: '';
    aspect-ratio: var(--aspect-ratio);
    pointer-events: none;
  }
}

.card-img-container-wrapper {
  position: relative;
}

.num-box {
  display: none;
}

body.num {
  .num-box {
    display: block;
    position: absolute;
    inset: -1px -1px auto auto;
    min-width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    font-size: 12px;
    padding: 0 2px;
    z-index: 9;
    color: var(--color-btn);
    background: var(--bg-btn);
    border: 1px solid var(--color-border);
    pointer-events: none;
  }
}

.card-img {
  aspect-ratio: var(--aspect-ratio);
  width: 100%;

  &.active {
    opacity: 0.3;
  }
}

body {
  &[data-size-idx="-2"] {
    .card-img-container {
      grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    }
  }

  &[data-size-idx="-1"] {
    .card-img-container {
      grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    }
  }

  &[data-size-idx="0"] {
    .card-img-container {
      grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
  }

  &[data-size-idx="1"] {
    .card-img-container {
      grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }
  }

  &[data-size-idx="2"] {
    .card-img-container {
      grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    }
  }
}

body.lock {
  .main-top-section {
    .tier-list {
      width: 100%;
    }

    .tier-label {
      pointer-events: none;
    }

    .tier-menu-btn-container {
      display: none;
    }
  }

  .book-card-img-container-outer,
  .void-card-img-container-outer {
    margin-right: 0;
  }

  .card-img {
    pointer-events: none;
  }
}

body.pin:not(.preview) {
  max-height: 100dvh;
  overflow-y: hidden;

  header {
    position: static;
  }

  main {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 41px);
    margin-top: 0;
    padding: 0;
  }

  .pin-container {
    display: flex;
    flex-direction: column;
  }

  .pin-top-container {
    max-height: calc(100% * 0.6);
    overflow-y: auto;
    flex-shrink: 0;
    padding-top: 8px;
  }

  .pin-bottom-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 4px;
  }
}

@media (width < 720px) {
  body {
    &[data-size-idx="-2"] {
      .card-img-container {
        grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
      }
    }

    &[data-size-idx="-1"] {
      .card-img-container {
        grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
      }
    }

    &[data-size-idx="0"] {
      .card-img-container {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
      }
    }

    &[data-size-idx="1"] {
      .card-img-container {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
      }
    }

    &[data-size-idx="2"] {
      .card-img-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
      }
    }
  }
}

.tier-item {
  &[data-color-idx="0"] {
    .tier-label-container {
      background: var(--bg-tier0);
    }
  }

  &[data-color-idx="1"] {
    .tier-label-container {
      background: var(--bg-tier1);
    }
  }

  &[data-color-idx="2"] {
    .tier-label-container {
      background: var(--bg-tier2);
    }
  }

  &[data-color-idx="3"] {
    .tier-label-container {
      background: var(--bg-tier3);
    }
  }

  &[data-color-idx="4"] {
    .tier-label-container {
      background: var(--bg-tier4);
    }
  }

  &[data-color-idx="5"] {
    .tier-label-container {
      background: var(--bg-tier5);
    }
  }

  &[data-color-idx="6"] {
    .tier-label-container {
      background: var(--bg-tier6);
    }
  }

  &[data-color-idx="7"] {
    .tier-label-container {
      background: var(--bg-tier7);
    }
  }

  &[data-color-idx="8"] {
    .tier-label-container {
      background: var(--bg-tier8);
    }
  }

  &[data-color-idx="9"] {
    .tier-label-container {
      background: var(--bg-tier9);
    }
  }

  &[data-color-idx="10"] {
    .tier-label-container {
      background: var(--bg-tier10);
    }
  }

  &[data-color-idx="11"] {
    .tier-label-container {
      background: var(--bg-tier11);
    }
  }

  &[data-color-idx="12"] {
    .tier-label-container {
      background: var(--bg-tier12);
    }
  }
}

.main-top-section,
.preview-section {
  .btn-container {
    display: flex;
    align-items: center;
    gap: 2px;
  }
}

.main-top-section {

  .undo-btn,
  .redo-btn {
    width: 32px;
  }
}

.preview-section {
  display: none;
}

body.preview {

  .main-top-section,
  .main-bottom-section {
    display: none;
  }

  .preview-section {
    display: block;
    padding-top: 16px;

    .preview-text {
      margin-top: 4px;
    }

    .canvas {
      display: block;
      max-width: 100%;
      margin-top: 4px;
    }
  }
}

.mask {
  position: fixed;
  inset: 0;
  background: #0009;
  z-index: 100;

  &.hidden {
    display: none;
  }
}

.drag-card-img {
  position: fixed;
  opacity: 0.5;
  pointer-events: none;
  z-index: 20;

  &.hidden {
    display: none;
  }
}

.modal {
  position: fixed;
  z-index: 110;
  padding: 12px 0;
  background: var(--bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 2px 3px #0007;

  &.hidden {
    display: none;
  }

  .color-radio-label-container {
    display: grid;
    grid-template-columns: repeat(7, 34px);
    grid-template-rows: repeat(2, 34px);
    grid-auto-flow: column;
    place-items: center;
    margin-bottom: -4px;
    padding: 4px 12px;
  }

  .color-radio-label {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;

    &:has(:checked) {
      width: 34px;
      height: 34px;
      filter: brightness(1.2);
    }

    &:nth-child(2n) {
      transform: translate(17px, -4px);
    }
  }

  .color-radio {
    display: none;
  }

  button {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 36px;
    font-size: 14px;
    color: var(--color);
    background: var(--bg);
    padding: 0 16px;

    &:disabled {
      color: var(--color-btn-disabled);
    }

    &:not(:disabled) {
      @media (hover: hover) {
        &:hover {
          filter: brightness(1.5);
        }
      }
    }

    .bi-stars,
    .bi-trash {
      font-size: 16px;
    }
  }
}

.modal {
  .color-radio-label {
    &:nth-child(1) {
      background: var(--bg-tier1);
    }

    &:nth-child(2) {
      background: var(--bg-tier2);
    }

    &:nth-child(3) {
      background: var(--bg-tier3);
    }

    &:nth-child(4) {
      background: var(--bg-tier4);
    }

    &:nth-child(5) {
      background: var(--bg-tier5);
    }

    &:nth-child(6) {
      background: var(--bg-tier6);
    }

    &:nth-child(7) {
      background: var(--bg-tier7);
    }

    &:nth-child(8) {
      background: var(--bg-tier8);
    }

    &:nth-child(9) {
      background: var(--bg-tier9);
    }

    &:nth-child(10) {
      background: var(--bg-tier10);
    }

    &:nth-child(11) {
      background: var(--bg-tier11);
    }

    &:nth-child(12) {
      background: var(--bg-tier12);
    }

    &:nth-child(13) {
      background: var(--bg-tier0);
    }
  }
}
