/* Tile-workshop sheet: beige paper, white drawing boards, cobalt lines, red for what you draw now. */
:root {
  --paper: #f6f1e7;
  --board: #fffcf6;
  --blue: #161412;
  --tile: #fffcf6;
  --tile-line: #161412;
  --red: #d4442a;
  --saffron: #f2b324;
  --frame: #161412;
  --sand: #d8cdb9;
  --text: #161412;
  --muted: #625a50;
  --col: 62rem;
  --page: 80rem;
  --t-s: clamp(1rem, 0.93rem + 0.31vw, 1.125rem);
  --t-m: clamp(1.125rem, 0.95rem + 0.78vw, 1.5rem);
  --t-l: clamp(1.5rem, 1.2rem + 1.35vw, 2.125rem);
  --t-xl: clamp(1.875rem, 1.43rem + 2.2vw, 2.875rem);
  --t-xxl: clamp(2.5rem, 1.67rem + 4.2vw, 4.25rem);
  --sp1: 0.5rem;
  --sp2: 1rem;
  --sp3: 1.5rem;
  --sp4: 2.5rem;
  --sp5: 4rem;
  --sp6: 6.5rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --f-head: "Zilla Slab", Rockwell, "Roboto Slab", Georgia, serif;
  --f-text: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .2 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--text);
  font-family: var(--f-text);
  font-size: var(--t-m);
  line-height: 1.6;
  font-kerning: normal;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  color: var(--blue);
  text-decoration-color: var(--red);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--red);
}

a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

p,
li {
  text-wrap: pretty;
}

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.col {
  max-width: var(--col);
}

/* masthead */
.bar .wrap {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  padding-top: var(--sp3);
}

.bar a {
  font-family: var(--f-head);
  font-size: var(--t-m);
  color: var(--blue);
  text-decoration: none;
}

.bar .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp1);
}

.bar .brand svg {
  width: 22px;
  height: 22px;
}

.bar .brand svg path {
  fill: none;
  stroke: var(--red);
  stroke-width: 2;
  stroke-linejoin: round;
}

.bar nav {
  display: flex;
  gap: var(--sp2);
  margin-left: auto;
}

.bar nav a {
  font-family: var(--f-text);
  font-size: var(--t-m);
  color: var(--muted);
}

.bar a:hover,
.bar nav a:hover {
  color: var(--red);
}

/* headings */
.page-head {
  padding: var(--sp6) 0 var(--sp5);
}

h1 {
  font-family: var(--f-head);
  font-weight: 400;
  color: var(--blue);
  font-size: var(--t-xxl);
  line-height: 1.05;
  margin: 0 0 var(--sp3);
}

h2 {
  font-family: var(--f-head);
  font-weight: 400;
  color: var(--blue);
  font-size: var(--t-xl);
  line-height: 1.1;
  margin: 0 0 var(--sp3);
}

h3 {
  font-family: var(--f-head);
  font-weight: 400;
  color: var(--blue);
  font-size: var(--t-l);
  line-height: 1.15;
  margin: 0 0 var(--sp2);
}

.meta {
  margin: 0 0 var(--sp2);
  color: var(--red);
  font-size: var(--t-s);
}

.lede {
  margin: 0;
  font-size: var(--t-l);
  line-height: 1.35;
}

section {
  padding: 0 0 var(--sp6);
}

section p {
  margin: 0 0 var(--sp2);
}

/* drawings */
.fig {
  display: block;
  width: 100%;
  height: auto;
  color: var(--blue);
}

.fig .pat {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.fig .unit {
  fill: var(--board);
  stroke: var(--sand);
  stroke-width: 1.25px;
  vector-effect: non-scaling-stroke;
}

.fig .unit-hl {
  fill: none;
  stroke: var(--red);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.fig .c-old {
  fill: none;
  stroke: var(--sand);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.fig .c-new {
  fill: none;
  stroke: var(--red);
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
}

.fig .c-grid {
  fill: none;
  stroke: var(--sand);
  stroke-width: 0.75px;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
}

.fig .pt {
  fill: var(--red);
}

.hero {
  margin: 0 0 var(--sp6);
}

.hero summary {
  display: block;
  cursor: pointer;
  list-style: none;
}

.hero summary::-webkit-details-marker {
  display: none;
}

.hero .more {
  display: inline-block;
  margin: var(--sp2) 0 0;
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 0.18em;
}

.hero summary:hover .more {
  color: var(--red);
}

.hero summary:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.hero .hide,
.hero .big,
.hero .ms,
.hero .mb,
.hero[open] .show,
.hero[open] .strip {
  display: none;
}

.hero[open] .big {
  display: block;
}

.hero[open] .hide {
  display: inline;
}

.hero[open] {
  max-width: none;
}


.steps .fig {
  background: var(--board);
}

/* construction steps */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
  gap: var(--sp4);
  align-items: start;
  padding: 0 0 var(--sp6);
}

.steps h3::before {
  content: counter(step);
  display: block;
  margin: 0 0 var(--sp1);
  font-size: var(--t-xl);
  line-height: 1;
  color: var(--red);
}

.steps p {
  margin: 0 0 var(--sp2);
}

.measured {
  color: var(--muted);
  font-size: var(--t-s);
  font-style: italic;
}

.measured b {
  color: var(--red);
  font-weight: 400;
}

@media (max-width: 760px) {
  .steps > li {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp3);
  }

  .steps > li > div {
    order: -1;
  }
}

/* how every pattern is built */
.how {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp2);
  margin: var(--sp4) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: how;
}

.how li {
  counter-increment: how;
}

.how .fig {
  display: block;
  background: var(--board);
  border: 2px solid var(--frame);
}

.how p {
  margin: var(--sp1) 0 0;
  font-size: var(--t-s);
  font-style: italic;
  color: var(--muted);
}

.how p::before {
  content: counter(how) ". ";
  font-style: normal;
  color: var(--red);
}

@media (max-width: 760px) {
  .how {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp3) var(--sp2);
  }
}

/* index: the only boxes are the links */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(17rem, 40vw), 1fr));
  gap: var(--sp5) var(--sp4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card a {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.tile {
  display: block;
  margin: 0;
  background: var(--tile);
  border: 2px solid var(--frame);
}

.tile .fig {
  background: var(--tile);
  color: var(--tile-line);
  transition: color 0.2s;
}

.card a:hover .fig {
  color: var(--blue);
}

.card .txt {
  padding: var(--sp2) 0 0;
}

.card h3 {
  font-size: var(--t-l);
  margin: 0 0 var(--sp1);
}

.card a:hover h3 {
  color: var(--red);
}

.card p {
  margin: 0.25em 0 0;
  color: var(--muted);
  font-size: var(--t-s);
  line-height: 1.35;
}

/* facts */
.facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp3);
  margin: 0 0 var(--sp4);
}

.facts dt {
  color: var(--red);
  font-size: var(--t-s);
}

.facts dd {
  margin: 0;
  font-family: var(--f-head);
  font-size: var(--t-l);
  line-height: 1.2;
  color: var(--blue);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--sp3);
  padding: 0 0 var(--sp6);
}

.pager a {
  font-family: var(--f-head);
  font-size: var(--t-m);
  text-decoration: none;
}

footer {
  padding: 0 0 var(--sp5);
  color: var(--muted);
  font-size: var(--t-s);
  font-style: italic;
}

@media (max-width: 760px) {
  .cards {
    gap: var(--sp4) var(--sp2);
  }

  .card h3 {
    font-size: var(--t-m);
  }
}

@media (max-width: 760px) {
  .facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* colouring */
.hero[data-palette="zellige"] {
  --f0: #f6f1e6;
  --f1: #1f6b55;
  --f2: #2b5597;
  --f3: #c8963a;
  --pl: #174d3d;
  --lw: 1;
}

.hero[data-palette="iznik"] {
  --f0: #f8f4ec;
  --f1: #1f3f8a;
  --f2: #3b9ca3;
  --f3: #b2382b;
  --pl: #1b2340;
  --lw: 1;
}

.hero[data-palette="timurid"] {
  --f0: #1e3a78;
  --f1: #2f9fb3;
  --f2: #d3a23f;
  --f3: #f3eee2;
  --pl: #f3eee2;
  --lw: 1;
}

.hero[data-palette] .tile .fig {
  color: var(--pl);
}

.paint {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp1);
  margin: calc(-1 * var(--sp5)) 0 var(--sp6);
}

.paint button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp1);
  min-height: 44px;
  padding: 0 var(--sp2);
  font: inherit;
  font-size: var(--t-s);
  color: var(--blue);
  background: var(--board);
  border: 1px solid var(--sand);
  border-radius: 4px;
  cursor: pointer;
}

.paint button[aria-pressed="true"] {
  border-color: var(--red);
  color: var(--red);
}

.paint button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.sw {
  display: inline-block;
  width: 2.25em;
  height: 0.9em;
  border-radius: 2px;
}

.sw-zellige {
  background: linear-gradient(90deg, #f6f1e6 0 33%, #1f6b55 33% 66%, #2b5597 66%);
}

.sw-iznik {
  background: linear-gradient(90deg, #f8f4ec 0 33%, #1f3f8a 33% 66%, #3b9ca3 66%);
}

.sw-timurid {
  background: linear-gradient(90deg, #1e3a78 0 33%, #2f9fb3 33% 66%, #d3a23f 66%);
}


@media (max-width: 760px) {
  .hero .strip,
  .hero[open] .big {
    display: none;
  }

  .hero .ms {
    display: block;
  }

  .hero[open] .ms {
    display: none;
  }

  .hero[open] .mb {
    display: block;
  }

  .hero {
    margin-block-end: var(--sp5);
  }

  .paint {
    flex-wrap: nowrap;
    gap: 0.25rem;
    margin-block-start: calc(-1 * var(--sp4));
  }

  .paint button {
    flex: 1 1 auto;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 0.25rem;
  }

  .paint .sw {
    width: 1.2em;
  }
}

@media (max-width: 560px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp3) var(--sp2);
  }
}

@media (max-width: 359px) {
  .paint {
    flex-wrap: wrap;
  }
}

.history .src {
  color: var(--muted);
  font-size: var(--t-s);
}

.zoom {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  font: inherit;
  background: none;
  border: 0;
  cursor: zoom-in;
}

.zoom .fig {
  display: block;
  border: 2px solid var(--frame);
}

.zoom:hover .fig,
.zoom:focus-visible .fig {
  border-color: var(--red);
}

.zoom:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.full {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: var(--sp2);
  background: var(--paper);
  border: 0;
  cursor: zoom-out;
}

.full::backdrop {
  background: var(--paper);
}

.full[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp2);
}

.full-fig {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
}

.full-fig {
  align-items: center;
}

.full-fig .fig {
  width: min(100%, calc(100dvh - 7rem));
  height: auto;
  border: 2px solid var(--frame);
}

.full-close {
  min-height: 44px;
  padding: 0 var(--sp2);
  font: inherit;
  color: var(--blue);
  background: var(--board);
  border: 1px solid var(--sand);
  border-radius: 4px;
  cursor: pointer;
}

@media (max-width: 760px) {
  .steps .zoom {
    max-width: 16rem;
  }
}

.how.plain p::before {
  content: none;
}

.rules {
  margin: 0 0 var(--sp3);
  padding: 0 0 0 1.2em;
}

.rules li {
  margin: 0 0 var(--sp2);
}

@media (max-width: 760px) {
  .bar .wrap {
    gap: var(--sp2);
    padding-top: var(--sp2);
  }

  .bar a,
  .bar nav a {
    font-size: var(--t-s);
    white-space: nowrap;
  }


  .bar nav {
    gap: var(--sp2);
  }
}

@media (max-width: 374px) {
  .bar .brand span {
    display: none;
  }
}

.ic {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  margin-right: 0.35em;
  vertical-align: -0.12em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.ic .on {
  fill: currentColor;
}

.metas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15em 0.9em;
}

.metas span {
  display: inline-flex;
  align-items: center;
}

.metas .ic {
  color: var(--red);
}

.facts dd .ic {
  width: 0.8em;
  height: 0.8em;
  vertical-align: -0.02em;
  color: var(--red);
  stroke-width: 1.4;
}

/* poster theme */
html,
body {
  overflow-x: clip;
}

body {
  background-image: none;
}

h1,
h2,
h3,
.facts dd,
.card h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 {
  line-height: 0.98;
}

h2,
h3 {
  line-height: 1.08;
}

.bar {
  background: var(--frame);
}

.bar .wrap {
  padding-block: var(--sp2);
}

.bar a,
.bar .brand {
  color: var(--paper);
  font-weight: 700;
}

.bar nav a {
  color: var(--paper);
  font-weight: 500;
}

.bar a:hover,
.bar nav a:hover,
.bar nav a[aria-current="page"] {
  color: var(--saffron);
}

.bar .brand svg path {
  stroke: var(--saffron);
}

.page-head {
  position: relative;
  isolation: isolate;
  padding-block: var(--sp5);
  margin-block-end: var(--sp5);
  color: var(--frame);
}

.page-head::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 -100vw;
  background: var(--saffron);
}

.page-head .meta {
  color: var(--frame);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: var(--t-s);
}

.page-head.home {
  color: var(--paper);
  padding-block: var(--sp6);
}

.page-head.home::before {
  background: var(--red);
}

.page-head.home h1 {
  color: var(--paper);
  max-width: 11ch;
}

.page-head.home .lede {
  max-width: 34rem;
  font-size: var(--t-m);
  line-height: 1.5;
}

.page-head.home a {
  color: var(--paper);
  text-decoration-color: var(--saffron);
}

.poster-art {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: calc(-1 * var(--gutter) - 8rem);
  width: min(46rem, 70vw);
  transform: translateY(-50%);
  pointer-events: none;
}

.poster-art .fig {
  display: block;
  width: 100%;
  height: auto;
  color: var(--saffron);
  opacity: 0.55;
}

h1,
h2,
.card h3,
.facts dd {
  color: var(--frame);
}

a {
  text-decoration-color: var(--red);
}

.steps h3::before,
.facts dt,
.history .src a {
  color: var(--red);
}

.facts dt {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.paint button {
  border: 2px solid var(--frame);
  border-radius: 999px;
  color: var(--frame);
  font-weight: 500;
  background: var(--board);
}

.paint button[aria-pressed="true"] {
  background: var(--frame);
  border-color: var(--frame);
  color: var(--paper);
}

.card a:hover .tile,
.card a:focus-visible .tile {
  background: var(--saffron);
}

.card a:hover h3 {
  color: var(--red);
}

.hero .more {
  color: var(--frame);
  font-weight: 600;
}

footer {
  margin-top: var(--sp5);
  padding-top: var(--sp4);
  background: var(--frame);
  color: var(--paper);
  font-style: normal;
}

footer a {
  color: var(--saffron);
}

@media (max-width: 760px) {
  .poster-art {
    top: auto;
    bottom: -30vw;
    right: -35vw;
    width: 95vw;
    transform: none;
  }

  .poster-art .fig {
    opacity: 0.4;
  }

  .page-head.home {
    padding-block: var(--sp5);
  }
}

.card a:hover .tile .fig,
.card a:focus-visible .tile .fig {
  background: var(--saffron);
}

.page-head.home {
  overflow: clip;
  overflow-clip-margin: 0;
}

.page-head.home::before {
  inset: 0;
}

.page-head.home {
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  max-width: none;
}

.page-head.home > * {
  max-width: var(--col);
}

.page-head.home {
  overflow: visible;
  box-shadow: 0 0 0 100vmax var(--red);
  clip-path: inset(0 -100vmax);
}

/* icons sit on the baseline and rise to the x-height */
.ic,
.facts dd .ic {
  display: inline-block;
  width: auto;
  height: 1ex;
  margin-right: 0.4em;
  vertical-align: baseline;
  overflow: visible;
  stroke-width: 1.5px;
}

.ic * {
  vector-effect: non-scaling-stroke;
}

.metas {
  align-items: baseline;
}

.metas span {
  display: inline;
}

.bar .wrap {
  align-items: baseline;
}

.bar .brand {
  display: inline-block;
}

.bar .brand svg,
.bar .brand svg {
  display: inline-block;
  width: auto;
  height: 1cap;
  margin-right: 0.35em;
  vertical-align: baseline;
  overflow: visible;
}

/* home: pattern all round, text in a rounded red card */
.page-head.home .poster-art {
  top: 0;
  bottom: 0;
  left: 50%;
  right: auto;
  width: 100vw;
  max-width: none;
  transform: translateX(-50%);
}

.page-head.home .poster-art .fig {
  width: 100%;
  height: 100%;
  opacity: 0.6;
}

.home-card {
  max-width: 44rem;
  padding: var(--sp4);
  background: var(--red);
  border-radius: 1.5rem;
}

.home-card h1 {
  margin-top: 0;
}

.home-card .lede {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .page-head.home .poster-art {
    bottom: 0;
    right: auto;
    width: 100vw;
    transform: translateX(-50%);
  }

  .home-card {
    padding: var(--sp3);
    border-radius: 1rem;
  }
}

.home-card {
  width: fit-content;
  padding-inline-end: var(--sp5);
}

@media (max-width: 760px) {
  .home-card {
    padding-inline-end: var(--sp3);
  }
}

.facts dd {
  font-size: var(--t-m);
  line-height: 1.25;
}

.facts .nw {
  white-space: nowrap;
}

.card a:hover .tile,
.card a:focus-visible .tile,
.card a:hover .tile .fig,
.card a:focus-visible .tile .fig {
  background: var(--red);
  color: var(--saffron);
}

.sw {
  width: 2.6em;
  height: 1em;
  border-radius: 3px;
}

.sw-zellige {
  background: linear-gradient(90deg, #f6f1e6 0% 25%, #1f6b55 25% 50%, #2b5597 50% 75%, #c8963a 75% 100%);
  box-shadow: inset 0 0 0 1.5px #174d3d;
}

.sw-iznik {
  background: linear-gradient(90deg, #f8f4ec 0% 25%, #1f3f8a 25% 50%, #3b9ca3 50% 75%, #b2382b 75% 100%);
  box-shadow: inset 0 0 0 1.5px #1b2340;
}

.sw-timurid {
  background: linear-gradient(90deg, #1e3a78 0% 25%, #2f9fb3 25% 50%, #d3a23f 50% 75%, #f3eee2 75% 100%);
  box-shadow: inset 0 0 0 1.5px #f3eee2;
}

.tile,
.zoom .fig,
.how .fig,
.full-fig .fig {
  border-width: 3px;
}

.facts dd {
  font-size: clamp(1.0625rem, 0.98rem + 0.4vw, 1.3125rem);
}

/* centred column, text stays left */
.col {
  margin-inline: auto;
}

.page-head.home .home-card {
  margin-inline: 0;
}

/* sticky bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* hero: always large, proportions follow the window */
.hero {
  margin: 0 auto var(--sp5);
  max-width: none;
}

.hero .tile {
  display: block;
  height: clamp(20rem, 62svh, 46rem);
  overflow: hidden;
}

.hero .tile .fig {
  display: block;
  width: 100%;
  height: 100%;
}

.hero .hm {
  display: none;
}

.paint {
  margin-top: 0;
}

@media (max-width: 760px) {
  .hero .hd {
    display: none;
  }

  .hero .hm {
    display: block;
    height: 64svh;
  }
}

.page-head.home .home-card {
  margin-inline: max(0px, (100% - var(--col)) / 2) auto;
}

.ic,
.facts dd .ic {
  height: 1cap;
}

@supports not (height: 1cap) {
  .ic,
  .facts dd .ic {
    height: 0.7em;
  }
}
