/* Amex offer component, rebuilt live for the homepage thumbnail.
   Static and decorative: it fades in once, then holds. The layout is fluid
   (script sets --ad-w from the host size, every measure below is in design
   units of --u = one unit at a 640-unit wide component) and the Carbon-style
   redlines are positioned from the real element rects by amex-demo.js.
   Base styles are the finished state; the intro is layered on top. */

@font-face {
  font-family: "Libre Franklin";
  font-style: normal; font-weight: 300; font-display: swap;
  src: url("fonts/libre-franklin-300.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Franklin";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/libre-franklin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Arimo";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/arimo-400.woff2") format("woff2");
}
@font-face {
  font-family: "Arimo";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/arimo-700.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/ibm-plex-sans-400.woff2") format("woff2");
}

.ad {
  --ad-stage: #f5f3f1;
  --ad-panel: #ffffff;
  --ad-head: #333333;
  --ad-body: #5f5f5f;
  --ad-strong: #333333;
  --ad-blue: #006fcf;
  --ad-link: #006fcf;

  /* Annotations use the site ink (--saunter-ink) at fixed opacity steps:
     100% for labels and anchor dots, 55% for measurement lines and leaders,
     30% for region edges, 5% for region fills. */
  --ink: 12 10 9;
  --rl: rgb(var(--ink));
  --rl-line: rgb(var(--ink) / 0.55);
  --rl-edge: rgb(var(--ink) / 0.3);
  --rl-fill: rgb(var(--ink) / 0.05);

  --ad-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ad-draw: cubic-bezier(0.65, 0, 0.35, 1);
  --ad-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --ad-sans: "Helvetica Neue", "Arimo", Helvetica, Arial, sans-serif;
  --ad-display: "Benton Sans", "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", "Arimo", Arial, sans-serif;
  --ad-plex: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;

  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: var(--ad-stage);
  color: var(--ad-head);
  font-family: var(--ad-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
:root[data-theme="dark"] .ad {
  --ad-stage: #0c0a09;
  --ad-panel: #171412;
  --ad-head: #faf8f8;
  --ad-body: #c1bfbe;
  --ad-strong: #faf8f8;
  --ad-link: #4aa3f0;

  --ink: 250 248 248;
  --rl-fill: rgb(var(--ink) / 0.07);
}

/* Case-study hero: the screenshot pair is the base layer from first paint. The live layer stays invisible until its
   fonts and card image are ready, then crossfades in (opacity only, same box); the screenshots are hidden once it
   has fully covered them. */
.ad.is-pending { opacity: 0; }
.ad.ad-xf { transition: opacity 360ms var(--ad-soft); }
.ad-xf-live > img { visibility: hidden !important; }

/* Component ---------------------------------------------------------- */
.ad-comp {
  --u: calc(var(--ad-w, 400px) / 640);
  --rp: max(8px, calc(var(--rad-panel, 20) * var(--u)));
  --rb: max(5px, calc(var(--rad-btn, 10) * var(--u)));
  position: absolute;
  width: var(--ad-w, 400px);
  padding-top: calc(var(--ad-w, 400px) * var(--art, 0.25) * 0.6333 * (1 - var(--ov, 0.5)));
}
.ad-panel {
  position: relative;
  box-sizing: border-box;
  padding:
    calc(var(--ad-w, 400px) * var(--art, 0.25) * 0.6333 * var(--ov, 0.5) + var(--t-art-head, 24) * var(--u))
    max(14px, calc(var(--t-pad, 64) * var(--u)))
    calc(var(--t-bottom, 32) * var(--u));
  text-align: center;
}
.ad-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--rp);
  background: var(--ad-panel);
}
.ad-in { position: relative; }
.ad-in > * { margin: 0; }

.ad-art {
  position: absolute;
  top: 0;
  left: calc((1 - var(--art, 0.25)) * 50%);
  width: calc(var(--art, 0.25) * 100%);
  z-index: 2;
}
.ad-card {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 304;
  border-radius: 4.2% / 6.6%;
  box-shadow: none;
  filter: none;
}

.ad-h {
  font-family: var(--ad-display);
  font-weight: 300;
  font-size: max(18px, calc(36 * var(--u)));
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--ad-head);
  text-wrap: balance;
}
.ad-p {
  max-width: max(calc(440 * var(--u)), 80%);
  margin: calc(var(--t-head-body, 16) * var(--u)) auto 0;
  font-size: max(10.5px, calc(15 * var(--u)));
  line-height: 1.46;
  color: var(--ad-body);
  text-wrap: pretty;
}
.ad-learn {
  color: var(--ad-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.ad-fee {
  margin-top: calc(var(--t-body-fee, 16) * var(--u));
  font-size: max(11px, calc(15 * var(--u)));
  line-height: 1.4;
  color: var(--ad-head);
}
.ad-fee b { font-weight: 700; color: var(--ad-strong); }
.ad-fee sup { font-size: 0.6em; line-height: 0; vertical-align: 0.55em; margin-left: 1px; }

.ad-btn {
  margin: calc(var(--t-fee-btn, 24) * var(--u)) auto 0;
  width: 50%;
  height: max(28px, calc(var(--btn-h, 48) * var(--u)));
  display: flex; align-items: center; justify-content: center;
  box-sizing: border-box;
  background: var(--ad-blue);
  border-radius: var(--rb);
  color: #fff;
  font-size: max(11px, calc(16 * var(--u)));
  letter-spacing: 0.01em;
}
.ad-links {
  margin-top: calc(var(--t-btn-links, 16) * var(--u));
  display: flex; justify-content: center; align-items: center;
  gap: calc(28 * var(--u));
  font-size: max(9.5px, calc(12 * var(--u)));
  line-height: 1.4;
}
.ad-links span { display: inline-flex; align-items: center; gap: 0.35em; color: var(--ad-link); white-space: nowrap; }
.ad-links svg { width: 0.8em; height: 0.8em; flex: none; }
.ad-links .ad-mk { width: 0.6em; height: 0.6em; }

/* Small hosts keep the links, stacked beneath the button. */
.ad[data-d="1"] .ad-links,
.ad[data-d="2"] .ad-links,
.ad[data-d="3"] .ad-links {
  flex-direction: column;
  gap: calc(8 * var(--u));
}

/* Content that yields when the host is small. */
.ad[data-d="2"] .ad-p,
.ad[data-d="3"] .ad-p,
.ad[data-d="3"] .ad-fee { display: none; }

/* Redlines (Carbon spec style) ---------------------------------------- */
.ad-ann { position: absolute; inset: 0; z-index: 3; overflow: hidden; }
.ad-ann > * { position: absolute; display: none; }
.ad-ann > .is-on { display: block; }

.ad-fill { background: var(--rl-fill); }

.ad-edge-h, .ad-edge-v, .ad-dim-line { overflow: hidden; }
.ad-edge-h > i, .ad-edge-v > i, .ad-dim-line > b { position: absolute; inset: 0; display: block; }
.ad-edge-h > i {
  background: repeating-linear-gradient(90deg, var(--rl-edge) 0 3px, transparent 3px 7px);
}
.ad-edge-v > i {
  background: repeating-linear-gradient(180deg, var(--rl-edge) 0 3px, transparent 3px 7px);
}
.ad-outline { box-sizing: border-box; overflow: hidden; }
.ad-outline > i {
  position: absolute; inset: 0; display: block;
  box-sizing: border-box;
  border: 1px dashed var(--rl-edge);
}

.ad-dim-line { position: absolute; }
.ad-dim-line > b { background: var(--rl-line); }
.ad-dim-tick { position: absolute; background: var(--rl-line); }
.ad-dim.no-a .ad-dim-tick.is-a { display: none; }
.ad-dim-label {
  position: absolute;
  font-family: var(--ad-plex);
  font-size: 11px;
  line-height: 14px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--rl);
}
.ad-dot {
  position: absolute; top: -2px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--rl);
}
.ad-dim.is-h .ad-dim-line { height: 1px; left: 0; top: 0; width: 100%; }
.ad-dim.is-h .ad-dim-tick { top: -4px; width: 1px; height: 9px; }
.ad-dim.is-h .ad-dim-tick.is-a { left: 0; }
.ad-dim.is-h .ad-dim-tick.is-b { right: 0; }
.ad-dim.is-v .ad-dim-line { width: 1px; top: 0; left: 0; height: 100%; }
.ad-dim.is-v .ad-dim-tick { left: -4px; height: 1px; width: 9px; }
.ad-dim.is-v .ad-dim-tick.is-a { top: 0; }
.ad-dim.is-v .ad-dim-tick.is-b { bottom: 0; }

/* Intro: the component settles first (about 1.3s). Then, in one calm pass:
   region boxes fade in together, each dimension line grows outward from its
   anchor in a short stagger (--i, set by the script), and its value label
   fades in one beat after the line. Ease-in-out only, no overshoot, opacity
   and transform only. Plays once, then holds. */
.ad.is-armed .ad-panel::before,
.ad.is-armed .ad-art,
.ad.is-armed .ad-in > *,
.ad.is-armed .ad-ann > * { opacity: 0; }

.ad.is-intro .ad-panel::before { animation: ad-rise 700ms var(--ad-ease) 0ms backwards; --ad-dy: 6px; }
.ad.is-intro .ad-art { animation: ad-rise 800ms var(--ad-ease) 110ms backwards; --ad-dy: 10px; }
.ad.is-intro .ad-h { animation: ad-rise 760ms var(--ad-ease) 200ms backwards; }
.ad.is-intro .ad-p { animation: ad-rise 760ms var(--ad-ease) 290ms backwards; }
.ad.is-intro .ad-fee { animation: ad-rise 760ms var(--ad-ease) 380ms backwards; }
.ad.is-intro .ad-btn { animation: ad-rise 760ms var(--ad-ease) 470ms backwards; }
.ad.is-intro .ad-links { animation: ad-rise 700ms var(--ad-ease) 560ms backwards; }

.ad.is-intro .ad-outline,
.ad.is-intro .ad-fill,
.ad.is-intro .ad-edge-h,
.ad.is-intro .ad-edge-v { animation: ad-fade 500ms var(--ad-soft) 1400ms backwards; }

.ad-dim.ad-call .ad-dim-line { transform-origin: 0 50%; }
.ad.is-intro .ad-dim.is-h .ad-dim-line { animation: ad-grow-x 520ms var(--ad-soft) calc(1900ms + var(--i, 0) * 110ms) backwards; }
.ad.is-intro .ad-dim.is-v .ad-dim-line { animation: ad-grow-y 520ms var(--ad-soft) calc(1900ms + var(--i, 0) * 110ms) backwards; }
.ad.is-intro .ad-dot { animation: ad-fade 240ms var(--ad-soft) calc(1900ms + var(--i, 0) * 110ms) backwards; }
.ad.is-intro .ad-dim-tick { animation: ad-fade 240ms var(--ad-soft) calc(2260ms + var(--i, 0) * 110ms) backwards; }
.ad.is-intro .ad-dim-label { animation: ad-fade 360ms var(--ad-soft) calc(2300ms + var(--i, 0) * 110ms) backwards; }

.ad.is-done *,
.ad.is-done *::before { animation: none !important; }

@keyframes ad-rise {
  from { opacity: 0; transform: translate3d(0, var(--ad-dy, 8px), 0); }
  to { opacity: 1; transform: none; }
}
@keyframes ad-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ad-grow-x { from { transform: scaleX(0); } to { transform: none; } }
@keyframes ad-grow-y { from { transform: scaleY(0); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ad *, .ad *::before { animation: none !important; transition: none !important; }
}
