/* ============================================================
   Local English Vocabulary — base.css
   Design tokens / reset / typography / utilities
   ============================================================ */

:root {
  color-scheme: light;

  /* typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 25px;
  --text-3xl: 30px;

  /* spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* shape */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* layout */
  --sidebar-w: 244px;
  --topbar-h: 60px;
  --bottomnav-h: 58px;
  --content-max: 1160px;

  /* motion */
  --dur: 180ms;
  --dur-slow: 260ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* light palette */
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #eaeaec;
  --border: #e8e8ea;
  --border-strong: #d7d7dc;
  --text: #17171a;
  --text-2: #5f5f6a;
  --text-3: #90909b;

  --accent: #3b5bdb;
  --accent-hover: #2f4bc0;
  --accent-soft: #eef1fc;
  --on-accent: #ffffff;

  --success: #158a4e;
  --success-soft: #e7f6ed;
  --danger: #cf4040;
  --danger-soft: #fdeded;
  --warning: #a86f16;
  --warning-soft: #fdf3e2;

  --shadow-sm: 0 1px 2px rgba(20, 20, 24, 0.05);
  --shadow-md: 0 6px 20px rgba(20, 20, 24, 0.09);
  --shadow-lg: 0 24px 56px rgba(20, 20, 24, 0.18);
  --scrim: rgba(20, 20, 24, 0.42);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1012;
  --bg-elev: #16171a;
  --surface: #17181c;
  --surface-2: #1e1f24;
  --surface-3: #26272d;
  --border: #2a2b31;
  --border-strong: #3b3c44;
  --text: #ececee;
  --text-2: #a1a1ab;
  --text-3: #71717b;

  --accent: #7f97f8;
  --accent-hover: #96a9fa;
  --accent-soft: #1c2133;
  --on-accent: #101115;

  --success: #46b97d;
  --success-soft: #14251c;
  --danger: #ef6f66;
  --danger-soft: #2a1918;
  --warning: #dda74e;
  --warning-soft: #2a2317;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------- reset */

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

* {
  margin: 0;
}

/* hidden 属性必须始终生效：否则 .note{display:flex} 之类的规则会盖掉它，
   导致「空的红色错误框」被显示出来 */
[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.3;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input, select, textarea {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
  flex-shrink: 0;
}

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

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------- scrollbar */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--radius-full);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------------------------- page transition */

.view > .page {
  animation: page-in var(--dur-slow) var(--ease);
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 长单词 / 长释义不撑破布局 */
.page {
  overflow-wrap: anywhere;
}

/* ---------------------------------------------- utilities */

.dim {
  color: var(--text-3);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num {
  font-variant-numeric: tabular-nums;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.grow {
  flex: 1;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: 12px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-sm);
  transition: top var(--dur) var(--ease);
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  margin: 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-2);
}
