/* brand.css -- the Bort Studio kit for BotAI: the logo, the sun/moon button
   and, on the public site, the base and component states (.dx-*).

   Bort's app/globals.css is the source (its `.dx-*` states, verbatim where the
   markup allows); tokens.css carries every value. NOTHING HERE NAMES A
   COLOUR -- only var(--token) -- so both themes and both accents follow, and
   brandTokens.test.ts fails on a literal.

   SCOPE. The logo and the toggle are drawn on every surface that loads this
   file (the public pages and the cabinet header). Everything else is under
   `.dx-site`, the class the public pages put on <body>: the cabinet and /admin
   keep their own components until phase 2 restyles them, and pick up the new
   palette only through the aliases in tokens.css. */

/* ==========================================================================
   1. The logo -- src/core/brandMark.ts draws the markup
   ========================================================================== */

.bai-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: normal;
  text-decoration: none;
}
.bai-logo-mark { flex: none; display: block; }
/* The word and its label are ONE line: „Bort" then, on its baseline, the small
   label (Bort's Logo.tsx). brandMark.ts writes the two font sizes inline --
   the word's `size`, the label's max(9, round(size × .5)) -- so a logo drawn at
   another size keeps the proportion. */
.bai-logo-text {
  display: inline-block;
  font-size: var(--type-heading);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
}
.bai-logo-word { color: var(--text); }
.bai-logo-suffix {
  margin-left: .1em;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.bai-logo-pulse { animation: dx-logo-pulse 2.4s ease-in-out infinite; }
@keyframes dx-logo-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* ==========================================================================
   2. The sun/moon button -- theme-boot.js handles the click
   Both icons are in the markup; this shows the one for the current theme, so
   nothing flashes. Sun in the dark theme (press for light), moon in the light.
   ========================================================================== */

.dx-theme-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  transition: background-color var(--t-base), border-color var(--t-base), transform .15s;
}
.dx-theme-toggle svg { display: block; width: var(--icon); height: var(--icon); animation: dx-theme-in .32s var(--ease) both; }
.dx-theme-moon { display: none !important; }
html[data-theme="light"] .dx-theme-sun,
html[data-theme-default="light"]:not([data-theme]) .dx-theme-sun { display: none !important; }
html[data-theme="light"] .dx-theme-moon,
html[data-theme-default="light"]:not([data-theme]) .dx-theme-moon { display: block !important; }
@media (hover: hover) {
  .dx-theme-toggle:hover { background: var(--tint-05); border-color: var(--line-4); color: var(--text); }
}
.dx-theme-toggle:active { transform: scale(.97); }
.dx-theme-toggle:focus-visible { outline: 2px solid var(--ac-ui); outline-offset: 3px; }
@keyframes dx-theme-in { from { opacity: 0; transform: rotate(-60deg) scale(.6); } to { opacity: 1; transform: none; } }

/* THE BOOT SCREEN (motion.boot; /assets/boot-screen.js sets the class). The
   page's ground (--bg: dark, or light in the light theme) with a 2px accent
   line drawn across its centre, fading out by 1.2s. Pseudo-elements of <html>,
   so it needs no markup and exists before <body> does; the animation ends at
   `visibility: hidden`, so a timer that never fires still leaves nothing
   behind, and it never takes a click. Off under reduced motion. */
html.dx-booting::before,
html.dx-booting::after {
  content: "";
  position: fixed;
  pointer-events: none;
}
html.dx-booting::before {
  inset: 0;
  z-index: 2147483646;
  background: var(--bg);
  animation: dx-boot-ground 1.2s var(--ease) forwards;
}
html.dx-booting::after {
  top: 50%;
  left: 50%;
  z-index: 2147483647;
  width: 120px;
  height: 2px;
  margin: -1px 0 0 -60px;
  border-radius: 1px;
  background: var(--ac);
  transform-origin: 0 50%;
  animation: dx-boot-line 1.2s var(--ease) forwards;
}
@keyframes dx-boot-ground { 0%, 70% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@keyframes dx-boot-line { 0% { transform: scaleX(0); } 60% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  html.dx-booting::before,
  html.dx-booting::after { content: none; animation: none; }
}

/* THE SKIP LINK (design/bort-standard.json → navigation.header.a11y.skipLink,
   phase 2g-header): the first focusable element of every page, hidden until
   it is focused, then shown top-left in the focus style. Every surface writes
   it — the public header (publicHeader.ts), the cabinet and the admin panel. */
.dx-skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text) !important;
  font-family: var(--font-sans);
  font-size: var(--type-emphasis);
  font-weight: 600;
  text-decoration: none !important;
  transform: translateY(calc(-100% - 16px));
}
.dx-skip:focus,
.dx-skip:focus-visible {
  transform: none;
  outline: 2px solid var(--ac-ui) !important;
  outline-offset: 3px !important;
}
.dx-skip-target:focus,
main[tabindex="-1"]:focus { outline: none !important; }

/* ==========================================================================
   3. The public site's base (body.dx-site)
   ========================================================================== */

html:has(body.dx-site) { background: var(--bg); scrollbar-color: var(--line-2) var(--bg); }
.dx-site {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  /* The standard's `type.body`: 16px, line-height 1.6, 17 from md (768). The
     product's scale has no 17 rung, so md takes the nearest, --type-title
     (17.5); `type.small` (14) is --type-emphasis (14.5) for the same reason. */
  font-size: var(--type-lead);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 768px) {
  .dx-site { font-size: var(--type-title); }
}
.dx-site .theme-dark { color: var(--text); }
.dx-site ::selection { background: var(--ac); color: var(--ac-on); }
.dx-site :focus-visible { outline: 2px solid var(--ac-ui) !important; outline-offset: 3px !important; }
.dx-site a:not(.b-btn):not(.btn):not(.bai-logo) { color: var(--ac-text); }
@media (hover: hover) {
  .dx-site a:not(.b-btn):not(.btn):not(.bai-logo):hover { color: var(--text); }
}
/* A link inside running text is underlined: colour alone does not tell it
   from the words around it (WCAG 1.4.1, axe: link-in-text-block). */
.dx-site :is(p, li, td, dd, blockquote) a:not(.b-btn):not(.btn):not(.bai-logo) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.dx-site ::placeholder { color: var(--placeholder); }
.dx-mono, .dx-site code, .dx-site kbd, .dx-site pre { font-family: var(--font-mono); }

/* Headings: tuned per <html lang> (tokens.css: --hk --hs --hls --hlh), 700 and
   Georgian stretched to 86% on phones, 600 on desktop. */
.dx-site h1, .dx-site h2, .dx-site h3, .dx-site .b-display {
  font-family: var(--font-sans);
  font-weight: var(--hw);
  font-stretch: var(--hs-m);
  overflow-wrap: break-word;
}
@media (min-width: 768px) {
  .dx-site h1, .dx-site h2, .dx-site .b-display {
    font-stretch: var(--hs);
    letter-spacing: var(--hls);
  }
}

/* The mono label: „// 01", statuses, small capitals over a section. */
.dx-label {
  font-family: var(--font-mono);
  font-size: var(--type-meta);
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.dx-index { font-family: var(--font-mono); color: var(--dim); }

/* ==========================================================================
   4. Components on the public site
   The markup keeps BotAI's class names (.b-btn-fill, .b-card …); inside
   .dx-site they take Bort's states.
   ========================================================================== */

/* Primary: the accent fill, --ac-on text. */
.dx-site .b-btn-fill,
.dx-btn {
  background: var(--ac);
  color: var(--ac-on);
  border: 1px solid transparent;
  transition: transform .18s var(--ease), box-shadow .25s, background-color .2s;
}
@media (hover: hover) {
  .dx-site .b-btn-fill:hover:not(:disabled),
  .dx-btn:hover:not(:disabled) {
    background: var(--ac);
    color: var(--ac-on);
    transform: translateY(-1px);
    box-shadow: 0 10px 28px -16px var(--ac);
  }
  .dx-site .b-btn:hover .dx-arrow,
  .dx-btn:hover .dx-arrow { transform: translateX(3px); }
}
.dx-site .b-btn-fill:active:not(:disabled),
.dx-btn:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }
.dx-arrow { display: inline-block; transition: transform .25s var(--ease); }

/* Secondary: transparent with a hairline. */
.dx-site .b-btn-outline,
.dx-site .b-btn-ghost,
.dx-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-2);
  transition: background-color .2s, border-color .2s, transform .15s;
}
@media (hover: hover) {
  .dx-site .b-btn-outline:hover:not(:disabled),
  .dx-site .b-btn-ghost:hover:not(:disabled),
  .dx-ghost:hover:not(:disabled) {
    background: var(--tint-05);
    border-color: var(--line-4);
    color: var(--text);
  }
}
.dx-site .b-btn-outline:active:not(:disabled),
.dx-site .b-btn-ghost:active:not(:disabled),
.dx-ghost:active:not(:disabled) { transform: scale(.97); }

/* Card: surface and a hairline; hover lifts the line and the ground. */
.dx-site .b-card,
.dx-card {
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .3s, background-color .3s;
}
@media (hover: hover) {
  .dx-site a.b-card:hover,
  .dx-card:hover { border-color: var(--line-3); background-color: var(--surface-4); }
}

/* The page grid: 56px, 40px on phones. On light it is the light grid token. */
.dx-grid {
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
}
@media (max-width: 767px) {
  .dx-grid { background-size: 40px 40px; }
}

/* Images on light: a soft frame instead of a dark edge. */
html[data-theme="light"] .dx-site main img:not([data-no-frame]),
html[data-theme-default="light"]:not([data-theme]) .dx-site main img:not([data-no-frame]) {
  outline: 1px solid var(--line);
  outline-offset: -1px;
  box-shadow: var(--shadow-soft);
}

/* ==========================================================================
   5. Motion off when asked
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .bai-logo-pulse,
  .dx-theme-toggle svg { animation: none; }
  .dx-site *,
  .dx-site *::before,
  .dx-site *::after { animation: none !important; transition: none !important; }
}
