/* 书本风格 UI 样式 - SBOP 编年史 */

@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@300;400;600&display=swap');

:root {
  --paper-bg: #fdfaf2;
  --paper-edge: #e8e1d3;
  --ink-color: #2c2c2c;
  --ink-secondary: #5a5a5a;
  --ink-hint: #8a8a8a;
  --accent-color: #8b4513;
  --accent-hover: #a0522d;
  --danger-ink: #8b0000;
  --book-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Serif SC', serif;
  background-color: #2a1b12; /* 更深的木纹底色 */
  background-image: 
    url('https://www.transparenttextures.com/patterns/dark-wood.png'),
    linear-gradient(to right, #3d2b1f, #2a1b12);
  color: var(--ink-color);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 20px;
}

/* 桌面背景装饰 */
.desk-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

.desk-item { position: absolute; opacity: 0.4; filter: drop-shadow(8px 8px 15px rgba(0,0,0,0.6)); }
.pen { top: 15%; right: 10%; width: 250px; height: 12px; background: linear-gradient(to bottom, #333, #000); transform: rotate(35deg); border-radius: 50% 2px 2px 50%; }
.cup-stain { bottom: 15%; left: 8%; width: 180px; height: 180px; border: 4px solid rgba(85, 45, 15, 0.15); border-radius: 50%; }
.paper-scraps { top: 75%; right: 8%; width: 120px; height: 150px; background: var(--paper-bg); transform: rotate(-10deg); box-shadow: 4px 4px 10px rgba(0,0,0,0.3); }

.app-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  max-width: 1300px;
  position: relative;
  z-index: 1;
}

/* 标尺时间线 - 样式修复与动画 */
.ruler-timeline-container {
  position: fixed;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 100;
}

.ruler-timeline {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-right: 20px;
  border-right: 2px solid rgba(255,255,255,0.15);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.ruler-item {
  width: 100%;
  text-align: right;
  padding: 12px 0;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: rgba(255,255,255,0.3);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ruler-date { font-family: 'Times New Roman', serif; font-size: 0.95rem; }
.ruler-line { height: 1px; background: rgba(255,255,255,0.1); width: 12px; margin-top: 5px; transition: 0.3s; }

.ruler-item[data-dist="0"] { color: #fff; transform: scale(1.35) translateX(-12px); text-shadow: 0 0 10px rgba(255,255,255,0.3); }
.ruler-item[data-dist="1"] { color: rgba(255,255,255,0.7); transform: scale(1.1) translateX(-6px); }
.ruler-item[data-dist="2"] { color: rgba(255,255,255,0.5); transform: scale(1.0); }

.ruler-item[data-dist="0"] .ruler-line { width: 35px; background: #fff; height: 2px; }

/* 书本容器 */
.book-container {
  margin-left: 140px;
  width: 100%;
  max-width: 900px;
  perspective: 2000px;
}

.book {
  background: var(--paper-bg);
  min-height: 85vh;
  box-shadow: 25px 25px 80px rgba(0,0,0,0.6);
  display: flex;
  border-radius: 4px 12px 12px 4px;
  overflow: hidden;
  animation: bookOpen 1.2s cubic-bezier(0.2, 1, 0.3, 1);
  position: relative;
  z-index: 2;
}

@keyframes bookOpen {
  from { transform: rotateY(-18deg) translateX(80px); opacity: 0; }
  to { transform: rotateY(0) translateX(0); opacity: 1; }
}

.book-spine {
  width: 50px;
  background: linear-gradient(to right, #1a100a, #4a2205 40%, #1a100a);
  box-shadow: 3px 0 15px rgba(0,0,0,0.5);
  border-right: 1px solid rgba(0,0,0,0.2);
}

.book-page {
  flex: 1;
  padding: 60px 80px;
  background-image: linear-gradient(rgba(0,0,0,0.015) 1px, transparent 1px);
  background-size: 100% 1.8em;
  display: flex;
  flex-direction: column;
  position: relative;
}

.book-page::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 30px;
  background: linear-gradient(to right, rgba(0,0,0,0.04), transparent);
  pointer-events: none;
}

.book-title { font-family: 'Ma Shan Zheng', cursive; font-size: 3.5rem; letter-spacing: 6px; text-align: center; margin-bottom: 5px; }
.header-divider { height: 2px; background: linear-gradient(to right, transparent, var(--ink-color), transparent); margin: 25px auto; width: 85%; position: relative; }
.header-divider::after { content: "❦"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--paper-bg); padding: 0 15px; font-size: 1.4rem; }
.book-subtitle { font-style: italic; color: var(--ink-secondary); font-size: 1rem; text-align: center; }

.book-controls { margin-top: 40px; display: flex; justify-content: space-between; align-items: center; gap: 30px; }
.book-btn { 
  display: flex; align-items: center; gap: 10px; 
  background: transparent; border: 1.5px solid var(--ink-color); 
  padding: 10px 22px; font-family: inherit; font-weight: 600;
  cursor: pointer; transition: 0.3s;
}
.book-btn:hover { background: var(--ink-color); color: var(--paper-bg); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }

.book-search { flex: 1; max-width: 350px; position: relative; }
.book-search input { 
  width: 100%; background: transparent; border: none; 
  border-bottom: 1.5px solid var(--ink-color); padding: 10px 0; 
  font-family: inherit; font-size: 1rem; outline: none; 
}

/* 列表条目优化 */
.journal-entry { border-bottom: 1px dashed var(--paper-edge); padding: 35px 0; cursor: pointer; transition: 0.4s cubic-bezier(0.2, 1, 0.3, 1); }
.journal-entry:hover { background: rgba(0,0,0,0.015); padding-left: 15px; }
.entry-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 12px; }
.entry-excerpt { font-size: 1.05rem; line-height: 1.85; color: var(--ink-secondary); white-space: pre-wrap; }
.entry-ink-thumb { margin-top: 20px; width: 220px; height: 140px; object-fit: cover; filter: sepia(0.2) contrast(1.05); border: 6px solid white; box-shadow: 0 8px 25px rgba(0,0,0,0.15); transition: 0.3s; }
.journal-entry:hover .entry-ink-thumb { transform: scale(1.02) rotate(1deg); box-shadow: 0 12px 35px rgba(0,0,0,0.2); }

/* 分页控件 */
.pagination-controls { margin-top: 50px; display: flex; justify-content: center; align-items: center; gap: 30px; padding-top: 25px; border-top: 1px solid var(--paper-edge); }
.page-btn { 
  background: transparent; border: 1px solid var(--ink-color); 
  padding: 8px 24px; cursor: pointer; font-family: inherit; font-weight: 600;
  transition: 0.3s;
}
.page-btn:hover:not(:disabled) { background: var(--ink-color); color: var(--paper-bg); }
.page-btn:disabled { opacity: 0.25; cursor: not-allowed; }

/* 模态框样式重写 */
.parchment-modal { 
  display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; 
  background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); z-index: 10000; 
  justify-content: center; align-items: center; padding: 40px; 
}

.parchment-modal.active {
  display: flex !important;
}

.parchment-modal.fullscreen {
  padding: 0;
}

.fullscreen-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.fullscreen-content img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.fullscreen-content .parchment-close {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 10002;
}

.parchment-content { 
  background: var(--paper-bg); 
  background-image: url('https://www.transparenttextures.com/patterns/old-paper.png'); 
  width: 100%; max-width: 700px; max-height: 90vh; overflow-y: auto;
  padding: 50px; box-shadow: 0 40px 100px rgba(0,0,0,0.8); border: 1px solid var(--paper-edge);
  position: relative;
  z-index: 10001;
  animation: parchmentOpen 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes parchmentOpen {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.parchment-header {
  margin-bottom: 40px;
  border-bottom: 2px solid var(--ink-color);
  padding-bottom: 15px;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.parchment-close {
  background: var(--paper-bg);
  border: 1.5px solid var(--ink-color);
  font-size: 1.2rem;
  color: var(--ink-color);
  cursor: pointer;
  line-height: 1;
  padding: 4px 10px;
  transition: 0.3s;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 2px 2px 0 var(--ink-color);
}

.parchment-header .parchment-close {
  position: static;
}

.parchment-close:hover {
  background: var(--ink-color);
  color: var(--paper-bg);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink-color);
}

.parchment-close.white {
  color: white;
}

/* 隐藏原生文件输入框 */
.hidden-input {
  display: none;
}

.parchment-header h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink-color);
}

/* 表单元素优化 */
.ink-group {
  margin-bottom: 30px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ink-group label {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink-color);
  display: block;
}

.ink-group input[type="text"],
.ink-group input[type="password"],
.ink-group textarea {
  width: 100%;
  background: rgba(0,0,0,0.03);
  border: none;
  border-bottom: 2px solid var(--ink-color);
  padding: 12px 15px;
  font-family: 'Noto Serif SC', serif;
  font-size: 1.05rem;
  outline: none;
  transition: all 0.3s ease;
  color: var(--ink-color);
  border-radius: 0; /* 移除圆角 */
  appearance: none;
}

.ink-group input:focus,
.ink-group textarea:focus {
  background: rgba(0,0,0,0.01);
  border-bottom-color: var(--accent-color);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* 按钮统一书本风格 */
.parchment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-edge);
}

.detail-text #viewContent,
#viewContent,
.journal-detail .detail-text #viewContent,
.detail-text {
  white-space: pre-wrap !important;
}

#viewContent {
  white-space: pre-wrap !important;
}

.ink-btn {
  padding: 12px 30px;
  font-family: 'Noto Serif SC', serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ink-btn.primary {
  background: var(--ink-color);
  color: var(--paper-bg);
  border: 1.5px solid var(--ink-color);
}

.ink-btn.secondary {
  background: transparent;
  color: var(--ink-color);
  border: 1.5px solid var(--ink-color);
}

.ink-btn.danger {
  background: transparent;
  color: var(--danger-ink);
  border: 1.5px solid var(--danger-ink);
}

.ink-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.ink-btn:active {
  transform: translateY(0);
}

/* 文件上传区域优化 */
.ink-upload .upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border: 2px dashed var(--ink-hint);
  text-align: center;
  cursor: pointer;
  background: rgba(0,0,0,0.02);
  transition: all 0.3s ease;
  min-height: 100px;
  width: 100%;
}

.ink-upload .upload-area:hover {
  background: rgba(0,0,0,0.05);
  border-color: var(--accent-color);
}

.ink-upload {
  position: relative;
  margin-bottom: 15px;
}

.ink-preview {
  margin-top: 15px;
  position: relative;
  display: inline-block;
}

.ink-preview img {
  max-width: 100%;
  max-height: 200px;
  border: 4px solid white;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.remove-ink-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--danger-ink);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* 详情展示样式补全 */
.detail-ink-image {
  margin-bottom: 30px;
  text-align: center;
}

.image-frame {
  display: inline-block;
  padding: 10px;
  background: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  transform: rotate(-1deg);
  cursor: zoom-in;
}

.image-frame img {
  max-width: 100%;
  max-height: 400px;
  display: block;
}

.detail-date {
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px dashed var(--paper-edge);
  color: var(--ink-hint);
  font-style: italic;
  font-size: 0.9rem;
  text-align: right;
}

.journal-entries.page-turning { animation: pageFlip 0.7s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes pageFlip {
  0% { transform: scale(1) rotateY(0); opacity: 1; }
  45% { transform: scale(0.96) rotateY(-12deg) translateX(-20px); opacity: 0.4; filter: blur(1px); }
  100% { transform: scale(1) rotateY(0); opacity: 1; }
}

.ink-toast { 
  position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%) translateY(120px); 
  background: var(--ink-color); color: var(--paper-bg); padding: 18px 50px; 
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); font-weight: 600; z-index: 2000; 
  transition: 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28); 
}
.ink-toast.show { transform: translateX(-50%) translateY(0); }
@media (max-width: 1200px) {
  .ruler-timeline-container { display: none; }
  .book-container { margin-left: 0; }
}
@media (max-width: 850px) {
  .book-page { padding: 40px; }
  .book-title { font-size: 2.8rem; }
  .detail-text { font-size: 1.1rem; }
}
