/* The blog: its index, its tag pages and every article. Served as one
   file together with figures.css, the figures inside an article
   (layouts/_default/baseof.html joins them).

   The layout is a magazine page, not a column of app cards: one canvas, and a
   reading measure centered in it that only a cover or a wide figure breaks out
   of. Rules (lines) separate things; boxes are for things you can press.
   Type roles and colors come from partials/brand.html, never from here. */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --canvas: 1040px;
  --measure: 640px;
  --gutter: 24px;
  --rule: var(--ps-linen);
}

body {
  font: var(--type-body);
  color: var(--text);
  background: var(--ps-gesso);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main,
.site-nav {
  max-width: calc(var(--canvas) + 2 * var(--gutter));
  margin: 0 auto;
  padding-inline: var(--gutter);
  width: 100%;
}

main { flex: 1; }

/* Nav */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 24px;
}

.site-nav a {
  color: var(--text);
  text-decoration: none;
}

.nav-home {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-home img {
  display: block;
  width: auto;
  height: 22px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-nav .nav-blog {
  font: var(--type-caption);
  color: var(--text-2);
}

.site-nav .nav-blog:hover { color: var(--ps-prussian); }

/* Masthead: the head of an article, of the index and of a tag page. One heavy
   rule on top, the way a magazine opens a page. */
.masthead {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--text);
}

.masthead h1 {
  font: var(--type-display);
  letter-spacing: var(--track-display);
  color: var(--accent);
  max-width: 18em;
}

.masthead-deck {
  font: var(--type-lead);
  color: var(--text-2);
  max-width: var(--measure);
  margin-top: 12px;
}

/* Eyebrow: the tags a post belongs to, above its title. */
.eyebrow {
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: var(--case-label);
  color: var(--text-2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 12px;
}

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

.eyebrow a:hover { color: var(--ps-prussian); }

.post-date {
  font: var(--type-caption);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.masthead .post-date {
  display: block;
  margin-top: 16px;
}

/* Article: everything sits on the centered reading measure, except the cover,
   wide figures and the related posts, which take the canvas. */
article > .masthead,
.article-body,
.faq,
.app-card {
  max-width: var(--measure);
  margin-inline: auto;
}

.article-cover {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-card);
  margin-top: 32px;
}

.article-body {
  font: var(--type-body-long);
  color: var(--text);
  margin-top: 32px;
  counter-reset: section figure;
}

/* The opening paragraph is the answer to the title, so it reads a step up. */
.article-body > p:first-child { font: var(--type-lead); }

/* Sections are numbered, so a reader always knows where they are in a long
   piece. */
.article-body h2 {
  font: var(--type-title);
  letter-spacing: var(--track-title);
  color: var(--accent);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  counter-increment: section;
}

.article-body h2::before {
  content: counter(section, decimal-leading-zero);
  display: block;
  font: var(--type-label);
  letter-spacing: var(--track-label);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  margin-bottom: 8px;
}

.article-body h3 {
  font: var(--type-heading);
  letter-spacing: var(--track-heading);
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 12px;
}

.article-body p { margin-bottom: 20px; }

.article-body ul,
.article-body ol {
  margin-bottom: 20px;
  padding-inline-start: 24px;
}

.article-body li { margin-bottom: 8px; }

.article-body a {
  color: var(--ps-prussian);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-body a:hover { color: var(--text); }

.article-body strong { font-weight: 600; }

.article-body table {
  font-variant-numeric: tabular-nums;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  overflow-x: auto;
  display: block;
}

.article-body thead { border-bottom: 2px solid var(--text); }

.article-body th {
  font-weight: 600;
  text-align: start;
  padding-block: 10px;
  padding-inline: 0 16px;
  white-space: nowrap;
}

.article-body td {
  padding-block: 8px;
  padding-inline: 0 16px;
  vertical-align: top;
}

.article-body tbody tr { border-bottom: 1px solid var(--rule); }
.article-body tbody tr:last-child { border-bottom: none; }

.article-body blockquote {
  font: var(--type-title);
  letter-spacing: var(--track-title);
  color: var(--accent);
  margin: 32px 0;
}

.article-body code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9em;
  background: var(--ps-prussian-wash);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.article-body pre {
  background: var(--ps-ivory-black);
  color: var(--ps-gesso);
  padding: 20px;
  border-radius: var(--radius-control);
  overflow-x: auto;
  margin-bottom: 20px;
}

.article-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

/* FAQ */
.faq {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 2px solid var(--text);
}

.faq h2 {
  font: var(--type-title);
  letter-spacing: var(--track-title);
  color: var(--accent);
  margin-bottom: 16px;
}

.faq details {
  border-bottom: 1px solid var(--rule);
  padding: 14px 0;
}

.faq details:first-of-type { border-top: 1px solid var(--rule); }

.faq summary {
  font: var(--type-heading);
  letter-spacing: var(--track-heading);
  cursor: pointer;
  list-style: none;
}

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

.faq summary::before {
  color: var(--text-2);
  content: "+ ";
}

details[open] summary::before { content: "- "; }

.faq details p { margin-top: 10px; }

/* Posts: one card, three sizes. A card is a picture and words on the page
   itself, with no box around them. */
.post-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.post-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
}

.post-card .eyebrow { margin-bottom: 8px; }

.post-card-title {
  font: var(--type-title);
  letter-spacing: var(--track-title);
  color: var(--accent);
  margin-bottom: 8px;
}

.post-card:hover .post-card-title { color: var(--text); }
.post-card:active { opacity: 0.85; }

.post-card p {
  color: var(--text-2);
  margin-bottom: 8px;
}

.post-card--lead .post-card-title {
  font: var(--type-display);
  letter-spacing: var(--track-display);
}

.post-card--lead p { font: var(--type-lead); }

.post-card--compact .post-card-title {
  font: var(--type-heading);
  letter-spacing: var(--track-heading);
}

.post-card--compact p {
  font: var(--type-caption);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Index and tag pages */
/* The tag index closes the page: a reader browses the posts first, and filters
   only if what they want is not in sight. */
.blog-tags {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 2px solid var(--text);
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}

.tag-group + .tag-group { margin-top: 8px; }

.tag-group-label {
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: var(--case-label);
  color: var(--text-2);
  min-width: 72px;
}

.tag-group a {
  font: var(--type-caption);
  color: var(--text);
  text-decoration: none;
}

.tag-group a:hover { color: var(--ps-prussian); }

.tag-count {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.post-lead {
  margin-top: 32px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--rule);
}

.post-grid {
  display: grid;
  gap: 40px 32px;
  margin-top: 40px;
}

/* The rest of the catalog: dense on purpose, so a reader can scan every title
   the blog has. A small square of each cover keeps the list alive. */
.post-index {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 2px solid var(--text);
}

.section-label {
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: var(--case-label);
  color: var(--text-2);
  margin-bottom: 8px;
}

.post-index ul { list-style: none; }

.post-index li {
  border-bottom: 1px solid var(--rule);
  break-inside: avoid;
}

.post-index a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  color: inherit;
  text-decoration: none;
}

.post-index img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-control);
}

.post-index-title {
  display: block;
  font-weight: 500;
  color: var(--accent);
}

.post-index a:hover .post-index-title { color: var(--text); }

/* Related posts */
.related-posts {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 2px solid var(--text);
}

.related-grid {
  display: grid;
  gap: 32px;
  margin-top: 16px;
}

@media (min-width: 600px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .post-index ul { columns: 2; column-gap: 32px; }
}

@media (min-width: 800px) {
  .post-card--lead {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 32px;
    align-items: center;
  }

  .post-card--lead img { margin-bottom: 0; }
}

/* App card (blog CTA) */
.app-card {
  margin-top: 48px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
  padding: 24px;
}

.app-card-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-card-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.app-card-name {
  font: var(--type-heading);
  letter-spacing: var(--track-heading);
  color: var(--text);
  margin: 0;
}

.app-card-tagline {
  color: var(--text-2);
  margin: 4px 0 0;
}

.app-card-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* The QR (computers only) takes the start of the row, the buttons the end. */
.app-card-badges .store-qr { margin-inline-end: auto; }

/* Custom store buttons: identical container so Apple and Google match. */
.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 16px;
  background: #000;
  border: 1px solid #000;
  border-radius: var(--radius-control);
  color: #fff;
  text-decoration: none;
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}

.store-btn:hover { opacity: 0.85; }

.store-btn-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
}

.store-btn-glyph svg {
  display: block;
  height: 22px;
  width: auto;
}

.store-btn--apple .store-btn-glyph svg { fill: #fff; }
.store-btn--google .store-btn-glyph svg { height: 21px; }

.store-btn-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.store-btn-top {
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  opacity: 0.95;
}

.store-btn-top--caps {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.store-btn-name {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-card-chrome {
  display: inline-flex;
  align-items: center;
  height: 52px;
  padding: 0 20px;
  background: #000;
  border: 1px solid #000;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-control);
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}

.app-card-chrome:hover { opacity: 0.85; }

/* Footer */
footer {
  font: var(--type-caption);
  color: var(--text-2);
  text-align: center;
  margin-top: 64px;
  padding: 24px;
  border-top: 1px solid var(--rule);
}

footer a {
  color: var(--ps-paynes-grey);
  text-decoration: none;
}

footer a:hover { color: var(--ps-prussian); }

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .site-nav { padding-block: 16px; }
}

/* RTL */
/* The whole page mirrors via dir="rtl" on <html>; layout uses logical
   properties so it flips automatically. Two deliberate exceptions: the nav
   stays LTR so the language selector and logo never move (a consistent escape
   hatch for a reader who landed on Arabic by mistake), and code/pre stays LTR
   because code is not RTL. */
html[dir="rtl"] .site-nav { direction: ltr; }

html[dir="rtl"] .article-body pre,
html[dir="rtl"] .article-body code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

/* Arabic: no tracking on cursive script (it disconnects the joins). */
html[dir="rtl"] .store-btn-top,
html[dir="rtl"] .store-btn-top--caps {
  letter-spacing: 0;
}
/* Figures inside an article (layouts/shortcodes/fig.html and the pieces that
   go in it). Served in the same file as blog.css.

   A figure is a graphic with its caption underneath, as wide as the reading
   measure. A wide figure breaks out to the full canvas, centered on the same
   axis, and keeps its caption on the measure. */

.fig {
  margin-block: 12px 32px;
  counter-increment: figure;
}

.fig figcaption {
  font: var(--type-caption);
  color: var(--text-2);
  margin-top: 12px;
}

/* Figures are numbered like the sections, so the text can be found again from
   a picture. A number needs no translation. */
.fig figcaption::before {
  content: counter(figure, decimal-leading-zero);
  display: block;
  font: var(--type-label);
  letter-spacing: var(--track-label);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-bottom: 4px;
}

.fig figcaption a { color: inherit; }

/* The canvas is wider than the measure by the same amount on each side. */
.fig--wide .fig-graphic {
  --canvas-now: min(var(--canvas), 100vw - 2 * var(--gutter));
  width: var(--canvas-now);
  margin-inline-start: calc((100% - var(--canvas-now)) / 2);
}

/* Pieces set side by side share the graphic's width equally. */
.fig-graphic {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* Pieces that belong in rows of a fixed number, at every width. One piece can
   take a whole row: the enlargement under the pair it comes from. */
.fig--rows .fig-graphic {
  grid-auto-flow: row;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
}

.fig-graphic > .marked--row { grid-column: 1 / -1; }

/* On a narrow screen a long row can fold into rows of a few pieces. */
@media (max-width: 600px) {
  .fig--folds .fig-graphic {
    grid-auto-flow: row;
    grid-template-columns: repeat(var(--narrow-columns), minmax(0, 1fr));
  }
}

/* Mixtures stack instead: each one is a full-width strip. */
.fig-graphic:has(> .mix) {
  grid-auto-flow: row;
  gap: 20px;
}

.mix-strip,
.mixchart-cell {
  border-radius: var(--radius-sm);
}

.mix-ends,
.mixchart-label {
  font: var(--type-caption);
  color: var(--text-2);
}

/* Mix: a strip from one color to another. */
.mix-strip {
  display: flex;
  height: 56px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(22, 24, 27, 0.08);
}

.mix-strip span { flex: 1; }

.mix-ends {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
}

/* Mix chart: every pair of colors, each lightened row by row. */
.mixchart {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: 4px;
}

.mixchart-label {
  padding-bottom: 4px;
  align-self: end;
  overflow-wrap: anywhere;
}

.mixchart-cell { aspect-ratio: 3 / 2; }

/* Artwork: a picture from the post's folder. */
.artwork img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Only the colors of a picture: over a gray, the picture gives its hue and
   strength of color and takes the gray's lightness, the same everywhere. */
.artwork-flat {
  display: block;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.artwork-flat img { mix-blend-mode: color; }

/* Gridded: a picture under a drawing grid. The picture always fills its
   surface, so a surface with other proportions shows it stretched, which is
   the mistake that figure exists to show. */
.gridded-surface {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.gridded-surface img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.gridded-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  --line: rgba(245, 243, 238, 0.8);
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--columns)) calc(100% / var(--rows));
  box-shadow: inset 0 0 0 1px var(--line);
}

/* One square, outlined on the whole picture and again around its enlargement,
   so the eye ties the two together. */
.gridded-mark,
.gridded--cell .gridded-surface::after {
  box-shadow: inset 0 0 0 3px var(--ps-cadmium-yellow);
}

.gridded-mark {
  position: absolute;
  z-index: 1;
  width: calc(100% / var(--columns));
  height: calc(100% / var(--rows));
  inset-inline-start: calc((var(--column) - 1) * 100% / var(--columns));
  top: calc((var(--row) - 1) * 100% / var(--rows));
}

.gridded--cell .gridded-surface img {
  position: absolute;
  width: calc(var(--columns) * 100%);
  height: calc(var(--rows) * 100%);
  max-width: none;
  inset-inline-start: calc((var(--column) - 1) * -100%);
  top: calc((var(--row) - 1) * -100%);
}

.gridded--cell .gridded-surface::after { background-image: none; }

.gridded-label,
.artwork-label {
  display: block;
  font: var(--type-caption);
  color: var(--text-2);
  margin-top: 6px;
}

/* Same value: two colors with the gray they share between them, so the gray
   reads as one band that belongs to both, over a value scale with their step
   outlined. */
.samevalue-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.samevalue-names {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  font: var(--type-caption);
  color: var(--text-2);
  margin-top: 6px;
}

.samevalue-names span:nth-child(2) {
  color: var(--text);
  text-align: center;
}

.samevalue-names span:last-child { text-align: end; }

.samevalue-scale {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 4px;
  margin-top: 24px;
  font: var(--type-caption);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  text-align: center;
}

.samevalue-scale i {
  display: block;
  aspect-ratio: 1;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px rgba(22, 24, 27, 0.08);
}

.samevalue-step { color: var(--text); font-weight: 600; }

.samevalue-step i {
  box-shadow: none;
  outline: 3px solid var(--ps-cadmium-yellow);
}

/* A marked step of a mix: outlined, with its words right over it. */
.mix-note {
  display: grid;
  grid-template-columns: repeat(var(--steps), minmax(0, 1fr));
  font: var(--type-caption);
  font-weight: 600;
  margin-bottom: 6px;
}

.mix-note span {
  grid-column: var(--mark);
  justify-self: center;
  white-space: nowrap;
}

.mix-mark { box-shadow: inset 0 0 0 3px var(--ps-cadmium-yellow); }

/* Marked: a picture with words that point at places in it. A word sits beside
   its place, joined to it by a hairline that ends in a dot. */
.marked-surface { position: relative; }

.marked-surface img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* The outlined part of a picture, and the outline around its enlargement. */
.marked-box,
.marked-surface--outlined::after {
  position: absolute;
  box-shadow: inset 0 0 0 3px var(--ps-cadmium-yellow);
}

.marked-surface--outlined::after {
  content: "";
  inset: 0;
}

.marked-point {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateY(-50%);
  font: var(--type-caption);
  font-weight: 600;
  color: var(--ps-gesso);
  white-space: nowrap;
}

.marked--dark .marked-point { color: var(--ps-ivory-black); }

.marked-point--left { flex-direction: row-reverse; }

.marked-point::before {
  content: "";
  width: 28px;
  height: 5px;
  background:
    radial-gradient(circle at 2.5px 2.5px, currentColor 2.5px, transparent 3px),
    linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
}

.marked-point--left::before { transform: scaleX(-1); }

.marked-label,
.surround-label,
.tintpair-row,
.tintpair-names {
  font: var(--type-caption);
  color: var(--text-2);
}

.marked-label,
.surround-label {
  display: block;
  margin-top: 6px;
}

/* Tint pair: two pigments touching, alone and then lightened. The lightened
   row is the tall one: it is where the difference shows. */
.tintpair-row { display: block; margin-bottom: 6px; }

.tintpair-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  height: 144px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tintpair-pair--alone {
  height: 56px;
  margin-bottom: 16px;
}

.tintpair-names {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

/* Surround: one color on two grounds, the two grounds touching. */
.surround {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.surround-ground {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
}

.surround-ground i {
  width: 30%;
  aspect-ratio: 1;
}

.surround-piece:first-child .surround-ground { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.surround-piece:last-child .surround-ground { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
