/* Modern Theme for 鍊磨館 - Blue Sky Aesthetic */

/* Logo Icon Fix - Ensure always visible */
.g-logo {
    background: url('/assets/icons/default.svg') no-repeat center !important;
    background-size: 100% 100% !important;
}

:root {
    --sky-blue: #4a90b8;
    --sky-dark: #2c5f7c;
    --sky-light: #7ab8d4;
    --moonlight: #f5f2eb;
    --parchment: #e8e4dc;
    --gold-dim: #c4a962;
    --gold-bright: #d4b76a;
    --muted-red: #8b3a3a;
    --muted-blue: #3a5a6b;
    --stone-gray: #6b6b6b;
    --text-primary: #2a2a2a;
    --text-secondary: #5a5a5a;
}

body {
    font-family: 'Noto Serif SC', serif;
    background: var(--moonlight) !important;
    color: var(--text-primary);
    line-height: 1.7;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

body.night-mode {
    --moonlight: #1a1f2a;
    --parchment: #252d3a;
    --text-primary: #dce4ec;
    --text-secondary: #9aa5b5;
}

body.night-mode .markdown-body .book-summary-box {
    background: #252d3a !important;
    border-color: rgba(122, 184, 212, 0.2) !important;
    color: #9aa5b5 !important;
}

body.night-mode .post-copyright {
    background: #252d3a !important;
    border-color: rgba(122, 184, 212, 0.2) !important;
    color: #9aa5b5 !important;
}

/* Noise overlay */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Navigation */
.g-header {
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Override JavaScript inline styles when at top */
.g-header:not(.headerUp):not(.headerDown),
.g-header:not(.headerUp).headerDown[style*="transparent"] {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

/* When scrolled down (has headerUp class), show blue background */
.g-header.headerUp {
    background: linear-gradient(to bottom, rgba(44, 95, 124, 0.95), rgba(44, 95, 124, 0.9)) !important;
    background-color: rgba(44, 95, 124, 0.95) !important;
    box-shadow: 0 2px 20px rgba(44, 95, 124, 0.2) !important;
    backdrop-filter: blur(10px) !important;
}

/* Keep navigation text visible at all times */
.g-nav a,
.g-nav a.color-f-gray,
.g-nav .random a,
.g-nav .travelling a,
.g-nav .mode a,
.g-nav .mode .icon {
    color: var(--moonlight) !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.g-nav a:hover {
    color: var(--gold-dim) !important;
}

.g-nav .random a:hover {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
    display: inline-block;
}

.g-nav .mode .icon {
    width: 20px;
    height: 20px;
}

.g-nav .mode .day,
.g-nav .mode .night {
    display: none;
}

body.night-mode .g-nav .mode .day {
    display: block;
}

body:not(.night-mode) .g-nav .mode .night {
    display: block;
}

/* Post Banner */
.g-banner {
    background: linear-gradient(135deg, var(--sky-dark) 0%, var(--sky-blue) 100%) !important;
}

.g-banner.post-header .post-wrapper h1 {
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Enhanced overlay for better text readability */
.g-banner.post-header .filter {
    background: linear-gradient(to bottom,
            rgba(0, 0, 0, 0.3) 0%,
            rgba(0, 0, 0, 0.5) 50%,
            rgba(0, 0, 0, 0.7) 100%) !important;
}

.g-banner.post-header .post-wrapper {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.g-banner.post-header .post-wrapper h1 {
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.8),
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(0, 0, 0, 0.3);
}

.g-banner.post-header .post-meta,
.g-banner.post-header .post-meta-item,
.g-banner.post-header .post-tags a {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.post-meta-item {
    color: rgba(245, 242, 235, 0.95) !important;
}

.g-banner.post-header .post-tags a {
    background: rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
    backdrop-filter: blur(4px);
}

/* Tags */
.post-tag {
    background: rgba(245, 242, 235, 0.2) !important;
    color: var(--moonlight) !important;
    border: 1px solid rgba(245, 242, 235, 0.3);
}

.post-tag:hover {
    background: rgba(245, 242, 235, 0.3) !important;
}

/* Main Content */
.post-content,
body.night-mode .post-content,
body.night-mode .post-content .container,
body.night-mode .post-content .contents {
    background: var(--moonlight) !important;
    background-color: var(--moonlight) !important;
}

.post-content .container {
    max-width: 1200px !important;
}

.post-content .contents {
    max-width: 100% !important;
    flex: 1 !important;
}

.post-content .contents article {
    max-width: 100% !important;
}

.markdown-body {
    font-family: 'Crimson Text', 'Noto Serif SC', serif;
    color: var(--text-primary);
    background: transparent !important;
    line-height: 1.9;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-body h1 {
    border-bottom: 2px solid var(--sky-blue);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    border-bottom: 1px solid rgba(74, 144, 184, 0.3);
    padding-bottom: 0.3rem;
}

.markdown-body a {
    color: var(--sky-blue);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.markdown-body a:hover {
    color: var(--muted-blue);
    border-bottom-color: var(--sky-blue);
}

.markdown-body blockquote {
    border-left: 4px solid var(--sky-blue);
    background: rgba(74, 144, 184, 0.05);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}

.markdown-body code {
    background: rgba(74, 144, 184, 0.1);
    color: var(--muted-blue);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

.markdown-body pre {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
    position: relative;
}

/* Code copy button */
.copy-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(74, 144, 184, 0.1);
    border-bottom: 1px solid rgba(74, 144, 184, 0.2);
    font-family: 'Noto Serif SC', serif;
}

.copy-container .lang {
    color: var(--muted-blue);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.copy-container .btn {
    background: var(--sky-blue);
    color: var(--moonlight);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.copy-container .btn:hover {
    background: var(--sky-dark);
}

.copy-container .btn svg {
    width: 16px;
    height: 16px;
}

.copy-container .tooltip {
    position: relative;
}

.copy-container .tooltip.unfinish,
.copy-container .tooltip.finish {
    display: none;
}

.copy-container .btn:hover .tooltip.unfinish {
    display: inline;
}

.copy-container .btn .tooltip.finish.active {
    display: inline;
}

/* Tables */
.table-area {
    overflow-x: auto;
    margin: 2rem 0;
}

.table-area table {
    width: 100%;
    border-collapse: collapse;
}

.table-area th {
    background: var(--sky-blue);
    color: var(--moonlight);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.table-area td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(74, 144, 184, 0.2);
}

.table-area tr:hover {
    background: rgba(74, 144, 184, 0.05);
}

/* TOC */
.table-of-contents {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
}

.table-of-contents .toc-header h2 {
    color: var(--sky-blue);
    border-bottom: 2px solid var(--sky-blue);
    padding-bottom: 0.5rem;
}

.toc-body li {
    border-left: 2px solid transparent;
}

.toc-body li.active {
    border-left-color: var(--sky-blue);
    background: rgba(74, 144, 184, 0.1);
}

.toc-body a {
    color: var(--text-secondary);
}

.toc-body a:hover {
    color: var(--sky-blue);
}

/* Sidebar */
.sidebar {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
}

.sidebar-section {
    border-bottom: 1px solid rgba(74, 144, 184, 0.2);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    color: var(--sky-blue);
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
}

/* Author Card */
.author-card {
    background: linear-gradient(135deg, rgba(74, 144, 184, 0.1), rgba(74, 144, 184, 0.05));
    border: 1px solid rgba(74, 144, 184, 0.3);
    border-radius: 8px;
}

.author-card .avatar img {
    border: 3px solid var(--sky-blue);
}

.author-name {
    color: var(--sky-dark);
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
}

/* Read Next */
.read-next-item {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.read-next-item:hover {
    border-color: var(--sky-blue);
    box-shadow: 0 4px 20px rgba(74, 144, 184, 0.2);
}

.read-next-item span {
    color: var(--text-primary);
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
}

.read-next-item p {
    color: var(--text-secondary);
}

/* Comments */
.comment-form {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
}

/* Footer */
.g-footer {
    background: var(--sky-dark) !important;
    color: var(--moonlight) !important;
    border-top: 1px solid rgba(122, 184, 212, 0.3);
    padding: 3rem 2rem;
}

.g-footer .g-container {
    max-width: 1200px;
    margin: 0 auto;
}

.g-footer .links {
    color: var(--moonlight) !important;
}

.g-footer .links a {
    color: var(--sky-light) !important;
    text-decoration: none;
    transition: color 0.3s ease;
}

.g-footer .links a:hover {
    color: var(--gold-dim) !important;
}

.g-footer .links svg {
    fill: currentColor;
}

.g-footer .badges img {
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

.g-footer .badges img:hover {
    opacity: 1;
}

.g-footer .notbyAI img {
    opacity: 0.95;
}

/* Archives Page */
#archive-articles h3 {
    color: var(--text-primary);
    font-family: 'Playfair Display', 'Noto Serif SC', serif;
    font-weight: 600;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

#archive-articles h3:first-child {
    margin-top: 0;
}

#archive-articles h3.year {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 4rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--sky-blue);
    padding-bottom: 0.5rem;
}

#archive-articles h3.year .icon-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    color: var(--gold-dim);
}

#archive-articles h3.year .icon-item svg {
    width: 28px;
    height: 28px;
}

.archives-title {
    border-left: 3px solid var(--sky-blue);
    padding-left: 1rem;
    margin: 1rem 0;
}

.archives-title a {
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'Crimson Text', 'Noto Serif SC', serif;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
}

.archives-title a:hover {
    color: var(--sky-blue);
}

.archives-date {
    color: var(--text-secondary);
}

/* Tags Page */
.tag-item {
    background: var(--parchment);
    border: 1px solid rgba(74, 144, 184, 0.2);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tag-item:hover {
    border-color: var(--sky-blue);
    background: rgba(74, 144, 184, 0.1);
}

/* Buttons */
.button {
    background: var(--sky-blue);
    color: var(--moonlight);
    border: none;
    transition: all 0.3s ease;
}

.button:hover {
    background: var(--sky-dark);
}

/* Social Share */
.social-share a {
    color: var(--stone-gray);
    transition: color 0.3s ease;
}

.social-share a:hover {
    color: var(--sky-blue);
}

/* Responsive */
@media (max-width: 768px) {
    .g-header {
        padding: 1rem;
    }

    .g-nav-list {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    /* Mobile menu dropdown - Force override with high specificity */
    .g-header .g-nav .g-nav-list>li.dropdown ul.dropdown-menu,
    .g-nav ul.dropdown-menu {
        background: linear-gradient(135deg, var(--sky-dark), var(--sky-blue)) !important;
        border: 1px solid rgba(74, 144, 184, 0.5) !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }

    .g-header .g-nav .g-nav-list>li.dropdown ul.dropdown-menu li a,
    .g-nav ul.dropdown-menu li a {
        color: var(--moonlight) !important;
        font-weight: 500 !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }

    .g-header .g-nav .g-nav-list>li.dropdown ul.dropdown-menu li:hover,
    .g-nav ul.dropdown-menu li:hover {
        background: rgba(245, 242, 235, 0.15) !important;
    }

    .g-header .g-nav .g-nav-list>li.dropdown ul.dropdown-menu li:hover a,
    .g-nav ul.dropdown-menu li:hover a {
        color: var(--gold-dim) !important;
    }
}