/* ============================================
   TYPOGRAPHY SYSTEM — 45black.tech
   IBM Plex Sans + Serif, Scales, Styles
   ============================================ */

/* ============================================
   HEADINGS
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-md);
  color: var(--brand-primary);
  letter-spacing: var(--letter-spacing-snug);
}

h1 {
  font-size: var(--font-size-3xl); /* 36px mobile, 48px desktop */
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-tight);
  line-height: var(--line-height-tight);
}

h2 {
  font-size: var(--font-size-2xl); /* 30px mobile, 36px desktop */
  margin-top: var(--space-xl);
  letter-spacing: var(--letter-spacing-snug);
}

h3 {
  font-size: var(--font-size-xl); /* 24px mobile, 30px desktop */
  margin-top: var(--space-lg);
  font-weight: var(--font-weight-semibold);
}

h4 {
  font-size: var(--font-size-lg); /* 20px mobile, 24px desktop */
  margin-top: var(--space-md);
}

h5 {
  font-size: var(--font-size-md); /* 18px mobile, 20px desktop */
  margin-top: var(--space-md);
}

h6 {
  font-size: var(--font-size-base); /* 16px mobile, 18px desktop */
  margin-top: var(--space-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

/* Remove top margin when heading is first child */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
  margin-top: 0;
}

/* ============================================
   BODY TEXT
   ============================================ */

p {
  margin-bottom: var(--space-md);
  max-width: var(--max-width-prose);
  line-height: var(--line-height-relaxed);
}

p:last-child {
  margin-bottom: 0;
}

p + p {
  margin-top: var(--space-md);
}

/* Lead Paragraph (Intro text) */
.lead,
p.lead {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
  max-width: 60ch;
}

/* Small Text */
small,
.text-sm {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.text-xs {
  font-size: var(--font-size-xs);
}

/* ============================================
   TEXT STYLES
   ============================================ */

strong, b {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

em, i {
  font-style: italic;
}

mark {
  background-color: rgba(27, 77, 62, 0.1);
  color: var(--brand-primary);
  padding: 0.125em 0.25em;
  border-radius: var(--border-radius-sm);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

pre {
  background: var(--bg-secondary);
  border: var(--border-width-1) solid var(--border-default);
  border-radius: var(--border-radius-base);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  line-height: var(--line-height-normal);
}

pre code {
  background: none;
  padding: 0;
  font-size: var(--font-size-sm);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  border: var(--border-width-1) solid var(--border-default);
  border-radius: var(--border-radius-sm);
  padding: 0.125rem 0.375rem;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

blockquote {
  margin: var(--space-lg) 0;
  padding-left: var(--space-lg);
  border-left: 4px solid var(--brand-primary);
  font-style: italic;
  color: var(--text-secondary);
}

blockquote p {
  margin-bottom: var(--space-sm);
}

blockquote cite {
  display: block;
  font-size: var(--font-size-sm);
  font-style: normal;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

blockquote cite::before {
  content: "— ";
}

/* ============================================
   LINKS
   ============================================ */

a {
  color: var(--link-default);
  text-decoration: underline;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.15em;
  text-decoration-color: rgba(27, 77, 62, 0.3);
  transition: var(--transition-colors);
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
  text-underline-offset: 0.25em;
}

a:focus {
  outline: var(--focus-ring-width) var(--focus-ring-style) var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--border-radius-sm);
}

a:active {
  color: var(--brand-primary);
}

/* Link without underline (use sparingly) */
a.no-underline {
  text-decoration: none;
}

a.no-underline:hover {
  text-decoration: underline;
}

/* External Link Icon (Optional) */
a[href^="http"]::after,
a[rel~="external"]::after {
  content: " ↗";
  font-size: 0.875em;
  opacity: 0.7;
}

/* Prevent icon on buttons that are links */
a.button::after,
a[role="button"]::after {
  content: none;
}

/* ============================================
   LISTS
   ============================================ */

ul, ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
  max-width: var(--max-width-prose);
}

ul ul,
ul ol,
ol ul,
ol ol {
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

li {
  margin-bottom: var(--space-xs);
  padding-left: var(--space-xs);
  line-height: var(--line-height-relaxed);
}

li:last-child {
  margin-bottom: 0;
}

/* Custom List Markers */
ul {
  list-style-type: disc;
}

ul ul {
  list-style-type: circle;
}

ul ul ul {
  list-style-type: square;
}

/* Definition Lists */
dl {
  margin-bottom: var(--space-lg);
}

dt {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

dd {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

dd:last-child {
  margin-bottom: 0;
}

/* Unstyled List */
.list-none {
  list-style: none;
  padding-left: 0;
}

.list-none li {
  padding-left: 0;
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */

hr {
  border: none;
  border-top: var(--border-width-1) solid var(--border-default);
  margin: var(--space-xl) 0;
}

/* ============================================
   TEXT UTILITIES
   ============================================ */

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

/* Transform */
.text-uppercase { text-transform: uppercase; }
.text-lowercase { text-transform: lowercase; }
.text-capitalize { text-transform: capitalize; }
.text-normal-case { text-transform: none; }

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

/* Style */
.italic { font-style: italic; }
.not-italic { font-style: normal; }

/* Color */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--brand-primary); }
.text-on-dark { color: var(--text-on-dark); }

/* Line Height */
.leading-none { line-height: var(--line-height-none); }
.leading-tight { line-height: var(--line-height-tight); }
.leading-snug { line-height: var(--line-height-snug); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-relaxed { line-height: var(--line-height-relaxed); }
.leading-loose { line-height: var(--line-height-loose); }

/* Letter Spacing */
.tracking-tighter { letter-spacing: var(--letter-spacing-tighter); }
.tracking-tight { letter-spacing: var(--letter-spacing-tight); }
.tracking-normal { letter-spacing: var(--letter-spacing-normal); }
.tracking-wide { letter-spacing: var(--letter-spacing-wide); }
.tracking-wider { letter-spacing: var(--letter-spacing-wider); }
.tracking-widest { letter-spacing: var(--letter-spacing-widest); }

/* Max Width */
.max-w-prose { max-width: var(--max-width-prose); }
.max-w-reading { max-width: var(--max-width-reading); }
.max-w-full { max-width: 100%; }

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

/* Line Clamp (Multi-line truncate) */
.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;
}

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

@media (max-width: 767px) {
  /* Mobile-specific adjustments */
  h1 {
    font-size: 2rem; /* 32px on very small screens */
    letter-spacing: var(--letter-spacing-tight);
  }

  h2 {
    font-size: 1.75rem; /* 28px */
  }

  .lead,
  p.lead {
    font-size: var(--font-size-md);
  }
}

/* ============================================
   PRINT TYPOGRAPHY
   ============================================ */

@media print {
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    color: #000;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  code, pre {
    border: var(--border-width-1) solid #ccc;
  }
}
