/*
 * SaaS style pack: base. A small reset, the type classes, the layout primitives, focus, the
 * entrances and the sky. Import after tokens.css. Tokens only.
 *
 * THE PAGE IS CENTRED. Headlines, sublines, buttons, cards and their text sit on the centre
 * line. The one exception is the picture of the product (.sa-window): it is an app, and apps
 * read from the left.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-synthesis: none; /* never a fake bold or a fake italic */
}

body {
  min-block-size: 100vh;
  background-color: var(--sa-page);
  color: var(--sa-ink);
  font-family: var(--sa-font-sans);
  font-size: var(--sa-text-body);
  font-weight: var(--sa-weight-text);
  line-height: var(--sa-leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Glass: the canvas is never a flat digital colour, a very fine still grain sits over it. */
[data-sa-style='glass'] body {
  background-image: var(--sa-grain-page-image);
}

img,
svg,
video,
canvas {
  display: block;
  max-inline-size: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

/* Emphasis is size and space, never bold or italic. */
b,
strong {
  font-weight: var(--sa-weight-control);
}

em,
i {
  font-style: normal;
}

::selection {
  background: var(--sa-selection);
  color: var(--sa-ink);
}

/* ---------- Focus: one ring, the sky ---------- */
:focus-visible {
  outline: 2px solid var(--sa-focus);
  outline-offset: 3px;
}

.sa-skip {
  position: absolute;
  inset-block-start: var(--sa-space-3);
  inset-inline-start: var(--sa-space-3);
  z-index: calc(var(--sa-z-header) + 1);
  padding: var(--sa-space-3) var(--sa-space-5);
  border-radius: var(--sa-radius-control);
  background: var(--sa-primary);
  color: var(--sa-on-primary);
  translate: 0 -200%;
}

.sa-skip:focus-visible {
  translate: 0 0;
}

.sa-sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Type: set ONLY through these classes ----------
   Serif: hero, close, display, figure, title. Sans: lede, body, small, meta. */
.sa-hero-title,
.sa-close-title,
.sa-display,
.sa-figure,
.sa-title,
.sa-wordmark {
  font-family: var(--sa-font-display);
  font-weight: 400;
  text-wrap: balance;
}

.sa-hero-title {
  max-inline-size: var(--sa-measure-hero);
  margin-inline: auto;
  font-size: var(--sa-text-hero);
  line-height: var(--sa-leading-hero);
  letter-spacing: var(--sa-tracking-hero);
}

.sa-close-title {
  max-inline-size: var(--sa-measure-hero);
  margin-inline: auto;
  font-size: var(--sa-text-close);
  line-height: var(--sa-leading-close);
  letter-spacing: var(--sa-tracking-hero);
}

.sa-display {
  max-inline-size: var(--sa-measure-display);
  margin-inline: auto;
  font-size: var(--sa-text-display);
  line-height: var(--sa-leading-display);
  letter-spacing: var(--sa-tracking-display);
}

.sa-figure {
  font-size: var(--sa-text-figure);
  line-height: 1;
  letter-spacing: var(--sa-tracking-figure);
}

.sa-title {
  font-size: var(--sa-text-title);
  line-height: var(--sa-leading-title);
  letter-spacing: var(--sa-tracking-title);
}

.sa-wordmark {
  font-size: var(--sa-text-wordmark);
  line-height: 1;
  letter-spacing: var(--sa-tracking-title);
}

.sa-lede {
  max-inline-size: var(--sa-measure-lede);
  margin-inline: auto;
  color: var(--sa-sub);
  font-size: var(--sa-text-lede);
  line-height: var(--sa-leading-lede);
  letter-spacing: var(--sa-tracking-tight);
  text-wrap: pretty;
}

.sa-text {
  color: var(--sa-sub);
  font-size: var(--sa-text-body);
  line-height: var(--sa-leading-body);
  text-wrap: pretty;
}

.sa-small {
  font-size: var(--sa-text-small);
  line-height: 1.45;
}

.sa-meta {
  color: var(--sa-quiet);
  font-size: var(--sa-text-meta);
  line-height: 1.4;
}

.sa-num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Layout ---------- */
.sa-wrap {
  max-inline-size: var(--sa-content-max);
  margin-inline: auto;
  padding-inline: var(--sa-gutter);
}

/* A section: one heading, at most one line, one thing. Divided from the one above by a
   hairline across the measure (not across the screen). */
.sa-section {
  max-inline-size: var(--sa-content-max);
  margin-inline: auto;
  padding: var(--sa-section) var(--sa-gutter);
  border-block-start: var(--sa-hairline) solid var(--sa-line);
  text-align: center;
}

.sa-section > .sa-text,
.sa-section > .sa-lede {
  margin-block-start: var(--sa-space-5);
}

.sa-section__body {
  margin-block-start: var(--sa-space-14);
}

.sa-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sa-space-3);
}

/* ---------- Long text: legal pages, a changelog entry, an article ----------
   The page stays centred, but paragraphs longer than two lines are read from the left: the
   column sits on the centre line and its text is flush left. */
.sa-prose {
  max-inline-size: var(--sa-measure-prose);
  margin-inline: auto;
  color: var(--sa-sub);
  text-align: start;
}

.sa-prose > * + * {
  margin-block-start: var(--sa-space-4);
}

.sa-prose :is(h2, h3) {
  margin-block-start: var(--sa-space-10);
  color: var(--sa-ink);
  font-family: var(--sa-font-display);
  font-size: var(--sa-text-title);
  font-weight: 400;
  line-height: var(--sa-leading-title);
  letter-spacing: var(--sa-tracking-title);
}

.sa-prose :is(ul, ol) {
  padding-inline-start: var(--sa-space-5);
}

.sa-prose a {
  color: var(--sa-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 0.2em;
}

/* ---------- Entrances ----------
   Everything that enters FADES in: opacity, a short rise and a blur clearing, together. A
   transform alone paints the text at full strength and then slides it: it reads as a jump.

   .sa-rise      above the fold, on load. Order with style="--i: 1" (2, 3...).
   [data-reveal]  on scroll; [data-reveal="scale"] for the closing case.
   [data-reveal-group]  its children reveal one after another.

   Scroll reveals are hidden by CSS from the first paint, and motion.js marks them
   data-revealed as they come into view. Until motion.js stamps data-sa-motion on <html>, a 0s
   animation shows everything after 3s, so a failed script never leaves the page blank.
   Without scripting, or with reduced motion, nothing is ever hidden. */
.sa-rise {
  animation: sa-rise var(--sa-dur-enter) var(--sa-ease) both;
  animation-delay: calc(80ms + var(--i, 0) * var(--sa-step-enter));
}

@keyframes sa-rise {
  from {
    opacity: 0;
    translate: 0 var(--sa-rise);
    filter: var(--sa-focus-in-hero);
  }
}

@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  [data-reveal]:not([data-revealed]),
  [data-reveal-group]:not([data-revealed]) > * {
    opacity: 0;
  }

  html:not([data-sa-motion]) [data-reveal]:not([data-revealed]),
  html:not([data-sa-motion]) [data-reveal-group]:not([data-revealed]) > * {
    animation: sa-failsafe 0s linear 3s forwards;
  }
}

@keyframes sa-failsafe {
  to {
    opacity: 1;
  }
}

[data-reveal][data-revealed],
[data-reveal-group][data-revealed] > * {
  animation: sa-reveal var(--sa-dur-reveal) var(--sa-ease) backwards;
  animation-delay: calc(var(--i, 0) * var(--sa-step-reveal));
}

[data-reveal='scale'][data-revealed] {
  animation-name: sa-reveal-scale;
}

[data-reveal-group] > :nth-child(2) { --i: 1; }
[data-reveal-group] > :nth-child(3) { --i: 2; }
[data-reveal-group] > :nth-child(4) { --i: 3; }
[data-reveal-group] > :nth-child(5) { --i: 4; }
[data-reveal-group] > :nth-child(6) { --i: 5; }
[data-reveal-group] > :nth-child(7) { --i: 6; }
[data-reveal-group] > :nth-child(8) { --i: 7; }
[data-reveal-group] > :nth-child(n + 9) { --i: 8; }

@keyframes sa-reveal {
  from {
    opacity: 0;
    translate: 0 var(--sa-rise-reveal);
    filter: var(--sa-focus-in);
  }
}

@keyframes sa-reveal-scale {
  from {
    opacity: 0;
    scale: 0.96;
    translate: 0 12px;
    filter: var(--sa-focus-in);
  }
}

/* ---------- The sky: the glow (flat style) ----------
   A sky-coloured light rising from below the hero, or falling into the closing case from
   above (.sa-sky--down). It drifts and breathes very slowly and carries a fine grain, so it
   never reads as a flat digital gradient. The geometry is four registered properties so the
   gradient itself can be animated. In glass, the fluted glass (fluted.js) replaces it. */
@property --sa-sky-x {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 50%;
}

@property --sa-sky-y {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 980px;
}

@property --sa-sky-w {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 115%;
}

@property --sa-sky-h {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: 700px;
}

.sa-sky {
  position: relative;
  isolation: isolate;
  background-image: radial-gradient(var(--sa-sky-w) var(--sa-sky-h) at var(--sa-sky-x) var(--sa-sky-y), var(--sa-glow));
  animation: sa-sky-drift var(--sa-glow-cycle) ease-in-out infinite alternate;
  animation-play-state: var(--sa-glow-motion);
}

.sa-sky--down {
  --sa-sky-y: -8%;
  --sa-sky-w: 120%;
  --sa-sky-h: 85%;
  animation-name: sa-sky-drift-down;
}

@keyframes sa-sky-drift {
  0% { --sa-sky-x: 45%; --sa-sky-y: 1000px; --sa-sky-w: 110%; --sa-sky-h: 690px; }
  50% { --sa-sky-x: 55%; --sa-sky-y: 940px; --sa-sky-w: 124%; --sa-sky-h: 740px; }
  100% { --sa-sky-x: 49%; --sa-sky-y: 975px; --sa-sky-w: 116%; --sa-sky-h: 710px; }
}

@keyframes sa-sky-drift-down {
  0% { --sa-sky-x: 54%; --sa-sky-y: -10%; --sa-sky-w: 114%; --sa-sky-h: 80%; }
  50% { --sa-sky-x: 46%; --sa-sky-y: -2%; --sa-sky-w: 128%; --sa-sky-h: 92%; }
  100% { --sa-sky-x: 51%; --sa-sky-y: -7%; --sa-sky-w: 120%; --sa-sky-h: 86%; }
}

/* grain over the glow, under the type; still, it does not crawl */
.sa-sky::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

[data-sa-theme='dark'] .sa-sky::after {
  opacity: 0.1;
}

/* In glass the fluted glass is the light: the CSS sky steps aside. */
[data-sa-style='glass'] .sa-sky {
  background-image: none;
  animation: none;
}

[data-sa-style='glass'] .sa-sky::after {
  content: none;
}

/* ---------- The fluted glass (glass style; drawn by fluted.js) ---------- */
.sa-fluted {
  position: absolute;
  inset-inline: 0;
  inset-block-start: 0;
  z-index: -1;
  block-size: 1040px;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.sa-fluted--fill {
  inset: 0;
  block-size: auto;
}

[data-sa-style='flat'] .sa-fluted,
html:not([data-sa-style]) .sa-fluted {
  display: none;
}

.sa-fluted > canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  scale: 1.06;
  transition:
    opacity 1600ms var(--sa-ease),
    scale 1600ms var(--sa-ease);
}

.sa-fluted > canvas[data-ready] {
  opacity: var(--sa-glow-opacity);
  scale: 1;
}

/* ---------- Grain images (glass) ---------- */
[data-sa-style='glass'] {
  --sa-grain-page-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.2 0 0 0 0 0.4 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --sa-grain-pane-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.2 0 0 0 0 0.4 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

[data-sa-style='glass'][data-sa-theme='dark'] {
  --sa-grain-page-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --sa-grain-pane-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Reduced motion: hold everything still ---------- */
@media (prefers-reduced-motion: reduce) {
  .sa-rise,
  [data-reveal][data-revealed],
  [data-reveal-group][data-revealed] > *,
  .sa-sky {
    animation: none;
  }

  .sa-fluted > canvas {
    transition: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
