/* ================================================
   Explore layout: same true-centering pattern as admin.
   The sidebar is taken out of flow so .explore-content spans full width.
   detail-content-wrap is centered on the page using margin-left:
     - calc(50% - 500px) centers a 1000px box within the scroll area.
     - max() ensures we never overlap the sidebar (200px sidebar - 32px
       scroll padding + 24px gap = 192px minimum).
   ================================================ */

:root {
    --explore-sidebar-width: 200px;
}

.explore-shell {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar ── */

.explore-sidebar {
    width: var(--explore-sidebar-width);
    min-width: var(--explore-sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-elevated);
}

.explore-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
}

.explore-sidebar-header i {
    font-size: 14px;
    color: var(--accent-purple);
}

.explore-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.explore-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
    text-decoration: none;
}

.explore-nav-item:hover {
    background: var(--bg-row-hover);
    color: var(--text-primary);
}

.explore-nav-item.active {
    background: var(--accent-purple-subtle);
    color: var(--accent-purple);
}

.explore-nav-item i {
    width: 16px;
    text-align: center;
    font-size: 12px;
    flex-shrink: 0;
}

/* ── Content area ── */

.explore-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.explore-content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 48px;
}

.explore-content-scroll .detail-content-wrap {
    max-width: var(--detail-content-max-width);
    margin-left: max(192px, calc(50% - 500px));
    margin-right: auto;
}

.explore-no-sidebar .explore-content-scroll .detail-content-wrap {
    margin-left: auto;
    margin-right: auto;
}

.explore-content .detail-header {
    padding-left: 0;
}

/* ── Feed ── */

.explore-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Feed cards ── */

.explore-card {
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    background: var(--bg-card);
    overflow: hidden;
    transition: border-color 0.12s;
    cursor: pointer;
}

.explore-card:hover {
    border-color: var(--border-secondary);
}

.explore-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 0;
}

.explore-card-header-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.explore-card-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-tertiary);
}

.explore-card-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--accent-purple);
    flex-shrink: 0;
}

.explore-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explore-card-name .pn-owner {
    color: var(--text-owner);
    font-weight: 400;
}

.explore-card-name .pn-sep {
    color: var(--text-muted);
    margin: 0 1px;
    font-weight: 400;
}

.explore-card-meta {
    padding: 8px 16px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.explore-card-desc {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

.explore-card-time {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.explore-card-time i {
    font-size: 10px;
}

.explore-card-badge {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.explore-card-badge i {
    font-size: 9px;
}

/* ── Card details area (commit + members) ── */

.explore-card-details {
    margin-top: 4px;
}

.explore-card-readme {
    padding: 12px 16px 10px;
    margin-top: 8px;
    border-top: 1px solid var(--border-primary);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 300px;
    overflow: hidden;
    position: relative;
}

.explore-card-readme.explore-readme-loaded {
    cursor: default;
}

.explore-card-readme-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-card));
    pointer-events: none;
}

.explore-card-readme-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.explore-card-readme-text {
    word-break: break-word;
}

.explore-card-readme-text h1 {
    font-size: 16px;
    margin: 12px 0 6px;
}

.explore-card-readme-text h2 {
    font-size: 15px;
    margin: 10px 0 5px;
}

.explore-card-readme-text h3 {
    font-size: 14px;
    margin: 8px 0 4px;
}

.explore-card-readme-text h4,
.explore-card-readme-text h5,
.explore-card-readme-text h6 {
    font-size: 13px;
    margin: 8px 0 4px;
}

.explore-card-readme-text h1:first-child,
.explore-card-readme-text h2:first-child,
.explore-card-readme-text h3:first-child {
    margin-top: 0;
}

.explore-card-readme-text p {
    margin: 6px 0;
}

.explore-card-readme-text ul,
.explore-card-readme-text ol {
    margin: 6px 0;
    padding-left: 20px;
}

.explore-card-readme-text code {
    font-size: 12px;
    background: var(--bg-badge);
    padding: 1px 4px;
    border-radius: 3px;
}

.explore-card-readme-text pre {
    margin: 6px 0;
    padding: 8px 10px;
    background: var(--bg-badge);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}

.explore-card-readme-text pre code {
    background: none;
    padding: 0;
}

/* ── Latest commit ── */

.explore-card-commit {
    padding: 10px 16px 0;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-height: 0;
}

.explore-card-commit:empty {
    display: none;
}

.explore-card-commit i {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    position: relative;
    top: 1px;
}

.explore-commit-msg {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.explore-commit-author {
    color: var(--text-muted);
    flex-shrink: 0;
}

.explore-commit-date {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Members ── */

.explore-card-members {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px 0;
    min-height: 0;
}

.explore-card-members:empty {
    display: none;
}

.explore-members-icon {
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 4px;
}

.explore-member {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-purple);
    color: #fff;
    font-size: 9px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.explore-members-more {
    font-size: 11px;
    color: var(--accent-purple);
    text-decoration: none;
    margin-left: 4px;
    font-weight: 500;
}

.explore-members-more:hover {
    text-decoration: underline;
}

.explore-card-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-purple);
    text-decoration: none;
}

.explore-card-link:hover {
    text-decoration: underline;
}

.explore-card-link i {
    font-size: 10px;
}

/* ── Skeleton cards ── */

.explore-skeleton {
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.explore-skeleton-line {
    height: 12px;
    border-radius: 4px;
    background: var(--bg-badge);
    animation: explore-pulse 1.2s ease-in-out infinite;
}

.explore-skeleton-line.sk-title {
    width: 45%;
    height: 14px;
}

.explore-skeleton-line.sk-desc {
    width: 70%;
}

.explore-skeleton-line.sk-readme {
    width: 90%;
}

.explore-skeleton-line.sk-readme-short {
    width: 60%;
}

@keyframes explore-pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

/* ── Sentinel and states ── */

.explore-sentinel {
    height: 1px;
    width: 100%;
}

/* ── Empty state ── */

.explore-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 24px;
    gap: 12px;
}

.explore-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--bg-badge);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.explore-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.explore-empty-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    max-width: 320px;
    line-height: 1.5;
}

/* ── End of feed ── */

.explore-end {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 20px 48px;
}

.explore-end-rule {
    width: 48px;
    height: 2px;
    border-radius: 1px;
    background: var(--border-primary);
}

.explore-end-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Project drawer ── */

.explore-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.explore-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.explore-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 65vw;
    min-width: 480px;
    background: var(--bg-page);
    border-left: 1px solid var(--border-primary);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}

.explore-drawer.open {
    transform: translateX(0);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
}

.explore-drawer-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-topbar);
    flex-shrink: 0;
}

.explore-drawer-close {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.explore-drawer-close:hover {
    background: var(--bg-row-hover);
    color: var(--text-primary);
}

.explore-drawer-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.explore-drawer-open {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-purple);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.12s;
}

.explore-drawer-open:hover {
    background: var(--accent-purple-subtle);
}

.explore-drawer-open i {
    font-size: 10px;
}

.explore-drawer-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--bg-page);
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .explore-drawer {
        width: 100vw;
        min-width: 0;
    }

    .explore-sidebar {
        display: none;
    }

    .explore-content-scroll .detail-content-wrap {
        margin-left: auto;
    }
}

@media (max-width: 500px) {
    .explore-content-scroll {
        padding: 16px 12px 48px;
    }

    .explore-card-header {
        padding: 12px 12px 0;
    }

    .explore-card-meta {
        padding: 6px 12px 0;
    }

    .explore-card-commit {
        padding: 10px 12px 0;
    }

    .explore-card-members {
        padding: 8px 12px 0;
    }

    .explore-card-readme {
        padding: 10px 12px 8px;
    }

    .explore-card-link {
        padding: 0 12px 10px;
    }
}