@font-face { font-family: "Naskh AR"; src: url(../fonts/RrQKbpV-9Dd1b1OAGA6M9PkyDuVBeN2DHV20Lg.woff2) format("woff2"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
/* GrainGrowth 2D: interactive article. Colours of the data match the colours in the text. */
:root {
  --paper: #FCFBF8;      /* warm white */
  --ink: #24282B;        /* charcoal */
  --ink-2: #4D555B;
  --ink-3: #737B81;
  --rule: #E4E1DA;
  --panel: #F3F1EC;
  --petrol: #1E5466;     /* links, active navigation, actions */
  --shrink: #3F72B8;      /* grains with fewer than six sides */
  --shrink-fill: #A9C3E6;
  --grow: #B26F12;        /* grains with more than six sides */
  --grow-fill: #EDC992;
  --six: #9AA3A9;
  --oxide: #B23A30;       /* fits, cursor, locator frame */
  --naskh: "Naskh AR", "IBM Plex Sans Arabic", serif;
  --plex: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 18.5px/2.05 var(--naskh); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; height: auto; }
a { color: var(--petrol); text-decoration-color: rgba(30,84,102,.4); text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--petrol); }
h1, h2, h3 { font-family: var(--naskh); font-weight: 700; margin: 0; }
p { margin: 0 0 1em; }
bdi { unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--petrol); outline-offset: 3px; border-radius: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 50; padding: 8px 14px; background: var(--ink); color: #fff; font: 500 15px var(--plex); }
.skip:focus { top: 10px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 12px clamp(18px, 4vw, 48px); background: rgba(252,251,248,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule); font-family: var(--plex); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 600 16px/1 var(--plex); color: var(--ink); white-space: nowrap; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 26px; font-size: 15px; }
.topbar nav a { text-decoration: none; color: var(--ink-2); padding: 4px 0; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a[aria-current] { color: var(--petrol); font-weight: 600; box-shadow: inset 0 -2px 0 var(--petrol); }

/* Masthead: compact so the first figure is visible on load */
.masthead { max-width: 1120px; margin: 0 auto; padding: 24px clamp(18px, 4vw, 48px) 16px; text-align: center; }
.masthead h1 { font-size: 40px; line-height: 1.3; }
.en { margin: 2px 0 0; font: 400 15.5px/1.5 var(--plex); color: var(--ink-3); }
.byline { display: flex; flex-wrap: wrap; justify-content: center; margin: 10px 0 0; font: 400 14px/1.7 var(--plex); color: var(--ink-2); }
.byline span + span { border-inline-start: 1px solid #CFCBC2; margin-inline-start: 14px; padding-inline-start: 14px; }
.byline i { font-style: normal; color: var(--ink-3); }
@media (max-width: 700px) {
  .masthead { padding-top: 18px; }
  .masthead h1 { font-size: 30px; }
  .en { font-size: 14px; }
  .byline { gap: 0 12px; font-size: 13.5px; }
  .byline span + span { border: 0; margin: 0; padding: 0; }
}

/* Wide interactive figures */
figure { margin: 0; }
.wide { max-width: 1120px; margin: 0 auto 56px; padding: 0 clamp(18px, 4vw, 48px); }
.wide > figcaption, .potts figcaption { font: 400 15px/1.85 var(--plex); color: var(--ink-2); margin-top: 16px; max-width: 760px; }
figcaption b { color: var(--ink); font-weight: 600; }
/* The map is sized from the viewport height so the map, slider and play button fit on the first screen */
.fig-evolve { --map: clamp(330px, calc(100svh - 300px), 600px); }
.evolve-grid { display: grid; grid-template-columns: var(--map) minmax(280px, 400px); justify-content: center; gap: 32px; background: var(--panel); border-radius: 4px; padding: 20px 28px; }
.pin-grid { display: grid; grid-template-columns: minmax(0, 560px) minmax(260px, 1fr); gap: 36px; background: var(--panel); border-radius: 4px; padding: 28px; }
.stage .frame { width: 100%; aspect-ratio: 1; border: 1px solid #C9CFD3; background: #E3E6E8; }
.controls { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.play-btn { display: inline-flex; align-items: center; gap: 10px; padding: 9px 18px 9px 20px; border: 0; border-radius: 999px; background: var(--petrol); color: #fff; font: 500 15px/1.2 var(--plex); cursor: pointer; }
.play-btn i { width: 0; height: 0; border-block: 6px solid transparent; border-inline-end: 10px solid #fff; }
.play-btn[aria-pressed="true"] i { width: 10px; height: 12px; border: 0; border-inline: 3px solid #fff; }
.scrub { flex: 1; }
input[type=range] { width: 100%; accent-color: var(--petrol); direction: ltr; }
.panel { display: flex; flex-direction: column; gap: 12px; font-family: var(--plex); }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.readouts dt { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.readouts dd { margin: 4px 0 0; font: 600 25px/1.1 var(--plex); font-variant-numeric: tabular-nums; }
.readouts small { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.mini { width: 100%; cursor: crosshair; touch-action: none; direction: ltr; }
.mini-label { margin: 4px 0 -8px; font-size: 13.5px; color: var(--ink-2); }
.nw { white-space: nowrap; }
.mini .plot-bg { fill: #fff; }
.mini .grid { stroke: #E6EAEC; }
.mini .tick { fill: var(--ink-2); font: 400 12.5px var(--plex); }
.mini .axis-label { fill: var(--ink-2); font: 500 11px var(--plex); }
.mini .line { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.mini .cursor { stroke: var(--oxide); stroke-width: 1.3; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 15px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: #C3CACF; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-end: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: inset-inline-end .2s; }
.switch input:checked + .track { background: var(--petrol); }
.switch input:checked + .track::after { inset-inline-end: 19px; }
.switch input:focus-visible + .track { outline: 2px solid var(--shrink); outline-offset: 2px; }
.key { margin: -6px 0 0; font-size: 13.5px; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; opacity: .45; transition: opacity .2s; }
.by-sides .key { opacity: 1; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 2px; vertical-align: -2px; margin-inline-end: 6px; border: 1px solid rgba(0,0,0,.15); }
.sw.shrink { background: var(--shrink-fill); } .sw.six { background: #D6D8DA; } .sw.grow { background: var(--grow-fill); }
.locator { width: 100%; max-width: 300px; border: 1px solid #C9CFD3; }

/* Text column and contents */
.flow { max-width: 1120px; margin: 0 auto; padding: 0 clamp(18px, 4vw, 48px); }
.text { max-width: 690px; margin: 0 auto; }
.text section { margin-bottom: 52px; }
.text section.cont { margin-top: -8px; }
.text h2 { font-size: 28px; line-height: 1.5; margin-bottom: 16px; display: flex; align-items: baseline; gap: 14px; }
.text h2 .num { font: 500 18px var(--plex); color: var(--ink-3); }
.abstract { border-inline-start: 3px solid var(--ink); padding-inline-start: 22px; }
.abstract h2 { font-size: 20px; }
.abstract p { font-size: 18px; line-height: 2; color: #2E363B; }
.mark { padding: 0 4px; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.mark.shrink { background: rgba(169,195,230,.55); }
.mark.grow { background: rgba(237,201,146,.6); }
.toc { font-family: var(--plex); max-width: 690px; margin: 0 auto 40px; padding: 18px 22px; border: 1px solid var(--rule); border-radius: 4px; }
.toc p { margin: 0 0 6px; font-size: 13px; color: var(--ink-3); }
.toc ol { margin: 0; padding-inline-start: 20px; font-size: 15px; line-height: 2; }
.toc a { text-decoration: none; color: var(--ink-2); }
.toc a[aria-current] { color: var(--petrol); font-weight: 600; }
@media (min-width: 1500px) {
  .toc { position: fixed; top: 96px; left: max(24px, calc((100vw - 1120px) / 2 - 230px)); width: 200px; border: 0; padding: 0; margin: 0; }
  .toc ol { list-style: none; padding: 0; border-inline-start: 1px solid var(--rule); }
  .toc li a { display: block; padding: 2px 14px; margin-inline-start: -1px; border-inline-start: 2px solid transparent; line-height: 1.7; margin-bottom: 6px; }
  .toc a[aria-current] { border-inline-start-color: var(--petrol); }
}

/* Potts widget */
.potts { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: start; background: var(--panel); border-radius: 4px; padding: 26px; margin: 26px 0 0; font-family: var(--plex); }
.potts figcaption { grid-column: 1 / -1; margin-top: 0; }
.potts-grid { display: grid; grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(3, 70px); gap: 3px; background: #9AA3A9; padding: 3px; border-radius: 3px; direction: ltr; }
.cell { border: 0; display: grid; place-items: center; font: 600 24px/1 var(--plex); direction: ltr; color: var(--ink); position: relative; }
.cell[data-s="A"] { background: #EAE3D2; } .cell[data-s="B"] { background: #CFDCEA; } .cell[data-s="C"] { background: #E6D2CF; }
.nb { cursor: pointer; }
.nb:hover { filter: brightness(.96); }
.nb[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--petrol); }
.same { cursor: not-allowed; opacity: .85; }
.centre { outline: 2px dashed var(--ink); outline-offset: -6px; }
.centre b { font-size: 19px; }
.centre small { position: absolute; bottom: 4px; font: 400 9.5px/1 var(--plex); color: var(--ink-2); }
.potts-out dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; margin: 0 0 14px; }
.potts-out dt { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.potts-out dd { margin: 2px 0 0; font: 600 21px/1.2 var(--plex); font-variant-numeric: tabular-nums; }
.prob { margin: 0 0 8px; font-size: 15px; }
.prob b { font: 700 19px var(--plex); }
.meter { height: 8px; background: #fff; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--petrol); inline-size: 0; transition: inline-size .25s; }
.verdict { margin: 10px 0 14px; font-size: 14.5px; color: var(--ink-2); min-height: 1.8em; line-height: 1.8; }
.kt { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }

/* Validation figure */
.tests-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.test h3 { font-size: 20px; line-height: 1.5; margin: 14px 0 6px; display: flex; gap: 10px; align-items: baseline; }
.test h3 .sub { font: 500 15px var(--plex); color: var(--ink-3); }
.test p { font: 400 15px/1.85 var(--plex); color: var(--ink-2); margin: 0; }
.chart { width: 100%; background: var(--panel); border-radius: 4px; padding: 6px 4px 2px; }
.chart .ax, .chart .tk { stroke: #8D979D; stroke-width: 1; }
.chart .gr { stroke: #DCE1E4; }
.chart .tl, .chart .al { fill: var(--ink-2); font: 400 13px var(--plex); }
.chart .data { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart .fit { stroke: var(--oxide); stroke-width: 1.6; }
.chart .ref { stroke: var(--ink-3); stroke-width: 1.3; stroke-dasharray: 5 4; }
.chart .zero { stroke: #8D979D; stroke-dasharray: 3 3; }
.chart .pt { fill: var(--ink); }
.chart .pt.shrink { fill: var(--shrink); } .chart .pt.grow { fill: var(--grow); } .chart .pt.six { fill: var(--six); }
.chart .open { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.chart .err { stroke: var(--ink-2); stroke-width: 1.1; opacity: .7; }
.chart .mark { fill: none; stroke: var(--oxide); stroke-width: 1.5; }
.chart .note { fill: var(--ink); font: 500 13px var(--plex); }
.chart .ref-note { fill: var(--ink-3); }
.lg { white-space: nowrap; margin-inline-start: 10px; }
.lg i { display: inline-block; width: 20px; height: 0; vertical-align: middle; margin-inline-end: 6px; border-top: 2px solid var(--ink); }
.lg i.l-fit { border-top-color: var(--oxide); } .lg i.l-ref { border-top: 2px dashed var(--ink-3); }

/* App and references */
.shot { margin: 8px -120px 28px; }
.shot img { width: 100%; border: 1px solid var(--rule); border-radius: 4px; }
.shot figcaption { font: 400 15px/1.85 var(--plex); color: var(--ink-2); margin-top: 12px; }
@media (max-width: 1180px) { .shot { margin-inline: 0; } }
.steps { margin: 0 0 1em; padding-inline-start: 24px; }
.steps li { margin-bottom: 6px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 26px; font: 500 16px var(--plex); }
.refs ol { font: 400 14.5px/1.8 var(--plex); color: var(--ink-2); padding-left: 20px; text-align: left; }
.refs li { margin-bottom: 8px; }
.refs p { font: 500 15px var(--plex); }

.foot { border-top: 1px solid var(--rule); margin-top: 40px; padding: 28px clamp(18px, 4vw, 48px) 40px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; font: 400 14px/1.8 var(--plex); color: var(--ink-2); }
.foot strong { display: block; font: 700 17px/1.6 var(--naskh); color: var(--ink); }
.foot span { display: block; }

@media (max-width: 980px) {
  .evolve-grid, .pin-grid { grid-template-columns: 1fr; padding: 18px; }
  .fig-evolve { --map: 100%; }
  .tests-grid { grid-template-columns: 1fr; }
  .potts { grid-template-columns: 1fr; justify-items: center; }
  .potts-out { justify-self: stretch; }
  .topbar { flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
  .topbar nav { width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 20px; font-size: 14px; scrollbar-width: none; }
  .topbar nav a { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

.foot-map { display: flex; flex-wrap: wrap; gap: 20px 48px; }
.foot-map p { margin: 0 0 4px; font-size: 12.5px; color: var(--ink-3); }
.foot-map a { display: block; color: var(--ink-2); text-decoration: none; line-height: 1.9; }
.foot-map a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 700px) { body { font-size: 17.5px; } .text h2 { font-size: 24px; } }
.wide { margin-bottom: 48px; }
