/* =========================================================================
   /resources: guide library
   Markup is built by renderGuideLibrary() in backend/server.js from
   guides.json; behaviour (current topic, phone/iPad topic menu) is in
   js/resources.js. Bump ?v= in resources.html when editing.

   Layout by width:
     >= 992px   topic menu down the left (sticky), cards 3 per row
     700-991px  sticky "Topic" bar under the nav, cards 3 per row (iPads)
     576-699px  sticky "Topic" bar, cards 2 per row
     < 576px    sticky "Topic" bar, cards become compact rows
   Side gutters match the nav's padding (50px / 18px) so edges line up.
   ========================================================================= */

.res-page {
  --res-navy: #004C80;
  --res-ink: #111111;
  --res-text: #5c5c5c;
  --res-muted: #8a8f96;
  --res-line: #e3e6ea;
  --res-line-soft: #eef0f2;
  --res-gutter: 50px;
  --res-side-w: 220px;
  --res-gap: 48px;
  /* --res-nav-h and --res-jump-h are measured by js/resources.js */
  --res-top: calc(var(--res-nav-h, 53px) + 28px);
}

/* main.css puts overflow-x: hidden on html AND body. On body that makes it a
   scroll container, which stops position: sticky from working. clip hides the
   same overflow without that side effect (older browsers keep hidden and just
   lose the sticky menu). */
body.res-page {
  overflow-x: clip;
}

main.res-main {
  padding: 0;
}

.res-wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 44px var(--res-gutter) 80px;
}

/* ---- Header ------------------------------------------------------------- */

.res-header {
  margin-bottom: 44px;
}

.res-eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--res-navy);
}

.res-header h1 {
  margin: 0 0 14px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--res-ink);
}

.res-lede {
  margin: 0;
  font-size: 17px;
  line-height: 1.65;
  color: #4a4f55;
}

/* ---- Library: topic menu + topics --------------------------------------- */

.res-library {
  display: grid;
  grid-template-columns: var(--res-side-w) minmax(0, 1fr);
  gap: var(--res-gap);
  align-items: start;
}

.res-side {
  position: sticky;
  top: var(--res-top);
}

.res-toc-label {
  margin: 2px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--res-navy);
}

.res-toc ul,
.res-jump-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.res-toc a,
.res-jump-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--res-line-soft);
  font-size: 15px;
  line-height: 1.35;
  color: #4a4f55;
  text-decoration: none;
  transition: color 0.15s ease;
}

.res-toc li:first-child a {
  border-top: 1px solid var(--res-line-soft);
}

.res-toc a:hover,
.res-jump-list a:hover {
  color: var(--res-navy);
  text-decoration: none;
}

.res-toc a:focus-visible,
.res-jump-list a:focus-visible,
.res-jump-summary:focus-visible {
  outline: 2px solid var(--res-navy);
  outline-offset: 2px;
  border-radius: 4px;
}

/* The current topic is bold. The hidden bold copy of the label reserves its
   width so going bold never re-wraps the line. */
.res-toc-name {
  display: inline-flex;
  flex-direction: column;
}

.res-toc-name::after {
  content: attr(data-label);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.res-toc-count {
  flex-shrink: 0;
  font-size: 13px;
  color: #a3a8ae;
  font-variant-numeric: tabular-nums;
}

.res-toc a[aria-current="true"],
.res-jump-list a[aria-current="true"] {
  color: var(--res-ink);
  font-weight: 700;
}

.res-toc a[aria-current="true"] .res-toc-count,
.res-jump-list a[aria-current="true"] .res-toc-count {
  color: var(--res-navy);
}

/* Phone / iPad topic bar: hidden while the left menu is showing */
.res-jump {
  display: none;
}

/* ---- Topics ------------------------------------------------------------- */

.res-topic {
  scroll-margin-top: var(--res-top);
}

/* Topics after the first have a rule and padding above the heading; the jump
   offset takes that off so every heading lands at the same spot (level with
   the "Topics" label on desktop, just under the topic bar on phones). */
.res-topic + .res-topic {
  --res-topic-pad: 48px;
  margin-top: 56px;
  padding-top: var(--res-topic-pad);
  border-top: 1px solid var(--res-line-soft);
  scroll-margin-top: calc(var(--res-top) - var(--res-topic-pad) - 1px);
}

.res-topic-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  margin-bottom: 8px;
}

.res-topic-title {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--res-ink);
}

.res-topic-count {
  font-size: 14px;
  color: var(--res-muted);
}

.res-topic-intro {
  margin: 0 0 24px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--res-text);
}

/* ---- Guide cards -------------------------------------------------------- */

.res-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.res-grid > li {
  display: flex;
}

.res-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.2s ease;
}

.res-card:hover,
.res-card:focus-visible {
  color: inherit;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.13);
}

.res-card:focus-visible {
  outline: 2px solid var(--res-navy);
  outline-offset: 3px;
}

.res-card-media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #eef2f6;
}

.res-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Guides without a photo: navy "blueprint paper" cover with a line icon */
.res-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: var(--res-navy);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: center center;
}

.res-cover svg {
  width: 46px;
  height: 46px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.res-card-body {
  flex: 1;
  padding: 16px 16px 20px;
  text-align: center;
}

.res-card-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--res-ink);
  transition: color 0.15s ease;
}

.res-card:hover .res-card-title {
  color: var(--res-navy);
}

.res-card-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--res-text);
}

/* ---- Closing line ------------------------------------------------------- */

/* Text and button sit together on the left. Owner, 2026-11-14: pushed to the
   right, the button sat directly under the nav's Contact Us button. */
.res-help {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 16px 24px;
  margin: 64px 0 0 calc(var(--res-side-w) + var(--res-gap));
  padding-top: 32px;
  border-top: 1px solid var(--res-line);
}

.res-help p {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
  color: var(--res-ink);
}

.res-help-btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 8px;
  background: var(--res-navy);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.res-help-btn:hover,
.res-help-btn:focus-visible {
  background: #003a61;
  color: #ffffff;
  text-decoration: none;
}

/* ---- Small laptops / iPad landscape (992-1199px) ------------------------- */

@media (max-width: 1199.98px) {
  .res-page {
    --res-side-w: 196px;
    --res-gap: 36px;
  }

  .res-grid {
    gap: 20px;
  }

  .res-card-title {
    font-size: 16px;
  }

  .res-card-text {
    font-size: 13.5px;
  }
}

/* ---- iPad portrait and phones (< 992px): topic bar instead of the menu --- */

@media (max-width: 991.98px) {
  .res-page {
    /* 18px matches the nav's side padding below 992px (css/nav.css), so the
       page edge lines up with the logo; 50px above does the same */
    --res-gutter: 18px;
    --res-top: calc(var(--res-nav-h, 60px) + var(--res-jump-h, 60px) + 16px);
  }

  .res-wrap {
    padding-top: 36px;
  }

  .res-header {
    margin-bottom: 28px;
  }

  .res-library {
    display: block;
  }

  .res-side {
    display: none;
  }

  .res-help {
    margin-left: 0;
  }

  .res-jump {
    display: block;
    position: sticky;
    top: var(--res-nav-h, 60px);
    z-index: 20;
    margin: 0 calc(-1 * var(--res-gutter)) 20px;
    padding: 8px var(--res-gutter);
    /* Before it sticks it's just the topic box; the white bar, rule and
       shadow appear only once it's stuck under the nav (is-stuck, set by
       js/resources.js). Same size either way, so nothing jumps. */
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .res-jump.is-stuck {
    background: rgba(255, 255, 255, 0.97);
    border-bottom-color: var(--res-line);
    box-shadow: 0 8px 16px -12px rgba(0, 0, 0, 0.22);
  }

  .res-jump-menu {
    position: relative;
  }

  .res-jump-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid #d5d9de;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  .res-jump-summary::-webkit-details-marker {
    display: none;
  }

  .res-jump-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--res-muted);
  }

  .res-jump-current {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 500;
    color: var(--res-ink);
  }

  .res-jump-chevron {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--res-navy);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
  }

  .res-jump-menu[open] .res-jump-chevron {
    transform: rotate(180deg);
  }

  .res-jump-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    padding: 4px 14px;
    background: #ffffff;
    border: 1px solid #d5d9de;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  }

  .res-jump-list li:last-child a {
    border-bottom: 0;
  }

  .res-jump-list a {
    padding: 12px 0;
  }

  .res-topic + .res-topic {
    --res-topic-pad: 40px;
    margin-top: 44px;
  }
}

/* Large phones / small tablets: 2 per row (iPads keep 3: the card photos are
   only 360-640px wide and look soft when stretched to half an iPad) */
@media (max-width: 699.98px) {
  .res-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---- Phones (< 768px) --------------------------------------------------- */

@media (max-width: 767.98px) {
  .res-wrap {
    padding-top: 28px;
    padding-bottom: 56px;
  }

  .res-eyebrow {
    font-size: 12px;
  }

  .res-header h1 {
    font-size: 30px;
  }

  .res-lede {
    font-size: 16px;
    line-height: 1.6;
  }

  .res-topic-title {
    font-size: 22px;
  }

  .res-topic-intro {
    font-size: 15px;
    margin-bottom: 18px;
  }

  .res-grid {
    gap: 16px;
  }

  .res-help {
    margin-top: 48px;
    padding-top: 28px;
  }

  .res-help p {
    font-size: 16px;
  }
}

/* ---- Small phones (< 576px): cards become compact rows ------------------ */

@media (max-width: 575.98px) {
  .res-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Photo and title share a top line, so rows with 1- and 2-line titles
     still line up */
  .res-card {
    flex-direction: row;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0;
    overflow: visible;
    border-radius: 0;
    border-bottom: 1px solid var(--res-line-soft);
    box-shadow: none;
  }

  .res-card:hover,
  .res-card:focus-visible {
    box-shadow: none;
  }

  .res-grid > li:first-child .res-card {
    padding-top: 2px;
  }

  .res-grid > li:last-child .res-card {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .res-card-media {
    flex: 0 0 min(104px, 28vw);
    width: min(104px, 28vw);
    aspect-ratio: 4 / 3;
    border-radius: 8px;
  }

  .res-cover {
    background-size: 14px 14px;
  }

  .res-cover svg {
    width: 30px;
    height: 30px;
  }

  .res-card-body {
    min-width: 0;
    padding: 0;
    text-align: left;
  }

  .res-card-title {
    margin: -2px 0 4px;
    font-size: 16px;
  }

  .res-card-text {
    font-size: 13.5px;
    line-height: 1.45;
  }

  .res-help {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .res-card,
  .res-card-title,
  .res-toc a,
  .res-jump-chevron {
    transition: none;
  }
}

/* ---- EN|ES switch (2026-11-19): top-right of the header, out of the flow so
   the header doesn't move; /resources and /es/guias are a language pair. ---- */
.res-header {
  position: relative;
}
.res-header > .bp-lang-switch {
  position: absolute;
  top: -6px;
  right: 0;
  margin: 0;
}
