/* ============================================================
   青屿实验中学：寻找苏晚晴 — 公共样式 v3.0
   - 二周目差异样式
   - 密码输入接近度视觉反馈
   - 心跳扫描线增强
   - 结局背景色过渡
   - 时间锁情感化样式
   ============================================================ */

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0a0a14; color: #e0e0e0; line-height: 1.7;
  min-height: 100vh; overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
}

/* ========== 二周目全局色调偏移 ========== */
body.second-run {
  filter: hue-rotate(-15deg) saturate(0.85);
}
body.second-run::before {
  content: '第二次翻阅';
  position: fixed; top: 8px; right: 8px; z-index: 9999;
  font-size: 10px; color: rgba(180, 180, 200, 0.4);
  letter-spacing: 2px; pointer-events: none;
}

/* ========== 链接 ========== */
a { color: #7aa2d6; text-decoration: none; }
a:hover { color: #a3c4f3; text-decoration: underline; }
a:focus { outline: 2px solid #4a7ab5; outline-offset: 2px; }

/* ========== 按钮 ========== */
button, .btn {
  display: inline-block; padding: 10px 24px; margin: 6px 4px;
  background: #2a2a4a; color: #e0e0e0; border: 1px solid #4a4a6a;
  border-radius: 6px; cursor: pointer; font-size: 14px;
  transition: all 0.25s ease; font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover {
  background: #3a3a5a; border-color: #6a6a8a;
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: #1a3a6a; border-color: #2a5a9a; }
button.primary:hover { background: #2a4a8a; }
button.danger { background: #5a1a1a; border-color: #8a2a2a; }
button.danger:hover { background: #7a2a2a; }

/* ========== 输入框 ========== */
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%; max-width: 320px; padding: 12px 16px;
  background: #1a1a2e; color: #e0e0e0; border: 2px solid #444;
  border-radius: 6px; font-size: 16px; font-family: inherit;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
  -webkit-user-select: text; user-select: text;
}
input:focus { outline: none; border-color: #4a7ab5; box-shadow: 0 0 12px rgba(74,122,181,0.3); }
input.correct { border-color: #4caf50 !important; box-shadow: 0 0 12px rgba(76,175,80,0.4) !important; }
input.wrong { border-color: #ff4444 !important; animation: shake 0.4s; }
input.close { border-color: #ff9800 !important; box-shadow: 0 0 10px rgba(255,152,0,0.3); }
input.exact { border-color: #4caf50 !important; box-shadow: 0 0 10px rgba(76,175,80,0.3); }

/* ========== 密码输入区域 ========== */
.password-box {
  background: #111125; border: 1px solid #333; border-radius: 10px;
  padding: 24px; margin: 20px 0; text-align: center;
}
.password-box label { display: block; margin-bottom: 12px; color: #aaa; font-size: 14px; }
.password-box .input-row { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.password-box .attempts { margin-top: 12px; font-size: 12px; color: #666; }
.password-box .attempts .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #333; margin: 0 2px; }
.password-box .attempts .dot.used { background: #ff4444; }
.password-box .hint-area { margin-top: 16px; min-height: 20px; }

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75); z-index: 1000;
  align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s;
}
.modal-overlay.show { display: flex; opacity: 1; }
.modal-box {
  background: #1a1a2e; border: 1px solid #444; border-radius: 12px;
  padding: 28px; max-width: 420px; width: 90%; max-height: 80vh; overflow-y: auto;
  transform: scale(0.9); transition: transform 0.3s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-overlay.show .modal-box { transform: scale(1); }
.modal-box h3 { margin-bottom: 16px; color: #a3c4f3; }
.modal-box p { margin-bottom: 12px; line-height: 1.8; }
.modal-box .modal-actions { margin-top: 20px; text-align: right; }

/* ========== Toast ========== */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #2a2a4a; color: #e0e0e0; padding: 12px 24px; border-radius: 8px;
  font-size: 14px; z-index: 2000; opacity: 0; transition: all 0.3s;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); pointer-events: none;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: #1a5a2a; border: 1px solid #2a8a4a; }
.toast-error { background: #5a1a1a; border: 1px solid #8a2a2a; }
.toast-info { background: #1a3a5a; border: 1px solid #2a5a8a; }
.toast-close { background: #4a4a2a; border: 1px solid #6a6a3a; }

/* ========== 动画 ========== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse { animation: pulse 2s infinite; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.5s ease forwards; }

@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}
.scanline {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(to bottom, transparent, rgba(255,60,60,0.6), transparent);
  animation: scanline 4s linear infinite; z-index: 9998; pointer-events: none;
}

@keyframes heartbeat-bg {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255,0,0,0); }
  50% { box-shadow: inset 0 0 80px rgba(255,0,0,0.15); }
}
.heartbeat-bg { animation: heartbeat-bg 1.2s ease-in-out infinite; }

@keyframes flicker {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.8; }
  6% { opacity: 1; }
  9% { opacity: 0.6; }
  12% { opacity: 1; }
  50% { opacity: 0.95; }
  80% { opacity: 0.85; }
  90% { opacity: 1; }
}
.flicker { animation: flicker 6s infinite; }

/* ========== 时间锁 ========== */
.timelock-box {
  background: #0d0d20; border: 1px solid #2a2a4a; border-radius: 10px;
  padding: 20px; margin: 16px 0; text-align: center;
}
.timelock-box .countdown {
  font-size: 18px; color: #a3c4f3; font-weight: bold;
  margin: 12px 0; font-family: 'Courier New', monospace;
}
.timelock-box .poetic {
  font-size: 13px; color: #888; font-style: italic; margin: 8px 0;
}
.timelock-box .progress-bar {
  width: 100%; height: 4px; background: #1a1a2e; border-radius: 2px; overflow: hidden;
  margin: 12px 0;
}
.timelock-box .progress-bar .fill {
  height: 100%; background: linear-gradient(to right, #4a7ab5, #a3c4f3);
  border-radius: 2px; transition: width 1s linear;
}
.timelock-box .stage-hint {
  font-size: 12px; color: #666; margin-top: 8px;
}
.timelock-box.unlocked {
  border-color: #4caf50; background: #0a1a0a;
}
.timelock-box.unlocked .countdown { color: #4caf50; }

/* ========== 结局背景色 ========== */
body.ending-truth { background: linear-gradient(180deg, #0a0a14 0%, #1a1a3a 50%, #0a0a14 100%); }
body.ending-silence { background: linear-gradient(180deg, #0a0a14 0%, #1a2a2a 50%, #0a0a14 100%); }
body.ending-write { background: linear-gradient(180deg, #0a0a14 0%, #2a2a1a 50%, #0a0a14 100%); }
body.ending-leave { background: linear-gradient(180deg, #0a0a14 0%, #2a1a1a 50%, #0a0a14 100%); }

/* ========== 结局动画 ========== */
.ending-container {
  max-width: 600px; margin: 40px auto; padding: 40px 20px;
  text-align: center; opacity: 0; animation: fadeIn 2s ease forwards;
}
.ending-container .ending-title {
  font-size: 24px; color: #a3c4f3; margin-bottom: 30px; letter-spacing: 4px;
}
.ending-container .ending-text {
  font-size: 16px; line-height: 2.2; color: #ccc;
}
.ending-container .ending-text p { margin-bottom: 16px; }
.ending-container .ending-final {
  font-size: 20px; color: #fff; margin-top: 40px; font-weight: bold;
  letter-spacing: 2px;
}
.ending-container .ending-stats {
  margin-top: 50px; padding: 20px; background: #111125;
  border-radius: 10px; text-align: left; font-size: 13px; color: #888;
}
.ending-container .ending-stats h4 { color: #666; margin-bottom: 12px; }
.ending-container .ending-stats .stat-row { display: flex; justify-content: space-between; margin: 6px 0; }
.ending-container .ending-quote {
  margin-top: 30px; font-size: 14px; color: #555; font-style: italic;
  border-left: 3px solid #333; padding-left: 16px; text-align: left;
}

/* ========== 信件阅读 ========== */
.letter-container {
  max-width: 560px; margin: 30px auto; padding: 30px;
  background: #15152a; border-radius: 12px; border: 1px solid #2a2a4a;
}
.letter-container .letter-header {
  font-size: 12px; color: #666; margin-bottom: 20px;
  border-bottom: 1px solid #2a2a4a; padding-bottom: 12px;
}
.letter-container .letter-body { font-size: 15px; line-height: 2; }
.letter-container .letter-body p { margin-bottom: 14px; }
.letter-container .letter-body .highlight {
  background: rgba(163,196,243,0.1); padding: 2px 6px; border-radius: 3px;
  border-left: 2px solid #4a7ab5; display: block; margin: 10px 0; padding-left: 12px;
}
.letter-container .letter-body .key-sentence {
  color: #ff6b6b; font-weight: bold;
}
.letter-container .letter-footer {
  margin-top: 24px; font-size: 12px; color: #555; text-align: right;
}

/* ========== 读信逐段高亮 ========== */
.letter-paragraph {
  opacity: 0.4; transition: opacity 0.5s;
}
.letter-paragraph.active {
  opacity: 1; background: rgba(163,196,243,0.05);
  padding: 4px 8px; border-radius: 4px;
}

/* ========== 真相页扫描线 ========== */
body.truth-mode { animation: heartbeat-bg 1s ease-in-out infinite; }
body.truth-mode::after {
  content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px, rgba(255,0,0,0.02) 2px, rgba(255,0,0,0.02) 4px
  );
  pointer-events: none; z-index: 9997;
}

/* ========== 隐藏信件（二周目） ========== */
.hidden-letter {
  display: none; opacity: 0; transition: opacity 1s;
}
body.second-run .hidden-letter {
  display: block; opacity: 1;
  margin-top: 30px; padding: 20px;
  background: #0d0d20; border: 1px dashed #4a4a6a; border-radius: 8px;
}
body.second-run .hidden-letter .label {
  font-size: 11px; color: #ff6b6b; letter-spacing: 2px; margin-bottom: 12px;
}

/* ========== 可点击线索 ========== */
.clue-link {
  color: #7aa2d6; cursor: pointer; border-bottom: 1px dotted #4a7ab5;
  transition: color 0.2s;
}
.clue-link:hover { color: #a3c4f3; }

/* ========== 快搜关键词高亮 ========== */
.search-highlight {
  background: rgba(255,200,50,0.15); padding: 1px 4px; border-radius: 2px;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .modal-box { padding: 20px; }
  .ending-container { padding: 20px 16px; }
  .letter-container { padding: 20px 16px; }
  input[type="text"], input[type="password"] { font-size: 16px; }
}
