/* GUOSMM Public Registry — mobile-first, Colorado SOS–inspired layout */
:root {
  --navy: #1a365d;
  --navy-dark: #0f2440;
  --blue: #2b6cb0;
  --blue-light: #ebf8ff;
  --gold: #c9a227;
  --gold-light: #faf6e8;
  --gray-50: #f7fafc;
  --gray-100: #edf2f7;
  --gray-200: #e2e8f0;
  --gray-500: #718096;
  --gray-700: #4a5568;
  --gray-900: #1a202c;
  --green: #276749;
  --red: #c53030;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --header-h: 3.5rem;
  --nav-w: min(320px, 88vw);
  --layout-max: min(100%, 1680px);
  --content-pad-x: 0.5rem;
  --content-pad-y: 0.65rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--gold);
  color: var(--navy-dark);
  padding: 0.5rem 1rem;
  z-index: 9999;
}
.skip-link:focus { left: 0; }

/* Header */
.site-header {
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem var(--content-pad-x);
  max-width: var(--layout-max);
  margin: 0 auto;
  width: 100%;
}

.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.4rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.menu-toggle span { transition: transform 0.2s, opacity 0.2s; }

.brand-block { flex: 1; min-width: 0; }
.brand-acronym {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Archive mode toggle */
.mode-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.mode-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 2px;
  border: 1px solid rgba(255,255,255,0.2);
}
.mode-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.mode-btn[aria-pressed="true"] {
  background: var(--gold);
  color: var(--navy-dark);
}
.mode-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Layout shell */
.app-shell {
  display: flex;
  max-width: var(--layout-max);
  margin: 0 auto;
  width: 100%;
  min-height: calc(100dvh - var(--header-h));
}

.side-nav {
  position: fixed;
  inset: 0;
  top: var(--header-h);
  background: rgba(0,0,0,0.4);
  z-index: 90;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s, visibility 0.2s;
}
.side-nav.open { visibility: visible; opacity: 1; }

.side-nav-panel {
  width: var(--nav-w);
  max-width: 100%;
  height: 100%;
  background: #fff;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.side-nav.open .side-nav-panel { transform: translateX(0); }

.nav-section { border-bottom: 1px solid var(--gray-200); }
.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  padding: 0.75rem 1rem 0.35rem;
}
.nav-link {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--navy);
  font-weight: 500;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}
.nav-link:hover, .nav-link.active {
  background: var(--blue-light);
  border-left-color: var(--blue);
  text-decoration: none;
}
.nav-sublink {
  padding-left: 1.75rem;
  font-weight: 400;
  font-size: 0.85rem;
}

.main-content {
  flex: 1;
  padding: var(--content-pad-y) var(--content-pad-x);
  min-width: 0;
  width: 100%;
}

/* Hero / search (CO SOS search block) */
.registry-hero {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.registry-hero h1 {
  font-size: 1.25rem;
  color: var(--navy);
  margin: 0 0 0.35rem;
}
.registry-hero .subtitle {
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-bottom: 1rem;
}
.hague-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  background: var(--gold-light);
  color: var(--navy-dark);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  margin-bottom: 0.75rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.search-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .search-row { flex-direction: row; }
}
.search-input, .search-select {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 1rem;
  min-height: 44px;
}
.search-input:focus, .search-select:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  min-height: 44px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-secondary { background: var(--gray-100); color: var(--navy); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-gold { background: var(--gold); color: var(--navy-dark); }
.btn-sm { padding: 0.4rem 0.65rem; min-height: 36px; font-size: 0.8rem; }

.disclaimer-box {
  font-size: 0.78rem;
  color: var(--gray-700);
  background: var(--gray-100);
  border-left: 4px solid var(--gold);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Results table — CO SOS style */
.results-panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.registry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.registry-table th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
  font-weight: 600;
}
.registry-table th.sortable { cursor: pointer; user-select: none; padding-right: 1.35rem; position: relative; }
.registry-table th.sortable:hover { background: var(--navy-dark); }
.registry-table th.sortable:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.sort-indicator {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  opacity: 0.55;
}
.registry-table th.sortable[aria-sort="ascending"] .sort-indicator,
.registry-table th.sortable[aria-sort="descending"] .sort-indicator {
  opacity: 1;
  color: var(--gold);
}
.registry-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
}
.registry-table tbody tr:hover { background: var(--blue-light); }
.registry-table .doc-id {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 600;
}
.series-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: #fff;
}
.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.status-production { background: #c6f6d5; color: var(--green); }
.status-scaffold { background: #feebc8; color: #9c4221; }

/* Machine-readable view */
.machine-panel pre, .machine-panel code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
}
.machine-json {
  background: var(--gray-900);
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  max-height: 480px;
}
.file-links { list-style: none; padding: 0; margin: 0; }
.file-links li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-200);
}
.file-links .hash {
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--gray-500);
  word-break: break-all;
}

/* Document detail — Summary page (CO SOS record summary) */
.doc-summary {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.doc-summary-header {
  background: var(--navy);
  color: #fff;
  padding: 1rem 1.25rem;
}
.doc-summary-header h1 { font-size: 1.1rem; margin: 0 0 0.25rem; }
.doc-summary-header .meta { font-size: 0.8rem; opacity: 0.9; }
.doc-summary-body { padding: 0.75rem 0.9rem; }
.summary-grid {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
.summary-item label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  margin-bottom: 0.15rem;
}
.summary-item .value {
  font-size: 0.9rem;
  word-break: break-word;
}
.summary-item .value.mono {
  font-family: monospace;
  font-size: 0.78rem;
}

.doc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0 1rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}
.doc-tab {
  padding: 0.65rem 0.85rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.doc-tab[aria-selected="true"] {
  color: var(--navy);
  border-bottom-color: var(--gold);
  background: #fff;
}

/* Document body (human) */
.doc-body-panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}
.doc-body-panel .prose {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: none;
}
.doc-body-panel .prose h1, .doc-body-panel .prose h2, .doc-body-panel .prose h3 {
  font-family: var(--font);
  color: var(--navy);
}
.doc-body-panel .prose h1 { font-size: 1.35rem; border-bottom: 2px solid var(--gold); padding-bottom: 0.35rem; }
.doc-body-panel .prose h2 { font-size: 1.1rem; margin-top: 1.5rem; }
.doc-body-panel .prose table { width: 100%; border-collapse: collapse; font-family: var(--font); font-size: 0.85rem; }
.doc-body-panel .prose th, .doc-body-panel .prose td { border: 1px solid var(--gray-200); padding: 0.4rem 0.6rem; }

/* PDF viewer panel */
.pdf-panel {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}
.pdf-toolbar .title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  min-width: 120px;
}
.pdf-viewer-wrap {
  position: relative;
  background: #525659;
  min-height: 360px;
  height: min(70vh, 640px);
}
.pdf-viewer-wrap iframe,
.pdf-viewer-wrap #pdf-canvas-container {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.pdf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
}

.download-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Cards for mobile machine view */
.doc-cards { display: none; }
@media (max-width: 639px) {
  .table-wrap .registry-table { display: none; }
  .doc-cards { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; }
  .doc-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.85rem;
  }
  .doc-card .doc-id { font-family: monospace; font-weight: 700; color: var(--navy); }
}

/* Footer */
.site-footer {
  max-width: var(--layout-max);
  margin: 1.25rem auto 0.65rem;
  padding: 0.65rem var(--content-pad-x);
  font-size: 0.75rem;
  color: var(--gray-500);
  text-align: center;
  border-top: 1px solid var(--gray-200);
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--blue); }

.info-page h2 { color: var(--navy); font-size: 1.1rem; margin-top: 1.5rem; }
.info-page p, .info-page li { font-size: 0.9rem; color: var(--gray-700); }

@media (min-width: 768px) {
  :root {
    --content-pad-x: 0.75rem;
    --content-pad-y: 0.75rem;
  }
  .menu-toggle { display: none; }
  .side-nav {
    position: static;
    visibility: visible;
    opacity: 1;
    background: transparent;
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--gray-200);
  }
  .side-nav-panel {
    transform: none;
    box-shadow: none;
    width: 100%;
    height: auto;
    position: sticky;
    top: calc(var(--header-h) + 0.5rem);
    max-height: calc(100dvh - var(--header-h) - 1rem);
  }
  .app-shell { padding-left: 0; }
  .brand-title { font-size: 1.05rem; white-space: normal; }
  .mode-btn { font-size: 0.72rem; padding: 0.4rem 0.7rem; }
}

@media (min-width: 1024px) {
  :root {
    --content-pad-x: 1rem;
  }
}
