/* XtheLine. Tokens and rules documented in DESIGN.md. */

:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-2: #707070; /* 4.95:1 on white */
  --placeholder: #ececec;

  /* Century Gothic where installed (Windows, Office); Questrial (webfont) elsewhere. */
  --font: "Century Gothic", CenturyGothic, AppleGothic, "URW Gothic", Questrial, sans-serif;
  --label: 11px;
  --reading: 13px;

  --margin: clamp(16px, 2.5vw, 40px);
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 48px;
  --s5: 96px;
  --s6: 160px;
  --wide: 1600px;
  --measure: 56ch;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Cursor: a plain black x. js/cursor.js replaces it with a drawn x that
   stretches into a trail (xxxx) proportional to mouse speed. Without JS
   (or on touch screens) this CSS cursor is used. Hotspot is the center. */
html {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M4 4L12 12M12 4L4 12' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") 8 8, auto;
}

a,
button,
[role="button"] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M3.5 3.5L12.5 12.5M12.5 3.5L3.5 12.5' stroke='%23000' stroke-width='2.6'/%3E%3C/svg%3E") 8 8, pointer;
}

html.x-cursor,
html.x-cursor * {
  cursor: none !important;
}

.x-trail {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 2147483647;
}

.x-trail svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  overflow: visible;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--label);
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1,
h2 {
  text-wrap: balance;
}

h1,
h2,
p,
ul,
dl,
dd,
figure {
  margin: 0;
  padding: 0;
  font: inherit;
}

ul {
  list-style: none;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

/* Links: underline is the entire hover vocabulary. */
a {
  color: inherit;
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover,
a[aria-current="page"] {
  text-decoration-line: underline;
}

:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  top: var(--s1);
  left: var(--margin);
  padding: 4px 0;
  background: var(--paper);
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

/* Header ------------------------------------------------------------ */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s2) var(--margin);
}

.site-header a {
  display: inline-block;
  padding: 4px 0; /* 24px touch target, no visual change */
}

.site-header ul {
  display: flex;
  gap: var(--s3);
}

/* Main -------------------------------------------------------------- */

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--margin));
  margin: 0 auto;
  padding: var(--s5) var(--margin) var(--s5);
}

@media (min-width: 1024px) {
  main {
    padding-top: var(--s6);
    padding-bottom: var(--s6);
  }
}

.meta,
figcaption {
  color: var(--ink-2);
}

.prose {
  max-width: var(--measure);
  font-size: var(--reading);
  line-height: 1.55;
  letter-spacing: 0;
  text-transform: none;
  text-wrap: pretty;
  text-align: justify;
  hyphens: none; /* no hyphenated line breaks */
  -webkit-hyphens: none;
}

.prose + .prose {
  margin-top: 1em;
}

.notice a {
  text-decoration-line: underline;
}

/* Image frame: gray placeholder until a real file is set. */

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--placeholder);
  overflow: hidden;
}

.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Home -------------------------------------------------------------- */

/* Wordmark: a big, heavier X followed by "the line", same typeface. */
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.08em;
  font-size: clamp(120px, 22vw, 320px);
  line-height: 0.8;
  letter-spacing: 0;
  text-transform: none;
}

.wordmark-x {
  font-weight: 700;
}

.wordmark-rest {
  font-size: 0.2em;
  letter-spacing: 0.02em;
}

.categories {
  margin-top: var(--s5);
  display: grid;
  gap: var(--s1);
}

.categories a {
  display: inline-block;
  padding: 4px 0;
}

@media (min-width: 1024px) {
  .categories {
    margin-top: var(--s6);
  }
}

/* List page / project page labels */
.list-title {
  margin-bottom: var(--s4);
}

.crumb {
  display: inline-block;
  margin-bottom: var(--s1);
  color: var(--ink-2);
}

/* Index ------------------------------------------------------------- */

.index {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--s2);
  row-gap: var(--s4);
}

.index a {
  display: block;
}

.index a:hover {
  text-decoration-line: none;
}

.index a:hover .name {
  text-decoration-line: underline;
}

.index .name {
  margin-top: var(--s1);
}

@media (min-width: 640px) {
  .index {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 5vw;
    row-gap: 7vw;
  }
}

@media (min-width: 1024px) {
  .index {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 6vw;
    row-gap: 8vw;
  }
}

/* Project ----------------------------------------------------------- */

/* Text left, optional image right (desktop); stacked on smaller screens. */
.project-aside {
  margin-top: var(--s4);
}

.project-aside figcaption {
  margin-top: var(--s1);
}

@media (min-width: 1024px) {
  .project-head.has-aside {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr); /* text column = prose measure */
    column-gap: var(--s5);
    align-items: start;
  }

  .project-aside {
    margin-top: 0;
  }
}

.project-head .prose {
  margin-top: var(--s3);
}

.plates {
  display: grid;
  gap: var(--s4);
  margin-top: var(--s5);
}

/* Full width, but never taller than the screen: a portrait or square
   image is always seen whole. --r (width/height) is set by main.js. */
.plates .frame {
  max-width: calc(100svh * var(--r, 1.5));
}

.plates figcaption {
  margin-top: var(--s1);
}

/* Row layout: images and text in one horizontal line (stacked on phones). */
.row-layout {
  display: grid;
  gap: var(--s4);
}

.row-layout figcaption {
  margin-top: var(--s1);
}

@media (min-width: 1024px) {
  .row-layout {
    grid-template-columns: var(--row-cols);
    gap: var(--s3);
    align-items: start;
  }
}

/* Aside layout: title, text and a small reference image on the left,
   the main image large on the right (stacked on phones). */
.aside-layout {
  display: grid;
  gap: var(--s4);
}

.aside-left {
  display: grid;
  gap: var(--s4);
  align-content: start;
}

.aside-layout figcaption {
  margin-top: var(--s1);
}

/* the reference stays small next to the main image */
.aside-ref {
  max-width: 62%;
}

@media (min-width: 1024px) {
  .aside-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
    gap: var(--s5);
    align-items: start;
  }

  /* three images: the middle and the main image share one size */
  .aside-layout.aside-three {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.5fr);
  }

  /* the main image is always seen whole: never taller than the screen below the header */
  .aside-main {
    justify-self: end;
    width: 100%;
    max-width: calc((100svh - 260px) * var(--main-r, 1));
  }

  /* the middle image: same size as the main one */
  .aside-mid {
    justify-self: end;
    width: 100%;
    max-width: calc((100svh - 260px) * var(--main-r, 1));
  }
}

/* Text under the images (layout "text-below"); main already gives top space. */
.plates:first-child {
  margin-top: 0;
}

.head-below {
  margin-top: var(--s4);
}

/* Art layout: image column left, title + text right (stacked on phones). */
.art {
  display: grid;
  gap: var(--s5);
}

.art .plates {
  margin-top: 0;
}

.art-text h1 {
  font-size: clamp(28px, 3.2vw, 48px);
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: none;
  margin-bottom: var(--s3);
}

@media (min-width: 1024px) {
  .art {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: var(--s5);
    align-items: start;
  }

  .art .plates {
    gap: var(--s3);
  }
}

/* Poem: one line per string, each line stretched to both edges. */
.poem p {
  text-align: justify;
  text-align-last: justify;
  hyphens: none;
  -webkit-hyphens: none;
}

/* Square magnifier (js/loupe.js). Thin black frame, no shadow, no radius. */
.loupe {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2147483646; /* just under the x cursor */
  pointer-events: none;
  border: 1px solid var(--ink);
  background-color: var(--paper);
  background-repeat: no-repeat;
}

/* Grid: equal cells across the full width (phones: 4 cols -> 2, 2-3 -> 1). */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s2);
}

.grid[data-cols="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid figcaption {
  margin-top: var(--s1);
}

/* Text beside a head image: the column width governs the measure. */
.project-head.head-fit .prose {
  max-width: none;
}

.head-grid {
  margin-top: var(--s3);
}

.frame-contain {
  background: var(--paper);
}

@media (min-width: 640px) {
  .grid,
  .grid[data-cols="4"] {
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--s3);
  }
}

/* Paragraph between images (type "text"). */
.plate-text .prose {
  max-width: var(--measure);
}

/* Legend under the plans: numbers and room names, two columns. */
.plates .legend {
  display: grid;
  gap: var(--s3);
  margin-top: calc(var(--s3) - var(--s4));
}

.legend ol {
  margin: var(--s1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--reading);
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
}

.legend li {
  display: grid;
  grid-template-columns: 2.2em 1fr;
}

.legend-no {
  font-variant-numeric: tabular-nums;
}

.legend li {
  break-inside: avoid;
}

/* one list over balanced columns, same rhythm as the grids above */
@media (min-width: 640px) {
  .legend ol {
    column-count: 2;
    column-gap: var(--s3);
  }
}

@media (min-width: 1024px) {
  .legend ol {
    column-count: 3;
  }
}

@media (min-width: 1024px) {
  .plates .legend {
    margin-top: calc(var(--s3) - var(--s5));
  }
}

/* Section label: separates parts of a project page with space, no rules. */
.plates .section-label {
  color: var(--ink-2);
  margin-top: var(--s4);
}

@media (min-width: 1024px) {
  .plates .section-label {
    margin-top: var(--s5);
  }
}

/* Gallery: large image with small choices below; a click swaps them. */
.gallery-choices {
  display: grid;
  grid-template-columns: var(--pair-cols, 1fr 1fr);
  gap: var(--s3);
  margin-top: var(--s3);
}

.gallery-choice {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
}

.gallery-choice:hover .frame {
  opacity: 0.85;
}

/* Pair: two images side by side, equal height (stacked on phones). */
.pair {
  display: grid;
  gap: var(--s4);
}

@media (min-width: 640px) {
  .pair {
    grid-template-columns: var(--pair-cols, 1fr 1fr);
    gap: var(--s3);
    align-items: start;
  }

  .pair.pair-bottom {
    align-items: end;
  }
}

/* Sequence: small numbered squares in reading order (model evolution). */
.sequence {
  display: grid;
  grid-template-columns: repeat(min(var(--cols, 8), 4), minmax(0, 1fr));
  column-gap: var(--s2);
  row-gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sequence .frame {
  background: var(--paper);
}

.sequence .frame[role="img"] {
  background: var(--placeholder);
}

.sequence .frame img {
  object-fit: contain;
}

.sequence .meta {
  display: block;
  margin-top: var(--s1);
}

@media (min-width: 640px) {
  .sequence {
    grid-template-columns: repeat(min(var(--cols, 8), 6), minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .sequence {
    grid-template-columns: repeat(var(--cols, 8), minmax(0, 1fr));
    column-gap: var(--s3);
    row-gap: var(--s4);
  }
}

/* Grouped sequence: groups flow side by side, one number per group. */
.sequence-groups {
  --cell: calc((100% - 3 * var(--s2)) / 4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4) var(--s4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.group-row {
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell-px));
  gap: var(--s1);
}

.sequence-groups {
  --cell-px: clamp(72px, 21vw, 150px);
}

@media (min-width: 1024px) {
  .sequence-groups {
    --cell-px: clamp(110px, 10vw, 170px);
  }
}

.group-row .frame {
  background: var(--paper);
}

.group-row .frame img {
  object-fit: contain;
}

.sequence-groups .meta {
  display: block;
  margin-top: var(--s1);
}

/* 3D model: white stage once a model file is set. */
.frame-model {
  background: var(--paper);
}

.frame-model model-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  --poster-color: transparent;
}

@media (min-width: 1024px) {
  .plates {
    gap: var(--s5);
    margin-top: var(--s6);
  }
}

.pager {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s5);
}

.pager a {
  padding: 4px 0;
}

@media (min-width: 1024px) {
  .pager {
    margin-top: var(--s6);
  }
}

/* About / Contact --------------------------------------------------- */

.block + .block {
  margin-top: var(--s5);
}

.block dt,
.block h2 {
  color: var(--ink-2);
  margin-bottom: var(--s1);
}

.block dd + dt {
  margin-top: var(--s3);
}

.about-image {
  max-width: 560px;
}

/* Footer ------------------------------------------------------------ */

.site-footer {
  padding: var(--s2) var(--margin);
  color: var(--ink-2);
}
