/*
 * Guide mode (inc/guide.php, assets/js/guide.js), 0.11.0: long pages and articles read as guides.
 * Loaded only on those views (body.agk-guided). Without JavaScript the rail and the bar stay hidden
 * and only the meta line and the narrower text column remain.
 */

.agk-guided {
  --agk-rail: 300px;
  --agk-rail-gap: 56px;
}

/* "10 chapters · 9 min read" under the H1, on the petrol hero (converted or theme hero). */
.agk-guide-meta.agk-guide-meta {
  margin: 18px 0 0;
  max-width: none;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.78);
}
.agk-hero .agk-guide-meta + p { margin-top: 22px; }

/* The check card is the rail's jump target: land it below the sticky header. */
.agk-guided #agk-check-cta { scroll-margin-top: 104px; }

/* ------------------------------------------------------------ the column ---- */

@media (min-width: 1200px) {
  /* Canvas pages: every band but the hero keeps its full-width colour; its content stops short of the rail. */
  .agk-guided.agk-guided .entry-content--canvas > .agk-sec:not(.agk-hero) {
    padding-inline-end: calc(var(--agk-band-x, 4rem) + var(--agk-rail) + var(--agk-rail-gap));
  }
  /* A centred line beside a rail reads as off-centre: the guide reads left-aligned, as a document. */
  .agk-guided .entry-content--canvas > .agk-sec:not(.agk-hero) :is(h2, h3, h4, p).has-text-align-center {
    text-align: left;
    margin-inline: 0;
  }
  /* Articles: the reading column steps left so the rail fits beside it. */
  .agk-guided .shell--reading {
    max-width: min(62rem, calc(100% - var(--agk-rail) - var(--agk-rail-gap)));
    margin-inline: max(0px, calc((100% - 62rem - var(--agk-rail) - var(--agk-rail-gap)) / 2)) auto;
  }
}

/* ------------------------------------------------------------------ rail ---- */

.agk-guide,
.agk-guidebar { display: none; }

@media (min-width: 1200px) {
  .agk-guide:not([hidden]) {
    position: fixed;
    z-index: 39; /* under the header (40) and its menus */
    top: calc(var(--agk-guide-top, 74px) + 24px);
    right: var(--agk-guide-right, 7vw);
    width: var(--agk-rail);
    max-height: calc(100vh - var(--agk-guide-top, 74px) - 48px);
    display: flex;
    flex-direction: column;
    background: var(--white);
    box-shadow: 0 0 0 1px var(--agk-line), 0 24px 48px -28px rgba(0, 20, 35, 0.45);
    font-size: 14px;
    line-height: 1.35;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0s linear 0.25s;
  }
  .agk-guide:not(.is-on) { opacity: 0; visibility: hidden; transform: translateY(8px); pointer-events: none; }
  .agk-guide.is-on { transition-delay: 0s; }
}

.agk-guide__head { padding: 18px 20px 10px; flex: none; }
.agk-guide .agk-guide__k {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brick-ink);
}
.agk-guide .agk-guide__prog {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.agk-guide__bar { flex: 1; height: 3px; background: var(--tint); }
.agk-guide__bar i,
.agk-guidebar__line i { display: block; width: 0; height: 100%; background: var(--navy); }

.agk-guide .agk-guide__list {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px;
  max-width: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
}
.agk-guide__list li { margin: 0; padding: 0; }
.agk-guide__list a {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 6px;
  padding: 7px 20px;
  color: var(--ink-soft);
  text-decoration: none;
}
.agk-guide__t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agk-guide__no { padding-top: 1px; font-size: 12.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.agk-guide__list a:hover { color: var(--navy); background: var(--surface); }
.agk-guide__list a:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.agk-guide__list .is-done a { color: var(--ink-muted); }
.agk-guide__list .is-on a { color: var(--navy); font-weight: 500; background: var(--surface); }
.agk-guide__list .is-on a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brick);
}

.agk-guide__cta { flex: none; padding: 16px 20px 18px; background: var(--surface); border-top: 1px solid var(--agk-line); }
.agk-guide .agk-guide__cta p { margin: 0 0 10px; max-width: none; font-size: 14px; color: var(--ink); }
.agk-guide__btn {
  display: block;
  padding: 12px 14px;
  text-align: center;
  font-weight: 500;
  font-size: 15px;
  color: var(--on-dark);
  background: var(--brick);
  text-decoration: none;
  transition: background-color 0.15s var(--ease);
}
.agk-guide__btn:hover { color: var(--on-dark); background: #9e2e20; }
.agk-guide__btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.agk-guide__alt { display: block; margin-top: 10px; text-align: center; font-size: 13px; color: var(--blue); }

/* ------------------------------------------------- bar (under 1200px) ---- */

@media (max-width: 1199px) {
  .agk-guidebar:not([hidden]) {
    display: block;
    position: fixed;
    z-index: 39;
    left: 0;
    right: 0;
    top: var(--agk-guide-top, 64px);
    background: var(--white);
    box-shadow: 0 1px 0 var(--agk-line), 0 10px 24px -18px rgba(0, 20, 35, 0.5);
    transition: opacity 0.2s var(--ease), visibility 0s linear 0.2s;
  }
  .agk-guidebar:not(.is-on) { opacity: 0; visibility: hidden; pointer-events: none; }
  .agk-guidebar.is-on { transition-delay: 0s; }
  /* A chapter jump lands below the header and the bar. */
  .agk-guided .entry-content [id] { scroll-margin-top: calc(var(--agk-guide-top, 64px) + 64px); }
}

.agk-guidebar__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}
.agk-guidebar__row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.agk-guidebar__n { flex: none; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.agk-guidebar__t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--navy); }
.agk-guidebar__chev {
  flex: none;
  width: 9px;
  height: 9px;
  margin: 0 4px 4px 0;
  border-right: 2px solid var(--navy);
  border-bottom: 2px solid var(--navy);
  transform: rotate(45deg);
}
.agk-guidebar__row[aria-expanded="true"] .agk-guidebar__chev { margin: 4px 4px 0 0; transform: rotate(-135deg); }
.agk-guidebar__line { display: block; height: 3px; background: var(--tint); }
.agk-guidebar__panel { max-height: min(70vh, calc(100vh - var(--agk-guide-top, 64px) - 60px)); overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--agk-line); }
.agk-guidebar__panel[hidden] { display: none; }
.agk-guidebar .agk-guide__list { list-style: none; margin: 0; padding: 6px 0; max-width: none; }
.agk-guidebar .agk-guide__list a { grid-template-columns: 28px minmax(0, 1fr); padding: 10px 16px; font-size: 15px; line-height: 1.35; }
.agk-guidebar .agk-guide__t { -webkit-line-clamp: 3; }
.agk-guidebar__cta { padding: 14px 16px 16px; background: var(--surface); border-top: 1px solid var(--agk-line); }

@media (prefers-reduced-motion: reduce) {
  .agk-guide:not([hidden]), .agk-guidebar:not([hidden]), .agk-guide__btn { transition: none; }
  .agk-guide:not(.is-on) { transform: none; }
}

@media print {
  .agk-guide, .agk-guidebar { display: none !important; }
}
