/* Updated: 2026-02-05 - Hybrid approach: JavaScript for screen, pre-processing for PDF */
/* JavaScript handles numbering for screen view */
/* Python pre-processing adds hardcoded numbers before PDF generation */

/* Disable hyphenation throughout the document */
body, p, li, dd, td, th, div {
  hyphens: none !important;
  -webkit-hyphens: none !important;
  -moz-hyphens: none !important;
  -ms-hyphens: none !important;
}

/* Screen mode - JavaScript handles numbering */
@media screen {
  table:not(.sdl-syntax-table) caption {
    font-weight: bold;
  }
}

/* Print mode - numbers already hardcoded by pre-processing */
@media print {
  table:not(.sdl-syntax-table) caption {
    font-weight: bold;
  }
}

figure {
  counter-increment: spec-figure;
}

figure figcaption::before {
  content: "Figure " counter(spec-section) "." counter(spec-figure) ": ";
  font-weight: bold;
}

/* Manual table titles (no auto-numbering) */
.table-title {
  font-weight: bold;
  text-align: center;
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.table-bordered {
  border: 1px solid #e9ecef;
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 1rem;
  background-color: transparent;
}

.table td, .table th {
  padding: .75rem;
  vertical-align: top;
  border-top: 1px solid #e9ecef;
}

.table-sm td, .table-sm th {
  padding: .3rem;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0,0,0,.05);
}

/* Table header styling */
.table thead th {
  background-color: #e9ecef;
  border-bottom: 2px solid #dee2e6;
  font-weight: bold;
  vertical-align: middle;
  text-align: center;
}

.formula {
  counter-increment: spec-formula;
  display: inline-block;
  margin-bottom: 1em;
}

.formula span {
  display: inline;
}

.formula figcaption::before {
  content: "Formula " counter(spec-formula) ": ";
  font-weight: bold;
  display: inline;
}

.reference {
  font-weight: bold;
}

/* SDL Syntax Table Styles */
.sdl-syntax-wrapper {
  margin: 1em 0;
  overflow-x: auto;
}

.sdl-syntax-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #ddd;
  font-family: 'Fira Code', 'Source Code Pro', 'JetBrains Mono', 'Roboto Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  background-color: #f8f9fa;
  margin-bottom: 1rem;
  counter-increment: none; /* Don't count SDL syntax tables as regular tables */
}

/* Table header */
.sdl-syntax-table thead {
  background-color: #e9ecef;
  font-weight: bold;
}

.sdl-syntax-table thead th {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 2px solid #ccc;
  border-right: 1px solid #ccc;
}

.sdl-syntax-table thead th:last-child {
  border-right: none;
}

/* Syntax name column header (left) */
.sdl-syntax-table .sdl-syntax-name {
  width: 85%;
}

/* Descriptor column header (right) - narrow */
.sdl-syntax-table .sdl-descriptor-header {
  width: 15%;
  min-width: 100px;
  text-align: center;
}

/* Table body */
.sdl-syntax-table tbody tr {
  border-bottom: 1px solid #e9ecef;
}

.sdl-syntax-table tbody tr:last-child {
  border-bottom: none;
}

.sdl-syntax-table tbody td {
  padding: 0.4rem 0.75rem;
  vertical-align: middle;
}

/* All cells in the first column (syntax/code) get the border */
.sdl-syntax-table tbody td:first-child {
  border-right: 1px solid #ccc;
}

/* Descriptor column (right side) - narrow */
.sdl-syntax-table .sdl-descriptor {
  width: 15%;
  min-width: 100px;
  font-weight: normal;
  color: #0066cc;
  text-align: center;
}

/* Variable/syntax element column with descriptor (left side) - BOLD */
.sdl-syntax-table .sdl-var-with-descriptor {
  width: 85%;
  font-weight: bold;
  color: #000;
  text-align: left;
}

/* Code lines without descriptors (full width) - NOT BOLD */
.sdl-syntax-table .sdl-code {
  font-weight: normal;
  color: #333;
  text-align: left;
}

/* Alternating row colors for better readability */
.sdl-syntax-table tbody tr:nth-child(even) {
  background-color: #ffffff;
}

.sdl-syntax-table tbody tr:nth-child(odd) {
  background-color: #f8f9fa;
}

/* Single-line comments */
.sdl-syntax-table .sdl-comment {
  color: #6a9955;
  font-style: italic;
  font-weight: normal;
}

/* Code block tables with alternating row colors */
.code-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  background-color: #f8f9fa;
  margin: 1em 0;
  border: 1px solid #ddd;
}

.code-table tbody tr {
  border-bottom: 1px solid #e9ecef;
}

.code-table tbody tr:last-child {
  border-bottom: none;
}

.code-table tbody td {
  padding: 0.4rem 0.75rem;
  vertical-align: top;
  white-space: pre;  /* Preserve whitespace and indentation */
}

/* Alternating row colors */
.code-table tbody tr:nth-child(even) {
  background-color: #ffffff;
}

.code-table tbody tr:nth-child(odd) {
  background-color: #f8f9fa;
}

/* Print styles for code tables */
@media print {
  /* Prefer to keep entire code tables together, but allow breaks if necessary */
  .code-table {
    page-break-inside: avoid;
  }

  /* Never break a row across pages */
  .code-table tbody tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  /* Never break a cell across pages */
  .code-table tbody td {
    page-break-inside: avoid;
  }
}

/* Code block styling - prevent horizontal overflow in nested lists */
@media screen {
  pre {
    max-width: 100%;
    white-space: pre-wrap;       /* Wrap long lines */
    word-wrap: break-word;        /* Break long words if needed */
    tab-size: 4;                  /* Consistent tab rendering */
    padding: 0.5em;
    margin: 0.5em 0;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    font-family: 'Fira Code', 'Source Code Pro', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
  }

  /* Inline code styling */
  code {
    font-family: 'Fira Code', 'Source Code Pro', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0.1em 0.3em;
    background-color: #f8f9fa;
    border-radius: 3px;
  }

  /* Don't add extra background to code inside pre */
  pre code {
    padding: 0;
    background-color: transparent;
    border: none;
    font-size: inherit;
  }
}

/* Hide "Back to TOC" links on screen - only show in PDF/print */
@media screen {
  .back-to-toc {
    display: none !important;
  }
}
