/* TELEIOS base layer ("Pop Studio").
   Reset, document, typography, focus, selection, scrollbars, icons, spinner and motion rules.
   Colours, radii, type and spacing come from css/tokens.css only.
   Layout / text utility classes (.row, .muted, …) live in components.css with the other shared classes. */

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

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
}

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  /* The app frame fills the window and scrolls inside its panes; the window itself never scrolls. */
  overflow: hidden;
  background-color: var(--canvas);
  color: var(--text);
  font: 500 var(--fs-md)/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

ul,
ol {
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }

strong,
b {
  font-weight: 700;
}

small {
  font-size: var(--fs-sm);
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

hr {
  height: 0;
  margin: var(--s-4) 0;
  border: 0;
  border-top: 1px solid var(--border);
}

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

button,
input,
select,
textarea {
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

textarea {
  resize: vertical;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

table {
  border-collapse: collapse;
}

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

/* `hidden` must win over any component display rule. */
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- focus and selection */

:where(a, button, input, select, textarea, summary, [tabindex], [contenteditable="true"]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

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

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

/* ---------------------------------------------------------------- scrollbars: thin and themed */

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text-muted) 55%, transparent) transparent;
}

/* Safari / older Chromium (ignored where scrollbar-color is supported) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--text-muted) 55%, transparent);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: var(--r-pill);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---------------------------------------------------------------- icons and spinner */

.icon {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  overflow: visible;
}

.spinner {
  display: inline-block;
  flex: none;
  vertical-align: middle;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: hs-spin 0.7s linear infinite;
}

@keyframes hs-spin {
  to { transform: rotate(360deg); }
}

@keyframes hs-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes hs-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  /* !important: has to beat every component's own transition / animation declaration. */
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }

  /* A busy indicator still has to say "working": keep it turning, slowly. */
  .spinner {
    animation: hs-spin 1.6s linear infinite !important;
  }
}
