/* ================================================================
   TYPOGRAPHY POLISH
   Professional typography refinements for optimal readability
   ================================================================ */

/* ================================================================
   FONT RENDERING OPTIMIZATIONS
   ================================================================ */

html {
  /* Optimized font rendering across browsers */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

body {
  /* Smooth text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Optimize text rendering */
  text-rendering: optimizeLegibility;

  /* Enable font features */
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;

  /* Prevent font size adjustments on iOS */
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ================================================================
   OPTIMAL LINE HEIGHT
   ================================================================ */

/* Body text - optimal readability (1.6) */
body,
p,
li,
.text-body,
.article__content,
.content,
blockquote {
  line-height: 1.6;
}

/* Headings - tighter line height (1.2) for visual hierarchy */
h1, .h1,
h2, .h2,
h3, .h3,
h4, .h4,
h5, .h5,
h6, .h6 {
  line-height: 1.2;
  font-weight: 700;
}

/* Large display text - even tighter */
.display-1,
.display-2,
.hero__title,
.page-title {
  line-height: 1.1;
}

/* Small text - slightly increased for readability */
small,
.text-small,
.text-xs,
.caption,
.meta {
  line-height: 1.5;
}

/* Code blocks - monospace optimal */
code,
pre,
kbd,
samp {
  line-height: 1.5;
}

/* Lists - breathing room */
ul,
ol {
  line-height: 1.6;
}

li {
  margin-bottom: 0.375em;
}

/* ================================================================
   LETTER SPACING REFINEMENTS
   ================================================================ */

/* Headings - slight negative tracking for professional look */
h1, .h1 {
  letter-spacing: -0.02em;
  font-size: clamp(2rem, 5vw, 3rem);
}

/* Content/article pages - moderate H1 sizing */
.prose header h1,
.section__inner--content header h1 {
  font-size: var(--text-3xl);
  line-height: 1.2;
}

h2, .h2 {
  letter-spacing: -0.02em;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

h3, .h3 {
  letter-spacing: -0.015em;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
}

h4, .h4 {
  letter-spacing: -0.01em;
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
}

h5, .h5,
h6, .h6 {
  letter-spacing: normal;
}

/* Body text - normal spacing */
body,
p,
li,
.text-body {
  letter-spacing: normal;
}

/* Small caps - increased spacing */
.small-caps,
.all-caps,
.uppercase {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.875em;
}

/* Button text - slight increase for clarity */
button,
.btn,
input[type="submit"],
input[type="button"] {
  letter-spacing: 0.025em;
  font-weight: 500;
}

/* Meta information - slight increase */
.meta,
.caption,
time,
.date {
  letter-spacing: 0.01em;
}

/* Code - monospace default */
code,
pre,
kbd,
samp {
  letter-spacing: normal;
}

/* ================================================================
   FONT SIZE SCALE CONSISTENCY
   ================================================================ */

/* Consistent type scale using CSS custom properties */
.text-xs,
.text-extra-small {
  font-size: var(--text-xs, 0.75rem);      /* 12px */
}

.text-sm,
.text-small {
  font-size: var(--text-sm, 0.875rem);     /* 14px */
}

.text-base,
.text-body {
  font-size: var(--text-base, 1rem);       /* 16px */
}

.text-lg,
.text-large {
  font-size: var(--text-lg, 1.0625rem);   /* 17px */
}

.text-xl {
  font-size: var(--text-xl, 1.25rem);      /* 20px */
}

.text-2xl {
  font-size: var(--text-2xl, 1.5rem);      /* 24px */
}

.text-3xl {
  font-size: var(--text-3xl, 2rem);        /* 32px */
}

.text-4xl {
  font-size: var(--text-4xl, 2.5rem);      /* 40px */
}

/* ================================================================
   IMPROVED READABILITY
   ================================================================ */

/* Optimal line length for reading (50-75 characters) */
.article__content,
.content,
.text-content,
.prose {
  max-width: 100%;
}

.article__content > *,
.content > *,
.prose > * {
  max-width: 100%;
}

/* ================================================================
   PROSE TYPOGRAPHY OVERRIDES
   Engine .prose sets font-size: var(--text-lg) (18px) and oversized
   headings. Journey/Mediavine requires 18px minimum body font for ad
   placement optimization. Using --text-lg (18px) to comply.
   ================================================================ */
.prose {
  font-size: var(--text-lg);
  line-height: 1.6;
}

.prose h2 {
  font-size: var(--text-2xl);
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.prose h3 {
  font-size: var(--text-xl);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.prose > * + * {
  margin-top: 0.75rem;
}

.prose ul,
.prose ol {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

/* Wider for lists and technical content */
.article__content ul,
.article__content ol,
.content ul,
.content ol {
  max-width: 70ch;
}

/* Full width for tables and figures */
.article__content table,
.article__content figure,
.article__content img,
.content table,
.content figure,
.content img {
  max-width: 100%;
}

/* Paragraph spacing, 1.5em gives Journey/Mediavine room for in-content ads */
p {
  margin-bottom: 1.5em;
}

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

/* Prevent orphans and widows */
p,
li,
h1, h2, h3, h4, h5, h6 {
  orphans: 3;
  widows: 3;
}

/* Headings should not break */
h1, h2, h3, h4, h5, h6 {
  break-after: avoid;
  page-break-after: avoid;
}

/* Global text-wrap: pretty, prevents single-word orphan last lines
   across all text elements. h2/h3 use balance (shorter headings
   benefit from equal-length lines). h1 excluded from balance because
   it narrows long titles (S123 fix). */
h1, h4, h5, h6, p, li, td, th, blockquote, figcaption, dt, dd {
  text-wrap: pretty;
}
h2, h3 {
  text-wrap: balance;
}

/* ================================================================
   PROPER HIERARCHY ENFORCEMENT
   ================================================================ */

/* Clear visual hierarchy through size and spacing */
h1, .h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 700;
}

h2, .h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.875rem;
  font-weight: 700;
}

h3, .h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h4, .h4 {
  margin-top: 1.75rem;
  margin-bottom: 0.625rem;
  font-weight: 600;
}

h5, .h5 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

h6, .h6 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  font-size: var(--text-sm, 0.875rem);
  letter-spacing: 0.05em;
}

/* First heading in content area needs no top margin */
.article__content > h1:first-child,
.article__content > h2:first-child,
.article__content > h3:first-child,
.content > h1:first-child,
.content > h2:first-child,
.content > h3:first-child {
  margin-top: 0;
}

/* ================================================================
   IMPROVED LINK STYLING
   ================================================================ */

/* Links within text content */
.article__content a:not([class]),
.content a:not([class]),
.prose a:not([class]),
p a:not([class]),
li a:not([class]) {
  color: var(--accent-primary, #0ea5e9);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.article__content a:hover,
.content a:hover,
.prose a:hover,
p a:hover,
li a:hover {
  color: var(--accent-hover, #00b8e0);
  border-bottom-color: var(--accent-hover, #00b8e0);
}

/* Headings are navigation titles, not inline text links, suppress the prose border-bottom
   so card title anchors get a single underline (text-decoration) on hover instead of a double line.
   Specificity must beat `.prose a:hover` (0,2,1), adding :hover bumps ours to 0,2,2. */
.prose h1 a, .prose h2 a, .prose h3 a, .prose h4 a, .prose h5 a, .prose h6 a,
.prose h1 a:hover, .prose h2 a:hover, .prose h3 a:hover, .prose h4 a:hover, .prose h5 a:hover, .prose h6 a:hover,
.article__content h1 a, .article__content h2 a, .article__content h3 a, .article__content h4 a, .article__content h5 a, .article__content h6 a,
.article__content h1 a:hover, .article__content h2 a:hover, .article__content h3 a:hover, .article__content h4 a:hover, .article__content h5 a:hover, .article__content h6 a:hover,
.content h1 a, .content h2 a, .content h3 a, .content h4 a, .content h5 a, .content h6 a,
.content h1 a:hover, .content h2 a:hover, .content h3 a:hover, .content h4 a:hover, .content h5 a:hover, .content h6 a:hover {
  border-bottom: 0;
  border-bottom-color: transparent;
}

/* Card-list patterns (SEO hub pages, category lists, sitemap): the `<li>` IS the card
   and the anchor is the whole item, not inline prose. Suppress the generic `li a:hover`
   border-bottom so hovering a card-row link shows no detached underline below the text. */
.page-list li a,
.page-list li a:hover,
.content-body ul:not(.toc-list) > li > a,
.content-body ul:not(.toc-list) > li > a:hover,
.content-section ul:not(.toc-list) > li > a,
.content-section ul:not(.toc-list) > li > a:hover,
.seo-content-page .content-body ul:not(.toc-list) > li > a,
.seo-content-page .content-body ul:not(.toc-list) > li > a:hover {
  border-bottom: 0;
  border-bottom-color: transparent;
}

.article__content a:focus,
.content a:focus,
.prose a:focus {
  outline: 2px solid var(--accent-primary, #0ea5e9);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Button border enforcement ──
   Problem: core.css sets `a { border-bottom: 1px solid transparent }` globally.
   The border-bottom longhand persists through the cascade and overrides .btn's
   border shorthand in contexts where specificity ties (source order loses).
   Fix: explicitly set border on ALL a.btn variants at higher specificity (0,1,1+),
   placed late in cascade (this file loads near end of site_css). */

/* Global: any <a> with .btn class, override the 'a' border-bottom cascade */
a.btn {
  text-decoration: none;
  border-bottom-color: inherit;
}

a.btn-primary,
a.btn-primary:visited {
  color: var(--bg-primary);
  border: 1px solid var(--accent-primary);
}

a.btn-primary:hover {
  color: var(--bg-primary);
  border-color: var(--accent-hover);
}

a.btn-secondary,
a.btn-secondary:visited {
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

a.btn-secondary:hover {
  border-color: var(--accent-primary);
}

a.btn-ghost,
a.btn-ghost:visited {
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

/* Prose/content context: bump specificity to (0,2,1) to beat .prose a (0,1,1) */
.prose a.btn,
.content a.btn {
  text-decoration: none;
  border-bottom-style: solid;
  border-bottom-width: 1px;
}

.prose a.btn-primary,
.content a.btn-primary {
  color: var(--bg-primary);
  border: 1px solid var(--accent-primary);
}

.prose a.btn-primary:hover,
.content a.btn-primary:hover {
  color: var(--bg-primary);
  border-color: var(--accent-hover);
}

.prose a.btn-secondary,
.content a.btn-secondary {
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.prose a.btn-secondary:hover,
.content a.btn-secondary:hover {
  border-color: var(--accent-primary);
}

.prose a.btn-ghost,
.content a.btn-ghost {
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

/* ================================================================
   BLOCKQUOTE STYLING
   ================================================================ */

blockquote {
  margin: 2rem 0;
  padding-left: 1.5rem;
  border-left: 4px solid var(--accent-primary, #0ea5e9);
  font-style: italic;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.6;
}

blockquote p {
  margin-bottom: 0.75em;
}

blockquote cite {
  display: block;
  margin-top: 1rem;
  font-style: normal;
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-muted, #b0b8c4);
}

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

/* ================================================================
   LIST IMPROVEMENTS
   ================================================================ */

ul,
ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

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

/* Nested lists */
ul ul,
ul ol,
ol ul,
ol ol {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Custom list markers */
.article__content ul,
.content ul,
.prose ul {
  list-style-type: disc;
}

.article__content ul ul,
.content ul ul,
.prose ul ul {
  list-style-type: circle;
}

/* ================================================================
   CODE & PRE FORMATTING
   ================================================================ */

code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.875em;
  background: var(--bg-tertiary, #162032);
  padding: 0.125em 0.375em;
  border-radius: 3px;
  color: var(--accent-primary, #0ea5e9);
  font-weight: 400;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
}

pre {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: var(--text-sm);
  line-height: 1.5;
  background: var(--bg-tertiary, #162032);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
}

pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--text-primary, #e2e8f0);
}

/* ================================================================
   TABLE TYPOGRAPHY
   ================================================================ */

table {
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.5;
}

th {
  font-weight: 600;
  text-align: left;
  letter-spacing: 0.025em;
}

td {
  font-weight: 400;
}

caption {
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 0.75rem;
  text-align: left;
  font-weight: 500;
}

/* ================================================================
   EMPHASIS & STRONG
   ================================================================ */

em,
i {
  font-style: italic;
}

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

/* ================================================================
   HORIZONTAL RULES
   ================================================================ */

hr {
  margin: 3rem 0;
  border: none;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

/* ================================================================
   ABBREVIATIONS
   ================================================================ */

abbr[title],
abbr[data-original-title] {
  text-decoration: underline dotted;
  cursor: help;
  border-bottom: 1px dotted var(--text-secondary, #94a3b8);
}

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

dl {
  margin-bottom: 1.5rem;
}

dt {
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary, #e2e8f0);
}

dd {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary, #94a3b8);
}

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

/* ================================================================
   MARK / HIGHLIGHT
   ================================================================ */

mark,
.highlight {
  background-color: rgba(234, 179, 8, 0.2);
  color: var(--text-primary, #e2e8f0);
  padding: 0.125em 0.25em;
  border-radius: 2px;
}

/* ================================================================
   SUBSCRIPT & SUPERSCRIPT
   ================================================================ */

sub,
sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.5em;
}

sub {
  bottom: -0.25em;
}

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

@media (max-width: 768px) {
  /* Scale down headings on mobile */
  h1, .h1 {
    font-size: clamp(1.75rem, 6vw, 2.5rem);
  }

  h2, .h2 {
    font-size: clamp(1.5rem, 5vw, 2rem);
  }

  h3, .h3 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
  }

  /* Reduce spacing on mobile */
  h2, .h2 {
    margin-top: 2rem;
  }

  h3, .h3 {
    margin-top: 1.5rem;
  }

  /* Optimize line length for mobile */
  .article__content,
  .content,
  .prose {
    max-width: 100%;
  }
}

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

@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
  }

  h1 {
    font-size: 24pt;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    page-break-after: avoid;
  }

  h3 {
    font-size: 14pt;
    page-break-after: avoid;
  }

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

  /* Show link URLs in print */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.875em;
    color: #666;
  }
}

/* ================================================================
   TEXT SELECTION
   ================================================================ */

::selection {
  background: var(--accent-primary, #0ea5e9);
  color: #fff;
}

::-moz-selection {
  background: var(--accent-primary, #0ea5e9);
  color: #fff;
}

/* Scrollbar styling consolidated in dark-mode-enhancements.css */

/* ================================================================
   ACCESSIBILITY ALIAS
   ================================================================ */

/* Common alias for .visually-hidden (provided by engine base theme) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Becomes visible on focus (for skip links / show-on-focus elements) */
.sr-only-focusable:focus,
.sr-only-focusable:focus-visible {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ================================================================
   PRINT STYLES
   ================================================================ */

@media print {
  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
  }

  h1 {
    font-size: 24pt;
    page-break-after: avoid;
  }

  h2 {
    font-size: 18pt;
    page-break-after: avoid;
  }

  h3 {
    font-size: 14pt;
    page-break-after: avoid;
  }

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

  /* Hide UI elements in print */
  .share-buttons,
  .error-toast,
  .cookie-consent,
  .bottom-nav,
  .btn--secondary {
    display: none !important;
  }

  /* Show link URLs in print */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.875em;
    color: #666;
  }
}

/* ================================================================
   RESPECT REDUCED MOTION
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
