/* Shared foundations for every lab variant: design tokens carried over from
 * modern-euc.com (Manrope, Fira Code, purple #503AA8), plus the geometry for
 * the tracking head and the 3D bookshelf. Variants restyle on top; they do
 * not redefine the geometry. */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap');

:root {
  --purple: #503aa8;
  --purple-lift: #6a51d4;
  --yellow: #f5cf3e;
  --off-white: #f4f2ef;
  --ink: #111013;
  --ink-soft: #2a2830;

  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', ui-monospace, 'Cascadia Code', monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --shelf-speed: 620ms;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

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

/* ---------------------------------------------------------------- head --- */

.head-stage {
  position: relative;
  perspective: 900px;
  perspective-origin: 50% 42%;
  display: grid;
  place-items: center;
  isolation: isolate;
  user-select: none;
}

/* Centred explicitly rather than by the grid: a sprite cell is wider than the
 * stage it sits in, and an over-sized grid item aligns to the start edge, which
 * silently shifts the head off-centre. `translate` is its own property, so it
 * survives the engine writing to `transform`. */
.head-rig {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  transform-style: preserve-3d;
  will-change: transform;
}

.head-portrait {
  display: block;
  width: var(--head-size, 340px);
  max-width: none;
  height: auto;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
}

/* Blurred copy sitting behind the portrait. Moving it against the portrait is
 * what reads as depth -- it is doing the job a second camera angle would. */
.head-plate {
  position: absolute;
  inset: -6%;
  background-size: cover;
  background-position: center 22%;
  filter: blur(16px) saturate(0.7) brightness(0.55);
  opacity: 0.55;
  border-radius: 50%;
  will-change: transform;
}

/* Eye band: the same photo, clipped to the eye line, sliding a few extra px.
 * Position it with --eye-top / --eye-height once the real crop is known. */
.head-eyes {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--eye-top, 33%);
  height: var(--eye-height, 12%);
  background-size: 100% auto;
  background-position: center var(--eye-bg, 33%);
  opacity: 0;
  will-change: transform;
  pointer-events: none;
}

.head-stage[data-eyes='on'] .head-eyes {
  opacity: 1;
  mask-image: radial-gradient(ellipse 60% 100% at 50% 50%, #000 55%, transparent 100%);
}

.head-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(112deg, transparent 30%, rgba(255, 255, 255, 0.5) 50%, transparent 68%);
  mix-blend-mode: soft-light;
  opacity: 0.2;
  pointer-events: none;
  will-change: transform, opacity;
}

/* The sheen only makes sense while the portrait moves -- parked, it is just a
 * diagonal streak across a face. */
.head-stage[data-static] .head-sheen {
  display: none;
}

.head-sprite {
  background-repeat: no-repeat;
  image-rendering: auto;
}

.head-shadow {
  position: absolute;
  bottom: 4%;
  width: 58%;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45), transparent 70%);
  filter: blur(6px);
  z-index: -1;
  will-change: transform;
}

/* ----------------------------------------------------------- bookshelf --- */

.shelf-stage {
  position: relative;
  perspective: 1400px;
  perspective-origin: 50% 44%;
  height: var(--shelf-height, 380px);
  cursor: grab;
  touch-action: pan-y;
  outline: none;
  overflow: hidden;
}

.shelf-stage.is-dragging {
  cursor: grabbing;
}

.shelf-stage:focus-visible {
  outline: 2px solid var(--purple-lift);
  outline-offset: 6px;
}

/* Given a real height rather than 0. Books are anchored to its bottom edge so
 * the layout is identical either way, but a zero-height ancestor makes Chrome
 * prune every book out of the accessibility tree. */
.shelf-rail {
  position: absolute;
  bottom: 60px;
  left: 48px;
  transform-style: preserve-3d;
  height: 300px;
  pointer-events: none;
}

.shelf-rail .book {
  pointer-events: auto;
}

.shelf-plank {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 44px;
  height: 16px;
  background: linear-gradient(180deg, var(--plank-top, #cfc7bb), var(--plank-bottom, #8d8375));
  box-shadow: 0 18px 30px -14px rgba(0, 0, 0, 0.55);
  transform: translateZ(-10px);
}

.book {
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--thickness);
  height: var(--height);
  transform-style: preserve-3d;
  will-change: transform;
}

.book-body {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  transition: transform var(--shelf-speed) var(--ease-out);
  will-change: transform;
}

.shelf-stage.is-dragging .book-body {
  transition: none;
}

/* Every face is centred on the box centre, then rotated out to its plane.
 * Anchoring faces at the box's top-left instead makes each rotation pivot
 * about a different point, which shows up as faces flapping loose. */
.book .face {
  position: absolute;
  left: 50%;
  top: 50%;
  backface-visibility: hidden;
  transform-style: flat;
}

/* Spine: the shelved face, thickness wide, full height. */
.book .spine {
  width: var(--thickness);
  height: var(--height);
  margin-left: calc(var(--thickness) / -2);
  margin-top: calc(var(--height) / -2);
  transform: translateZ(calc(var(--depth) / 2));
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 22%, transparent 78%, rgba(0, 0, 0, 0.35)),
    var(--colour);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.spine-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.94);
  max-height: calc(var(--height) - 54px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.spine-mark {
  font-family: var(--font-mono);
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.55);
  writing-mode: vertical-rl;
}

/* Front cover: the big face, revealed when the book is pulled. */
.book .cover {
  width: var(--depth);
  height: var(--height);
  margin-left: calc(var(--depth) / -2);
  margin-top: calc(var(--height) / -2);
  transform: rotateY(90deg) translateZ(calc(var(--thickness) / 2));
  background: var(--colour);
  border-radius: 2px 4px 4px 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* ------------------------------------------------------- cover jackets --- */

/* One jacket design, typeset from the post's own metadata. Laid out as a grid
 * so the title takes the slack and the imprint stays pinned to the foot,
 * whatever the title length. */
.book .cover {
  display: grid;
  /* minmax(0, 1fr), not 1fr: a plain `1fr` track has an `auto` minimum, so it
   * refuses to shrink below the title's content and the longest titles push
   * through the imprint no matter what the item's own min-height says. */
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 7px;
  padding: 15px 14px 13px;
  justify-content: stretch;
  overflow: hidden;
  background:
    linear-gradient(158deg, color-mix(in srgb, var(--colour) 86%, #fff) 0%, var(--colour) 46%,
      color-mix(in srgb, var(--colour) 76%, #000) 100%);
}

/* The hinge: a darker strip along the spine edge, which is what stops the
 * cover reading as a flat rectangle of colour. */
.book .cover::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.34), transparent);
  pointer-events: none;
}

.cover-motif {
  height: 46px;
  opacity: 0.5;
  mix-blend-mode: soft-light;
}

/* Per-category motif. Geometric and abstract on purpose -- it has to read at
 * 150px wide and survive being rotated in 3D. */
.cover[data-cat='avd'] .cover-motif {
  background-image:
    repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px 11px),
    repeating-linear-gradient(0deg, #fff 0 2px, transparent 2px 11px);
}
.cover[data-cat='nme'] .cover-motif {
  background-image: radial-gradient(circle at 50% 50%, #fff 1.6px, transparent 1.8px);
  background-size: 11px 11px;
}
.cover[data-cat='w365'] .cover-motif {
  background-image: repeating-linear-gradient(135deg, #fff 0 2px, transparent 2px 10px);
}
.cover[data-cat='intune'] .cover-motif {
  background-image:
    repeating-linear-gradient(45deg, #fff 0 2px, transparent 2px 12px),
    repeating-linear-gradient(-45deg, #fff 0 2px, transparent 2px 12px);
}
.cover[data-cat='entra'] .cover-motif {
  background-image: repeating-radial-gradient(circle at 0% 100%, transparent 0 9px, #fff 9px 11px);
}

.cover-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  line-height: 1.35;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.cover-rule {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--yellow);
}

.cover-title {
  margin: 0;
  /* Stretched to the track, not sized to its content. With `align-self: start`
   * the element keeps its full text height and overflows the track, so the clip
   * never happens and long titles cross the imprint. */
  align-self: stretch;
  max-height: 100%;
  font-size: 0.78rem;
  line-height: 1.22;
  letter-spacing: -0.015em;
  font-weight: 800;
  color: #fff;
  /* Titles run long and the jacket is a fixed slab, so clamp rather than spill
   * past the edge of the board. `min-height: 0` is required: without it this
   * grid row refuses to shrink below its content and the longest titles run
   * straight through the imprint line. */
  min-height: 0;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cover-imprint {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.42rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.58);
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  padding-top: 7px;
}

/* Back cover, the opposite large face. */
.book .back {
  width: var(--depth);
  height: var(--height);
  margin-left: calc(var(--depth) / -2);
  margin-top: calc(var(--height) / -2);
  transform: rotateY(-90deg) translateZ(calc(var(--thickness) / 2));
  background: color-mix(in srgb, var(--colour) 72%, #000);
  border-radius: 4px 2px 2px 4px;
}

/* Page block: the open edge, which faces the back of the shelf. */
.book .pages {
  width: var(--thickness);
  height: var(--height);
  margin-left: calc(var(--thickness) / -2);
  margin-top: calc(var(--height) / -2);
  transform: rotateY(180deg) translateZ(calc(var(--depth) / 2));
  background: repeating-linear-gradient(90deg, #efe9dd 0 1px, #d9d1c2 1px 2px);
}

.book .top {
  width: var(--thickness);
  height: var(--depth);
  margin-left: calc(var(--thickness) / -2);
  margin-top: calc(var(--depth) / -2);
  transform: rotateX(90deg) translateZ(calc(var(--height) / 2));
  background: repeating-linear-gradient(0deg, #efe9dd 0 1px, #cdc4b3 1px 2px);
}

.book:not(.is-active):hover .book-body {
  transform: translateZ(26px) translateY(-10px);
}

.book.is-active {
  z-index: 5;
}

.shelf-stage.has-selection .book:not(.is-active) .spine {
  filter: brightness(0.6) saturate(0.7);
}

@media (prefers-reduced-motion: reduce) {
  .book-body,
  .head-rig {
    transition: none !important;
  }
}
