/**
 * 爱平小世界 - 响应式样式
 * 适配桌面端、平板、手机端
 * 需求: 1.3
 */

/* ========== 断点定义 ========== */
/*
 * 移动端优先设计
 * xs: < 576px (手机竖屏)
 * sm: >= 576px (手机横屏)
 * md: >= 768px (平板)
 * lg: >= 992px (小型桌面)
 * xl: >= 1200px (大型桌面)
 * xxl: >= 1400px (超大屏幕)
 */

/* ========== 基础移动端样式 (< 576px) ========== */

/* 容器 */
.container {
    padding: 0 var(--spacing-sm);
}

/* 导航栏 - 移动端 */
.navbar {
    padding: var(--spacing-xs) 0;
}

.navbar-brand {
    font-size: 1rem;
}

/* 遮罩层 */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 汉堡菜单动画 */
.navbar-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* 标题 */
h1, .h1 {
    font-size: var(--font-size-2xl);
}

h2, .h2 {
    font-size: var(--font-size-xl);
}

h3, .h3 {
    font-size: var(--font-size-lg);
}

/* 卡片 */
.card {
    padding: var(--spacing-md);
}

/* 翻转卡片 */
.flip-card {
    height: 250px;
}

/* 按钮 - 移动端优化 */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
    width: 100%;
    min-height: 48px;
}

.btn-group {
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* 表单 - 移动端优化 */
.form-input,
.form-textarea {
    font-size: 16px; /* 防止iOS缩放 */
    padding: var(--spacing-md);
}

/* 头像 */
.avatar {
    width: 80px;
    height: 80px;
}

.avatar-lg {
    width: 120px;
    height: 120px;
}

/* 网格布局 */
.grid {
    display: grid;
    gap: var(--spacing-md);
}

.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

/* 隐藏/显示 */
.hide-mobile { display: none !important; }
.show-mobile { display: block !important; }

/* 间距调整 */
.section {
    padding: var(--spacing-xl) 0;
}

.hero-section {
    padding-top: calc(60px + var(--spacing-xl));
    min-height: auto;
}

/* 文字大小 */
.text-responsive {
    font-size: var(--font-size-sm);
}

/* ========== 测试页面移动端适配 ========== */
.test-section {
    padding-top: calc(70px + var(--spacing-md));
    min-height: 100vh;
}

.test-start,
.test-progress,
.test-result {
    padding: var(--spacing-md) !important;
    margin: 0 var(--spacing-xs);
}

.test-icon,
.result-icon {
    font-size: 3rem !important;
}

.test-info {
    padding: var(--spacing-sm) !important;
}

.test-info .d-flex {
    flex-direction: column;
    gap: var(--spacing-sm);
}

.info-item {
    justify-content: center;
}

/* 题目选项移动端优化 */
.option-item {
    padding: var(--spacing-md);
    font-size: var(--font-size-base);
}

.option-radio {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.question-text {
    font-size: var(--font-size-lg) !important;
    line-height: 1.6;
}

/* 测试导航按钮 */
.test-nav {
    flex-direction: column;
    gap: var(--spacing-sm);
}

.test-nav .btn {
    width: 100%;
}

/* 结果页面移动端 */
.score-circle {
    width: 130px;
    height: 130px;
}

.score-number {
    font-size: 2.5rem;
}

.scores-grid {
    grid-template-columns: 1fr !important;
}

.result-actions {
    flex-direction: column;
    gap: var(--spacing-sm);
}

.result-actions .btn {
    width: 100%;
}

/* ========== 留言页面移动端适配 ========== */
.messages-section {
    padding-top: calc(70px + var(--spacing-md));
}

.messages-header {
    padding: 0 var(--spacing-xs);
}

.message-form-wrapper {
    padding: var(--spacing-md) !important;
    margin: 0 var(--spacing-xs);
}

.messages-list-wrapper {
    padding: 0 var(--spacing-xs);
}

.message-card {
    padding: var(--spacing-md);
}

.message-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-xs);
}

.message-content {
    font-size: var(--font-size-base);
    line-height: 1.8;
}

/* ========== 首页移动端适配 - 简洁文字风格 ========== */
.welcome-section {
    padding: 80px var(--spacing-sm) 40px;
    min-height: 100vh;
    min-height: 100svh; /* 使用svh避免移动端地址栏导致的滚动问题 */
}

.welcome-content {
    padding: 0 15px;
    max-width: 100%;
}

/* 散落图标移动端 */
.scatter-icons {
    display: block;
}

.scatter-icon {
    font-size: 1.2rem;
    opacity: 0.5;
}

.si-1 { top: 12%; left: 5%; }
.si-2 { top: 20%; right: 8%; font-size: 1rem; }
.si-3 { top: 40%; left: 3%; }
.si-4 { top: 55%; right: 5%; font-size: 1.4rem; }
.si-5 { bottom: 35%; left: 8%; font-size: 1.1rem; }
.si-6 { bottom: 28%; right: 10%; }
.si-7 { top: 32%; right: 3%; font-size: 1.2rem; }
.si-8 { bottom: 45%; left: 5%; font-size: 1.5rem; opacity: 0.3; }

/* 问候语 - 响应式字体（放大） */
.hero-greeting {
    font-size: clamp(1.8rem, 7vw, 2.2rem);
    margin-bottom: 1rem;
    color: var(--color-light-blue);
    font-weight: 500;
}

/* 主标题 - 响应式字体（放大） */
.hero-main-title {
    font-size: clamp(2rem, 8vw, 3rem);
    line-height: 1.5;
    margin-bottom: 1.2rem;
    font-weight: 600;
    color: var(--color-text-dark);
}

/* 渐变文字在移动端保持一致 */
.hero-main-title .gradient-text {
    background: linear-gradient(135deg, #5bb5d6, #7ec8e3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* 特色标签 - 强制一行显示 */
.hero-traits {
    font-size: clamp(0.7rem, 3.5vw, 0.9rem);
    margin-bottom: 1.5rem;
    color: var(--color-text);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* 按钮 - 保持水平排列与PC端一致 */
.hero-buttons {
    flex-direction: row;
    gap: 0.8rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.btn-primary-hero,
.btn-secondary-hero {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    white-space: nowrap;
    flex: 1;
    max-width: 140px;
}

/* 滚动提示 - 与PC端一致 */
.scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.scroll-hint-text {
    font-size: 0.8rem;
    color: var(--color-text-light);
}

.scroll-hint-arrow {
    font-size: 0.9rem;
}

/* 故事时间线移动端 */
.story-section {
    padding: 60px 0;
}

.section-title {
    font-size: 1.5rem;
}

.story-timeline {
    padding-left: 20px;
}

.story-timeline::before {
    width: 3px;
}

.timeline-dot {
    left: -28px;
    width: 12px;
    height: 12px;
}

.timeline-content {
    padding: var(--spacing-md);
    margin-left: 10px;
}

.timeline-icon {
    font-size: 1.5rem;
}

.timeline-content h3 {
    font-size: 1.1rem;
}

.timeline-content p {
    font-size: 0.9rem;
}

.timeline-tags {
    gap: 0.4rem;
}

.mini-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

/* 缘分签移动端 */
.fortune-section {
    padding: 60px 0;
}

.fortune-box {
    width: 150px;
    height: 220px;
}

.stick-body {
    width: 25px;
    height: 180px;
}

.fortune-result {
    padding: var(--spacing-md);
    margin: 0 var(--spacing-sm);
}

.fortune-level {
    font-size: 1.5rem;
}

.fortune-text {
    font-size: 1rem;
}

/* 翻书效果移动端 */
.feelings-section {
    padding: 60px 0;
}

.book-container {
    padding: 0 var(--spacing-sm);
}

.book {
    height: 320px;
}

.book-page {
    padding: var(--spacing-md);
}

.page-content h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.page-content p {
    font-size: 0.95rem;
    line-height: 1.8;
}

.book-nav {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.book-btn {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
}

/* 图片画廊移动端 */
.gallery-section {
    padding: 60px 0;
}

.gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0 var(--spacing-sm);
}

.gallery-item {
    height: 150px;
    border-radius: 15px;
}

.gallery-icon {
    font-size: 2rem;
}

.gallery-overlay p {
    font-size: 0.85rem;
    padding: 0.5rem;
}

/* CTA区域移动端 */
.cta-section {
    padding: 60px 0;
}

.cta-card {
    padding: 2rem var(--spacing-md);
    margin: 0 var(--spacing-sm);
}

.cta-icon {
    font-size: 3rem;
}

.cta-card h2 {
    font-size: 1.5rem;
}

.cta-quote {
    font-size: 0.95rem;
}

.cta-buttons {
    flex-direction: column;
    gap: 0.8rem;
}

.cta-buttons .btn {
    width: 100%;
}

/* 返回顶部按钮移动端 */
.back-to-top {
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
}

/* 页脚移动端 */
.footer {
    padding: var(--spacing-lg) 0;
}

.footer-text {
    font-size: var(--font-size-xs);
}

/* ========== 小型手机横屏 (>= 576px) ========== */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
    
    .btn {
        width: auto;
    }
    
    .btn-group {
        flex-direction: row;
    }
    
    .grid-sm-2 { grid-template-columns: repeat(2, 1fr); }
    
    .flip-card {
        height: 280px;
    }
    
    /* 测试页面 */
    .test-start,
    .test-progress,
    .test-result {
        padding: var(--spacing-lg) !important;
    }
    
    .test-nav {
        flex-direction: row;
    }
    
    .test-nav .btn {
        width: auto;
    }
    
    /* 首页 - 简洁文字风格 */
    .welcome-section {
        padding: 80px var(--spacing-sm) 40px;
    }
    
    .welcome-content {
        padding: 0 20px;
    }
    
    .hero-greeting {
        font-size: 1.05rem;
        margin-bottom: 1rem;
    }
    
    .hero-main-title {
        font-size: 1.7rem;
        line-height: 1.5;
        margin-bottom: 1.2rem;
    }
    
    .hero-traits {
        font-size: 1rem;
        margin-bottom: 1.8rem;
    }
    
    .hero-buttons {
        gap: 1rem;
        margin-bottom: 2.5rem;
    }
    
    .btn-primary-hero,
    .btn-secondary-hero {
        padding: 0.8rem 1.6rem;
        font-size: 0.9rem;
    }
    
    .scroll-hint-text {
        font-size: 0.85rem;
    }
    
    .scroll-hint-arrow {
        font-size: 1rem;
    }
    
    .scatter-icon {
        font-size: 1.4rem;
        opacity: 0.6;
    }
    
    /* 画廊 */
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .gallery-item {
        height: 180px;
    }
    
    /* CTA */
    .cta-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .cta-buttons .btn {
        width: auto;
    }
    
    /* 结果页面 */
    .result-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .result-actions .btn {
        width: auto;
    }
}

/* ========== 平板 (>= 768px) ========== */
@media (min-width: 768px) {
    /* 容器 */
    .container {
        max-width: 720px;
        padding: 0 var(--spacing-md);
    }
    
    /* 导航栏 - 平板及以上：重置移动端样式 */
    .navbar-nav {
        display: flex;
        position: static;
        flex-direction: row;
        width: auto;
        height: auto;
        right: auto;
        top: auto;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding: 0;
        box-shadow: none;
        gap: var(--spacing-sm);
        overflow: visible;
        z-index: auto;
    }
    
    .navbar-nav .nav-link {
        padding: var(--spacing-xs) var(--spacing-sm);
        border-bottom: none;
        font-size: var(--font-size-base);
        display: inline-block;
        background: transparent;
    }
    
    .navbar-nav .nav-link.active {
        background: rgba(126, 184, 218, 0.15);
    }
    
    .navbar-toggle {
        display: none;
    }
    
    .nav-overlay {
        display: none;
    }
    
    /* 标题 */
    h1, .h1 {
        font-size: var(--font-size-3xl);
    }
    
    h2, .h2 {
        font-size: var(--font-size-2xl);
    }
    
    /* 卡片 */
    .card {
        padding: var(--spacing-lg);
    }
    
    /* 翻转卡片 */
    .flip-card {
        height: 300px;
    }
    
    /* 按钮 */
    .btn {
        padding: var(--spacing-sm) var(--spacing-lg);
        font-size: var(--font-size-base);
        min-height: auto;
    }
    
    /* 网格 */
    .grid-md-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-md-3 { grid-template-columns: repeat(3, 1fr); }
    
    /* 隐藏/显示 */
    .hide-tablet { display: none !important; }
    .show-tablet { display: block !important; }
    .hide-mobile { display: block !important; }
    .show-mobile { display: none !important; }
    
    /* 间距 */
    .section {
        padding: var(--spacing-xl) 0;
    }
    
    .hero-section {
        padding-top: calc(70px + var(--spacing-xl));
        min-height: 80vh;
    }
    
    /* 文字 */
    .text-responsive {
        font-size: var(--font-size-base);
    }
    
    /* 两列布局 */
    .two-column {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-lg);
        align-items: center;
    }
    
    /* 侧边栏布局 */
    .sidebar-layout {
        display: grid;
        grid-template-columns: 250px 1fr;
        gap: var(--spacing-lg);
    }
    
    /* ========== 测试页面平板适配 ========== */
    .test-section {
        padding-top: calc(80px + var(--spacing-xl));
    }
    
    .test-start,
    .test-progress,
    .test-result {
        padding: var(--spacing-xl) !important;
    }
    
    .test-icon,
    .result-icon {
        font-size: 4rem !important;
    }
    
    .test-info .d-flex {
        flex-direction: row;
    }
    
    .question-text {
        font-size: var(--font-size-xl) !important;
    }
    
    .scores-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* ========== 留言页面平板适配 ========== */
    .messages-section {
        padding-top: calc(80px + var(--spacing-xl));
    }
    
    .message-form-wrapper {
        padding: var(--spacing-lg) !important;
    }
    
    .message-header {
        flex-direction: row;
        align-items: center;
    }
    
    /* ========== 首页平板适配 - 简洁文字风格 ========== */
    .welcome-section {
        padding: 100px var(--spacing-md) 60px;
    }
    
    .hero-greeting {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .hero-main-title {
        font-size: 2.2rem;
        margin-bottom: 1.5rem;
    }
    
    .hero-traits {
        font-size: 1.1rem;
        margin-bottom: 2rem;
    }
    
    .btn-primary-hero,
    .btn-secondary-hero {
        padding: 0.9rem 2rem;
        font-size: 0.95rem;
    }
    
    .scatter-icon {
        font-size: 1.5rem;
        opacity: 0.6;
    }
    
    /* 故事时间线平板 */
    .story-section {
        padding: 100px 0;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .story-timeline {
        padding-left: 30px;
    }
    
    .timeline-dot {
        left: -38px;
        width: 16px;
        height: 16px;
    }
    
    .timeline-content {
        padding: 1.5rem;
        margin-left: 20px;
    }
    
    .timeline-icon {
        font-size: 2rem;
    }
    
    .timeline-content h3 {
        font-size: 1.25rem;
    }
    
    .timeline-content p {
        font-size: 1rem;
    }
    
    .mini-tag {
        font-size: 0.75rem;
        padding: 0.25rem 0.75rem;
    }
    
    /* 缘分签平板 */
    .fortune-section {
        padding: 100px 0;
    }
    
    .fortune-box {
        width: 200px;
        height: 300px;
    }
    
    .stick-body {
        width: 30px;
        height: 250px;
    }
    
    .fortune-result {
        padding: 2rem;
    }
    
    .fortune-level {
        font-size: 2rem;
    }
    
    .fortune-text {
        font-size: 1.1rem;
    }
    
    /* 翻书效果平板 */
    .feelings-section {
        padding: 100px 0;
    }
    
    .book {
        height: 350px;
    }
    
    .book-page {
        padding: 2rem;
    }
    
    .page-content h3 {
        font-size: 1.5rem;
    }
    
    .page-content p {
        font-size: 1.1rem;
    }
    
    .book-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }
    
    /* 图片画廊平板 */
    .gallery-section {
        padding: 100px 0;
    }
    
    .gallery-grid {
        gap: 1.5rem;
    }
    
    .gallery-item {
        height: 200px;
        border-radius: 20px;
    }
    
    .gallery-icon {
        font-size: 3rem;
    }
    
    .gallery-overlay p {
        font-size: 1rem;
    }
    
    /* CTA区域平板 */
    .cta-section {
        padding: 100px 0;
    }
    
    .cta-card {
        padding: 4rem;
    }
    
    .cta-icon {
        font-size: 4rem;
    }
    
    .cta-card h2 {
        font-size: 2rem;
    }
    
    .cta-quote {
        font-size: 1.1rem;
    }
    
    /* 返回顶部按钮平板 */
    .back-to-top {
        bottom: 30px;
        right: 30px;
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* 页脚平板 */
    .footer {
        padding: var(--spacing-xl) 0;
    }
    
    .footer-text {
        font-size: var(--font-size-sm);
    }
}

/* ========== 小型桌面 (>= 992px) ========== */
@media (min-width: 992px) {
    /* 容器 */
    .container {
        max-width: 960px;
    }
    
    /* 导航 */
    .navbar-nav {
        gap: var(--spacing-md);
    }
    
    /* 网格 */
    .grid-lg-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-lg-4 { grid-template-columns: repeat(4, 1fr); }
    
    /* 隐藏/显示 */
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
    
    /* 翻转卡片 */
    .flip-card {
        height: 320px;
    }
    
    /* 侧边栏布局 */
    .sidebar-layout {
        grid-template-columns: 280px 1fr;
    }
    
    /* 三列布局 */
    .three-column {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-lg);
    }
}

/* ========== 大型桌面 (>= 1200px) ========== */
@media (min-width: 1200px) {
    /* 容器 */
    .container {
        max-width: 1140px;
    }
    
    .container-lg {
        max-width: 1320px;
    }
    
    /* 网格 */
    .grid-xl-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-xl-5 { grid-template-columns: repeat(5, 1fr); }
    
    /* 间距 */
    .section {
        padding: calc(var(--spacing-xl) * 1.5) 0;
    }
    
    /* 翻转卡片 */
    .flip-card {
        height: 350px;
    }
}

/* ========== 超大屏幕 (>= 1400px) ========== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .container-lg {
        max-width: 1400px;
    }
}

/* ========== 特殊设备适配 ========== */

/* 高分辨率屏幕 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 确保图片清晰 */
    .avatar,
    .logo {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        min-height: auto;
        padding: var(--spacing-lg) 0;
    }
    
    .navbar {
        padding: var(--spacing-xs) 0;
    }
}

/* 触摸设备 */
@media (hover: none) and (pointer: coarse) {
    /* 增大点击区域 */
    .nav-link,
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 禁用悬停效果 */
    .hover-lift:hover,
    .hover-scale:hover,
    .hover-glow:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* 翻转卡片改为点击触发 */
    .flip-card:hover .flip-card-inner {
        transform: none;
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .footer,
    .btn,
    .floating-bubbles {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .glass,
    .glass-card,
    .glass-card-strong {
        background: white !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    a {
        text-decoration: underline;
    }
    
    .container {
        max-width: 100% !important;
    }
}

/* ========== 响应式工具类 ========== */

/* Flexbox 响应式 */
@media (max-width: 767px) {
    .flex-column-mobile {
        flex-direction: column !important;
    }
    
    .text-center-mobile {
        text-align: center !important;
    }
    
    .order-first-mobile {
        order: -1 !important;
    }
    
    .order-last-mobile {
        order: 999 !important;
    }
}

@media (min-width: 768px) {
    .flex-row-tablet {
        flex-direction: row !important;
    }
    
    .text-left-tablet {
        text-align: left !important;
    }
}

/* 间距响应式 */
@media (max-width: 767px) {
    .p-mobile-2 { padding: var(--spacing-sm) !important; }
    .p-mobile-3 { padding: var(--spacing-md) !important; }
    .mt-mobile-3 { margin-top: var(--spacing-md) !important; }
    .mb-mobile-3 { margin-bottom: var(--spacing-md) !important; }
}

/* 宽度响应式 */
.w-full-mobile {
    width: 100%;
}

@media (min-width: 768px) {
    .w-auto-tablet {
        width: auto;
    }
    
    .w-half-tablet {
        width: 50%;
    }
}

/* ========== 安全区域适配 (iPhone X+) ========== */
@supports (padding: max(0px)) {
    .navbar {
        padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
        padding-left: max(var(--spacing-md), env(safe-area-inset-left));
        padding-right: max(var(--spacing-md), env(safe-area-inset-right));
    }
    
    .footer {
        padding-bottom: max(var(--spacing-xl), env(safe-area-inset-bottom));
    }
    
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
