/* PainDecode Base Styles */
/* 基于 tokens.css 设计变量 */

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

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  color: var(--color-text-primary);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.display {
  font-size: var(--font-size-display);
  line-height: var(--line-height-display);
  font-weight: var(--font-weight-bold);
}

h1, .h1 {
  font-size: var(--font-size-h1);
  line-height: var(--line-height-h1);
}

h2, .h2 {
  font-size: var(--font-size-h2);
  line-height: var(--line-height-h2);
}

h3, .h3 {
  font-size: var(--font-size-h3);
  line-height: var(--line-height-h3);
}

.body-lg {
  font-size: var(--font-size-body-lg);
  line-height: var(--line-height-body-lg);
}

.body {
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
}

.caption {
  font-size: var(--font-size-caption);
  line-height: var(--line-height-caption);
}

.small {
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

.text-secondary {
  color: var(--color-text-secondary);
}

.text-tertiary {
  color: var(--color-text-tertiary);
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

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

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

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

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

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

ul, ol {
  list-style: none;
}

/* ========== Images ========== */

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

/* ========== Forms ========== */

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:focus {
  outline: 2px solid var(--color-primary-light);
  outline-offset: 2px;
}

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

/* ========== Layout ========== */

.container {
  width: 100%;
  max-width: var(--content-width-lg);
  margin: 0 auto;
  padding: var(--space-lg);
}

.container-sm {
  max-width: var(--content-width-sm);
}

.container-md {
  max-width: var(--content-width-md);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-center {
  align-items: center;
  justify-content: center;
}

.flex-between {
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ========== Spacing Utilities ========== */

.m-0 { margin: 0; }
.m-xs { margin: var(--space-xs); }
.m-sm { margin: var(--space-sm); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }
.m-xl { margin: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }
.mt-3xl { margin-top: var(--space-3xl); }

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.p-0 { padding: 0; }
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

/* ========== Display Utilities ========== */

.hidden {
  display: none !important;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.fixed {
  position: fixed;
}

/* ========== Visibility ========== */

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

/* ========== Animation Utilities ========== */

.fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-in-left {
  animation: slideInLeft var(--duration-normal) var(--ease-out);
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-in-right {
  animation: slideInRight var(--duration-normal) var(--ease-out);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========== Responsive ========== */

/* Mobile-first approach */
@media (min-width: 480px) {
  .container {
    padding: var(--space-xl);
  }
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-2xl);
  }
}

/* ========== Safe Area (iOS) ========== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .safe-area-bottom {
    padding-bottom: var(--safe-area-bottom);
  }
}