/* ============================================================
   site.css — 全局共享样式（Shell / Hero / 卡片增强 / 暗黑切换）
   依赖 bunny-ui 的 CSS 变量，深色模式随变量自动适配
   ============================================================ */

/* ---------- 品牌色（PHP 蓝 → tphp 红） ---------- */
:root {
    --tphp-blue: #777BB3;       /* PHP 官方品牌蓝 */
    --tphp-blue-deep: #4F5B93;  /* PHP 深蓝（暗色模式 / hover） */
    --tphp-red: #EF564E;        /* TinyPHP 图标红 */
    --tphp-red-deep: #D13B3A;   /* TinyPHP 深红（暗色模式 / hover） */
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--black);
    background-color: var(--white-shallow);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

::selection { background: var(--default-shallow); color: var(--default); }

a { color: inherit; }

/* 去掉 base.css 中 a:hover 下划线对导航 trigger 的副作用 */
a.trigger, a.trigger:hover { text-decoration: none; }

/* ---------- 布局容器 ---------- */
.site-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.section {
    padding: clamp(48px, 8vw, 96px) 0;
}

.section--tight { padding: clamp(32px, 5vw, 56px) 0; }

.section-head {
    text-align: center;
    max-width: 720px;
    margin: 0 auto clamp(32px, 5vw, 56px);
}

.section-head--left { text-align: left; }

/* 页头（共享：文档/生态/关于） */
.page-hero {
    padding: clamp(48px, 8vw, 88px) 0 clamp(32px, 5vw, 48px);
    background:
        radial-gradient(1000px 400px at 85% -20%, rgba(239, 86, 78, 0.10), transparent 60%),
        radial-gradient(700px 300px at 5% 30%, rgba(119, 123, 179, 0.15), transparent 60%);
    position: relative;
    overflow: hidden;
}
.page-hero .section-title { margin-top: 8px; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tphp-red);
    background: rgba(239, 86, 78, 0.10);
    padding: 4px 14px;
    border-radius: var(--border-radius-full);
    margin-bottom: 16px;
}

.section-title {
    font-size: clamp(1.75rem, 3.5vw, 2.6rem);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    margin: 0 0 12px;
    color: var(--black);
}

.section-subtitle {
    font-size: var(--font-size-16);
    color: var(--black-shallow);
    line-height: 1.7;
    margin: 0;
}

/* ---------- 站点头部 ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.site-header [hx-ext~="bny-nav"] {
    box-shadow: var(--box-shadow-005);
    background:
        linear-gradient(90deg, rgba(119, 123, 179, 0.12) 0%, rgba(239, 86, 78, 0.12) 100%),
        var(--white);
}

html.dark .site-header [hx-ext~="bny-nav"] {
    background:
        linear-gradient(90deg, rgba(119, 123, 179, 0.18) 0%, rgba(239, 86, 78, 0.18) 100%),
        var(--white);
}

/* 导航 logo 文字 */
.site-header .logo-box {
    gap: 12px;
}

.site-header .logo {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-header .logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 主题切换按钮：与 .bny-icon 视觉统一（高度 25.6px、字号 16px） */
#mode-btn { cursor: pointer; }
#mode-btn .mode-icons {
    position: relative;
    width: 16px;
    height: 25.6px;          /* 与框架 .bny-icon 的 line-height 一致，撑开 trigger 高度 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#mode-btn svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    transition: transform .45s cubic-bezier(.4, 0, .2, 1), opacity .3s ease;
}
/* 深浅图标交叉动画：transform 链中 translate(-50%,-50%) 保持居中，rotate/scale 做动画 */
html:not(.dark) .icon-sun   { opacity: 1; transform: translate(-50%, -50%) rotate(0)        scale(1); }
html:not(.dark) .icon-moon  { opacity: 0; transform: translate(-50%, -50%) rotate(-90deg)   scale(.4); }
html.dark      .icon-sun   { opacity: 0; transform: translate(-50%, -50%) rotate(90deg)    scale(.4); }
html.dark      .icon-moon  { opacity: 1; transform: translate(-50%, -50%) rotate(0)        scale(1); }

/* ---------- 站点页脚 ---------- */
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-shallow);
    padding: clamp(40px, 6vw, 64px) 0 32px;
    margin-top: clamp(48px, 8vw, 96px);
}

.site-footer .footer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.site-footer .footer-brand {
    max-width: 360px;
}

.site-footer .footer-brand .logo-line {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-20);
    font-weight: var(--font-weight-semibold);
    color: var(--default);
    margin-bottom: 12px;
}

.site-footer .footer-brand .logo-line img { width: 30px; height: 30px; }

.site-footer .footer-brand p {
    color: var(--black-shallow);
    font-size: var(--font-size-sm);
    line-height: 1.7;
    margin: 0;
}

.site-footer .footer-links {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
}

.site-footer .footer-col h4 {
    font-size: var(--font-size);
    font-weight: var(--font-weight-semibold);
    margin: 0 0 14px;
    color: var(--black);
}

.site-footer .footer-col a {
    display: block;
    color: var(--black-shallow);
    font-size: var(--font-size-sm);
    line-height: 2;
    transition: var(--transition-fast);
}

.site-footer .footer-col a:hover { color: var(--default); }

.site-footer .footer-social {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.site-footer .footer-bottom {
    border-top: 1px solid var(--gray-shallow);
    padding-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    color: var(--black-shallow);
    font-size: var(--font-size-sm);
}

/* ---------- Hero ---------- */
.hero {
    position: relative;
    padding: clamp(72px, 12vw, 140px) 0 clamp(56px, 9vw, 104px);
    overflow: hidden;
    background:
        radial-gradient(1200px 500px at 80% -10%, rgba(239, 86, 78, 0.12), transparent 60%),
        radial-gradient(900px 400px at 10% 20%, rgba(119, 123, 179, 0.18), transparent 55%);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--gray-middle) 1px, transparent 1px);
    background-size: 26px 26px;
    opacity: .35;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 75%);
    pointer-events: none;
}

.hero .hero-inner {
    position: relative;
    z-index: 1;
    max-width: 820px;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: var(--font-weight-semibold);
    line-height: 1.08;
    letter-spacing: -.02em;
    margin: 0 0 20px;
    background: linear-gradient(135deg, var(--tphp-blue) 0%, var(--tphp-red) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.hero-subtitle {
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    color: var(--black-shallow);
    line-height: 1.75;
    max-width: 620px;
    margin: 0 0 32px;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }

.hero-actions .bny-btn { font-size: var(--font-size-16); }

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin-top: 48px;
    padding-top: 28px;
    border-top: 1px solid var(--gray-shallow);
}

.hero-meta .meta-item { display: flex; flex-direction: column; }

.hero-meta .meta-num {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: var(--font-weight-semibold);
    color: var(--default);
    line-height: 1;
}

.hero-meta .meta-label {
    font-size: var(--font-size-sm);
    color: var(--black-shallow);
    margin-top: 6px;
}

/* ---------- 卡片增强 ---------- */
.bny-card[model~="transition"] {
    transition: var(--transition);
    cursor: pointer;
}

.bny-card[model~="transition"]:hover {
    border-color: var(--default-shallow);
    box-shadow: var(--box-shadow-hover-055);
    transform: translateY(-4px);
}

.bny-card[model~="transition"] > img {
    transition: transform var(--transition);
}

.bny-card[model~="transition"]:hover > img {
    transform: scale(1.05);
}

.bny-card > .body { padding: 18px 20px 20px; }
.bny-card > .body > .title { font-size: var(--font-size-16); margin: 0 0 6px; }
.bny-card > .body > .subtitle { font-size: var(--font-size-sm); color: var(--black-shallow); margin: 0 0 10px; }
.bny-card > .body > .content { font-size: var(--font-size-sm); color: var(--black-shallow); line-height: 1.7; margin: 0; }

/* bny-tag 首项去左箭头偏移 */
.bny-tag:first-child { margin-left: 0; }

/* ---------- 通用网格 ---------- */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- 文档正文排版 ---------- */
.prose { max-width: 760px; }
.prose p { line-height: 1.85; color: var(--black-shallow); margin: 0 0 18px; }
.prose h2 { font-size: 1.6rem; margin: 40px 0 16px; }
.prose h3 { font-size: 1.25rem; margin: 32px 0 12px; }
.prose ul, .prose ol { line-height: 1.85; color: var(--black-shallow); padding-left: 22px; }
.prose blockquote { margin: 24px 0; }

/* ---------- 工具类 ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.hidden { display: none; }

/* 页面进入淡入 */
[bny-view].spa-enter { animation: bny-fade-in .4s ease; }
@keyframes bny-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* 响应式：移动端 section 内距收紧 */
@media (max-width: 768px) {
    .site-container { padding: 0 16px; }
    .hero-meta { gap: 20px; }
}

/* 响应式：平板及以下 */
@media (max-width: 992px) {
    .site-footer .footer-links { gap: 32px; }
}

/* 响应式：手机端 */
@media (max-width: 640px) {
    /* 页脚单列布局 */
    .site-footer .footer-grid {
        flex-direction: column;
        gap: 28px;
    }
    .site-footer .footer-links {
        gap: 28px;
        flex-wrap: wrap;
    }
    .site-footer .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 6px;
    }
    /* 段落标题左对齐（手机端不再居中） */
    .section-head { text-align: left; }
    /* 卡片内边距收紧 */
    .bny-card > .body { padding: 16px; }
    /* hero 按钮占满宽度 */
    .hero-actions .bny-btn { flex: 1; }
    .hero-meta { gap: 16px 24px; }
}

/* 预格式化内容（代码块）窄屏滚动 */
pre { overflow-x: auto; max-width: 100%; }

/* ---------- highlight.js 代码块样式 ---------- */
pre code.hljs {
    display: block;
    overflow-x: auto;
    padding: 16px 20px;
    border-radius: var(--border-radius);
    background: #282c34;
    font-size: var(--font-size-sm);
    line-height: 1.7;
    font-family: var(--font-family-mono, "SFMono-Regular", Consolas, Monaco, monospace);
}

pre.hljs {
    padding: 0;
    margin: 0 0 16px;
    border-radius: var(--border-radius);
    overflow: hidden;
}

/* 行内代码 */
.prose code:not(.hljs) {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--gray-shallow);
    color: var(--default);
    font-size: .9em;
    font-family: var(--font-family-mono, "SFMono-Regular", Consolas, Monaco, monospace);
}
