/* ============================================================
   Xiehe Nexus — reset, base elements, accessibility primitives
   ============================================================ */

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

/* "hidden" always wins. Without this, any class that sets display (a .field,
   a .btn) quietly shows elements the code has hidden. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-tight);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

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

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

/* Icons sit inside sentences and labels, so they must behave like text. */
svg.icon {
  display: inline-block;
  vertical-align: -0.18em;
  flex: none;
}

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

input, select, textarea {
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}
a:hover {
  color: var(--accent-hover);
}

table {
  border-collapse: collapse;
  width: 100%;
}

hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: var(--sp-5) 0;
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* ---- focus: visible, never suppressed -------------------- */
/* Suppress the ring only for pointer focus; keyboard focus always shows one. */
:focus:not(:focus-visible) {
  outline: none;
}
/*
  The ring is drawn with both `outline` and a `box-shadow` pair. Outline is the
  correct property, but some engines suppress it on form controls inside a
  composited subtree, and a keyboard user who cannot see where they are is
  locked out of the platform. The box-shadow ring costs nothing and always
  paints; the inner shadow in the page colour keeps it legible against any
  surface.
*/
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-ring);
}

/* ---- screen-reader + skip link --------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: calc(var(--z-toast) + 1);
  background: var(--accent);
  color: var(--on-accent);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus-visible {
  top: var(--sp-4);
  color: var(--on-accent);
}

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

/* ---- high-contrast / forced colors ----------------------- */
@media (forced-colors: active) {
  .card,
  .btn,
  .chip {
    border: 1px solid CanvasText;
  }
}

/* ---- shared animations ----------------------------------- */
@keyframes xn-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes xn-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes xn-spin {
  to { transform: rotate(360deg); }
}
@keyframes xn-shimmer {
  0% { background-position: -420px 0; }
  100% { background-position: 420px 0; }
}

/* ---- print ----------------------------------------------- */
@media print {
  .topbar,
  .sidenav,
  .rail,
  .mobile-tabs,
  .toast-region,
  .composer-fab {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .main {
    padding: 0;
  }
}
