/* ============================================================
   TawkirJournal — Post Detail Styles
   ============================================================ */

/* ——— Post Hero Header ——— */
.post-hero {
  width: 100%;
  padding: 4rem 0 3rem;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
}

.post-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hero-gradient, linear-gradient(135deg, #f97316 0%, #c2410c 100%));
  opacity: 1;
}

.post-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 30%, rgba(255,255,255,0.12) 0%, transparent 55%),
              radial-gradient(ellipse at 10% 80%, rgba(0,0,0,0.18) 0%, transparent 50%);
}

.post-hero-inner {
  position: relative;
  z-index: 2;
  max-width: 840px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-hero-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.post-hero-cat {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.95);
  border: 1px solid rgba(255,255,255,0.3);
  backdrop-filter: blur(4px);
  transition: background var(--duration-fast);
  text-decoration: none;
}

.post-hero-cat:hover {
  background: rgba(255,255,255,0.35);
  color: white;
}

.post-hero-title {
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  letter-spacing: -0.02em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.post-hero-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.post-hero-meta .meta-sep { opacity: 0.4; }

.post-hero-meta a {
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  text-decoration: none;
}

.post-hero-meta a:hover {
  color: white;
  text-decoration: underline;
}

/* ——— Post Layout ——— */
.post-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 3rem;
  align-items: start;
}

/* ——— Article ——— */
.post-article {
  min-width: 0;
}

/* ——— Post Body (CKEditor content) ——— */
.post-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text);
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 2rem 0 1rem;
  letter-spacing: -0.01em;
}

.post-body h2 { font-size: 1.6rem; }
.post-body h3 { font-size: 1.3rem; }
.post-body h4 { font-size: 1.1rem; }

.post-body p { margin: 0 0 1.25rem; }

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body a:hover { color: var(--accent-dark); }

.post-body ul,
.post-body ol {
  margin: 1rem 0 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.post-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-elevated);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-body pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 1.5rem 0;
}

.post-body code:not(pre code) {
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: var(--font-mono);
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.post-body th,
.post-body td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.875rem;
  text-align: left;
}

.post-body th {
  background: var(--bg-elevated);
  font-weight: 600;
}

/* ——— YouTube Video ——— */
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  margin: 2rem 0;
  box-shadow: var(--shadow-lg);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ——— Post Sidebar ——— */
.post-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + 1.5rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Table of Contents */
.toc-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toc-item a {
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all var(--duration-fast);
  line-height: 1.4;
}

.toc-item a:hover,
.toc-item a.active {
  background: var(--bg-elevated);
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-item.toc-h3 a { padding-left: 1.25rem; font-size: 0.78rem; }
.toc-item.toc-h4 a { padding-left: 2rem; font-size: 0.75rem; }

/* Post Share Widget */
.share-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.share-widget-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-surface);
  transition: all var(--duration-fast);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  width: 100%;
}

.share-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.share-btn.twitter:hover { background: #1da1f2; color: white; border-color: #1da1f2; }
.share-btn.linkedin:hover { background: #0a66c2; color: white; border-color: #0a66c2; }
.share-btn.copy:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ——— Related Posts ——— */
.related-posts {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

.related-posts-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.related-grid .post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--duration), box-shadow var(--duration);
  text-decoration: none;
}

.related-grid .post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

/* ——— Comments Section ——— */
.comments-section {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.comments-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.comments-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.comments-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  margin-left: 0.5rem;
}

.comment-form-area {
  margin-bottom: 2rem;
}

.comment-form-area textarea {
  min-height: 120px;
  resize: vertical;
}

.comment-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Comment Item — Chat-style layout */
.comment-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-body {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.comment-avatar {
  flex-shrink: 0;
}

.comment-avatar img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border);
  display: block;
}

.comment-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.comment-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.625rem 0.875rem;
  transition: border-color var(--duration-fast);
}

.comment-bubble:hover {
  border-color: var(--accent-glow);
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.comment-author-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.comment-dot {
  font-size: 0.7rem;
  color: var(--text-muted);
  user-select: none;
}

.comment-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

.comment-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.comment-text p {
  margin: 0;
}

.comment-text p + p {
  margin-top: 0.4rem;
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  padding-left: 0.125rem;
}

.comment-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--duration-fast);
  line-height: 1;
}

.comment-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.comment-action-btn.reply-btn,
.comment-action-btn.toggle-replies-btn {
  color: var(--accent);
}

.comment-action-btn.reply-btn:hover,
.comment-action-btn.toggle-replies-btn:hover {
  background: var(--accent-glow);
}

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

.comment-action-btn.delete-btn:hover {
  background: #fef2f2;
}

[data-theme="dark"] .comment-action-btn.delete-btn:hover {
  background: rgba(239,68,68,0.12);
}

/* Nested replies */
.comment-replies {
  margin-left: 2.25rem;
  margin-top: 0.25rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-item.reply .comment-bubble {
  background: var(--bg-surface);
}

/* Reply/Edit forms */
.reply-form,
.edit-form {
  margin-top: 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
}

.reply-form textarea,
.edit-form textarea {
  min-height: 90px;
}

/* Login prompt */
.login-to-comment {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.login-to-comment a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

/* Comment search */
.comment-search-wrap {
  position: relative;
  max-width: 240px;
}

.comment-search-wrap svg {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#comment-search {
  padding-left: 2rem;
  height: 36px;
  font-size: 0.85rem;
  border-radius: var(--radius-full);
}

/* Notification toast */
#comment-notification {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  max-width: 320px;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
}

#comment-notification.show {
  transform: translateY(0);
  opacity: 1;
}

#comment-notification.success { border-left: 4px solid #22c55e; }
#comment-notification.error { border-left: 4px solid #ef4444; }

/* ============================================================
   COMMENT FORM — Beautiful card style
   ============================================================ */
.comment-form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease);
}

.comment-form-card:hover {
  box-shadow: var(--shadow);
}

.comment-form-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.comment-form-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.comment-form-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.comment-form-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.comment-form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.comment-textarea-wrap textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.comment-textarea-wrap textarea::placeholder {
  color: var(--text-muted);
}

.comment-textarea-wrap textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.875rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.comment-form-char-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.comment-submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Author info inside comment item */
.author-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.author-info .username {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.author-info .comment-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   FLOATING TABLE OF CONTENTS
   ============================================================ */
.toc-float-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 16px var(--accent-glow), 0 8px 24px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.toc-float-btn.toc-btn-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toc-float-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow), 0 12px 28px rgba(0,0,0,0.2);
}

.toc-btn-label {
  display: inline;
}

.toc-btn-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.2);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.toc-float-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 90vw;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease);
  box-shadow: var(--shadow-xl);
}

.toc-float-panel.toc-panel-open {
  transform: translateX(0);
}

.toc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.toc-panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.toc-panel-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.toc-panel-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.toc-panel-progress {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

.toc-panel-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  width: 0%;
  transition: width 0.1s linear;
}

.toc-panel-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.toc-panel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toc-pi a {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.45rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: all var(--duration-fast);
  line-height: 1.45;
  text-decoration: none;
}

.toc-pi a:hover {
  background: var(--bg-elevated);
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-pi a.toc-pi-active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc-pi-h3 a {
  padding-left: 1.25rem;
  font-size: 0.78rem;
}

.toc-pi-h4 a {
  padding-left: 2rem;
  font-size: 0.75rem;
}

.toc-pi-num {
  font-family: var(--font-mono);
  font-size: 0.75em;
  opacity: 0.6;
  flex-shrink: 0;
}

.toc-pi-text {
  word-break: break-word;
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.toc-backdrop.toc-backdrop-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ——— Responsive ——— */
@media (max-width: 1024px) {
  .post-layout {
    grid-template-columns: 1fr;
    padding: 2rem 1.5rem;
  }
  .post-sidebar { position: static; }
}

@media (max-width: 768px) {
  .post-hero { padding: 2.5rem 0 2rem; }
  .post-hero-title { font-size: 1.75rem; }
  .post-body { font-size: 1rem; }

  .comment-replies { margin-left: 0.75rem; padding-left: 0.75rem; }

  .related-grid { grid-template-columns: 1fr 1fr; }

  .toc-float-btn {
    bottom: 1rem;
    right: 1rem;
    padding: 0.65rem 1rem;
  }
  .toc-btn-label {
    display: none;
  }
  .toc-float-panel {
    width: 280px;
  }
}

@media (max-width: 480px) {
  .related-grid { grid-template-columns: 1fr; }
  .comments-section { padding: 0 1rem 3rem; }
}
