/* ============================================================
   DAFTER MAGED — Writings Page (المقالات والكتابات)
   ============================================================ */

/* ── Status Pipeline ── */
.writings-pipeline {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: var(--space-5);
  padding-bottom: 2px;
}
.writings-pipeline::-webkit-scrollbar { display: none; }

.pipeline-step {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer; flex-shrink: 0; min-width: 90px;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.pipeline-step:hover { border-color: var(--color-primary); }
.pipeline-step.active {
  background: var(--color-primary-muted);
  border-color: var(--color-primary);
}
.pipeline-step-icon { font-size: 1.3rem; }
.pipeline-step-label {
  font-size: var(--text-xs); font-weight: var(--font-weight-semi);
  color: var(--color-text-muted); white-space: nowrap;
}
.pipeline-step.active .pipeline-step-label { color: var(--color-primary); }
.pipeline-step-count {
  font-size: var(--text-lg); font-weight: var(--font-weight-black);
  color: var(--color-text); line-height: 1;
}

/* ── Writings List ── */
.writings-list {
  display: flex; flex-direction: column; gap: var(--space-4);
}

/* ── Writing Card ── */
.writing-card {
  background: var(--card-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: all var(--transition-base);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.writing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--color-primary); }

.writing-card-body { padding: var(--space-4); }

.writing-header {
  display: flex; align-items: flex-start;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.writing-type-badge {
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 10px; font-weight: var(--font-weight-bold);
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; flex-shrink: 0;
}
.type-article  { background: var(--blue-100);           color: var(--blue-700); }
.type-essay    { background: rgba(139,92,246,.12);      color: #7c3aed; }
.type-analysis { background: rgba(245,158,11,.12);      color: #d97706; }
.type-review   { background: rgba(34,197,94,.12);       color: #15803d; }
.type-story    { background: rgba(244,63,94,.10);       color: #e11d48; }
.type-other    { background: var(--color-surface-2);    color: var(--color-text-muted); }
[data-theme="dark"] .type-article  { background:rgba(59,130,246,.15); color:var(--blue-300); }
[data-theme="dark"] .type-essay    { background:rgba(139,92,246,.15); color:#a78bfa; }
[data-theme="dark"] .type-analysis { background:rgba(245,158,11,.12); color:#fbbf24; }
[data-theme="dark"] .type-review   { background:rgba(34,197,94,.12);  color:#4ade80; }
[data-theme="dark"] .type-story    { background:rgba(244,63,94,.12);  color:#fb7185; }

.writing-title {
  flex: 1; font-size: var(--text-base); font-weight: var(--font-weight-bold);
  color: var(--color-text); line-height: 1.3;
}
.writing-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 6px;
}

.writing-excerpt {
  font-size: var(--text-sm); color: var(--color-text-muted);
  line-height: var(--leading-normal);
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: var(--space-3);
}

/* Tags */
.writing-tags {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.writing-tag {
  padding: 2px var(--space-2);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  font-size: 10px; color: var(--color-text-muted);
  font-weight: var(--font-weight-semi);
}

/* Word count + date */
.writing-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-light);
}
.writing-meta {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-xs); color: var(--color-text-subtle);
}
.writing-meta-item { display: flex; align-items: center; gap: 4px; }
.writing-actions { display: flex; gap: var(--space-1); }
.writing-action-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; background: none;
  color: var(--color-text-subtle); transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.writing-action-btn:hover        { background: var(--color-surface-2); color: var(--color-text); }
.writing-action-btn.delete:hover { background: rgba(239,68,68,.1); color: var(--danger); }

/* ── Writing Editor Modal ── */
.writing-editor-layout {
  display: flex; flex-direction: column; gap: var(--space-4);
}
.writing-editor-title {
  width: 100%; font-size: var(--text-xl);
  font-weight: var(--font-weight-black);
  background: none; border: none; color: var(--color-text);
  font-family: var(--font-family); padding: 0; line-height: 1.3;
}
.writing-editor-title::placeholder { color: var(--color-text-subtle); }
.writing-editor-title:focus { outline: none; }

.writing-editor-meta {
  display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}
.writing-editor-meta select,
.writing-editor-meta input[type="text"] {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  background: var(--color-surface-2); color: var(--color-text);
  font-size: var(--text-xs); font-family: var(--font-family);
  -webkit-appearance: none;
}

.writing-editor-content {
  width: 100%; min-height: 300px; max-height: 55vh;
  resize: vertical; background: none; border: none;
  color: var(--color-text); font-family: var(--font-family);
  font-size: var(--text-base); line-height: var(--leading-loose);
  padding: 0;
}
.writing-editor-content::placeholder { color: var(--color-text-subtle); }
.writing-editor-content:focus { outline: none; }

.writing-editor-toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border-light);
  flex-wrap: wrap;
}
.word-count-display {
  font-size: var(--text-xs); color: var(--color-text-subtle);
  font-weight: var(--font-weight-semi);
}

/* Status stepper in editor */
.status-stepper {
  display: flex; gap: var(--space-2); align-items: center;
}
.status-step-btn {
  display: flex; align-items: center; gap: 4px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full); font-size: 10px;
  font-weight: var(--font-weight-semi); cursor: pointer;
  border: 1.5px solid var(--color-border); background: none;
  font-family: var(--font-family); transition: all var(--transition-fast);
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.status-step-btn.active { color: white; border-color: transparent; }

/* Empty */
.writings-empty {
  padding: var(--space-12) var(--space-6);
  display: flex; flex-direction: column;
  align-items: center; gap: var(--space-3); text-align: center;
}

@media (min-width: 768px) {
  .writings-list { display: grid; grid-template-columns: repeat(2, 1fr); }
  .writing-editor-content { min-height: 400px; }
}
@media (min-width: 1100px) {
  .writings-list { grid-template-columns: repeat(3, 1fr); }
}
