/* ============================================
   通用组件 Components
   菜单栏 / Dock / 纸感窗口 / 便签 / 贴纸 / 格纹 / 弹窗
   ============================================ */

/* ———— macOS 菜单栏（奶油纸感细条） ———— */
.menu-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--menu-bar-h);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-4);
  font-size: 12.5px;
  color: var(--ink-soft);
  background: rgba(253, 250, 242, .82);
  -webkit-backdrop-filter: saturate(1.5) blur(16px);
  backdrop-filter: saturate(1.5) blur(16px);
  border-bottom: 1px solid rgba(120, 100, 72, .13);
  user-select: none;
}
.menu-bar .mb-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: .01em;
  flex: 0 0 auto;
}
.menu-bar .mb-brand svg { width: 14px; height: 14px; color: var(--red); flex: 0 0 auto; }
.menu-bar .mb-brand span {
  display: inline-block;
  white-space: nowrap;
  max-width: 130px;
  opacity: 1;
  overflow: hidden;
  transition: max-width .42s var(--ease-spring), opacity .26s ease;
}
.menu-bar .mb-app {
  font-weight: 600;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13.5px;
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-bar .mb-spacer { flex: 1; }
.menu-bar .mb-clock {
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  font-size: 12px;
}
.menu-bar .mb-item {
  border-radius: var(--r-pill);
  padding: 3px 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: var(--butter-soft);
  border: 1px solid rgba(120, 100, 72, .12);
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.menu-bar .mb-item:hover { background: var(--butter); transform: rotate(-1.5deg); }

/* ———— Dock（磨砂玻璃胶囊） ———— */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 190;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: rgba(253, 250, 242, .58);
  -webkit-backdrop-filter: saturate(1.6) blur(22px);
  backdrop-filter: saturate(1.6) blur(22px);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 10px 34px rgba(78, 62, 42, .18), inset 0 1px 0 rgba(255,255,255,.6);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock-item {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.dock-item:hover { transform: translateY(-8px) scale(1.08); }
.dock-item:active { transform: translateY(-2px) scale(.97); }
.dock-item svg { width: 38px; height: 38px; }
.dock-item .dock-img { width: 38px; height: 38px; object-fit: contain; display: block; image-rendering: -webkit-optimize-contrast; }
.dock-item.is-active::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--red);
}
.dock-item .dock-tip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: var(--cream);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.dock-item:hover .dock-tip,
.dock-item:focus-visible .dock-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.dock-sep {
  width: 1px;
  align-self: stretch;
  margin: 7px 4px;
  background: rgba(120, 100, 72, .18);
}

/* ———— Mac 纸感窗口 ———— */
.mac-window {
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow-window);
  border: 1px solid rgba(120, 100, 72, .14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mac-titlebar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 42px;
  padding: 0 var(--sp-4);
  background: linear-gradient(180deg, #FEFBF4, #F7EFE0);
  border-bottom: 1px dashed rgba(120, 100, 72, .18);
  user-select: none;
}
.traffic { display: flex; gap: 7px; align-items: center; }
.traffic button {
  width: 11px; height: 11px;
  border-radius: 50%;
  position: relative;
  transition: transform var(--dur-fast);
}
.traffic button:hover { transform: scale(1.15); }
.traffic .t-close { background: var(--win-close); }
.traffic .t-min   { background: var(--win-min); }
.traffic .t-max   { background: var(--win-max); }
.mac-titlebar .title {
  flex: 1;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mac-titlebar .title-right { width: 52px; flex: 0 0 auto; }
.mac-body { flex: 1; min-height: 0; overflow: auto; }

/* ———— 按钮 ———— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--ink);
  color: var(--cream);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-2px) rotate(-.6deg); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.btn-pill-butter { background: var(--butter); color: var(--ink); border: 1px solid rgba(120,100,72,.16); }
.btn.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px dashed rgba(120, 100, 72, .3);
}
.btn.btn-ghost:hover { background: var(--paper); }
.btn.btn-purple { background: var(--purple); color: #fff; }
.btn.btn-purple:hover { background: var(--purple-deep); }
.btn .btn-ico { width: 16px; height: 16px; flex: 0 0 auto; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid rgba(120, 100, 72, .16);
  color: var(--ink-soft);
  transition: all var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--ink); color: var(--cream); transform: translateY(-2px); }
.icon-btn svg { width: 18px; height: 18px; }

/* ———— 格纹 gingham ———— */
.gingham {
  background-color: #FDF6F2;
  background-image:
    linear-gradient(90deg, rgba(214, 87, 78, .34) 50%, transparent 50%),
    linear-gradient(rgba(214, 87, 78, .34) 50%, transparent 50%);
  background-size: 46px 46px;
}
.gingham-soft {
  background-color: #FEF8F5;
  background-image:
    linear-gradient(90deg, rgba(214, 87, 78, .16) 50%, transparent 50%),
    linear-gradient(rgba(214, 87, 78, .16) 50%, transparent 50%);
  background-size: 38px 38px;
}

/* ———— 便签 sticky note ———— */
.sticky {
  position: relative;
  background: var(--butter);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 2px 2px 10px 2px;
  box-shadow: 0 3px 10px rgba(90, 72, 48, .16);
  transform: rotate(-2deg);
  font-family: var(--font-hand);
  line-height: 1.35;
  transition: transform var(--dur-med) var(--ease-spring), box-shadow var(--dur-med);
}
.sticky::after {
  content: "";
  position: absolute;
  right: 0; bottom: 0;
  width: 18px; height: 18px;
  background: linear-gradient(135deg, transparent 50%, rgba(180, 155, 95, .25) 50%);
  border-radius: 0 0 10px 0;
}
.sticky:hover { transform: rotate(0deg) translateY(-3px); box-shadow: var(--shadow-md); }
.sticky.is-link { cursor: pointer; }
.sticky .st-kicker {
  display: block;
  font-family: var(--font-sans);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 2px;
}

/* ———— 胶带 ———— */
.tape {
  position: absolute;
  width: 88px;
  height: 26px;
  background: rgba(246, 226, 154, .82);
  border-left: 1px dashed rgba(120, 100, 72, .2);
  border-right: 1px dashed rgba(120, 100, 72, .2);
  box-shadow: 0 1px 3px rgba(90, 72, 48, .14);
  pointer-events: none;
}
.tape.is-red { background: rgba(242, 181, 190, .8); }

/* ———— 贴纸 st 标签 ———— */
.sticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--butter-soft);
  color: var(--ink-soft);
  border: 1px dashed rgba(120, 100, 72, .28);
  transform: rotate(-1.5deg);
  box-shadow: 0 2px 6px rgba(90, 72, 48, .09);
}
.sticker.s-sage  { background: var(--sage-soft); }
.sticker.s-mist  { background: var(--mist-soft); }
.sticker.s-blush { background: var(--blush-soft); }
.sticker.s-lilac { background: var(--lilac-soft); }
.sticker.s-butter{ background: var(--butter-soft); }
.sticker.s-red   { background: var(--red-soft); }

/* ———— 星星闪片 ———— */
.sparkle {
  position: absolute;
  pointer-events: none;
  color: var(--red);
  opacity: .85;
}
.sparkle svg { width: 100%; height: 100%; }

/* ———— 拍立得 ———— */
.polaroid {
  background: var(--paper);
  padding: 9px 9px 30px;
  border-radius: 4px;
  box-shadow: var(--shadow-paper);
  border: 1px solid rgba(120, 100, 72, .1);
  position: relative;
  transition: transform var(--dur-med) var(--ease-spring),
              box-shadow var(--dur-med);
}
.polaroid:hover { transform: translateY(-5px) rotate(-1deg); box-shadow: var(--shadow-lift); }
.polaroid img { border-radius: 2px; width: 100%; }
.polaroid figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 5px;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 12px;
  color: var(--ink-mute);
}

/* ———— 弹窗 ———— */
.modal-root { position: relative; z-index: 400; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 48, 34, .34);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  animation: fadeIn var(--dur-fast) var(--ease-out);
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  animation: popIn var(--dur-med) var(--ease-spring);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ———— 占位标注 ———— */
.placeholder-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--ink-faint);
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 6px,
    rgba(120, 100, 72, .05) 6px, rgba(120, 100, 72, .05) 12px
  );
  border: 1px dashed rgba(120, 100, 72, .24);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}

/* ———— 衬线斜体小标题工具 ———— */
.serif-it {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: .01em;
}

/* ———— 响应式 ———— */
/* 窄屏：名字淡出收起（保留苹果图标） */
@media (max-width: 900px) {
  .menu-bar .mb-brand span { max-width: 0; opacity: 0; }
}

@media (max-width: 640px) {
  .menu-bar { gap: var(--sp-2); padding: 0 var(--sp-3); }
  .menu-bar .mb-app { display: none; }
  .menu-bar .mb-clock { font-size: 11px; }
  /* 两个重复的项目入口（都指向 /projects）在窄屏收起，给其余入口留空间 */
  .menu-bar .mb-item[href="#/projects"] { display: none; }
  .dock-item { width: 44px; height: 44px; }
  .dock-item svg { width: 36px; height: 36px; }
  .dock-item .dock-img { width: 36px; height: 36px; }
  .dock { gap: 4px; padding: 6px 10px; }
}
@media (max-width: 380px) {
  .menu-bar .mb-clock { display: none; }
  .dock-item { width: 40px; height: 40px; }
  .dock-item svg { width: 32px; height: 32px; }
  .dock-item .dock-img { width: 32px; height: 32px; }
}
