/* Design System IBM · base.
   AIDEV-NOTE: aqui morrem os padrões do navegador (seleção, cursor de texto, rolagem, foco, autopreenchimento,
   setas de número, marcador de <details>). Não reintroduza appearance nativa em nenhum controle. */

@layer ds.reset, ds.tokens, ds.base, ds.components, ds.utilities;

@layer ds.reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  svg { flex-shrink: 0; }
  input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  fieldset { border: 0; padding: 0; min-width: 0; }
  legend { padding: 0; }
  table { border-collapse: collapse; border-spacing: 0; }
  ol[role='list'], ul[role='list'] { list-style: none; padding: 0; }
  [hidden] { display: none !important; }
  dialog { padding: 0; border: 0; color: inherit; background: none; max-width: none; max-height: none; }
  summary { list-style: none; cursor: pointer; }
  summary::-webkit-details-marker { display: none; }
}

@layer ds.base {
  html {
    color-scheme: light;
    scrollbar-gutter: stable;
    font-family: var(--font-sans);
    font-size: 100%;
    font-optical-sizing: auto;
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
    scrollbar-color: var(--color-scrollbar) transparent;
  }

  body {
    min-height: 100dvh;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    caret-color: var(--color-primary);
  }

  h1, h2, h3, h4 { font-weight: var(--weight-semibold); line-height: var(--leading-snug); text-wrap: balance; }
  p, li, dd { text-wrap: pretty; }
  strong, b { font-weight: var(--weight-semibold); }

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

  a { color: var(--color-link); text-decoration-thickness: from-font; text-underline-offset: 0.2em; }
  a:hover { color: var(--color-link-hover); }

  :focus { outline: none; }
  :focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-xs); }

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

  /* Rolagem fina com as cores da casa */
  * { scrollbar-width: thin; scrollbar-color: var(--color-scrollbar) transparent; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--color-scrollbar); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-thumb:hover { background: var(--color-scrollbar-hover); border: 2px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-corner { background: transparent; }

  /* Autopreenchimento sem o fundo amarelo ou azul do navegador */
  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus,
  textarea:-webkit-autofill {
    -webkit-text-fill-color: var(--color-text);
    caret-color: var(--color-primary);
    box-shadow: 0 0 0 1000px var(--color-surface) inset;
    transition: background-color 9999s ease-out 0s;
  }

  /* Sem setas de número, botão de limpar busca ou ícones nativos de data e hora */
  input[type='number'] { appearance: textfield; -moz-appearance: textfield; }
  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button { appearance: none; margin: 0; }
  input[type='search']::-webkit-search-decoration,
  input[type='search']::-webkit-search-cancel-button,
  input[type='search']::-webkit-search-results-button { appearance: none; }
  input::-webkit-calendar-picker-indicator { display: none; }
  input::-webkit-credentials-auto-fill-button,
  input::-webkit-contacts-auto-fill-button { visibility: hidden; position: absolute; right: 0; }
  input::-ms-reveal, input::-ms-clear { display: none; }

  /* Números em tabelas, datas e horários sempre alinhados */
  table, time, .ds-tnum { font-variant-numeric: tabular-nums; }

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

@layer ds.utilities {
  .ds-sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .ds-skip {
    position: fixed; left: var(--space-3); top: var(--space-3); z-index: var(--z-toast);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
    background: var(--color-surface); color: var(--color-primary); font-weight: var(--weight-semibold);
    transform: translateY(calc(-100% - var(--space-6)));
  }
  /* Sombra só com foco: escondido, ele não pode vazar sombra no canto da tela. */
  .ds-skip:focus-visible { transform: none; box-shadow: var(--shadow-lg); }
  .ds-display { font-family: var(--font-display); font-weight: var(--weight-medium); letter-spacing: var(--tracking-display); }
  .ds-muted { color: var(--color-text-secondary); }
  .ds-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
