/* ==========================================
   huiwu.com — 全局样式 + 便签墙
   拟态主题 + 移动端优先
   ========================================== */

/* ─── CSS 变量 ─────────────────────────────── */
:root {
  /* 全局配色 */
  --bg: #f0ebe0;
  --bg-card: rgba(255, 255, 255, 0.75);
  --text: #3d3629;
  --text-muted: #8a7e6b;
  --text-light: #b0a590;
  --accent: #c8963e;
  --accent-2: #7b9c6e;
  --accent-3: #6b7db3;
  --accent-4: #b37b5e;

  /* 拟态阴影 */
  --neu-light: rgba(255, 255, 255, 0.7);
  --neu-dark: rgba(180, 170, 150, 0.35);

  /* 便签 */
  --note-bg: rgba(255, 252, 242, 0.94);
  --note-text: #4a3f2f;

  /* 尺寸（移动端优先） */
  --nav-height: 48px;
  --note-width: 180px;
  --note-min-height: 140px;
  --note-radius: 6px;
  --note-rolled-height: 26px;
  --toolbar-height: 52px;
  --card-gap: 14px;

  /* 安全区域 */
  --safe-bottom: env(safe-area-inset-bottom, 8px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (min-width: 600px) {
  :root {
    --nav-height: 52px;
    --note-width: 240px;
    --note-min-height: 180px;
    --note-radius: 8px;
    --note-rolled-height: 30px;
    --toolbar-height: 56px;
    --card-gap: 18px;
  }
}

@media (min-width: 1024px) {
  :root {
    --nav-height: 56px;
    --note-width: 280px;
    --note-min-height: 200px;
    --note-rolled-height: 32px;
    --note-radius: 10px;
    --card-gap: 24px;
  }
}

/* ─── 基础重置 ─────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  background: var(--bg);
  color: var(--text);
}

/* ─── 导航栏 ───────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  padding-top: var(--safe-top);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(240, 235, 224, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding-left: 8px;
  padding-right: 8px;
}

.nav-back {
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, opacity 0.3s, transform 0.2s;
  flex-shrink: 0;
}
.nav-back:hover { background: rgba(0, 0, 0, 0.06); color: var(--text); }
.nav-back:active { transform: scale(0.9); }
.nav-back.hidden { opacity: 0; pointer-events: none; }

.nav-title {
  font-size: 16px; font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  flex: 1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-spacer { width: 36px; flex-shrink: 0; }

@media (min-width: 600px) {
  .nav-title { font-size: 18px; }
}

/* ─── 视图容器 ─────────────────────────────── */
.view {
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ─── 主页 ─────────────────────────────────── */
.page-home {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  min-height: 100%;
}

.home-hero {
  text-align: center;
  margin-bottom: 36px;
}

.home-hero h1 {
  font-size: 26px; font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  margin-bottom: 6px;
}

.home-hero p {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.home-cards {
  display: flex; flex-direction: column;
  gap: var(--card-gap);
  width: 100%; max-width: 420px;
}

.home-card {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 18px;
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow:
    4px 4px 12px var(--neu-dark),
    -3px -3px 10px var(--neu-light);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none; color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.home-card:active { transform: scale(0.97); }
.home-card:hover {
  box-shadow:
    6px 6px 18px var(--neu-dark),
    -4px -4px 14px var(--neu-light);
}

.home-card-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  color: #fff;
}
.home-card-icon.info   { background: var(--accent); }
.home-card-icon.history { background: var(--accent-4); }

.home-card-body { flex: 1; min-width: 0; }
.home-card-body h3   { font-size: 16px; font-weight: 600; margin-bottom: 3px; }
.home-card-body p    { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.home-card-arrow     { color: var(--text-light); font-size: 18px; flex-shrink: 0; }

/* ─── 信息板块子页 ─────────────────────────── */
.page-info {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 28px 20px;
  min-height: 100%;
}

.page-info .section-title {
  font-size: 15px; font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 18px;
  letter-spacing: 0.5px;
}

.info-cards {
  display: flex; flex-direction: column;
  gap: var(--card-gap);
  width: 100%; max-width: 420px;
}

.info-card {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px;
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow:
    3px 3px 10px var(--neu-dark),
    -2px -2px 8px var(--neu-light);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.info-card:active { transform: scale(0.97); }

.info-card-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.info-card-dot.notes   { background: var(--accent); }
.info-card-dot.reply   { background: var(--accent-2); }
.info-card-dot.collect { background: var(--accent-3); }

.info-card-body { flex: 1; }
.info-card-body h4  { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.info-card-body p   { font-size: 12px; color: var(--text-muted); }
.info-card-arrow    { color: var(--text-light); font-size: 16px; }

/* ─── 占位页 ───────────────────────────────── */
.page-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
  text-align: center;
  gap: 16px;
}

.page-placeholder .ph-icon {
  font-size: 56px;
  opacity: 0.35;
}

.page-placeholder h3 {
  font-size: 18px; font-weight: 600;
  color: var(--text-muted);
}

.page-placeholder p {
  font-size: 13px; color: var(--text-light);
  max-width: 260px; line-height: 1.6;
}

/* ==========================================
   便签墙样式
   ========================================== */

/* ─── 墙面 ─────────────────────────────────── */
.wall {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ─── 背景图片层 ───────────────────────────── */
.wall-bg {
  position: absolute; inset: 0;
  background: #c8b89a;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.3s ease;
}

.wall-bg:empty,
.wall-bg[style*="none"] {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(139, 115, 85, 0.08) 2px,
      rgba(139, 115, 85, 0.08) 4px
    ),
    linear-gradient(
      135deg,
      #c8b89a 0%, #d4c4a8 30%, #bfae90 60%, #d0c0a4 100%
    );
}

/* ─── 便签层 ───────────────────────────────── */
.notes-layer {
  position: absolute; inset: 0; z-index: 2;
}

/* ─── 新建提示 ─────────────────────────────── */
.create-hint {
  position: absolute;
  bottom: calc(var(--toolbar-height) + 60px);
  left: 50%; transform: translateX(-50%);
  z-index: 3;
  padding: 10px 24px; border-radius: 24px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff; font-size: 14px; letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.create-hint.visible { opacity: 1; }

/* ─── 便签本体 ─────────────────────────────── */
.note {
  position: absolute;
  width: var(--note-width);
  min-height: var(--note-min-height);
  border-radius: var(--note-radius);
  background: var(--note-bg);
  color: var(--note-text);
  box-shadow:
    4px 4px 12px var(--neu-dark),
    -2px -2px 8px var(--neu-light),
    inset 1px 1px 0 rgba(255,255,255,0.4);
  cursor: grab;
  transition:
    box-shadow 0.35s ease,
    height 0.45s cubic-bezier(0.4,0,0.2,1),
    min-height 0.45s cubic-bezier(0.4,0,0.2,1),
    border-radius 0.45s ease,
    background 0.35s ease;
  overflow: hidden;
  z-index: 10;
  will-change: transform, height;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.note.dragging {
  cursor: grabbing;
  box-shadow:
    8px 8px 24px rgba(0,0,0,0.2),
    -4px -4px 12px var(--neu-light);
  z-index: 100;
  transition: box-shadow 0.15s ease;
}

.note.expanded {
  cursor: default;
  z-index: 50;
  box-shadow:
    6px 6px 18px var(--neu-dark),
    -3px -3px 10px var(--neu-light),
    inset 1px 1px 0 rgba(255,255,255,0.4);
}

/* ─── 卷起状态 — 画卷卷轴 ──────────────────── */
.note.rolled {
  height: var(--note-rolled-height) !important;
  min-height: var(--note-rolled-height) !important;
  cursor: pointer;
  border-radius: calc(var(--note-rolled-height) / 2);
  background:
    linear-gradient(
      to bottom,
      rgba(180,160,130,0.55) 0%,
      rgba(230,220,200,0.8) 15%,
      rgba(255,252,242,0.94) 40%,
      rgba(255,252,242,0.96) 60%,
      rgba(230,220,200,0.8) 85%,
      rgba(180,160,130,0.55) 100%
    );
  box-shadow:
    0 2px 6px rgba(0,0,0,0.15),
    0 0 0 1px rgba(180,160,130,0.2);
  overflow: hidden;
}

.note.rolled::before,
.note.rolled::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 8px; height: calc(100% + 6px);
  border-radius: 4px;
  background: linear-gradient(to bottom, #7a5c3e, #5a3d28, #8b6b4a, #5a3d28, #7a5c3e);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
}
.note.rolled::before { left: -5px; }
.note.rolled::after  { right: -5px; }
.note.rolled::before,
.note.rolled::after  { opacity: 1; }

.note.rolled:hover {
  box-shadow:
    0 3px 10px rgba(0,0,0,0.2),
    0 0 0 1px rgba(200,170,120,0.4),
    0 0 20px rgba(255,220,150,0.3);
}

/* ─── 便签内部结构 ─────────────────────────── */
.note-inner {
  display: flex; flex-direction: column;
  height: 100%;
  padding: 12px 14px;
  transition: opacity 0.25s ease;
}

.note-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.note-pin {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e8c84a, #b8942e);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.2), 1px 1px 3px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.note-date {
  font-size: 11px; color: #b0a590; letter-spacing: 0.3px;
}

.note-delete {
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: transparent;
  color: #c0b0a0; font-size: 16px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s, background 0.2s;
}
.note:hover .note-delete,
.note.expanded .note-delete { opacity: 1; }
.note-delete:hover {
  color: #e05555;
  background: rgba(224,85,85,0.1);
}

.note-body {
  flex: 1; width: 100%; min-height: 60px;
  border: none; outline: none; resize: none;
  background: transparent;
  color: var(--note-text);
  font-size: 14px; line-height: 1.7;
  font-family: inherit;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.note-body::placeholder { color: #c8bda5; font-style: italic; }

@media (min-width: 600px) {
  .note-body { font-size: 15px; line-height: 1.8; }
}

.note.rolled .note-inner {
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s ease;
}

.note.rolled .note-preview {
  display: block;
  position: absolute;
  top: 50%; left: 14px; right: 14px;
  transform: translateY(-50%);
  font-size: 11px; color: #a09080;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.note-preview { display: none; }

/* ─── 底部工具栏 ───────────────────────────── */
.toolbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: var(--toolbar-height);
  padding: 0 16px;
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.tool-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 20px; border: none;
  background: rgba(255,255,255,0.12);
  color: #fff; font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.tool-btn:hover,
.tool-btn:active { background: rgba(255,255,255,0.22); }

.tool-divider {
  width: 1px; height: 20px;
  background: rgba(255,255,255,0.2);
}

.tool-note-count {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
}
