/* ==========================================================================
   Comments System (YouTube-like Threaded Comments & Drawer)
   ========================================================================== */

/* Detail Pages Post-Content Footer Section */
.zone-detail-footer {
  background: var(--color-sand);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 64px !important;
  margin-top: 48px;
}

.detail-footer-content {
  position: relative;
}

.detail-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.btn-detail-action {
  box-shadow: 0 2px 8px rgba(26, 60, 53, 0.05);
}

.btn-quick-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #ffffff;
  color: var(--color1);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: var(--font4);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-quick-share:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.btn-quick-share:active {
  transform: translateY(0);
}

.btn-quick-share.copied {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}

.article-comments-trigger-bar {
  margin: 32px 0 24px;
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Inline Comments Section (under detail content) */
.article-inline-comments {
  margin: 0 0 24px;
  padding: 28px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(26, 60, 53, 0.04);
}

.article-inline-comments .inline-comments-header h3 {
  font-family: var(--font1);
  font-size: 22px;
  color: var(--color1);
  margin: 0 0 18px;
}

.article-inline-comments .inline-comments-input-wrap {
  margin-bottom: 20px;
}

.article-inline-comments .comments-tree {
  margin-top: 16px;
}

.article-inline-comments .comment-item {
  animation: fadeInComment 0.3s ease;
}

@keyframes fadeInComment {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-comments-open {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color1);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: var(--font4);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-comments-like {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #ffffff;
  color: var(--color1);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: var(--font4);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-comments-like:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.btn-comments-like.liked {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.btn-comments-open:hover {
  background: #122a25;
  transform: translateY(-1px);
}

.comments-total-badge {
  font-weight: 700;
}

/* Comments Modal Backdrop */
.comments-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  justify-content: flex-end;
  animation: commentsFadeIn 0.25s ease;
  overscroll-behavior: contain;
  touch-action: none;
}

@keyframes commentsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Comments Drawer Panel */
.comments-drawer {
  background: #ffffff;
  width: 100%;
  max-width: 540px;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.2);
  transform: translateX(100%);
  animation: commentsSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

@keyframes commentsSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@media (max-width: 767px) {
  .comments-drawer {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    height: 90vh;
    height: 90dvh;
    margin-top: auto;
    animation: commentsSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  @keyframes commentsSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* Drawer Header */
.comments-drawer-header {
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: #fdfdfd;
  touch-action: none;
}

.comments-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comments-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--color1);
}

.comments-drawer-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comments-count-pill {
  font-size: 12.5px;
  color: var(--gray);
  font-weight: 500;
}

.comments-drawer-close {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.comments-drawer-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Drawer Body */
.comments-drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Input Section */
.comments-input-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}


.comments-input-logged {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comment-author-avatar,
.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color1);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.comment-avatar--admin {
  background: #b91c1c;
}

.comment-form,
.inline-reply-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--desc-font);
  font-size: 13.5px;
  line-height: 1.5;
  color: #1e293b;
  resize: vertical;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.comment-textarea:focus {
  outline: none;
  border-color: var(--color1);
  box-shadow: 0 0 0 3px rgba(26, 60, 53, 0.12);
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.comment-btn-cancel {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #475569;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--font4);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.comment-btn-cancel:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.comment-btn-submit {
  background: var(--color1);
  border: none;
  color: #ffffff;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: var(--font4);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.comment-btn-submit:hover {
  background: #122a25;
}

.comment-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Comments List & Tree */
.comments-list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comments-loading,
.comments-empty,
.comments-error {
  text-align: center;
  padding: 28px 16px;
  font-size: 13.5px;
  color: #64748b;
}

.comments-error {
  color: #dc2626;
}

.comments-tree {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Individual Comment Item (YouTube-like) */
.comment-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comment-item--deleted .comment-avatar {
  background: #e2e8f0;
  color: #94a3b8;
}

.comment-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-author-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.comment-role-icon {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  margin-right: 2px;
}

.comment-badge-admin {
  background: rgba(185, 28, 28, 0.1);
  color: #b91c1c;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.comment-time {
  font-size: 12px;
  color: #94a3b8;
}

.comment-content {
  font-size: 13.5px;
  line-height: 1.5;
  color: #334155;
  word-break: break-word;
  overflow-wrap: break-word;
}

.comment-deleted-text {
  color: #94a3b8;
  font-style: italic;
  font-size: 13px;
}

/* Actions Bar */
.comment-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 4px;
}

.comment-action-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  font-family: var(--font4);
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.comment-action-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.comment-action-like .like-num {
  font-size: 11.5px;
  font-weight: 600;
}

.comment-action-delete {
  color: #ef4444;
}

.comment-action-delete:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* Toggle Replies Button */
.comment-toggle-replies-btn {
  background: none;
  border: none;
  padding: 6px 0;
  color: var(--color1);
  font-family: var(--font4);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  align-self: flex-start;
}

.comment-toggle-replies-btn:hover {
  text-decoration: underline;
}

/* Nested Replies */
.comment-replies-wrapper {
  margin-top: 8px;
  min-width: 0;
}

.comment-replies-list {
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Depth flattening: Cap cumulative left shift to avoid rightward drift */
.comment-replies-list .comment-replies-list {
  padding-left: 8px;
  border-left: 1.5px solid #cbd5e1;
}

.comment-replies-list .comment-replies-list .comment-replies-list {
  padding-left: 4px;
  border-left: 1.5px solid #e2e8f0;
}

.comment-item--reply .comment-avatar {
  width: 28px;
  height: 28px;
  font-size: 11.5px;
}

.inline-reply-box {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-width: 0;
}

/* Comments Sort Controls */
.comments-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.inline-comments-controls {
  margin-top: 24px;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.comments-sort-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comments-sort-options {
  display: flex;
  align-items: center;
  gap: 6px;
}

.comments-sort-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #475569;
  font-family: var(--font4);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.comments-sort-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.comments-sort-btn.active {
  background: var(--color1);
  color: #ffffff;
}

.comments-input-guest {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 18px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.comments-input-guest p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #475569;
}

.btn-login-comment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  background: var(--color1);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-family: var(--font4);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.btn-login-comment:hover {
  background: #122a25;
  transform: translateY(-1px);
}

.btn-login-comment:active {
  transform: translateY(0);
}

.comment-action-edit {
  color: #0284c7;
}

.comment-action-edit:hover {
  background: #e0f2fe;
  color: #0369a1;
}

.inline-edit-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-width: 0;
}

/* Mobile Comments Optimizations (< 768px) */
@media screen and (max-width: 767px) {
  .comments-tree {
    gap: 12px;
  }

  .comment-item {
    gap: 8px;
  }

  .comment-replies-list {
    padding-left: 8px;
    border-left-width: 1.5px;
    gap: 10px;
  }

  .comment-replies-list .comment-replies-list {
    padding-left: 6px;
  }

  .comment-replies-list .comment-replies-list .comment-replies-list {
    padding-left: 2px;
    border-left-color: transparent;
  }

  .comment-actions {
    gap: 6px 8px;
    margin-top: 3px;
  }

  .comment-action-btn {
    padding: 3px 5px;
    font-size: 11px;
    gap: 4px;
  }

  .comment-action-btn .action-icon {
    font-size: 11px;
  }

  .inline-reply-box,
  .inline-edit-box {
    padding: 8px;
  }
}

/* Tactile Pressed Micro-Springs (Touch Feedback) */
@media (hover: none) and (pointer: coarse) {
  .news-card,
  .agenda-card,
  .btn,
  .pill-btn {
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .news-card:active,
  .agenda-card:active,
  .btn:active,
  .pill-btn:active {
    transform: scale(0.975);
    transition-duration: 0.1s;
  }
}

/* ==========================================================================
   Mobile Swipe-Friendly Horizontal Carousels (Snap Scrolling)
   Applies only to mobile screens (< 768px) on secondary sections
   ========================================================================== */
@media screen and (max-width: 767px) {
  #actualites .news-grid,
  #commune-loisirs .news-grid,
  #galeries .news-grid,
  .agenda-grid {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    gap: 16px !important;
    padding-top: 10px;
    padding-bottom: 28px;
    padding-left: var(--padding, 16px);
    padding-right: 28px !important; /* Visual cue: peek of the next card */
    margin-left: calc(-1 * var(--padding, 16px));
    margin-right: calc(-1 * var(--padding, 16px));
    margin-bottom: 8px;
    scroll-padding-left: var(--padding, 16px);
    scrollbar-width: none;
    touch-action: pan-x pan-y;
  }

  #actualites .news-grid::-webkit-scrollbar,
  #commune-loisirs .news-grid::-webkit-scrollbar,
  #galeries .news-grid::-webkit-scrollbar,
  .agenda-grid::-webkit-scrollbar {
    display: none;
  }

  #actualites .news-grid > *,
  #commune-loisirs .news-grid > *,
  #galeries .news-grid > *,
  .agenda-grid > * {
    flex: 0 0 82% !important;
    max-width: 82% !important;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
  }

  .agenda-grid .agenda-card {
    height: auto;
    min-height: 220px;
  }

  /* Carousel Pill Indicator Dots */
  .carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 12px auto 6px;
    padding: 4px 0;
  }

  .carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(26, 60, 53, 0.22);
    transition: all 0.25s ease;
    cursor: pointer;
    border: none;
    padding: 0;
  }

  .carousel-dot.active {
    width: 20px;
    background: var(--color1);
  }
}

@media screen and (min-width: 768px) {
  .carousel-dots {
    display: none !important;
  }
}

/* ==========================================================================
   Skeleton Loading Shimmers
   ========================================================================== */
@keyframes skeleton-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, #eef2f0 25%, #f7f9f8 50%, #eef2f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  border-radius: 6px;
}

.skeleton-comment {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 12px;
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-line.medium {
  width: 70%;
}

.skeleton-line.full {
  width: 100%;
}

