/*
 * The theme every Sounding site shares: the colour and type tokens, the
 * three-state appearance choice on <html data-theme>, and the appearance
 * control. The product's own pages link it ahead of styles.css; a site
 * without the wasm (the blog, the pricing demo) copies this file verbatim
 * along with web-rs/prefs/theme.js and the control's markup in
 * web-rs/prefs/theme-switch.html (README.md beside this file says how).
 * Nothing in it may depend on styles.css, so it stands alone there.
 */

/* The wordmark's typeface, self-hosted: the CSP takes fonts from the page's
   own origin alone. The file carries only the letters of thesounding.site
   (web-rs/prefs/brand/README.md), and every site ships brand/ beside this
   sheet, hence the relative URL. Swap: the system font shows until it
   arrives rather than nothing. */
@font-face {
  font-family: "Space Grotesk";
  src: url("brand/SpaceGrotesk-thesounding.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

/*
 * Appearance is three-state: the system's
 * preference by default, or a person's own light or dark choice stamped on
 * <html data-theme>. Every colour token names both its values here and
 * `color-scheme` picks between them, so the choice is one property rather
 * than a second palette to keep in step — and the native controls (the
 * language select and its dropdown) follow that same property.
 */
:root {
  color-scheme: light dark;
  --fg: light-dark(#1a1a1a, #e8e8e8);
  --bg: light-dark(#fafafa, #17191c);
  --accent: light-dark(#1e5f8c, #6fb3e0);
  /* An edge, not a tint: inputs, selects and the invite-link box end here,
     so it holds 3:1 against the page in both schemes (WCAG 1.4.11). */
  --border: light-dark(#8a8a8a, #6a6e75);
  /* The one red is too dark for the dark page (2.4:1); its dark value is a
     lighter red that measures the same way the light one does. */
  --error: light-dark(#a3241f, #ff7b73);
  --ok: light-dark(#1e6f3e, #6fce96);
  /*
   * Three greys, by what they may colour. --dim measures 3.8:1 against the
   * light background, under AA for text, so it stays inside the trace
   * drawer — phase headers, directions, sizes, notes, the detail under a
   * row — where the log's density wants the hierarchy; nothing a person is
   * asked to read or press outside the drawer uses it. --faint is for what
   * repeats information already in the text beside it: the trace
   * timestamps and the rules around a phase header. --quiet clears 4.5:1 in
   * both schemes (measured in web-rs/prefs/tests/contrast.rs) and is the
   * colour of every quiet *text*: hints, the header row, the trace toggle,
   * the account line, the SAS words.
   */
  --dim: color-mix(in srgb, var(--fg) 55%, transparent);
  --faint: color-mix(in srgb, var(--fg) 35%, transparent);
  --quiet: color-mix(in srgb, var(--fg) 70%, transparent);
  --trace-bg: light-dark(
    color-mix(in srgb, var(--fg) 4%, var(--bg)),
    color-mix(in srgb, #000 25%, var(--bg))
  );
  --row-hover: color-mix(in srgb, var(--accent) 8%, transparent);
  /*
   * The type scale: one hero per screen — the
   * title, the check words, the answer — and everything else stays in the
   * sm/base band so the hero has nothing to compete with. Every font-size
   * in this sheet names one of the five (the trace caret, a glyph scaled to
   * its button, is the one em value); --text-sm is the floor, the trace
   * drawer included.
   */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.4rem;
  --text-2xl: 1.75rem;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* A person's own choice, stamped before first paint by the shells' inline
   script and again by the theme control. No attribute means the system
   decides, which is the default and the state the control calls Auto. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* The appearance control: the three states side
   by side in one segmented group, the one in force filled. Quiet enough to
   sit beside the language control without either shouting. */
.theme-switch {
  /* Inline, so on a page that sets it in running content it is as wide as
     its three buttons; in the product's header row it is a flex item
     either way. */
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  overflow: hidden;
}

.theme-switch button {
  /* Each state is an icon (its name is the label and the title), so each
     button is a square touch target, the same in every language. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 2.75rem; /* ≥44px touch target */
  width: 2.75rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  /* What styles.css's base button gives the product's pages, said here so
     the control looks and behaves the same on a page without it. */
  font-family: inherit;
  cursor: pointer;
}

.theme-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-switch button + button {
  border-inline-start: 1px solid var(--border);
}

.theme-switch button:hover {
  color: var(--fg);
  background: var(--row-hover);
  filter: none; /* the base button's hover brightens a filled shape; this one isn't */
}

.theme-switch button[aria-pressed="true"] {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 10%, transparent);
}

/* The icon itself: block, so no line box adds height under it. */
.theme-switch svg {
  display: block;
}

/* On a phone the product's header row is full (styles.css says why): the
   group keeps its size, and the lockup beside it is what steps down. */
@media (max-width: 30rem) {
  .theme-switch {
    flex-shrink: 0;
  }
}

/* The footer every Sounding site shares (web-rs/prefs/footer.rs, pasted on
   the sites without the wasm as footer.html): the lockup on a line of its own,
   then the row of links to the four sites and the source, and the AI:X
   badge. Quiet text, like the product's header row; it sets no width or
   outer margin, which are the site's. */
.sounding-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid color-mix(in srgb, var(--fg) 15%, transparent);
  font-size: var(--text-sm);
  color: var(--quiet);
}

.sounding-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
}

.sounding-footer nav a {
  color: inherit;
}

.sounding-footer nav a:hover {
  color: var(--fg);
}

/* Both badge images are in the markup; show the one for the scheme in
   force. A manual choice is on <html data-theme>; with none (Auto) the
   system's preference decides — which a <picture> source's media query
   alone could not follow, since it never sees the manual choice. Each
   image's display comes from its own class alone: a broader rule such as
   `.sounding-footer img { display: block }` outranks `.ai-badge-dark` and
   shows both. */
.ai-badge-light {
  display: block;
}
.ai-badge-dark {
  display: none;
}
:root[data-theme="dark"] .ai-badge-light {
  display: none;
}
:root[data-theme="dark"] .ai-badge-dark {
  display: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ai-badge-light {
    display: none;
  }
  :root:not([data-theme="light"]) .ai-badge-dark {
    display: block;
  }
}

/* The logo (web-rs/prefs/src/brand.rs, pasted as lockup.html): its strokes
   take the page's tokens, so it follows the appearance choice the way the
   text does. Ink for the S, accent for the pings, the echoes and the dots. */
.logo-ink {
  fill: none;
  stroke: var(--fg);
}
.logo-accent {
  fill: none;
  stroke: var(--accent);
}
.logo-accent-fill {
  fill: var(--accent);
}

/* The lockup: the logo, then the domain in Space Grotesk — "the" and "site"
   quiet, "sounding" heavier, and the full stop a drawn accent dot about the
   size of the logo's own. The logo's height follows the type, its width the
   logo's own proportions, so one font-size sizes the whole lockup. */
.lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.12em;
  white-space: nowrap;
  line-height: 1;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
}
.lockup .logo {
  height: 1.9em;
  width: auto;
  flex: none;
}
.lockup-the,
.lockup-site {
  font-weight: 400;
  color: var(--quiet);
}
.lockup-name {
  font-weight: 600;
}
.lockup-dot {
  display: inline-block;
  width: 0.2em;
  height: 0.2em;
  margin: 0 0.07em;
  border-radius: 50%;
  background: var(--accent);
}
.lockup:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A header's lockup (`lockup-steps`) steps down as its row narrows, so the
   controls beside it keep their room: the whole domain, then the mark and
   "sounding", then the mark alone. Measured 2026-11-26 in the product's
   header row (Chromium): the whole lockup 175 px, mark and "sounding"
   108 px, the controls 214 px whatever the language (the widest tag, RU,
   is under a pixel wider than EN), plus the row's gaps (0.5rem on a phone,
   styles.css) and the column's 2.5rem of padding. Each step leaves a few
   pixels to spare: the whole lockup from 441 px, "sounding" from 369. */
@media (max-width: 27.5rem) {
  .lockup-steps .lockup-the,
  .lockup-steps .lockup-dot,
  .lockup-steps .lockup-site {
    display: none;
  }
}
@media (max-width: 23rem) {
  .lockup-steps .lockup-word {
    display: none;
  }
}

/* The footer's lockup is whole and has a line of its own above the links. */
.sounding-footer .lockup {
  flex-basis: 100%;
  justify-content: center;
  font-size: var(--text-base);
}

/* The lockup's ping (decided 2026-11-27): when the pointer rests on the
   lockup or it takes focus, theme.js (the sites without the wasm) or the
   Lockup component adds `lockup-ping` for a moment. The ping leaves the
   bottom dot and runs down its arcs, waves spreading from the dot; the echo
   runs up the top arcs into the top dot, which sends waves of its own.
   Each part waits out its delay dimmed (fill-mode both), so the whole logo
   dims at once and lights in order. Nothing moves for anyone who asks for
   reduced motion. The waves sit in the logo hidden until then, and their
   own fill and opacity attributes keep them hidden on a page whose
   stylesheet predates them. */
.logo-wave {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
.logo-wave,
.logo-ping-dot,
.logo-echo-dot {
  transform-box: fill-box;
  transform-origin: center;
}
.lockup .logo {
  overflow: visible;
}
@keyframes logo-arc-light {
  from {
    opacity: 0.12;
  }
  to {
    opacity: 1;
  }
}
@keyframes logo-dot-pulse {
  0% {
    opacity: 0.35;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.6);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes logo-wave-out {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  1% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: scale(17);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .lockup-ping .logo-ping-arc,
  .lockup-ping .logo-echo-arc {
    animation: logo-arc-light 120ms ease-out both;
  }
  .lockup-ping .logo-ping-dot,
  .lockup-ping .logo-echo-dot {
    animation: logo-dot-pulse 400ms ease-out both;
  }
  .lockup-ping .logo-wave {
    animation: logo-wave-out 700ms ease-out both;
  }
  .lockup-ping .logo-ping-dot,
  .lockup-ping .logo-ping-wave-1 {
    animation-delay: 100ms;
  }
  .lockup-ping .logo-ping-1 {
    animation-delay: 150ms;
  }
  .lockup-ping .logo-ping-2 {
    animation-delay: 210ms;
  }
  .lockup-ping .logo-ping-wave-2 {
    animation-delay: 220ms;
  }
  .lockup-ping .logo-ping-3 {
    animation-delay: 270ms;
  }
  .lockup-ping .logo-ping-wave-3 {
    animation-delay: 340ms;
  }
  .lockup-ping .logo-echo-1 {
    animation-delay: 550ms;
  }
  .lockup-ping .logo-echo-2 {
    animation-delay: 610ms;
  }
  .lockup-ping .logo-echo-3 {
    animation-delay: 670ms;
  }
  .lockup-ping .logo-echo-dot,
  .lockup-ping .logo-echo-wave-1 {
    animation-delay: 730ms;
  }
  .lockup-ping .logo-echo-wave-2 {
    animation-delay: 850ms;
  }
  .lockup-ping .logo-echo-wave-3 {
    animation-delay: 970ms;
  }
}
