/* =========================================================
   부드러운 화면과 움직임 (style2.css 다음에 불러온다)
   - 이 파일을 빼면 원래의 차분한 디자인으로 돌아간다.
   - 컴퓨터에서 "애니메이션 줄이기" 를 켠 사람에게는 움직임을 끈다. (맨 아래)
   ========================================================= */

/* ---------- 1. 움직임 기본값 ---------- */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);        /* 빠르게 시작해서 부드럽게 멈춤 */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* 살짝 튕기는 느낌 */
  --fast: 160ms;
  --normal: 280ms;

  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 16px 40px rgba(15, 23, 42, 0.1);
  --gradient: linear-gradient(135deg, #4f6bff 0%, #7a5cff 55%, #b15cff 100%);

  --font-base: "Pretendard Variable", "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", -apple-system, "Segoe UI", sans-serif;
}

body {
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* 페이지를 옮길 때 화면이 부드럽게 바뀐다. (지원하는 브라우저에서만, 예: 최신 크롬) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-out 120ms var(--ease-out) both;
}

::view-transition-new(root) {
  animation: page-in 200ms var(--ease-out) both;
}

.site-header {
  view-transition-name: site-header; /* 헤더는 그대로 두고 내용만 바뀌게 */
}

/* ---------- 2. 유리처럼 비치는 헤더 ---------- */
.site-header {
  background-color: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom-color: transparent;
  transition: box-shadow var(--normal) var(--ease-out), border-color var(--normal);
}

.site-header.is-scrolled {
  border-bottom-color: rgba(15, 23, 42, 0.06);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

.main-nav a {
  position: relative;
  transition: color var(--fast);
}

/* 메뉴 밑줄이 가운데서 양옆으로 늘어난다 */
.main-nav a::after {
  content: "";
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: -6px;
  height: 2px;
  background: var(--gradient);
  border-radius: 2px;
  transition: left var(--normal) var(--ease-out), right var(--normal) var(--ease-out);
}

.main-nav a:hover::after,
.main-nav a[aria-current="page"]::after {
  left: 0;
  right: 0;
}

/* ---------- 3. 버튼: 올리면 살짝 뜨고, 누르면 살짝 눌림 ---------- */
.btn,
.like-button,
.sort-tabs a,
.pagination a,
.file-preview-remove,
.comment-action {
  transition:
    transform var(--fast) var(--ease-out),
    box-shadow var(--normal) var(--ease-out),
    background-color var(--fast),
    border-color var(--fast),
    color var(--fast);
}

.btn {
  border-radius: 12px;
}

.btn-primary {
  background: var(--gradient);
  background-size: 140% 140%;
  background-position: 0% 50%;
  box-shadow: 0 6px 16px rgba(95, 92, 255, 0.28);
  transition:
    transform var(--fast) var(--ease-out),
    box-shadow var(--normal) var(--ease-out),
    background-position var(--normal) var(--ease-out);
}

.btn-primary:hover {
  background: var(--gradient);
  background-size: 140% 140%;
  background-position: 100% 50%;
  box-shadow: 0 10px 24px rgba(95, 92, 255, 0.36);
}

.btn:hover:not(:disabled),
.pagination a[href]:hover {
  transform: translateY(-1px);
}

.btn:active:not(:disabled),
.like-button:active,
.pagination a[href]:active,
.sort-tabs a:active {
  transform: scale(0.96);
  transition-duration: 80ms;
}

.btn-outline,
.btn-ghost {
  box-shadow: none;
}

.btn-outline:hover {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.btn-danger {
  box-shadow: 0 6px 16px rgba(217, 45, 32, 0.22);
}

.pagination a {
  border-radius: 10px;
}

.pagination a.is-current {
  background: var(--gradient);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(95, 92, 255, 0.3);
}

/* 모바일 메뉴 버튼: 세 줄이 X 로 바뀜 */
.menu-toggle span {
  transition: transform var(--normal) var(--ease-out), opacity var(--fast);
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- 4. 카드: 둥글고 부드러운 그림자, 올리면 살짝 뜸 ---------- */
.card,
.board-list,
.post,
.comments,
.post-nav,
.lab-card,
.auth-card,
.mypage-card {
  border-color: rgba(15, 23, 42, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  transition: transform var(--normal) var(--ease-out), box-shadow var(--normal) var(--ease-out);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.placeholder {
  border-radius: 14px;
  background: linear-gradient(135deg, #eef1f6, #e5e9f2);
}

a.board-row {
  transition: background-color var(--fast), transform var(--normal) var(--ease-out);
}

a.board-row:hover {
  background-color: #f6f8ff;
}

a.board-row:active {
  transform: scale(0.995);
}

.sort-tabs,
.segmented {
  border-radius: 12px;
}

/* ---------- 5. 입력칸: 포커스하면 은은한 빛 ---------- */
.form-group input,
.form-group textarea,
.comment-form textarea,
.board-search select,
.board-search input {
  border-radius: 12px;
  transition: border-color var(--fast), box-shadow var(--normal) var(--ease-out), background-color var(--fast);
}

.form-group input:focus,
.form-group textarea:focus,
.comment-form textarea:focus,
.board-search input:focus,
.board-search select:focus {
  border-color: #7a5cff;
  box-shadow: 0 0 0 4px rgba(122, 92, 255, 0.14);
}

.form-message {
  border-radius: 12px;
  animation: pop-in var(--normal) var(--ease-spring) backwards;
}

/* ---------- 6. 등장 애니메이션 ---------- */
/* 페이지가 열리면 본문이 아래에서 살짝 올라온다 */
/* (backwards: 애니메이션이 끝나면 원래 스타일로 돌아가서 hover 효과와 겹치지 않음) */
main {
  animation: fade-up 300ms var(--ease-out) backwards;
}

/* 목록 줄, 댓글, 카드가 하나씩 차례로 올라온다 (motion.js 가 --i 순서를 붙임) */
.animate-in {
  animation: fade-up 300ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 20ms);
}

/* 화면을 내리면 나타나는 요소 (홈 화면 구역들) */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* 모바일 메뉴가 위에서 부드럽게 펼쳐진다 */
.site-menu.is-open {
  animation: menu-down var(--normal) var(--ease-out) both;
}

/* ---------- 7. 로딩 중 반짝이는 회색 상자 (스켈레톤) ---------- */
.skeleton-row {
  display: grid;
  grid-template-columns: 64px 1fr 110px 96px 76px 76px;
  gap: 12px;
  padding: 18px 20px;
  border-top: 1px solid var(--color-border);
}

.skeleton-row span,
.skeleton-line {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #eef1f5 0%, #f7f8fa 50%, #eef1f5 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-row span:nth-child(2) {
  width: 70%;
}

/* ---------- 8. 좋아요: 하트가 톡 튐 ---------- */
.like-button {
  position: relative;
}

.like-button.is-popping .like-heart {
  animation: heart-pop 480ms var(--ease-spring);
}

.like-button.is-liked {
  box-shadow: 0 6px 18px rgba(240, 68, 56, 0.2);
}

/* 사진을 두 번 탭하면 가운데에 큰 하트 */
.attachment {
  position: relative;
}

.attachment img {
  cursor: zoom-in;
  touch-action: manipulation; /* 휴대폰에서 두 번 탭할 때 화면 확대 대신 좋아요가 되게 */
  -webkit-user-select: none;
  user-select: none;
  transition: transform var(--normal) var(--ease-out);
}

.double-tap-heart {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 96px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  animation: big-heart 900ms var(--ease-out) both;
}

/* ---------- 9. 사진 크게 보기 (라이트박스) ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: rgba(10, 12, 20, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
  animation: fade-in var(--normal) var(--ease-out) both;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  animation: zoom-in 360ms var(--ease-spring) both;
}

.lightbox.is-closing {
  animation: fade-out 200ms var(--ease-out) both;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 26px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* ---------- 10. 토스트 알림 (아래에서 쓱 올라왔다 사라짐) ---------- */
.toast-area {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background-color: rgba(23, 26, 33, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  animation: toast-in 380ms var(--ease-spring) both;
}

.toast.is-error {
  background-color: rgba(180, 35, 24, 0.94);
}

.toast.is-leaving {
  animation: toast-out 260ms var(--ease-out) both;
}

/* ---------- 11. 움직임 정의 ---------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes zoom-in {
  from { opacity: 0; transform: scale(0.88); }
  to { opacity: 1; transform: none; }
}

@keyframes menu-down {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.45); }
  65% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes big-heart {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  35% { transform: translate(-50%, -50%) scale(0.95); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes page-out {
  to { opacity: 0; transform: translateY(-6px); }
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* ---------- 12. 모바일 ---------- */
@media (max-width: 768px) {
  .skeleton-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 16px;
  }

  .skeleton-row span:nth-child(n + 3) {
    display: none;
  }

  .toast-area {
    bottom: 20px;
  }
}

/* ---------- 13. "애니메이션 줄이기" 를 켠 사람에게는 움직임을 끈다 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
