/* PCS guides and Map demo: Read pages in the Star Atlas world.
   Loads after atlas.css. The reading body is a chart-paper sheet between two slate rails. */

.guide {
  --paper-2: #d9e1cf;
  --paper-3: #cdd7c1;
  --step-h2: clamp(1.75rem, 1.15rem + 1.9vw, 2.75rem);
  --sheet-pad: clamp(22px, 4.6vw, 72px);
}
.guide .wrap { padding-inline: var(--margin); }

/* Intro: title, lead, one cropped star */
.guide-intro {
  position: relative; overflow: clip;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter);
  padding: clamp(48px, 8vh, 112px) var(--margin) clamp(64px, 10vh, 128px);
}
.guide-intro > :not(.guide-intro__star) { grid-column: 1 / span 8; position: relative; z-index: 1; }
.guide-intro h1 { font-size: var(--step-display); line-height: 1; letter-spacing: -0.035em; max-width: 12ch; }
.guide-intro .lead { font-size: var(--step-lead); line-height: 1.4; max-width: 40ch; margin-top: clamp(24px, 3.5vh, 40px); }
.guide-intro p:not(.lead) { max-width: 60ch; margin-top: 18px; }
.guide-intro .guide-intro__note, .guide-intro .small-note { color: var(--muted); font-size: var(--step-small); }
.guide-intro__star {
  position: absolute; z-index: 0; pointer-events: none;
  right: -7vw; top: 50%; translate: 0 -50%;
  height: 125%; width: auto; aspect-ratio: 200 / 260; max-width: none; fill: var(--cream);
}
.guide-intro .returning-user { color: var(--muted); }
.guide-intro .returning-user a, .guide-intro p a { color: var(--sage); text-underline-offset: 0.22em; text-decoration-thickness: 0.07em; }

/* Getting started: the four parts as one bar */
.start-jump { display: flex; gap: 6px; margin-top: 40px; max-width: 760px; }
.start-jump a {
  flex: 1 1 0; display: flex; align-items: flex-end; min-height: 76px; padding: 14px 16px;
  font-weight: 600; text-decoration: none; line-height: 1.2;
  transition: transform var(--t-press) var(--ease-out), filter var(--t-hover) ease;
}
.start-jump a:nth-child(1) { background: var(--ground-3); color: var(--ink); }
.start-jump a:nth-child(2) { background: var(--green); color: var(--ink); }
.start-jump a:nth-child(3) { background: var(--sage); color: var(--ground); }
.start-jump a:nth-child(4) { background: var(--sage-soft); color: var(--ground); }
.start-jump a:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .start-jump a:hover { filter: brightness(1.08); } }

/* Three columns: contents rail, the reading sheet, the guides rail */
.article-layout {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); align-items: start;
  padding: 0 var(--margin) var(--section);
}
.toc, .guide-nav {
  position: sticky; top: 24px; display: flex; flex-direction: column;
  max-height: calc(100vh - 48px); overflow: auto; padding: 4px 4px 4px 0; scrollbar-width: thin;
}
.toc { grid-column: 1 / span 2; }
.guide-nav { grid-column: 11 / span 2; }
.toc > p:first-child, .toc > strong:first-child, .guide-nav > p:first-child { font-weight: 600; margin-bottom: 10px; color: var(--ink); }
.toc a, .guide-nav a:not(.button) {
  position: relative; display: block; padding: 7px 0 7px 22px; line-height: 1.35;
  color: var(--muted); text-decoration: none; transition: color var(--t-hover) ease;
}
.toc a::before, .guide-nav a:not(.button)::before {
  content: ""; position: absolute; left: 2px; top: 0.72em; width: 11px; height: 14px; background: var(--cream);
  -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat;
  opacity: 0; scale: 0.6; transition: opacity var(--t-ui) ease, scale var(--t-ui) var(--ease-out);
}
.toc a.is-current, .guide-nav a[aria-current="page"] { color: var(--ink); }
.toc a.is-current::before { opacity: 1; scale: 1; }
.guide-nav a[aria-current="page"]::before { opacity: 1; scale: 1; background: var(--sage); }
.guide-nav { text-align: right; align-items: stretch; padding-right: 0; }
.guide-nav a:not(.button) { padding: 7px 0; }
.guide-nav a:not(.button)::before { position: relative; display: inline-block; left: auto; top: auto; margin-right: 9px; vertical-align: -1px; }
.guide-nav .button { margin-top: 18px; align-self: flex-end; text-align: center; }
@media (hover: hover) and (pointer: fine) { .toc a:hover, .guide-nav a:not(.button):hover { color: var(--ink); } }

.prose, .start-content {
  grid-column: 3 / span 8; min-width: 0;
  background: var(--paper); color: var(--paper-ink);
  padding: var(--sheet-pad);
}
.prose > * { max-width: 68ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  font-size: var(--step-h2); line-height: 1.08; letter-spacing: -0.03em; max-width: 24ch;
  margin-top: 2.4em; margin-bottom: 0.1em; scroll-margin-top: 24px;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: var(--step-lead); line-height: 1.25; letter-spacing: -0.01em; margin-top: 1.6em; }
.prose p, .prose li { line-height: 1.6; }
.prose strong, .prose b, .start-content strong { font-weight: 600; color: #0b1216; }
.prose a, .start-content a:not(.button) {
  color: var(--green); text-decoration: underline; text-decoration-thickness: 0.07em; text-underline-offset: 0.2em;
  transition: color var(--t-hover) ease;
}
@media (hover: hover) and (pointer: fine) { .prose a:hover, .start-content a:not(.button):hover { color: var(--ground); } }
.guide code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.86em;
  background: var(--paper-3); color: var(--paper-ink); padding: 0.1em 0.35em; overflow-wrap: anywhere;
}
.prose ul, .start-content ul { display: grid; gap: 0.5em; }
.prose ul > li, .start-content ul > li { position: relative; padding-left: 1.5em; }
.prose ul > li::before, .start-content ul > li::before {
  content: ""; position: absolute; left: 0.1em; top: 0.48em; width: 0.62em; height: 0.78em; background: var(--green);
  -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat;
}
.prose ol, .start-content ol { display: grid; gap: 0.6em; counter-reset: step; }
.prose ol > li, .start-content ol > li { position: relative; padding-left: 2.1em; counter-increment: step; }
.prose ol > li::before, .start-content ol > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums;
}
.prose figure, .start-content figure { max-width: none; margin-top: 2em; margin-bottom: 0.4em; }
.prose figure img, .start-content figure img { width: 100%; height: auto; background: var(--ground); }
.prose figure a, .start-content figure a { display: block; text-decoration: none; cursor: zoom-in; }
.prose figcaption, .start-content figcaption { margin-top: 10px; font-size: var(--step-small); color: var(--paper-muted); line-height: 1.45; }

/* Callouts: a slate block on the paper */
.callout { background: var(--ground); color: var(--ink); padding: 22px 26px; }
.callout p + p { margin-top: 0.8em; }
.prose .callout strong { color: var(--sage); }
.prose .callout a { color: var(--sage); }
@media (hover: hover) and (pointer: fine) { .prose .callout a:hover { color: var(--ink); } }

/* Disclosures on paper: a tone step, no lines */
:is(.prose, .start-content) details { background: var(--paper-2); }
:is(.prose, .start-content) details > summary {
  position: relative; cursor: pointer; list-style: none;
  padding: 16px 52px 16px 20px; font-weight: 600; line-height: 1.35;
  transition: background-color var(--t-hover) ease;
}
:is(.prose, .start-content) details > summary::-webkit-details-marker { display: none; }
:is(.prose, .start-content) details > summary::after {
  content: ""; position: absolute; right: 22px; top: 50%; width: 10px; height: 10px; margin-top: -7px;
  border: solid var(--green); border-width: 0 2px 2px 0; rotate: 45deg;
  transition: rotate var(--t-ui) var(--ease-out), translate var(--t-ui) var(--ease-out);
}
:is(.prose, .start-content) details[open] > summary::after { rotate: -135deg; translate: 0 4px; }
@media (hover: hover) and (pointer: fine) { :is(.prose, .start-content) details > summary:hover { background: var(--paper-3); } }
:is(.prose, .start-content) details > :not(summary) { padding-inline: 20px; }
:is(.prose, .start-content) details > :not(summary) + * { margin-top: 0.9em; }
:is(.prose, .start-content) details > :last-child { padding-bottom: 20px; }
:is(.prose, .start-content) details > summary + * { margin-top: 2px; }

/* Getting started */
.start-content > * { max-width: 1040px; }
.start-content > * + * { margin-top: clamp(72px, 9vw, 136px); }
.start-content h2 { font-size: var(--step-h2); line-height: 1.08; letter-spacing: -0.03em; max-width: 24ch; scroll-margin-top: 24px; }
.start-content h3 { font-size: var(--step-lead); line-height: 1.25; letter-spacing: -0.01em; }
.start-content p, .start-content li { line-height: 1.6; max-width: 68ch; }
.start-step-body > * + *, .start-next > * + *, .finish-section > * + *, .start-switching > * + * { margin-top: 1.1em; }
.start-step-body > h2 + *, .start-next > h2 + *, .finish-section > h2 + *, .start-switching > h2 + * { margin-top: 0.8em; }
.step-two-column { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); align-items: start; }
.step-two-column > div:first-child > * + * { margin-top: 1em; }
.setup-note { background: var(--ground); color: var(--ink); padding: 22px 24px; display: grid; gap: 10px; }
.start-content .setup-note strong { color: var(--ink); }
.start-content .setup-note a:not(.button) { color: var(--sage); }
.muted, .small-note { color: var(--paper-muted); }
.small-note { font-size: var(--step-small); }
.vault-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.vault-facts span { background: var(--ground); color: var(--ink); padding: 12px 16px; font-weight: 600; }
.setup-detail + .setup-detail { margin-top: 6px; }
.setup-accordions { display: grid; gap: 6px; }

.connection-tabs { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-top: 1.4em; }
.connection-tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0;
  background: none; border: 0; cursor: pointer; font-size: var(--step-lead); font-weight: 500; color: var(--paper-muted);
  transition: color var(--t-hover) ease;
}
.connection-tabs [role="tab"]::before {
  content: ""; width: 0.6em; height: 0.74em; background: var(--green);
  -webkit-mask: var(--star) center / contain no-repeat; mask: var(--star) center / contain no-repeat;
  opacity: 0; scale: 0.6; transition: opacity var(--t-ui) ease, scale var(--t-ui) var(--ease-out);
}
.connection-tabs [role="tab"][aria-selected="true"] { color: var(--paper-ink); }
.connection-tabs [role="tab"][aria-selected="true"]::before { opacity: 1; scale: 1; }
@media (hover: hover) and (pointer: fine) { .connection-tabs [role="tab"]:hover { color: var(--paper-ink); } }
.connection-chooser [role="tabpanel"] { margin-top: 14px; background: var(--paper-2); padding: 24px clamp(20px, 3vw, 32px); display: grid; gap: 16px; }
.connection-chooser [role="tabpanel"][hidden] { display: none; }
.connection-chooser [role="tabpanel"] > div > * + * { margin-top: 0.8em; }
.route-label { display: block; font-weight: 600; color: var(--green); font-size: var(--step-small); }
.route-note { font-size: var(--step-small); color: var(--paper-muted); }

.permission-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.permission-cards > div { background: var(--ground); color: var(--ink); padding: 20px 22px 24px; }
.permission-cards span { display: block; font-size: var(--step-lead); font-weight: 600; color: var(--sage); margin-bottom: 6px; }
.first-prompt { background: var(--sage); color: var(--ground); padding: 24px clamp(20px, 3vw, 32px); }
.first-prompt span { display: block; font-weight: 600; font-size: var(--step-small); margin-bottom: 6px; }
.first-prompt p { font-size: var(--step-lead); line-height: 1.35; font-weight: 500; }
#introduction > * + * { margin-top: 0.9em; }

.finish-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.finish-grid > div { background: var(--green); color: var(--ink); padding: 20px 22px 24px; }
.finish-grid b { display: block; font-size: var(--step-lead); font-weight: 600; margin-bottom: 6px; color: var(--ink); }

.start-support { display: grid; gap: 20px; background: var(--ground); color: var(--ink); padding: clamp(24px, 3.5vw, 48px); }
.start-support > div:first-child > * + * { margin-top: 0.8em; }
.start-support > div:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.start-content .start-support a.text-link { color: var(--sage); }
.start-support code { background: var(--ground-3); color: var(--ink); }

/* Map demo */
.map-page-section { padding: 0 var(--margin) clamp(64px, 8vw, 120px); }
.guide .pcs-map { font-family: "Albert Sans", "Segoe UI", system-ui, sans-serif; border: 0; background: var(--ground-2); }
.guide .pcs-map-canvas, .guide .pcs-map-stage { background-image: none; }
.map-caption { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px 32px; margin-top: 18px; color: var(--muted); font-size: var(--step-small); }
.map-caption p:first-child { color: var(--ink); font-weight: 600; }
.no-script { background: var(--ground-2); padding: 20px 24px; }
.no-script a { color: var(--sage); }
.feature-list > li > strong { display: block; font-size: var(--step-lead); line-height: 1.3; }
.feature-list > li > p + p { margin-top: 0.4em; }
.prose blockquote { margin: 0; padding: 14px 18px; background: var(--paper); }
.record-meta { font-size: var(--step-small); color: var(--paper-muted); }
.sample-records { display: grid; gap: 6px; }
.sample-records details > summary { font-weight: 500; }
.guide-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: none; }
.prose .guide-links a {
  display: grid; align-content: space-between; gap: 18px; min-height: 150px; padding: 20px 22px;
  background: var(--ground); color: var(--ink); text-decoration: none;
  transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.prose .guide-links a:active { transform: scale(0.98); }
.guide-links h3 { margin: 0; font-size: var(--step-lead); color: var(--sage); }
.guide-links p { color: var(--muted); font-size: var(--step-small); }
@media (hover: hover) and (pointer: fine) { .prose .guide-links a:hover { background: var(--ground-3); color: var(--ink); } }

/* Motion: the intro arrives once; headings and figures rise as they are reached */
@media (prefers-reduced-motion: no-preference) {
  .js .guide-intro h1 { animation: guide-rise 760ms var(--ease-expo) 80ms both; }
  .js .guide-intro h1 ~ :not(.guide-intro__star) { animation: guide-rise 560ms var(--ease-out) 320ms both; }
  .js .guide-intro__star { animation: guide-star 1200ms var(--ease-expo) 40ms both; }
}
@keyframes guide-rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes guide-star { from { opacity: 0; scale: 0.92; } }

/* Tablet: rails fold into the flow */
@media (max-width: 1080px) {
  .guide-intro > :not(.guide-intro__star) { grid-column: 1 / span 10; }
  .guide-intro__star { right: -16vw; height: 105%; }
  .toc, .guide-nav {
    grid-column: 1 / -1; position: static; max-height: none; overflow: visible;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gutter);
  }
  .toc { padding: 0 0 28px; }
  .guide-nav { padding: 40px 0 0; }
  .toc > p:first-child, .toc > strong:first-child, .guide-nav > p:first-child { grid-column: 1 / -1; }
  .guide-nav { text-align: left; }
  .guide-nav a:not(.button) { padding: 7px 0; }
  .guide-nav .button { grid-column: 1 / -1; justify-self: start; }
  .prose, .start-content { grid-column: 1 / -1; }
  .step-two-column { grid-template-columns: 1fr; }
  .map-caption { grid-template-columns: 1fr; }
}

/* Phone */
@media (max-width: 640px) {
  .guide-intro { padding-bottom: 200px; }
  .guide-intro > :not(.guide-intro__star) { grid-column: 1 / -1; }
  .guide-intro h1 { font-size: clamp(2.125rem, 9.4vw, 2.75rem); }
  .guide-intro__star { top: auto; bottom: -40px; right: -14vw; translate: none; height: 230px; }
  .start-jump { flex-wrap: wrap; }
  .start-jump a { flex: 1 1 calc(50% - 3px); min-height: 60px; }
  .toc, .guide-nav { grid-template-columns: 1fr; }
  .guide { --sheet-pad: var(--margin); --step-h2: 1.375rem; }
  .article-layout { padding-inline: 0; }
  .toc, .guide-nav { padding-inline: var(--margin); }
  .map-page-section { padding-inline: 0; }
  .guide .pcs-map { padding: 16px var(--margin); border-radius: 0; }
  .permission-cards, .finish-grid, .guide-links { grid-template-columns: 1fr; }
  :is(.prose, .start-content) details > summary { padding: 14px 46px 14px 16px; }
  :is(.prose, .start-content) details > :not(summary) { padding-inline: 16px; }
  .callout { padding: 18px; }
}
