/* Shared site foundation and components. Load after tokens.css, before page CSS. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* The sticky nav would otherwise land on top of whatever you jumped to. */
  scroll-padding-top: calc(var(--nav-height) + var(--space-4));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: var(--weight-body);
  font-size: var(--size-300);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent-soft);
  text-decoration: none;
}

a:hover {
  color: var(--text);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Keyboard users get to the content without walking the whole nav. */
.skip {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: var(--weight-strong);
  transition: top var(--dur-hover) var(--ease-out);
}

.skip:focus {
  top: var(--space-4);
}

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

/* --- buttons -------------------------------------------------------------
   The raised bottom edge is the product's own button. It reads as a physical
   thing, which is why pressing it has to move it.

   Same object as the app's GButton (lib/ui/animations/buttons/buttons.dart),
   rebuilt in CSS because a Flutter widget paints to a canvas and no stylesheet
   can reach inside it. Only the paint is duplicated: every colour, radius and
   curve below comes from tokens.generated.css, which is generated from
   lib/theme/tokens.dart. */

.btn {
  --edge: 4px;
  --press: 3px; /* how far the face drops: the edge minus the 1px that stays */
  --ring: 2px;  /* G.outlineWidth */
  /* The face, as its own property so :hover can lighten it without replacing
     the gradient built from it. The lip and the ring do not follow: in the app
     the hover veil sits on the face alone. */
  --face: var(--button-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: calc(var(--button-height) - var(--edge));
  /* The edge and the ring are shadows, not borders: they take no layout space,
     so the margin gives it back and a pressed button never moves what is
     around it. */
  margin-bottom: calc(var(--edge) + var(--ring));
  padding-inline: var(--space-5);
  border: 0;
  border-radius: var(--button-radius);
  /* Lit from above, like GButton: the top of the face is 10% white. */
  background: linear-gradient(
    color-mix(in srgb, var(--ink-000) 10%, var(--face)),
    var(--face)
  );
  /* The lip, and the ring around both it and the face. The app paints the ring
     behind the face so it travels down with it; three shadows are how that
     looks from out here. */
  box-shadow:
    0 0 0 var(--ring) var(--button-outline),
    0 var(--edge) 0 var(--button-edge),
    0 var(--edge) 0 var(--ring) var(--button-outline);
  color: var(--button-text);
  font-family: inherit;
  font-size: var(--size-200);
  font-weight: var(--weight-display);
  letter-spacing: 0.02em;
  cursor: pointer;
  /* Named properties, never `all`: `all` animates things you did not mean to,
     and half of them are not compositable. */
  transition: transform var(--dur-press) var(--ease-out),
    box-shadow var(--dur-press) var(--ease-out),
    background-color var(--dur-hover) ease;
}

/* The global rule rounds the focus ring to --radius-sm, which is 3px tighter
   than this button. Restated here so the ring follows the corner it is on. */
.btn:focus-visible {
  border-radius: var(--button-radius);
}

/* The face sinks into its own edge, ring and all. */
.btn:active {
  transform: translateY(var(--press));
  box-shadow:
    0 0 0 var(--ring) var(--button-outline),
    0 calc(var(--edge) - var(--press)) 0 var(--button-edge),
    0 calc(var(--edge) - var(--press)) 0 var(--ring) var(--button-outline);
}

/* 12% white, the same veil GButtonInk.highlight lays over the app's buttons. */
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    --face: color-mix(in srgb, var(--button-bg) var(--button-hover-strength, 88%), var(--ink-000));
  }
}

.btn--ghost {
  --button-bg: var(--button-ghost-bg);
  --button-edge: var(--button-ghost-edge);
  /* Restated, not inherited: see the note in tokens.css. */
  --button-outline: color-mix(in srgb, var(--button-ghost-bg) 40%, black);
  --button-text: var(--button-ghost-text);
  --button-hover-strength: 84%;
  /* Flat: the top-lit gradient reads as a glow on a grey face. */
  background: var(--face);
}

@media (hover: hover) and (pointer: fine) {
  .btn--ghost:hover {
    color: var(--text);
  }
}

.btn--sm {
  --edge: 3px;
  --press: 2px;
  min-height: calc(42px - var(--edge));
  padding-inline: var(--space-4);
  font-size: var(--size-100);
}

/* --- cookie consent -------------------------------------------------------
   Nothing beyond what the site needs to work runs before this is answered, and
   refusing is exactly as easy as accepting — one button, same size, same row.
   A "reject" hidden behind a settings screen is not a choice. */

.consent {
  position: fixed;
  inset-inline: var(--space-4);
  inset-block-end: var(--space-4);
  z-index: 60;
  max-width: 520px;
  margin-inline: auto;
  padding: var(--space-5);
  background: var(--bg-raised);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lift);
  transform: translateY(12px);
  opacity: 0;
  visibility: hidden;
  transition: transform 260ms var(--ease-out), opacity 260ms var(--ease-out),
    visibility 260ms;
}

.consent[data-open="true"] {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.consent h2 {
  font-size: var(--size-400);
  margin-block-end: var(--space-3);
}

.consent p {
  font-family: var(--font-reading);
  font-size: var(--size-200);
  color: var(--text-soft);
}

.consent__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-block-start: var(--space-5);
}

.consent__row .btn {
  flex: 1 1 160px;
}

.consent__toggles {
  display: grid;
  gap: var(--space-3);
  margin-block-start: var(--space-4);
  padding-block-start: var(--space-4);
  border-block-start: var(--hairline) solid var(--line);
}

.consent__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--size-200);
  color: var(--text-soft);
}

.consent__toggle input {
  inline-size: 20px;
  block-size: 20px;
  accent-color: var(--accent);
}

/* Links that perform an action, shared by the footer and legal pages. */
.text-button {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-soft);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Shared table structure; page CSS owns column sizing and mobile layouts. */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: var(--hairline) solid var(--line);
  border-radius: var(--table-radius, var(--card-radius));
  overflow: hidden;
  background: var(--surface);
}

.data-table th,
.data-table td {
  padding: var(--table-cell-padding, var(--space-4));
  text-align: start;
  font-size: var(--table-cell-size, var(--size-200));
  vertical-align: top;
  border-block-end: 1px solid var(--line);
}

.data-table thead th {
  background: var(--surface-dim);
  font-size: var(--size-100);
  letter-spacing: var(--table-heading-spacing, 0.08em);
  text-transform: uppercase;
  color: var(--text-muted);
}

.data-table tbody tr:last-child :is(th, td) {
  border-block-end: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
