/* ============================================
   BASE — Reset + Typography + Utilities
   ============================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

#app {
  min-height: 100vh;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: var(--radius-full);
  transition: background var(--transition);
}

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

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) var(--surface-2);
}

/* ── Selection ── */
::selection {
  background-color: rgba(var(--primary-rgb), 0.2);
  color: var(--primary-dark);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: var(--font-semibold); }

@media (max-width: 768px) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
}

p {
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

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

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

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

ul, ol {
  list-style: none;
}

strong, b { font-weight: var(--font-semibold); }
em, i     { font-style: italic; }

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
}

pre {
  background: var(--text);
  color: var(--text-inverse);
  padding: var(--space-4);
  border-radius: var(--radius);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ── Focus styles ── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Utilities ── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
}

.hidden        { display: none !important; }
.invisible     { visibility: hidden; }
.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;
}

/* Flex helpers */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-start    { display: flex; align-items: center; justify-content: flex-start; }
.flex-end      { display: flex; align-items: center; justify-content: flex-end; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.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; }
.gap-1         { gap: var(--space-1); }
.gap-2         { gap: var(--space-2); }
.gap-3         { gap: var(--space-3); }
.gap-4         { gap: var(--space-4); }
.gap-6         { gap: var(--space-6); }
.gap-8         { gap: var(--space-8); }

/* Grid helpers */
.grid          { display: grid; }
.grid-2        { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3        { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4        { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }

@media (max-width: 1024px) {
  .grid-4      { grid-template-columns: repeat(2, 1fr); }
  .grid-3      { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-4,
  .grid-3,
  .grid-2      { grid-template-columns: 1fr; }
}

/* Text utilities */
.text-center   { text-align: center; }
.text-left     { text-align: left; }
.text-right    { text-align: right; }
.text-xs       { font-size: var(--text-xs); }
.text-sm       { font-size: var(--text-sm); }
.text-base     { font-size: var(--text-base); }
.text-lg       { font-size: var(--text-lg); }
.text-xl       { font-size: var(--text-xl); }
.text-2xl      { font-size: var(--text-2xl); }
.text-primary  { color: var(--primary); }
.text-secondary{ color: var(--text-secondary); }
.text-muted    { color: var(--text-muted); }
.text-success  { color: var(--success); }
.text-error    { color: var(--error); }
.text-warning  { color: var(--warning); }
.font-medium   { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold     { font-weight: var(--font-bold); }

/* Spacing utilities */
.mt-auto { margin-top: auto; }
.mb-auto { margin-bottom: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-4     { padding: var(--space-4); }
.p-6     { padding: var(--space-6); }
.p-8     { padding: var(--space-8); }
.px-4    { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4    { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.mt-4    { margin-top: var(--space-4); }
.mt-6    { margin-top: var(--space-6); }
.mt-8    { margin-top: var(--space-8); }
.mb-4    { margin-bottom: var(--space-4); }
.mb-6    { margin-bottom: var(--space-6); }

/* Width/Height */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Surface */
.surface { background: var(--surface); }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: var(--radius-full); }

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

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-6);
  text-align: center;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.empty-state__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text);
}

.empty-state__description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 320px;
}

/* Section */
.section {
  padding: var(--space-16) 0;
}

@media (max-width: 768px) {
  .section {
    padding: var(--space-10) 0;
  }
}

.section__header {
  text-align: center;
  margin-bottom: var(--space-12);
}

.section__title {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin-bottom: var(--space-3);
}

.section__subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* Page header */
.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
}
