/* ============================================================
   Swiftpoint Hub — base layer

   Reset, element defaults, layout primitives and accessibility.
   Loaded after tokens.css, before ui.css and page CSS.
   Page stylesheets own layout; this file owns everything global.
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchor targets clear the sticky header */
  scroll-padding-top: calc(var(--hdr-h) + var(--sp-4));
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  /* Two soft ambient washes; tokens keep them consistent per theme */
  background-image:
    radial-gradient(900px 420px at 85% -10%, var(--amb-1), transparent 60%),
    radial-gradient(800px 500px at -10% 25%, var(--amb-2), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---- Typography ---- */
h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 {
  font-size: var(--fs-h1);
}
h2 {
  font-size: var(--fs-h2);
}
h3 {
  font-size: var(--fs-h3);
}
h4 {
  font-size: var(--fs-body);
}

p {
  margin: 0 0 var(--sp-4);
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin: 0 0 var(--sp-4);
  padding-left: 1.35em;
}

li {
  margin-bottom: var(--sp-1);
}

hr {
  height: 1px;
  border: 0;
  margin: var(--sp-6) 0;
  background: var(--line);
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 3px;
  transition: color var(--t-fast), text-decoration-color var(--t-fast);
}

a:hover {
  text-decoration-color: var(--accent);
}

strong,
b {
  font-weight: 600;
  color: var(--text);
}

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

code {
  padding: 0.12em 0.38em;
  border-radius: var(--r-xs);
  background: var(--code-bg);
  border: 1px solid var(--line);
  color: var(--accent);
}

pre {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--code-bg);
  border: 1px solid var(--line);
  overflow-x: auto;
  line-height: 1.55;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
}

blockquote {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-4);
  border-left: 2px solid var(--accent);
  color: var(--text-2);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th,
td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--text-3);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Form element defaults ---- */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: inherit;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Number inputs: the spinners break alignment in dense tables */
input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

::placeholder {
  color: var(--text-3);
  opacity: 1;
}

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

/* ---- Scrollbars ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
}

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

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

*::-webkit-scrollbar-thumb {
  background: var(--track);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: content-box;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link: first tab stop, only visible once focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-4);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: top var(--t-fast);
}

.skip-link:focus {
  top: var(--sp-3);
}

/* ---- Layout primitives ---- */
.container {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

/* ---- App shell ----
   Pages that behave like a desktop app (builder, recordings, OLED
   editor) opt in with <body data-app-shell>. The header keeps its
   natural height — one row or two — and the content takes the rest.

   Flexbox instead of `position: fixed; inset: <header-height>`: a
   tool strip that wraps must never push the panels out of view, and
   this needs no height arithmetic to stay correct. */
body[data-app-shell] {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

body[data-app-shell] > .hdr {
  flex: 0 0 auto;
  position: relative;
  top: auto;
}

/* `data-app-shell` means "the body is a fixed window": its children lay
   out in it and it clips, so every pane that can hold more than fits needs
   its own scroller. Only two pages are built that way — the Profile Builder
   and the OLED editor — and both are tools, not documents.

   A page that scrolls normally must NOT carry this. The recordings library
   did, and the symptom was a page whose content could not be reached below
   the fold, plus a missing footer (chrome.js skips it on this flag). */
body[data-app-shell] > main,
body[data-app-shell] > .app-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.stack > * + * {
  margin-top: var(--sp-4);
}

.stack-sm > * + * {
  margin-top: var(--sp-2);
}

.stack-lg > * + * {
  margin-top: var(--sp-6);
}

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

.row-wrap {
  flex-wrap: wrap;
}

.spacer {
  flex: 1 1 auto;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--text-2);
}

[hidden] {
  display: none !important;
}

/* ---- Shared motion ---- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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