/*
 * vy-base.css: the V6 element floor (spec 060, slice S02). Linked right after tokens.css on every
 * surface that uses the shared layer: /app and the auth doors today, admin from S11a and the
 * public pages from S12a. Every value comes from tokens.css; this file holds the element
 * defaults, the one focus rule, the [hidden] guarantee and the app print floor (S18).
 *
 * Deliberately not here (05 §1.3, critic C1): V6's hard resets (p margin, link underline, the bare
 * button reset, block svg) and scroll-padding-top. App and admin CSS rely on the UA defaults, and
 * /app scrolls the document with its own anchor offsets, so those live in vy-site.css (public).
 * Rule R9 (paint only): nothing here sets position, inset, z-index, transform or overflow on an
 * element that JS shows and hides.
 */

/* Elements only, as V6 and the app always had it: pseudo-element glyphs drawn with borders keep
   their content-box size. Scrollbars are thin; their colour follows the theme (tokens.css :root). */
* {
  box-sizing: border-box;
  scrollbar-width: thin;
}

/* Body copy in --text, headings and labels in --ink (D1); Onest only (D2). The size stays the
   15px/1.6 the app already reads, so S02 moves no text; a size change is one token here. */
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: var(--weight-regular) var(--text-base)/var(--leading-relaxed) var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
}

/* Emphasis is 500 everywhere (D4, critic C3): the UA makes these bold. */
h5,
h6,
th,
dt,
legend,
strong,
b {
  font-weight: var(--weight-strong);
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

a {
  color: inherit;
}

:where(button, input, textarea, select) {
  font: inherit;
}

/* Under a finger a text field computes to at least 16 px, or a phone zooms the page on focus; the page never gets there by
   forbidding zoom (D41 §8). A floor over every surface's own size, hence !important; 1em keeps a field that inherits more. */
@media (pointer: coarse) {
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"]),
  textarea,
  select,
  [contenteditable="true"] {
    font-size: max(16px, 1em) !important;
  }
}

/* Unclassed labels stack their text over the control; 16 app forms rely on this grid (C2). */
label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: var(--weight-strong);
}

/* ---------- Focus: one recipe, an outline (not a box-shadow) ----------
   It follows border-radius, survives forced colours and never fights a component's own shadow.
   --focus-color is the accent (9.16:1 on paper); always-dark bands switch it (the band recipe,
   .vy-on-dark in vy-components.css). */
:focus-visible,
/* public: the /pricing audience switch hands its hidden radio's ring to the visible tab (S13) */
#ld-aud-self:focus-visible ~ .ld-aud [for="ld-aud-self"],
#ld-aud-biz:focus-visible ~ .ld-aud [for="ld-aud-biz"] {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

/* Inside a scroller the ring is drawn inside the control, where the scroller cannot clip it
   (critic C14): one pixel in from the edge, because a scroller brings a focused row into view
   only to the nearest whole pixel. One list of the app's scrolling containers. */
:where(
  .workspace-drawer,
  .app-overlay-panel,
  .answer-table-wrap,
  .turn-integrity,
  .source-parameter-panel,
  .request-composer-example-list,
  .sp-dict-results,
  .canvas-viewport,
  .vy-table-wrap,
  .vy-menu,
  .vy-tabs
) :focus-visible {
  outline-offset: calc(-1 * var(--focus-width) - 1px);
}

/* The hidden attribute always wins, whatever display a later rule gives the element. */
[hidden] {
  display: none !important;
}

/* ---------- Utilities ---------- */
.vy-sr,
.sr-only,
/* app: what a press under an answer did, for a screen reader while the icon says it; a refusal shows */
.answer-action-status:not([data-error]),
/* public: the words behind the /pricing table's marks, and its caption (S13) */
.ld-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* V6 .skip: a quiet surface chip that appears on focus, without motion. Fixed: a chat stands at its end and the canvas holds the page
   there, so a chip at the page's top would stay out of the window or throw the reader up to it. */
.skip-link {
  position: fixed;
  left: -9999px;
  top: 8px;
  z-index: var(--z-toast);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--edge-2);
  text-decoration: none;
}

.skip-link:focus {
  left: 12px;
}

/* Where the chip stands with focus: over no control (#2809), each place here, beside the link's one rule; the admin's beside its frame
   (admin-shell.css), the public pages' beside their header (vy-site.css). A place weighs nothing of its own (:where), so the later one
   wins. /app: under the top row at the column's left, where what it skips to begins; on the row it covered the row's toggle and the
   docked sidebar's head. The column starts after a docked sidebar, at the window's edge when the sidebar is hidden, anonymous or a door hides it. */
:where(body:has(> .lawyer-shell)) > .skip-link:focus { top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + var(--space-1)); }
@media (min-width: 1000px) {
  :where(html:not([data-sidebar="hidden"], [data-incognito="on"]) body:has(> .lawyer-shell:not(.shell-auth))) > .skip-link:focus {
    left: calc(var(--sidebar-w) + 12px);
  }
}
/* A ticket opens with its way back there, so the chip takes the row's right. */
:where(body:has([data-support-page="thread"])) > .skip-link:focus { right: 12px; left: auto; }
/* The canvas: a step under its row of tools (F-TOOLBAR, the row's own height), over its world, which pans. */
:where(body:has(.canvas-stage)) > .skip-link:focus { top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + var(--toolbar-h) + var(--space-1)); }
/* A document holding the room hides the column the link leads to, and its head, tools and sheet leave the chip no place. */
:where(body:has([data-doc-room])) > .skip-link { display: none; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* The corpus line (C-CORPUS-LINE): one look on every surface of /app and the admin. The slot keeps its line, so the figures
   that arrive after mount move nothing below it. */
.corpus-stats-line {
  margin: 0;
  min-height: 1lh;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ---------- Print floor (D22, S18) ----------
   Paper is always light (the dark tokens are screen-only). On paper /app keeps the reading
   surface: no navigation, composers, canvas tools, answer buttons, feedback, run log or
   overlays; the answer is full width; a source link that shows a name instead of its address
   prints the address after it, so a printed answer still carries its official sources
   (AGENTS.md §1.2). The editor has its own print sheet (user-document-print.css): while its
   dialog is open this floor steps aside. Paper has no way to open anything, so what an answer
   folds opens on it (CH-ANSWER, D33): the drawers and «ще N». */
@media print {
  body:not(:has(> .working-copy-dialog[open])) :is(
    .drawer-backdrop,
    .workspace-drawer,
    .sidebar-resizer,
    .user-topbar,
    .service-strip-region,
    .ws-composer,
    .composer-dock,
    [data-thread-composer],
    .canvas-toggle,
    .topbar-share,
    .canvas-toolbar,
    .answer-actions,
    .answer-limitations-more > summary,
    .court-copy-button, .citation-copy,
    [data-run-comparison],
    [data-answer-feedback],
    .chat-runtime-timeline,
    .app-overlay
  ) {
    display: none !important;
  }

  body:not(:has(> .working-copy-dialog[open])) .user-view {
    width: auto;
    margin: 0;
  }

  body:not(:has(> .working-copy-dialog[open])) .source-link.labeled {
    display: inline;
    white-space: normal;
  }

  body:not(:has(> .working-copy-dialog[open])) :is(
    .vy-src-row a,
    .source-link.labeled,
    .answer-attribution a,
    .answer-table-wrap a,
    .answer-source-title a
  )::after {
    content: " " attr(href);
    overflow-wrap: anywhere;
  }
}
