/* ========================= 0) Fonts ========================= */
@font-face {
  font-family: "Campton";
  src: url("/fonts/Campton-Book.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Campton";
  src: url("/fonts/Campton-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Campton";
  src: url("/fonts/Campton-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Campton";
  src: url("/fonts/Campton-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ========================= 1) Tokens / Base ========================= */
:root {
  --bg: #fff;
  --card: #fff;
  --border: #e6e6e6;
  --text: #222;
  --muted: #666;
  --radius: 12px;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  font-family: "Campton", Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden; /* internal scroller lives in .table-body */
}

/* ========================= 2) Layout ========================= */
.page {
  width: 100%;
  max-width: 692px;
  margin: 16px auto 48px;
  padding: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#searchView {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

/* ========================= 3) Utilities ========================= */
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
  font-style: italic;
}
.dash {
  color: #999;
  font-weight: 400;
  font-size: 14px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================= 4) Intro (text + figure) ========================= */
.intro {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
  margin: 8px 0 12px;
}
.intro p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
}
.intro-fig img {
  max-width: 92%;
  margin-left: auto;
  display: block;
  border-radius: 8px;
}
.intro a.intro-link {
  display: inline-block;
  margin-top: 20px;
  color: #28506e;
  text-decoration: none;
  font-weight: 600;
}
.intro a.intro-link:hover {
  text-decoration: underline;
}
@media (min-width: 661px) {
  .intro {
    grid-template-columns: 1fr 240px;
    gap: 16px;
  }
}

/* ========================= 5) Search ========================= */
.search-bar {
  margin: 12px 0 12px;
}
.search-bar label {
  display: block;
  margin-bottom: 6px;
}
.search-bar .row {
  display: flex;
  gap: 8px;
}
.search-bar input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.search-bar input::placeholder {
  font-family: "Campton", Arial, Helvetica, sans-serif;
}
.search-bar button,
.muted-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #28506e;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}
.search-bar button:hover,
.muted-btn:hover {
  background: #204058;
}
.results-bar {
  margin: 20px 0 8px;
  font-size: 14px;
  font-weight: 600;
  min-height: 22px;
}
.results-bar.is-hidden {
  visibility: hidden;
}

/* ========================= 6) Table (header + scrolling body) ========================= */
/* -- Shell ----------------------------------------------------------- */
.table-wrap {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

/* -- Header: continuous blue bar (no scrollbar) --------------------- */
.table-head {
  flex: 0 0 auto;
  overflow: hidden;
  padding-right: var(--sbw, 0px);
  background: #28506e;
  color: #fff;
  font-family: "Campton", Arial, Helvetica, sans-serif;
  font-weight: 600;
  border-bottom: 1px solid #e9eef3;
}
.table-head table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}
.table-head thead th {
  font: inherit;
  color: inherit;
  background: transparent;
  text-align: left;
  padding: 12px 10px;
  min-width: 0;
  min-height: 44px;
  border-radius: 0;
}
.table-head thead th button.sort {
  all: unset;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.table-head thead th .sort-arrow {
  color: inherit;
}
.table-head thead th[aria-sort="ascending"] .sort-arrow::after {
  content: "▲";
}
.table-head thead th[aria-sort="descending"] .sort-arrow::after {
  content: "▼";
}
.table-head thead th[aria-sort="none"] .sort-arrow::after {
  content: "";
}
.table-head thead th .sort-arrow::after {
  font-size: 10px;
  vertical-align: middle;
  opacity: 0.85;
  margin-left: 2px;
}
.table-head th:nth-child(4) button.sort {
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -- Body: the only scrolling area ---------------------------------- */
.table-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.table-body table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

/* Rows & cells */
.table-body tbody td {
  padding: 10px;
  border-bottom: 1px solid #f1f1f1;
  vertical-align: top;
  min-width: 0;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  overflow-wrap: anywhere;
  word-break: normal;
}
.table-body tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}
.table-body tbody tr:hover {
  background: #d4dce2;
}
.table-body tbody tr:focus-within {
  outline: 2px solid #c9def5;
  outline-offset: -2px;
  background: #d4dce2;
}

/* Table text & links */
.inst-table {
  font-size: 14px;
}
/* Global link styling (covers links in table & details) */
a {
  color: #28506e;
  font-weight: 600;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Compact lists inside cells */
ul.compact {
  margin: 0;
  padding-left: 0;
  list-style: none;
}
ul.compact li {
  position: relative;
  margin: 2px 0;
  padding-left: 12px;
  color: var(--text);
  font-weight: 400;
  font-size: 14px;
}
ul.compact li::before {
  content: "-";
  position: absolute;
  left: 0;
  color: #999;
  font-weight: 400;
}

/* -- Infinite scroll helpers ---------------------------------------- */
.loading {
  margin: 10px 0;
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
}
.loading.is-hidden {
  display: none;
}
#infiniteSentinel {
  height: 1px;
}
#infiniteSentinelRow td {
  padding: 0;
  border: 0;
}

/* ========================= 7) Detail view ========================= */
.detail-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 8px;
}
.back-link {
  color: #28506e;
  text-decoration: none;
  font-weight: 500;
}
.back-link:hover {
  text-decoration: underline;
}
.detail-card {
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  font-size: 14px;
}
.detail-header {
  padding-bottom: 10px;
  border-bottom: 2px solid #ccc;
}
.detail-title {
  font-size: 26px;
  margin: 0;
}
.detail-status {
  margin: 0.25rem 0 0.6rem;
  color: #777;
  font-style: italic;
}
.detail-status.current {
  color: #007b3e;
  font-style: normal;
  font-weight: 600;
}
.detail-status.historic {
  color: #c62828;
  font-style: normal;
  font-weight: 600;
}
.icon-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 14px;
  color: #444;
}
.icon-line .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: currentColor;
  -webkit-mask-image: var(--icon);
  mask-image: var(--icon);
  -webkit-mask-size: cover;
  mask-size: cover;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.globe-line {
  --icon: url("/icons/globe.svg");
}
.location-line {
  --icon: url("/icons/location.svg");
}
#instWebsite a {
  color: #28506e;
  text-decoration: none;
  font-weight: 600;
}
#instWebsite a:hover {
  text-decoration: underline;
}
.location-line + .globe-line {
  margin-top: 10px;
}
.kv {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
}
.kv th,
.kv td {
  padding: 0.65rem 0.5rem;
  vertical-align: top;
  border-top: 1px solid #eee;
}
.kv tr:first-child th,
.kv tr:first-child td {
  border-top: none;
}
.kv th {
  width: 40%;
  font-weight: 600;
  color: #333;
  text-align: left;
}

/* Hyphen prefix for multi-line lists in details view */
.hyphen-list .item {
  display: block;
  padding-left: 1rem;
  position: relative;
  line-height: 1.45;
}
.hyphen-list .item::before {
  content: "-";
  position: absolute;
  left: 0;
  top: 0;
  color: #999;
  font-weight: 400;
}

/* ========================= 8) Responsive ========================= */
@media (max-width: 660px) {
  .page {
    padding: 0;
  }
  .results-bar {
    margin: 20px 0 16px;
  }
  .table-wrap {
    margin-right: 8px;
  }
  .table-body {
    scrollbar-gutter: stable both-edges;
    padding-right: 6px;
  }
  .table-head {
    padding-right: calc(var(--sbw, 0px) + 6px);
  }
  .intro-fig {
    display: flex;
    justify-content: center;
  }
  .intro-fig img {
    margin: 0 auto;
    max-width: 92%;
  }
  .table-head thead th,
  .table-body tbody td,
  .inst-table,
  .inst-table a,
  ul.compact li {
    font-size: 13px;
    line-height: 1.4;
  }
  .table-head thead th,
  .table-body tbody td {
    padding: 6px;
  }
  ul.compact li::before {
    font-size: 13px;
  }
  .inst-table colgroup col:nth-child(1),
  .inst-table colgroup col:nth-child(2),
  .inst-table colgroup col:nth-child(3) {
    width: 27% !important;
  }
  .inst-table colgroup col:nth-child(4) {
    width: 19% !important;
  }
  .table-head th:nth-child(4) button.sort {
    max-width: 100px;
  }
}

/* ========================= 9) Print ========================= */
@media print {
  .back-link,
  .search-bar,
  .results-bar {
    display: none !important;
  }
  .table-wrap {
    border: 0;
  }
}
