/* ========================================
   三阶段任务引导系统 - 全局样式文件
   基于现代CSS规范，支持登录、说明、任务三个独立页面的共享样式
   创建日期: 2026-02-18
======================================== */

/* ========================================
   1. 全局重置与盒模型
======================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 移除列表默认样式 */
ul, ol {
  list-style: none;
}

/* 移除按钮默认样式 */
button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

/* 链接基础样式 */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ========================================
   2. CSS自定义属性（设计变量）
======================================== */
:root {
  /* ------------------------------
     字体族配置
  ------------------------------ */
  --font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* ------------------------------
     色彩方案
  ------------------------------ */
  --primary-color: #3b82f6;      /* 主色调：蓝色 */
  --primary-hover: #2563eb;      /* 主色调悬停 */
  --success-color: #10b981;      /* 成功色：绿色 */
  --error-color: #ef4444;        /* 错误色：红色 */
  --warning-color: #f59e0b;      /* 警告色：黄色 */
  --info-color: #3b82f6;         /* 信息色：蓝色 */
  --text-primary: #1f2937;      /* 主要文字 */
  --text-secondary: #6b7280;     /* 次要文字 */
  --border-color: #d1d5db;       /* 边框颜色 */
  --bg-white: #ffffff;           /* 白色背景 */
  --bg-light: #f9fafb;           /* 浅色背景 */
  --bg-gray: #f3f4f6;            /* 灰色背景 */

  /* ------------------------------
     间距系统 (基于rem)
  ------------------------------ */
  --space-xs: 0.25rem;    /* 4px */
  --space-sm: 0.5rem;     /* 8px */
  --space-md: 1rem;       /* 16px */
  --space-lg: 1.5rem;     /* 24px */
  --space-xl: 2rem;       /* 32px */

  /* ------------------------------
     圆角规范
  ------------------------------ */
  --radius-sm: 0.375rem;  /* 6px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */

  /* ------------------------------
     阴影系统
  ------------------------------ */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* ------------------------------
     过渡动画速度
  ------------------------------ */
  --transition-fast: 0.2s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
  --transition-slow: 0.5s ease-in-out;
}

/* ========================================
   3. 全局字体与基础样式
======================================== */
body {
  font-family: var(--font-family);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-gray);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

/* ========================================
   4. 布局容器样式
======================================== */
.main-container {
  width: 100%;
  max-width: 28rem; /* 448px */
  margin: 0 auto;
}

.screen-container {
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: all var(--transition-normal);
}

/* 隐藏屏幕类（由JS控制） */
.hidden-screen {
  display: none !important;
}

/* ========================================
   5. 登录页面样式
======================================== */
#login-header {
  background-color: var(--primary-color);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  color: white;
}

.login-icon {
  display: inline-block;
  padding: 0.75rem;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  margin-bottom: var(--space-sm);
}

#login-header h1 {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: var(--space-xs);
}

#login-header p {
  font-size: 0.875rem;
  opacity: 0.9;
}

.login-form {
  padding: var(--space-xl) var(--space-md);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  font-size: 1rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: all var(--transition-fast);
  font-family: var(--font-family);
  background-color: var(--bg-white);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  z-index: 1;
}

.btn-login {
  width: 100%;
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 44px; /* 最小触摸目标 */
}

.btn-login:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   6. 说明页面样式
======================================== */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#instruction-screen {
  animation: slideInUp 0.4s ease-out;
}

.instruction-content {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
}

.instruction-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.instruction-text {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.btn-confirm {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px; /* 最小触摸目标 */
}

.btn-confirm:hover {
  background-color: var(--primary-hover);
}

/* ========================================
   7. 任务页面样式
======================================== */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#task-screen {
  animation: fadeInScale 0.4s ease-out;
}

.task-header {
  background-color: var(--bg-light);
  padding: var(--space-lg);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.task-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.task-form {
  padding: var(--space-xl) var(--space-md);
}

.textarea-task {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: var(--space-md);
}

.textarea-task:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.char-counter {
  text-align: right;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.btn-submit {
  background-color: var(--success-color);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px; /* 最小触摸目标 */
}

.btn-submit:hover {
  background-color: #0da272;
}

.task-success-message {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

/* ========================================
   8. 交互状态样式
======================================== */
/* 加载旋转动画 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 错误状态样式 */
.error-state {
  border-color: var(--error-color) !important;
  background-color: rgba(239, 68, 68, 0.05);
}

.error-state:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
  color: var(--error-color);
  font-size: 0.875rem;
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.error-message::before {
  content: "⚠";
  font-weight: bold;
}

/* 成功状态样式 */
.success-state {
  border-color: var(--success-color);
}

.success-state:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ========================================
   9. 动画效果系统
======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-in-out;
}

.fade-in-scale {
  animation: fadeInScale 0.4s ease-out;
}

.slide-in-up {
  animation: slideInUp 0.4s ease-out;
}

/* ========================================
   10. 响应式设计
======================================== */
@media (max-width: 640px) {
  body {
    padding: var(--space-sm);
  }

  .screen-container {
    border-radius: var(--radius-md); /* 减小圆角 */
  }

  .main-container {
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }

  .form-input,
  .textarea-task {
    font-size: 1rem; /* 防止iOS自动缩放 */
  }

  .btn-login,
  .btn-confirm,
  .btn-submit {
    padding: 0.875rem; /* 增大点击区域 */
  }

  .login-form,
  .instruction-content,
  .task-form {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }
}

/* ========================================
   11. 触摸设备优化
======================================== */
@media (hover: hover) {
  .btn-login:hover,
  .btn-confirm:hover,
  .btn-submit:hover {
    transform: translateY(-1px);
  }
}

/* 确保所有交互元素有足够大的触摸目标 */
button,
input[type="button"],
input[type="submit"],
input[type="text"],
input[type="password"],
textarea {
  min-height: 44px;
}