/* light theme */
:root {
    --width-max: 720px;
    --font-primary: Verdana, sans-serif;
    --font-secondary: monospace;
    --font-size-primary: 1em;
    --font-size-secondary: 0.8em;
    --bg-color-primary: #fdfdfd;
    --bg-color-secondary: #f2f4f7;
    --text-color-primary: #1a1a1a;
    --text-color-secondary: #444;
    --text-color-tertiary: #8c8c8c;
    --link-color: #0066cc;
    --link-visited-color: #551a8b;
    --border-color: #d0d7de;
    --upvoted-color: #fa8072;
}

@media (prefers-color-scheme: dark) {

    /* dark theme */
    :root {
        --bg-color-primary: #121212;
        --bg-color-secondary: #1c1f24;
        --text-color-primary: #e5e5e5;
        --text-color-secondary: #b3b3b7;
        --text-color-tertiary: #a0a0a0;
        --link-color: #6da6ff;
        --link-visited-color: #b388ff;
        --border-color: #30363d;
        --upvoted-color: #ff6b6b;
    }
}

body {
    font-family: var(--font-primary);
    font-size: var(--font-size-primary);
    margin: auto;
    padding: 20px;
    max-width: var(--width-max);
    text-align: left;
    background-color: var(--bg-color-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
    color: var(--text-color-primary);
}

h1,
h2,
h3,
h4,
h5,
h6,
strong,
b {
    color: var(--text-color-primary);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 16px 0;
}

a {
    color: var(--link-color);
    cursor: pointer;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.title {
    text-decoration: none;
    border: 0;
}

.title:hover {
    text-decoration: none;
}

.title span {
    font-weight: 400;
}

nav a {
    margin-right: 8px;
}

nav span {
    color: gray;
    font-size: small;
    margin-right: 8px;
}

ul.tags {

    list-style: none;
    padding: 0;
    margin: 0;
}

ul.tags li {
    display: inline-block;
    margin-right: 10px;
    font-size: small;
    text-decoration: underline;
}


textarea {
    width: 100%;
    font-size: 16px;
}

input {
    font-size: 14px;
}

main {
    line-height: 1.6;
}

main div.content {
    word-break: break-word;
    hyphens: auto;
    text-align: justify;
}

table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 4px;
}

th {
    background-color: var(--bg-color-secondary);
}

hr {
    border: 0;
    border-top: 1px dashed;
    color: rgba(128, 128, 128, 0.267);
}

img {
    max-width: 100%;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    content-visibility: auto;
}

img[src*="#minipic"] {
    max-width: 50%;
    margin-left: 0;
    margin-right: auto;
}

.image-caption figcaption {
    text-align: center;
    font-style: italic;
    font-size: 0.8em;
    margin-top: 0.6em;
    color: var(--text-color-secondary);
}

.image-caption {
    margin: auto;
}

i {
    font-style: normal;
}

time {
    font-family: var(--font-secondary);
    font-size: 15px;
}

code {
    font-family: var(--font-secondary);
    background-color: var(--bg-color-secondary);
    padding: 2px;
    border-radius: 4px;
}

pre code {
    display: block;
    padding: 16px;
    white-space: pre-wrap;
    overflow-x: auto;
}

div.highlight pre {
    border-radius: 4px;
}

div.highlight code {
    background-color: var(--bg-color-secondary);
}

blockquote {
    border-left: 4px solid var(--border-color);
    color: var(--text-color-secondary);
    margin: 0;
    padding-left: 8px;
    font-style: normal;
}

blockquote p {
    margin: 0;
}

footer {
    padding: 25px 0;
    text-align: center;
    font-size: var(--font-size-secondary);
    color: gray;
}

ul li:has(input) {
    list-style-type: none;
    margin-left: -25.5px;
}

/* blog post list */
ul.blog-posts {
    list-style-type: none;
    padding: unset;
}

ul.blog-posts li {
    display: flex;
}

ul.blog-posts li span {
    flex: 0 0 130px;
}

ul.blog-posts li span.grouped {
    flex: 0 0 80px;
}

ul.blog-posts li a:visited {
    color: var(--link-visited-color);
}

.toc ul {
    list-style: square;
}

.toc li::marker {
    color: rgba(128, 128, 128, 0.347);
}

button.upvote-btn {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color-primary);
}

button.upvoted {
    color: var(--upvoted-color);
}

span.upvote-count {
    margin-top: -4px;
    font-size: smaller;
}

/* 图片放大功能 - CSS only */
body:has(.image-zoom-toggle:checked) {
    overflow: hidden;
}

.image-zoom-container {
    position: relative;
    display: block;
}

.image-zoom-toggle {
    display: none;
}

.image-zoom-label {
    cursor: zoom-in;
    display: block;
    position: relative;
}

.image-zoom-label:focus {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.zoomable-image {
    transition: transform 0.3s ease;
}

/* 放大overlay - 新建一个元素专门用于overlay */
.image-zoom-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

.image-zoom-toggle:checked~.image-zoom-overlay {
    display: flex;
    cursor: zoom-out;
}

/* 确保原始label保持正常cursor */
.image-zoom-toggle:checked~.image-zoom-label {
    cursor: default;
}

.image-zoom-toggle:checked~.image-zoom-overlay .zoomable-image {
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    transform: scale(1);
    border: none;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin-left: auto !important;
    margin-right: auto !important;
}

.image-zoom-toggle:checked~.image-zoom-overlay::before {
    content: "";
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
}

.image-zoom-toggle:checked~.image-zoom-overlay::after {
    content: "✕";
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    z-index: 1002;
}

.image-zoom-toggle:checked~.image-zoom-overlay figcaption {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1001;
    max-width: 80vw;
    text-align: center;
}

/* 移动设备适配 */
@media (max-width: 800px) {
    img[src*="#minipic"] {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }

    .image-zoom-label {
        cursor: pointer;
    }

    .image-zoom-toggle:checked~.image-zoom-overlay {
        padding: 10px;
    }

    .image-zoom-toggle:checked~.image-zoom-overlay::before,
    .image-zoom-toggle:checked~.image-zoom-overlay::after {
        top: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .image-zoom-toggle:checked~.image-zoom-overlay figcaption {
        bottom: 10px;
        font-size: 12px;
        padding: 6px 12px;
    }
}