/* The tabbed folders */
:root {
  --blue: #2343e6;
  --paper: #f7f5ee;
  --ink: #0e1440;
  --grid: rgba(255, 255, 255, 0.12);
  --edge: clamp(16px, 3vw, 40px);
  --top: 58px;      /* where the folders stick: the older ones rise a little above it */
  --tab: 46px;      /* how tall the tabs are */
  --slant: 22px;    /* how wide the tab's slanted side is */
}

* { box-sizing: border-box; }
html,
body {
  margin: 0;
}
body {
  background-color: var(--blue);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--paper);
  font-family: 'Geist Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
}

.top {
  padding: var(--edge) var(--edge) 0;
}
.brand {
  margin: 0 0 4px;
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-size: clamp(19px, 1.7vw, 22px);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.01em;
}
.top__line {
  margin: 0;
  font-size: 12px;
  font-weight: 450;
  opacity: 0.82;
}

.intro,
.drawer,
.outro {
  max-width: 1240px;
  margin: 0 auto;
}
.intro {
  padding: 11vh var(--edge) 15vh;
}
.intro__title {
  margin: 0 0 0.3em;
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-size: clamp(3rem, 11.5vw, 9.6rem);
  font-weight: 800;
  font-stretch: 108%;
  letter-spacing: -0.025em;
  line-height: 0.92;
}
.intro__text {
  max-width: 46ch;
  margin: 0;
  font-size: clamp(0.88rem, 0.82rem + 0.3vw, 1.04rem);
  font-weight: 450;
  line-height: 1.55;
}

/* ---- the drawer: every folder sticks at the same height and the next one slides over it ---- */
.drawer {
  --body: min(calc(100svh - var(--top) - var(--tab) - 34px), 540px);
  padding: 0 var(--edge);
  list-style: none;
}
/* a sticky box has to stay inside its container's content, margin included: this empty stretch after the last folder
   is what lets the whole pile hold still for a while, and then leave together */
.drawer::after {
  content: '';
  display: block;
  height: 36vh;
}
.folder {
  position: sticky;
  top: var(--top);
  margin: 0 0 14vh;
  /* an older folder rises a little for every one that lands on it (the script writes --rise) */
  transform: translateY(var(--rise, 0px));
  will-change: transform;
  /* the row is empty except for the tab: clicks have to reach the tabs of the folders underneath */
  pointer-events: none;
}
.folder__row {
  height: var(--tab);
}
/* the tab: one place further along for every folder, so that piled up they fill the row */
.folder__tab {
  position: relative;
  display: block;
  width: calc(100% / var(--count) - var(--slant));
  height: 100%;
  margin-left: calc(var(--n) * 100% / var(--count));
  padding: 0 4px 0 16px;
  border: 0;
  border-radius: 12px 0 0 0;
  background: var(--tint);
  color: var(--on);
  font: inherit;
  font-size: 13px;
  font-weight: 620;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}
.folder__tab::after {
  content: '';
  position: absolute;
  left: calc(100% - 0.5px);
  top: 0;
  width: calc(var(--slant) + 0.5px);
  height: 100%;
  background: inherit;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}
.folder__tab span {
  display: inline-block;
  opacity: 0.6;
  transition: opacity 0.25s ease;
}
.folder.is-front .folder__tab span,
.folder__tab:focus-visible span {
  opacity: 1;
}
@media (hover: hover) {
  .folder__tab:hover span {
    opacity: 1;
  }
}
.folder__tab:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}
.folder__body {
  height: var(--body);
  overflow: hidden;
  border-radius: 16px;
  background: var(--tint);
  color: var(--on);
  box-shadow: 0 -14px 34px rgba(14, 20, 64, 0.22);
  pointer-events: auto;
}
/* no round corner where the tab joins the body */
.folder:first-child .folder__body { border-top-left-radius: 0; }
.folder:last-child .folder__body { border-top-right-radius: 0; }

.folder__inside {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(16px, 3vw, 44px);
  height: 100%;
  padding: clamp(18px, 2.6vw, 36px);
  /* a folder being covered loses its content (the script writes --fade) */
  opacity: var(--fade, 1);
}
.folder__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.folder__date {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.78;
}
.folder__title {
  margin: 0 0 14px;
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-size: clamp(2rem, 4.6vw, 4.2rem);
  font-weight: 800;
  font-stretch: 100%;
  letter-spacing: -0.02em;
  line-height: 0.96;
}
.folder__line {
  max-width: 30ch;
  margin: 0;
  font-size: clamp(0.86rem, 0.8rem + 0.28vw, 1.02rem);
  font-weight: 450;
  line-height: 1.5;
}
/* the labels are small folders too */
.folder__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: auto 0 0;
  padding: 0;
  list-style: none;
}
.folder__tags li {
  padding: 14px 12px 7px;
  background: var(--on);
  color: var(--tint);
  font-size: 12px;
  font-weight: 620;
  line-height: 1.2;
  clip-path: polygon(0 0, 40% 0, calc(40% + 7px) 7px, 100% 7px, 100% 100%, 0 100%);
}

/* the picture sits in a selection frame, with its four handles */
.folder__art {
  position: relative;
  min-height: 0;
  margin: 0;
  border: 1.5px solid var(--on);
}
.folder__art svg {
  display: block;
  width: 100%;
  height: 100%;
}
.folder__art i {
  position: absolute;
  width: 11px;
  height: 11px;
  margin: -6.25px;
  border: 1.5px solid var(--on);
  background: var(--tint);
}
.folder__art i:nth-of-type(1) { left: 0; top: 0; }
.folder__art i:nth-of-type(2) { left: 100%; top: 0; }
.folder__art i:nth-of-type(3) { left: 0; top: 100%; }
.folder__art i:nth-of-type(4) { left: 100%; top: 100%; }

.outro {
  padding: 8vh var(--edge) 34vh;
}
.outro__text {
  margin: 0;
  font-family: 'Anybody Variable', system-ui, sans-serif;
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 800;
  font-stretch: 108%;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---- phones: narrower tabs, the picture under the text ---- */
@media (max-width: 760px) {
  :root {
    --top: 46px;
    --tab: 40px;
    --slant: 13px;
  }
  .folder__tab {
    padding-left: 9px;
    border-radius: 9px 0 0 0;
    font-size: 11px;
  }
  .folder__inside {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .folder__tags {
    margin-top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .folder__tab span {
    transition: none;
  }
}
