/* Shared chrome + article styling for the online guide and legal pages. */

:root {
  --ink: #38332b;
  --ink-soft: #6e6558;
  --paper: #fafaf7;
  --wash: #e3cfd4;
  --wash-deep: #e3cfd4;
  --line: #e3cfd4;
  --accent: #8a5a2e;
  --off-black: #1b1c20;
  --off-black-soft: #2b2c33;
  --book-blue: #2a5480;
  --deep: #4a3e2e;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L",
    Georgia, serif;
  /* Dream Orphans is reserved for the site title only. */
  --font-title: "Dream Orphans", Georgia, serif;
}

/* Keep anchor jumps clear of the sticky top bar. */
html {
  scroll-padding-top: 4.5rem;
}

body.site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--wash);
  color: #322e26;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.125rem;
  line-height: 1.65;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.4rem;
  background: var(--off-black-soft);
  color: #f6f5f2;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.topbar .brand {
  font-family: var(--font-title);
  font-weight: bold;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: #f6f5f2;
  text-decoration: none;
  white-space: nowrap;
}

.topnav {
  display: flex;
  gap: 1.4rem;
}

.topnav a {
  color: #d6d9e0;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.topnav a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: 0;
  padding: 0.5rem;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: #f6f5f2;
}

/* ---------- Guide layout: sidebar + chapter ---------- */

.guide-layout {
  display: flex;
  flex: 1;
  width: 100%;
  align-items: flex-start;
  gap: 1.5%;
  padding: 1.5rem 1.5% 2.5rem;
}

.sidebar {
  position: sticky;
  top: 4.2rem;
  flex: 0 0 18%;
  min-width: 215px;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 0.9rem;
  font-size: 0.92rem;
}

.chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-list > li {
  margin: 0.15rem 0;
}

.chapter-list a {
  display: block;
  padding: 0.28rem 0.55rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 6px;
}

.chapter-list a:hover {
  background: var(--wash-deep);
  color: var(--ink);
}

.chapter-list > li.active > a {
  color: var(--off-black);
  font-weight: bold;
}

.chapter-list ul {
  list-style: none;
  margin: 0.15rem 0 0.3rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--line);
}

.chapter-list ul a {
  font-size: 0.87rem;
  padding: 0.2rem 0.5rem;
}

.chapter {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
  margin-bottom: 1rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

/* ---------- Article ---------- */

.chapter article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2.2rem clamp(1.2rem, 4vw, 3rem) 2.6rem;
}

.chapter h1,
.page-main h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--off-black);
  font-size: 2.1rem;
  letter-spacing: 0.01em;
  margin-bottom: 1.2rem;
}

.chapter h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--off-black);
  font-size: 1.5rem;
  margin: 2rem 0 0.7rem;
}

.chapter h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: #46474e;
  font-size: 1.18rem;
  margin: 1.5rem 0 0.4rem;
}

/* Copy-link button beside section headers */

.heading-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-left: 0.45rem;
  padding: 0.15rem;
  vertical-align: middle;
  color: var(--line);
  border-radius: 4px;
  transition: color 0.15s ease;
}

h1:hover .heading-link,
h2:hover .heading-link,
h3:hover .heading-link,
.heading-link:focus-visible {
  color: var(--accent);
}

.chapter h1 .heading-link svg {
  width: 18px;
  height: 18px;
}

.heading-link:hover {
  background: var(--wash-deep);
}

.heading-link.copied::after {
  content: "Link copied";
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  background: var(--off-black);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: normal;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  border-radius: 5px;
  white-space: nowrap;
}

.chapter p,
.page-main p {
  margin: 0.8rem 0;
}

.chapter ul,
.chapter ol {
  margin: 0.8rem 0 0.8rem 1.6rem;
}

.chapter li {
  margin: 0.3rem 0;
}

.chapter a,
.page-main a,
.tos-note a {
  color: var(--accent);
}

.chapter sup {
  font-size: 0.72em;
}

.doc-figure {
  margin: 1.4rem auto;
  text-align: center;
}

.doc-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* Side-by-side rows from the book: plain text next to one colored callout */

.callout-row {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  margin: 1.2rem 0;
}

.callout-row > * {
  flex: 1;
  min-width: 0;
}

.callout {
  background: var(--book-blue);
  color: #f3f8ff;
  border-radius: 8px;
  padding: 1rem 1.2rem;
  box-shadow: 0 3px 10px rgba(7, 55, 99, 0.25);
}

.callout a {
  color: #cfe3f7;
}

.callout p:first-child,
.callout-side p:first-child { margin-top: 0; }
.callout p:last-child,
.callout-side p:last-child { margin-bottom: 0; }

.profile-box {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 1.2rem 0;
}

.profile-box .profile-text {
  flex: 1;
}

.profile-box .doc-figure {
  flex: 0 0 min(240px, 40%);
  margin: 0;
}

/* Data tables */

.table-wrap {
  overflow-x: auto;
  margin: 1.2rem 0;
}

.doc-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.doc-table th,
.doc-table td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  background: var(--deep);
  color: #f8f4ec;
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  font-weight: 600;
}

.doc-table tr:nth-child(even) td {
  background: var(--wash);
}

.doc-table p { margin: 0.25rem 0; }

/* ---------- Prev / next pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.4rem;
}

.pager-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 48%;
  padding: 0.65rem 1.1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
}

.pager-link:hover {
  background: var(--wash-deep);
}

.pager-link.disabled {
  visibility: hidden;
}

.pager-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Simple pages (contents, terms, privacy) ---------- */

.page-main {
  flex: 1;
  width: 100%;
  padding: 2rem 4% 2.5rem;
}

.page-main h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--off-black);
  font-size: 1.45rem;
  margin: 1.8rem 0 0.6rem;
}

.page-main ul {
  margin: 0.8rem 0 0.8rem 1.6rem;
}

.contents-intro {
  color: var(--ink-soft);
}

.contents-list {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
}

.contents-list > li {
  margin: 0.35rem 0;
}

.contents-list > li > a {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
}

.contents-list > li > a:hover {
  text-decoration: underline;
}

.contents-list ul {
  list-style: none;
  margin: 0.2rem 0 0.6rem 1rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--line);
}

.contents-list ul a {
  color: var(--ink-soft);
  font-size: 0.95rem;
  text-decoration: none;
}

.contents-list ul a:hover {
  text-decoration: underline;
}

/* ---------- Terms-acceptance note + footer ---------- */

.tos-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-soft);
  padding: 0.6rem 1rem;
}

.site-footer {
  background: var(--off-black);
  color: #c9ccd4;
  text-align: center;
  padding: 1.3rem 1rem 1.1rem;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
}

.footer-nav a {
  color: #f6f5f2;
  text-decoration: none;
}

.footer-nav a:hover {
  text-decoration: underline;
}

.site-footer .copyright {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.site-footer .built-by {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #8e929c;
}

.site-footer .built-by a {
  color: #b8bcc6;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .guide-layout {
    flex-direction: column;
    /* In a column, align-items governs width; stretch so the long
       nowrap pager titles can't force the chapter wider than the screen. */
    align-items: stretch;
  }

  .pager-link {
    min-width: 0;
  }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    width: 100%;
    flex: none;
  }

  body.sidebar-open .sidebar {
    display: block;
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .callout-row,
  .profile-box {
    flex-direction: column;
  }

  .profile-box .doc-figure {
    flex: none;
    align-self: center;
  }

  /* Collapse the top menu into a hamburger */
  .nav-toggle {
    display: inline-flex;
  }

  .topnav {
    display: none;
  }

  body.nav-open .topnav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.5rem 1.4rem 1.1rem;
    background: var(--off-black-soft);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.3);
  }

  body.nav-open .topnav a {
    font-size: 1.05rem;
  }

  /* Smaller headers on phones */
  .topbar .brand {
    font-size: 1.05rem;
  }

  .chapter h1,
  .page-main h1 {
    font-size: 1.5rem;
  }

  .chapter h2 {
    font-size: 1.25rem;
  }

  .chapter h3 {
    font-size: 1.08rem;
  }

  .page-main h2 {
    font-size: 1.2rem;
  }

  .chapter h1 .heading-link svg {
    width: 14px;
    height: 14px;
  }

  .chapter article {
    padding: 1.5rem 1.1rem 1.9rem;
  }
}
