/**
 * Familytree 2.0 - CSS Reset
 * Modern reset optimized for 3D transforms and mobile-first design
 */

/* ============================================
   Box Sizing Reset
   ============================================ */

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

/* ============================================
   Document & Body
   ============================================ */

html {
  /* Prevent font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* Smooth scrolling (respects prefers-reduced-motion) */
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);

  /* Prevent horizontal scroll on mobile */
  overflow-x: hidden;

  /* Smooth text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* Enable hardware acceleration for 3D transforms */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ============================================
   Typography Reset
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}

p {
  margin: 0;
}

/* ============================================
   Links
   ============================================ */

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

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

/* ============================================
   Lists
   ============================================ */

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ============================================
   Forms & Buttons
   ============================================ */

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* ============================================
   Images & Media
   ============================================ */

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  border-style: none;
}

/* ============================================
   Tables
   ============================================ */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* ============================================
   Accessibility
   ============================================ */

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus visible for keyboard navigation */
.focus-visible:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

/* ============================================
   3D Transform Optimization
   ============================================ */

/* Apply to elements that will use 3D transforms */
.transform-3d {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
}

/* Force GPU acceleration */
.gpu-accelerate {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* ============================================
   Touch Action
   ============================================ */

/* Prevent pull-to-refresh and overscroll on mobile */
body,
html {
  overscroll-behavior: none;
}

/* Allow only pan-x and pan-y for globe controls */
.touch-pan {
  touch-action: pan-x pan-y;
}

/* Prevent any touch action (for custom gesture handling) */
.touch-none {
  touch-action: none;
}

/* ============================================
   Selection
   ============================================ */

::selection {
  background-color: rgba(102, 126, 234, 0.3);
  color: var(--color-text-primary);
}

::-moz-selection {
  background-color: rgba(102, 126, 234, 0.3);
  color: var(--color-text-primary);
}

/* ============================================
   Scrollbar Styling (WebKit)
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-focus);
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  img {
    page-break-inside: avoid;
  }

  h2,
  h3,
  p {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}
