/* Deliberate deviations from the design canvas.
 *
 * Everything else in this port reproduces the canvas exactly, and the parity harness
 * holds it to that. Changes we have decided to make on purpose live here instead of in
 * the extracted markup, so re-running the extraction cannot quietly undo them — and so
 * the list of things we do differently is one short, reviewable file.
 *
 * Each rule states what it changes and why.
 */

/* Footer content width — align it with the header and the page sections.
 *
 * The footer element is self-contained (it deliberately depends on no design-system
 * token), and it caps its inner container at the same 1200px as everything else but then
 * adds its own 48px side padding. That puts its content 48px further in on each side than
 * the header or any section: content edges at 168…1272 instead of 120…1320 on a 1440
 * viewport. Widening the container by exactly those two gutters lines the columns up with
 * the rest of the page, and because the padding stays, the footer keeps its gutter on
 * narrow screens — below ~1296px both it and the sections resolve to the same 48px inset.
 */
gain-footer .gfx-in {
  max-width: calc(var(--container-max, 1200px) + 96px);
}

/* Pricing's content container — align it with the header, the footer and every other page.
 *
 * The pricing page's markup predates the shared container: its `.wrap` is 1240px wide with
 * its own 48px padding, so its content sits at 148…1292 on a 1440 viewport while every other
 * page — and the header and footer — sit at 120…1320. On the canvas that was consistent,
 * because the page also carried its own full-width nav; this port gives it the site header
 * instead, which is what leaves the 28px step visible down both edges. Widening the container
 * by its own two gutters lines the content up, and keeps the gutter on narrow screens.
 */
main .wrap {
  max-width: calc(var(--container-max, 1200px) + 96px);
}

/* One smooth-scroll implementation, not two.
 *
 * The pricing and policy sheets ask the browser for `scroll-behavior: smooth`, which on the
 * canvas was those routes' whole smooth-scrolling story: the shell names no motion entry
 * point for them, so Lenis never ran there. This port runs the motion layer on every page,
 * and the two smoothing layers fight — five 200px wheel notches travel 844px on a policy page
 * against 1000px on a page without the CSS rule, and the difference is visible as sluggish,
 * stalling scroll. Lenis' own documentation says to remove the CSS rule when it is in use.
 */
html {
  scroll-behavior: auto;
}

/* Give the mobile drawer a height its containing block cannot.
 *
 * The drawer is `position: fixed; top: 68px; bottom: 0` inside `header.site-header`, which
 * carries `backdrop-filter: blur(20px)` for the frosted chrome. A filtered element becomes
 * the containing block for its fixed descendants, so those insets resolve against the 68px
 * header rather than the viewport: `bottom: 0` left the drawer 0px of content, 48px of
 * padding, and every menu clipped to a sliver — the whole mobile nav, on every page.
 *
 * Stating a height instead of a bottom inset is the smallest fix that keeps the frosted
 * header. `100%` is that same containing block, so this stays correct if the header's own
 * height changes, and `dvh` follows the mobile browser's collapsing toolbars where it is
 * supported. The panels run past the viewport now that they list real pages — the Solutions
 * one is about 1000px tall — so the drawer scrolls, and keeps that scroll to itself.
 */
header.site-header .gain-drawer {
  bottom: auto;
  height: calc(100vh - 100%);
  height: calc(100dvh - 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Opaque, because the frosted look cannot work here.
   *
   * The drawer asks for `background: rgba(251,253,251,.92)` over `backdrop-filter:
   * blur(22px)`, and the blur is inert: a filtered ancestor starts a new backdrop root, so
   * the drawer blurs the header's content rather than the page behind it. What is left is
   * an 8% window onto unblurred body copy, and the hero heading reads straight through the
   * menu. craft.css already states this same solid colour where it turns transparency off
   * for reduced-transparency and forced-colours, so the drawer uses it unconditionally. */
  background: #fbfdfb;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Keep the "not yet designed" note out of the drawer, as it already is everywhere else.
 *
 * site-nav.js labels every `.nav-unbuilt` item with that note and then hides it again for
 * the desktop nav, the mainnav and the footer — the three places a visitor sees. The drawer
 * is not in that list because it was never visible to check: its containing block collapsed
 * it to 48px. With a height it is, and a phone would read "Email ticketing NOT YET DESIGNED"
 * in the live menu. Specificity has to beat that script's own injected sheet, which is
 * appended to the head after this file.
 */
header.site-header .gain-drawer .nav-unbuilt::after {
  display: none;
}

/* One header on every page: switch to the burger globally, not once per route sheet.
 *
 * The captured header carries `display` inline on both navs — `nav-desktop` flex, the
 * `nav-mobile` burger none — so the mobile swap has to be an `!important` rule to beat them.
 * The canvas put that rule inside nine route stylesheets, one identical copy each
 * (home, blog, post, cases, case-study, privacy, terms, cookie, product-page), and
 * pricing.css is the one that never got a copy. So /pricing alone showed the full desktop
 * nav on a phone with no way to open a menu, which is the same header markup behaving
 * differently on one route.
 *
 * Stated once here, where every redesigned page already links it last, the swap cannot be
 * missed by a route again. The nine copies are the same declarations at the same breakpoint,
 * so they stay harmless where they are — this file is loaded after all of them.
 */
@media (max-width: 1000px) {
  .nav-desktop {
    display: none !important;
  }

  .nav-mobile {
    display: inline-flex !important;
  }
}

/* Keep the Intake stage's glow inside the page, as every other section already does.
 *
 * `.cv-glow` is a decorative radial blur, `position: absolute` and 40cqw wide, centred on
 * `.cv-term` at 88.33% of `.cv-stage` — so it is designed to bleed roughly 8% past the
 * stage's right edge. Every other section on the page clips that kind of bleed (`#hero`
 * states `overflow: hidden` inline, and `.sec-fx` carries `overflow-x: hidden`); the `.cv`
 * section is the one that never got it, so the glow reaches the document and scrolls it.
 *
 * It only shows in a band: the stage is hidden below ~1150px, and from 1400px up the stage
 * hits its 1200px max-width and the glow lands inside the viewport again. In between, the
 * whole page scrolls sideways — 42px at 1180, 51px at 1280, the single most common desktop
 * width. Clipping at the section is the same treatment the other sections already have, and
 * cuts the glow exactly where the screen ends rather than anywhere a viewer can see.
 */
section.cv {
  overflow: hidden;
}

/* Let the stacked single-column grids be narrower than their content.
 *
 * At 1000px and below the route sheets collapse these grids with `grid-template-columns:
 * 1fr`, and `1fr` is `minmax(auto, 1fr)`: the track can never go below the item's
 * min-content width. The items are flex columns holding a design mock, so their min-content
 * is whatever the widest mock card measures — 360px in the hero, 428px in the Eden AI — and the
 * track keeps that width on a 360px phone. The overflow is invisible rather than scrollable,
 * because the sections clip it, so the headline, the body copy and the CTA are simply sliced
 * off down the right edge.
 *
 * `minmax(0, 1fr)` lets the track take the container's width, and `min-width: 0` on the items
 * stops the same automatic minimum re-appearing one level down. Both are the standard pair for
 * this; neither changes anything above the breakpoint, where the canvas already states
 * `minmax(0px, ...)` tracks itself.
 */
@media (max-width: 1000px) {
  .hero-grid,
  .two-col,
  .faq-grid,
  .wt-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .hero-grid > *,
  .two-col > *,
  .faq-grid > *,
  .wt-grid > * {
    min-width: 0;
  }
}

/* Let the drawer's accordion collapse, which it has never once done.
 *
 * `paintAccordions()` in interactions.js opens and closes each section by setting
 * `panel.hidden`, and every captured panel carries `style="display: flex; …"` inline. An
 * inline declaration outranks the UA stylesheet's `[hidden] { display: none }`, so the
 * attribute flipped and nothing moved: all three sections stood open at once — 2834px of
 * content inside a 776px drawer — under chevrons that said "collapsed". Restating the UA
 * rule with enough weight to beat the inline style is the whole fix; the script is already
 * correct, and this is the same class of trap as the drawer's own collapsed height above.
 */
header.site-header .gain-drawer [data-drawer-panel][hidden] {
  display: none !important;
}

/* Let the header row fit on a phone.
 *
 * The row keeps its desktop geometry at every width — 48px page gutters, a 40px gap, and
 * the trial CTA still in it. On a 360px screen that asks for 679px of content inside 264px,
 * and the burger, the only way into the menu, is what gives: `flex-shrink` takes it from
 * 44px to 34 and its right edge lands 11.9px PAST the viewport, half the control off-screen
 * (measured on `/` at 360px, and on `/pricing` at 390px). The gutter steps down to the
 * narrow token the rest of the site already uses below this width, and the burger is told not
 * to shrink at all so the tap target stays 44 square.
 *
 * The gap goes wider, to the whole band where the burger exists. The row's 40px is the space
 * between the wordmark and the desktop nav, and it lands between the trial CTA and the burger
 * too — 48px with the burger's own inline 8px margin, which is why they read as two unrelated
 * controls rather than one group at 641–1000px. Below the wordmark it changes nothing: the
 * capture pushes the right-hand group over with `margin-left: auto`, so shrinking the gap only
 * gives that auto margin more to absorb.
 *
 * `:first-child` matters: `.gain-drawer` is the header's other direct child, and it carries
 * a 6px gap of its own that is not this row's to change.
 */
@media (max-width: 1000px) {
  header.site-header > div:first-child {
    gap: var(--space-3) !important;
  }
}

@media (max-width: 640px) {
  header.site-header {
    padding: 0 var(--gutter-page) !important;
  }

  header.site-header button.nav-mobile[aria-expanded] {
    flex: 0 0 44px;
  }
}

@media (max-width: 480px) {
  /* The CTA leaves the row for the foot of the menu. It is what crowds the burger off a
   * 360px screen, and at the foot of the drawer it is pinned rather than 2800px down. */
  header.site-header .nav-mobile-cta {
    display: none !important;
  }

  /* Nothing in the row is centred or spaced apart: the capture pushes its right-hand group
   * over with `margin-left: auto` on the CTA. Take the CTA out and the burger falls back
   * against the wordmark, 151px from the left. It inherits the job it was leaning on. */
  header.site-header > div:first-child > button.nav-mobile[aria-expanded] {
    margin-left: auto !important;
  }

  /* A sheet, not a 88vw panel. The 47px strip of page down the left showed nothing legible,
   * is too narrow to aim at, and has no scrim to say it dismisses. */
  header.site-header .gain-drawer {
    width: 100% !important;
    left: 0;
    right: 0;
    /* The capture's left border separated the panel from the strip of page beside it. With
       no strip left there is nothing to separate, and it reads as a hairline down the edge
       of the screen. */
    border-left: 0;
  }
}

/* The dismiss layer, built in interactions.js and parented to the BODY.
 *
 * Not to the header: `.site-header` carries `backdrop-filter`, which makes it the
 * containing block for its `position: fixed` descendants — the same trap that collapsed the
 * drawer itself to 48px above. A scrim parented there would cover the 68px header and
 * nothing else. z-index stays under the header's own 50 so the burger, which is the close
 * button while the menu is open, is never covered by it.
 */
.gain-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--surface-overlay);
  will-change: opacity;
}

@media (max-width: 480px) {
  /* Full-bleed, nothing of the page is left to dim. */
  .gain-drawer-scrim {
    display: none;
  }
}

/* Put the two calls to action on the floor of the menu instead of at the end of its scroll.
 *
 * The drawer's last child holds the trial CTA. With every section open it sat 1941px down;
 * collapsed it is reachable, but still only after the whole of whichever section is open.
 *
 * Two declarations, because there are two states. The drawer is a flex column, so
 * `margin-top: auto` drops the bar to the floor of the sheet while the menu is short enough
 * not to scroll — auto resolves to 0 the moment it does, which is when `position: sticky`
 * takes over and holds the bar against the bottom through the scroll. The negative margins
 * let it bleed to the drawer's edges through the drawer's own 24px padding, and the bottom
 * inset is that padding again so it settles flush rather than 24px up.
 *
 * The top margin is the one declaration here that has to shout. The captured div states
 * `margin-top: var(--space-6)` inline, which outranks this file, and it is not visible in
 * `getComputedStyle().marginTop` either — that reads 24px whether the bar is pinned or not,
 * so the inline value has to be read in the markup rather than measured. Longhands, because
 * a `margin` shorthand cannot mark one side important.
 */
header.site-header .gain-drawer > :last-child {
  position: sticky;
  bottom: calc(var(--space-6) * -1);
  z-index: 1;
  margin-top: auto !important;
  margin-right: calc(var(--space-6) * -1);
  margin-bottom: calc(var(--space-6) * -1);
  margin-left: calc(var(--space-6) * -1);
  padding: var(--space-4) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  background: var(--surface-card);
  border-top: 1px solid var(--border-subtle);
}

/* Give the homepage a gutter that shrinks on a phone, and the one the header already uses.
 *
 * `--gutter-page-lg` is 48px and no media query anywhere redefines it, so every homepage
 * section keeps a 48px inset down to the narrowest screen: on a 320px phone that is 96px of
 * padding around a 224px column, and at 280px the Fragmentation tax stat row needs 193px
 * against the 184px it is given, which is the last of that page's horizontal overflow.
 *
 * The header drops to `--gutter-page` (24px) at 640px, so holding the body at 48px also left
 * the logo and the hero heading on two different left edges on every phone. Matching the
 * header's value and its breakpoint exactly is what lines them back up; a smaller phone
 * gutter (the 16/24/32 ramp that Material, Apple's HIG and Tailwind all land near) would read
 * better still, but only once the header moves with it, so it is deliberately not taken here.
 *
 * Redefining the token rather than restating a padding reaches all eleven places the page
 * states a gutter — ten section paddings in the extracted markup and `.jny-wrap` in home.css
 * — and nothing above 640px changes, so the desktop layout is untouched. `data-route` keeps
 * it to this one page; the other routes have their own gutters and are not in scope yet.
 */
@media (max-width: 640px) {
  html[data-route='home'] {
    --gutter-page-lg: var(--space-6);
  }

  /* Pull the Eden AI satellites back in, now that the gutter no longer hides their overhang.
   *
   * The two floating chips hang deliberately outside the chat mock — the markup gives one
   * `left: -34px` and the other `right: -30px` — which sat inside the page as long as the
   * gutter was 48px. Against 24px they reach 10px past the left edge and 6px past the right,
   * and the section clips them, so each loses a corner.
   *
   * A margin on both sides moves each one without the rule having to know which it is: an
   * absolutely positioned, shrink-to-fit box is anchored by whichever inset it states, so the
   * margin on that side pulls it in and the margin on the other side does nothing. 20px
   * leaves the left chip 10px clear and the right chip 14px, and both still overhang the
   * mock, which is the look the canvas drew.
   */
  html[data-route='home'] .eden-sat {
    margin-left: var(--space-5);
    margin-right: var(--space-5);
  }
}

/* The product pages' content containers — the same alignment the footer and pricing already got.
 *
 * Five rules across four route sheets cap a centred container at 1144px — `.pp-wrap` for the
 * body sections, `.hero-c` for the crm/helpdesk/eden heroes, plus `.mcp-hero-grid`,
 * `.fx-wrap` and `.crx-split` — and none of them adds padding, so on a 1440 viewport every
 * product page sits at 148…1292 while the header, the footer, the homepage, the policy pages
 * and (since the rule above) pricing all sit at 120…1320. A visitor moving between them sees
 * a 28px step down both edges.
 *
 * It is the identical 28px this file already corrected for pricing, and the correction is the
 * same one: state the shared container. They are grouped here rather than fixed one sheet at a
 * time because 1144 is plainly one number copied five times, not five decisions.
 *
 * Deliberately not included: the containers that are narrower on purpose — EasyDesk's 760px
 * reading column and the homepage's 1060px `.mapp-grid` — which are design, not drift.
 * Nothing changes below ~1240px either, where these are already narrower than their own cap,
 * so this only moves the desktop alignment.
 */
main .pp-wrap,
main .hero-c,
main .mcp-hero-grid,
main .fx-wrap,
/* The All Features hero map (GAIN-5000), the same 1144px copied once more. */
main .fx-hero-vis,
main .crx-split,
main .fs-wrap,
main .fs-chips {
  max-width: var(--container-max, 1200px);
}

/* The mobile app hero, at the width the rest of the page uses.
 *
 * `.ma-hero` caps itself at 1320px — 120px wider than the site container — so on a 1440
 * viewport it spans 60…1380 while the section directly beneath it spans 120…1320. The hero
 * reads as overhanging the page rather than heading it, and it is the only hero on the site
 * that does. Its grid keeps its proportions; it is the cap that was wrong, not the layout.
 */
.ma-hero {
  max-width: var(--container-max, 1200px);
}

/* Stop the fragmentation table's columns painting over each other.
 *
 * Every row is a four-track grid stated inline — `minmax(0px, 4fr) minmax(0px, 5fr)
 * minmax(0px, 2fr) minmax(0px, 2fr)`. A `minmax(0, …)` track may be narrower than the text in
 * it, and these cells do not clip, so once a track is too small the text simply paints across
 * its neighbour. "$29/user/mo" runs 20px into "$290" at 1024px and 56px into it at 320px, and
 * on a phone "Scheduling tool" lands on top of "Meeting booking".
 *
 * It is not only a phone problem: 600 and 768 are fine because the column has stacked and the
 * table has the full width, while 1024 — still two columns — is where the money cells are
 * tightest. So the money tracks are sized to their own text at every width, which is what they
 * always wanted: they hold two fixed strings, not prose, and nothing is gained by letting them
 * flex. That alone clears every width from 481px up.
 */
#fragmentation-tax .frag-row,
#fragmentation-tax div:has(> div > .frag-row) > :first-child {
  grid-template-columns: minmax(0, 4fr) minmax(0, 5fr) auto auto !important;
}

/* Below that, four columns cannot fit at all, so each row becomes two lines.
 *
 * At 320px the card has about 208px of content: the two money cells need ~112px of it and the
 * gaps another 48, which leaves 48px for the category and the job — less than the word
 * "Scheduling". Two lines give each pair the full width instead: the category with its monthly
 * total on the first, the job it does with its unit price on the second, which is also the
 * order someone reads them in.
 *
 * The cells are placed by position rather than reordered in the markup, so the DOM order —
 * category, job, price, total — stays the reading order for a screen reader and the extracted
 * markup is left alone.
 *
 * The header row takes the same two lines rather than being hidden, which is what keeps the
 * table's meaning. Three of its labels a reader could infer, but "At 10 users" they could not:
 * without it the bold "$290" beside a "$29/user/mo" is a number with nothing to say what it
 * counts. Laid out this way each label lands directly over the value it names — category above
 * the name, "At 10 users" above the total, job above the job, price above the unit price.
 */
@media (max-width: 640px) {
  #fragmentation-tax .frag-row,
  #fragmentation-tax div:has(> div > .frag-row) > :first-child {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 2px 12px !important;
    align-items: baseline;
  }

  #fragmentation-tax .frag-row > :nth-child(1),
  #fragmentation-tax div:has(> div > .frag-row) > :first-child > :nth-child(1) { grid-area: 1 / 1; }
  #fragmentation-tax .frag-row > :nth-child(2),
  #fragmentation-tax div:has(> div > .frag-row) > :first-child > :nth-child(2) { grid-area: 2 / 1; }
  #fragmentation-tax .frag-row > :nth-child(3),
  #fragmentation-tax div:has(> div > .frag-row) > :first-child > :nth-child(3) { grid-area: 2 / 2; }
  #fragmentation-tax .frag-row > :nth-child(4),
  #fragmentation-tax div:has(> div > .frag-row) > :first-child > :nth-child(4) { grid-area: 1 / 2; }
}

/* Land a `/#journey` link under the fixed header (GAIN-3396).
 *
 * A feature page's "See the full journey" links to the homepage's journey section, and
 * site-nav.js lands a hash on its target's `scroll-margin-top`. Without one the section's top
 * would sit behind the 68px header.
 */
html[data-route="home"] #journey {
  scroll-margin-top: 68px;
}

/* Every other hash target clears the header too.
 *
 * site-nav.js now lands a hash on load instead of snapping to the top, so a deep link such as
 * `/mcp-server#install-cursor` puts its target at its `scroll-margin-top` — 0 by default, which
 * is behind the 68px fixed header. `:where` keeps this at zero specificity, so any page's own
 * value (the policy pages' 92px headings, MCP's `#early-access`, the post prose's 100px) still
 * wins; this only fills in for targets that state none.
 */
:where(main [id]) {
  scroll-margin-top: 68px;
}
