/* ═══════════════════════════════════════════════════
   TOOLS + MARKET SIZING DATA PAGES, AND THE SITE CART
   Loaded after site.css on every page (the nav Cart button and drawer are site-wide).
   Uses site.css tokens only — no new colors or fonts.
════════════════════════════════════════════════════ */

/* ── NAV CART BUTTON ── */
.cart-toggle {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans);
  font-size: .75rem; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink);
  padding: 0;
  transition: color .2s;
}
.cart-toggle:hover { color: var(--green); }

/* ── CART DRAWER (native <dialog>) ── */
.cart-drawer {
  margin: 0 0 0 auto;
  height: 100dvh; max-height: 100dvh;
  width: min(420px, 100vw); max-width: 100vw;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--cream);
  color: var(--ink);
  padding: 2rem 1.75rem;
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}
.cart-drawer[open] { display: flex; }
.cart-drawer::backdrop { background: rgba(var(--ink-rgb), .45); }
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.75rem; }
.cart-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.75rem; line-height: 1; color: var(--ink);
  width: 2.75rem; height: 2.75rem;
}
.cart-close:hover { color: var(--green); }
.cart-added {
  padding: .9rem 1rem;
  background: var(--oat);
  border-left: 3px solid var(--green);
  font-size: .875rem; line-height: 1.5;
}
.cart-added span { color: var(--green); font-weight: 600; margin-right: .25rem; }
.cart-added strong { font-weight: 600; }
.cart-continue { text-align: center; }
.cart-items { list-style: none; display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.cart-item {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.cart-item-name { font-weight: 500; line-height: 1.4; }
.cart-item-meta { font-size: .8rem; color: var(--muted); }
.cart-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; white-space: nowrap; }
.cart-remove {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans); font-size: .75rem;
  color: var(--green); text-decoration: underline;
  padding: .6rem 0 .6rem .75rem;  /* comfortable tap target on phones */
  min-height: 44px;
}
.cart-empty { color: var(--muted); }
.cart-foot { display: flex; flex-direction: column; gap: 1rem; }
.cart-subtotal { display: flex; justify-content: space-between; font-weight: 500; }
.cart-checkout { text-align: center; }
.cart-note { font-size: .75rem; color: var(--muted); line-height: 1.6; }

/* ── Section wrapper, eyebrow, and heading type: the shared recipes in site.css (.res-section joins them) ── */
.res-section h2 { line-height: 1.1; margin-bottom: 1rem; }

.page-meta { margin-top: 1.5rem; }  /* micro-label recipe lives in site.css */
.page-header .page-intro { max-width: 640px; }

/* breadcrumb */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 2rem; font-size: .75rem; }
.breadcrumb li + li::before { content: '/'; margin-right: .5rem; color: var(--muted); }
.breadcrumb a { color: var(--green); }
.breadcrumb [aria-current] { color: var(--muted); }

/* disabled "coming soon" buttons */
.btn[aria-disabled="true"],
.btn:disabled {
  border-color: var(--border); color: var(--muted); cursor: not-allowed; background: transparent;
}
.btn.is-in-cart { background: var(--ink); color: var(--cream); }

/* ── TOOLS PAGE ── */
/* featured tool: a full-width band directly under the page header */
.tool-featured {
  background: var(--oat);
  display: flex; flex-direction: column; gap: 1rem;
}
.tool-featured .tool-summary { max-width: 720px; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.tool-card {
  border: 1px solid var(--border);
  padding: 2rem;
  display: flex; flex-direction: column; gap: 1rem;
}
/* tool cards with a preview image: the whole card opens the tool's page */
.tool-card-visual { position: relative; padding: 0; gap: 0; transition: border-color .2s, transform .2s, box-shadow .2s; }
.tool-card-visual:hover,
.tool-card-visual:focus-within { border-color: var(--green); transform: translateY(-3px); box-shadow: 0 10px 24px rgba(var(--ink-rgb), .08); }
.tool-card-media { aspect-ratio: 4 / 3; overflow: hidden; background: var(--oat); }
.tool-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.tool-card-visual:hover .tool-card-media img { transform: scale(1.04); }
.tool-card-body { padding: 1.75rem 2rem 2rem; display: flex; flex-direction: column; gap: 1rem; flex: 1; }
.tool-card-link { color: var(--ink); text-decoration: none; }
.tool-card-link::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.tool-card-link:focus-visible { outline: none; }
@supports not selector(:has(a)) {
  .tool-card-link:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
}
.tool-card-visual:has(.tool-card-link:focus-visible) { outline: 2px solid var(--green); outline-offset: 3px; }
.tool-card-visual:hover .tool-card-link { color: var(--green); }
.tool-card-visual .tool-offer .btn { position: relative; z-index: 2; }
.tool-card-more {
  font-size: .75rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--green);
}

/* tool page: preview image beside the description */
.tool-page-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 4rem; align-items: start; }
.tool-page-media img { width: 100%; height: auto; display: block; border: 1px solid var(--border); }

.tool-card h3,
.tool-featured h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.6rem; line-height: 1.2; }
.tool-featured h2 { font-size: 2.1rem; }
.tool-details summary {
  cursor: pointer;
  font-size: .75rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--green);
}
.tool-details ul { margin-top: .75rem; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .4rem; }
.tool-offers { list-style: none; display: flex; flex-direction: column; gap: .75rem; margin-top: auto; }
.tool-offer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.tool-offer-info { font-size: .8rem; color: var(--muted); }
.tool-offer-info strong { color: var(--ink); font-weight: 600; }
.tool-offer .btn { padding: .7rem 1.5rem; min-height: 44px; }
.tool-offer-note { flex-basis: 100%; font-size: .8rem; color: var(--muted); line-height: 1.6; }
.tool-more-link { margin-top: 2rem; }
.tool-page-buy { margin-top: 2rem; }
.tool-page-buy .tool-offer { justify-content: flex-start; gap: 1.5rem; }
.tool-page-buy .tool-offer-info { font-size: .95rem; }
.page-header.tool-page-header .purchase-terms { margin-top: 2rem; max-width: 560px; font-size: .75rem; line-height: 1.7; }
.purchase-terms { margin-top: 3rem; font-size: .75rem; color: var(--muted); max-width: 720px; line-height: 1.7; }

/* ── MARKET SIZING: layout + section index (sidebar on desktop, jump menu on mobile) ── */
.msd-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}
.msd-index {
  position: sticky; top: calc(var(--nav-h) + 18px);
  max-height: calc(100vh - var(--nav-h) - 38px);   /* 18px gap under the nav + 20px at the bottom */
  display: flex; flex-direction: column;
}
.msd-index-box { display: flex; flex-direction: column; min-height: 0; }
.msd-index-box > summary { display: none; }
.msd-index-list { overflow-y: auto; min-height: 0; max-height: calc(100vh - var(--nav-h) - 38px); padding-right: .5rem; }
/* type comes from .eyebrow; the extra class beats `.res-section .eyebrow` (margin-bottom 1.5rem) */
.msd-index .msd-index-group { margin: 0 0 .5rem; }
.msd-index ul { list-style: none; margin-bottom: 1.75rem; }
.msd-index a {
  display: flex; justify-content: space-between; align-items: baseline; gap: .75rem;
  padding: .3rem 0 .3rem .75rem;
  border-left: 2px solid transparent;
  font-size: .85rem; line-height: 1.35;
  color: var(--ink); text-decoration: none;
}
.msd-index a:hover { color: var(--green); }
.msd-index a.is-active,
.msd-index a.is-current { color: var(--green); border-left-color: var(--green); font-weight: 500; }
.msd-index-count { font-size: .75rem; color: var(--muted); font-weight: 400; }

/* hub: the page header is the only header; sources start right under it */
.msd-hub-header { padding-bottom: 2.5rem; border-bottom: none; }
.res-section.msd-sources { padding-top: 0; }
.msd-hub-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; }
.msd-hub-actions .page-meta { margin: 0; max-width: none; }

/* linked section titles (sections with their own page) */
.msd-section-title { color: var(--ink); text-decoration: none; }
.msd-section-title .msd-arrow { color: var(--green); font-size: .8em; margin-left: .4rem; display: inline-block; transition: transform .2s; }
.msd-section-title:hover { color: var(--green); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.msd-section-title:hover .msd-arrow { transform: translateX(3px); }
.msd-section-blurb { font-size: .9rem; color: var(--muted); line-height: 1.6; max-width: 640px; margin: .25rem 0 1rem; }

/* ── MARKET SIZING: finder ── */
.msd-finder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 1rem 1.5rem;
  align-items: end;
  margin-bottom: 1rem;
}
.msd-field-search { grid-column: 1 / -1; }
.msd-field { display: flex; flex-direction: column; gap: .45rem; }
.msd-field label {
  font-size: .7rem; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
}
.msd-field input,
.msd-field select {
  font-family: var(--font-sans); font-size: 1rem; font-weight: 300;
  color: var(--ink);
  background: transparent;
  border: none; border-bottom: 1px solid var(--muted);
  padding: .6rem 0;
  border-radius: 0;
  width: 100%;
}
.msd-field input:focus,
.msd-field select:focus { border-bottom-color: var(--green); }
.msd-reset {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-sans);
  font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--green); text-decoration: underline;
  padding: .7rem .5rem;
  min-height: 44px;
}
.msd-status { font-size: .85rem; color: var(--muted); margin-bottom: 2.5rem; }

/* ── MARKET SIZING: source tables ── */
.msd-section + .msd-section { margin-top: 3.5rem; }
.msd-section h3 { font-family: var(--font-serif); font-weight: 400; font-size: 1.5rem; margin-bottom: .25rem; }
.msd-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.msd-table caption { text-align: left; }
.msd-table th {
  text-align: left;
  font-size: .7rem; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted);
  padding: .75rem 1rem .75rem 0;
  border-bottom: 1px solid var(--ink);
  vertical-align: bottom;
}
.msd-table td {
  padding: 1rem 1rem 1rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: .9rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.msd-table td:nth-child(2) { color: var(--muted); }
.msd-table td:nth-child(3),
.msd-table td:nth-child(4) { white-space: nowrap; font-size: .8rem; }
.msd-table a { color: var(--ink); font-weight: 500; text-decoration-color: var(--green); text-underline-offset: 3px; }
.msd-table a:hover { color: var(--green); }
.msd-table .ext { color: var(--green); margin-left: .2rem; }
.msd-table th:nth-child(1) { width: 28%; }
.msd-table th:nth-child(3) { width: 11%; }
.msd-table th:nth-child(4) { width: 13%; }

/* ── MARKET SIZING: closing band ── */
.msd-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}
.msd-band h2 { font-family: var(--font-serif); font-weight: 400; font-size: clamp(1.75rem, 2.5vw, 2.25rem); line-height: 1.15; }
.msd-band p { margin-bottom: 1.5rem; }
.msd-band-btns { margin-top: 0; }
.msd-related-title { font-family: var(--font-sans); font-size: .9375rem; font-weight: 600; margin: 2rem 0 .75rem; }
.msd-related { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.msd-related a { color: var(--green); font-size: .9rem; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .msd-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 2.5rem; }
  .msd-table td:nth-child(3),
  .msd-table td:nth-child(4) { white-space: normal; }
  .msd-table th:nth-child(3),
  .msd-table th:nth-child(4) { width: 15%; }
}
@media (max-width: 900px) {
  .res-section,
  .msd-band { padding: var(--section-pad-sm); }
  .tool-featured { padding: var(--section-pad-sm); }
  .tool-page-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .tool-page-media { max-width: 420px; }
  .tool-actions { flex-direction: column; }
  .tool-actions .btn { text-align: center; }
  .msd-band { grid-template-columns: 1fr; gap: 2rem; }
  .nav-links .nav-cart { padding: .85rem 1.5rem; }
  .nav-links .cart-toggle { font-size: .9rem; }

  /* index becomes a sticky "Jump to section" menu */
  .msd-layout { grid-template-columns: 1fr; gap: 2rem; }
  .msd-index { top: calc(var(--nav-h) - 1px); z-index: 50; max-height: none; background: var(--cream); }
  .msd-index-box { border: 1px solid var(--border); background: var(--cream); }
  .msd-index-box > summary {
    display: flex; justify-content: space-between; align-items: center;
    padding: .9rem 1rem; cursor: pointer; list-style: none;
    font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
    color: var(--green);
  }
  .msd-index-box > summary::-webkit-details-marker { display: none; }
  .msd-index-box > summary::after { content: '+'; font-size: 1.1rem; }
  .msd-index-box[open] > summary::after { content: '\2212'; }
  .msd-index-list { max-height: 60vh; padding: 0 1rem 1rem; }
  .msd-section { scroll-margin-top: calc(var(--nav-h) + 71px); }   /* nav + the sticky jump-menu bar */
  .msd-hub-header { padding-bottom: 2rem; }

  /* tables become stacked cards */
  .msd-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .msd-table, .msd-table tbody, .msd-table tr, .msd-table td { display: block; width: 100%; }
  .msd-table tr { padding: 1rem 0; border-bottom: 1px solid var(--border); }
  .msd-table td { border: none; padding: .15rem 0; white-space: normal !important; }
  /* Mobile-only member of site.css's SHARED MICRO-LABEL RECIPE: it can't join that list, which applies at every
     width, and on desktop these cells are plain table columns. Keep the values in step with the recipe. */
  .msd-table td:nth-child(3),
  .msd-table td:nth-child(4) { display: inline-block; width: auto; margin-right: 1rem; color: var(--rust); font-weight: 600; letter-spacing: .13em; text-transform: uppercase; font-size: .75rem; }
}
@media (max-width: 600px) {
  .msd-finder { grid-template-columns: 1fr; }
}
