:root {
    --space-ink: #17121f;
    --space-plum: #2d2036;
    --space-rose: #b78c96;
    --space-coral: #e75867;
    --space-amber: #d99262;
    --space-paper: #f5efeb;
    --space-text: #231c26;
}

/* 首页模块公共容器 */
.home-section {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    padding: clamp(64px, 7vw, 96px) 24px;
    background: var(--space-paper);
}

.home-section__inner {
    box-sizing: border-box;
    width: min(1200px, 100%);
    margin: 0 auto;
}

/* Projects：左侧栏目说明，右侧项目网格 */
.projects-section__layout {
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    gap: clamp(40px, 6vw, 88px);
    align-items: start;
}

/* 栏目说明 */
.projects-section__intro {
    padding-top: 8px;
}

.projects-section__eyebrow {
    margin: 0 0 22px;
    color: var(--space-coral);
    font-family: "Source Code Pro", monospace;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.18em;
}

.projects-section__intro h2 {
    margin: 0;
    color: var(--space-text);
    font-size: clamp(44px, 5vw, 68px);
    font-weight: 500;
    line-height: 0.95;
    letter-spacing: -0.055em;
}

.projects-section__description {
    max-width: 250px;
    margin: 28px 0 0;
    color: #756970;
    font-size: 15px;
    line-height: 1.8;
}

/* 项目网格 */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

/*
 * Featured 项目占据网格的完整一行，
 * 但高度受到控制，不再成为一个完整屏幕。
 */
.project-card--featured {
    grid-column: 1 / -1;
}

/* 单张项目卡 */
.project-card {
    --project-accent: var(--space-coral);

    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-width: 0;
    min-height: 310px;
    overflow: hidden;
    color: #f8f3f1;
    background:
        radial-gradient(
            circle at 94% 4%,
            rgba(217, 146, 98, 0.28),
            transparent 34%
        ),
        radial-gradient(
            circle at 65% 110%,
            rgba(231, 88, 103, 0.18),
            transparent 44%
        ),
        linear-gradient(135deg, var(--space-ink), var(--space-plum));
    border: 1px solid rgba(45, 32, 54, 0.22);
    border-radius: 22px;
    box-shadow:
        0 18px 45px rgba(35, 23, 39, 0.12),
        0 2px 8px rgba(35, 23, 39, 0.08);
    transition:
        transform 180ms ease,
        box-shadow 180ms ease;
}

.project-card--featured {
    min-height: 340px;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 24px 55px rgba(35, 23, 39, 0.18),
        0 4px 12px rgba(35, 23, 39, 0.1);
}

/* 卡片顶部 */
.project-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.project-card__label {
    color: var(--project-accent);
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.project-card__meta {
    color: var(--space-rose);
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* 卡片主要内容 */
.project-card__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 28px;
    align-items: center;
    padding: 28px 24px;
}

.project-card--featured .project-card__body {
    grid-template-columns: minmax(0, 1fr) 158px;
    padding: 34px 30px;
}

.project-card__content {
    min-width: 0;
}

.project-card__content h3 {
    margin: 0;
    color: #fff;
    font-size: clamp(32px, 3.5vw, 46px);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.045em;
}

.project-card--featured .project-card__content h3 {
    font-size: clamp(42px, 5vw, 62px);
}

.project-card__content > p {
    max-width: 580px;
    margin: 20px 0 0;
    color: #cbbec4;
    font-size: 15px;
    line-height: 1.75;
}

/* 技术栈 */
.project-card__stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
    padding: 0;
}

.project-card__stack li {
    padding: 7px 10px;
    color: #d9cdd1;
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    line-height: 1;
    list-style: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

/* 右侧项目标记 */
.project-card__mark {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    width: 112px;
    aspect-ratio: 1;
    padding: 14px;
    overflow: hidden;
    color: var(--space-ink);
    background:
        radial-gradient(
            circle at 20% 15%,
            rgba(255, 239, 221, 0.78),
            transparent 34%
        ),
        linear-gradient(
            145deg,
            var(--project-accent),
            #8e3d52
        );
    border-radius: 16px;
}

.project-card--featured .project-card__mark {
    width: 158px;
}

.project-card__mark::before {
    position: absolute;
    inset: 0;
    content: "";
    opacity: 0.16;
    background-image:
        linear-gradient(rgba(23, 18, 31, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 18, 31, 0.4) 1px, transparent 1px);
    background-size: 22px 22px;
}

.project-card__mark strong,
.project-card__mark span {
    position: relative;
    z-index: 1;
}

.project-card__mark strong {
    align-self: flex-end;
    font-size: 42px;
    line-height: 0.9;
    letter-spacing: -0.08em;
}

.project-card--featured .project-card__mark strong {
    font-size: 58px;
}

.project-card__mark span {
    font-family: "Source Code Pro", monospace;
    font-size: 9px;
    letter-spacing: 0.14em;
}

/* 卡片底部链接 */
.project-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding: 0 24px 24px;
}

.project-card--featured .project-card__actions {
    padding: 0 30px 28px;
}

.project-card__actions a {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 14px;
    color: #f8f3f1;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    transition:
        color 160ms ease,
        background-color 160ms ease,
        border-color 160ms ease;
}

.project-card__actions a:first-child {
    color: var(--space-ink);
    background: var(--project-accent);
    border-color: var(--project-accent);
}

.project-card__actions a:hover {
    color: var(--space-ink);
    background: var(--space-paper);
    border-color: var(--space-paper);
}

/* 中等宽度 */
@media screen and (max-width: 960px) {
    .projects-section__layout {
        grid-template-columns: 1fr;
        gap: 42px;
    }

    .projects-section__description {
        max-width: 520px;
        margin-top: 20px;
    }
}

/* 手机 */
@media screen and (max-width: 680px) {
    .home-section {
        padding: 54px 18px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .project-card--featured {
        grid-column: auto;
    }

    .project-card,
    .project-card--featured {
        min-height: 0;
        border-radius: 18px;
    }

    .project-card__header {
        padding: 18px;
    }

    .project-card__body,
    .project-card--featured .project-card__body {
        grid-template-columns: minmax(0, 1fr) 92px;
        gap: 18px;
        padding: 26px 18px;
    }

    .project-card__mark,
    .project-card--featured .project-card__mark {
        width: 92px;
    }

    .project-card__mark strong,
    .project-card--featured .project-card__mark strong {
        font-size: 38px;
    }

    .project-card__actions,
    .project-card--featured .project-card__actions {
        padding: 0 18px 20px;
    }
}

@media screen and (max-width: 460px) {
    .project-card__body,
    .project-card--featured .project-card__body {
        grid-template-columns: 1fr;
    }

    .project-card__mark {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-card,
    .project-card__actions a {
        transition: none;
    }

    .project-card:hover {
        transform: none;
    }
}

/* Writing 栏目入口 */
.writing-intro {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    padding: clamp(76px, 8vw, 112px) 24px 0;
    background: #fff;
}

.writing-intro__inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 48px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e8e1e3;
}

.writing-intro__eyebrow {
    margin: 0 0 18px;
    color: var(--space-coral);
    font-family: "Source Code Pro", monospace;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.18em;
}

.writing-intro h2 {
    margin: 0;
    color: var(--space-text);
    font-size: clamp(40px, 5vw, 64px);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.05em;
}

.writing-intro__description {
    max-width: 360px;
    margin: 0 0 4px;
    color: #756970;
    font-size: 14px;
    line-height: 1.8;
    text-align: right;
}

/* 缩短栏目标题与第一篇文章之间的距离 */
#primary .post:first-child {
    margin-top: 64px;
}

@media screen and (max-width: 680px) {
    .writing-intro {
        padding: 64px 18px 0;
    }

    .writing-intro__inner {
        display: block;
        padding-bottom: 24px;
    }

    .writing-intro__description {
        margin-top: 20px;
        text-align: left;
    }

    #primary .post:first-child {
        margin-top: 42px;
    }
}

/* Friends：Drink Log 风格的链接标签面板 */
.friends-section {
    margin-top: 0;
    padding-top: clamp(64px, 6vw, 84px);
    padding-bottom: clamp(64px, 6vw, 84px);
    color: var(--space-text);
    background: #fff;
}

.friends-section__layout {
    display: grid;
    grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
    gap: clamp(40px, 6vw, 88px);
    align-items: start;
}

.friends-section__eyebrow {
    margin: 0 0 22px;
}

.friends-section__intro h2 {
    margin: 0;
    color: var(--space-text);
    font-size: clamp(40px, 4.5vw, 58px);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.05em;
}

.friends-section__description {
    max-width: 250px;
    margin: 24px 0 0;
    color: #756970;
    font-size: 14px;
    line-height: 1.8;
}

/* 包住所有友链的统一面板 */
.friends-panel {
    overflow: visible;
    color: var(--space-ink);
    background: var(--space-paper);
    border: 3px solid var(--space-ink);
    border-radius: 0;
    box-shadow: 8px 8px 0 var(--space-coral);
}

.friends-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 20px;
    color: var(--space-ink);
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    border-bottom: 2px dashed var(--space-ink);
}

/* Tag 容器 */
.friends-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 22px 16px;
    align-items: center;
    margin: 0;
    padding: 34px 28px 38px;
}

.friend-tag {
    --tag-shift: 0px;
    --tag-tilt: 0deg;

    position: relative;
    max-width: 100%;
    list-style: none;
    transform: translateY(var(--tag-shift)) rotate(var(--tag-tilt));
    transform-origin: center;
}

/* 受控随机：轻微错位，但每次刷新保持稳定 */
.friend-tag:nth-child(8n + 1) {
    --tag-shift: -5px;
    --tag-tilt: -2.8deg;
}

.friend-tag:nth-child(8n + 2) {
    --tag-shift: 4px;
    --tag-tilt: 2deg;
}

.friend-tag:nth-child(8n + 3) {
    --tag-shift: -3px;
    --tag-tilt: -1.8deg;
}

.friend-tag:nth-child(8n + 4) {
    --tag-shift: 5px;
    --tag-tilt: 2.7deg;
}

.friend-tag:nth-child(8n + 5) {
    --tag-shift: 4px;
    --tag-tilt: -2.2deg;
}

.friend-tag:nth-child(8n + 6) {
    --tag-shift: -5px;
    --tag-tilt: 3deg;
}

.friend-tag:nth-child(8n + 7) {
    --tag-shift: 3px;
    --tag-tilt: 1.7deg;
}

.friend-tag:nth-child(8n + 8) {
    --tag-shift: -4px;
    --tag-tilt: -2.5deg;
}

.friend-tag:hover {
    z-index: 1;
}

/* 单个友链 Tag */
.friend-tag > a {
    --friend-accent: var(--space-coral);

    display: inline-flex;
    max-width: 100%;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 9px 11px;
    color: #fff;
    text-decoration: none;
    background: var(--space-ink);
    border: 2px solid var(--space-ink);
    border-radius: 0;
    box-shadow: 4px 4px 0 var(--friend-accent);
    transition:
        color 100ms steps(2, end),
        background-color 100ms steps(2, end),
        box-shadow 100ms steps(2, end),
        transform 100ms steps(2, end);
}

.friend-tag__prefix {
    flex: 0 0 auto;
    color: var(--friend-accent);
    font-family: "Source Code Pro", monospace;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.friend-tag strong {
    flex: 0 0 auto;
    color: #fff;
    font-family: "Source Code Pro", monospace;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.friend-tag__description {
    max-width: 180px;
    overflow: hidden;
    color: #f3c969;
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-tag__description::before {
    color: var(--space-coral);
    content: "// ";
}

.friend-tag__arrow {
    flex: 0 0 auto;
    color: var(--friend-accent);
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    line-height: 1;
}

.friend-tag > a:hover {
    color: var(--space-ink);
    background: var(--space-paper);
    border-color: var(--space-ink);
    box-shadow: 1px 1px 0 var(--friend-accent);
    transform: translate(3px, 3px);
}

.friend-tag > a:hover strong {
    color: var(--space-ink);
}

/* 三个首页章节的统一分界 */
.projects-section,
.friends-section,
.writing-intro {
    position: relative;
}

.projects-section::before,
.friends-section::before,
.writing-intro::before {
    position: absolute;
    top: 0;
    left: 50%;
    width: min(1200px, calc(100% - 48px));
    height: 3px;
    content: "";
    background: var(--space-ink);
    transform: translateX(-50%);
}

/* 让章节编号成为明显的视觉标签 */
.projects-section__eyebrow,
.friends-section__eyebrow,
.writing-intro__eyebrow {
    display: inline-flex;
    min-height: 27px;
    align-items: center;
    box-sizing: border-box;
    padding: 0 10px;
    color: #fff;
    font-family: "Source Code Pro", monospace;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.15em;
    background: var(--space-ink);
    border: 2px solid var(--space-ink);
    border-radius: 0;
    box-shadow: 4px 4px 0 var(--space-coral);
}

/* 响应式 */
@media screen and (max-width: 960px) {
    .friends-section__layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .friends-section__description {
        max-width: 520px;
        margin-top: 18px;
    }
}

@media screen and (max-width: 680px) {
    .friends-section {
        padding-top: 54px;
        padding-bottom: 54px;
    }

    .friends-panel {
        border-radius: 0;
        box-shadow: 5px 5px 0 var(--space-coral);
    }

    .friends-panel__header {
        padding: 18px;
    }

    .friends-tags {
        gap: 18px 14px;
        padding: 28px 20px 32px;
    }

    .friend-tag__description {
        display: none;
    }

    .projects-section::before,
    .friends-section::before,
    .writing-intro::before {
        width: calc(100% - 36px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .friend-tag > a {
        transition: none;
    }

    .friend-tag > a:hover {
        transform: none;
    }
}
