/* ==================================================================
   Nilesh's Files — archive portfolio
   Design system ported from the Mosby's Files folder-archive layout.
   ================================================================== */

/* ---------- 1. Fonts -------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=IBM+Plex+Mono:wght@400;700&family=Newsreader:opsz,wght@6..72,200..600&display=swap');

/* ---------- 2. Reset -------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

* { -webkit-tap-highlight-color: transparent; }

body { margin: 0; }

img {
  border-style: none;
  -webkit-user-select: none;
  user-select: none;
  max-width: 100%;
  /* width/height attributes are present for CLS; let CSS width win on size */
  height: auto;
}

a, h1, h2, h3, h4, h5, h6, li, ol, p, span, ul {
  margin: 0;
  padding: 0;
}

ul, ol { list-style: none; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* ---------- 3. Root scale --------------------------------------- */

html {
  font-family: var(--font-serif);
  font-weight: 300;
  line-height: 1.25;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
}

@media only screen and (min-width: 1025px) { html { font-size: 15px; } }
@media only screen and (min-width: 1440px) { html { font-size: 16px; } }
@media only screen and (min-width: 1920px) { html { font-size: 18px; } }
@media only screen and (max-width: 1024px) { html { font-size: 14px; } }
@media only screen and (max-width: 900px)  { html { font-size: 14px; } }
@media only screen and (max-width: 768px)  { html { font-size: 13px; } }
@media only screen and (max-width: 480px)  { html { font-size: 13px; } }
@media only screen and (max-width: 320px)  { html { font-size: 12px; } }

:root {
  /* type */
  --font-display: 'Anton', 'Arial Narrow', 'Haettenschweiler', sans-serif;
  --font-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  /* colour */
  --color-light: #fdfaf7;
  --color-gray: #787a7f;
  --color-dark: #191919;
  --color-primary: var(--color-dark);
  --color-contrast: var(--color-light);
  --color-paper: #fffcf9;

  /* stack geometry — ported verbatim */
  --stack-border-radius: 4px;
  --stack-group-height-sm: 20vw;
  --stack-group-height-lg: 80vh;
  --stack-group-offset: 3.75rem;
  --stack-perspective: 3000px;
  --stack-rotation-angle: -3deg;
  --stack-rotation-offset: 1rem;
  --stack-shadow: 0 -1px 8px rgba(0, 0, 0, .15);
  --folder-shadow: 1px 0 8px rgba(0, 0, 0, .15);
  --tag-height: 2.75rem;
  --tag-aspect-ratio: 1.409;

  --ease: cubic-bezier(.33, 1, .68, 1);

  /* Anton's caps are 0.86em tall; Founders Grotesk X-Condensed (the
     reference face) is 0.63em. Same font-size therefore renders 36%
     larger here, and a 0.8 line-height clips Anton's ascenders and
     overlaps its lines. Correct the size, and carry the reference's
     optical leading across at the corrected size. */
  --display-scale: 0.733;
  --display-leading: 1.1;

  /* procedural paper grain — no external assets, no licensing */
  --texture-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
  --texture-fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.015 0.55' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.55'/%3E%3C/svg%3E");

  --container-offset: 32px;
  --container-size: calc(var(--vw, 100vw) - var(--container-offset) * 2);
}

@media only screen and (max-aspect-ratio: 2/1) { :root { --stack-group-height-sm: 15vw; } }
@media only screen and (max-width: 1024px) { :root { --stack-group-height-sm: 20vh; } }
@media only screen and (max-width: 480px)  { :root { --stack-group-height-sm: 15vh; } }
@media only screen and (max-width: 768px)  { :root { --tag-height: 2.25rem; } }

@media only screen and (min-width: 1440px) { :root { --container-offset: 34px; } }
@media only screen and (min-width: 1920px) { :root { --container-offset: 48px; } }
@media only screen and (max-width: 1024px) { :root { --container-offset: 30px; } }
@media only screen and (max-width: 768px)  { :root { --container-offset: 20px; } }
@media only screen and (max-width: 480px)  { :root { --container-offset: 18px; } }

@media only screen and (min-width: 1025px) {
  :root { --case-content-width: calc((var(--container-size) - 19 * 1rem) * 16 / 20 + 15rem); }
}
@media only screen and (max-width: 1024px) {
  :root { --case-content-width: calc(var(--container-size) - var(--tag-height)); }
}

/* ---------- 4. Typography --------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  margin: 0;
}

.heading-1,
.heading-2 {
  font-weight: 400;
  line-height: var(--display-leading);
  text-transform: uppercase;
  letter-spacing: -0.005em;
}

.heading-1 { font-size: calc(clamp(4rem, 2.25rem + 5.833vw, 7.5rem) * var(--display-scale)); }
.heading-2 { font-size: calc(clamp(2.66rem, 1.49rem + 3.9vw, 5rem) * var(--display-scale)); }

.heading-3 {
  font-size: clamp(2rem, 1.429rem + 2.857vw, 4rem);
  font-weight: 400;
  line-height: .92;
}

.heading-4 {
  font-size: calc(2rem * var(--display-scale));
  font-weight: 400;
  line-height: var(--display-leading);
  letter-spacing: -0.005em;
}

.heading-5 { font-size: 1.125rem; font-weight: 400; line-height: 1.16; }

.par-1 {
  font-size: clamp(1rem, .875rem + .417vw, 1.25rem);
  line-height: 1.4;
}

.par-2,
.caption {
  font-family: var(--font-mono);
  line-height: 1.4;
}

.par-2   { font-size: 1.125rem; }
.caption { font-size: clamp(.75rem, 0rem + .833vw, 1rem); }

.logo {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1;
  margin-top: -.05em;
  padding-bottom: .05em;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.--upp { text-transform: uppercase; }

/* ---------- 5. Layout shell ------------------------------------- */

body {
  font-size: 1rem;
  background-color: var(--color-primary);
  color: var(--color-contrast);
}

body, html { overflow-x: clip; }
html.is-scroll-disabled { overflow: hidden; }

.__app {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.__app,
.__page { overflow: clip; }

.__page {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  width: 100%;
}

.container {
  display: flex;
  justify-content: flex-start;
  margin-inline: var(--container-offset);
  width: var(--container-size);
}

.rich-text { width: 100%; }

/* Lenis */
html.lenis { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden !important; }

/* Intro gate */
.__app.is-loading .section-hero__title,
.__app.is-loading .section-hero__desc,
.__app.is-loading .stack,
.__app.is-loading .case-hero-title,
.__app.is-loading .page-about { opacity: 0; }

/* The case folder itself stays painted — its cover simply starts closed,
   so the first frame is a shut folder rather than an empty screen. */
.__app.is-loading .case-folder__cover { transform: rotateY(0); }

/* ---------- 6. Header ------------------------------------------- */

.the-header,
.the-sub-header {
  backdrop-filter: blur(100px);
  -webkit-backdrop-filter: blur(100px);
  background-color: rgba(25, 25, 25, .8);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  left: 0;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  transition: transform .65s var(--ease);
}

.the-header.is-hidden,
.the-sub-header.is-hidden,
.is-loading .the-header,
.is-loading .the-sub-header {
  transform: translateY(-100%);
  transition: transform .325s var(--ease);
}

.the-header__content {
  align-items: center;
  height: 3.75rem;
  justify-content: flex-end;
  position: relative;
}

.the-header__logo {
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.the-header__logo a { display: flex; }

.the-sub-header__content {
  align-items: center;
  height: 3.75rem;
  justify-content: space-between;
  position: relative;
}

.the-sub-header__title { font-size: 1.375rem; }

/* sits above the main header, which stays put underneath it */
.the-sub-header { z-index: 1001; }

.the-sub-header__controls { display: flex; gap: 1.5rem; }

.the-sub-header__controls a {
  display: flex;
  opacity: .45;
  transition: opacity .4s var(--ease);
}

.the-sub-header__controls a:hover { opacity: 1; }

.the-nav {
  display: grid;
  grid-gap: 2.5rem;
  grid-auto-flow: column;
}

.the-nav__item {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 2rem;
  opacity: .8;
  transition: opacity .65s;
}

@media (hover: hover) { .the-nav__item:hover { opacity: 1; } }
.the-nav__item.is-active { opacity: 1; }

@media only screen and (max-width: 560px) {
  .the-header__logo { font-size: 1.375rem; }
}

/* ---------- 7. Hero --------------------------------------------- */

.section-hero {
  height: 100vh;
  /* top padding clears the fixed header, so the title keeps its distance
     from it at rest and has room to spare once the page starts scrolling */
  padding-block: calc(3.75rem + 1.875rem) calc(var(--stack-group-offset) * 5);
}

@media only screen and (max-aspect-ratio: 2/1) {
  .section-hero {
    padding-block: calc(3.75rem + 1.875rem)
                   calc(var(--stack-group-offset) * 3.5 + var(--stack-group-height-sm));
  }
}

.section-hero__inner {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  height: 100%;
  justify-content: center;
  text-align: center;
  text-wrap: balance;
  width: 100%;
}

@media only screen and (max-aspect-ratio: 2/1) {
  .section-hero__inner { gap: 1.25rem; }
}

.section-hero__title {
  font-size: clamp(1px, (var(--vw, 100vw) - var(--container-offset) * 2) * .0872, 200px);
}

@media only screen and (max-aspect-ratio: 2/1) {
  .section-hero__title { font-size: clamp(1px, (var(--vw, 100vw) - var(--container-offset) * 2) * .0770, 200px); }
}
@media only screen and (max-width: 1024px) {
  .section-hero__title { font-size: clamp(1px, (var(--vw, 100vw) - var(--container-offset) * 2) * .0953, 200px); }
}
@media only screen and (max-width: 768px) {
  .section-hero__title { font-size: clamp(1px, (var(--vw, 100vw) - var(--container-offset) * 2) * .1319, 200px); }
}
@media only screen and (max-width: 480px) {
  .section-hero__title { font-size: clamp(1px, (var(--vw, 100vw) - var(--container-offset) * 2) * .1686, 200px); }
}

.section-hero__title .line { margin-bottom: -.1em; }
.section-hero__title .char { padding-bottom: .1em; will-change: transform; }

.section-hero__desc {
  color: var(--color-gray);
  max-width: var(--container-size);
  text-wrap: balance;
  width: 50rem;
}

@media only screen and (max-width: 480px) {
  .section-hero__desc { font-size: 16px; }
}

/* Split-text primitives */
.line { position: relative; display: block; text-align: start; }
.word { position: relative; display: inline-block; }
.char-mask { position: relative; display: inline-block; overflow: clip; }
.char { position: relative; display: inline-block; }

/* ---------- 8. Stack -------------------------------------------- */

.page-home {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.stack {
  display: flex;
  flex-direction: column;
  height: calc(var(--stack-group-height-lg) + var(--stack-group-offset) * (var(--group-count) - 1));
  margin-inline: auto;
  margin-top: calc(var(--stack-group-offset) * var(--group-count) * -1);
  perspective: var(--stack-perspective);
  position: relative;
}

@media only screen and (max-aspect-ratio: 2/1) {
  .stack {
    margin-top: calc(
      var(--stack-group-offset) * var(--group-count) * -1
      - var(--stack-group-height-sm) + var(--stack-group-offset)
    );
  }
}

@media only screen and (min-width: 1025px) { .stack { width: calc(90% - .1rem); } }
@media only screen and (max-width: 1024px) { .stack { width: 100%; } }
@media only screen and (max-width: 480px)  { .page-home__stack { margin: 0; width: 100%; } }

.stack-group {
  --cover-color: var(--group-fg);
  --cover-bg-color: var(--group-bg);
  bottom: 0;
  height: calc(var(--stack-group-height-lg) + var(--stack-group-offset) * var(--group-offset));
  left: 0;
  right: 0;
  margin-top: calc(var(--stack-border-radius) * -1);
  position: absolute;
  transform-origin: bottom;
  transform-style: preserve-3d;
  will-change: height, transform;
  z-index: var(--group-index);
}

.__app:not(.is-loading) .stack-group {
  transition: transform .65s var(--ease), height .65s var(--ease);
}

.stack-group.is-rotated {
  height: calc(var(--stack-group-height-lg) + var(--stack-group-offset) * var(--group-offset) - 1rem);
  transform: rotateX(var(--stack-rotation-angle)) translateZ(calc(2px * var(--group-index)));
}

/* Folders sit bottom-anchored, so making one shorter slides its top edge
   down. Applied to every folder in front of the hovered one, this opens a
   gap wide enough to read the hovered folder's description. */
.stack-group.is-unfolded {
  height: calc(
    var(--stack-group-height-lg) - var(--stack-group-height-sm)
    + var(--stack-group-offset) + var(--stack-group-offset) * var(--group-offset)
  );
}

.stack-group.is-unfolded.is-rotated {
  height: calc(
    var(--stack-group-height-lg) - var(--stack-group-height-sm)
    + var(--stack-group-offset) + var(--stack-group-offset) * var(--group-offset) - 1rem
  );
}

.stack-group__inner {
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  width: 100%;
}

/* --- folder cover --- */

.stack-cover {
  align-items: flex-start;
  background-color: var(--cover-bg-color);
  border-radius: 4px 4px 0 0;
  bottom: 0;
  color: var(--cover-color);
  display: flex;
  height: 100%;
  justify-content: flex-end;
  left: 0;
  right: 0;
  padding: 0 2rem;
  pointer-events: none;
  position: absolute;
  transform-origin: bottom;
  transform-style: preserve-3d;
  z-index: 100;
  transition: transform .65s var(--ease);
}

.stack-cover::after {
  background: linear-gradient(0deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .05));
  border-radius: inherit;
  box-shadow: var(--stack-shadow);
  content: '';
  inset: 0;
  opacity: 0;
  position: absolute;
  z-index: 5;
  transition: opacity .65s var(--ease);
}

.stack-cover.is-hovered::after { opacity: 1; }

.stack-cover.is-rotated {
  transform: translateY(var(--stack-rotation-offset)) rotateX(var(--stack-rotation-angle));
}

.stack-cover__desc {
  align-self: center;
  left: 0;
  max-width: 85vh;
  padding-block-end: var(--container-offset);
  padding-inline: calc(var(--tag-height) * var(--tag-aspect-ratio));
  position: absolute;
  text-wrap: balance;
  top: var(--stack-group-offset);
  transform-style: preserve-3d;
}

@media only screen and (max-width: 480px) { .stack-cover__desc { display: none; } }

.stack-cover__category {
  align-items: center;
  display: inline-flex;
  gap: .5rem;
  line-height: var(--stack-group-offset);
}

@media only screen and (max-width: 768px) { .stack-cover__category { display: none; } }

.stack-cover__category svg {
  transform: rotate(90deg);
  transition: transform .65s var(--ease);
  flex-shrink: 0;
}

.stack-cover.is-unfolded .stack-cover__category svg { transform: rotate(0); }

.stack-cover .the-footer {
  bottom: 0;
  left: 0;
  right: 0;
  padding-block-end: calc(var(--container-offset) * 2);
  padding-inline: calc(var(--tag-height) * var(--tag-aspect-ratio));
  position: absolute;
  transform-style: preserve-3d;
  transition: transform .65s var(--ease);
}

.stack-cover .the-footer * { transform-style: preserve-3d; }
.stack-cover .the-footer a { pointer-events: auto; }

@media only screen and (min-aspect-ratio: 2/1) {
  .stack-cover:not(.is-unfolded) .the-footer {
    transform: translateY(var(--stack-group-height-sm));
  }
}

@media only screen and (max-width: 768px) {
  .stack-cover .the-footer,
  .stack-cover__desc { padding-inline: calc(var(--tag-height) * var(--tag-aspect-ratio) - .2rem); }
}
@media only screen and (max-width: 480px) {
  .stack-cover .the-footer,
  .stack-cover__desc { padding-inline: var(--container-offset); }
}

/* --- folder page (a case) --- */

.stack-page {
  --color: var(--page-fg);
  --bg-color: var(--page-bg);
  border-radius: var(--stack-border-radius) var(--stack-border-radius) 0 0;
  bottom: 0;
  height: 100%;
  left: 0;
  right: 0;
  position: absolute;
  transform: translateZ(0);
  transform-origin: bottom;
  transform-style: preserve-3d;
  width: 100%;
  z-index: var(--page-index);
  transition: transform .65s var(--ease);
}

.stack-page.is-rotated {
  transform: translateY(var(--stack-rotation-offset)) rotateX(var(--stack-rotation-angle));
}

.stack-page__bg {
  background-color: var(--bg-color);
  border-radius: inherit;
  inset: 0;
  position: absolute;
  z-index: -1;
}

.stack-page__header {
  align-items: center;
  bottom: 100%;
  display: flex;
  left: var(--stack-border-radius);
  pointer-events: none;
  position: absolute;
  transform-origin: left bottom;
  z-index: -2;
}

.stack-page__unfold-area {
  bottom: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 33%;
  z-index: 5;
}

/* --- tags (folder tabs) --- */

.tag {
  --color: var(--tag-fg);
  --bg-color: var(--tag-bg);
  align-items: flex-start;
  color: var(--color);
  display: flex;
  font-family: var(--font-serif);
  font-size: 1.625rem;
  height: var(--tag-height);
  margin-bottom: -1px;
  opacity: 0;
  pointer-events: none;
  position: relative;
  white-space: nowrap;
}

@media only screen and (max-width: 1024px) { .tag { font-size: 1.25rem; } }
@media only screen and (max-width: 768px) {
  .tag { font-size: 1.25rem; margin-left: -.2rem; margin-right: -.75rem; }
  .tag__middle span { margin-inline: -.33rem; }
}
@media only screen and (max-width: 480px) {
  .tag { font-size: 15px; margin-left: -.5rem; margin-right: -1rem; }
  .tag__middle span { margin-inline: -.66rem; }
  .tag__start, .tag__end { width: 3.25rem; }
}

.tag * { pointer-events: none; }
.tag { flex-shrink: 0; }

.tag__middle {
  align-items: center;
  background-color: var(--bg-color);
  display: flex;
  height: 100%;
  justify-content: center;
  z-index: 5;
}

.tag__start,
.tag__end {
  color: var(--bg-color);
  height: 100%;
  transform-origin: top;
}

.tag__start { transform: scale(-1, 1.01) translate(-1px); }
.tag__end   { transform: scaleY(1.01) translate(-1px); }

.tag__side-dummy {
  aspect-ratio: var(--tag-aspect-ratio);
  background-color: var(--bg-color);
  height: 100%;
}

.tag.is-visible { opacity: 1; pointer-events: auto; }

/* ---------- 9. Footer ------------------------------------------- */

.the-footer {
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: .75rem;
  /* tighter than the reference: this footer carries a contact row too, and
     has to clear the folder description sitting above it */
  gap: 2.25rem;
  text-transform: uppercase;
  transform: translateZ(1px);
  width: 100%;
}

.the-footer__marks {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: center;
}

.the-footer__mark {
  display: inline-flex;
  max-width: 4rem;
  transform-origin: center center;
  width: 100%;
}

.the-footer__mark img { width: 100%; height: auto; will-change: transform; }

@media only screen and (max-width: 480px) {
  .the-footer__mark.--hide-on-mobile { display: none; }
}

.the-footer__bottom {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
  position: relative;
}

.the-footer__scale,
.the-footer__year,
.the-footer__signature {
  margin-block: -1rem;
  padding-block: 1rem;
}

.the-footer__scale { width: 8.75rem; }

.the-footer__year {
  bottom: 0;
  left: 50%;
  position: absolute;
  transform: translate(-50%);
}

@media only screen and (max-width: 768px) { .the-footer__year { display: none; } }

.the-footer__signature {
  align-items: flex-end;
  display: flex;
  gap: 1.5rem;
  text-align: right;
  text-wrap: balance;
}

.the-footer__signature img { width: 2.5rem; flex-shrink: 0; }

.the-footer__contact {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.the-footer__contact a {
  opacity: .75;
  transition: opacity .4s var(--ease);
  text-decoration: underline;
  text-underline-offset: .3em;
  text-decoration-thickness: 1px;
}

.the-footer__contact a:hover { opacity: 1; }

@media only screen and (max-width: 560px) {
  .the-footer { gap: 2rem; }
  .the-footer__bottom { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .the-footer__signature { text-align: left; }
}

/* ---------- 10. Case page --------------------------------------- */

.page-case { --case-color: var(--page-color); }

.case-hero {
  margin-block-start: 3.75rem;
  padding-block: 3.75rem;
}

.case-hero-title {
  transform-origin: top left;
  z-index: 5;
}

.case-hero-title .line { margin-top: -.05em; }
.case-hero-title .char { padding-bottom: .05em; will-change: transform; }

.case-content {
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.case-content__inner { width: var(--case-content-width); }

.case-content__draggable-bounds {
  bottom: -3rem;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: calc(var(--case-content-width) * 1.12);
}

.case-folder {
  --case-color: var(--folder-color);
  perspective: var(--stack-perspective);
  position: relative;
  transform-origin: top right;
  width: 100%;
}

.case-folder__inner {
  background-color: var(--case-color);
  border-radius: 0 var(--stack-border-radius) var(--stack-border-radius) 0;
  height: 100%;
  width: 100%;
  padding: var(--container-offset);
  padding-inline-start: 0;
}

/* the flap that swings open on entry */
.case-folder__cover {
  border-radius: 0 var(--stack-border-radius) var(--stack-border-radius) 0;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  transform: rotateY(-180deg);
  transform-origin: left;
  transform-style: preserve-3d;
  width: 100%;
  z-index: 10;
  pointer-events: none;
}

.case-folder__cover__front,
.case-folder__cover__back {
  backface-visibility: hidden;
  border-radius: inherit;
  inset: 0;
  position: absolute;
}

.case-folder__cover__front { background: var(--case-color); z-index: 2; }

.case-folder__cover__back {
  background-color: var(--case-color);
  transform: rotateX(180deg);
}

.case-folder__cover__front__overlay,
.case-folder__cover__front__shadow,
.case-folder__cover__back__overlay {
  border-radius: inherit;
  inset: 0;
  position: absolute;
}

.case-folder__cover__front__overlay { background: linear-gradient(0deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .05)); }
.case-folder__cover__front__shadow { box-shadow: var(--folder-shadow); opacity: 0; }
.case-folder__cover__back__overlay { background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .05)); }

/* --- sibling tabs, rotated up the left edge --- */

.case-folder-tags {
  display: flex;
  position: absolute;
  right: 0;
  top: var(--stack-border-radius);
  transform: translate(100%, -100%) rotate(90deg);
  transform-origin: left bottom;
  width: 100%;
  z-index: -1;
}

.case-folder-tags__page {
  display: flex;
  margin-block-end: -20px;
  padding-block-end: 20px;
  pointer-events: none;
  position: relative;
  transition: transform .325s var(--ease);
  width: 100%;
}

.case-folder-tags__page:not(:first-child) { bottom: 0; left: 0; position: absolute; }
.case-folder-tags__page:first-child  { z-index: 4; }
.case-folder-tags__page:nth-child(2) { z-index: 3; }
.case-folder-tags__page:nth-child(3) { z-index: 2; }
.case-folder-tags__page.--active     { z-index: 10; }

.case-folder-tags__page::before,
.case-folder-tags__page::after {
  bottom: 0;
  content: '';
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}

.case-folder-tags__page::before {
  background: var(--bg-color);
  border-radius: var(--stack-border-radius) var(--stack-border-radius) 0 0;
}

.case-folder-tags__page::after {
  box-shadow: 0 -10px 20px rgba(0, 0, 0, .5);
  opacity: 0;
  top: calc(100% + 20px);
  transition: opacity .325s var(--ease);
  z-index: 200;
}

@media only screen and (hover: hover) {
  .case-folder-tags__page:hover { transform: translateY(-10px); }
  .case-folder-tags__page:hover::after { opacity: 1; }
}

.case-folder-tags__item .tag {
  /* height here is the tab face; the padding is the overlap onto the folder
     edge, so it must sit outside the declared height (content-box). */
  box-sizing: content-box;
  margin-block-end: -20px;
  padding-block-end: 19px;
  z-index: 10;
}

.case-folder-tags__item.--current { cursor: default; pointer-events: none; }

/* --- the paper sheet --- */

.case-folder-sheet-wrapper {
  --clip-size: 5rem;
  --padding-l: 3rem;
  display: flex;
  justify-content: flex-end;
  max-height: 100%;
  width: 100%;
}

@media only screen and (min-width: 1025px) { .case-folder-sheet-wrapper { aspect-ratio: 210/297; } }
@media only screen and (min-width: 1440px) { .case-folder-sheet-wrapper { --padding-l: 5.625rem; } }
@media only screen and (max-width: 1024px) { .case-folder-sheet-wrapper { aspect-ratio: auto; } }
@media only screen and (max-width: 768px)  { .case-folder-sheet-wrapper { --clip-size: 4rem; } }
@media only screen and (max-width: 480px)  { .case-folder-sheet-wrapper { --padding-l: 1.5rem; --clip-size: 2.5rem; } }

.case-folder-sheet {
  background-color: var(--color-paper);
  border-radius: 4px;
  color: var(--color-dark);
  flex-grow: 0;
  flex-shrink: 0;
  padding: var(--padding-l) var(--padding-l) var(--padding-l) calc(var(--clip-size) + 1rem);
  position: relative;
  z-index: 0;
  width: calc(var(--case-content-width) - var(--container-offset) - .25rem);
}

@media only screen and (min-width: 1025px) { .case-folder-sheet { aspect-ratio: 210/297; } }
@media only screen and (min-width: 1440px) { .case-folder-sheet { width: calc(var(--case-content-width) - var(--container-offset) * 2); } }

.case-folder-sheet__inner {
  border-bottom: 1px solid #100f0a;
  display: flex;
  height: 100%;
  justify-content: space-between;
  width: 100%;
}

@media only screen and (max-width: 1024px) { .case-folder-sheet__inner { height: auto; padding-bottom: 4rem; } }
@media only screen and (max-width: 768px)  { .case-folder-sheet__inner { flex-direction: column; gap: 3rem; justify-content: flex-start; } }

.case-folder-sheet__left,
.case-folder-sheet__right {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media only screen and (max-width: 768px) {
  .case-folder-sheet__left,
  .case-folder-sheet__right { align-items: flex-start; flex-direction: row; }
}
@media only screen and (max-width: 480px) {
  .case-folder-sheet__left,
  .case-folder-sheet__right { flex-direction: column; }
}

.case-folder-sheet__left  { width: 30%; }
.case-folder-sheet__right { width: 60%; }

@media only screen and (max-width: 768px) {
  .case-folder-sheet__left,
  .case-folder-sheet__right { width: 100%; }
}

.case-folder-sheet__photo {
  align-items: center;
  aspect-ratio: .875;
  display: flex;
  justify-content: center;
  margin-bottom: calc(var(--padding-l) * .66);
  margin-top: calc(var(--padding-l) * -1 + 1rem);
  min-width: 140px;
  position: relative;
  transform: rotate(-1.5deg);
  transform-origin: left bottom;
  width: 100%;
}

@media only screen and (max-width: 768px) { .case-folder-sheet__photo { flex: auto 1 0; width: 33%; } }
@media only screen and (max-width: 480px) { .case-folder-sheet__photo { width: 90%; } }

.case-folder-sheet__photo img {
  aspect-ratio: inherit;
  object-fit: cover;
  width: 100%;
  height: 100%;
  min-height: 0;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .25);
}

.case-folder-sheet__photo .content-paperclip {
  position: absolute;
  right: 2rem;
  top: 0;
  transform: translateY(-1rem) !important;
}

.case-folder-sheet__info-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-wrap: balance;
}

.case-folder-sheet__info {
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.4;
}

.case-folder-sheet__info p:first-child { font-weight: 700; }

.case-folder-sheet__desc {
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
  line-height: 1.4;
  text-shadow: 1px 1px 1px #fff;
  font-size: 18px;
}

@media only screen and (min-width: 1025px) { .case-folder-sheet__desc { font-size: 1.6vw; } }
@media only screen and (min-width: 1440px) { .case-folder-sheet__desc { font-size: 22px; } }
@media only screen and (min-width: 1920px) { .case-folder-sheet__desc { font-size: 26px; } }
@media only screen and (max-width: 768px)  { .case-folder-sheet__desc { font-size: 16px; gap: 1.5rem; } }

.case-folder-sheet__desc p:not(:first-child) { text-indent: 2.5rem; }

.case-folder-sheet__desc p:first-child::first-letter {
  display: inline-block;
  float: left;
  font-size: calc(5em * var(--display-scale));
  line-height: .58;
  margin-right: .8rem;
  margin-top: .12em;
  font-family: var(--font-display);
}

.case-folder-sheet__clip {
  align-items: center;
  border-right: 1px solid #b8b3ae;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-around;
  left: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: var(--clip-size);
  z-index: 5;
}

@media only screen and (max-width: 480px) { .case-folder-sheet__clip { border: none; width: 3rem; } }

.case-folder-sheet__clip span {
  background-color: var(--case-color);
  border-radius: 50%;
  display: inline-block;
  height: clamp(10px, 1.33vw, 20px);
  width: clamp(10px, 1.33vw, 20px);
}

.case-folder-sheet__overlay,
.case-folder-sheet__marks {
  background-position: 50%;
  background-size: cover;
  border-radius: inherit;
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.case-folder-sheet__overlay {
  background-image: var(--texture-paper);
  mix-blend-mode: multiply;
  opacity: .5;
}

.case-folder-sheet__marks {
  background-image: var(--texture-fibre);
  mix-blend-mode: multiply;
  opacity: .35;
}

/* --- scrapbook --- */

.case-folder-scrapbook {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
}

/* On wide screens the scrapbook is a definite-size stage that overlaps the
   lower half of the sheet, so every pinned item resolves its % offsets
   against a box that does not depend on the items themselves. */
@media only screen and (min-width: 1025px) {
  .case-folder-scrapbook {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1.58;
    margin-top: -52%;
  }
}

@media only screen and (max-width: 1024px) {
  .case-folder-scrapbook {
    gap: 4rem;
    margin-left: 5%;
    margin-block: -4rem 4rem;
    width: 90%;
  }
}

@media only screen and (min-width: 1025px) {
  .scrapbook-item {
    left: var(--sx);
    position: absolute;
    top: var(--sy);
  }
}

@media only screen and (max-width: 1024px) {
  .scrapbook-item { max-width: 100%; z-index: 15; }
  .scrapbook-item:nth-child(2n) { align-self: flex-end; }
}

.scrapbook-item__inner { position: relative; }

.draggable { cursor: grab; }
.draggable:active { cursor: grabbing; }

/* --- note --- */

.content-note-wrapper { position: relative; }

@media only screen and (max-width: 1024px) {
  .content-note-wrapper { max-width: 100%; width: 480px; }
}

.content-note {
  --padding-multiplier: 1;
  background-color: var(--note-bg);
  border-radius: 4px;
  color: var(--note-fg, #000);
  display: flex;
  flex-direction: column;
  gap: calc(2.5rem * var(--padding-multiplier));
  opacity: .97;
  overflow: clip;
  padding: calc(4rem * var(--padding-multiplier)) calc(3.5rem * var(--padding-multiplier))
           calc(5rem * var(--padding-multiplier)) calc(3.5rem * var(--padding-multiplier));
  position: relative;
  text-wrap: balance;
  transform: rotate(var(--note-rot, 0deg));
  box-sizing: border-box;
}

@media only screen and (min-width: 1025px) { .content-note { --padding-multiplier: .7; } }
@media only screen and (min-width: 1440px) { .content-note { --padding-multiplier: .85; } }
@media only screen and (max-width: 1024px) { .content-note { --padding-multiplier: .7; width: 100%; } }
@media only screen and (max-width: 480px) {
  .content-note { gap: 1.25rem; padding: 34px 24px 34px 28px; }
  .content-note__title { font-size: 1.625rem; }
  .content-note__desc { font-size: 1rem; }
}

@media only screen and (min-width: 1025px) {
  .content-note.--size-xs { width: clamp(19rem, 4rem + 16.6vw, 24rem); }
  .content-note.--size-s  { width: clamp(21rem, 0rem + 23.3vw, 28rem); }
  .content-note.--size-m  { width: clamp(23rem, -1rem + 26.6vw, 31rem); }
  .content-note.--size-l  { width: clamp(28rem, 11.5rem + 18.3vw, 33.5rem); }
}

.content-note__desc p + p { margin-top: .75em; }

.note-overlay,
.note-marks {
  border-radius: inherit;
  inset: 0;
  pointer-events: none;
  position: absolute;
  background-position: 50%;
  background-size: cover;
}

.note-overlay { background-image: var(--texture-paper); mix-blend-mode: multiply; opacity: .45; }
.note-marks   { background-image: var(--texture-fibre); mix-blend-mode: multiply; opacity: .3; }

/* --- photo plate --- */

.content-photo {
  display: flex;
  left: var(--px, auto);
  top: var(--py, auto);
  position: relative;
  transform: rotate(var(--protate, 0deg));
  transform-origin: var(--porigin, center);
  width: var(--pw, 100%);
  z-index: var(--pz, 0);
}

.content-photo img {
  object-fit: contain;
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}

/* --- stacked plates --- */

.content-stack {
  left: var(--px, auto);
  top: var(--py, auto);
  position: relative;
  transform: rotate(var(--protate, 0deg));
  width: var(--pw, 100%);
  z-index: var(--pz, 0);
}

.content-stack__inner { display: flex; height: 100%; width: 100%; }
.content-stack__inner > :first-child { position: static; }
.content-stack__inner > :not(:first-child) { position: absolute; }

/* --- link chip --- */

.content-link {
  align-items: center;
  background-color: var(--color-paper);
  border-radius: 4px;
  color: var(--color-dark);
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: .875rem;
  gap: .75rem;
  letter-spacing: .02em;
  padding: .9rem 1.4rem;
  position: relative;
  text-transform: uppercase;
  transform: rotate(var(--note-rot, 0deg));
  transition: transform .325s var(--ease), box-shadow .325s var(--ease);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  white-space: nowrap;
}

.content-link:hover {
  transform: rotate(var(--note-rot, 0deg)) translateY(-3px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .35);
}

.content-link svg { flex-shrink: 0; }

/* --- paperclip --- */

.content-paperclip {
  color: var(--clip-color, #b7b7b7);
  height: 0;
  position: absolute;
  width: 0;
  z-index: var(--clip-z, 1);
  transform: rotate(var(--clip-rot, 0deg));
}

.content-paperclip > * { left: 0; position: absolute; top: 0; transform: translate(-10%, -5%); }
.paperclip { width: 1.25rem; }

/* ---------- 11. About page -------------------------------------- */

.page-about {
  --button-size: 3.375rem;
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-block: calc(var(--container-offset) * 2);
  padding-inline: var(--container-offset);
  position: relative;
  width: calc(var(--container-size) + var(--container-offset) * 2);
}

/* The panel is a sheet of paper laid on the dark page, not a white
   background — the archive stays visible around its edges. */
.page-about__inner {
  background: var(--color-light);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, .45);
}

.page-about__inner {
  align-items: center;
  display: flex;
  flex-direction: column;
  padding-block: calc(var(--container-offset) * 2);
  position: relative;
  color: var(--color-dark);
  width: calc(90% - .1rem);
  z-index: 5;
}

@media only screen and (max-width: 1024px) { .page-about__inner { width: 100%; } }

.page-about__content {
  align-items: flex-start;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: calc(88.88889% - .11111rem);
  gap: 1rem;
}

@media only screen and (max-width: 1024px) {
  .page-about__content { flex-direction: column; gap: 3.75rem; width: 100%; }
}

.page-about__left,
.page-about__right { display: flex; flex-direction: column; gap: 5rem; }

@media only screen and (min-width: 1025px) {
  .page-about__left  { position: sticky; top: var(--container-offset); width: calc(37.5% - .625rem); }
  .page-about__right { width: calc(50% - .5rem); }
}
@media only screen and (max-width: 1024px) {
  .page-about__left { max-width: 480px; width: 100%; }
  .page-about__left, .page-about__right { gap: 2.5rem; }
}

.page-about__title {
  font-family: var(--font-display);
  font-size: calc(3.25rem * var(--display-scale));
  font-weight: 400;
  line-height: var(--display-leading);
  text-transform: uppercase;
  text-wrap: balance;
  letter-spacing: -0.005em;
}

.page-about__desc {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.5;
}

@media only screen and (max-width: 1024px) { .page-about__desc { font-size: 16px; } }

.page-about__desc p:not(:first-child) { margin-top: 1em; text-indent: 2.5em; }

.page-about__close {
  display: flex;
  justify-content: flex-end;
  left: 0;
  padding-block: calc(var(--container-offset) * 2);
  padding-inline: var(--container-offset);
  pointer-events: none;
  position: fixed;
  top: 0;
  transform: translate(calc(var(--button-size) * .5), calc(var(--button-size) * -.5));
  width: var(--container-size);
  z-index: 50;
}

.page-about__close .close-button {
  background: #303030;
  color: #b6b6b6;
  height: var(--button-size);
  width: var(--button-size);
  margin-right: calc(5% + .05rem);
  pointer-events: all;
}

.page-about__signature {
  align-items: center;
  color: #b4b4b4;
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 14px;
  gap: 1rem;
  text-align: center;
}

.page-about__signature a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: .25em;
}

.about-gallery { display: flex; flex-direction: column; gap: 1rem; width: 100%; }

.about-gallery__inner { aspect-ratio: 4/3; overflow: hidden; width: 100%; }

.about-gallery__images { height: 100%; overflow: hidden; position: relative; width: 100%; }

.about-gallery img {
  height: 100%;
  left: 0;
  object-fit: cover;
  position: absolute;
  top: 0;
  width: 100%;
}

.about-gallery img:first-child { z-index: 2; }
.about-gallery img:not(:first-child) { opacity: 0; }

.about-gallery__captions {
  font-family: var(--font-mono);
  font-size: 14px;
  opacity: .6;
  position: relative;
  text-wrap: balance;
  width: 100%;
  min-height: 3em;
}

.about-gallery__captions p { opacity: 0; transition: opacity .65s var(--ease); }
.about-gallery__captions p:not(:first-child) { left: 0; position: absolute; top: 0; }
.about-gallery__captions p.is-active { opacity: 1; }

.close-button {
  align-items: center;
  background-color: red;
  border-radius: 50%;
  color: var(--color-dark);
  cursor: pointer;
  display: flex;
  height: 3.375rem;
  justify-content: center;
  width: 3.375rem;
  will-change: transform;
  transition: transform .325s var(--ease);
}

.close-button svg { transition: transform .325s var(--ease); }
.close-button:hover { transform: scale(.97); }
.close-button:hover svg { transform: scale(1.03); }
.close-button:active svg { transform: scale(1.2); }

/* ---------- 12. Lightbox ---------------------------------------- */

.popup {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 5rem var(--container-offset);
  position: fixed;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s var(--ease);
}

.popup.is-open { opacity: 1; pointer-events: auto; }

.popup__bg { background: rgba(0, 0, 0, .85); inset: 0; position: absolute; z-index: -1; }

.popup__view {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  max-height: 100%;
  max-width: 100%;
  transform: scale(.94);
  transition: transform .5s var(--ease);
}

.popup.is-open .popup__view { transform: scale(1); }

.popup__view img { max-height: calc(100vh - 10rem); max-width: 100%; object-fit: contain; }

.popup__close {
  position: absolute;
  right: var(--container-offset);
  top: var(--container-offset);
  z-index: 10;
}

/* ---------- 13. Utilities --------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
