/* ===================================================================
   Novode — Layout Patterns
   =================================================================== */

/* --- Reading content (Lora prose) ------------------------------- */
.prose {
    font-family: var(--font-reading);
    font-size: var(--text-lg);
    line-height: var(--leading-body);
    max-width: 700px;
    margin: 0 auto;
    color: var(--color-text);
}

.prose p {
    margin-bottom: 1.5em;
}

.prose h2 {
    font-family: var(--font-ui);
    font-size: var(--text-2xl);
    margin-top: 2.5em;
    margin-bottom: .75em;
}

.prose h3 {
    font-family: var(--font-ui);
    font-size: var(--text-xl);
    margin-top: 2em;
    margin-bottom: .5em;
}

.prose a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.prose img {
    border-radius: var(--radius-lg);
    margin: 2em auto;
    box-shadow: var(--shadow-md);
}

.prose blockquote {
    position: relative;
    border-left: 3px solid var(--color-accent);
    padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6);
    margin: 2em 0;
    font-style: italic;
    color: var(--color-text-secondary);
    background: var(--color-accent-soft);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.prose blockquote p {
    margin-bottom: 0;
}

.prose ul,
.prose ol {
    padding-left: 1.5em;
    margin-bottom: 1.5em;
}

.prose ul {
    list-style: disc;
}

.prose ol {
    list-style: decimal;
}

.prose strong {
    font-weight: 700;
    color: var(--color-text);
}

.prose hr {
    border: none;
    height: 1px;
    background: var(--color-border);
    margin: 2em 0;
}

/* --- Comments section ------------------------------------------- */
.comments-section {
    max-width: 700px;
    margin: var(--sp-10) auto 0;
}

.comments-title {
    font-size: var(--text-xl);
    margin-bottom: var(--sp-6);
}

.comment {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-4) 0;
    border-bottom: 1px solid var(--color-border);
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}

.comment:last-child {
    border-bottom: none;
}

.comment-body {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
}

.comment-author {
    font-weight: 600;
    font-size: var(--text-sm);
}

.comment-date {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.comment-text {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-body);
}

.comment-reply {
    font-size: var(--text-xs);
    color: var(--color-accent);
    cursor: pointer;
    margin-top: var(--sp-1);
    border: 0;
    background: transparent;
    padding: 0;
    font-weight: 600;
}

.comment-reply:hover {
    color: var(--color-accent-hover);
}

.comment-reply-target {
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

.comment-pending {
    font-size: var(--text-xs);
    color: var(--color-warning);
    font-style: italic;
    margin-top: var(--sp-1);
}

.comment-replies {
    margin-left: var(--sp-10);
}

.comment-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-6);
}

.comment-form-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt);
}

.comment-form-guest {
    margin-top: 0;
    margin-bottom: var(--sp-3);
}

.comment-avatar-form {
    width: 36px;
    height: 36px;
}

/* --- Content grids ---------------------------------------------- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--sp-6);
    justify-items: stretch;
}

.content-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-6);
    align-items: stretch;
    justify-items: stretch;
}

.content-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
}

/* --- Gallery grid ----------------------------------------------- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
}

.gallery-item {
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: var(--color-surface-alt);
    aspect-ratio: 16/10;
    border: 1px solid var(--color-border);
    transition: all var(--duration) var(--ease);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms var(--ease);
}

.gallery-item:hover {
    box-shadow: var(--shadow-md);
}

.gallery-item:hover img {
    transform: scale(1.04);
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--sp-3) var(--sp-4);
    background: linear-gradient(transparent, rgba(0, 0, 0, .65));
    color: #fff;
    font-size: var(--text-sm);
    opacity: 0;
    transition: opacity 200ms;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-badge {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-2);
}

.gallery-item-fav {
    position: absolute;
    top: var(--sp-2);
    left: var(--sp-2);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    opacity: 0;
    transition: all 200ms;
    box-shadow: var(--shadow-sm);
}

.gallery-item:hover .gallery-item-fav {
    opacity: 1;
}

.gallery-item-fav.active {
    opacity: 1;
    color: var(--color-danger);
}

/* --- Story / article page --------------------------------------- */
.article-page {
    max-width: 800px;
    margin: 0 auto;
}

.article-header {
    margin-bottom: var(--sp-8);
}

.article-title {
    font-size: var(--text-4xl);
    font-weight: 800;
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    margin-bottom: var(--sp-4);
}

.article-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-4);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--sp-6);
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.article-cover {
    width: 100%;
    border-radius: var(--radius-xl);
    margin-bottom: var(--sp-8);
    box-shadow: var(--shadow-lg);
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-6);
    margin-bottom: var(--sp-6);
}

.article-top-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.article-image-meta {
    margin-top: var(--sp-2);
    margin-bottom: var(--sp-6);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.article-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin: var(--sp-8) 0;
}

.article-actions .btn-like.liked {
    background: var(--color-danger-soft);
    border-color: rgba(220, 38, 38, .2);
    color: var(--color-danger);
}

.reading-content {
    font-family: var(--font-reading);
    font-size: var(--text-lg);
    line-height: 1.92;
    color: var(--color-text);
}

.reading-content p {
    margin-bottom: 1.35em;
}

.reading-content h2 {
    font-family: var(--font-ui);
    font-size: var(--text-2xl);
    margin-top: 2.15em;
    margin-bottom: .75em;
}

.reading-content h3 {
    font-family: var(--font-ui);
    font-size: var(--text-xl);
    margin-top: 1.85em;
    margin-bottom: .55em;
}

.reading-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5em auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.reading-content ul,
.reading-content ol {
    margin-bottom: 1.35em;
    padding-left: 1.4em;
}

.reading-content blockquote {
    border-left: 3px solid var(--color-accent);
    padding: var(--sp-3) var(--sp-4);
    margin: 1.75em 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    background: var(--color-accent-soft);
    color: var(--color-text-secondary);
}

.card-cover-meta {
    margin-top: var(--sp-2);
    margin-bottom: 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.related-section {
    margin-top: var(--sp-10);
}

.related-title {
    margin-bottom: var(--sp-4);
    font-size: var(--text-xl);
    font-weight: 800;
}

.related-grid {
    gap: var(--sp-4);
}

.related-card {
    text-decoration: none;
    color: inherit;
}

.related-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-card-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0;
}

/* Prev/Next navigation */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin: var(--sp-8) 0;
}

.article-nav-item {
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--duration) var(--ease);
}

.article-nav-item:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
}

.article-nav-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--sp-1);
}

.article-nav-title {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text);
}

.article-nav-next {
    text-align: right;
}

/* --- Wallpaper view --------------------------------------------- */
.wallpaper-view {
    max-width: 1000px;
    margin: 0 auto;
}

.wallpaper-preview {
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--color-surface-alt);
    text-align: center;
    border: 1px solid var(--color-border);
    margin-bottom: var(--sp-6);
    position: relative;
}

.wallpaper-preview img {
    max-height: 70vh;
    margin: 0 auto;
    object-fit: contain;
    cursor: zoom-in;
}

.wallpaper-preview.is-zoomable::after {
    content: '＋';
    position: absolute;
    top: var(--sp-4);
    right: var(--sp-4);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(16, 24, 40, 0.62);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.wallpaper-files {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.wallpaper-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.wallpaper-file-info {
    font-size: var(--text-sm);
}

.wallpaper-file-label {
    font-weight: 600;
}

.wallpaper-file-dims {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    margin-left: var(--sp-2);
}

/* --- Admin Sidebar ---------------------------------------------- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 50;
    overflow-y: auto;
}

.admin-sidebar-header {
    padding: var(--sp-5) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    font-weight: 800;
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.admin-brand {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.admin-brand-logo {
    width: 132px;
    height: auto;
    display: block;
    flex-shrink: 0;
}

.admin-sidebar-nav {
    padding: var(--sp-3);
    flex: 1;
}

.admin-sidebar-section {
    margin-bottom: var(--sp-4);
}

.admin-sidebar-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-1);
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.admin-nav-item:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.admin-nav-item.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: 600;
}

.admin-nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-nav-icon img {
    width: 20px;
    height: 20px;
    display: block;
}

.admin-nav-badge {
    margin-left: auto;
}

/* Admin main content */
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}

.admin-topbar {
    height: var(--header-h);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-topbar-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.admin-page {
    padding: var(--sp-6);
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.admin-page-title {
    font-size: var(--text-2xl);
    font-weight: 800;
}

/* Admin search bar */
.admin-search {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    width: 280px;
    transition: all var(--duration);
}

.admin-search:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.admin-search input {
    flex: 1;
    background: none;
}

/* --- Tabs ------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--sp-6);
}

.tab {
    padding: var(--sp-3) var(--sp-5);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--duration);
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--color-text);
}

.tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}

.tab .tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: var(--sp-2);
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}

.tab.active .tab-count {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

/* --- Rich text editor ------------------------------------------- */
.editor-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-wrap: wrap;
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border);
}

.editor-toolbar-btn {
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--color-text-secondary);
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration);
}

.editor-toolbar-btn:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.editor-toolbar-btn.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.editor-toolbar-sep {
    width: 1px;
    height: 24px;
    background: var(--color-border);
    margin: 0 var(--sp-1);
}

.editor-content {
    min-height: 300px;
    padding: var(--sp-5);
    outline: none;
    font-family: var(--font-reading);
    font-size: var(--text-lg);
    line-height: var(--leading-body);
    color: var(--color-text);
}

.editor-content:focus {
    background: var(--color-surface);
}

.editor-content:empty::before {
    content: attr(data-placeholder);
    color: var(--color-text-muted);
    pointer-events: none;
}

/* --- Lightbox --------------------------------------------------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 96vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.lightbox-close {
    position: absolute;
    top: var(--sp-5);
    right: var(--sp-5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: background 200ms;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, .3);
}

/* --- Section dividers ------------------------------------------- */
.section-divider {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-accent), var(--color-secondary), transparent);
    opacity: .25;
    margin: var(--sp-12) 0;
}

.section-heading {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--text-2xl);
    font-weight: 800;
    margin-bottom: var(--sp-6);
}

.section-heading::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gradient-accent);
    flex-shrink: 0;
}

/* --- Shimmer skeleton ------------------------------------------- */
@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            var(--color-surface-alt) 25%,
            rgba(255, 255, 255, .6) 37%,
            var(--color-surface-alt) 63%);
    background-size: 800px 100%;
    animation: shimmer 1.8s ease infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--sp-2);
}

.skeleton-title {
    height: 24px;
    width: 70%;
    margin-bottom: var(--sp-3);
}

.skeleton-card {
    height: 180px;
}

/* --- Card hover lift -------------------------------------------- */
.card-lift {
    transition: transform var(--duration-md) var(--ease),
        box-shadow var(--duration-md) var(--ease);
}

.card-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

@media (prefers-reduced-motion: reduce) {
    .card-lift:hover {
        transform: none;
    }

    .skeleton {
        animation: none;
    }
}

/* --- Responsive ------------------------------------------------- */
@media (max-width: 768px) {

    .content-grid,
    .content-grid-compact,
    .gallery-grid,
    .content-grid-3 {
        grid-template-columns: 1fr;
    }

    .article-title {
        font-size: var(--text-2xl);
    }

    .article-nav {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        display: none;
    }

    .admin-sidebar.mobile-open {
        display: flex;
        position: fixed;
        width: 280px;
        box-shadow: var(--shadow-xl);
    }

    .admin-main {
        margin-left: 0;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .content-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
