/* The user guide's pages, written by scripts/build-guide.mjs (documents/design/user-guide.md §6.1).
   Layout C, ruled by the owner 2026-09-26: every guide page on the left, the page's sections and jobs
   on a right rail, and each job under How to do it as a card. Built on the site's tokens in styles.css. */

.gd-layout {
  display: grid;
  grid-template-columns: 14rem minmax(0, 46rem) 12rem;
  justify-content: space-between;
  gap: 2.6rem;
  padding: 1.4rem 0 3rem;
}

.gd-layout-index {
  grid-template-columns: minmax(0, 1fr);
}

/* The site's top bar (styles.css .topbar) stays at the top of the window, 4.2rem tall on a wide screen
   and 6.8rem on a phone, where it stacks. Whatever else sticks, or is jumped to, stops a gap below it. */
.gd-layout {
  --gd-below-bar: 5.2rem;
}

/* ── Every guide page, on the left ───────────────────────────────────────────────────────────────── */

.gd-toc {
  position: sticky;
  top: var(--gd-below-bar);
  align-self: start;
  max-height: calc(100vh - var(--gd-below-bar) - 1rem);
  overflow-y: auto;
  padding-right: 1rem;
  border-right: 1px solid var(--line);
  font-size: 0.92rem;
}

/* The summary is the phone's menu button. On a wide screen the list is always open, so it hides. */
.gd-toc > summary {
  display: none;
}

.gd-toc ul,
.gd-onpage ul,
.gd-related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.gd-toc li a {
  display: block;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  text-decoration: none;
}

.gd-toc li a:hover,
.gd-toc li a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--text);
}

.gd-toc-group {
  margin: 0.9rem 0 0.25rem;
  color: var(--text-faint);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── This page's sections and jobs, on the right ─────────────────────────────────────────────────── */

.gd-onpage {
  position: sticky;
  top: var(--gd-below-bar);
  align-self: start;
  margin-top: 2.2rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
  font-size: 0.88rem;
}

.gd-onpage p {
  margin: 0 0 0.4rem;
  color: var(--text-faint);
}

.gd-onpage a {
  display: block;
  padding: 0.18rem 0;
  color: var(--text-soft);
  text-decoration: none;
}

.gd-onpage a:hover {
  color: var(--text);
}

.gd-onpage-job a {
  padding-left: 0.8rem;
  color: var(--text-faint);
  font-size: 0.84rem;
}

/* ── The page ────────────────────────────────────────────────────────────────────────────────────── */

.gd-main a {
  color: var(--accent);
}

.gd-crumbs {
  color: var(--text-faint);
  font-size: 0.86rem;
}

.gd-crumbs a {
  color: var(--text-soft);
  text-decoration: none;
}

.gd-main h1 {
  max-width: none;
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(2rem, 3.4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.gd-main h2 {
  margin: 0 0 0.8rem;
  font-size: 1.55rem;
  line-height: 1.25;
}

.gd-main h3 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.12rem;
  line-height: 1.3;
}

.gd-main h2,
.gd-main h3 {
  scroll-margin-top: calc(var(--gd-below-bar) + 0.4rem);
}

/* A page heading and its # mark side by side. The mark sits beside the heading, not in it, so the
   heading's text is its words alone (build-guide.mjs). The box carries the heading's spacing. */
.gd-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.gd-heading > h2,
.gd-heading > h3 {
  margin: 0;
}

.gd-heading-h2 {
  margin: 0 0 0.8rem;
}

.gd-heading-h3 {
  margin: 1.6rem 0 0.6rem;
}

/* The mark is the heading's size, as it was when it sat inside the heading. */
.gd-heading-h2 > .gd-mark {
  font-size: 1.3rem;
}

.gd-heading-h3 > .gd-mark {
  font-size: 1.05rem;
}

.gd-main p,
.gd-main li {
  font-size: 1.02rem;
  line-height: 1.7;
}

.gd-main strong {
  color: #fff;
  font-weight: 600;
}

.gd-main code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--card-strong);
  font-size: 0.9em;
}

.gd-lede {
  color: var(--text-soft);
  font-size: 1.1rem;
}

.gd-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  margin: 0 0 1rem;
}

.gd-facts dt {
  color: var(--text-faint);
  font-size: 0.8rem;
}

.gd-facts dd {
  margin: 0;
}

/* One block (What it is, What it can do, How to do it) per section, with a rule above each. */
.gd-block {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

/* A job under How to do it is a card, so a support link lands on something that reads as one unit. */
.gd-block-how-to .gd-job {
  margin: 1.2rem 0 0;
  padding: 1rem 1.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
}

.gd-block-how-to .gd-job .gd-heading-h3 {
  margin-top: 0;
}

/* Steps: numbered discs on a thin line. */
.gd-main ol {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.gd-main ol > li {
  position: relative;
  padding: 0 0 0.9rem 2.6rem;
  counter-increment: step;
}

.gd-main ol > li::before {
  content: counter(step);
  position: absolute;
  top: 0.1rem;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid rgba(138, 180, 248, 0.35);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}

.gd-main ol > li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 2rem;
  bottom: 0.1rem;
  left: 0.83rem;
  width: 1px;
  background: var(--line);
}

/* A picture of the app (guide-pictures.md). One wider than the column is scaled down and links to itself. */
.gd-shot {
  margin: 0.4rem 0 1.2rem;
}

.gd-shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.gd-shot a {
  display: inline-block;
  cursor: zoom-in;
}

/* The # after a heading copies that heading's address (guide.js). */
.gd-mark {
  margin-left: 0.3rem;
  color: var(--text-faint) !important;
  text-decoration: none;
  opacity: 0;
}

.gd-heading:hover .gd-mark,
.gd-mark:focus-visible {
  opacity: 1;
}

.gd-mark.gd-copied::after {
  content: attr(data-copied);
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-weight: normal;
}

/* A summary box: the page's main points, set apart at the top of the page or of a section. */
.gd-summary {
  margin: 1.2rem 0 1.4rem;
  padding: 0.9rem 1.2rem 0.2rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.gd-summary > p,
.gd-summary > ul,
.gd-summary > ol {
  margin: 0 0 0.7rem;
}

.gd-summary ul {
  padding-left: 1.2rem;
}

/* A table. The box scrolls sideways when the table is wider than the column, so a phone never scrolls
   the whole page. */
.gd-table {
  margin: 0.4rem 0 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.gd-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.55;
}

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

.gd-table th {
  background: var(--card-strong);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.gd-table tbody tr:last-child td {
  border-bottom: 0;
}

/* A search key or a path stays on one line, so a narrow screen scrolls it instead of breaking it. */
.gd-table code {
  white-space: nowrap;
}

.gd-table .gd-center {
  text-align: center;
}

.gd-table .gd-right {
  text-align: right;
}

.gd-related {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.gd-related h2 {
  font-size: 1.1rem;
}

.gd-related ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.gd-related li a {
  display: block;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  text-decoration: none;
}

.gd-related li a:hover {
  border-color: var(--accent);
}

.gd-checked {
  margin-top: 2rem;
  color: var(--text-faint);
  font-size: 0.85rem !important;
}

/* ── The contents page: one section per group, one card per page ─────────────────────────────────── */

.gd-layout-index .gd-lede,
.gd-layout-index article > p {
  max-width: 44rem;
}

.gd-layout-index h2 {
  margin: 2rem 0 0.7rem;
  color: var(--text-faint);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gd-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gd-list li a {
  display: block;
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.gd-list li a:hover {
  border-color: var(--accent);
  background: var(--card);
}

.gd-list li span {
  display: block;
  margin-top: 0.3rem;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ── Japanese ────────────────────────────────────────────────────────────────────────────────────── */

html:lang(ja) h1,
html:lang(ja) h2,
html:lang(ja) h3,
html:lang(ja) .brand-copy strong {
  font-family:
    "Noto Sans JP", "Bahnschrift", "Aptos Display", "Segoe UI Variable Display", sans-serif;
}

/* styles.css sizes the home page's Japanese headings for its hero. The guide keeps its own scale. */
html:lang(ja) .gd-main h1 {
  font-size: clamp(1.8rem, 3vw, 2.3rem);
}

html:lang(ja) .gd-main h2 {
  font-size: 1.45rem;
  line-height: 1.3;
}

html:lang(ja) .gd-main h3 {
  line-height: 1.4;
}

html:lang(ja) .gd-layout-index h2 {
  font-size: 0.85rem;
}

/* ── Narrower screens ────────────────────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .gd-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .gd-onpage {
    display: none;
  }
}

@media (max-width: 760px) {
  .gd-layout {
    --gd-below-bar: 7.8rem;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  /* The list of every page becomes a menu above the page. guide.js closes it on load. */
  .gd-toc {
    position: static;
    max-height: none;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
  }

  .gd-toc > summary {
    display: flex;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    color: var(--text);
    cursor: pointer;
    list-style: none;
  }

  .gd-toc > summary::after {
    content: "▾";
    color: var(--text-faint);
  }

  .gd-toc[open] > summary::after {
    content: "▴";
  }

  .gd-toc > nav {
    padding: 0 0.6rem 0.8rem;
  }

  .gd-main h2 {
    font-size: 1.35rem;
  }

  .gd-summary {
    padding: 0.8rem 0.9rem 0.1rem;
  }

  .gd-table th,
  .gd-table td {
    padding: 0.45rem 0.7rem;
  }
}
