/* ==========================================================================
   VARIABLES
   ========================================================================== */
:root {
  --ink: #1a1814;
  --ink-2: #3d3a33;
  --ink-3: #6b6760;
  --page: #faf8f4;
  --rule: #ddd9d0;

  --col-label-bg: #e8f3e8;
  --col-label-border: #c2dcc2;

  --bg-pink: #fce8e3;
  --bg-yellow: #fdf6d8;

  --col-lin-s-bg: var(--bg-pink);
  --col-lin-s-border: #e8c8c0;
  --col-log-s-bg: var(--bg-pink);

  --col-lin-v-bg: var(--bg-pink);
  --col-lin-v-border: #e8c8c0;
  --col-log-v-bg: var(--bg-pink);

  --col-lin-m-bg: var(--bg-yellow);
  --col-lin-m-border: #e8dca8;
  --col-log-m-bg: var(--bg-yellow);

  --header-border: #c8c4f0;
  --accent-purple: #5b4fcf;
  --accent-teal: #0e7a6e;
}

/* ==========================================================================
   RESETS & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

* {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  font-family: "Lora", Georgia, serif;
  background: var(--page);
  color: var(--ink);
  min-height: 100vh;
  padding: 48px 24px 80px;
}

/* ==========================================================================
   LAYOUT & UTILITIES
   ========================================================================== */
.page {
  max-width: 1400px;
  margin: 0 auto;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.text-upper {
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ==========================================================================
   TABLES: GENERAL & LAYOUT
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  margin-bottom: 48px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

.main-table col.c-label {
  width: 10%;
}

.main-table col.c-lin-s,
.main-table col.c-log-s,
.main-table col.c-lin-v,
.main-table col.c-log-v,
.main-table col.c-lin-m,
.main-table col.c-log-m {
  width: 15%;
}

.dataset-table {
  min-width: 600px;
}

/* ==========================================================================
   TABLES: HEADERS & CELLS
   ========================================================================== */
td {
  padding: 18px 18px;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.9;
}

tbody tr {
  border-bottom: 1px solid var(--rule);
}

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

.dataset-table td,
.dataset-table th {
  text-align: center;
  border-right: 1px solid var(--rule);
}

.dataset-table th,
thead tr.top-header th {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  padding: 14px 18px;
  background: #e8e2f8;
  border-bottom: 1.5px solid var(--header-border);
  color: var(--accent-purple);
  text-align: center;
}

.dataset-table .td-label {
  font-size: 14px;
  color: var(--ink-2);
}

thead tr.top-header th.th-empty {
  background: transparent !important;
  border: hidden !important;
}

thead tr.top-header th.th-sca,
thead tr.top-header th.th-vec {
  border-right: 2px solid var(--rule);
}

thead tr.sub-header th {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  padding: 8px 18px 10px;
  color: var(--ink-3);
  text-align: center;
  border-bottom: 1.5px solid var(--rule);
}

.header-desc {
  display: block;
  font-family: "Lora", Georgia, serif;
  font-size: 11px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink-3);
  margin-top: 6px;
  font-weight: 400;
}

/* ==========================================================================
   TABLES: SPECIFIC CELL COLOURS
   ========================================================================== */
td.td-label {
  background: var(--col-label-bg);
  border-right: 1px solid var(--col-label-border);
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  color: var(--accent-teal);
  text-align: center;
  line-height: 1.7;
}

th.sub-lin-s,
td.td-lin-s {
  background: var(--col-lin-s-bg);
  border-right: 1px solid var(--col-lin-s-border);
}

th.sub-log-s,
td.td-log-s {
  background: var(--col-log-s-bg);
  border-right: 2px solid var(--rule);
}

th.sub-lin-v,
td.td-lin-v {
  background: var(--col-lin-v-bg);
  border-right: 1px solid var(--col-lin-v-border);
}

td.td-lin-v[colspan="2"] {
  border-right: 2px solid var(--rule);
}

th.sub-log-v,
td.td-log-v {
  background: var(--col-log-v-bg);
  border-right: 2px solid var(--rule);
}

th.sub-lin-m,
td.td-lin-m {
  background: var(--col-lin-m-bg);
  border-right: 1px solid var(--col-lin-m-border);
}

th.sub-log-m,
td.td-log-m {
  background: var(--col-log-m-bg);
}

td.td-sca-shared,
td.td-vec-shared {
  background: var(--col-lin-s-bg);
  border-right: 2px solid var(--rule);
}

td.td-mat-shared {
  background: var(--col-lin-m-bg);
}

/* ==========================================================================
   EQUATIONS & MATH (KATEX)
   ========================================================================== */
.eq {
  font-size: 14px;
  line-height: 2.5;
  text-align: center;
  padding: 12px 0;
  overflow: visible;
  white-space: normal;
}

.katex {
  font-size: 1em !important;
}

.katex-display {
  margin: 0 !important;
}

/* ==========================================================================
   COMPONENT: NEQ CARD
   ========================================================================== */
.neq-card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  background: var(--page);
  margin-bottom: 48px;
  overflow: hidden;
}

.neq-block {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.neq-block:not(:last-child) {
  border-bottom: 1px solid var(--col-lin-m-border);
}

.neq-label {
  flex: 0 0 180px;
  background: var(--col-label-bg);
  border-right: 1px solid var(--col-label-border);
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 14px;
  line-height: 1.7;
  word-break: break-word;
}

.neq-label--math {
  flex: 0 0 180px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 9px;
}

.neq-body {
  flex: 1;
  padding: 22px 28px;
  background: var(--col-lin-m-bg);
}

.neq-prose {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.8;
}

.neq-eq {
  text-align: center;
  font-size: 14px;
  line-height: 2.5;
  padding: 12px 0;
  overflow: visible;
}

.neq-eq-bullet {
  margin-top: 10px;
  margin-bottom: 4px;
}

.neq-divider {
  display: none;
}

.neq-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.neq-list li {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.8;
  padding-left: 20px;
  position: relative;
}

.neq-list li::before {
  position: absolute;
  left: 0;
  color: var(--accent-teal);
  font-weight: 600;
}

ul.neq-list > li::before {
  content: "•";
}

ol.neq-list {
  counter-reset: neq-counter;
}

ol.neq-list > li::before {
  counter-increment: neq-counter;
  content: counter(neq-counter) ".";
}

/* ==========================================================================
   COMPONENT: NOTES & GRIDS
   ========================================================================== */
.note {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 8px;
  line-height: 1.7;
  font-style: italic;
  text-align: center;
}

.note-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 4px 0;
}

.note-item {
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
  font-style: italic;
}

.note-pro {
  background: #eef7ee;
  border-left: 3px solid #7bbf7b;
}

.note-con {
  background: #fff5ee;
  border-left: 3px solid #e0a070;
}

.note-tag {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-style: normal;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink-3);
}

/* ==========================================================================
   NAVIGATION FOOTER
   ========================================================================== */
.nav-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-trail-link {
  color: var(--accent-purple);
  text-decoration: none;
  transition: opacity 0.2s;
}

.nav-trail-link:hover {
  opacity: 0.7;
}

.nav-trail-current {
  color: var(--ink);
  font-weight: 600;
}

.nav-trail-sep {
  color: var(--rule);
  margin: 0 4px;
  user-select: none;
}

/* ==========================================================================
   BORDERS & EDGE CASES (TABLE RADIUS OVERRIDES)
   ========================================================================== */
thead tr:first-child th {
  border-top: 1px solid var(--rule);
}

tbody td {
  border-bottom: 1px solid var(--rule);
}

tr > :last-child {
  border-right: 1px solid var(--rule);
}

thead tr.top-header th:first-child,
tbody td.td-label,
tbody td.td-section-header {
  border-left: 1px solid var(--rule);
}

thead tr:first-child th:first-child {
  border-top-left-radius: 8px;
}

thead tr:first-child th:last-child {
  border-top-right-radius: 8px;
}

tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

.main-table thead tr.top-header th.th-empty + th {
  border-top-left-radius: 8px;
  border-left: 1px solid var(--rule);
}

.main-table thead tr.sub-header th:first-child {
  border-left: 1px solid var(--rule);
}

.main-table tbody tr:first-child td:first-child {
  border-top-left-radius: 8px;
  border-top: 1px solid var(--rule);
}

.phase-table tbody tr:first-child td.td-label {
  border-top: 1px solid var(--rule);
}

.phase-table tbody tr:first-child td.td-section-header,
.phase-table tbody tr:nth-child(2) td {
  border-bottom: 2px solid var(--rule);
}

.phase-table tbody tr:nth-last-child(2) td.td-section-header {
  border-bottom-left-radius: 8px;
  border-bottom: 1px solid var(--rule);
}

.phase-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 0;
}

/* ==========================================================================
   SEARCH BAR COMPONENT
   ========================================================================== */
.search-container {
  position: relative;
  margin: 0 auto 32px auto;
  width: 100%;
  max-width: 1400px;
  z-index: 100;
}

#site-search {
  width: 100%;
  padding: 12px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  background: var(--page);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

#site-search:focus {
  border-color: var(--header-border);
  box-shadow: 0 0 0 3px rgba(200, 196, 240, 0.3);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: var(--accent-purple);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: background 0.2s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: #e8e2f8;
  color: var(--ink);
}

.search-result-empty {
  padding: 12px 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  font-style: italic;
}
