/* ========================================
   MiniTavern Common Styles
   共用样式文件 - 用于所有协议页面和Tutorial页面
   ======================================== */

/* CSS Variables - 颜色主题变量 */
:root {
    --bg-color: #f0f2f5;
    --text-color: #333;
    --title-color: #000;
    --secondary-text-color: #555;
    --border-color: #e5e5e5;
    --link-color: #000000;
    --link-hover-color: #333333;
    --card-bg: #fff;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --highlight-bg: #e9ecef;
    --gradient-start: #666;
    --gradient-end: #111;
}

html.dark-mode {
    --bg-color: #1c1c1e;
    --text-color: #c7c7cc;
    --title-color: #fff;
    --secondary-text-color: #8e8e93;
    --border-color: #38383a;
    --link-color: #ffffff;
    --link-hover-color: #f0f0f0;
    --card-bg: #2c2c2e;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --highlight-bg: #3a3a3c;
    --gradient-start: #ccc;
    --gradient-end: #eee;
}

/* Global Box Sizing and Overflow Control - 全局盒模型和溢出控制 */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

/* Selection Styles - 文本选择样式 */
::selection {
    background-color: #333;
    color: #fff;
}

html.dark-mode ::selection {
    background-color: #fff;
    color: #1c1c1e;
}

/* Base Styles - 基础样式 */
body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Container - 容器 */
.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    width: 100%;
    overflow-x: hidden;
}

/* Typography - 排版 */
h1, h2, h3 {
    color: var(--title-color);
}

h1 {
    text-align: center;
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.2rem;
    margin-top: 2rem;
}

p, li {
    color: var(--secondary-text-color);
    margin-bottom: 1rem;
}

ul {
    padding-left: 20px;
}

strong {
    color: var(--title-color);
}

/* Links - 链接 */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: none;
}

/* Footer - 页脚 */
footer {
    text-align: center;
    margin-top: 5rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    color: var(--secondary-text-color);
}

footer a {
    color: var(--link-color);
    text-decoration: none;
}

footer a:hover {
    color: var(--link-hover-color);
}

/* Home Button - 首页按钮 */
.home-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 8px 16px;
    background-color: var(--card-bg);
    color: var(--title-color);
    border-radius: 20px;
    box-shadow: 0 4px 12px var(--shadow-color);
    cursor: pointer;
    z-index: 1001;
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.2s;
}

.home-btn:hover {
    transform: scale(1.05);
}

/* Theme Switcher - 主题切换器 */
.theme-switch-wrapper {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.theme-switch {
    background: var(--highlight-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.theme-switch:hover {
    background: var(--border-color);
}

.theme-switch svg {
    width: 20px;
    height: 20px;
    color: var(--title-color);
    transition: color 0.3s;
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

html.dark-mode .sun-icon {
    display: block;
}

html.dark-mode .moon-icon {
    display: none;
}

/* Back to Top Button - 返回顶部按钮 */
.back-to-top-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-40px);
    padding: 8px 16px;
    background-color: var(--card-bg);
    color: var(--title-color);
    border-radius: 20px;
    box-shadow: 0 4px 12px var(--shadow-color);
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    font-weight: 700;
}

.back-to-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.back-to-top-btn.hiding {
    opacity: 0;
    transform: translateX(-50%) translateY(-40px);
}

/* Disable Text Selection - 禁用文本选择 */
footer,
.home-btn,
.back-to-top-btn {
    user-select: none;
    -webkit-user-select: none;
}

/* Font Themes - 字体主题 */
.font-lato {
    font-family: 'Lato', sans-serif;
}

.font-serif {
    font-family: Georgia, serif;
}

.font-mono {
    font-family: 'Courier New', monospace;
}

.font-cursive {
    font-family: 'Comic Sans MS', cursive;
}

.font-fantasy {
    font-family: Impact, fantasy;
}

/* Responsive - 响应式 */
@media (max-width: 600px) {
    .container {
        margin: 1rem auto;
        padding: 0 1rem;
        max-width: 100%;
    }

    body {
        min-width: 100%;
        max-width: 100vw;
    }

    h1, h2, h3, p, li, a, strong {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }

    /* 确保所有内容元素不超出屏幕 */
    section, main, header, footer {
        max-width: 100%;
        overflow-x: hidden;
    }
}
