/* ============================================================
   MEIG — Dark Tech Theme
   ============================================================ */

:root {
    --bg:           #0d1117;
    --bg-card:      #161b22;
    --bg-card-2:    #1c2128;
    --border:       #30363d;
    --border-light: #21262d;
    --text:         #e6edf3;
    --text-muted:   #8b949e;
    --text-faint:   #6e7681;
    --accent:       #58a6ff;
    --accent-dim:   #1f6feb33;
    --green:        #3fb950;
    --header-h:     56px;
    --radius:       8px;
    --radius-lg:    12px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base */
body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
    width: 100%;
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 24px;
    position: fixed;
    top: 0;
    z-index: 1000;
}

.header a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
    letter-spacing: 0.01em;
}

.header a:hover {
    color: var(--text);
    background: var(--bg-card-2);
}

.header .separator {
    color: var(--border);
    font-size: 16px;
    user-select: none;
    padding: 0 4px;
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 0;
    line-height: 0;
}

.dropdown-button a {
    /* inherit nav link style */
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: var(--radius);
    display: inline-block;
    transition: color 0.15s, background 0.15s;
}

.dropdown-button:hover a,
.dropdown:hover .dropdown-button a {
    color: var(--text);
    background: var(--bg-card-2);
}

.dropdown-content {
    display: none;
    position: absolute;
    /* overlap the button slightly so hover is continuous — no gap */
    top: calc(100% - 2px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-width: 180px;
    /* top padding creates the visual gap without breaking hover zone */
    padding: 8px 6px 6px;
    z-index: 1001;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.dropdown-content a {
    display: block;
    color: var(--text-muted) !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    font-weight: 500;
    border-radius: 6px;
    background: transparent !important;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
}

.dropdown-content a:hover {
    color: var(--text) !important;
    background: var(--bg-card-2) !important;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
    display: flex;
    gap: 24px;
    margin-top: var(--header-h);
    padding: 24px 24px 48px;
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
    align-items: flex-start;
}

/* ── Left sidebar ────────────────────────────────────────── */
.left-column {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.left-column::-webkit-scrollbar { width: 4px; }
.left-column::-webkit-scrollbar-track { background: transparent; }
.left-column::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Profile photo */
.profile-photo {
    width: 100%;
    aspect-ratio: 4/3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Sidebar links */
.links { margin-top: 4px; }

.link-item {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-card-2);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.section-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.book-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.book-list li {
    margin-bottom: 6px;
    padding-left: 14px;
    position: relative;
}

.book-list li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--text-faint);
    font-size: 14px;
    line-height: 1.4;
}

.link-item a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    display: inline;
    transition: color 0.15s;
}

.link-item a:hover {
    color: var(--accent);
}

/* ── Blog content area ───────────────────────────────────── */
.blog-content {
    flex: 1;
    min-width: 0;
}

/* Blog list */
.blog-list { margin-bottom: 32px; }

.blog-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin: 12px 0;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.blog-container:hover {
    border-color: var(--accent);
    background: var(--bg-card-2);
}

.blog-date {
    font-size: 12px;
    color: var(--text-faint);
    font-weight: 400;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.blog-heading {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.blog-container:hover .blog-heading {
    color: var(--accent);
}

.blog-preview {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Blog detail view ────────────────────────────────────── */
.blog-details {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    color: var(--text);
    line-height: 1.75;
    font-size: 15.5px;
}

/* Back button */
.blog-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    margin-bottom: 24px;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}

.blog-back-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

/* Blog detail typography */
.blog-details h1,
.blog-details h2,
.blog-details h3,
.blog-details h4 {
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
    margin: 28px 0 12px;
    letter-spacing: -0.02em;
}

.blog-details h1 { font-size: 26px; margin-top: 0; }
.blog-details h2 { font-size: 20px; }
.blog-details h3 { font-size: 17px; }
.blog-details h4 { font-size: 15px; color: var(--text-muted); }

.blog-details p {
    margin: 0 0 16px;
    color: var(--text-muted);
}

.blog-details a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--accent-dim);
    transition: text-decoration-color 0.15s;
}

.blog-details a:hover {
    text-decoration-color: var(--accent);
}

.blog-details strong, .blog-details b {
    color: var(--text);
    font-weight: 600;
}

.blog-details em, .blog-details i {
    color: var(--text-muted);
}

.blog-details blockquote {
    border-left: 3px solid var(--accent);
    margin: 20px 0;
    padding: 4px 0 4px 20px;
    color: var(--text-muted);
    font-style: italic;
}

.blog-details code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--green);
}

.blog-details pre {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 13px;
    line-height: 1.6;
}

.blog-details pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.blog-details hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

.blog-details ul, .blog-details ol {
    padding-left: 24px;
    margin: 0 0 16px;
    color: var(--text-muted);
}

.blog-details li { margin-bottom: 6px; }

.blog-details img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 20px 0;
    border: 1px solid var(--border);
    display: block;
}

/* Reading meta (title + time) */
.blog-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.blog-detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.blog-detail-info {
    font-size: 12px;
    color: var(--text-faint);
    display: flex;
    gap: 12px;
    align-items: center;
}

.blog-detail-info span::before {
    content: '·';
    margin-right: 12px;
    color: var(--border);
}

.blog-detail-info span:first-child::before { display: none; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 28px 0;
    padding: 12px;
}

.pagination-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.pagination-btn:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.page-info {
    color: var(--text-faint);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    background: var(--bg-card-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-variant-numeric: tabular-nums;
}

/* ── State messages ──────────────────────────────────────── */
.no-posts, .error-message {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.error-message { color: #f85149; border-color: #f8514933; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        padding: 16px 16px 40px;
    }

    .left-column {
        width: 100%;
        position: relative;
        top: 0;
    }

    .header { gap: 2px; }
}

@media (max-width: 768px) {
    .container { margin-top: var(--header-h); padding: 12px 12px 32px; }

    .blog-container { padding: 16px 18px; }
    .blog-heading { font-size: 16px; }
    .blog-details { padding: 20px 18px; font-size: 15px; }
    .blog-detail-title { font-size: 20px; }

    .header .separator { display: none; }

    .dropdown-content {
        left: 0;
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .header { padding: 0 12px; }
    .header a, .dropdown-button a { font-size: 13px; padding: 5px 8px; }

    .blog-details { padding: 16px 14px; }
    .pagination-controls { gap: 8px; }
    .pagination-btn { padding: 6px 12px; font-size: 12px; }
}

/* ── Spotify sidebar section ─────────────────────────────── */
.spotify-section {
    margin-top: 4px;
}

.spotify-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.spotify-track {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.spotify-track:hover {
    background: var(--bg-card);
}

.spotify-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.7;
}

.spotify-track-info {
    min-width: 0;
}

.spotify-track-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-track-artist {
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spotify-track a {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.spotify-track a:hover .spotify-track-title {
    color: #1db954;
}

/* ── Linked books in blog detail ─────────────────────────── */
.linked-books {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.linked-books-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.linked-books-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.linked-books-list li {
    padding-left: 14px;
    position: relative;
}

.linked-books-list li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--text-faint);
}

.linked-books-list a {
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
}

.linked-books-list a:hover {
    text-decoration: underline;
}
