/* ===== Post list (board) ===== */
.post-list { padding: 0; }
.post-item { display: flex; flex-direction: column; padding: 15px 15px; border-bottom: 1px solid var(--border-gray); position: relative; transition: background-color: 0.15s ease-in-out; cursor: pointer; }
.post-item:hover { background-color: var(--purple-hover); }
.post-item.popular::before { content: ""; position: absolute; left: 0; top: 0; width: 4px; height: 100%; background-color: var(--main-purple); }
.post-title {
  font-size: calc(1rem * var(--content-font-scale, 1));
  margin-bottom: 8px;
  cursor: pointer;
}
.post-title-content { display: flex; align-items: center; min-width: 0; }
.post-title-content > .board-live-badge,
.post-title-content > .media-icon { flex: 0 0 auto; }
.post-title .title-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-title .media-icon { margin-right: 6px; color: var(--text-gray); font-size: 0.95em; vertical-align: middle; }
.post-item.is-read .post-title { color: var(--text-read); font-weight: 500; }
.post-title .comment-count { color: var(--main-purple); font-weight: bold; flex: 0 0 auto; margin-left: 4px; }
.post-meta { display: flex; justify-content: space-between; font-size: calc(0.8rem * var(--content-font-scale, 1)); color: var(--text-gray); }
.post-item--live .post-title { margin-bottom: 0; }

.post-item.post-item--live {
  padding-top: 8px;
  padding-bottom: 8px;
}
.post-stats { display: inline-flex; align-items: center; }
.post-stats span+span { position: relative; padding-left: 8px; margin-left: 8px; }
.post-stats span+span::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 1px; height: 12px; background: var(--border-gray); }
.post-stats .time { display: inline-flex; align-items: center; }
.post-stats .time i { margin-right: 4px; font-size: 0.95em; }
.page-divider { text-align: left; color: var(--text-gray); font-size: calc(0.8rem * var(--content-font-scale, 1)); padding: 5px 15px; border-top: 1px solid var(--border-gray); border-bottom: 1px solid var(--border-gray); }
.post-item+.page-divider { border-top: none; }
.end-message { text-align: center; padding: 20px 15px; font-size: calc(0.9rem * var(--content-font-scale, 1)); color: var(--text-gray); }

/* Newly created post highlight */
.post-item.is-highlight {
  background: rgba(133, 114, 238, 0.12);
  animation: postFlash 1.6s ease-in-out 1;
}
@keyframes postFlash {
  0% { background: rgba(133,114,238,0.18); }
  60% { background: rgba(133,114,238,0.06); }
  100% { background: rgba(133,114,238,0.00); }
}

/* Disable hover effects on devices that don't support hover (mobile/tablet touch) */
@media (hover: none), (pointer: coarse) {
  .post-item:hover { background-color: transparent; }
}

/* Post Editor styles */
body.editing-post {
  overflow: hidden;
}
.editing-post #global-footer {
  display: none !important;
}
.post-editor {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  overflow: hidden;
}
.post-editor-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--header-height, 60px);
  padding-bottom: var(--footer-height, 56px);
  overflow: hidden;
}
.post-editor-form-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 768px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}
.post-editor-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.post-editor textarea {
  flex: 1;
  min-height: 200px;
  resize: none;
}

/* Post Editor: bottom bar anon password input */
.post-editor .post-editor-fixed-bar .anon-password-row input {
  color: var(--text-primary);
  background: var(--background-white);
  border: 1px solid var(--border-gray);
}
.post-editor .post-editor-fixed-bar .anon-password-row input::placeholder {
  color: var(--text-gray);
}

/* Post Editor: attachment buttons */
.post-editor .attach-buttons { display: inline-flex; align-items: center; gap: 8px; }
.post-editor .btn-icon:hover { background: var(--purple-hover, rgba(133,114,238,0.08)); }
.post-editor .btn-icon:focus { outline: 2px solid var(--main-purple, #8572EE); outline-offset: 1px; }

/* Post Editor: toolbar between title and content */
.post-editor .editor-attach-toolbar { display: flex; align-items: center; gap: 8px; padding: 0; margin: 0 0 0; }
.post-editor .btn-attach { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--border-gray); background: var(--background-white); color: var(--text-primary); border-radius: 6px; cursor: pointer; }
.post-editor .btn-attach:hover { background: var(--purple-hover, rgba(133,114,238,0.08)); }
.post-editor .btn-attach:focus { outline: 2px solid var(--main-purple, #8572EE); outline-offset: 1px; }
.post-editor .btn-attach i { font-size: 14px; }

/* Attachments grid (shared) */
.attachments-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
/* 상세 보기(PostModal)에서는 원본 비율을 유지하고 한 줄에 하나씩 */
.post-modal .attachments-grid { grid-template-columns: 1fr; }
.attachment-item { position: relative; overflow: hidden; border: none; border-radius: 6px; background: var(--background-white); }
/* 기본은 자연 비율: 높이는 콘텐츠가 결정하도록 */
.attachment-item img, .attachment-item video { width: auto; max-width: 100%; height: auto; display: block; }
/* 에디터 전용: 1:1 그리드 유지 */
.post-editor .attachments-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.post-editor .attachment-item { aspect-ratio: 1 / 1; }
.post-editor .attachment-item img, .post-editor .attachment-item video {
  position: absolute; inset:0; width: 100%; height: 100%; object-fit: cover; z-index: 1;
}

/* 모바일 환경에서는 첨부 아이템 크기를 조정 */
@media (max-width: 480px) {
  .post-editor .attachments-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
/* 상세 보기 스켈레톤 */
/* 상세 보기에서 작은 미디어는 가운데 정렬, 큰 미디어는 컨테이너 너비까지만 확장 */
.attachments-section .attachment-item { display: grid; justify-items: center; align-items: start; }
/* 로더/스켈레톤과 미디어를 같은 그리드 셀에 겹치도록 배치하여 좌우 밀림 방지 */
.attachments-section .attachment-item > .media-loader,
.attachments-section .attachment-item > .skeleton,
.attachments-section .attachment-item > img,
.attachments-section .attachment-item > video { grid-area: 1 / 1; }
/* 로더 또는 스켈레톤이 미디어 위에 오도록 보장 */
.attachments-section .attachment-item .media-loader,
.attachments-section .attachment-item .skeleton { z-index: 2; }
/* 미디어는 로딩 완료 전까지 투명 처리, 완료 시 페이드인 */
.attachments-section .attachment-item img,
.attachments-section .attachment-item video { opacity: 0; transition: opacity 0.18s ease-in-out; }
.attachments-section .attachment-item img.is-ready,
.attachments-section .attachment-item video.is-ready { opacity: 1; }
/* 첨부가 있을 때만 상단 여백 (데스크탑 기본 20px) */
.attachments-section .attachments-grid:not(:empty) { margin-top: 20px; }
/* 모바일에서는 10px로 축소 */
@media (max-width: 480px) {
  .attachments-section .attachments-grid:not(:empty) { margin-top: 10px; }
}
/* 상세 보기: 미디어는 모달 너비의 95%까지만 표시(작은 이미지는 원본 크기 유지) */
.attachments-section .attachment-item img,
.attachments-section .attachment-item video { max-width: 95%; }
.attachments-section .attachment-item video[data-gif-like="0"] { width: 95%; }
.attachments-section .attachment-item.video.portrait-video .media-loader {
  width: 70%;
}
.attachments-section .attachment-item.video.portrait-video video[data-gif-like="0"] {
  width: 70%;
  max-width: 70%;
}
/* 스켈레톤도 95%로 맞춤 */
.attachments-section .attachment-item .skeleton { width: 95%; }
/* 로딩 스피너 컨테이너도 95%로 맞춤 및 비율 확보 */
.attachments-section .attachment-item .media-loader { position: relative; width: 95%; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: var(--ar, 16 / 9); }
 .attachments-section .attachment-item .media-loader::before { content: ""; display: none; }
 .attachments-section .attachment-item .media-loader .spinner { width: 28px; height: 28px; border: 3px solid var(--border-gray); border-top-color: var(--main-purple); border-radius: 50%; animation: spin 1s linear infinite; pointer-events: none; }
 .attachments-section .attachment-item .media-loader .loader-text { margin-top: 8px; font-size: 14px; color: var(--text-gray, #6b7280); text-align: center; }
/* 비디오 로딩 중에는 video 태그 숨기기 */
.attachments-section .attachment-item.video video.loading { display: none; }
.attachment-item .skeleton { position: relative; width: 100%; padding-top: 56%; background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.12), rgba(0,0,0,0.06)); background-size: 200% 100%; animation: skeletonMove 1.2s ease-in-out infinite; }
@keyframes skeletonMove { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
/* Skeleton center text */
.attachments-section .attachment-item .skeleton .sk-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .06em;
  color: var(--text-gray, #6b7280);
  text-shadow: 0 1px 2px rgba(0,0,0,0.06);
  pointer-events: none;
}
.post-editor .editor-attachments-view { margin-bottom: 8px; }
/* 에디터: 첨부가 있을 때만 그리드 상단 간격 제공 */
.post-editor .editor-attachments-view > .attachments-grid { margin-top: 0; }
.post-editor .editor-attachments-view > .attachments-grid:has(> .attachment-item) { margin-top: 8px; }
.attachment-item .att-delete { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: none; border-radius: 12px; background: rgba(17,17,17,0.7); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; pointer-events: auto; }
.attachment-item.dragging { opacity: 0.6; }

/* Post Editor: attachment status styles */
.attachment-item { 
  position: relative; 
  transition: all 0.3s ease;
}

/* Pending status - dashed border for files waiting to upload */
.attachment-item.pending {
  border: 2px dashed var(--border-gray) !important;
  opacity: 0.85;
}

.attachment-item.pending::before {
  content: "대기 중";
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  z-index: 5;
}

/* Uploading status - animated border */
.attachment-item.uploading {
  border: 2px solid var(--main-purple) !important;
  animation: pulse-border 1.5s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Upload progress bar */
.attachment-item .upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.2);
  z-index: 10;
  overflow: hidden;
}

.attachment-item .progress-bar {
  height: 100%;
  background: var(--main-purple);
  transition: width 200ms ease-out;
  box-shadow: 0 0 10px rgba(133, 114, 238, 0.5);
}

/* Uploaded status - success state */
.attachment-item.uploaded {
  border: 2px solid #10b981 !important;
}

.attachment-item.uploaded::after {
  content: "✓";
  position: absolute;
  top: 8px;
  left: 8px;
  background: #10b981;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  animation: checkmark-pop 0.3s ease-out;
  z-index: 5;
}

@keyframes checkmark-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Error status */
.attachment-item.error {
  border: 2px solid #ef4444 !important;
  background: rgba(239, 68, 68, 0.05);
}

.attachment-item .error-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ef4444;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

/* Drag and drop styles */
.attachment-item.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  cursor: move;
}

.attachment-item.drag-over {
  border-color: var(--main-purple) !important;
  background: var(--purple-hover);
  transform: scale(1.02);
}

/* Delete button enhanced */
.attachment-item .att-delete {
  opacity: 1; /* 항상 보이도록 */
  transition: opacity 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  touch-action: manipulation;
  z-index: 3;
}

.attachment-item:hover .att-delete {
  opacity: 1;
}

/* 비디오 항목은 항상 삭제 버튼을 보이게 하여 컨트롤러와의 충돌을 회피 */
.attachment-item.video .att-delete {
  opacity: 1;
}

.attachment-item.pending .att-delete,
.attachment-item.uploading .att-delete {
  background: rgba(17, 17, 17, 0.9);
}

/* Post Editor: upload progress tray (legacy support) */
.post-editor .upload-queue { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.post-editor .upload-item { border: 1px dashed var(--border-gray); border-radius: 8px; padding: 8px 10px; background: var(--background-white); }
.post-editor .upload-item .progress-track { background: var(--border-gray); height: 6px; border-radius: 4px; overflow: hidden; }
.post-editor .upload-item .progress-fill { background: var(--main-purple); height: 100%; width: 0%; transition: width 120ms ease-out; }

/* ===== Notice Post ===== */
.post-item--notice {
  background-color: var(--notice-bg);
}

.post-item--notice .post-meta {
  display: none;
}

.post-item--notice .post-title {
  margin-bottom: 0;
}

.post-item--notice.is-read .post-title {
  color: var(--text-primary); /* 공지사항은 읽어도 색상이 변하지 않도록 */
  font-weight: 500;
}

.post-item--notice .post-title::before {
  content: '공지';
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--main-purple);
  border: 1px solid var(--main-purple);
  border-radius: 4px;
  vertical-align: middle;
}
