:root {
  --fondo: #ffffff;
  --carta: #efece6;
  --carta-scura: #e4e0d8;
  --foglio: #ffffff;
  --grafite: #1b1c20;
  --grafite-chiara: #2a2c32;
  --inchiostro: #1c1d21;
  --grigio: #7b7a80;
  --tenue: #b5b3b8;
  --accento: #4d63ff;
  --accento-tenue: rgba(77, 99, 255, 0.09);
  --font: 'Mona Sans Variable', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

/* the folder: width, height and the row step are set by script.js from the window */
.folder {
  position: relative;
  width: var(--w, 320px);
  height: var(--h, 360px);
  perspective: 700px;
}

/* the back of the folder, with its tab: it grows when the menu opens */
.folder__back {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 120px;
  border-radius: 4px 16px 18px 18px;
  background:
    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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--carta), var(--carta-scura));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 0 0 1px rgba(28, 29, 33, 0.06) inset,
    0 2px 4px rgba(28, 29, 33, 0.05),
    0 18px 40px -18px rgba(28, 29, 33, 0.3);
}
.folder__tab {
  position: absolute;
  left: 0; bottom: 100%;
  width: 124px; height: 26px;
  margin-bottom: -1px;
}
.folder__tab-shape {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  fill: var(--carta);
  filter: drop-shadow(0 -1px 0 rgba(28, 29, 33, 0.06));
}
.folder__tab-label {
  position: relative;
  display: block;
  padding: 7px 0 0 14px;
  font-size: 11.5px;
  font-weight: 620;
  letter-spacing: 0.01em;
  color: #5e5d63;
  font-variation-settings: 'wdth' 100;
}
.folder__hint, .folder__keys {
  position: absolute;
  top: 9px;
  font-size: 11.5px;
  color: var(--grigio);
  opacity: 0;
}
.folder__hint { left: 16px; font-weight: 560; }
.folder__keys { right: 14px; top: 7px; }
.folder__keys kbd {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 600 10.5px/1 var(--font);
  color: #55545a;
  border-radius: 6px;
  background: linear-gradient(180deg, #fff, #f4f2ee);
  box-shadow: 0 0 0 1px rgba(28, 29, 33, 0.09), 0 1px 0 rgba(28, 29, 33, 0.12);
}

/* the sheets: one place each */
.sheets { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
.sheet {
  position: absolute;
  left: 10px; right: 10px; top: 0;
  height: var(--sheet, 38px);
  will-change: transform;
}
.sheet__btn {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; height: 100%;
  padding: 0 12px 0 11px;
  border-radius: 11px;
  background: linear-gradient(180deg, #ffffff, #fbfbfa);
  box-shadow:
    0 0 0 1px rgba(28, 29, 33, 0.07),
    0 1px 0 rgba(255, 255, 255, 1) inset,
    0 1px 2px rgba(28, 29, 33, 0.06),
    0 6px 14px -10px rgba(28, 29, 33, 0.35);
  text-align: left;
  transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background-color 0.3s ease;
}
.sheet__btn::before {
  /* the top edge of the sheet that peeks out of the pocket; the current place has it in the accent */
  content: '';
  position: absolute;
  left: 12px; right: 12px; top: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: transparent;
  transition: background-color 0.3s ease;
}
.sheet.is-current .sheet__btn::before { background: var(--accento); }
.folder.is-open .sheet__btn::before { background: transparent; }
.sheet__end { flex: none; position: relative; display: flex; align-items: center; justify-content: flex-end; min-width: 34px; }
.sheet__icon {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: #f3f2f0;
  box-shadow: 0 0 0 1px rgba(28, 29, 33, 0.05) inset;
  transition: background-color 0.3s ease, transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sheet__icon svg { width: 16px; height: 16px; fill: none; stroke: #3a3b41; stroke-width: 1.45; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.3s ease; }
.sheet__label {
  flex: 1; min-width: 0;
  font-size: 14px;
  font-weight: 560;
  letter-spacing: -0.005em;
  white-space: nowrap;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease;
}
.sheet__meta {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--grigio);
  transition: opacity 0.25s ease;
}
.sheet__check {
  position: absolute; right: 0; top: 50%;
  width: 16px; height: 16px; margin-top: -8px;
  fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sheet__check path { stroke-dasharray: 14; stroke-dashoffset: 14; }
.sheet.is-current .sheet__check path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.4s 0.08s cubic-bezier(0.65, 0, 0.35, 1); }
.sheet.is-current .sheet__meta { opacity: 0; }
.sheet.is-current .sheet__label { color: var(--accento); }
.sheet.is-current .sheet__icon { background: var(--accento-tenue); }
.sheet.is-current .sheet__icon svg { stroke: var(--accento); }

/* hover (or the pilot): the sheet is pulled a little out of the stack, its neighbours feel it */
.sheet.is-hot .sheet__btn {
  transform: translateX(7px);
  box-shadow:
    0 0 0 1px rgba(28, 29, 33, 0.08),
    0 1px 0 rgba(255, 255, 255, 1) inset,
    0 2px 4px rgba(28, 29, 33, 0.07),
    0 14px 24px -12px rgba(28, 29, 33, 0.38);
}
.sheet.is-near .sheet__btn { transform: translateX(2px); }
.sheet.is-hot .sheet__label { font-variation-settings: 'wdth' 112; }
.sheet.is-hot .sheet__icon { transform: rotate(-6deg) scale(1.06); }
.sheet.is-press .sheet__btn { transform: translateX(5px) scale(0.985); transition-duration: 0.12s; }

/* the pocket: the front of the folder, the button of the menu */
.pocket {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--pocket, 66px);
  z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px 4px 12px;
  border-radius: 14px 14px 18px 18px;
  color: #fff;
  text-align: left;
  background:
    radial-gradient(120% 140% at 20% -30%, rgba(255, 255, 255, 0.1), transparent 55%),
    linear-gradient(180deg, var(--grafite-chiara), var(--grafite));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16) inset,
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 -10px 18px -12px rgba(28, 29, 33, 0.45),
    0 10px 22px -10px rgba(28, 29, 33, 0.45);
  transform-origin: 50% 100%;
}
.pocket__shade {
  /* a soft light that runs along the lip of the pocket */
  position: absolute; left: 14px; right: 14px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  opacity: 0.6;
}
.pocket__icon {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(160deg, #6a7cff, var(--accento) 55%, #3a4ee0);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 6px 14px -6px rgba(77, 99, 255, 0.8);
  overflow: hidden;
}
.pocket__icon svg { width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; grid-area: 1 / 1; }
.pocket__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pocket__roll { position: relative; display: block; height: 19px; overflow: hidden; }
.pocket__name { position: absolute; left: 0; top: 0; font-size: 15px; font-weight: 620; line-height: 19px; letter-spacing: -0.01em; white-space: nowrap; }
.pocket__meta { font-size: 11.5px; color: rgba(255, 255, 255, 0.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.pocket__toggle {
  flex: none;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: background-color 0.3s ease;
}
.pocket__toggle svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pocket__meter {
  position: absolute; left: 62px; right: 56px; bottom: 9px;
  height: 2px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.pocket__fill { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, #8a98ff, var(--accento)); transform-origin: 0 50%; transform: scaleX(0.368); }
@media (hover: hover) {
  .pocket:hover .pocket__toggle { background: rgba(255, 255, 255, 0.14); }
}

.pointer {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: #1c1d21; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pocket:focus:not(:focus-visible), .sheet__btn:focus:not(:focus-visible) { outline: none; }
.pocket:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }
.sheet__btn:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .sheet__btn, .sheet__icon, .sheet__label { transition: none; }
  .sheet.is-hot .sheet__btn, .sheet.is-near .sheet__btn, .sheet.is-press .sheet__btn, .sheet.is-hot .sheet__icon { transform: none; }
  .sheet.is-hot .sheet__btn { background: #f7f7f9; }
}
