/**
 * Material 3 Base Styles
 * 基础重置与全局样式
 */

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--md-sys-font-family);
  font-size: var(--md-sys-typescale-body-medium);
  line-height: 1.5;
  color: var(--md-sys-color-on-background);
  background-color: var(--md-sys-color-background);
  min-height: 100vh;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--md-sys-color-primary);
  text-decoration: none;
  transition: color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

a:hover {
  color: var(--md-sys-color-on-primary-container);
}

a:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: var(--md-sys-shape-corner-extra-small);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

ul, ol {
  list-style: none;
}

/* ===== Typography Classes ===== */
.display-large {
  font-size: var(--md-sys-typescale-display-large);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.25px;
}

.display-medium {
  font-size: var(--md-sys-typescale-display-medium);
  font-weight: 400;
  line-height: 1.16;
}

.display-small {
  font-size: var(--md-sys-typescale-display-small);
  font-weight: 400;
  line-height: 1.22;
}

.headline-large {
  font-size: var(--md-sys-typescale-headline-large);
  font-weight: 400;
  line-height: 1.25;
}

.headline-medium {
  font-size: var(--md-sys-typescale-headline-medium);
  font-weight: 400;
  line-height: 1.29;
}

.headline-small {
  font-size: var(--md-sys-typescale-headline-small);
  font-weight: 400;
  line-height: 1.33;
}

.title-large {
  font-size: var(--md-sys-typescale-title-large);
  font-weight: 500;
  line-height: 1.27;
}

.title-medium {
  font-size: var(--md-sys-typescale-title-medium);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.15px;
}

.title-small {
  font-size: var(--md-sys-typescale-title-small);
  font-weight: 500;
  line-height: 1.43;
  letter-spacing: 0.1px;
}

.body-large {
  font-size: var(--md-sys-typescale-body-large);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.5px;
}

.body-medium {
  font-size: var(--md-sys-typescale-body-medium);
  font-weight: 400;
  line-height: 1.43;
  letter-spacing: 0.25px;
}

.body-small {
  font-size: var(--md-sys-typescale-body-small);
  font-weight: 400;
  line-height: 1.33;
  letter-spacing: 0.4px;
}

.label-large {
  font-size: var(--md-sys-typescale-label-large);
  font-weight: 500;
  line-height: 1.43;
  letter-spacing: 0.1px;
}

.label-medium {
  font-size: var(--md-sys-typescale-label-medium);
  font-weight: 500;
  line-height: 1.33;
  letter-spacing: 0.5px;
}

.label-small {
  font-size: var(--md-sys-typescale-label-small);
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.5px;
}

/* ===== Layout Container ===== */
.container {
  width: 100%;
  max-width: var(--md-sys-layout-max-width);
  margin-inline: auto;
  padding-inline: var(--md-sys-space-4);
}

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  padding-bottom: var(--md-sys-layout-bottom-nav-height);
}

/* Desktop: 无底部导航 */
@media (min-width: 840px) {
  .app-content {
    padding-bottom: 0;
    padding-left: var(--md-sys-layout-nav-rail-width);
  }
  
  .app-content.with-drawer {
    padding-left: var(--md-sys-layout-drawer-width);
  }
}

/* ===== Utility Classes ===== */
.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;
}

.hidden {
  display: none !important;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--md-sys-color-primary); }
.text-secondary { color: var(--md-sys-color-secondary); }
.text-error { color: var(--md-sys-color-error); }
.text-on-surface { color: var(--md-sys-color-on-surface); }
.text-on-surface-variant { color: var(--md-sys-color-on-surface-variant); }

.bg-surface { background-color: var(--md-sys-color-surface); }
.bg-surface-container { background-color: var(--md-sys-color-surface-container); }
.bg-surface-container-high { background-color: var(--md-sys-color-surface-container-high); }
.bg-primary-container { background-color: var(--md-sys-color-primary-container); }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--md-sys-space-1); }
.gap-2 { gap: var(--md-sys-space-2); }
.gap-3 { gap: var(--md-sys-space-3); }
.gap-4 { gap: var(--md-sys-space-4); }
.gap-5 { gap: var(--md-sys-space-5); }
.gap-6 { gap: var(--md-sys-space-6); }

/* Grid */
.grid { display: grid; }

/* Spacing */
.p-1 { padding: var(--md-sys-space-1); }
.p-2 { padding: var(--md-sys-space-2); }
.p-3 { padding: var(--md-sys-space-3); }
.p-4 { padding: var(--md-sys-space-4); }
.p-5 { padding: var(--md-sys-space-5); }
.p-6 { padding: var(--md-sys-space-6); }

.px-1 { padding-inline: var(--md-sys-space-1); }
.px-2 { padding-inline: var(--md-sys-space-2); }
.px-3 { padding-inline: var(--md-sys-space-3); }
.px-4 { padding-inline: var(--md-sys-space-4); }
.px-5 { padding-inline: var(--md-sys-space-5); }

.py-1 { padding-block: var(--md-sys-space-1); }
.py-2 { padding-block: var(--md-sys-space-2); }
.py-3 { padding-block: var(--md-sys-space-3); }
.py-4 { padding-block: var(--md-sys-space-4); }
.py-5 { padding-block: var(--md-sys-space-5); }

.m-1 { margin: var(--md-sys-space-1); }
.m-2 { margin: var(--md-sys-space-2); }
.m-3 { margin: var(--md-sys-space-3); }
.m-4 { margin: var(--md-sys-space-4); }

.mb-1 { margin-bottom: var(--md-sys-space-1); }
.mb-2 { margin-bottom: var(--md-sys-space-2); }
.mb-3 { margin-bottom: var(--md-sys-space-3); }
.mb-4 { margin-bottom: var(--md-sys-space-4); }
.mb-5 { margin-bottom: var(--md-sys-space-5); }
.mb-6 { margin-bottom: var(--md-sys-space-6); }

.mt-1 { margin-top: var(--md-sys-space-1); }
.mt-2 { margin-top: var(--md-sys-space-2); }
.mt-3 { margin-top: var(--md-sys-space-3); }
.mt-4 { margin-top: var(--md-sys-space-4); }
.mt-5 { margin-top: var(--md-sys-space-5); }
.mt-6 { margin-top: var(--md-sys-space-6); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Text overflow */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

/* Width/Height */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Aspect ratio */
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-poster { aspect-ratio: 2 / 3; }
.aspect-square { aspect-ratio: 1 / 1; }

/* Border radius */
.rounded-none { border-radius: var(--md-sys-shape-corner-none); }
.rounded-xs { border-radius: var(--md-sys-shape-corner-extra-small); }
.rounded-sm { border-radius: var(--md-sys-shape-corner-small); }
.rounded-md { border-radius: var(--md-sys-shape-corner-medium); }
.rounded-lg { border-radius: var(--md-sys-shape-corner-large); }
.rounded-xl { border-radius: var(--md-sys-shape-corner-extra-large); }
.rounded-full { border-radius: var(--md-sys-shape-corner-full); }

/* Elevation */
.elevation-0 { box-shadow: var(--md-sys-elevation-0); }
.elevation-1 { box-shadow: var(--md-sys-elevation-1); }
.elevation-2 { box-shadow: var(--md-sys-elevation-2); }
.elevation-3 { box-shadow: var(--md-sys-elevation-3); }
.elevation-4 { box-shadow: var(--md-sys-elevation-4); }
.elevation-5 { box-shadow: var(--md-sys-elevation-5); }
