/*
 * Sapwood Grove — page styles (v1.0.0)
 *
 * Loads ALONGSIDE polaris-home.css (which provides the shared header chrome:
 * .pp-header, .pp-panel, .pp-topbar, logo, search, footer, and the header
 * scroll/compact behavior). This file adds only the Sapwood body: the
 * three-column grid, the Table of Contents, the action buttons, the fixed
 * scroll-logo, and the back-to-top arrow, plus the mobile stack.
 *
 * Design tokens (--navy, --forest, etc.) are defined in polaris-home.css :root.
 */

/* ---- Body wrapper (outer-column textured background shows here) ---------- */
.sw-lower {
  background-repeat: repeat;
  background-size: auto;
  background-color: #c9c6cf;          /* fallback under the texture */
  min-height: 60vh;
}

/* ---- Three-column grid --------------------------------------------------- */
.sw-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 200px;
  gap: 0;
  align-items: start;
  max-width: 1240px;
  margin: 0 auto;
}

/* Outer columns are transparent so the .sw-lower texture shows through.
   The center column is solid white. */
.sw-side {
  background: transparent;
  padding: 28px 20px 40px;
}
.sw-side-left  { padding-left: 28px; }
.sw-side-right { padding-right: 28px; }

/* ---- LEFT sidebar: sub-logo + TOC --------------------------------------- */
.sw-sidelogo {
  text-align: center;
  margin-bottom: 18px;
}
.sw-sidelogo img {
  max-width: 150px;
  height: auto;
  display: inline-block;
}

.sw-toc {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(31,45,74,0.12);
  border-radius: 10px;
  padding: 14px 14px 16px;
  position: sticky;
  top: 24px;                 /* TOC follows as you read on desktop */
}
.sw-toc-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy, #1f2d4a);
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(31,45,74,0.15);
  text-align: center;
  letter-spacing: 0.02em;
}
/* The mobile "Contents" toggle is hidden on desktop. */
.sw-toc-toggle { display: none; }

/* TOC groups (one per tag/category) */
.sw-toc-group { margin-bottom: 12px; }
.sw-toc-group:last-child { margin-bottom: 0; }
.sw-toc-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--forest, #2f5d4f);
  margin: 0 0 5px;
}
.sw-toc-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sw-toc-group li { margin: 0 0 3px; }
.sw-toc-link {
  display: block;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--navy, #1f2d4a);
  text-decoration: none;
  padding: 3px 6px;
  border-radius: 5px;
  transition: background 150ms ease, color 150ms ease;
}
.sw-toc-link:hover { background: rgba(47,93,79,0.12); }
.sw-toc-link.is-active {
  background: var(--forest, #2f5d4f);
  color: #fff;
}

/* ---- CENTER: white content column --------------------------------------- */
.sw-main {
  background: #ffffff;
  min-height: 70vh;
  box-shadow: 0 0 0 1px rgba(31,45,74,0.06);
}
.sw-content {
  padding: 36px 40px 48px;
  color: #2a2f37;
  font-size: 1rem;
  line-height: 1.7;
}
.sw-content h2 {
  font-size: 1.5rem;
  color: var(--navy, #1f2d4a);
  margin: 1.6em 0 0.5em;
}
/* Entry headings */
.sw-content h3 {
  font-size: 1.2rem;
  color: var(--forest-deep, #1f3f35);
  margin: 1.8em 0 0.4em;
  padding-top: 6px;
  scroll-margin-top: 24px;   /* so jump-links don't tuck under anything */
}
.sw-content h3:first-child { margin-top: 0; }
.sw-content h4 {
  font-size: 1.02rem;
  color: var(--navy, #1f2d4a);
  margin: 1.3em 0 0.3em;
}
.sw-content p { margin: 0 0 1em; }
.sw-content a { color: var(--forest, #2f5d4f); }
.sw-content ul, .sw-content ol { margin: 0 0 1em 1.4em; }
.sw-content img { max-width: 100%; height: auto; border-radius: 6px; }

/* ---- Tag pills (rendered by JS from the [tags: ...] marker) -------------- */
.sw-entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0.4em 0 1.6em;
}
.sw-tag-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--forest-deep, #1f3f35);
  background: rgba(47,93,79,0.12);
  border: 1px solid rgba(47,93,79,0.25);
  border-radius: 999px;
  padding: 2px 10px;
  text-decoration: none;
  transition: background 150ms ease;
}
a.sw-tag-pill:hover { background: rgba(47,93,79,0.22); }

/* ---- RIGHT: action buttons ---------------------------------------------- */
.sw-actions {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sw-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 64px;
  padding: 12px 10px;
  background: #ffffff;
  border: 1px solid rgba(31,45,74,0.45);
  border-radius: 8px;
  color: var(--navy, #1f2d4a);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, transform 120ms ease;
}
.sw-action-btn:hover {
  background: var(--navy, #1f2d4a);
  color: #fff;
  transform: translateY(-1px);
}
.sw-action-tip {
  background: var(--forest, #2f5d4f);
  border-color: var(--forest-deep, #1f3f35);
  color: #fff;
}
.sw-action-tip:hover {
  background: var(--forest-deep, #1f3f35);
  color: #fff;
}

/* ---- Fixed scroll-logo (appears after header scrolls away) --------------- */
.sw-scroll-logo {
  position: fixed;
  top: 22px;
  left: 26px;                /* ample padding from the corner */
  z-index: 1200;
  display: block;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
  pointer-events: none;
}
.sw-scroll-logo img {
  display: block;
  width: 84px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.sw-scroll-logo.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* ---- Back-to-top arrow (sticky, bottom-right) --------------------------- */
.sw-backtotop {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--navy, #1f2d4a);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease, background 160ms ease;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
.sw-backtotop svg { width: 22px; height: 22px; }
.sw-backtotop:hover { background: var(--forest, #2f5d4f); }
.sw-backtotop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* =========================================================================
   MOBILE (max-width: 820px): single column stack.
   Order: header (handled by polaris-home.css) -> sub-logo -> collapsible
   Contents -> white content -> action buttons. The outer texture shows
   behind the TOC and buttons; content stays white.
   ========================================================================= */
@media (max-width: 820px) {
  .sw-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .sw-side, .sw-side-left, .sw-side-right {
    padding: 18px 16px;
  }

  /* Sub-logo smaller, centered above the Contents menu */
  .sw-sidelogo img { max-width: 120px; }

  /* TOC becomes a collapsible "Contents" menu, not a sticky sidebar */
  .sw-toc {
    position: static;
    top: auto;
    padding: 0;
    background: rgba(255,255,255,0.7);
    overflow: hidden;
  }
  .sw-toc-title { display: none; }              /* replaced by the toggle */
  .sw-toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: var(--navy, #1f2d4a);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
  }
  .sw-toc-caret {
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #fff;
    transition: transform 200ms ease;
  }
  .sw-toc-toggle[aria-expanded="true"] .sw-toc-caret { transform: rotate(180deg); }

  /* Collapsed by default on mobile; JS toggles .is-open */
  .sw-toc-list {
    max-height: 0;
    opacity: 0;
    transition: max-height 280ms ease, opacity 200ms ease, padding 200ms ease;
    padding: 0 14px;
  }
  .sw-toc-list.is-open {
    max-height: 1200px;
    opacity: 1;
    padding: 12px 14px 14px;
  }

  /* Content full width */
  .sw-content { padding: 24px 18px 32px; }

  /* Action buttons: row of pills at the bottom (2x2 grid) */
  .sw-actions {
    position: static;
    top: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }
  .sw-action-btn {
    flex: 1 1 calc(50% - 10px);
    min-height: 54px;
    font-size: 0.85rem;
  }

  /* On mobile the desktop TOC list is shown/hidden via JS, so the list
     starts collapsed. On desktop (above) it's always visible. */
}

/* On DESKTOP the list is always open regardless of the mobile toggle state. */
@media (min-width: 821px) {
  .sw-toc-list { max-height: none !important; opacity: 1 !important; }
}
