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

/* The cursor is a small grey square everywhere (the grey of the tagline
   text), hotspot at its centre.
   !important so it wins over the pointer/default/auto cursors set below. */
html,
html * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Crect width='6' height='6' fill='%23a3a3a3'/%3E%3C/svg%3E") 3 3, auto !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
}

html {
  overflow-y: scroll; /* keep width stable so the files don't re-layout */
}

.layout {
  padding: 40px;
}

/* Desktop: the files sit flush with the bottom of the screen (main.js sets
   the gap above them). */
@media (min-width: 801px) {
  .layout {
    padding-bottom: 0;
  }
}

/* Space above the files: 4 areas side by side. The first column grows to fit
   its longest line (so each "I care about" bullet stays on one line), capped
   at half the width so narrow desktops still wrap; the other 3 share the rest.
   On desktop main.js adds space below them to fill the screen above the files. */
.intro {
  display: grid;
  grid-template-columns: fit-content(50%) repeat(3, 1fr);
}

.area {
  min-width: 0;
  padding: 0 16px;
}

.area:first-child {
  padding-left: 0;
}

.area:last-child {
  padding-right: 0;
}

/* Name + tagline: same size, name black, tagline grey */
.name,
.tagline {
  margin: 0;
  font-size: 16px;
  font-weight: normal;
  line-height: 1.35;
}

.tagline {
  max-width: 48ch;
  color: #a3a3a3;
}

/* "I care about" sits under the name */
.care {
  margin-top: 24px;
}

/* Desktop: a wider gap */
@media (min-width: 801px) {
  .care {
    margin-top: 60px;
  }
}

/* Venn diagram, centre area: vertically centred against the text beside it.
   Circles in the folder-square colours (set per circle in index.html); labels
   grey like the tagline, "bshao" black like the name. */
.area-venn {
  display: flex;
  align-items: center;
}

/* Wrapper around the diagram, full column width (no visible border) */
.venn-frame {
  flex: 1;
  min-width: 0;
  /* uneven on purpose: evens out the SVG's own built-in margins, so the
     drawing has ~15px of room on every side */
  padding: 14px 11px 5px;
}

.venn {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

/* Desktop: the diagram sits at the top left of its column instead of centred. */
@media (min-width: 801px) {
  /* Top of the diagram's drawing area lines up with the top of column 1. */
  .area-venn {
    align-items: flex-start;
  }

  /* Pulled up 12px so the drawing area's empty top edge sits above the text. */
  .venn-frame {
    margin-top: -12px;
    padding-top: 0;
    padding-left: 0;
  }

  /* It may spill into the empty third column (but no further) rather than
     shrinking to fit its own. */
  .venn {
    margin-left: 0;
    max-width: 200%;
  }
}

.venn circle {
  fill: none;
  stroke-width: 1;
}

/* Hidden until venn.js has placed everything (and set up the intro), so the
   circles never flash up stacked in the middle before the script runs. */
.venn:not(.is-ready) circle,
.venn:not(.is-ready) text {
  visibility: hidden;
}


.venn text {
  font-family: Arial, Helvetica, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
  fill: #a3a3a3;
}

.venn .venn-center {
  fill: #000;
}

/* Text sections in the areas: black heading, grey lines, same size */
.area-heading,
.plain-list {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: normal;
  line-height: 1.35;
}

.plain-list {
  list-style: none;
  color: #a3a3a3;
}

/* Square bullets, coloured like the folder tabs' squares (--mark per item) */
.plain-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.plain-list li::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--mark, #000);
}

/* Inline link in the grey tagline text: same grey, underlined */
.highlight {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.highlight:hover,
.highlight:focus-visible {
  color: #000;
}

/* Links, top-right area: a row of light grey dots against the right edge. Each name sits under its dot in grey,
   turned 90° so it reads top to bottom. */
.links {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px;
  font-size: 16px;
}

.links a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #a3a3a3;
  text-decoration: none;
}

.links a::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d4d4d4;
}

.links span {
  writing-mode: vertical-rl;
  line-height: 1;
}

.links a:hover,
.links a:focus-visible {
  color: #000;
  text-decoration: underline;
}

/* Files — full width under the areas */
.files {
  margin-top: 48px;
}

/* Clips the stack; height is set from main.js. */
.files {
  overflow: hidden;
}

#files {
  display: block;
}

#files text {
  font-family: Arial, Helvetica, sans-serif;
  user-select: none;
}

/* Cards in front of an open card slide down. */
.shift {
  transition: transform 450ms ease;
}

.card {
  transition: transform 160ms ease;
}

/* Section cards are not interactive. */
.card.divider,
.card.blank {
  cursor: default;
}

.card.item {
  cursor: pointer;
  outline: none;
}

.card.item:not(.is-open):hover,
.card.item:not(.is-open):focus-visible {
  transform: translateY(-8px);
}

/* Contents of an open card */
.sheet {
  display: none;
  cursor: auto;
}

.shift.is-open > .sheet {
  display: block;
}

.sheet-inner {
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.35;
}

.sheet-meta {
  margin: 0;
}

.sheet-title {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: normal;
}

.sheet-body {
  margin: 24px 0 0;
  max-width: 60ch;
}

/* A work: reads left → right, one section after another, each section split
   from the last by a thin full-height rule. Within a section, text flows
   through columns like a newspaper (main.js widens each .flow to fit its
   columns), with featured figures in big columns of their own between flows.
   The sheet scrolls sideways. */
/* The sheet: the article, then its progress bar along the bottom. */
.article-frame {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.article {
  --rule: #e5e5e5;
  box-sizing: border-box;
  flex: 1;
  min-height: 0;
  padding: 0 var(--pad, 0px);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none; /* replaced by .article-progress */
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.article::-webkit-scrollbar {
  display: none;
}

/* How far through the article you are: a thin dark bar over a light track,
   in the lower-left corner (main.js sets the fill). */
.article-progress {
  flex: none;
  margin-left: var(--pad, 0px);
  width: 210px;
  height: 4px;
  margin-top: 14px;
  background: #e5e5e5;
  overflow: hidden;
}

.article-progress-fill {
  height: 100%;
  background: #525252;
  transform: scaleX(0);
  transform-origin: left;
}

/* A section: text flows, with any featured figures between them. */
.article-section {
  flex: none;
  display: flex;
  gap: 40px; /* keep in sync with COL_GAP in main.js */
  height: 100%;
}

.article-section + .article-section {
  margin-left: 40px;
  padding-left: 40px;
  border-left: 1px solid var(--rule);
}

.flow {
  flex: none;
  width: var(--col);
  height: 100%;
  column-width: var(--col);
  column-gap: 40px; /* keep in sync with COL_GAP in main.js */
  column-fill: auto;
}

.flow.is-balanced {
  column-fill: balance;
}

.flow > * {
  margin: 0 0 14px;
}

/* One blank column after the last one. */
.article::after {
  content: "";
  flex: none;
  width: calc(var(--col) + 40px);
}

/* The first column: title at the top, opening paragraphs at the bottom. */
.article-opening {
  flex: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: var(--col);
  height: 100%;
}

.article-opening-text {
  margin-top: auto;
}

/* Space between the title and the opening paragraphs, and under the
   paragraphs (as shares of the sheet's height; padding in % would follow the
   section's width, which grows with whatever else sits in the section).
   Spare room goes above the paragraphs. A long opening eats into the space
   under them first, so the gap under the title holds as long as it can. */
.article-opening-gap {
  flex: 0 1 18%;
  min-height: 0;
}

.article-opening::after {
  content: "";
  flex: 0 60 23%;
  min-height: 16px;
}

.article-opening-text > p {
  margin: 0 0 14px;
}

.article-opening-text > p:last-child {
  margin-bottom: 0;
}

.article a {
  color: inherit;
}

.article-head {
  margin-bottom: 32px;
}

/* A dek under the title, e.g. the subtitle of an essay. */
.article-subtitle {
  margin: 8px 0 0;
  color: #737373;
  font-style: italic;
}

.article-meta,
.article-source {
  display: block;
  margin: 12px 0 0;
  color: #737373;
}

.article-source {
  margin-top: 4px;
}

/* A note added after the fact, e.g. when the piece was written. */
.article-note {
  margin: 16px 0 0;
  padding-left: 12px;
  border-left: 2px solid #d4d4d4;
  color: #737373;
  font-style: italic;
}

/* Live site · code · posts, in one wrapping row under the meta line. */
.article-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 4px 0 0;
  color: #737373;
}

/* Language switch on works with more than one version: EN | 中文. Plain grey
   words; the one being read is black and underlined. */
.article-lang {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 0;
  color: #a3a3a3;
  font-size: 13px;
}

.article-lang button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.article-lang button:hover {
  color: #171717;
}

.article-lang button[aria-pressed="true"] {
  color: #171717;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: default;
}

/* Chinese reads better a little looser, in a font that has the glyphs. */
.article-frame:lang(zh) .article {
  font-family: Arial, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.75;
  text-align: justify;
}

.flow > .section-head {
  margin-bottom: 16px;
  break-after: avoid;
}

.section-num {
  display: block;
  color: #a3a3a3;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Arial has no medium weight, so headings use Helvetica Neue Medium where
   it's available (Apple devices) and fall back to Arial elsewhere. */
.article h3 {
  margin: 4px 0 0;
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
}

.article ol {
  padding-left: 1.4em;
}

.article li + li {
  margin-top: 8px;
}

/* The points to take away (`big` in main.js): numbered lines at the title's
   size, each with a smaller sentence under it. */
.article .article-big {
  margin-top: 22px;
  padding: 0;
  list-style: none;
}

.article .article-big li {
  break-inside: avoid;
}

.article .article-big li + li {
  margin-top: 30px;
}

.big-line {
  margin: 6px 0 0;
  font-size: 28px; /* the title's (.sheet-title) */
  line-height: 1.2;
}

.big-note {
  max-width: 32em;
  margin: 10px 0 0;
  color: #525252;
}

.article .article-figure {
  margin: 6px 0 22px;
  break-inside: avoid;
}

.article .article-figure.feature {
  flex: none;
  margin: 0;
}

/* Compact links to posts on X (the references in section 01). */
.article-refs {
  padding: 0;
  list-style: none;
  break-inside: avoid;
}

.article-refs li + li {
  margin-top: 8px;
}

.article-refs a {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  line-height: 1.35;
}

.article-refs a:hover {
  border-color: #000;
}

/* A reply quoted in full: no thumbnail, so the words take the whole card. */
.article-refs a.is-quote {
  grid-template-columns: 1fr;
}

.article-refs a.is-quote .ref-note {
  -webkit-line-clamp: 5;
}

.ref-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 3px;
  background: #f2f2f2;
}

.ref-text {
  display: block;
  min-width: 0;
}

.ref-who {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}

.ref-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.ref-handle {
  display: block;
  color: #a3a3a3;
}

.ref-note {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: #525252;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Festival laurels (renderLaurels in main.js): a wreath with the award,
   festival and year inside, two to a row. */
.article-laurels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  justify-content: start;
  gap: 6px 12px;
  padding: 0;
  list-style: none;
  break-inside: avoid;
}

.article .laurel + .laurel {
  margin-top: 0;
}

.laurel {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 3 / 2;
}

.laurel-wreath {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: #000;
}

.laurel-stem {
  fill: none;
  stroke: #000;
  stroke-width: 2;
  stroke-linecap: round;
}

.laurel-text {
  position: absolute;
  inset: 20% 23% 14%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6cqw;
  text-align: center;
  line-height: 1.15;
}

.laurel-award {
  font-size: 5.2cqw;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.laurel-category {
  margin-top: -1cqw;
  font-size: 5.2cqw;
}

.laurel-festival {
  font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
  font-size: 7cqw;
  font-weight: 500;
}

.laurel-year {
  font-size: 5.2cqw;
  font-variant-numeric: tabular-nums;
}

.figure-grid {
  display: grid;
  justify-content: start;
  gap: 8px; /* keep in sync with MEDIA_GAP in main.js */
}

.figure-grid img,
.figure-grid video {
  display: block;
  width: 100%;
  object-fit: cover;
  background: #f2f2f2;
  border-radius: 4px;
}

/* Scrubbable video (see scrubber in main.js): a thin rail over the bottom edge. */
.scrub {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}

.figure-grid .scrub video {
  height: 100%;
}

.scrub video {
  cursor: pointer;
}

.scrub-bar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px 4px 6px;
}

.scrub-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: #fff;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  filter: drop-shadow(0 0 3px rgb(0 0 0 / 0.4));
}

.scrub-toggle svg {
  width: 12px;
  height: 12px;
}

.scrub-toggle:focus-visible {
  outline: 2px solid #002fa7;
}

.scrub-track {
  display: flex;
  flex: 1;
  align-items: center;
  height: 28px;
  cursor: pointer;
  touch-action: none;
  outline: none;
}

.scrub-rail {
  flex: 1;
  height: 3px;
  overflow: hidden;
  background: rgb(255 255 255 / 0.4);
  border-radius: 2px;
  box-shadow: 0 0 6px rgb(0 0 0 / 0.25);
  transition: height 0.15s ease;
}

.scrub-fill {
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}

.scrub-track:hover .scrub-rail,
.scrub-track:focus-visible .scrub-rail,
.scrub.is-scrubbing .scrub-rail {
  height: 6px;
}

.scrub-track:focus-visible .scrub-rail {
  outline: 2px solid #002fa7;
  outline-offset: 2px;
}

/* A swap (see swapper in main.js): takes stacked in one frame, one showing,
   each fitted whole. Its toggle sits at the start of the caption. */
.swap {
  position: relative;
}

.swap-pane {
  position: absolute;
  inset: 0;
}

.swap-pane[hidden] {
  display: none;
}

.figure-grid .swap-pane > img,
.figure-grid .swap-pane > video,
.figure-grid .swap-pane > .scrub {
  width: 100%;
  height: 100%;
}

.figure-grid .swap-pane > img {
  object-fit: contain;
  background: none;
}

.article-figure figcaption.has-toggle {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.swap-toggle {
  display: inline-flex;
  flex: none;
  align-items: baseline;
  gap: 7px;
  color: #a3a3a3;
}

.swap-toggle button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.swap-toggle button:hover {
  color: #171717;
}

.swap-toggle button[aria-pressed="true"] {
  color: #171717;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: default;
}

.figure-grid img.edged {
  outline: 1px solid var(--rule);
  outline-offset: -1px;
}

.article-figure figcaption {
  margin-top: 8px;
  color: #737373;
  font-size: 12px;
}

/* Embedded posts on X: X's own card, flush with the column. */
.tweet-slot {
  position: relative;
  display: flow-root; /* X floats its card; keep the slot as tall as it */
}

.tweet-slot .twitter-tweet {
  margin: 0 !important;
}

/* A `full` post (see main.js): the column's full width, cut off at the
   sheet's height with a fade, and scrolling inside its own box. */
.tweet-scroll {
  overflow-y: auto;
  scrollbar-width: none;
  border-radius: 12px; /* X's card */
}

.tweet-slot.is-clipped::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  height: 64px;
  background: linear-gradient(rgb(255 255 255 / 0), #fff);
  pointer-events: none;
}

/* Other embedded pages (an Are.na channel): a framed window, column-wide. */
.embed-slot {
  position: relative;
}

.embed-slot iframe {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

/* Clear cover over a post, so the sheet keeps the scroll wheel (see main.js). */
.tweet-slot.is-covered::after,
.embed-slot.is-covered::after {
  content: "";
  position: absolute;
  inset: 0;
}

.tweet-fallback {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
}

.card-body {
  fill: #fff;
  stroke: #000;
  stroke-width: 1.25;
  stroke-linejoin: round;
  transition: stroke 160ms ease;
}

/* Only the selected (open) file — or the one under the cursor — gets a black
   outline; every other card is drawn in light grey. */
.card:not(.is-open) .card-body {
  stroke: #c4c4c4;
}

.card.item:hover .card-body,
.card.item:focus-visible .card-body {
  stroke: #000;
}

.tab-text {
  fill: #000;
}

/* Section cards: a black square before the title. */
.section-mark {
  fill: #000;
}

@media (max-width: 800px) {
  .layout {
    padding: 24px;
  }

  /* Phones: no grid, areas stack in page order. */
  .intro {
    display: block;
  }

  .area {
    padding: 0;
  }

  .area:empty {
    display: none;
  }

  .area + .area {
    margin-top: 16px;
  }

  /* Phones: names read normally, each next to its dot, all in one row spread
     edge to edge (wraps only if the screen is too narrow to fit them). */
  .links {
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 9px;
  }

  .links a {
    flex-direction: row;
    gap: 4px;
  }

  .links a::before {
    width: 5px;
    height: 5px;
  }

  .links span {
    writing-mode: horizontal-tb;
    line-height: 1.35;
  }

  .files {
    margin-top: 40px;
  }
}

/* Phones: the work reads top to bottom instead, media in line with the text. */
@media (max-width: 640px) {
  .big-line {
    font-size: 24px;
  }

  /* The article is inset by the margin and clipped with rounded corners, so
     content cut off at the top and bottom gets rounded corners too. */
  .article-frame {
    box-sizing: border-box;
    padding: 0 var(--pad, 0px);
  }

  .article {
    display: block;
    padding: 0;
    border-radius: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .article-progress {
    margin-left: 0;
  }

  .article-opening {
    display: block;
    width: auto;
    height: auto;
  }

  .article-opening::after,
  .article-opening-gap {
    display: none;
  }

  .article-opening-text > p:last-child {
    margin-bottom: 14px;
  }

  .article-section {
    display: block;
    height: auto;
  }

  .flow {
    width: auto;
    height: auto;
    columns: auto;
  }

  /* Sections are split by a thin line across instead. */
  .article-section + .article-section {
    margin: 32px 0 0;
    padding: 32px 0 0;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }

  .article::after {
    display: none;
  }

  .figure-grid {
    gap: 6px;
  }
}
