@use 'sass:map';
@use 'utils/base' as *;
@use 'legacy' as *;

:root {
  @each $key, $font-size in $font-sizes {
    --fs-#{$key}: #{rem(map.get($font-size, lg))};
  }
  @media screen and (max-width: $breakpoint-md) {
    @each $key, $font-size in $font-sizes {
      --fs-#{$key}: #{rem(map.get($font-size, sm))};
    }
  }
}

/* font */
.fs-1 {
  font-size: var(--fs-1);
}
.fs-2 {
  font-size: var(--fs-2);
}
.fs-3 {
  font-size: var(--fs-3);
}
.fs-4 {
  font-size: var(--fs-4);
}
.fs-5 {
  font-size: var(--fs-5);
}
.fs-6 {
  font-size: var(--fs-6);
}
.fs-7 {
  font-size: var(--fs-7);
}
.fs-8 {
  font-size: var(--fs-8);
}
.fs-9 {
  font-size: var(--fs-9);
}

/* popup */
.popup-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: $zindex-popover;
  background-color: rgba(33, 33, 33, 0.8);
  overflow-y: auto;
}

.popup-container {
  position: absolute;
  left: 50%;
  top: 10vh;
  padding: rem(10);
  background-color: #fff;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease-out;
  width: auto;
  border-radius: 16px;

  /* 뷰포트 넘침 방지 */
  max-width: min(500px, 90vw);
  // max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.popup-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 8px; /* 이미지 모서리 */

  /* 이미지 */
  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }

  /* 영상 16:9 비율 래퍼 */
  .popup-video-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;

    iframe,
    video {
      position: absolute;
      top: 0;
      left: 0;
      width: 100% !important;
      height: 100% !important;
      border: none;
    }
  }
}

.popup-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.625rem 0 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  align-content: center;
  justify-content: center;
  align-items: center;
  justify-items: center;
  flex-shrink: 0;

  .popup-today-close {
    color: #666;
    font-size: 18px;
    cursor: pointer;
    text-align: center;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    display: block;
    width: 100%;
    line-height: 28px;
  }

  .btn-popup-close {
    color: #666;
    width: 100%;
    font-size: 18px;
    cursor: pointer;
    text-align: center;
    background: none;
    border: none;
    box-shadow: none;
  }

  .popup-today-close:hover,
  .btn-popup-close:hover {
    text-decoration: underline;
  }
}

@media (max-width: rem($breakpoint-md)) {
  .popup-container {
    width: calc(100% - 32px);
    max-width: none;
    top: rem(16);
    // max-height: 90vh;
  }

  .popup-content img {
    width: 100%;
  }
}

/* 애니메이션 */
.pt-page-rotateFall {
  transform-origin: 0% 0%;
  animation: rotateFall 1s both ease-in;
}
.popup-close-fade {
  animation: popupFade 0.4s ease-out forwards;
}

.popup-close-blur {
  animation: popupBlur 0.4s ease-out forwards;
}

@keyframes popupFade {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes popupBlur {
  0% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    filter: blur(8px);
  }
}
@keyframes rotateFall {
  0% {
    transform: rotateZ(0deg);
    opacity: 1;
  }
  20% {
    transform: rotateZ(10deg);
    animation-timing-function: ease-out;
    opacity: 1;
  }
  40% {
    transform: rotateZ(17deg);
    opacity: 0.8;
  }
  60% {
    transform: rotateZ(16deg);
    opacity: 0.6;
  }
  100% {
    transform: translateY(100%) rotateZ(17deg);
    opacity: 0;
  }
}

/* board */
.board-section-container {
  padding: rem(100) 0;
}
.responsive-inner {
  position: relative;
  max-width: rem(1200);
  width: 100%;
  margin: 0 auto;
}
@media screen and (max-width: rem($breakpoint-lg)) {
  .board-section-container {
    padding: rem(80) 0;
  }
  .responsive-inner {
    width: 92.1875%;
  }
}
@media screen and (max-width: rem($breakpoint-md)) {
  .board-section-container {
    padding: rem(60) 0;
  }
}

/* pagination */
.pagination-items {
  @include flex-center;
  gap: rem(28);
  font-weight: 700;
  color: #bbb;
}
.pagination-item {
  padding: rem(16) rem(6);
  &.active {
    border-bottom: 2px solid $almost-black;
    color: $almost-black;
  }
}
@media screen and (max-width: rem($breakpoint-md)) {
  .pagination-items {
    gap: rem(18);
  }
  .pagination-item {
    padding: rem(10) rem(4);
    &.active {
      border-bottom: 1px solid $almost-black;
    }
  }
}

/* 뒤로 가기 */
.pagination-back-link {
  width: max-content;
  padding: rem(10) 0;
  margin: 0 auto;
  border-bottom: 1px solid $almost-black;
}
@media screen and (max-width: rem($breakpoint-md)) {
  .pagination-back-link {
    padding: rem(5) 0;
    font-size: rem(12);
  }
}
