/* ==========================================================
   base.css — Reset, Typography & Global Elements
   ========================================================== */

/* ---- Box Sizing Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ---- Document Reset ---- */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-sm) 0;
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
}

h1 { font-size: var(--font-size-xxl); }
h2 { font-size: var(--font-size-xl); }
h3 { font-size: var(--font-size-lg); }
h4 { font-size: var(--font-size-md); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

/* ---- Paragraph ---- */
p {
  margin: 0 0 var(--space-sm) 0;
  line-height: var(--line-height-base);
}

p:last-child {
  margin-bottom: 0;
}

/* ---- Links ---- */
a {
  color: var(--color-text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Lists ---- */
ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- Images ---- */
img, svg {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}

/* ---- Code & Pre ---- */
code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background-color: var(--color-bg-code);
  color: var(--color-danger);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  background-color: var(--color-bg-code);
  color: var(--color-text);
  padding: var(--space-base);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ---- Horizontal Rule ---- */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-lg) 0;
}

/* ---- Tables (base reset) ---- */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* ---- Form Elements Reset ---- */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  margin: 0;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

textarea {
  resize: vertical;
}

fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

label {
  display: inline-block;
}

/* ---- Hidden / SR Only ---- */
[hidden] {
  display: none !important;
}

.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;
}

/* ---- Scrollbar Styling ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-secondary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-muted) transparent;
}

/* ---- Selection ---- */
::selection {
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* ---- Focus Visible ---- */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Utility Classes ---- */
.text-muted {
  color: var(--color-text-muted) !important;
}

.text-secondary {
  color: var(--color-text-secondary) !important;
}

.text-center {
  text-align: center !important;
}

.text-right {
  text-align: right !important;
}

.text-left {
  text-align: left !important;
}

.text-danger {
  color: var(--color-danger) !important;
}

.text-success {
  color: var(--color-success) !important;
}

.text-warning {
  color: var(--color-warning) !important;
}

.text-primary {
  color: var(--color-primary) !important;
}

.font-semibold {
  font-weight: var(--font-weight-semibold) !important;
}

.font-bold {
  font-weight: var(--font-weight-bold) !important;
}

.text-xs {
  font-size: var(--font-size-xs) !important;
}

.text-sm {
  font-size: var(--font-size-sm) !important;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-flex { display: inline-flex !important; }

.gap-xs { gap: var(--space-xs) !important; }
.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }
.gap-base { gap: var(--space-base) !important; }

.flex-1 { flex: 1 !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }