/* Hallmark base · floor defaults · app scope · cobalt
 * Reset、应用外壳、抽屉机制与工具类。视觉语言一律在 theme.css。
 */

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

html, body { overflow-x: clip; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-paper);
}

body {
  min-height: 100vh;
  color: var(--color-ink);
  background: var(--color-paper);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.6;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-deep); }
img, svg { display: block; max-width: 100%; }
p, li, dd, dt, h1, h2, h3 { overflow-wrap: break-word; }
h1, h2, h3 { text-wrap: balance; }

::selection { background: var(--color-selection); color: var(--color-ink); }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ——— 应用外壳 ——— */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-paper-2);
  border-right: var(--rule-hair) solid var(--color-rule);
}

.nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--color-rule-2); border-radius: var(--radius-pill); }
.nav::-webkit-scrollbar-track { background: transparent; }

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  min-height: var(--topbar-height);
  background: var(--color-paper);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-2xl) var(--space-4xl);
}

/* ——— 移动端抽屉：60rem 以下收进菜单 ——— */
.menu-toggle { display: none; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

@media (max-width: 60rem) {
  /* 抽屉：桌面列在窄屏收起，打开时为覆盖层（不用视口外的负位移） */
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    width: min(var(--sidebar-width), 84vw);
    box-shadow: var(--shadow-modal);
    animation: drawer-in var(--dur-short) var(--ease-out) both;
  }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
  }
}

body.nav-open { overflow: hidden; }

/* ——— 工具类 ——— */
.muted { color: var(--color-muted); }
.small { font-size: var(--text-sm); }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading { opacity: 0.6; pointer-events: none; }

/* 骨架：与将来内容同形，不用转圈 */
.skeleton {
  border-radius: var(--radius-sm);
  background: var(--color-skeleton);
  animation: skeleton-pulse var(--dur-short) var(--ease-in-out) infinite alternate;
}
@keyframes skeleton-pulse { from { opacity: 1; } to { opacity: 0.55; } }

/* ——— 滚动条 ——— */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--color-paper-2); }
::-webkit-scrollbar-thumb {
  background: var(--color-rule-2);
  border: 2px solid var(--color-paper-2);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-muted); }

/* ——— 动效退让 ——— */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ——— 打印 ——— */
@media print {
  *, *::before, *::after { background: transparent !important; color: var(--color-print-ink) !important; box-shadow: none !important; animation: none !important; }
  html { background: #fff !important; }
  .sidebar, .topbar, .toast, .menu-toggle, .card-actions, .pager, .filters, .back-link, .tabs { display: none !important; }
  .main { margin: 0 !important; }
  .content { max-width: none; padding: 0 !important; }
}
