/* =============================================================
   CPP Data Repository — Stylesheet
   ============================================================= */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #fff;
}
a { color: #2C6FAC; text-decoration: none; }
a:hover { color: #1a4f7a; text-decoration: underline; }
h1, h2, h3, h4 { color: #222; margin-top: 1.5em; margin-bottom: 0.5em; }
h1 { font-size: 1.8em; }
h2 { font-size: 1.4em; border-bottom: 1px solid #dee2e6; padding-bottom: 0.3em; }
h3 { font-size: 1.15em; }
p { margin: 0.6em 0; }
img { max-width: 100%; }

/* --- Layout --- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Navigation --- */
nav {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.nav-brand {
  font-weight: 700;
  font-size: 1.05em;
  color: #222;
  text-decoration: none;
}
.nav-brand:hover { color: #222; text-decoration: none; }
.nav-links { display: flex; gap: 18px; flex-wrap: wrap; }
.nav-links a {
  font-size: 0.95em;
  color: #555;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: #2C6FAC; text-decoration: none; }
.nav-links a.active {
  color: #2C6FAC;
  border-bottom-color: #2C6FAC;
}

/* --- Page Header --- */
.page-header {
  margin: 2em 0 1.5em;
}
.page-header h1 { margin-bottom: 0.2em; }
.page-header .subtitle {
  color: #666;
  font-size: 1.05em;
  margin-top: 0;
}

/* --- Stat Boxes (Home) --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 1.5em 0;
}
.stat-box {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 20px 16px;
  text-align: center;
  border: 1px solid #e9ecef;
}
.stat-number {
  font-size: 1.8em;
  font-weight: 700;
  color: #2C3E50;
  line-height: 1.2;
}
.stat-label {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

/* --- Institutions List --- */
.institution-list {
  list-style: none;
  padding: 0;
}
.institution-list li {
  padding: 4px 0;
  font-size: 0.93em;
  white-space: nowrap;
}
.institution-list .site-code {
  display: inline-block;
  width: 28px;
  font-weight: 600;
  color: #888;
  font-size: 0.85em;
}

/* --- Tables --- */
table.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.93em;
}
table.info-table th {
  background: #f8f9fa;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
}
table.info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: top;
}
table.info-table tr:hover { background: #f8f9fa; }
table.info-table code {
  font-size: 0.9em;
  background: #e9ecef;
  padding: 1px 5px;
  border-radius: 3px;
}
tr.recommended td { background: #f0f8f0; }
tr.recommended td:first-child { border-left: 3px solid #4CAF50; }

/* --- Download Buttons --- */
.btn-download {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.82em;
  background: #2C6FAC;
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
}
.btn-download:hover { background: #1a4f7a; color: #fff; text-decoration: none; }

/* --- Code Blocks --- */
pre {
  background: #f6f8fa;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 14px 18px;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.5;
}
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
p code, li code {
  background: #f0f2f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}
.code-label {
  display: inline-block;
  background: #2C3E50;
  color: #fff;
  font-size: 0.75em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
  position: relative;
  top: 1px;
}

/* --- Type Badges (Codebook) --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.78em;
  font-weight: 600;
  text-transform: lowercase;
  white-space: nowrap;
}
.badge-continuous  { background: #e8f5e9; color: #2e7d32; }
.badge-categorical { background: #e3f2fd; color: #1565c0; }
.badge-binary      { background: #fff3e0; color: #e65100; }
.badge-ordinal     { background: #f3e5f5; color: #7b1fa2; }
.badge-string      { background: #eceff1; color: #455a64; }
.badge-blank       { background: #f5f5f5; color: #9e9e9e; }
.badge-id          { background: #efebe9; color: #5d4037; }

/* --- Codebook Filters --- */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar label {
  font-size: 0.88em;
  font-weight: 600;
  color: #555;
}
.filter-bar select {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
  background: #fff;
}
.filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Codebook Child Row --- */
.child-row {
  padding: 12px 16px;
  background: #fafbfc;
  border-left: 3px solid #2C6FAC;
}
.child-row dt {
  font-weight: 600;
  color: #555;
  font-size: 0.85em;
  margin-top: 8px;
}
.child-row dt:first-child { margin-top: 0; }
.child-row dd {
  margin-left: 0;
  font-size: 0.9em;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- FAQ --- */
.faq-item { margin-bottom: 2em; }
.faq-item h3 {
  color: #2C3E50;
  margin-bottom: 0.3em;
}

/* --- Footer --- */
footer {
  margin-top: 3em;
  padding: 1.5em 0;
  border-top: 1px solid #dee2e6;
  text-align: center;
  font-size: 0.85em;
  color: #888;
}

/* --- DataTables Overrides --- */
.dataTables_wrapper .dataTables_length select {
  padding: 4px 8px;
}
.dataTables_wrapper .dataTables_filter input {
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
table.dataTable {
  font-size: 0.9em;
}
table.dataTable thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  font-size: 0.88em;
}
table.dataTable tbody td {
  padding: 6px 10px;
  vertical-align: top;
}
table.dataTable tbody tr:hover {
  background: #f0f4f8 !important;
  cursor: pointer;
}
td.font-mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88em;
}
td.truncated {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Section Divider --- */
.tier-section {
  margin-top: 2em;
}
.tier-section h3 {
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 4px solid #2C6FAC;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .institution-list { columns: 1; }
  .nav-inner { flex-direction: column; align-items: flex-start; }
  .nav-links { gap: 12px; }
  h1 { font-size: 1.4em; }
  .filter-bar { flex-direction: column; }
  td.truncated { max-width: 150px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
}
