/* ==========================================================================
   /ai-gateway — Figma 0:4789 (desktop) / 0:7534 (mobile)
   Loaded after style.css + product.css. ≥ 1000 px desktop frame, < 1000 px
   mobile frame.
   ========================================================================== */

/* ---- Line migration + routing matrix ─ 0:4836 ---- */
.gw-mig { padding: 144px 0; }
.gw-mig__wrap { width: min(1200px, 100% - 48px); margin: 0 auto; }

.mg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--hairline); }
.mg-intro { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; padding: 108px 40px; border-right: 1px solid var(--hairline); }
.mg-title { font-size: 40px; font-weight: 600; font-variation-settings: "opsz" 31; line-height: 1.3; letter-spacing: -0.01em; }
.mg-panel { grid-column: span 2; display: flex; flex-direction: column; align-self: start; min-width: 0; }
.mg-tabs { display: flex; border-bottom: 1px solid #202020; }
.mg-tabs button {
  flex: 1 1 0;
  height: 50px;
  border-right: 1px solid var(--hairline);
  background: #171717;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  color: #fff;
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease;
}
.mg-tabs button:last-child { border-right: 0; }
.mg-tabs button:hover { background: #222; }
.mg-tabs button[aria-selected="true"] { background: #fff; color: #171717; font-weight: 500; }
.mg-tabs button:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.mg-codewrap { display: grid; background: #202020; }
.mg-code {
  grid-area: 1 / 1;
  min-width: 0;
  margin: 0;
  padding: 32px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: #8a8a8a;
  white-space: pre;
  tab-size: 4;
}
.mg-code[hidden] { display: block; visibility: hidden; }   /* panels share one cell: no height jump */
.mg-code.is-in { animation: mg-in .45s var(--ease-sheet) both; }
@keyframes mg-in { from { opacity: 0; translate: 0 6px; } }
.mg-code i { font-style: normal; }
.c-kw { color: #b083f0; }
.c-cls { color: #f2f0ed; }
.c-str { color: #e0653a; }
.c-s2 { color: #98c379; }
.c-cm { color: #5c6370; }

.mx-head { display: flex; flex-direction: column; align-items: flex-start; gap: 40px; padding: 204px 32px 64px; border-inline: 1px solid var(--hairline); }
.mx-title { font-size: 48px; font-weight: 600; font-variation-settings: "opsz" 31; line-height: 1.1; letter-spacing: -0.01em; }
.mx { border: 1px solid var(--hairline); border-top: 0; }
.mx-row { display: grid; grid-template-columns: 46.42% repeat(3, minmax(0, 1fr)); height: 48px; border-top: 1px solid var(--hairline); background: #1e1e1e; }
.mx-row > span { display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--hairline); }
.mx-row > span:last-child { border-right: 0; }
.mx-row > span:first-child {
  justify-content: flex-start;
  padding: 0 20px 0 48px;
  border-right-color: rgb(255 255 255 / .08);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #f2f0ed;
}
.mx-row--head { background: #282828; font-family: var(--mono); font-size: 14px; color: #b4b4b4; }
.mx-row--head > span:first-child { border-right-color: var(--hairline); }
.mx-ok { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #2e2e2e; }
.mx-ok img { width: 23.33px; height: 23.33px; margin-top: .5px; }

/* ---- API surface ─ 0:4936 ----
   The fifteen endpoints run as two tickers into the gateway tile; glints
   travel the dashed leads toward it. */
/* Fills the viewport under the nav, so it is the only section on screen
   while it is in view; the overhead section only arrives after it. */
.gw-api {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 62px);
  min-height: calc(100svh - 62px);
  padding: 112px 0;
  overflow-x: clip;
}
.gw-api__head { display: flex; flex-direction: column; align-items: center; gap: 40px; text-align: center; }
.gw-api__title { font-size: 40px; font-weight: 600; font-variation-settings: "opsz" 40; line-height: 1.2; color: #f2f0ed; }
.gw-api__flow { display: flex; align-items: center; gap: 9px; width: min(1200px, 100% - 48px); margin: 72px auto 0; }
.gw-api__rows { display: none; }

.ep-col {
  flex: none;
  width: 296px;
  height: 369px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 50%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 50%, transparent);
}
.ep-run { display: flex; flex-direction: column; gap: 4px; will-change: transform; }
.ep-col--up .ep-run { animation: ep-up 34s linear infinite; }
.ep-col--down .ep-run { animation: ep-down 30s linear infinite; }
@keyframes ep-up { from { transform: translateY(0); } to { transform: translateY(calc(-50% - 2px)); } }
@keyframes ep-down { from { transform: translateY(calc(-50% - 2px)); } to { transform: translateY(0); } }
.ep {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  width: 296px;
  height: 64px;
  padding: 4px;
  border-radius: 7px;
  background: #3a3a3a;
}
.ep span { padding: 0 12px; font-family: var(--mono); font-size: 14px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep i { position: relative; flex: none; width: 56px; height: 56px; border-radius: 4.392px; background: #2e2e2e; }
.ep i::after {
  content: '';
  position: absolute;
  inset: 13px;
  background: #fff;
  -webkit-mask: var(--m) center / contain no-repeat;
  mask: var(--m) center / contain no-repeat;
}

.ep-arrow { position: relative; flex: 1 1 0; min-width: 0; height: 14.73px; overflow: hidden; }
.ep-arrow img { display: block; width: 100%; height: 100%; }
.ep-arrow--in { transform: scaleX(-1); }
.ep-arrow::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 0;
  width: 44px;
  height: 3px;
  margin-left: -44px;
  border-radius: 2px;
  background: linear-gradient(to right, rgb(255 96 56 / 0), rgb(255 96 56 / .95));
  opacity: 0;
  animation: ep-glint 2.8s cubic-bezier(.45, 0, .55, 1) infinite;
}
.ep-arrow--in::after { animation-delay: 1.4s; }
@keyframes ep-glint { 0% { left: 0; opacity: 0; } 14% { opacity: 1; } 82% { opacity: 1; } 100% { left: 100%; opacity: 0; } }

.gw-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  border-radius: 24px;
  background:
    url("data:image/svg+xml;utf8,<svg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none'><rect x='0' y='0' height='100%' width='100%' fill='url(%23grad)' opacity='0.30000001192092896'/><defs><radialGradient id='grad' gradientUnits='userSpaceOnUse' cx='0' cy='0' r='10' gradientTransform='matrix(-11.306 2.0072 3.6127 -10.283 118.59 61.502)'><stop stop-color='rgba(102,102,102,1)' offset='0'/><stop stop-color='rgba(77,77,77,1)' offset='0.25'/><stop stop-color='rgba(51,51,51,1)' offset='0.5'/><stop stop-color='rgba(26,26,26,1)' offset='0.75'/><stop stop-color='rgba(13,13,13,1)' offset='0.875'/><stop stop-color='rgba(6,6,6,1)' offset='0.9375'/><stop stop-color='rgba(0,0,0,1)' offset='1'/></radialGradient></defs></svg>"),
    linear-gradient(136.46deg, rgb(37 37 37 / .07) 4.928%, rgb(37 37 37 / .07) 14.657%, rgb(255 255 255 / .07) 33.674%, rgb(37 37 37 / .07) 50.921%, rgb(37 37 37 / .07) 68.611%, rgb(255 255 255 / .07) 81.879%, rgb(37 37 37 / .07) 96.915%),
    #252525;
  background-size: 100% 100%;
  box-shadow: 0 104px 41px rgb(0 0 0 / .01), 0 58px 35px rgb(0 0 0 / .05), 0 26px 26px rgb(0 0 0 / .09), 0 6px 14px rgb(0 0 0 / .1);
}
.gw-tile img { width: 41.23px; height: 32px; }
.gw-api:not(.is-live) .ep-run, .gw-api:not(.is-live) .ep-arrow::after { animation-play-state: paused; }

/* ---- Overhead budget ─ 0:4975 ---- */
.gw-lat { padding: 80px 0; }
.gw-lat__title {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 64px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.gw-lat__a { min-height: 34px; color: #63c462; }  /* fixed 34 px box in both frames */
.gw-lat__b { color: #b7b7b7; }
/* The caret takes no room, so typing never re-wraps the line; it hangs
   1 px above cap height down to the baseline (Figma 21 × 35). */
.tw-caret { display: inline-block; width: 0; }
.gw-cursor { display: inline-block; width: 21px; height: 35px; margin-left: 13px; vertical-align: baseline; background: #b7b7b7; animation: gw-blink 1.06s steps(1) infinite; }
@keyframes gw-blink { 50% { opacity: 0; } }
.is-typing .gw-cursor { animation: none; }
/* typing: the untyped remainder stays in the line, invisible, so the line
   keeps its final width and wrap from the first frame */
.tw-rest { color: transparent; }

/* strokes sit inside the boxes, as in Figma: header 56, rows 68 */
.lt { outline: 1px solid var(--hairline); outline-offset: -1px; font-family: var(--mono); }
.lt-row { display: grid; grid-template-columns: 300px 200px minmax(0, 1fr); align-items: center; padding: 24px; box-shadow: inset 0 -1px 0 var(--hairline); }
.lt-row > span:nth-child(1) { font-size: 15px; color: #f2f0ed; }
.lt-row > span:nth-child(2) { font-size: 13px; color: #f2f0ed; }
.lt-row > span:nth-child(3) { font-size: 15px; color: #8a8a8a; }
.lt-row--head { padding: 20px; background: #282828; }
.lt-row--head > span:nth-child(n) { font-size: 12px; color: #b4b4b4; text-transform: uppercase; }
/* the table enters once the headline has typed (gateway.js) */
.lt.is-armed { opacity: 0; transition: opacity .45s ease; }
.lt.is-armed.is-open { opacity: 1; }
.lt.is-armed .lt-row { opacity: 0; translate: 0 10px; }
.lt.is-armed .lt-row.is-in { opacity: 1; translate: none; transition: opacity .5s ease, translate .6s var(--ease-sheet); transition-delay: var(--d, 0ms); }

@supports (text-box: trim-both cap alphabetic) {
  .mg-tabs button, .gw-lat__a, .gw-lat__b { text-box: trim-both cap alphabetic; }
  @media (min-width: 1000px) {
    .mg-title, .mx-title, .gw-api__title { text-box: trim-both cap alphabetic; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .ep-run, .ep-arrow::after, .gw-cursor, .mg-code.is-in { animation: none !important; }
}

/* 1000–1239: the 1200 flow row zooms as a unit */
@media (max-width: 1239px) and (min-width: 1000px) {
  .gw-api__flow { zoom: var(--rz, 1); width: 1200px; }
}

/* ==========================================================================
   < 1000: mobile frame
   ========================================================================== */
@media (max-width: 999px) {
  /* line migration ─ 0:7575 */
  .gw-mig { padding: 64px 0; }
  .gw-mig__wrap { width: min(560px, 100% - 40px); }
  .mg-grid { display: flex; flex-direction: column; }
  .mg-intro { gap: 32px; padding: 24px 16px; border-right: 0; border-bottom: 1px solid var(--hairline); }
  .mg-title { font-size: 28px; line-height: 1.1; }
  .mg-panel { display: flex; flex-direction: column; }
  .mg-codewrap { order: 1; border-bottom: 1px solid var(--hairline); }
  .mg-code { padding: 16px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
  .mg-tabs { order: 2; border: 0; }
  .mg-tabs button { height: 48px; background: #1b1b1b; font-family: var(--sans); font-weight: 700; font-size: 12px; text-transform: uppercase; color: #acacac; }
  .mg-tabs button[aria-selected="true"] { background: #fff; color: #1b1b1b; font-weight: 700; }

  /* routing matrix */
  .mx-head { gap: 32px; padding: 88px 16px 24px; border-bottom: 1px solid var(--hairline); }
  .mx-title { font-size: 28px; line-height: 1.2; }
  .mx { border-top: 0; }
  .mx-row { grid-template-columns: minmax(0, 1fr) repeat(3, 72px); height: 40px; }
  .mx-row:first-child { border-top: 0; }
  .mx-row--head { height: 32px; font-size: 11px; }
  .mx-row > span:first-child { padding: 0 12px; font-size: 11px; }
  .mx-ok { width: 24px; height: 24px; }
  .mx-ok img { width: 20px; height: 20px; }

  /* API surface ─ 0:7671: three ticker rows */
  .gw-api { min-height: calc(100vh - 65px); min-height: calc(100svh - 65px); padding: 56px 0; }
  .gw-api__head { gap: 24px; width: min(350px, 100% - 40px); }
  .gw-api__title { font-size: 28px; font-variation-settings: "opsz" 31; line-height: 1.1; letter-spacing: -0.01em; }
  .gw-api__flow { display: none; }
  .gw-api__rows { display: flex; flex-direction: column; gap: 8px; margin-top: 48px; }
  .ep-row { overflow: hidden; }
  .ep-row .ep-run { flex-direction: row; gap: 8px; width: max-content; animation: ep-left 40s linear infinite; }
  .ep-row--rev .ep-run { animation-name: ep-right; animation-duration: 46s; }
  .ep-row:nth-child(2) .ep-run { animation-delay: -17s; }      /* rows start out of step, as drawn */
  .ep-row:nth-child(3) .ep-run { animation-delay: -29s; }
  @keyframes ep-left { from { transform: translateX(0); } to { transform: translateX(calc(-50% - 4px)); } }
  @keyframes ep-right { from { transform: translateX(calc(-50% - 4px)); } to { transform: translateX(0); } }
  .ep-row .ep { flex-direction: row-reverse; gap: 10px; width: auto; height: auto; padding: 4px 12px 4px 4px; }
  .ep-row .ep span { padding: 0; font-size: 13px; }
  .ep-row .ep i { width: 40px; height: 40px; border-radius: 3.137px; }
  .ep-row .ep i::after { inset: 9.25px; }
  .gw-api:not(.is-live) .ep-row .ep-run { animation-play-state: paused; }

  /* overhead budget ─ 0:7702 */
  .gw-lat { padding: 64px 0; }
  .gw-lat .wrap { width: min(560px, 100% - 32px); }
  .gw-lat__title { gap: 4px; margin-bottom: 32px; font-size: 24px; line-height: 1.3; }
  .lt { margin-inline: 4px; }                                   /* 350 in the 358 column */
  .gw-cursor { width: 12px; height: 20px; margin-left: 8px; vertical-align: -3px; }
  .lt-row { grid-template-columns: 100px 72px minmax(0, 1fr); column-gap: 8px; padding: 14px 16px; }
  .lt-row--head { padding: 12px 16px; }
  .lt-row > span:nth-child(n) { font-size: 12px; }
  .lt-row--head > span:nth-child(n) { font-size: 11px; }
}
