/* Xyncema One — shared primitives. Visual character lives in each demo stylesheet;
   this file only provides reset, accessibility behaviour and neutral mechanics driven by theme tokens. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.on-dark :focus-visible { outline-color: var(--primary-on-dark); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: .75rem 1rem;
  background: var(--text); color: var(--bg); text-decoration: none; border-radius: 4px;
}
.skip-link:focus { top: 1rem; }

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

/* ---------- Preview bar (showcase chrome, not part of the demo design) ---------- */
.xy-bar {
  position: relative; z-index: 60; background: #0E0F12; color: #E9EAEE;
  font: 500 13px/1.3 "Manrope", "Helvetica Neue", Arial, sans-serif; letter-spacing: 0;
}
.xy-bar__inner {
  display: flex; align-items: center; gap: .5rem 1rem; min-height: 40px;
  padding: .35rem clamp(1rem, 3vw, 2rem); flex-wrap: wrap;
}
.xy-bar a, .xy-bar button {
  color: #E9EAEE; text-decoration: none; background: none; border: 0; padding: .35rem .15rem;
  min-height: 32px; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
}
.xy-bar svg { width: 15px; height: 15px; flex: none; }
.xy-bar a:hover, .xy-bar button:hover { color: #FFFFFF; text-decoration: underline; text-underline-offset: 3px; }
.xy-bar :focus-visible { outline: 2px solid #A59CF7; outline-offset: 2px; }
.xy-bar__brand { font-weight: 700; }
.xy-bar__name { color: #A8ACB6; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xy-bar__sep { width: 1px; height: 16px; background: #3A3D45; }
@media (max-width: 640px) {
  .xy-bar__name, .xy-bar__sep--name, .xy-bar__long { display: none; }
  .xy-bar__inner { justify-content: space-between; }
}

/* ---------- Dialog & drawer mechanics ---------- */
dialog.xy-dialog {
  border: 0; padding: 0; margin: auto; color: var(--text); background: var(--surface);
  width: min(560px, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  border-radius: var(--radius); box-shadow: 0 24px 80px rgba(0, 0, 0, .28); overflow: hidden;
}
dialog.xy-dialog[open] { display: flex; flex-direction: column; }
dialog.xy-dialog::backdrop { background: rgba(10, 12, 16, .55); }
.xy-dialog__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.25rem 1.25rem .75rem; border-bottom: 1px solid var(--border);
}
.xy-dialog__title { font-family: var(--font-heading); font-size: 1.35rem; line-height: 1.2; }
.xy-dialog__body { padding: 1.25rem; overflow: auto; overscroll-behavior: contain; }
.xy-dialog__foot { padding: 1rem 1.25rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.xy-close {
  flex: none; width: 44px; height: 44px; margin: -.5rem -.5rem 0 0; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 999px; color: inherit;
}
.xy-close:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.xy-close svg { width: 20px; height: 20px; }

dialog.xy-drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(440px, 100vw); border-radius: 0;
}
dialog.xy-drawer[open] { animation: xy-drawer-in .22s ease-out; }
@keyframes xy-drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.xy-drawer .xy-dialog__body { flex: 1 1 auto; }
body.xy-locked { overflow: hidden; }

/* Lightbox */
dialog.xy-lightbox {
  width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0;
  background: rgba(12, 12, 12, .96); color: #F4F4F4; box-shadow: none;
}
dialog.xy-lightbox[open] { display: grid; grid-template-rows: auto 1fr auto; }
.xy-lightbox__bar { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; font-size: .9rem; }
.xy-lightbox__stage { display: grid; place-items: center; padding: 0 clamp(.5rem, 4vw, 4rem); min-height: 0; }
.xy-lightbox__stage img { max-height: calc(100dvh - 9rem); width: auto; object-fit: contain; }
.xy-lightbox__nav { display: flex; justify-content: center; gap: 1rem; padding: 1rem; }
.xy-lightbox button { color: #F4F4F4; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); min-height: 44px; min-width: 44px; padding: 0 1rem; border-radius: 999px; }
.xy-lightbox button:hover { background: rgba(255,255,255,.16); }
.xy-lightbox :focus-visible { outline-color: #FFFFFF; }

/* ---------- Forms (mechanics; demos restyle) ---------- */
.xy-field { display: grid; gap: .4rem; }
.xy-field label, .xy-legend { font-weight: 600; font-size: .9rem; }
.xy-hint { font-size: .85rem; color: var(--muted); }
.xy-input {
  width: 100%; min-height: 46px; padding: .6rem .8rem; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--text) 30%, var(--border)); border-radius: min(var(--radius), 10px);
}
textarea.xy-input { min-height: 110px; resize: vertical; }
.xy-input:focus-visible { outline-offset: 1px; }
.xy-input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
/* iOS Safari zooms the page when a field under 16px takes focus. Touch screens only, so desktop type is untouched. */
@media (pointer: coarse) {
  select, textarea, input:not([type="radio"]):not([type="checkbox"]):not([type="range"]):not([type="hidden"]) { font-size: max(16px, 1em) !important; }
}
.xy-error { display: flex; gap: .4rem; align-items: flex-start; color: var(--danger); font-size: .88rem; font-weight: 600; }
.xy-error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; margin-top: .1rem; border-radius: 50%; background: var(--danger); color: #fff; font-size: .72rem; }
fieldset.xy-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.xy-demo-note {
  display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; line-height: 1.45;
  padding: .7rem .85rem; border-radius: min(var(--radius), 8px);
  background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text);
}
.xy-demo-note svg { flex: none; width: 18px; height: 18px; margin-top: .1rem; }

/* ---------- Attribution (shown in every demo footer) ---------- */
.xy-attribution { display: grid; gap: .35rem; font-size: .85rem; line-height: 1.5; }
.xy-attribution strong { font-weight: 600; }
.xy-attribution button { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

.xy-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
