/* =============================================
   Articles — Editor & Reading View
   ============================================= */

/* ---- Shared page wrappers ---- */
.editor-page,
.article-read-page {
    padding: 0;
    max-width: none;
    width: 100%;
}

/* =============================================
   EDITOR
   ============================================= */

/* Top bar — sticky below the site header */
.editor-topbar {
    position: sticky;
    top: 56px; /* site header height */
    height: 52px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 99;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.editor-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.editor-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.editor-back:hover { background: var(--border-light); color: var(--text); }

.editor-breadcrumb {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.editor-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.editor-status-badge.draft {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}
.editor-status-badge.published {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.editor-topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.editor-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.save-spinner {
    animation: spin 1s linear infinite;
    opacity: 0.6;
}

.editor-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}


.editor-publish-btn {
    padding: 7px 20px;
    font-size: 13px;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}
.editor-publish-btn:hover { background: var(--primary-dark); }
.editor-publish-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.editor-view-btn {
    padding: 7px 20px;
    font-size: 13px;
    font-weight: 600;
}

.editor-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-light);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.editor-delete-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Editor workspace */
.editor-workspace {
    min-height: calc(100vh - 56px - 52px);
}

.editor-write-panel,
.editor-preview-panel {
    width: 100%;
    min-height: inherit;
}

.editor-inner {
    max-width: 840px;
    margin: 0 auto;
    padding: 48px 24px 96px;
}

/* Title input */
.editor-title-input {
    display: block;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Quicksand', -apple-system, sans-serif;
    font-size: 38px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    background: transparent;
    padding: 0;
    margin-bottom: 8px;
    overflow: hidden;
}
.editor-title-input::placeholder { color: var(--border); }

/* Formatting toolbar */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    margin-bottom: 8px;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    position: sticky;
    top: 108px; /* 56px site header + 52px editor topbar */
    z-index: 10;
    background: var(--bg);
}

.etb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-family: inherit;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.etb-btn:hover { background: var(--border-light); color: var(--text); }
.etb-bold { font-weight: 700; }
.etb-italic { font-style: italic; }

.etb-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

/* WYSIWYG contenteditable */
.editor-wysiwyg {
    min-height: 300px;
    outline: none;
    cursor: text;
}

.editor-wysiwyg:empty::before {
    content: 'Tell your story…';
    color: var(--text-light);
    pointer-events: none;
    display: block;
    font-size: 18px;
    font-weight: 400;
}

/* Active state for the </> raw toggle */
.etb-raw-toggle.active {
    background: var(--border-light);
    color: var(--text);
    font-weight: 600;
}

/* Content textarea */
.editor-content-input {
    display: block;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Quicksand', -apple-system, sans-serif;
    font-size: 18px;
    line-height: 1.8;
    color: var(--text);
    background: transparent;
    padding: 0;
    min-height: 300px;
    overflow: hidden;
}
.editor-content-input::placeholder { color: var(--text-light); }

/* =============================================
   IMAGE DIALOG
   ============================================= */

.editor-image-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.editor-image-dialog {
    background: var(--bg-card);
    border-radius: 10px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.editor-image-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}
.editor-image-dialog-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
}
.dialog-close:hover { background: var(--border-light); }

.editor-image-dialog-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.image-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    color: var(--text-muted);
}
.image-upload-zone:hover,
.image-upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.04);
    color: var(--text);
}
.image-upload-zone svg { margin-bottom: 8px; opacity: 0.5; }
.image-upload-zone p { margin: 0 0 4px 0; font-size: 14px; }
.upload-hint { font-size: 12px; color: var(--text-light); }

.image-upload-progress {
    padding: 16px;
    background: var(--border-light);
    border-radius: var(--radius);
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
}
.upload-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 8px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 60%;
    animation: progressPulse 1.5s ease-in-out infinite;
}
@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.image-url-section label,
.image-alt-section label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.optional { color: var(--text-muted); font-weight: 400; }

.editor-image-dialog-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =============================================
   ARTICLE READING VIEW
   ============================================= */

.article-reading-view {
    max-width: 840px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

.article-read-page {
    padding-top: 0;
}

.article-reading-header {
    margin-bottom: 40px;
}

.article-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-muted);
    transition: color 0.15s;
}
.article-back-link:hover { color: var(--text); }

.article-reading-title {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.18;
    margin: 0 0 28px 0;
    color: var(--text);
    letter-spacing: -0.5px;
}

@media (max-width: 600px) {
    .article-reading-title {
        font-size: 28px;
    }
}

/* Sub-header: board links + tags, sits between title and byline */
.article-sub-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: -18px;
    margin-bottom: 24px;
}

/* Board links */
.article-board-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
}

/* Tag links */
.article-tag-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.article-board-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
}

.article-board-chip:hover {
    color: var(--primary);
}

.article-board-chip .board-icon {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

/* Byline */
.article-byline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}

.article-byline-author {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.article-byline-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}
.article-byline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.article-byline-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.article-byline-meta {
    font-size: 13px;
    color: var(--text-muted);
}
.byline-dot {
    margin: 0 4px;
}

.article-author-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.article-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
    white-space: nowrap;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.article-edit-btn:hover { border-color: var(--primary); color: var(--primary); }

.article-report-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: color 0.15s;
    flex-shrink: 0;
}
.article-report-btn:hover { color: var(--danger, #c0392b); }

/* Article body */
.article-content {
    font-size: 18px;
    line-height: 1.85;
    color: var(--text);
}

.article-content h1,
.article-content h2 {
    font-size: 26px;
    font-weight: 700;
    margin: 2em 0 0.6em;
    line-height: 1.25;
}
.article-content h3 {
    font-size: 21px;
    font-weight: 700;
    margin: 1.6em 0 0.5em;
}
.article-content p {
    margin: 0 0 1.4em;
}
.article-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 24px 0;
    display: block;
}
.article-content blockquote {
    margin: 24px 0;
    padding: 8px 0 8px 20px;
    border-left: 3px solid var(--primary);
    color: var(--text-muted);
    font-style: italic;
    font-size: 20px;
}
.article-content code {
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.875em;
    font-family: 'Fira Code', 'Consolas', monospace;
}
.article-content pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    overflow-x: auto;
    margin: 24px 0;
}
.article-content pre code {
    background: none;
    padding: 0;
    font-size: 14px;
}
.article-content hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 40px auto;
    max-width: 100px;
}
.article-content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.article-content ul,
.article-content ol {
    margin: 0 0 1.4em 1.4em;
    padding: 0;
}
.article-content li {
    margin-bottom: 6px;
}

/* Author card footer */
.article-reading-footer {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border-light);
}

.article-author-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.author-card-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}
.author-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.author-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.author-card-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.author-card-name:hover { color: var(--primary); }
.author-card-bio {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* =============================================
   PROFILE — Articles section
   ============================================= */

.profile-articles-section {
    margin-bottom: 36px;
}

.profile-articles-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.profile-articles-header h2 {
    margin: 0;
}

.write-article-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
    white-space: nowrap;
}
.write-article-btn:hover { background: var(--primary-dark); color: #fff; }

.article-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
}
.article-list-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.article-list-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius);
    color: var(--primary);
    flex-shrink: 0;
}
.article-list-item.is-draft .article-list-icon {
    background: var(--border-light);
    color: var(--text-muted);
}

.article-list-body {
    flex: 1;
    min-width: 0;
}

.article-list-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}
.article-list-item.is-draft .article-list-title {
    color: var(--text-muted);
    font-style: italic;
}

.article-list-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.article-draft-badge {
    display: inline-block;
    padding: 1px 7px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.article-list-arrow {
    color: var(--text-light);
    flex-shrink: 0;
}

/* Empty state */
.articles-empty {
    padding: 28px 20px;
    text-align: center;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 14px;
}
.articles-empty p { margin: 8px 0 0; }

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 600px) {
    .editor-topbar { padding: 0 12px; gap: 8px; }
    .editor-breadcrumb { display: none; }
    .editor-save-indicator { display: none; }
    .editor-inner { padding: 24px 16px 60px; }
    .editor-title-input { font-size: 26px; }
    .editor-content-input { font-size: 16px; }
    .article-reading-view { padding: 24px 16px 60px; }
    .article-reading-title { font-size: 26px; }
    .article-content { font-size: 16px; line-height: 1.75; }
}
