/* ═══════════════════════════════════════════
   Base Styles — 联合文社
   ═══════════════════════════════════════════ */

@import './tokens.css';

*,*::before,*::after {
  margin:0;padding:0;box-sizing:border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--ui-bg);
  color: var(--ui-fg);
  line-height: 1.7;
  min-height: 100vh;
  cursor: var(--cursor-default);
  transition: background var(--dur-slow) var(--ease-out),
              color var(--dur-slow) var(--ease-out);
  overflow-x: hidden;
}

/* ── Selection ── */
::selection {
  background: var(--ui-selection);
  color: var(--ui-selection-fg);
}

/* ── Typography ── */
h1,h2,h3,h4,h5,h6 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.04em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h4 { font-size: 1.125rem; letter-spacing: -0.02em; }

p { margin-bottom: var(--gap-md); color: var(--ui-fg-muted); line-height: 1.75; }

a {
  color: var(--ui-fg);
  text-decoration: none;
  border-bottom: var(--ui-border) solid transparent;
  transition: border-color var(--dur-fast) var(--ease-out);
  cursor: var(--cursor-pointer);
}
a:hover { border-bottom-color: var(--ui-fg); }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--ui-surface);
  padding: 2px 6px;
  border: var(--ui-border) solid var(--ui-line);
}

pre {
  background: var(--ui-surface);
  border: var(--ui-border) solid var(--ui-line);
  padding: var(--gap-md);
  overflow-x: auto;
  margin-bottom: var(--gap-md);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--ui-bg); }
::-webkit-scrollbar-thumb {
  background: var(--ui-line-strong);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: var(--ui-fg-muted); }

/* ── Container ── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gap-lg);
}

/* ── Grid System ── */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--gap-md));
}
.col { flex: 1; padding: 0 var(--gap-md); }
.col-6 { flex: 0 0 50%; padding: 0 var(--gap-md); }
.col-4 { flex: 0 0 33.333%; padding: 0 var(--gap-md); }
.col-8 { flex: 0 0 66.666%; padding: 0 var(--gap-md); }

@media (max-width: 768px) {
  .col-6, .col-4, .col-8, .col { flex: 0 0 100%; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .col-4 { flex: 0 0 50%; }
}

/* ── Utilities ── */
.text-center { text-align: center; }
.text-muted  { color: var(--ui-fg-muted); }
.text-accent { color: var(--ui-accent); }
.text-mono   { font-family: var(--font-mono); }
.mt-sm  { margin-top: var(--gap-sm); }
.mt-md  { margin-top: var(--gap-md); }
.mt-lg  { margin-top: var(--gap-lg); }
.mt-xl  { margin-top: var(--gap-xl); }
.mt-2xl { margin-top: var(--gap-2xl); }
.mt-3xl { margin-top: var(--gap-3xl); }
.mb-sm  { margin-bottom: var(--gap-sm); }
.mb-md  { margin-bottom: var(--gap-md); }
.mb-lg  { margin-bottom: var(--gap-lg); }
.mb-xl  { margin-bottom: var(--gap-xl); }
.mb-2xl { margin-bottom: var(--gap-2xl); }
.mb-3xl { margin-bottom: var(--gap-3xl); }

/* ── Mouse Trail Canvas ── */
#mouse-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Cursor Effects Override ── */
button, [role="button"], .btn, a, select, input[type="submit"] {
  cursor: var(--cursor-pointer);
}
input[type="text"], input[type="email"], input[type="password"],
textarea, [contenteditable="true"] {
  cursor: var(--cursor-text);
}

/* ── Focus ── */
:focus-visible {
  outline: var(--ui-border) solid var(--ui-fg);
  outline-offset: 2px;
}

/* ── Keyframes (no overshoot) ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Enter animation classes ── */
.anim-enter {
  animation: fadeIn var(--dur-slow) var(--ease-out) both;
}
.anim-enter-1 { animation-delay: 50ms; }
.anim-enter-2 { animation-delay: 100ms; }
.anim-enter-3 { animation-delay: 150ms; }
.anim-enter-4 { animation-delay: 200ms; }
.anim-enter-5 { animation-delay: 250ms; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══ Global Mobile Patches ═══ */
@media (max-width: 768px) {
  body {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }
  /* Larger tap targets */
  button, .btn, [role="button"], a.button {
    min-height: 44px;
    min-width: 44px;
  }
  /* Prevent iOS input zoom */
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ═══ Print Styles ═══ */
@media print {
  .navbar, .nav-theme-btn, .cursor-dot, .cursor-ring, #mouse-bg,
  #admin-sidebar, .admin-menu-toggle, .theme-btn { display: none !important; }
  body { background: #fff; color: #000; }
}
