/* The filing drawer menu: a green steel filing cabinet on a white page, built in CSS 3D. The drawers are the menu's
   items; the manila folders inside them are the links. The shell, the holes and the inside of the drawers are faces
   the script adds and places. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #23201b;           /* the words on the cards and the folders */
  --steel: #2f4b41;         /* the cabinet's paint */
  --steel-light: #46685a;   /* where the light falls on it */
  --steel-dark: #1d3029;    /* its sides in the shade */
  --hole: #0d1512;          /* inside the cabinet */
  --brass: #c7a04e;         /* the label holders and the handles */
  --card: #f6f1e6;          /* the cards in the holders */
  --manila: #e9d4a4;        /* the folders */
  --manila-dark: #cdb47f;
}

* {
  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: 'Familjen Grotesk Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the stage: the cabinet in the middle of the page */
.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 40px 16px;
}

/* ---------------------------------------------------------------- the cabinet */
/* the room it needs: the folders rise above the top drawer */
.cab {
  position: relative;
  width: var(--room-w, 380px);
  height: var(--room-h, 520px);
  perspective: 1500px;
  perspective-origin: 50% 30%;
  -webkit-tap-highlight-color: transparent;
}

.cab__scene,
.cab__body,
.cab__drawers,
.drawer,
.drawer__folders,
.drawer__folders > li {
  position: absolute;
  transform-style: preserve-3d;
}

.cab__scene {
  left: 50%;
  top: var(--floor, 470px);
  width: 0;
  height: 0;
}

.cab__body {
  left: 0;
  top: 0;
}

.cab__drawers {
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* every face is placed from its middle by the script */
.face,
.drawer,
.drawer__folders,
.folder {
  left: 50%;
  top: 50%;
}

.face {
  position: absolute;
  display: block;
  pointer-events: none;
}

/* the paint: the front catches the light, the top more, the side is in the shade */
.face--front {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.08)),
    var(--steel);
}

.face--top {
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.16)),
    var(--steel-light);
}

.face--side {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.2)),
    var(--steel-dark);
}

.face--plinth {
  background: linear-gradient(180deg, var(--steel-dark), #121d19);
}

.face--hole {
  background: var(--hole);
}

.face--hole-wall {
  background: linear-gradient(90deg, #22332c, var(--hole) 70%);
}

.face--hole-floor {
  background: linear-gradient(0deg, #1e2d27, var(--hole) 80%);
}

/* inside a drawer: bare steel, lighter where it is near the open front */
.face--box {
  background: linear-gradient(90deg, #4e6f62, #26392f);
}

.face--box-floor {
  background: linear-gradient(0deg, #3d5c4f, #1c2a24);
}

.face--box-back {
  background: #20322a;
}

.face--lip {
  background: linear-gradient(0deg, var(--steel-light), #5c8070);
}

.face--lip-side {
  background: var(--steel-dark);
}

/* the shadow an open drawer casts on the cabinet below it */
.face--shade {
  background: linear-gradient(180deg, rgba(5, 10, 8, 0.6), rgba(5, 10, 8, 0.22) 30%, rgba(5, 10, 8, 0));
  opacity: 0;
}

/* the cabinet's shadow on the floor */
.face--floor {
  background: radial-gradient(closest-side, rgba(40, 30, 15, 0.38), rgba(40, 30, 15, 0.12) 60%, transparent);
}

/* ---------------------------------------------------------------- the drawers */
.drawer {
  list-style: none;
}

.drawer__front {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 7px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0.12)),
    var(--steel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    inset 1px 0 0 rgba(255, 255, 255, 0.06),
    inset -1px 0 0 rgba(0, 0, 0, 0.2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  backface-visibility: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* pressed: the handle is pulled and the front darkens a little */
.drawer__front:active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0.2)),
    var(--steel);
}

.drawer__front:active .drawer__pull {
  transform: translateY(1px) scaleY(0.9);
}

.drawer__front:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -5px;
}

html[data-using='pointer'] .drawer__front:focus-visible {
  outline: none;
}

/* the brass holder with its typed card */
.drawer__card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 10px;
  width: min(176px, 64%);
  padding: 4px 11px 5px 12px;
  border: 2px solid var(--brass);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 45%),
    var(--card);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 2px rgba(60, 40, 10, 0.25),
    0 1px 0 1px rgba(255, 240, 200, 0.18);
  text-align: left;
  pointer-events: none;
}

.drawer__name {
  font-size: 15px;
  font-weight: 640;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

/* the letters the drawer files, in the drawer's colour */
.drawer__range {
  color: var(--tint);
  font-weight: 700;
  font-family: 'Courier Prime', ui-monospace, monospace;
  font-size: 11px;
}

/* the handle: a brass cup */
.drawer__pull {
  width: 64px;
  height: 11px;
  border-radius: 2px 2px 7px 7px;
  background:
    linear-gradient(180deg, #f1d58e 0%, var(--brass) 38%, #7d5e22 100%);
  box-shadow:
    0 3px 3px rgba(0, 0, 0, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the folders */
.drawer__folders {
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.folder {
  position: absolute;
  display: block;
  border-radius: 2px 2px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 14px),
    linear-gradient(180deg, var(--manila), var(--manila-dark));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 -1px 0 rgba(120, 90, 40, 0.25);
  transform-origin: 50% 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* the tab sticks up from the folder's top edge, at its own place along it */
.folder__tab {
  position: absolute;
  bottom: 100%;
  left: var(--at, 8px);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 2px 11px 0;
  border-radius: 6px 6px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%),
    var(--manila);
  /* the drawer's colour along the tab's top edge */
  box-shadow:
    inset 0 3px 0 var(--tint),
    inset 0 4px 0 rgba(255, 255, 255, 0.5);
  font-size: 13px;
  font-weight: 620;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.folder__note {
  position: absolute;
  top: 6px;
  left: var(--note, 8px);
  right: 8px;
  overflow: hidden;
  color: color-mix(in srgb, var(--ink) 72%, var(--manila));
  font-family: 'Courier Prime', ui-monospace, monospace;
  font-size: 11.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.folder[aria-current='page'] .folder__tab {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%),
    var(--card);
}

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

.folder:focus-visible .folder__tab {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

html[data-using='pointer'] .folder:focus-visible .folder__tab {
  outline: none;
}
