/* RadPress — Base Stylesheet */

:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --accent: #5c6bc0;
    --accent-hover: #3f51b5;
    --border: #dee2e6;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --max-width: 960px;
    --max-width-wide: 1200px;
    --radius: 6px;
}

/* ── Reset ─────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ── Layout ────────────────────────────────────────────── */

main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1rem;
}

.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.site-header nav {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.logo:hover { text-decoration: none; color: var(--accent); }

.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; }
.nav-links a:hover { color: var(--accent); }

.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-outline { border-color: var(--border); color: var(--text); background: transparent; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-warning { background: var(--warning); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; color: #fff; }

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1.1rem; }

/* ── Forms ─────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: var(--font-body);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.15);
}
.form-group small { color: var(--text-muted); font-size: 0.8rem; }

.form-row { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }

.form-card {
    max-width: 600px;
}

.code-textarea {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ── Alerts ────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Badges ────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-draft { background: #e2e3e5; color: #383d41; }
.badge-published { background: #d4edda; color: #155724; }
.badge-scheduled { background: #fff3cd; color: #856404; }
.badge-unlisted { background: #d1ecf1; color: #0c5460; }

/* ── Auth ──────────────────────────────────────────────── */

.auth-container {
    max-width: 400px;
    margin: 2rem auto;
}
.auth-container h1 { margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }
.auth-form button { width: 100%; margin-top: 0.5rem; }

/* ── Dashboard ─────────────────────────────────────────── */

.dashboard { max-width: var(--max-width); }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}
.header-actions { display: flex; gap: 0.5rem; }

.blog-card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.blog-card h2, .blog-card h3 { margin-bottom: 0.25rem; }
.blog-slug { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.blog-actions { display: flex; gap: 0.5rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state .btn { margin-top: 1rem; }

/* ── Table ─────────────────────────────────────────────── */

.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ── Editor ────────────────────────────────────────────── */

.editor-container { max-width: var(--max-width-wide); margin: 0 auto; }

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.editor-textarea {
    width: 100%;
    min-height: 500px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
}

.preview-pane {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 500px;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.preview-placeholder { color: var(--text-muted); font-style: italic; }

.editor-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.media-upload {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
}
.media-upload h3 { margin-bottom: 0.5rem; font-size: 0.95rem; }

.saved { color: var(--success); font-size: 0.85rem; }

/* ── Hero (Homepage) ───────────────────────────────────── */

.hero {
    text-align: center;
    padding: 4rem 1rem;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.75rem; }
.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 1.5rem;
    line-height: 1.7;
}
.hero-actions { margin-top: 1.5rem; }
.hero-actions .btn { margin: 0 0.25rem; }

/* ── Home Feed ────────────────────────────────────────── */

.home-feed {
    margin-top: 3rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}

.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.feed-header h2 { font-size: 1.5rem; }

.feed-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.feed-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.feed-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    background: var(--bg-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.feed-item:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(92, 107, 192, 0.15);
    transform: translateY(-3px);
}

.feed-item-link {
    display: block;
    padding: 1.5rem 1.75rem;
    color: var(--text);
    text-decoration: none;
}
.feed-item-link:hover {
    text-decoration: none;
    color: var(--text);
}

.feed-item-hero {
    margin: -1.5rem -1.75rem 1.25rem;
    height: 160px;
    overflow: hidden;
}
.feed-item-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-item-content { min-width: 0; }

.feed-item-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.35;
    color: var(--text);
}

.feed-item-summary {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.feed-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.feed-item-blog {
    font-weight: 600;
    color: var(--text);
}

.feed-item-author {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.feed-item-handle {
    color: var(--accent);
    font-weight: 500;
}

.feed-item-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.feed-item-domain {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.feed-item-views {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}
.feature {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.feature h3 { margin-bottom: 0.5rem; }
.feature p { color: var(--text-muted); font-size: 0.9rem; }

/* ── Public Blog ───────────────────────────────────────── */

.blog-container { max-width: 720px; margin: 0 auto; }

.blog-header { margin-bottom: 2rem; }
.blog-header h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.blog-author { color: var(--text-muted); }
.rss-link { font-size: 0.85rem; }

.post-card {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}
.post-card:last-child { border-bottom: none; }
.post-card h2 { margin-bottom: 0.5rem; font-size: 1.4rem; }
.post-summary { color: var(--text-muted); margin-bottom: 0.5rem; }

.post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.post-tags { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ── Single Post ───────────────────────────────────────── */

.post-container { max-width: 720px; margin: 0 auto; }

.post-header { margin-bottom: 2rem; }
.post-header h1 { font-size: 2.25rem; line-height: 1.3; margin-bottom: 0.75rem; }

.post-hero { border-radius: var(--radius); margin-bottom: 1.5rem; }
.post-hero-full { border-radius: var(--radius); margin-bottom: 2rem; width: 100%; }

/* ── Prose (article body) ──────────────────────────────── */

.prose h1 { font-size: 1.75rem; margin: 2rem 0 0.75rem; }
.prose h2 { font-size: 1.5rem; margin: 1.75rem 0 0.5rem; }
.prose h3 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin-bottom: 1rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.25rem; }
.prose blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-style: italic;
}
.prose code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-secondary);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
}
.prose pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1rem;
}
.prose pre code { background: none; padding: 0; }
.prose img { border-radius: var(--radius); margin: 1rem 0; }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.prose th, .prose td { padding: 0.5rem 0.75rem; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--bg-secondary); font-weight: 600; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose a { text-decoration: underline; }

/* ── Post Footer ───────────────────────────────────────── */

.post-footer { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }

.tip-section { margin-bottom: 1.5rem; }
.tip-section h3 { margin-bottom: 0.5rem; }
.tip-buttons { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.tip-section small { color: var(--text-muted); }

.post-nav { margin-top: 1.5rem; }

/* ── Profile ───────────────────────────────────────────── */

.profile-container { max-width: 720px; margin: 0 auto; }

/* ── Error Page ────────────────────────────────────────── */

.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 4rem; color: var(--text-muted); }
.error-page p { margin: 1rem 0; color: var(--text-muted); }

/* ── Alerts (Phase 2) ─────────────────────────────────── */

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Comments ─────────────────────────────────────────── */

.comments-section { margin-top: 2rem; }
.comments-section h3 { margin-bottom: 1rem; }

.comment {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.comment-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.comment-body { font-size: 0.95rem; }
.comment-hidden { opacity: 0.5; }
.comment-actions { margin-top: 0.5rem; }

.comment-form { margin-top: 1rem; }
.comment-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* ── Subscribe ────────────────────────────────────────── */

.subscribe-section { margin: 1.5rem 0; }
.subscriber-count { color: var(--text-muted); font-size: 0.85rem; margin-left: 0.5rem; }

/* ── Cart ─────────────────────────────────────────────── */

.cart-container { max-width: 720px; margin: 0 auto; }

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}
.cart-item-info { flex: 1; }
.cart-item-price { font-weight: 600; margin: 0 1rem; }
.cart-empty { text-align: center; padding: 2rem; color: var(--text-muted); }
.cart-total {
    text-align: right;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem 0;
    border-top: 2px solid var(--border);
    margin-top: 1rem;
}

/* ── Schedule ─────────────────────────────────────────── */

.schedule-section {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    margin-bottom: 1rem;
}
.schedule-section h4 { margin-bottom: 0.5rem; }

/* ── Analytics (post stats) ───────────────────────────── */

.post-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.stat-value { font-weight: 600; color: var(--text); }

/* ── SEO Section (editor) ─────────────────────────────── */

.seo-section { margin-bottom: 1rem; }
.seo-section summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.5rem 0;
    color: var(--text-muted);
}
.seo-section summary:hover { color: var(--text); }

/* ── Admin ────────────────────────────────────────────── */

.admin-container { max-width: var(--max-width-wide); margin: 0 auto; }

.admin-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.admin-nav a {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.admin-nav a:hover { background: var(--bg-secondary); color: var(--accent); text-decoration: none; }
.admin-nav a.active { background: var(--accent); color: #fff; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; display: block; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar input,
.filter-bar select {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

/* ── Feed Page ────────────────────────────────────────── */

.feed-container { max-width: 720px; margin: 0 auto; }

/* ── Directory ─────────────────────────────────────────── */

.directory-container { max-width: var(--max-width); margin: 0 auto; }

.directory-header { margin-bottom: 2rem; }
.directory-header h1 { font-size: 2rem; margin-bottom: 0.25rem; }

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

.directory-card {
    display: block;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.directory-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(92, 107, 192, 0.1);
    text-decoration: none;
}
.directory-card h3 { margin-bottom: 0.5rem; font-size: 1.1rem; }

.directory-author {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.directory-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.directory-domain {
    background: var(--bg-secondary);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.directory-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.sort-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sort-tab {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    transition: all 0.15s;
}
.sort-tab:last-child { border-right: none; }
.sort-tab:hover { background: var(--bg-secondary); color: var(--text); text-decoration: none; }
.sort-tab.active { background: var(--accent); color: #fff; }
.sort-tab.active:hover { text-decoration: none; }

.domain-filter select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--bg);
    cursor: pointer;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
    .editor-split { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .dashboard-header { flex-direction: column; gap: 1rem; }
    .hero h1 { font-size: 1.75rem; }
    .feed-item-link { padding: 1.25rem; }
    .feed-item-hero { margin: -1.25rem -1.25rem 1rem; height: 140px; }
    .feed-header { flex-direction: column; align-items: flex-start; }
    .feed-item-title { font-size: 1.05rem; }
}
