/* The leading accordion: five questions on a white page, split by hairlines. Under each question its answer, shut:
   every line of it set on the same spot, a dark rule made of text. The script cuts the answers into lines and moves
   them; their colours and sizes come from here. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #141414;           /* the questions */
  --answer: #2b2925;        /* the answers, and the rule they make when shut */
  --line: #e4e1da;          /* the hairline between two questions */
  --icon: #141414;          /* the plus */
  --accent: #e3431b;        /* the minus of the open question, and the focus ring */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Roboto Flex Variable', system-ui, sans-serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

/* the list sits in the middle of the page; the script gives it a fixed height (every question shut plus the longest
   answer open), so its top never moves when an answer opens. In a real page it simply sits in the flow */
.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

.faq {
  width: min(620px, 100%);
}

/* ---------------------------------------------------------------- one question */
.faq__item {
  border-top: 1px solid var(--line);
}

.faq__item:last-child {
  border-bottom: 1px solid var(--line);
}

.faq__head {
  margin: 0;
  font: inherit;
}

.faq__q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 18px 0 4px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.012em;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.faq__q:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* the weight and the width of the question: the script moves --qw (open) and --qh (under the pointer) */
.faq__text {
  --qw: 0;
  --qh: 0;
  font-variation-settings: 'wght' calc(430 + 150 * var(--qw) + 60 * var(--qh)), 'wdth' calc(100 - 6 * var(--qw));
}

/* the plus: two hairlines that turn (the script turns them; one more span each would hold a CSS transform) */
.faq__icon {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  color: var(--icon);
}

.faq__bar {
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 1.5px;
  margin-top: -0.75px;
  border-radius: 1px;
  background: currentColor;
}

/* ---------------------------------------------------------------- the answer */
.faq__a {
  position: relative;
  padding-bottom: 14px;
}

/* the lines of the answer: the script sets the height from where the lowest line is */
.faq__lines {
  position: relative;
  width: calc(100% - 42px);
  max-width: 470px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.faq__item.is-open .faq__lines {
  cursor: auto;
}

.faq__row,
.faq__measure {
  font-size: 16px;
  letter-spacing: 0;
  color: var(--answer);
}

.faq__row {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  will-change: transform;
}

/* the paragraph is set here once, hidden, to find where its lines break */
.faq__measure {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  visibility: hidden;
  pointer-events: none;
}

/* with the script on, the paragraph is only for screen readers (and hidden while the answer is shut) */
.is-cut .faq__src {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.faq__src {
  margin: 0;
  max-width: 54ch;
  font-size: 16px;
  line-height: 1.6;
  color: var(--answer);
}

@media (max-width: 520px) {
  .faq__q {
    gap: 18px;
    padding-top: 16px;
    font-size: 18px;
  }

  .faq__lines {
    width: calc(100% - 30px);
  }

  .faq__row,
  .faq__measure {
    font-size: 15px;
  }
}
