/* American Samoa Code Annotated browser — builds on the site palette in styles.css */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.code-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: start;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: 1.5rem;
  padding: 0 1.25rem;
}

/* Sidebar / table of contents */
.code-sidebar {
  position: sticky;
  top: 64px; /* below sticky header */
  align-self: start;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e3e8ef;
  padding-right: 0.75rem;
}

.sidebar-head {
  padding: 1rem 0 0.75rem;
}

#search {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
}

#search:focus {
  outline: 2px solid var(--gold);
  border-color: var(--gold);
}

.toc {
  overflow-y: auto;
  padding-bottom: 2rem;
  font-size: 0.9rem;
}

.toc-chapter > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.5rem 0.4rem;
  font-weight: 600;
  color: var(--navy);
  border-radius: 4px;
}

.toc-chapter > summary::-webkit-details-marker { display: none; }
.toc-chapter > summary:hover { background: var(--bg-alt); }

.toc-chapter .ch-num {
  color: var(--muted);
  font-weight: 500;
  margin-right: 0.4rem;
}

.toc-sections {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0 0 0 0.5rem;
}

.toc-sections a {
  display: block;
  padding: 0.3rem 0.4rem;
  color: var(--text);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
}

.toc-sections a:hover { background: var(--bg-alt); }
.toc-sections a.active {
  border-left-color: var(--gold);
  background: var(--bg-alt);
  font-weight: 600;
}

.toc-sections .sec-num { color: var(--muted); margin-right: 0.35rem; }

/* Main reading column */
.code-main {
  padding: 1.5rem 0 4rem;
  min-width: 0;
}

.title-head {
  border-bottom: 2px solid var(--gold);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
}
.title-head .eyebrow {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}
.title-head h1 {
  margin: 0.25rem 0 0;
  font-size: 1.9rem;
  color: var(--navy);
}

.chapter-block { margin-bottom: 2.5rem; }
.chapter-block > h2 {
  font-size: 1.3rem;
  color: var(--navy);
  border-bottom: 1px solid #e3e8ef;
  padding-bottom: 0.4rem;
  margin: 0 0 1.25rem;
}
.chapter-block > h2 .ch-num { color: var(--muted); font-weight: 500; }

.section-block {
  margin-bottom: 1.75rem;
  scroll-margin-top: 72px;
}

.section-block h3 {
  font-size: 1.05rem;
  color: var(--navy);
  margin: 0 0 0.5rem;
}
.section-block h3 .sec-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--gold);
  margin-right: 0.5rem;
}
.section-block h3 a.anchor {
  opacity: 0;
  text-decoration: none;
  color: var(--muted);
  margin-left: 0.4rem;
  font-size: 0.85em;
}
.section-block h3:hover a.anchor { opacity: 1; }

.section-body p { margin: 0 0 0.65rem; }

.annotations { margin-top: 0.5rem; }

.annotation {
  border: 1px solid #e3e8ef;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  background: var(--bg-alt);
}
.annotation > summary {
  cursor: pointer;
  padding: 0.45rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
  list-style: none;
}
.annotation > summary::-webkit-details-marker { display: none; }
.annotation > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--gold);
  transition: transform 0.15s ease;
}
.annotation[open] > summary::before { transform: rotate(90deg); }

.annotation .ann-body {
  padding: 0 0.75rem 0.65rem 1.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.annotation .ann-body p { margin: 0 0 0.5rem; }
.annotation .ann-body a.pl-link {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 2px;
}
.annotation .ann-body a.pl-link:hover { color: var(--gold); }

.no-results { color: var(--muted); font-style: italic; padding: 1rem 0; }
mark { background: #fff1c2; padding: 0 1px; }

/* Back link in reader sidebar */
.back-link {
  display: inline-block;
  margin-bottom: 0.6rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.back-link:hover { color: var(--navy); }

.toc-flat { padding-left: 0.25rem; }
.doc-entry h3 { font-size: 1.1rem; }

/* ---------- Landing page ---------- */
.code-landing { padding: 2.5rem 1.25rem 4rem; }
.code-landing > h1 {
  font-size: 2rem;
  color: var(--navy);
  margin: 0 0 0.5rem;
}
.landing-lede {
  color: var(--muted);
  max-width: 640px;
  margin: 0 0 1.5rem;
}

.global-search { position: relative; max-width: 640px; margin-bottom: 2.5rem; }
#gsearch {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
}
#gsearch:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

.global-results:not(:empty) {
  margin-top: 0.5rem;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.gresult {
  display: block;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid #eef2f7;
}
.gresult:last-child { border-bottom: none; }
.gresult:hover { background: var(--bg-alt); }
.gr-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--gold);
  margin-right: 0.5rem;
  font-size: 0.9rem;
}
.gr-head { font-weight: 600; }
.gr-title { display: block; font-size: 0.8rem; color: var(--muted); }

.title-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.title-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.title-card:hover {
  border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(11, 37, 69, 0.08);
  transform: translateY(-1px);
}
.tc-num {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold);
  font-weight: 700;
}
.tc-name { font-weight: 600; color: var(--navy); line-height: 1.3; }
.tc-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

.search-note { font-size: 0.8rem; color: var(--muted); padding: 0.4rem 0.85rem; }

/* Breadcrumbs */
.crumbs {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.crumbs a { color: var(--navy); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { margin: 0 0.35rem; color: #aab4c0; }

/* Chapter cards on the title landing */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}
.chapter-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  text-decoration: none;
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.chapter-card:hover {
  border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(11, 37, 69, 0.08);
  transform: translateY(-1px);
}
.cc-num {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold);
  font-weight: 700;
}
.cc-name { font-weight: 600; color: var(--navy); line-height: 1.3; }
.cc-meta { font-size: 0.78rem; color: var(--muted); }

/* Sidebar chapter link (whole summary acts as a link to the chapter) */
.toc-ch-link {
  color: var(--navy);
  text-decoration: none;
  display: inline;
}
.toc-ch-link:hover { color: var(--gold); }

/* Prev / next chapter navigation */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e3e8ef;
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  max-width: 48%;
  padding: 0.65rem 0.9rem;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s ease;
}
.chapter-nav a:hover { border-color: var(--gold); }
.chapter-nav .cn-next { text-align: right; align-items: flex-end; }
.cn-dir { font-size: 0.75rem; color: var(--gold); font-weight: 700; }
.cn-label { font-size: 0.85rem; color: var(--navy); font-weight: 600; }

/* Responsive: collapse sidebar above content on narrow screens */
@media (max-width: 800px) {
  .code-layout { grid-template-columns: 1fr; }
  .code-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #e3e8ef;
    padding-right: 0;
  }
  .toc { max-height: 40vh; }
}
