/* Reset, element defaults, focus, utilities. Layout primitives only.
   Part of the Cabinhub News newsroom stylesheet set (see frontend/css/README).
   Class names are contractual: frontend/app.js emits them. */

/* ============================================================ base ===== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The sticky stack is masthead + rail + toolbar + filters, not just the
     filters row. 2.4.11: a focused element must not land under it. */
  scroll-padding-top: calc(var(--masthead-h, 84px) + var(--rail-h, 40px) + var(--toolbar-h, 56px) + var(--filters-h, 48px) + env(safe-area-inset-top, 0px));
  overflow-wrap: break-word;
  background: var(--paper);
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* Apple's own reading measure: optical tightening only on the display sizes,
   never on body text, and never on CJK (see cjk.css). */
h1, h2, h3 { letter-spacing: -0.018em; }

main { position: relative; flex: 1 0 auto; }

h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }

a, button, .chip, .locale-switch__btn, .article, .card, summary, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* One focus ring, used everywhere, and visible on both grounds. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
.ops :focus-visible { outline-color: var(--accent); }
:focus:not(:focus-visible) { outline: none; }

/* The container targets are focused with tabindex="-1" (the skip link goes to
   #main, and the router moves focus to it on every route change so a screen
   reader starts at the new content). Chrome then matches :focus-visible on that
   programmatic focus and the global ring draws a 2px accent rectangle around the
   WHOLE main column — measured on the markets route at 1440: a full-bleed orange
   band across the viewport at the container's bottom edge, reading as a stray
   divider. A ring around a full-page container says nothing a reader can act on;
   the element that was activated (.skip-link, the tab, the card) keeps its own. */
main[tabindex="-1"]:focus,
main[tabindex="-1"]:focus-visible,
[data-root]:focus,
[data-root]:focus-visible { outline: none; }

.skip-link {
  position: absolute;
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  top: -6rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0.65rem 1rem;
  background: var(--canvas);
  color: var(--ink);
  font-size: var(--fs-meta);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  text-decoration: none;
}
.skip-link:focus { top: max(0.75rem, env(safe-area-inset-top, 0px)); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
