/* 1. 显式引入 400, 500, 700 三个字重，防止伪粗体 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

@font-face {
    font-family: "Noto Sans SC Custom";
    src: local("Noto Sans SC"), local("NotoSansSC-Medium");
    /* 尝试增加到 97%，补偿缩小带来的笔画变细 */
    size-adjust: 97%;
    /* 必须声明这个自定义字体支持哪些字重 */
    font-weight: 400 500 700;
}

:root {
    --bg-color: #ffffff;
    --text-color: #000000;

    /* 3. 优先级排序：英文优先，中文回退到缩放后的 Noto */
    --font-family: "Helvetica Neue Medium", "Helvetica Neue", Helvetica, Arial, "Noto Sans SC Custom", sans-serif;

    --gutter: 20px;
    --font-size: 0.9rem;
    --overlay-opacity: 0;
}

/* Dark mode */
body.dark {
    --bg-color: #000000;
    --text-color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: var(--font-size);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* Floating hover preview */
.hover-preview {
    position: fixed;
    width: 400px;
    height: 400px;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hover-preview.visible {
    opacity: 1;
}

.hover-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Custom Info Grid Alignments */
.info-label {
    display: inline-block;
    width: 7.5rem;
    vertical-align: top;
}

body.xl-mode .info-label {
    display: inline-block;
    width: 13rem;
    vertical-align: top;
}

.lang-zh .info-label {
    width: 5rem;
}

body.xl-mode .lang-zh .info-label {
    width: 10rem;
}

.info-value {
    display: inline-block;
    width: calc(100% - 8rem);
    vertical-align: top;
}

body.xl-mode .info-value {
    display: inline-block;
    width: calc(100% - 14rem);
    vertical-align: top;
}

.lang-zh .info-value {
    width: calc(100% - 6rem);
}

body.xl-mode .lang-zh .info-value {
    width: calc(100% - 12rem);
}

.container {
    position: relative;
    z-index: 1;
    padding: var(--gutter);
    padding-left: calc(var(--gutter) + 5px);
    padding-right: calc(var(--gutter) + 5px);
    max-width: 100vw;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Site Title and Navigation */
a.site-title {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

a.site-title:hover {
    opacity: 0.6;
}

.proj-nav {
    margin: 0 0.5rem;
    font-family: inherit;
    font-size: inherit;
}

.proj-nav a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.proj-nav a:hover {
    opacity: 0.6;
}

.proj-nav a.disabled {
    opacity: 0.2;
    pointer-events: none;
}

.container::before {
    content: "";
    position: absolute;
    left: calc(var(--gutter) - 5px);
    top: var(--gutter);
    bottom: var(--gutter);
    width: 1px;
    background-color: var(--text-color);
}

/* Main Panel */
.main-panel {
    width: 100%;
}

.header-top {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    /* approximate distance of line height 1.4 */
    margin-bottom: 1rem;
}

h1 {
    font-size: var(--font-size);
    font-weight: 500;
    margin-bottom: -0.16rem;
    /* remove bottom margin since gap handles it */
}


.gap {
    margin-top: 200px;
    margin-bottom: 200px;
}

.site-title {
    font-family: "Times New Roman", Times, serif;
    font-style: italic;
    font-weight: normal;
}

.description {
    font-size: var(--font-size);
    line-height: 1.2;
    max-width: 28rem;
    font-weight: 500;
    margin-bottom: 1.3rem;
}

.description a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.space {
    padding-left: 2rem;
}

.description a:hover {
    border-bottom: 1px solid var(--text-color);
}

/* Sort nav */
.sort-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 1rem;
    position: relative;
}

/* Sort buttons group */
.sort-btns-group {
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
    width: 100%;
}

.sort-btn {
    background: none;
    border: none;
    font-family: "Times New Roman", Times, serif;
    font-style: italic;
    font-size: var(--font-size);
    font-weight: normal;
    cursor: pointer;
    color: var(--text-color);
    text-align: left;
    line-height: 1.2;
}

/* Setup dynamic widths driven by CSS variables set in JS */

/* Base visibility for extra columns, default hide unless CSS class allows it */
.extra-col,
.sort-btn[data-sort="date"],
.item-date,
.sort-btn[data-sort="category"],
.item-category {
    display: none;
}

body.show-date .sort-btn[data-sort="date"],
body.show-date .item-date {
    display: block;
    width: var(--w-date, 80px);
}

body.show-category .sort-btn[data-sort="category"],
body.show-category .item-category {
    display: block;
    width: var(--w-category, auto);
}

body.show-platform .sort-btn[data-sort="platform"],
body.show-platform .item-platform {
    display: block;
    width: var(--w-platform, auto);
}

/* 
 * By default, every column tries to take its exact max text width.
 * The LAST visible column according to the priority takes flex: 1 
 * so it fills the remaining space gracefully. 
 * JS will add classes to the body to indicate which is the last visible. 
 */

.sort-btn[data-sort="name"],
.item-name {
    width: var(--w-name, 100px);
}

body.last-col-name .sort-btn[data-sort="name"],
body.last-col-name .item-name {
    text-align: left;
    /* only one column visible, so align left */
    padding-right: 0;
}

body.last-col-date .sort-btn[data-sort="date"],
body.last-col-date .item-date {
    text-align: right;
    padding-right: 0;
}

body.last-col-category .sort-btn[data-sort="category"],
body.last-col-category .item-category {
    text-align: right;
    padding-right: 0;
}

body.last-col-platform .sort-btn[data-sort="platform"],
body.last-col-platform .item-platform {
    text-align: right;
    padding-right: 0;
}

/* View controls container */
.view-controls-container {
    display: none;
    /* removed from HTML structure */
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    white-space: nowrap;
}

.lang-toggle:hover {
    opacity: 1;
}

.col-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    opacity: 0.3;
}

.col-toggle:hover {
    opacity: 0.7;
}

.col-toggle.active {
    opacity: 1;
}

.footer-text {
    text-align: center;
    margin-top: 100px;
    padding-bottom: 5px;
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    font-size: var(--font-size);
}

.theme-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    margin-left: 8px;
    line-height: 1;
    user-select: none;
}

.xl-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    white-space: nowrap;
}

.xl-toggle:hover {
    opacity: 1;
}

.mode-toggle {
    background: none;
    border: none;
    font-family: inherit;
    font-size: var(--font-size);
    font-weight: 500;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    margin-left: 12px;
    white-space: nowrap;
    opacity: 0.7;
}

.mode-toggle:hover {
    opacity: 1;
}

/* Base list */
.list {
    column-gap: 20px;
    column-fill: auto;
    overflow: hidden;
    column-rule: 1px solid var(--text-color);
}

.list.cols-1 {
    column-count: 1;
}

.list.cols-2 {
    column-count: 2;
}

.list.cols-3 {
    column-count: 3;
}

.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px 0;
    cursor: pointer;
    font-size: var(--font-size);
    border-bottom: 1px solid transparent;
    break-inside: avoid;
    line-height: 1.2;
    overflow: visible;
}

.project-item:hover {
    border-bottom: 1px solid var(--text-color);
}

.project-item.archived {
    text-decoration: line-through;
    opacity: 0.5;
    cursor: not-allowed;
}

.project-media {
    display: flex;
    flex-direction: column;
    align-items: center;
}


.item-name,
.item-date,
.item-category,
.item-platform {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
}

.item-name {
    display: flex;
    align-items: center;
    overflow: visible;
}

.item-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

/* Ensure text is readable over fully opaque background images */
.project-item span {
    /* background-color: var(--bg-color); */
    padding: 0
        /* Give it a slight padding so the background box looks nice */
        /* Optional: to make it blend slightly, you could use an rgba var, but solid is safest for readability */
}

body.last-col-name .item-name,
body.last-col-date .item-date,
body.last-col-category .item-category,
body.last-col-platform .item-platform {
    /* When right-aligned, ensure padding-right is still 0, but keep standard bg padding */
    padding-right:
}

/* Responsive Overrides */
@media (max-width: 600px) {

    .view-controls button[data-cols="2"],
    .view-controls button[data-cols="3"] {
        display: none;
    }
}

/* Language visibility */
body.lang-en .lang-zh {
    display: none;
}

body.lang-zh .lang-en {
    display: none;
}

/* XL Mode Styles */
body.xl-mode {
    --font-size: 1.5rem;
}

body.xl-mode,
body.xl-mode h1,
body.xl-mode .site-title,
body.xl-mode .description,
body.xl-mode .sort-btn,
body.xl-mode .lang-toggle,
body.xl-mode .col-toggle,
body.xl-mode .theme-toggle,
body.xl-mode .mode-toggle,
body.xl-mode .xl-toggle,
body.xl-mode .project-item {
    font-weight: 700;
}

body.xl-mode .description {
    max-width: 40rem;
}

body.xl-mode .space {
    padding-left: 3rem;
}

.experimental-label {
    display: inline-block;
    flex-shrink: 0;
    font-size: 0.6em;
    font-family: var(--font-family);
    font-weight: 500;
    font-style: italic;
    transform: rotate(-10deg);
    transform-origin: left center;
    margin-left: 4px;
    opacity: 0.8;
}

body.xl-mode .experimental-label {
    font-weight: 700;
}