/* 全站共享：设计 token、基础元素、按钮、顶栏、故事卡片、页脚。
   页面专属样式见 home.css / story.css / game.css。
   默认暗色；[data-theme="light"] 为可选浅色。压在原画上的元素在两种主题下都保持暗底亮字。 */

/* ============================================================
   Tokens
   ============================================================ */

:root {
    --font-ui: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei",
        "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --gutter: clamp(16px, 4vw, 40px);
    --topbar-h: 64px;
    --ease-out: cubic-bezier(.2, .7, .2, 1);

    /* 原画上的文字，两种主题都一样 */
    --on-art: #f3efe8;
    --on-art-2: rgba(243, 239, 232, .78);
    --on-art-3: rgba(243, 239, 232, .55);
    --gold: #f2b84b;
    --gold-hover: #ffc965;
    --gold-text: #f5c56a;
    --gold-fg: #1b1306;
}

:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0c10;
    --bg-soft: #101218;
    --surface: #161920;
    --surface-2: #1e2129;
    --line: rgba(255, 255, 255, .08);
    --line-strong: rgba(255, 255, 255, .16);
    --text: #eeeae3;
    --text-2: #b3b1ba;
    --text-3: #8d8c97;
    --accent: #f2b84b;
    --accent-hover: #ffc965;
    --accent-fg: #1b1306;
    --accent-text: #f5c56a;
    --accent-soft: rgba(242, 184, 75, .14);
    --ok: #4ade80;
    --danger: #ff7a7a;
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    --topbar-bg: rgba(11, 12, 16, .72);
    --hero-fade: var(--bg);
    --brand-tile: #1e2129;
    --brand-page: #eeeae3;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f2ed;
    --bg-soft: #ebe8e1;
    --surface: #ffffff;
    --surface-2: #f2efe9;
    --line: rgba(28, 27, 25, .10);
    --line-strong: rgba(28, 27, 25, .20);
    --text: #1c1b19;
    --text-2: #4f4d48;
    --text-3: #6c6a64;
    --accent: #e0a134;
    --accent-hover: #eab04a;
    --accent-fg: #1b1306;
    --accent-text: #8a5a08;
    --accent-soft: rgba(224, 161, 52, .16);
    --ok: #15803d;
    --danger: #c0392b;
    --shadow-lg: 0 24px 60px rgba(30, 25, 15, .18);
    --topbar-bg: rgba(244, 242, 237, .82);
    /* 浅色下首屏底边不往米白渐变，保持干净的暗色画幅 */
    --hero-fade: rgba(11, 12, 16, 0);
    --brand-tile: #1e2129;
    --brand-page: #eeeae3;
}

/* ============================================================
   Base
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar-h) + 16px);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.icon { width: 1.25em; height: 1.25em; flex: none; }

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5em;
    height: 44px;
    padding: 0 1.25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, color .2s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn--sm { height: 36px; padding: 0 1rem; font-size: .85rem; }
.btn--lg { height: 52px; padding: 0 1.6rem; font-size: 1rem; }
.btn .icon { width: 18px; height: 18px; }

.btn--primary { background: var(--accent); color: var(--accent-fg); }
.btn--primary:hover { background: var(--accent-hover); }

.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }

.btn[disabled] { cursor: progress; opacity: .75; }

/* 压在原画上的按钮 */
.on-art .btn--primary { --accent: var(--gold); --accent-hover: var(--gold-hover); --accent-fg: var(--gold-fg); }
.on-art .btn--ghost {
    border-color: rgba(255, 255, 255, .24);
    background: rgba(255, 255, 255, .06);
    color: var(--on-art);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.on-art .btn--ghost:hover { background: rgba(255, 255, 255, .12); }

.icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[disabled] { opacity: .3; cursor: default; background: transparent; }
.icon-btn .icon { width: 20px; height: 20px; }

/* 请求中：文字与图标透明，居中一个转圈 */
.is-loading { color: transparent !important; }
.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid var(--accent-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    background: var(--topbar-bg);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 32px;
    height: 100%;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex: none;
}
.brand__mark { width: 30px; height: 30px; flex: none; }
.brand__name {
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.topnav { display: flex; gap: 28px; }
.topnav a {
    color: var(--text-2);
    font-size: .92rem;
    text-decoration: none;
    transition: color .2s;
}
.topnav a:hover { color: var(--text); }

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

[data-theme="dark"] .icon--moon,
[data-theme="light"] .icon--sun { display: none; }

/* ============================================================
   Story card（首页货架、详情页相关推荐共用）
   ============================================================ */

.card {
    position: relative;
    isolation: isolate;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    scroll-snap-align: start;
    box-shadow: 0 0 0 1px var(--line);
    transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}

.card__link {
    position: absolute;
    inset: 0;
    display: block;
    color: var(--on-art);
    text-decoration: none;
}
.card__link:focus-visible { outline-offset: -3px; border-radius: var(--radius-md); }

.card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .6s var(--ease-out);
}

.card__link::before,
.card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    transition: opacity .35s var(--ease-out);
}
.card__link::before {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, .55) 64%, rgba(0, 0, 0, .92) 100%);
}
/* 悬停展开简介时文字区变高，换一层更深的遮罩保证可读 */
.card__link::after {
    background: linear-gradient(180deg, rgba(0, 0, 0, .05) 0%, rgba(0, 0, 0, .6) 38%, rgba(0, 0, 0, .95) 100%);
    opacity: 0;
}

/* 有剧本（好感、章节、多结局）的故事 */
.card__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(11, 12, 16, .62);
    backdrop-filter: blur(6px);
    color: var(--gold-text);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .06em;
}

.card__body {
    position: absolute;
    inset: auto 0 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px 14px 15px;
}
.card__body p { margin: 0; }
.card__tags { color: var(--gold-text); font-size: .72rem; font-weight: 600; letter-spacing: .06em; }
.card__title {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.38;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.card__meta { color: rgba(255, 255, 255, .66); font-size: .75rem; }
.card__desc {
    display: -webkit-box;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    color: rgba(255, 255, 255, .84);
    font-size: .8rem;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    transition: max-height .4s var(--ease-out), opacity .3s, margin-top .4s var(--ease-out);
}

.card__play {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--gold);
    color: var(--gold-fg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .4);
    cursor: pointer;
    opacity: 0;
    transform: scale(.85);
    transition: opacity .25s, transform .25s var(--ease-out), background-color .2s;
}
.card__play .icon { width: 18px; height: 18px; margin-left: 2px; }
.card__play:hover { background: var(--gold-hover); }
.card__play:focus-visible,
.card__play.is-loading { opacity: 1; transform: none; }
.card__play.is-loading::after { border-color: var(--gold-fg); border-right-color: transparent; }

@media (hover: hover) {
    .card:hover,
    .card:focus-within {
        transform: translateY(-4px);
        box-shadow: 0 18px 40px rgba(0, 0, 0, .45), 0 0 0 1px rgba(242, 184, 75, .6);
    }
    .card:hover .card__img,
    .card:focus-within .card__img { transform: scale(1.06); }
    .card:hover .card__link::after,
    .card:focus-within .card__link::after { opacity: 1; }
    .card:hover .card__desc,
    .card:focus-within .card__desc { max-height: 4.8em; margin-top: 4px; opacity: 1; }
    .card:hover .card__play,
    .card:focus-within .card__play { opacity: 1; transform: none; }
}

/* 触屏没有悬停：开始按钮常驻，点卡片本身进详情 */
@media (hover: none) {
    .card__play { width: 38px; height: 38px; opacity: 1; transform: none; }
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    padding-block: 48px 32px;
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
}

.footer__bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    color: var(--text-3);
    font-size: .82rem;
}
.footer__bottom .brand__name { color: var(--text-2); font-size: .95rem; }

/* ============================================================
   Responsive / motion
   ============================================================ */

@media (max-width: 720px) {
    .topnav { display: none; }
    .topbar__inner { gap: 12px; }
}

@media (max-width: 380px) {
    .brand__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        transition-delay: 0s !important;
    }
}
