/* sharland.github.io
   A sidebar that never scrolls away, a disc of generative drawing in it, and
   a column of text beside it. On phones the sidebar becomes a header and a
   sticky menu bar. The day's piece sets the page accent. */

@font-face {
  font-family: "Literata";
  src: url("../fonts/Literata-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  src: url("../fonts/Literata-Italic-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Public Sans";
  src: url("../fonts/PublicSans-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/PublicSans-Italic-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Type pairing. "a": serif headings, sans text. "b": the reverse.
   Every rule below uses --display, --text or --ui, never a family directly. ---- */
:root, html[data-type="a"] { --display: var(--serif); --text: var(--sans); }
html[data-type="b"]        { --display: var(--sans);  --text: var(--serif); }

/* ---- Pieces. Each has a plate (the disc's own ground), two or three line
   colours, and a text accent for each page scheme. The default equals the
   no-JavaScript fallback image. ---- */
:root {
  --disc-kind: burst;
  --plate: #f4efe6;
  --c1: #8e0b0b; --c2: #c41414; --c3: #8e0b0b;
  --accent-l: #8e0b0b; --accent-d: #ff6b6b;
}
html[data-disc="ribbons-lime"]    { --disc-kind: ribbons; --plate: #07080a; --c1: #c9f33a; --c2: #2fd9b4; --c3: #ffe14d; --accent-l: #3d6d00; --accent-d: #c9f33a; }
html[data-disc="ribbons-magenta"] { --disc-kind: ribbons; --plate: #07080a; --c1: #ff33cc; --c2: #ffd21f; --c3: #7a3cff; --accent-l: #a3007a; --accent-d: #ff5fd6; }
html[data-disc="ribbons-cyan"]    { --disc-kind: ribbons; --plate: #07080a; --c1: #35d7ff; --c2: #7b5cff; --c3: #b23cff; --accent-l: #0f5fa8; --accent-d: #5fe0ff; }
html[data-disc="rings-orange"]    { --disc-kind: rings;   --plate: #0d2a45; --c1: #f08a1e; --c2: #ffb347; --c3: #ffd9a0; --accent-l: #a34d00; --accent-d: #ffa033; }
html[data-disc="rings-gradient"]  { --disc-kind: rings;   --plate: #f4efe6; --c1: #5a2d8f; --c2: #e23a1e; --c3: #ff7a4d; --accent-l: #7a2fb0; --accent-d: #d58cff; }
html[data-disc="burst-red"]       { --disc-kind: burst;   --plate: #f4efe6; --c1: #8e0b0b; --c2: #c41414; --c3: #8e0b0b; --accent-l: #8e0b0b; --accent-d: #ff6b6b; }
html[data-disc="sheets-black"]    { --disc-kind: ribbons; --plate: #f4efe6; --c1: #17161a; --c2: #3a3842; --c3: #17161a; --accent-l: #17161a; --accent-d: #ece9e2; }
html[data-disc="mesh-black"]      { --disc-kind: mesh;    --plate: #fbfaf7; --c1: #17161a; --c2: #2c2a30; --c3: #17161a; --accent-l: #17161a; --accent-d: #ece9e2; }

/* ---- Page tokens ---- */
:root {
  color-scheme: light dark;
  --paper: #f4efe6;
  --ink: #17161a;
  --muted: #68635c;
  --rule: #d8d0c2;
  --accent: var(--accent-l);
  --serif: "Literata", Charter, "Iowan Old Style", Georgia, serif;
  --sans: "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --ui: var(--sans);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 35rem;
  --gutter: 1.25rem;
  --side-w: clamp(20rem, 34vw, 28rem);
  --bar-h: 2.75rem;
}
/* Dark tokens apply when the switch says dark, or when the system says dark
   and the switch has not said light. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0c0f; --ink: #ece9e2; --muted: #a39e95; --rule: #26282e; --accent: var(--accent-d);
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0c0f; --ink: #ece9e2; --muted: #a39e95; --rule: #26282e; --accent: var(--accent-d);
  }
}

/* ---- Base ---- */
html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
body { margin: 0; min-height: 100vh; }
/* The page accent follows the disc and the ground follows the theme switch;
   a short crossfade keeps either change from snapping. */
html, body, a, .bar, .footer, h2, .group-title, .textbtn, .arrow, .menu a,
h2::before, .menu a[aria-current="true"]::before, .bar .menu a, .side, .skip {
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}
*, *::before, *::after { box-sizing: border-box; }
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul.plain, ul.entries, ul.menu { list-style: none; margin: 0; padding: 0; }
code, .is-code { font-family: var(--mono); font-size: 0.875em; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  padding: 0.5rem 0.75rem; background: var(--paper); color: var(--ink);
  border: 1px solid var(--accent);
}
.skip:focus { top: 1rem; }

/* ---- Sidebar pieces (shared by both layouts) ---- */
.disc-frame { position: relative; aspect-ratio: 1 / 1; }
.disc-frame canvas, .disc-frame img {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  border-radius: 50%;
}
.name {
  font-family: var(--display);
  font-size: clamp(2rem, 1.4rem + 2vw, 3rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}
.name a { color: inherit; text-decoration: none; }
.name a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.role { color: var(--muted); margin: 0; font-family: var(--ui); }
.side-links { color: var(--muted); margin: 0; font-family: var(--ui); font-size: 0.9375rem; }
.side-theme { margin: 0.5rem 0 0; font-family: var(--ui); font-size: 0.9375rem; }

/* Text buttons look like links; the disc itself is a button when scripts run. */
.textbtn {
  font: inherit; font-family: var(--ui);
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em;
  cursor: pointer;
}
.textbtn:hover { text-decoration-thickness: 2px; }
.disc-controls {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  margin: 0.75rem 0 0; font-family: var(--ui); color: var(--muted);
}
.disc-name { font-family: var(--mono); font-size: 0.8125rem; min-width: 7.5em; text-align: center; }
.arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0; margin: 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--accent); cursor: pointer;
}
.arrow svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.arrow:hover { color: var(--ink); }
.disc-frame canvas.is-button { cursor: pointer; }
.disc-frame canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.menu { font-family: var(--ui); }
.menu li { margin: 0; }
.menu a {
  display: inline-block;
  text-decoration: none;
  color: var(--ink);
}
.menu a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.menu a[aria-current="true"] { color: var(--accent); }

/* ---- Desktop: two columns, sidebar pinned ---- */
@media (min-width: 64rem) {
  body {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
  }
  .side {
    grid-column: 1; grid-row: 1 / span 2;
    position: sticky; top: 0; align-self: start;
    height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
    padding: 2rem 2rem 1.75rem;
    border-right: 1px solid var(--rule);
  }
  .side-disc { width: min(100%, calc(100vh - 29rem)); margin: 0 0 1.5rem; }
  .side-id { margin-bottom: 1.5rem; }
  .side-menu { margin-bottom: auto; }
  .menu { display: flex; flex-direction: column; gap: 0.6rem; }
  .menu a { font-size: 1.0625rem; position: relative; padding-left: 0; transition: padding-left 0.15s ease; }
  .menu a[aria-current="true"] { padding-left: 1.5rem; }
  /* The same arrow as the disc controls, drawn as a mask so it takes the accent. */
  .menu a[aria-current="true"]::before {
    content: ""; position: absolute; left: 0; top: 0.32em; width: 1em; height: 1em;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .side-links { margin-top: 1.5rem; }
  .bar { display: none; }
  .main { grid-column: 2; grid-row: 1; padding: 3.25rem clamp(2rem, 5vw, 4.5rem) 1rem; }
  .footer { grid-column: 2; grid-row: 2; margin: 0 clamp(2rem, 5vw, 4.5rem); }
  .section { scroll-margin-top: 2rem; }
}

/* ---- Phone and tablet: header, sticky bar, disc, text ---- */
@media (max-width: 63.99rem) {
  body { display: flex; flex-direction: column; }
  .side { display: contents; }
  .skip { order: 0; }
  .side-id { order: 1; padding: 2rem var(--gutter) 0; }
  .side-links { order: 2; padding: 0.5rem var(--gutter) 1rem; }
  .bar { order: 3; }
  .side-disc { order: 4; width: min(72vw, 22rem); margin: 1.75rem auto 0; }
  .main { order: 5; padding: 1.5rem var(--gutter) 0; }
  .footer { order: 6; margin: 0 var(--gutter); }
  .side-menu, .side-theme { display: none; }

  .bar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 0.25rem;
    height: var(--bar-h);
    padding: 0 var(--gutter);
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }
  .bar-home { display: inline-flex; align-items: center; margin-right: 0.75rem; flex: none; }
  .bar .menu { display: flex; flex-wrap: nowrap; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; }
  .bar .menu::-webkit-scrollbar { display: none; }
  .bar .menu a {
    font-size: 0.9375rem; line-height: var(--bar-h); white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  .bar .menu a[aria-current="true"] { border-bottom-color: var(--accent); }
  .bar-theme { margin-left: auto; flex: none; font-size: 0.9375rem; padding-left: 0.75rem; }
  .section { scroll-margin-top: calc(var(--bar-h) + 0.75rem); }
}

/* ---- Main column ---- */
.main > * { max-width: var(--measure); }
.lede { font-family: var(--serif); font-size: 1.25rem; line-height: 1.45; margin: 0 0 2.5rem; }
.section { margin-top: 3rem; }
h2 {
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 1rem;
  padding-top: 0.9rem;
  position: relative;
}
h2::before { content: ""; position: absolute; top: 0; left: 0; width: 2rem; height: 2px; background: var(--accent); }
.group-title { font-family: var(--display); font-size: 1.0625rem; font-weight: 500; color: var(--accent); margin: 1.75rem 0 0.25rem; }
.group-blurb { color: var(--muted); margin-bottom: 1rem; }
.entries > li { margin: 0 0 1.5rem; }
.entries > li:last-child { margin-bottom: 0; }
.entry-head { margin-bottom: 0.2em; }
.entry-title { font-weight: 500; }
.entry-meta { color: var(--muted); font-family: var(--ui); font-size: 0.9375em; }
.entry-body { margin: 0; }
.plain > li { margin: 0 0 0.6em; }

/* ---- Notes ---- */
.note { max-width: none; }
.note > :not(.note-body), .note-body > :not(table) { max-width: var(--measure); }
.note-title, .main > h1 {
  font-family: var(--display);
  font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.25rem);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
.doc-control { color: var(--muted); font-family: var(--ui); font-size: 0.9375rem; margin-bottom: 1.75rem; }
.note-summary { font-size: 1.125em; line-height: 1.5; margin-bottom: 2rem; }
.note-body h2 { margin-top: 2.5rem; }
.note-body h3 { font-family: var(--display); font-size: 1.0625em; font-weight: 600; margin: 2rem 0 0.5rem; }
.note-body h4 { font-family: var(--display); font-size: 1em; font-weight: 500; font-style: italic; margin: 1.5rem 0 0.5rem; }
.note-body ul, .note-body ol { padding-left: 1.4em; margin: 0 0 1em; }
.note-body li { margin-bottom: 0.3em; }
.note-body blockquote { margin: 1.5em 0; padding-left: 1em; border-left: 2px solid var(--accent); color: var(--muted); }
.note-body table {
  display: block; overflow-x: auto;
  border-collapse: collapse; width: 100%; max-width: 46rem;
  font-family: var(--ui); font-size: 0.875rem; line-height: 1.45; margin: 1.5em 0;
}
.note-body th, .note-body td { text-align: left; vertical-align: top; padding: 0.5rem 0.9rem 0.5rem 0; border-top: 1px solid var(--rule); }
.note-body thead th { border-top: 0; border-bottom: 1px solid var(--ink); font-weight: 600; }
.note-body tbody tr:last-child td { border-bottom: 1px solid var(--rule); }
.note-body pre { font-family: var(--mono); font-size: 0.875em; line-height: 1.5; overflow-x: auto; padding: 0.75em 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.note-body hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
.note-back { margin-top: 3rem; }

/* ---- Footer ---- */
.footer {
  margin-top: 4rem;
  padding: 1rem 0 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.9375rem;
}

@media print {
  .side, .bar, .skip, .footer, .note-back { display: none; }
  html { font-size: 11pt; background: #fff; color: #000; }
  a { color: inherit; }
  .note-body table { display: table; }
}
