/* =============================================================================
   ALMA · Command guides  (apps/web/public/css/guide.css)
   /guide and /guide/:command (views/command-guide.ejs). Loaded after codex.css, whose entries, contents,
   cards, tables, limits and questions it reuses: this sheet fits the Codex onto the site shell (the site
   header is --nav-h tall, not the studio's top bar) and adds the guide-only parts: the breadcrumb, the
   relic, recipes, related commands, previous and next, and the guides index.
   Motion: the relic floats, cards lift and sweep on hover, entries rise in (codex.css .cx-wait/.cx-in).
   Transform and opacity only; reduced motion turns it off.
   ============================================================================= */

/* --- the Codex on the site shell ------------------------------------------------ */
.cg { padding-top: var(--s5); }
.cg .contents { top: calc(var(--nav-h) + var(--s4)); max-height: calc(100vh - var(--nav-h) - var(--s4) * 2); }
.cg .entry { scroll-margin-top: calc(var(--nav-h) + var(--s4)); }
.cg .codex-hero { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.cg .codex-hero .t-hero { font-size: clamp(34px, 4.2vw, 54px); }

.cg-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--fg-3); }
.cg-crumbs a { color: var(--fg-2); text-decoration: none; font: 600 12px/1 var(--f-label); letter-spacing: 0.16em; text-transform: uppercase; }
.cg-crumbs a:hover { color: var(--gold); }

.cg-hero-side { display: grid; gap: var(--s3); align-content: start; justify-items: stretch; min-width: 0; }
.cg-relic { justify-self: center; display: block; width: 180px; aspect-ratio: 1; animation: cg-float 7s ease-in-out infinite alternate; }
.cg-relic picture { display: contents; }
.cg-relic img, .cg-card-art img { width: 100%; height: 100%; object-fit: cover; -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent 100%); mask-image: radial-gradient(closest-side, #000 62%, transparent 100%); }
@keyframes cg-float { from { transform: translateY(-5px); } to { transform: translateY(6px); } }
.cg .at-glance strong { font-size: 20px; overflow-wrap: anywhere; }

/* --- section bodies from the guides module ----------------------------------------- */
.cg-body { display: grid; gap: var(--s3); min-width: 0; }
.cg-body > p { font-size: 15px; line-height: 1.65; color: var(--fg-2); max-width: 70ch; }
.cg-body > p.lead { font-size: 16.5px; }
.cg-body p b, .cg-body p strong { color: var(--fg); }
.cg-body ul:not([class]), .cg-body ol:not([class]) { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14.5px; color: var(--fg-2); max-width: 70ch; }
.cg-body ul:not([class]) li::marker { color: var(--gold); }
.cg-body h3 { font: 400 19px/1.25 var(--f-display); letter-spacing: 0.02em; margin-top: var(--s2); }
.cg-body h4 { font: 600 12px/1 var(--f-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.cg-body a { color: var(--fg); text-decoration-color: var(--gold); }
.cg-body .steps p { margin: 0; }
.cg-body .steps li:has(> p:only-child)::before { grid-row: span 1; }

/* --- recipes ----------------------------------------------------------------------- */
.cg-recipes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.cg-recipe { --cut: 10px; display: grid; gap: var(--s3); align-content: start; padding: var(--s4); background: var(--layer-1); box-shadow: inset 0 0 0 1px var(--line); clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); transition: background var(--t-quick), box-shadow var(--t-quick); }
.cg-recipe:hover { background: var(--layer-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.cg-recipe h3 { font: 400 18px/1.25 var(--f-display); letter-spacing: 0.02em; }
.cg-recipe .example-h h4 { margin: 0; font: 600 11.5px/1 var(--f-label); letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
.cg-recipe .example-h .btn { margin: -6px -8px -6px 0; }
.cg-req { font: 400 13.5px/1.6 var(--f-mono); color: var(--fg); overflow-wrap: anywhere; white-space: pre-wrap; }
.cg-why { font-size: 13.5px; color: var(--fg-2); }
.cg-why b { color: var(--fg); }
.cx-in .cg-recipes > * { animation: gm-in-up var(--t-panel) var(--ease-panel) backwards; animation-delay: calc(120ms + var(--cx-j, 0) * 40ms); }
.cx-in .cg-recipes > :nth-child(2) { --cx-j: 1; } .cx-in .cg-recipes > :nth-child(3) { --cx-j: 2; } .cx-in .cg-recipes > :nth-child(n+4) { --cx-j: 3; }

.cg-tips .gcard { grid-template-columns: 30px minmax(0, 1fr); column-gap: var(--s2); }
.cg-tips .gcard .n { grid-row: span 2; padding-top: 3px; }
.cg-tips .gcard h3:empty { display: none; }
.cg-limits li > .ico { color: var(--warn); }
.cg-limits h3:empty { display: none; }

/* --- every option (the command's own definitions) ------------------------------------ */
.cg-opts { display: grid; gap: var(--s2); }
.cg-opts-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font: 500 14px/1.4 var(--f-body); color: var(--fg-2); }
.cg-opts-h code { font-size: 14px; }
.cg-opts .gtable tbody th { white-space: nowrap; }
.cg-opts .gtable tbody th .badge { margin-left: 4px; vertical-align: 1px; }
.cg-opts .gtable td:last-child { white-space: nowrap; color: var(--fg-3); font-size: 13px; }
.cg-lim { display: block; white-space: normal; font-size: 12.5px; color: var(--fg-3); min-width: 14ch; }
.cg-opts .gtable td:last-child { white-space: normal; }

/* --- sources ------------------------------------------------------------------------ */
.cg-sources { display: grid; gap: var(--s2); padding-top: var(--s4); border-top: 1px solid var(--line); }
.cg-sources ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cg-sources a { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--fg-2); text-decoration-color: var(--line-2); overflow-wrap: anywhere; }
.cg-sources a:hover { color: var(--fg); text-decoration-color: var(--gold); }
.cg-sources .ico { width: 13px; height: 13px; flex: none; }

/* --- related, previous and next ---------------------------------------------------- */
.cg-related { display: grid; gap: var(--s2); }
.cg-related-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.cg-rel { --cut: 6px; display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 14px; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); text-decoration: none; font-size: 13.5px; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); transition: background var(--t-quick), box-shadow var(--t-quick); }
.cg-rel:hover { background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--line-2); }
.cg-rel:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }

.cg-pn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.cg-pn-a { --cut: 10px; display: grid; gap: 6px; align-content: start; padding: var(--s4); background: var(--layer-1); box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); text-decoration: none; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); transition: background var(--t-quick), box-shadow var(--t-quick), translate var(--t-panel) var(--ease-panel); }
.cg-pn-a.is-next { text-align: right; justify-items: end; }
.cg-pn-a .label { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-3); }
.cg-pn-a .label .ico { width: 15px; height: 15px; transition: transform var(--t-base) var(--ease-panel); }
.cg-pn-a b { font: 400 22px/1.15 var(--f-display); letter-spacing: 0.02em; color: var(--gold); }
.cg-pn-a small { font-size: 13px; color: var(--fg-2); }
.cg-pn-a:hover { background: var(--layer-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.cg-pn-a.is-next:hover .ico { transform: translateX(4px); }
.cg-pn-a.is-prev:hover .ico { transform: translateX(-4px); }
.cg-pn-a:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }

/* --- the guides index ---------------------------------------------------------------- */
.cg-index { display: grid; gap: var(--s5); padding-block: var(--s6) var(--s7); }
.cg-ihead { display: grid; gap: 10px; max-width: 760px; }
.cg-ihead h1 { font: 400 clamp(30px, 3.8vw, 46px)/1.08 var(--f-display); letter-spacing: 0.01em; text-wrap: balance; }
.cg-ilead { color: var(--fg-2); font-size: 16px; line-height: 1.6; max-width: 64ch; }
.cg-ilead a { color: var(--fg); text-decoration-color: var(--gold); }
.cg-group { display: grid; gap: var(--s3); }
.cg-group .section-title { margin-top: 0; }
.cg-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.cg-cards > li { display: grid; min-width: 0; }
.cg-card { --cut: 10px; position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) 18px; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4) var(--s3) var(--s3); background: var(--layer-1); box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); text-decoration: none; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); transition: background var(--t-quick), box-shadow var(--t-quick), translate var(--t-panel) var(--ease-panel); }
.cg-card:hover { background: var(--layer-2); box-shadow: inset 0 0 0 1px var(--line-2); translate: 0 -2px; }
.cg-card:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }
.cg-card-art { display: block; width: 64px; height: 64px; }
.cg-card-art picture { display: contents; }
.cg-card-art img { transition: transform var(--t-panel) var(--ease-panel); }
.cg-card:hover .cg-card-art img { transform: scale(1.1); }
.cg-card-copy { display: grid; gap: 4px; min-width: 0; }
.cg-card-copy b { font: 400 17px/1.25 var(--f-display); letter-spacing: 0.02em; }
.cg-card-lead { font-size: 13px; color: var(--fg-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-card-go { color: var(--fg-3); transition: color var(--t-quick), transform var(--t-base) var(--ease-panel); }
.cg-card-go .ico { width: 16px; height: 16px; }
.cg-card:hover .cg-card-go { color: var(--gold); transform: translateX(3px); }
.cg-iend { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s3) var(--s5); }
.cg-iend > div:first-child { display: grid; gap: 6px; }
.cg-wait { justify-self: start; }

/* --- the build guide's link block to the other guides (build-docs.ejs, studio shell) ------------ */
.cx-guides { --cut: var(--cut); display: grid; gap: var(--s4); padding: var(--s5); }
.cx-guides-h { display: grid; gap: 8px; }
.cx-guides-h p { font-size: 14px; max-width: 64ch; }
.cx-guides-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.cx-guides-list a { --cut: 6px; display: grid; gap: 3px; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); text-decoration: none; clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)); transition: background var(--t-quick), box-shadow var(--t-quick); }
.cx-guides-list a:hover { background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--line-2); }
.cx-guides-list a:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold); }
.cx-guides-list b { font: 500 13.5px/1.2 var(--f-mono); color: var(--gold); }
.cx-guides-list span { font-size: 12.5px; color: var(--fg-2); }
@media (max-width: 760px) { .cx-guides { padding: var(--s4); } .cx-guides-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ================================ narrower ================================ */
@media (max-width: 1080px) { .cg-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) { .cg .codex-hero { grid-template-columns: minmax(0, 1fr); } .cg-hero-side { grid-template-columns: 150px minmax(0, 1fr); align-items: center; } .cg-relic { width: 150px; } }
@media (max-width: 760px) {
  .cg { padding-top: var(--s3); }
  .cg .contents { top: var(--nav-h); max-height: none; }
  .cg .entry { scroll-margin-top: calc(var(--nav-h) + 48px + var(--s3)); }
  .cg .codex-hero .t-hero { font-size: clamp(30px, 8.6vw, 38px); }
  .cg-hero-side { grid-template-columns: minmax(0, 1fr); }
  .cg-relic { position: absolute; right: 10px; top: 10px; width: 84px; z-index: -1; opacity: 0.9; }
  .cg-crumbs, .cg .cx-hero-copy > .label { padding-right: 88px; }
  .cg-recipes, .cg-pn { grid-template-columns: minmax(0, 1fr); }
  .cg-recipe { padding: var(--s3); }
  .cg-pn-a.is-next { text-align: left; justify-items: start; }
  .cg-index { padding-block: var(--s4) var(--s6); gap: var(--s4); }
  .cg-cards { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .cg-card { grid-template-columns: 52px minmax(0, 1fr) 16px; padding: var(--s2) var(--s3) var(--s2) var(--s2); }
  .cg-card-art { width: 52px; height: 52px; }
  .cg-iend { grid-template-columns: minmax(0, 1fr); padding: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  .cg-relic { animation: none; }
  .cg-card, .cg-pn-a, .cg-card-art img, .cg-card-go, .cg-pn-a .label .ico { transition: none; }
  .cg-card:hover { translate: none; }
  .cg-card:hover .cg-card-art img { transform: none; }
  .cx-in .cg-recipes > * { animation: none !important; }
}
.gm-lite .cg-relic { animation: none; }
