/* ==========================================================================
   Base Styles — Global Resets and Foundations
   Authority: docs/design/foundations.md
   Purpose: Resets, html/body, typography, scrollbar, focus rings
   ========================================================================== */

/* HTML & Body Reset */
html {
  scroll-behavior: smooth;
  font-feature-settings: "palt";  /* Japanese text spacing */
}

body {
  background-color: var(--surface-default);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-weight: var(--weight-body);
  font-feature-settings: "rlig" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Default Link Styles — no underline; chrome/nav links inherit this */
a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-normal);
}

a:hover {
  color: var(--action-primary-hover);
}

/* Focus Styles - WCAG 2.2 AA compliant */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgb(var(--color-focus-ring-rgb) / 0.5);
}

/* Universal Border Color */
* {
  border-color: var(--border-default);
}

/* Theme Switching Performance */
/* Disable all transitions during theme switch to prevent lag */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
  animation: none !important;
}

/* Typography Defaults */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin: 0;
}

h1 {
  font-size: var(--text-h1);
  font-weight: var(--weight-h1);
  line-height: var(--leading-h1);
}

h2 {
  font-size: var(--text-h2);
  font-weight: var(--weight-h2);
  line-height: var(--leading-h2);
}

h3 {
  font-size: var(--text-h3);
  font-weight: var(--weight-h3);
  line-height: var(--leading-h3);
}

h4, h5, h6 {
  font-size: var(--text-body);
  font-weight: var(--weight-h3);
  line-height: var(--leading-h3);
}

p {
  margin: 0;
  line-height: var(--leading-body);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background-color: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  opacity: 0.8;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background-color: white !important;
    color: black !important;
  }

  .table-responsive {
    overflow: visible !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }
}

/* Reduced Motion Support */
@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;
  }
}
