/*
 * 微语时间轴。
 *
 * 只依赖 theme.css 已经定义好的那几个变量（--ink / --muted / --line / --radius / --dur / --motion），
 * 不另起一套配色 —— 微语是站点的内容页之一，换主题时它应该跟着变色，而不是自带一套色板。
 *
 * 版式的两个关键决定：
 * 1. 竖线是 .memo__rail 上的一条 border-right，不是绝对定位的伪元素：
 *    这样线的高度天然等于这一条微语的高度，不需要给容器算总高。
 * 2. 文字用 white-space: pre-wrap，正文里的换行按原样显示 —— 数据库存的是纯文本，
 *    如果不在 CSS 里保留换行，用户在编辑框里分段写的东西会挤成一段。
 */

.memo-page {
    padding: 56px 0 72px;
}

.memo-hero {
    max-width: 720px;
    margin-bottom: 44px;
}

.memo-hero__eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--mkt-accent, #2563eb);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.memo-hero__title {
    margin: 0 0 10px;
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 800;
    line-height: 1.15;
    color: var(--ink, #111);
}

.memo-hero__sub {
    margin: 0;
    color: var(--muted, #777);
    font-size: 15px;
    line-height: 1.7;
}

/* ------------------------------------------------------------ 时间轴 */

.memo-timeline {
    max-width: 760px;
}

.memo {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 4px;
}

/* 轨道：一条贯穿整列的头像线，最后一条不画到底，避免页面尾部多出一截悬空的线 */
.memo__rail {
    position: relative;
    display: flex;
    justify-content: center;
    border-right: 1px solid var(--line, #eaeaea);
}

.memo:last-child .memo__rail {
    border-right-color: transparent;
}

.memo__dot {
    position: absolute;
    top: 22px;
    width: 9px;
    height: 9px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--mkt-accent, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mkt-accent, #2563eb) 16%, transparent);
}

.memo__body {
    padding: 18px 20px;
    margin-bottom: 18px;
    border: 1px solid var(--line, #eaeaea);
    border-radius: var(--radius, 14px);
    background: #fff;
    transition: transform var(--dur, 0.3s) var(--motion, cubic-bezier(0.2, 0.7, 0.3, 1)),
        box-shadow var(--dur, 0.3s) var(--motion, cubic-bezier(0.2, 0.7, 0.3, 1)),
        border-color var(--dur, 0.3s) var(--motion, cubic-bezier(0.2, 0.7, 0.3, 1));
}

.memo__body:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--mkt-accent, #2563eb) 35%, var(--line, #eaeaea));
    box-shadow: 0 12px 26px rgb(17 17 17 / 7%);
}

/* ------------------------------------------------------------ 头 */

.memo__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.memo__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #14304f, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    user-select: none;
}

.memo__who {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.memo__author {
    color: var(--ink, #111);
    font-size: 14px;
    font-weight: 700;
}

.memo__time {
    color: var(--muted, #999);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.memo__pin {
    padding: 2px 9px;
    margin-left: auto;
    flex: none;
    border-radius: 999px;
    background: color-mix(in srgb, var(--mkt-accent, #2563eb) 12%, #fff);
    color: var(--mkt-accent, #2563eb);
    font-size: 12px;
    font-weight: 600;
}

/* ------------------------------------------------------------ 正文 */

.memo__text {
    margin: 0 0 12px;
    color: var(--ink, #222);
    font-size: 15.5px;
    line-height: 1.85;
    /* 编辑框里敲的换行要看得见：纯文本正文全靠它分段 */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ 配图 */

.memo__images {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
}

.memo__img {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 1;
    border-radius: 8px;
    background: var(--soft, #f6f6f7);
}

.memo__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--dur, 0.3s) var(--motion, cubic-bezier(0.2, 0.7, 0.3, 1));
}

.memo__img:hover img {
    transform: scale(1.04);
}

/*
 * 单图不走九宫格：一张图占满一格的三分之一太小了，观感像缩略图。
 * 给它一个上限宽度（560px），并且保留原始比例 —— 竖图不会被拉成正方形。
 */
.memo__images--single {
    display: block;
}

.memo__images--single .memo__img {
    width: auto;
    max-width: 560px;
    aspect-ratio: auto;
}

.memo__images--single .memo__img img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: contain;
}

/* ------------------------------------------------------------ 脚 */

.memo__foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--muted, #999);
    font-size: 12.5px;
}

.memo__loc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.memo__loc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentcolor;
    opacity: 0.5;
}

.memo__stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-variant-numeric: tabular-nums;
}

.memo-empty {
    max-width: 760px;
    padding: 56px 0;
    border: 1px dashed var(--line, #eaeaea);
    border-radius: var(--radius, 14px);
    color: var(--muted, #999);
    text-align: center;
}

/* ------------------------------------------------------------ 断点 */

@media (max-width: 640px) {
    .memo-page {
        padding: 36px 0 56px;
    }

    .memo {
        grid-template-columns: 24px minmax(0, 1fr);
    }

    .memo__body {
        padding: 14px 14px;
    }

    .memo__dot {
        top: 18px;
    }

    .memo__images {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .memo__body,
    .memo__img img {
        transition: none;
    }

    .memo__body:hover {
        transform: none;
    }
}

/* ------------------------------------------------------------ 弹幕墙 */

/*
 * 页面顶部那一大块：按热度抽出来的微语在轨道上从右往左飘。
 *
 * 高度写死 220px、轨道数写死 12 —— 轨道位置由模板算好（--track: 0~11），
 * 这里只负责把它换算成 top 的百分比。不用 JS 计算，也不依赖元素实际高度，
 * 所以首屏不会出现「脚本没跑完时一堆弹幕叠在第一行」。
 */
.memo-bullets {
    position: relative;
    height: 220px;
    overflow: hidden;
    border-bottom: 1px solid var(--line, #eaeaea);
    background:
        radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--mkt-accent, #2563eb) 10%, transparent), transparent 55%),
        radial-gradient(circle at 82% 76%, color-mix(in srgb, var(--mkt-accent, #2563eb) 7%, transparent), transparent 58%),
        #fbfbfc;
    /* 两端淡出：弹幕从边外飞进来时不会「啪」地出现在屏幕边缘 */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}

.memo-bullets__band {
    position: absolute;
    top: calc(var(--track, 0) * (220px - 34px) / 11);
    left: 0;
    white-space: nowrap;
    animation: memo-bullet-fly var(--dur, 24s) linear infinite;
    animation-delay: var(--delay, 0s);
    will-change: transform;
}

.memo-bullets__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 78vw;
    padding: 5px 14px;
    border: 1px solid var(--line, #eaeaea);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 4px 14px rgb(17 17 17 / 5%);
    color: var(--ink, #333);
    font-size: 13.5px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memo-bullets__mood {
    flex: none;
    font-size: 14px;
}

@keyframes memo-bullet-fly {
    from {
        transform: translate3d(100vw, 0, 0);
    }

    to {
        transform: translate3d(calc(-100vw - 110%), 0, 0);
    }
}

/* ------------------------------------------------------------ 点赞 / 评论 */

.memo__act {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 12.5px;
    line-height: 1.6;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.memo__act:hover {
    border-color: var(--line, #eaeaea);
    background: color-mix(in srgb, var(--mkt-accent, #2563eb) 6%, transparent);
    color: var(--mkt-accent, #2563eb);
}

.memo__act:active {
    transform: scale(0.97);
}

/* 点赞点亮是红的（国内习惯：赞 = 红），不跟主题强调色走 */
.memo__act--like.is-on {
    color: #e0484f;
    border-color: color-mix(in srgb, #e0484f 28%, transparent);
    background: color-mix(in srgb, #e0484f 8%, transparent);
}

.memo__act--like.is-on:hover {
    color: #e0484f;
    border-color: color-mix(in srgb, #e0484f 45%, transparent);
    background: color-mix(in srgb, #e0484f 12%, transparent);
}

.memo__act-icon {
    font-size: 13px;
    line-height: 1;
}

.memo__act-num {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ 评论浮层 */

.memo-dialog {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.memo-dialog[hidden] {
    display: none;
}

.memo-dialog__mask {
    position: absolute;
    inset: 0;
    background: rgb(17 17 17 / 42%);
    backdrop-filter: blur(2px);
}

.memo-dialog__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(680px, 100%);
    max-height: min(82vh, 760px);
    overflow: hidden;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 64px rgb(0 0 0 / 24%);
}

.memo-dialog__head {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line, #eaeaea);
}

.memo-dialog__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink, #111);
}

.memo-dialog__close {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted, #888);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.memo-dialog__close:hover {
    background: var(--soft, #f4f4f5);
    color: var(--ink, #111);
}

.memo-dialog__body {
    flex: 1;
    min-height: 0;
    padding: 4px 18px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* 浮层打开时把背后的页面定住，滚轮只滚评论 */
body.memo-locked {
    overflow: hidden;
}

@media (max-width: 640px) {
    .memo-bullets {
        height: 168px;
    }

    .memo-bullets__band {
        top: calc(var(--track, 0) * (168px - 32px) / 11);
    }

    .memo-bullets__item {
        font-size: 12.5px;
    }

    .memo-dialog {
        padding: 0;
        align-items: flex-end;
    }

    .memo-dialog__panel {
        width: 100%;
        max-height: 86vh;
        border-radius: 14px 14px 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* 动效敏感的用户不该被一整屏移动文字糊住：整块弹幕墙直接不画 */
    .memo-bullets {
        display: none;
    }

    .memo__act:active {
        transform: none;
    }
}
