/* Responsive Styles for Roundstone App - Optimized */

/* ============================================
   性能优化基础设置
   ============================================ */
.diary-entry,
.roundstone-response,
.whisper-entry,
.whisper-content {
    transform: translateZ(0);
    backface-visibility: hidden;
}

.conversation-area,
.monthly-entries,
.diary-section {
    -webkit-overflow-scrolling: touch;
    overflow-anchor: auto;
    scroll-behavior: smooth;
}

/* 动画简化设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   桌面端调整 (≤1200px)
   ============================================ */
@media (max-width: 1200px) {
    .diary-section,
    .calendar-section {
        padding: 32px 24px;
    }
    
    .input-area {
        left: 24px;
        bottom: 24px;
        margin-right: 24px;
    }
    
    .storage-options {
        flex-direction: column;
    }
}

/* ============================================
   平板端优化 (769px - 1024px)
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-container {
        height: 100vh;
        overflow: hidden;
    }
    
    .diary-section {
        flex: 0 0 60%;
        padding: 40px 30px;
        padding-left: max(30px, env(safe-area-inset-left));
        padding-right: max(30px, env(safe-area-inset-right));
        padding-top: max(25px, env(safe-area-inset-top));
        padding-bottom: max(100px, env(safe-area-inset-bottom));
    }
    
    .calendar-section {
        flex: 0 0 40%;
        padding: 40px 25px;
        padding-left: max(25px, env(safe-area-inset-left));
        padding-right: max(25px, env(safe-area-inset-right));
        padding-top: max(25px, env(safe-area-inset-top));
        padding-bottom: max(100px, env(safe-area-inset-bottom));
    }
    
    .input-area {
        left: 30px;
        right: calc(40% + 25px);
        bottom: 25px;
        margin-right: 0;
    }
}

/* ============================================
   移动端主布局 (≤768px)
   ============================================ */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }
    
    .diary-section {
        flex: 1;
        min-height: 100vh;
        height: 100vh;
        padding: 20px 15px 70px;
        border-right: none;
        border-bottom: none;
        overflow-y: auto;
    }
    
    .calendar-section {
        display: none;
    }
    
    .input-area {
        position: fixed;
        left: 15px;
        right: 15px;
        bottom: 15px;
        margin-right: 0;
        z-index: 50;
    }
    
    /* 日期信息布局 */
    .date-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .date-secondary {
        width: 100%;
        justify-content: space-between;
    }
    
    .date-primary {
        cursor: pointer;
    }
    
    /* 对话区域 */
    .conversation-area {
        min-height: calc(100vh - 200px);
        padding-bottom: 20px;
    }
    
    /* 弹窗优化 */
    .welcome-modal,
    .settings-container {
        width: 95% !important;
        max-width: 95% !important;
        padding: 20px !important;
        margin: 10px !important;
    }
    
    .welcome-title {
        font-size: 22px !important;
    }
    
    .settings-title {
        font-size: 20px;
    }
    
    .agree-button {
        width: 100%;
        margin-top: 15px;
    }
    
    /* 选项布局 */
    .greeting-options {
        grid-template-columns: 1fr !important;
    }
    
    .data-option {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .option-button {
        align-self: flex-end;
    }
    
    /* 月度视图 */
    .month-group {
        margin-left: 10px;
    }
    
    .entry-list {
        margin-left: 20px;
    }
    
    .monthly-header {
        cursor: pointer;
    }
    
    .mobile-toggle {
        display: none;
    }
    
    /* 全屏模式 */
    .fullscreen-mode {
        flex-direction: column;
    }
    
    .fullscreen-left {
        flex: 1;
        padding: 20px 15px;
        border-right: none;
        border-bottom: 1px solid var(--grid-line);
    }
    
    .fullscreen-right {
        flex: 1;
        padding: 20px 15px 70px;
    }
    
    .fullscreen-left::after,
    .fullscreen-right::before {
        display: none;
    }
    
    /* 警告卡片 */
    .warning-card {
        max-width: 85%;
        min-width: 200px;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        padding: 10px 16px;
        font-size: 21px;
    }
}

/* ============================================
   小屏移动端 (≤480px)
   ============================================ */
@media (max-width: 480px) {
    .diary-header {
        margin-bottom: 20px;
    }
    
    /* 字体大小调整 */
    .date-primary {
        font-size: 26px;
    }
    
    .calendar-info {
        padding: 10px 0;
    }
    
    .monthly-title {
        font-size: 20px;
    }
    
    .year-title {
        font-size: 26px;
    }
    
    .month-title {
        font-size: 55px;
    }
    
    .entry-date,
    .entry-preview {
        font-size: 13px;
    }
    
    .welcome-content,
    .about-content {
        font-size: 13px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .option-label {
        font-size: 14px;
    }
    
    /* 警告卡片 */
    .warning-card {
        max-width: 90%;
        min-width: 180px;
        bottom: 70px;
        padding: 8px 14px;
        font-size: 21px;
    }
}

/* ============================================
   键盘遮挡处理
   ============================================ */
@media (max-height: 700px) and (max-width: 768px) {
    .diary-section {
        padding-bottom: 100px;
    }
    
    .input-area {
        bottom: 60px;
    }
}

@media (max-height: 800px) and (min-width: 769px) {
    .diary-section,
    .calendar-section {
        padding-top: 20px;
        padding-bottom: 20px;
    }
    
    .input-area {
        bottom: 15px;
    }
}

/* ============================================
   触摸设备交互优化
   ============================================ */
@media (hover: none) {
    .entry-item:hover {
        background-color: inherit;
    }
    
    .entry-item:active {
        background-color: rgba(122, 155, 142, 0.1);
    }
    
    .greeting-option:hover {
        border-color: var(--paper-line);
        background: transparent;
    }
    
    .greeting-option:active,
    .greeting-option.selected {
        border-color: var(--stone-green);
        background: rgba(122, 155, 142, 0.1);
    }
}

@media (max-width: 768px) {
    /* 日期信息 */
    .date-primary {
        font-size: var(--font-size-xl);
    }
    
    .date-secondary {
        font-size: var(--font-size-base);
    }
    
    /* 日记内容 */
    .diary-content,
    .roundstone-response,
    .whisper-content {
        font-size: var(--font-size-base);
        line-height: var(--line-height-zh-base);
    }
    
    /* 月度视图 */
    .year-title {
        font-size: var(--font-size-2xl);
    }
    
    .month-title {
        font-size: var(--font-size-3xl);
    }
    
    .entry-date {
        font-size: var(--font-size-3xl);
    }
    
    .entry-preview {
        font-size: var(--font-size-sm);
        line-height: var(--line-height-zh-base);
    }
    
    /* 设置页面 */
    .settings-title {
        font-size: var(--font-size-2xl);
    }
    
    .section-title {
        font-size: var(--font-size-lg);
    }
    
    .option-label {
        font-size: var(--font-size-sm);
    }
}

@media (max-width: 480px) {
    /* 小屏幕优化 */
    :lang(zh-TW), :lang(zh-CN), :lang(ja) {
        font-size: var(--font-size-cjk-base); /* 使用CJK专用尺寸 */
        line-height: var(--line-height-zh-relaxed);
        letter-spacing: var(--letter-spacing-zh-relaxed);
    }
    
    :lang(en) {
        font-size: var(--font-size-sm);
        line-height: var(--line-height-en-relaxed);
        letter-spacing: var(--letter-spacing-en-relaxed);
    }
}