/*
 * Guides: a two-pane reader. A dense list rail on the left, the selected
 * document framed on the right, so a guide is read inside the portal rather
 * than in a tab of its own.
 *
 * Sits on top of admin-split.css and borrows its tokens (--ares-navy,
 * --ares-line, --ares-muted). Below 980px the app sidebar already collapses to
 * a top bar, so the reader steps aside and the rail becomes the whole page —
 * guides open in a new tab from there.
 */

/* This page shows and hides panes through the `hidden` property, and several of
   them (the loader and the placeholder) are absolutely positioned overlays with
   their own `display` rule. An author `display` beats the UA's `[hidden]`
   regardless of specificity, so without this the overlays stay stacked over a
   guide that has already loaded and the reader looks stuck on its spinner. */
.guides-page [hidden] { display: none !important; }

/* ---- full-height shell -------------------------------------------------- */
/* The reader owns the scrolling, so the page itself must not scroll. */
.guides-page .split-main { overflow: hidden; }

.guides-page .split-content {
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.guides-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  /* Deliberately not transitioned: browsers do not interpolate between two
     track lists, and a half-applied transition leaves the collapsed rail stuck
     at its open width. The rail fades instead. */
  grid-template-columns: 264px minmax(0, 1fr);
}
.guides-layout.rail-hidden { grid-template-columns: 0 minmax(0, 1fr); }
.guides-layout.rail-hidden .guides-rail { opacity: 0; pointer-events: none; }

/* ---- rail --------------------------------------------------------------- */
.guides-rail {
  min-width: 0;
  border-right: 1px solid var(--ares-line);
  background: var(--ares-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .12s ease;
}

.guides-rail-head {
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--ares-line);
}

.guides-rail-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.guides-rail-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ares-navy);
}
.guides-rail-count {
  font-size: 12px;
  color: var(--ares-muted);
}

/* ---- search ---- */
.guides-search { position: relative; }
.guides-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--ares-muted);
  pointer-events: none;
}
.guides-search input {
  width: 100%;
  padding: 8px 12px 8px 30px;
  border: 1px solid var(--ares-line);
  border-radius: 7px;
  background: var(--ares-bg);
  color: var(--ares-text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.guides-search input:focus {
  outline: none;
  background: var(--ares-card);
  border-color: var(--ares-blue);
  box-shadow: 0 0 0 3px rgba(8, 174, 234, .14);
}
.guides-search input::-webkit-search-cancel-button { cursor: pointer; }

/* ---- list ---- */
.guides-rail-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 8px 20px;
}

.guides-group + .guides-group { margin-top: 14px; }

.guides-group-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px 4px;
}
.guides-group-head h2 {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ares-muted);
  margin: 0;
}
.guides-group-count { font-size: 11px; color: var(--ares-muted); opacity: .65; }

/* One row per guide: title, then a quiet meta line. */
.guide-row {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font-family: inherit;
  color: inherit;
  padding: 8px 30px 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.guide-row:hover { background: var(--ares-bg); }
.guide-row:focus-visible { outline: 2px solid var(--ares-blue); outline-offset: -2px; }

.guide-row-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ares-text);
}
.guide-row-meta {
  display: block;
  font-size: 11.5px;
  color: var(--ares-muted);
  margin-top: 2px;
}

.guide-row.active { background: var(--ares-navy); }
.guide-row.active .guide-row-title,
.guide-row.active .guide-row-meta { color: #fff; }
.guide-row.active .guide-row-meta { opacity: .72; }

/* Per-row escape hatch to a real tab, without leaving the list. */
.guide-row-tab {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: var(--ares-muted);
  text-decoration: none;
  font-size: 12px;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease;
}
.guide-row:hover .guide-row-tab,
.guide-row:focus-within .guide-row-tab { opacity: 1; }
.guide-row-tab:hover { background: rgba(8, 174, 234, .14); color: var(--ares-navy); }
.guide-row.active .guide-row-tab { color: rgba(255, 255, 255, .75); opacity: 1; }
.guide-row.active .guide-row-tab:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.guide-row mark {
  background: #fef3c7;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.guide-row.active mark { background: rgba(255, 226, 130, .32); color: #fff; }

/* ---- reader ------------------------------------------------------------- */
.guides-reader {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--ares-bg);
}

.guides-reader-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 46px;
  flex: 0 0 46px;
  background: var(--ares-card);
  border-bottom: 1px solid var(--ares-line);
}

.guides-reader-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
}
.guides-reader-heading strong {
  font-size: 14px;
  color: var(--ares-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guides-reader-heading span {
  font-size: 12px;
  color: var(--ares-muted);
  white-space: nowrap;
}

.guides-icon-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ares-line);
  border-radius: 7px;
  background: var(--ares-card);
  color: var(--ares-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.guides-icon-btn:hover {
  color: var(--ares-navy);
  border-color: #b9c8dd;
  background: var(--ares-bg);
}
.guides-icon-btn:focus-visible { outline: 2px solid var(--ares-blue); outline-offset: 1px; }

.guides-reader-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.guides-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--ares-bg);
}

.guides-reader-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--ares-muted);
  font-size: 14px;
}

/* ---- loading + empty ---------------------------------------------------- */
.guides-reader-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ares-bg);
  z-index: 2;
}
.guides-reader-loading span {
  width: 22px;
  height: 22px;
  border: 2px solid var(--ares-line);
  border-top-color: var(--ares-blue);
  border-radius: 50%;
  animation: guides-spin .7s linear infinite;
}
@keyframes guides-spin { to { transform: rotate(360deg); } }

.guides-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--ares-muted);
  font-size: 13px;
  line-height: 1.6;
}
.guides-empty strong {
  display: block;
  color: var(--ares-text);
  font-size: 14px;
  margin-bottom: 6px;
}
.guides-empty code {
  background: var(--ares-bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.guides-skeleton { padding: 8px; display: grid; gap: 8px; }
.guides-skeleton-row {
  height: 40px;
  border-radius: 7px;
  background: linear-gradient(100deg, #eef1f6 30%, #f7f9fc 50%, #eef1f6 70%);
  background-size: 220% 100%;
  animation: guides-shimmer 1.3s linear infinite;
}
@keyframes guides-shimmer {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .guides-skeleton-row, .guides-reader-loading span { animation: none; }
  .guides-rail, .guide-row { transition: none; }
}

/* ---- narrow: no room for two panes ------------------------------------- */
@media (max-width: 980px) {
  .guides-page .split-main { overflow: auto; }
  .guides-page .split-content { display: block; }

  .guides-layout,
  .guides-layout.rail-hidden { display: block; }

  .guides-rail {
    border-right: 0;
    background: none;
    opacity: 1;
    pointer-events: auto;
  }
  .guides-rail-head { border-bottom: 0; padding: 14px 12px 10px; }
  .guides-rail-title h1 { font-size: 22px; }

  .guides-rail-list { overflow: visible; padding: 0 8px 24px; }

  /* Cards read better than dense rows once the list is the whole page. */
  .guide-row {
    background: var(--ares-card);
    border: 1px solid var(--ares-line);
    border-radius: 9px;
    padding: 12px 38px 12px 14px;
    margin-bottom: 8px;
  }
  .guide-row-title { font-size: 14.5px; }
  .guide-row-tab { opacity: 1; right: 8px; }
  .guide-row.active { background: var(--ares-card); border-color: var(--ares-navy); }
  .guide-row.active .guide-row-title { color: var(--ares-text); }
  .guide-row.active .guide-row-meta { color: var(--ares-muted); opacity: 1; }
  .guide-row.active .guide-row-tab { color: var(--ares-muted); }

  .guides-reader { display: none; }
}
