/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --radius: 0.5rem;
    /* A4 尺寸转换为像素 (96dpi) */
    --a4-width: 794px;  /* 210mm = 794px */
    --a4-height: 1123px; /* 297mm = 1123px */
    --page-padding: 75px; /* 20mm = 75px */
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: hsl(var(--secondary));
    color: hsl(var(--foreground));
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.page-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

/* A4 纸张样式 */
.container {
    width: var(--a4-width);
    height: var(--a4-height);
    padding: var(--page-padding);
    background: hsl(var(--background));
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    transform-origin: center;
    position: relative;
}

/* 自动缩放脚本会设置这个变量 */
@media screen {
    .container {
        transform: scale(calc(min(
            (100vh - 120px) / var(--a4-height),
            (100vw - 40px) / var(--a4-width)
        )));
    }
}

h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.4;
}

h2 {
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: 500;
    color: hsl(var(--primary));
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.section {
    display: flex;
    flex-direction: column;
}

.section:first-child {
    flex: 0 0 auto;
    margin-bottom: 30px;
}

.section:last-child {
    flex: 1;
}

/* 口算题区域 */
.mental-math {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    font-size: 18px;
}

.problem {
    text-align: left;
    padding: 4px 0;
}

/* 竖式计算区域 */
.vertical-math {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 40px;
    padding: 0 10px;
    height: 100%;
}

.vertical-problem {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.problem-text {
    font-size: 20px;
    margin-bottom: 10px;
}

.calculation-space {
    flex: 1;
    min-height: 80px;
    border-bottom: 1px solid hsl(var(--secondary));
}

/* 页脚样式 */
.page-footer {
    position: absolute;
    bottom: 20px;
    left: var(--page-padding);
    right: var(--page-padding);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.page-number {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    text-align: left;
}

.website {
    font-size: 12px;
    opacity: 0.8;
    margin-left: auto;
}

/* 控制按钮样式 */
.controls {
    display: flex;
    gap: 12px;
    padding: 10px 0;
}

.button-primary,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-weight: 500;
    padding: 8px 16px;
    font-size: 16px;
    line-height: 1.6;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.button-primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid transparent;
}

.button-primary:hover {
    opacity: 0.9;
}

.button-secondary {
    background-color: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--secondary-foreground));
}

.button-secondary:hover {
    background-color: hsl(var(--secondary-foreground));
    color: hsl(var(--secondary));
}

/* 打印样式 */
@media print {
    body {
        padding: 0;
        background: none;
    }
    
    .page-wrapper {
        transform: none;
    }
    
    .container {
        box-shadow: none;
        padding: var(--page-padding);
        margin: 0;
        transform: none;
        width: 210mm;
        height: 297mm;
    }
    
    .controls {
        display: none;
    }
}

/* 确保容器有相对定位 */
.container {
    position: relative;
}

/* 首页样式 */
.home-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.home-container h1 {
    font-size: 36px;
    margin-bottom: 0;
}

.subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
}

.grade-section {
    margin: 40px 0;
    padding: 20px;
    background: hsl(var(--background));
    border-radius: var(--radius);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.grade-section h2 {
    margin-bottom: 20px;
    color: hsl(var(--primary));
}

.exercise-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exercise-link {
    display: inline-block;
    padding: 15px 25px;
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    text-decoration: none;
    border-radius: var(--radius);
    transition: opacity 0.2s ease;
}

.exercise-link:hover {
    opacity: 0.9;
}

.coming-soon {
    margin-top: 40px;
    padding: 20px;
    background: hsl(var(--secondary));
    border-radius: var(--radius);
}

.coming-soon h3 {
    margin-bottom: 15px;
    color: hsl(var(--primary));
}

.coming-soon ul {
    list-style: none;
    padding: 0;
}

.coming-soon li {
    margin: 10px 0;
    color: #666;
}

footer {
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid hsl(var(--secondary));
    color: #666;
}

/* Logo 样式 */
.site-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    line-height: 1;
}

.site-header h1 {
    margin: 0;
    line-height: 1;
}

.logo {
    width: 48px;
    height: 48px;
    display: block;
    flex-shrink: 0;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    line-height: 1;
}

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
}

.small-logo {
    width: 32px;
    height: 32px;
    display: block;
    flex-shrink: 0;
} 