/* CSS Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  overflow-wrap: break-word;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  font-family: var(--font-family);
  font-size: 1.0625rem; /* ~17px */
  line-height: var(--line-height-body);
  color: var(--color-text-main);
  background-color: var(--color-bg-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

#root {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  color: var(--color-primary);
  font-weight: 700;
  line-height: var(--line-height-heading);
  letter-spacing: -0.02em;
  word-break: break-word;
}

button, input, select, textarea {
  font-family: var(--font-family);
}

h1 {
  font-size: clamp(1.85rem, 5.5vw, 3.5rem);
  line-height: var(--line-height-tight);
}

h2 {
  font-size: clamp(1.5rem, 4.2vw, 2.5rem);
  line-height: 1.2;
}

h3 {
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  line-height: 1.35;
}

h4 {
  font-size: 1.15rem;
  line-height: 1.4;
}

p {
  margin-bottom: 1.25rem;
  color: var(--color-text-muted);
}

p:last-child {
  margin-bottom: 0;
}

strong {
  font-weight: 600;
  color: var(--color-text-main);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Accessible focus ring */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
}

/* Section Wrapper */
.section {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
  position: relative;
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--space-20);
    padding-bottom: var(--space-20);
  }
}

@media (max-width: 640px) {
  .section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

@media (max-width: 380px) {
  .section {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }
}

.section-surface {
  background-color: var(--color-bg-surface);
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
}

.section-dark {
  background-color: var(--color-primary-dark);
  color: var(--color-text-inverted);
}

.section-dark h1,
.section-dark h2,
.section-dark h3,
.section-dark strong {
  color: var(--color-text-inverted);
}

.section-dark p {
  color: #B5C4D0;
}

/* Lists */
ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Reduced motion preference */
@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;
  }
}
