/* ==========================================================================
   Reset + podstawy typografii
   ========================================================================== */
@layer rp-reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; interpolate-size: allow-keywords; }
  body, h1, h2, h3, h4, h5, p, figure, blockquote, dl, dd, ol, ul { margin: 0; }
  ol[role="list"], ul[role="list"], .list-reset { list-style: none; padding: 0; margin: 0; }
  img, video, canvas { display: block; max-width: 100%; }
  svg { display: inline-block; vertical-align: middle; flex-shrink: 0; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  button:disabled { cursor: not-allowed; }
  a { color: inherit; text-decoration: none; }
  table { border-collapse: collapse; border-spacing: 0; }
  dialog { padding: 0; border: 0; color: inherit; }
  [hidden] { display: none !important; }
  :where(h1, h2, h3, h4) { text-wrap: balance; }
  :where(p, li, dd) { text-wrap: pretty; }
}

@layer rp-base {
  html {
    background: var(--bg);
    scrollbar-gutter: stable;
    hanging-punctuation: first last;
  }

  body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--fs-14);
    line-height: 1.5;
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    accent-color: var(--accent);
  }

  ::selection { background: color-mix(in oklab, var(--accent) 26%, transparent); }

  /* Nagłówki i <main> dostają fokus programowo (czytniki ekranu po zmianie podstrony) — bez ramki */
  [tabindex="-1"]:focus { outline: none; }

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

  code, kbd, samp, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }

  kbd {
    display: inline-grid;
    place-items: center;
    min-width: 1.6em;
    height: 1.6em;
    padding: 0 0.4em;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1;
  }

  hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }

  .num, .tabular { font-variant-numeric: tabular-nums; }

  .link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in oklab, var(--accent) 35%, transparent);
    text-underline-offset: 3px;
    &:hover { text-decoration-color: currentColor; }
  }

  .muted { color: var(--text-2); }
  .subtle { color: var(--text-3); }

  /* Paski przewijania w stylu panelu */
  * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

  .skip-link {
    position: fixed;
    top: var(--s-3);
    left: var(--s-3);
    z-index: 1000;
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-pill);
    background: var(--surface-inverse);
    color: var(--text-inverse);
    font-weight: 600;
    transform: translateY(-160%);
    transition: transform var(--dur-2) var(--ease-out);
    &:focus { transform: none; }
  }

  .sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }
}

/* ==========================================================================
   View Transitions — płynne przejścia między podstronami
   ========================================================================== */
@layer rp-base {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 180ms; }

  ::view-transition-old(page) { animation: vt-fade-out 140ms var(--ease-out) both; }
  ::view-transition-new(page) { animation: vt-rise-in 260ms var(--ease-out) both; }

  /* Wskaźnik aktywnej pozycji menu „przepływa” między pozycjami */
  ::view-transition-group(nav-active) { animation-duration: 300ms; animation-timing-function: var(--ease-spring); }
  ::view-transition-old(nav-active), ::view-transition-new(nav-active) { animation: none; mix-blend-mode: normal; }

  /* Zmiana motywu: kołowe odsłonięcie od miejsca kliknięcia */
  html.theme-transition::view-transition-old(root) { animation: none; }
  html.theme-transition::view-transition-new(root) {
    animation: vt-reveal 520ms var(--ease-out) both;
  }

  @keyframes vt-fade-out { to { opacity: 0; } }
  @keyframes vt-rise-in { from { opacity: 0; transform: translateY(8px); } }
  @keyframes vt-reveal {
    from { clip-path: circle(0 at var(--vt-x, 90%) var(--vt-y, 5%)); }
    to { clip-path: circle(150vmax at var(--vt-x, 90%) var(--vt-y, 5%)); }
  }

  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 color-mix(in oklab, currentColor 45%, transparent); }
    70% { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
  }
  @keyframes shimmer { to { background-position: -200% 0; } }
  @keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
}

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