/* The bellows accordion: the questions of an accordion shop on a white page. Every question is a piece of the
   instrument's treble side (ivory and ebony keys, a mother-of-pearl plate, a chrome tab); under the open one a red
   cloth bellows unfolds, with chrome corners on its folds and the answer stamped in gold on its pleats. The script
   draws the keys and the pleats; their colours come from here. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #2a1a15;           /* the questions, engraved in the pearl */
  --pearl: #efe9df;         /* the mother-of-pearl, under its colours */
  --ivory: #fbf6ea;         /* the white keys */
  --ebony: #15110f;         /* the black keys and the bed they sit in */
  --chrome: #c9cdd2;        /* the trims, the tab and the corners of the bellows */
  --cloth: #8f101c;         /* the red cloth of the bellows */
  --cloth-deep: #4f0710;    /* the tape along its edges, and the deep of the folds */
  --gold: #f1c76c;          /* the answer, stamped in gold leaf */
  --gold-light: #fff2cc;    /* where the gold catches the light */
  --focus: #8f101c;         /* the ring of the keyboard focus */

  /* the measures (the script reads them) */
  --row: 80px;              /* a question's row */
  --keys: 60px;             /* the keyboard on its left */
  --face: 26px;             /* a face of the bellows: one line of the answer */
  --text-x: 82px;           /* where the questions and the answers start */
  --text-r: 34px;           /* the room on the right of the answers */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Roboto Serif Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

/* the script gives the list a fixed height, with room for every question and the tallest open bellows, so its top
   never moves while the answers open and close */
.faq {
  position: relative;
  width: min(640px, 100%);
  -webkit-user-select: none;
  user-select: none;
}

.faq__item {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  will-change: transform;
}

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

/* ---------------------------------------------------------------- the question: a piece of the treble side */
.faq__q {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--row);
  margin: 0;
  padding: 0 64px 3px var(--text-x);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--ebony);
  color: var(--ink);
  font: inherit;
  font-size: 19px;
  font-weight: 560;
  line-height: 1.18;
  letter-spacing: -0.006em;
  font-variation-settings: 'opsz' 30, 'wdth' 92, 'GRAD' 0;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: font-variation-settings 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.faq__item:first-of-type .faq__q {
  border-radius: 16px 16px 0 0;
}

/* the chrome trim under the pearl, where the bellows is fixed */
.faq__q::after {
  content: '';
  position: absolute;
  left: var(--keys);
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(180deg, #fbfcfd 0%, var(--chrome) 40%, #6d737a 100%);
}

/* the chrome trim between the keys and the pearl */
.faq__q::before {
  content: '';
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: var(--keys);
  width: 3px;
  background: linear-gradient(90deg, #7b8188 0%, #fbfcfd 45%, var(--chrome) 70%, #5d636a 100%);
}

.faq__q:focus-visible {
  outline: none;
}

.faq__q:focus-visible .faq__plate::after {
  box-shadow: inset 0 0 0 2px var(--focus), inset 0 0 0 4px rgba(255, 255, 255, 0.75);
}

/* the keys: the script lays out five white keys and the black ones between them, and presses them */
.faq__keys {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--keys);
  background: var(--ebony);
}

.key {
  --p: 0;
  position: absolute;
  left: 0;
  right: 1px;
  border-radius: 0 2px 2px 0;
  transform-origin: 100% 50%;
  transform: scaleX(calc(1 - var(--p) * 0.045));
}

.key--white {
  background: linear-gradient(90deg, #e3dccb 0%, var(--ivory) 9%, var(--ivory) 70%, #efe7d4 100%);
  box-shadow: inset 0 -1px 0 rgba(60, 40, 20, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  border-radius: 3px 0 0 3px;
}

.key--black {
  z-index: 1;
  left: auto;
  right: 0;
  width: 56%;
  background: linear-gradient(180deg, #4a4340 0%, #231d1b 30%, #0c0a09 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 0, 0, 0.45);
  border-radius: 2px 0 0 2px;
}

/* a pressed key sinks: it darkens and the keys beside it shade its edges */
.key::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(40, 24, 10, 0.55), rgba(40, 24, 10, 0.12) 35%, rgba(40, 24, 10, 0.12) 65%, rgba(40, 24, 10, 0.45));
  opacity: calc(var(--p) * 0.75);
}

/* the mother-of-pearl plate */
.faq__plate {
  position: absolute;
  left: calc(var(--keys) + 3px);
  right: 0;
  top: 0;
  bottom: 3px;
  overflow: hidden;
  background: var(--pearl);
}

.faq__pearl {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='720' height='240'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0042 0.021' numOctaves='3' seed='9' stitchTiles='stitch'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='table' tableValues='0.1 1 0.2 0.85 0.35 1 0.2'/%3E%3CfeFuncG type='table' tableValues='0.3 0.9 0.15 1 0.45 0.8 0.3'/%3E%3CfeFuncB type='table' tableValues='0.2 1 0.35 0.75 0.1 1 0.4'/%3E%3CfeFuncA type='table' tableValues='1 1'/%3E%3C/feComponentTransfer%3E%3CfeColorMatrix type='matrix' values='0.21 0 0 0 0.77 0 0.16 0 0 0.8 0 0 0.22 0 0.75 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
  background-size: 720px 240px;
}

.faq__item:nth-of-type(2) .faq__pearl { background-position: -180px -80px; }
.faq__item:nth-of-type(3) .faq__pearl { background-position: -60px -160px; }
.faq__item:nth-of-type(4) .faq__pearl { background-position: -300px -40px; }
.faq__item:nth-of-type(5) .faq__pearl { background-position: -420px -120px; }

/* the colours that run over the pearl as it turns in the light: the script moves them with the pointer */
.faq__sheen {
  --sx: 30%;
  position: absolute;
  inset: 0;
  background: linear-gradient(104deg, rgba(255, 255, 255, 0) 18%, rgba(255, 170, 205, 0.55) 32%, rgba(255, 236, 190, 0.6) 40%, rgba(160, 240, 215, 0.55) 48%, rgba(165, 195, 255, 0.55) 57%, rgba(255, 255, 255, 0) 72%);
  background-size: 300% 100%;
  background-position: var(--sx) 0;
  mix-blend-mode: soft-light;
}

/* the lacquer over the pearl */
.faq__plate::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 36%, rgba(255, 255, 255, 0) 70%, rgba(70, 40, 25, 0.1) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.faq__text {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.faq__q:active .faq__text {
  transform: translateY(0.5px);
}

/* the register tab: a chrome rocker with a chevron cut into it; the script turns it over */
.faq__tab {
  position: absolute;
  z-index: 1;
  right: 22px;
  top: calc(50% - 13px);
  width: 36px;
  height: 22px;
  perspective: 120px;
}

.faq__rocker {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff 0%, #e4e7ea 30%, #a9afb5 52%, #d9dde1 78%, #f6f7f8 100%);
  box-shadow: inset 0 0 0 1px rgba(40, 46, 52, 0.28), inset 0 1px 0 #ffffff, 0 1px 1px rgba(30, 20, 15, 0.35), 0 3px 6px -2px rgba(30, 20, 15, 0.35);
}

.faq__rocker svg {
  width: 16px;
  height: 10px;
  overflow: visible;
}

.faq__rocker path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.faq__cut {
  stroke: #3b4148;
}

.faq__cut-lo {
  stroke: rgba(255, 255, 255, 0.95);
}

@media (hover: hover) and (pointer: fine) {
  .faq__q:hover {
    font-variation-settings: 'opsz' 30, 'wdth' 92, 'GRAD' 120;
  }
}

/* ---------------------------------------------------------------- the bellows (laid out by the script) */
.faq__bellows {
  position: relative;
  height: 0;
}

.bel__face {
  position: absolute;
  left: 0;
  top: 0;
  height: var(--face);
  overflow: hidden;
  transform-origin: 0 0;
  backface-visibility: hidden;
  background-color: var(--cloth);
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.09) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, rgba(255, 255, 255, 0) 1px 3px);
}

/* the tape along both edges of the bellows, with a gold thread in it */
.bel__face::before,
.bel__face::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 11px;
}

.bel__face::before {
  left: 0;
  background: linear-gradient(90deg, var(--cloth-deep) 0 6px, rgba(241, 199, 108, 0.75) 6px 7px, var(--cloth-deep) 7px 100%);
}

.bel__face::after {
  right: 0;
  background: linear-gradient(270deg, var(--cloth-deep) 0 6px, rgba(241, 199, 108, 0.75) 6px 7px, var(--cloth-deep) 7px 100%);
}

/* one line of the answer, stamped in gold */
.bel__line {
  --g: 40%;
  position: absolute;
  left: var(--text-x);
  top: 0;
  height: var(--face);
  line-height: var(--face);
  white-space: nowrap;
  font-size: 16px;
  font-weight: 520;
  font-variation-settings: 'opsz' 16, 'wdth' 100, 'GRAD' 0;
  letter-spacing: 0.004em;
  color: var(--gold);
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 30%, #c99536 46%, var(--gold-light) 58%, var(--gold) 76%, #b8842c 100%);
  background-size: 100% 320%;
  background-position: 0 var(--g);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* the chrome corners on the outer folds: half on each face, they meet on the fold */
.bel__guard {
  position: absolute;
  width: 30px;
  height: 8px;
}

.bel__guard--l {
  left: 0;
}

.bel__guard--r {
  right: 0;
}

.bel__face--down .bel__guard {
  top: 0;
  background: linear-gradient(180deg, #ffffff 0%, var(--chrome) 35%, #8a9097 75%, #5b6168 100%);
}

.bel__face--up .bel__guard {
  bottom: 0;
  background: linear-gradient(0deg, #ffffff 0%, var(--chrome) 35%, #8a9097 75%, #5b6168 100%);
}

/* tapered towards the middle, like a bent metal corner */
.bel__face--down .bel__guard--l { clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%); }
.bel__face--down .bel__guard--r { clip-path: polygon(0 0, 100% 0, 100% 100%, 22% 100%); }
.bel__face--up .bel__guard--l { clip-path: polygon(0 0, 78% 0, 100% 100%, 0 100%); }
.bel__face--up .bel__guard--r { clip-path: polygon(22% 0, 100% 0, 100% 100%, 0 100%); }

/* the deep of the fold, darker the deeper it goes */
.bel__ao {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.bel__face--down .bel__ao {
  background: linear-gradient(0deg, rgba(30, 0, 5, 0.7) 0%, rgba(30, 0, 5, 0.18) 45%, rgba(30, 0, 5, 0) 75%);
}

.bel__face--up .bel__ao {
  background: linear-gradient(180deg, rgba(30, 0, 5, 0.7) 0%, rgba(30, 0, 5, 0.18) 45%, rgba(30, 0, 5, 0) 75%);
}

/* how much light the face turns towards: the script sets its colour */
.bel__shade {
  position: absolute;
  inset: 0;
}

/* the frame at the bottom of the bellows */
.bel__plate {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7px;
  transform-origin: 0 0;
  background: linear-gradient(180deg, #2a1714 0%, #120c0b 55%, #fbfcfd 56%, var(--chrome) 75%, #6d737a 100%);
}

/* the shadow the question casts on the bellows under it */
.bel__lip {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 12px;
  background: linear-gradient(180deg, rgba(25, 0, 4, 0.55), rgba(25, 0, 4, 0));
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the end of the instrument */
.faq__foot {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 50%, rgba(70, 40, 25, 0.14)),
    linear-gradient(90deg, var(--ebony) 0 var(--keys), #6d737a var(--keys), #fbfcfd calc(var(--keys) + 1.5px), #6d737a calc(var(--keys) + 3px), var(--pearl) calc(var(--keys) + 3px));
  box-shadow: 0 26px 40px -22px rgba(70, 18, 12, 0.5);
}

/* the answer's words, set at the width of the bellows to find its lines */
.faq__measure {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  font-size: 16px;
  font-weight: 520;
  font-variation-settings: 'opsz' 16, 'wdth' 100, 'GRAD' 0;
  letter-spacing: 0.004em;
  line-height: var(--face);
}

/* the answer for screen readers: the region is there, the words are drawn on the bellows */
.faq__a {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 520px) {
  :root {
    --row: 72px;
    --keys: 46px;
    --face: 25px;
    --text-x: 62px;
    --text-r: 20px;
  }

  .faq__q {
    padding-right: 56px;
    font-size: 16.5px;
    line-height: 1.16;
  }

  .faq__tab {
    right: 14px;
    width: 32px;
    height: 20px;
    top: calc(50% - 12px);
  }

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

  .bel__guard {
    width: 23px;
  }

  .bel__face::before,
  .bel__face::after {
    width: 9px;
  }
}

/* una casella bassa (l'anteprima sul telefono, 341 per 410): righe, pieghe e caratteri più piccoli, così le cinque
   domande e il mantice più alto stanno in altezza senza rimpicciolirsi (lo script rilegge le misure) */
@media (max-width: 520px) and (max-height: 520px) {
  :root {
    --row: 44px;
    --keys: 38px;
    --face: 18px;
    --text-x: 50px;
    --text-r: 12px;
  }

  .stage {
    padding: 8px 14px;
  }

  .faq__q {
    padding-right: 50px;
    font-size: 14px;
    line-height: 1.12;
  }

  .faq__item:first-of-type .faq__q {
    border-radius: 12px 12px 0 0;
  }

  .faq__foot {
    border-radius: 0 0 12px 12px;
  }

  .faq__tab {
    right: 10px;
    width: 30px;
    height: 18px;
    top: calc(50% - 11px);
  }

  .bel__line,
  .faq__measure {
    font-size: 12.5px;
  }

  .bel__guard {
    width: 18px;
    height: 6px;
  }

  .bel__face::before,
  .bel__face::after {
    width: 8px;
  }
}
