/* PaperSorter Base Styles - Foundation and Typography */

/* =================================== */
/* CSS Reset and Base */
/* =================================== */

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =================================== */
/* Body Styles */
/* =================================== */

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
  background-color: var(--bg-body);
  margin: 0;
  padding: var(--container-padding);
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--spacing-base);
}

h1 {
  font-size: var(--font-size-title);
  margin-bottom: var(--spacing-xl);
}

h2 {
  font-size: var(--font-size-xxl);
  margin-bottom: var(--spacing-lg);
}

h3 {
  font-size: var(--font-size-xl);
}

h4 {
  font-size: var(--font-size-lg);
}

h5 {
  font-size: var(--font-size-md);
}

h6 {
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--spacing-base);
  line-height: var(--line-height-relaxed);
}

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

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

strong, b {
  font-weight: var(--font-weight-bold);
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
  color: var(--text-meta);
}

code {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
  padding: 2px 4px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  padding: var(--spacing-base);
  background-color: var(--bg-hover);
  border-radius: var(--radius-base);
  overflow-x: auto;
  margin-bottom: var(--spacing-base);
}

blockquote {
  padding: var(--spacing-base);
  margin: var(--spacing-base) 0;
  border-left: 4px solid var(--color-primary);
  background-color: var(--bg-hover);
  font-style: italic;
}

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

ul, ol {
  margin-bottom: var(--spacing-base);
  padding-left: var(--spacing-xl);
}

ul ul, ol ol, ul ol, ol ul {
  margin-bottom: 0;
}

li {
  margin-bottom: var(--spacing-xs);
}

dl {
  margin-bottom: var(--spacing-base);
}

dt {
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--spacing-xs);
}

dd {
  margin-left: var(--spacing-xl);
  margin-bottom: var(--spacing-sm);
}

/* =================================== */
/* Container System */
/* =================================== */

.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--container-padding);
}

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

.flex {
  display: flex;
}

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

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

.justify-start {
  justify-content: flex-start;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

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

.justify-around {
  justify-content: space-around;
}

.align-start {
  align-items: flex-start;
}

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

.align-end {
  align-items: flex-end;
}

.align-stretch {
  align-items: stretch;
}

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

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

.d-none { display: none; }
.d-block { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid { display: grid; }

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

/* Margin */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mt-0 { margin-top: 0; }
.mr-0 { margin-right: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }

.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-base { margin-top: var(--spacing-base); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-base { margin-bottom: var(--spacing-base); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

/* Padding */
.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pr-0 { padding-right: 0; }
.pb-0 { padding-bottom: 0; }
.pl-0 { padding-left: 0; }

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

/* =================================== */
/* Text Utilities */
/* =================================== */

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-justify { text-align: justify; }

.text-lowercase { text-transform: lowercase; }
.text-uppercase { text-transform: uppercase; }
.text-capitalize { text-transform: capitalize; }

.text-nowrap { white-space: nowrap; }
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-weight-normal { font-weight: var(--font-weight-normal); }
.font-weight-medium { font-weight: var(--font-weight-medium); }
.font-weight-semibold { font-weight: var(--font-weight-semibold); }
.font-weight-bold { font-weight: var(--font-weight-bold); }

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

.visible { visibility: visible; }
.invisible { visibility: hidden; }

.opacity-0 { opacity: 0; }
.opacity-25 { opacity: 0.25; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

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

::selection {
  background-color: var(--color-primary);
  color: var(--text-white);
  opacity: 0.2;
}

::-moz-selection {
  background-color: var(--color-primary);
  color: var(--text-white);
  opacity: 0.2;
}

/* =================================== */
/* Scrollbar Styles */
/* =================================== */

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

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

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-meta);
}

/* =================================== */
/* Focus Styles */
/* =================================== */

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

:focus:not(:focus-visible) {
  outline: none;
}

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

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

@media print {
  body {
    background: white;
    color: black;
  }

  .no-print {
    display: none !important;
  }
}

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

@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  body {
    padding: var(--container-padding-mobile);
  }

  .container {
    padding: 0 var(--container-padding-mobile);
  }

  h1 {
    font-size: calc(var(--font-size-title) * 0.85);
  }

  h2 {
    font-size: calc(var(--font-size-xxl) * 0.85);
  }

  h3 {
    font-size: calc(var(--font-size-xl) * 0.85);
  }
}