/* 7strikes.dev
   System fonts only. No webfonts, no images, no scripts.
   Palette derived from Xcode's light-mode syntax colours. */

/* Appearance. No data-theme attribute on <html> means "auto": follow the
   system. The footer control sets data-theme to "light" or "dark", which
   wins over the system setting. The dark palette therefore appears twice:
   once behind the media query, once behind the attribute. Keep them equal. */

:root {
  color-scheme: light dark;
  --paper:      #fcfcfa;
  --ink:        #14181f;
  --ink-soft:   #565c66;
  --ink-faint:  #8a919c;
  --rule:       #dcdcd6;
  --wash:       #f3f3ee;
  --code:       #3f6e74;   /* Xcode type colour */
  --signal:     #6c36a9;   /* Xcode system function colour, used sparingly */
  --kind-article:      #3f6e74;
  --kind-article-wash: #e9f0f0;
  --kind-note:         #0f68a0;
  --kind-note-wash:    #e7eff6;
  --important:  #947100;   /* Xcode attribute colour: callout, important */
  --important-wash: #faf6e4;
  --critical:   #c41a16;   /* Xcode string colour: callout, critical */
  --critical-wash:  #fbeeed;
  /* Swift code blocks: Xcode's Default (Light) syntax colours */
  --syn-keyword:   #9b2393;
  --syn-string:    #c41a16;
  --syn-comment:   #5d6c79;
  --syn-number:    #1c00cf;
  --syn-attribute: #815f03;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #16181c;
    --ink:       #e8e8e4;
    --ink-soft:  #9aa0aa;
    --ink-faint: #6e7681;
    --rule:      #2c3038;
    --wash:      #1d2026;
    --code:      #7ab7bf;
    --signal:    #a167e6;
    --kind-article:      #7ab7bf;
    --kind-article-wash: #1b2528;
    --kind-note:         #6bb0e0;
    --kind-note-wash:    #19222c;
    --important: #d0bf69;
    --important-wash: #26241a;
    --critical:  #fc6a5d;
    --critical-wash:  #2b1d1c;
    --syn-keyword:   #fc5fa3;
    --syn-string:    #fc6a5d;
    --syn-comment:   #7f8c98;   /* Xcode's #6c7986, lifted to 4.5:1 on --wash */
    --syn-number:    #d0bf69;
    --syn-attribute: #bf8555;
  }
}

:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:     #16181c;
  --ink:       #e8e8e4;
  --ink-soft:  #9aa0aa;
  --ink-faint: #6e7681;
  --rule:      #2c3038;
  --wash:      #1d2026;
  --code:      #7ab7bf;
  --signal:    #a167e6;
  --kind-article:      #7ab7bf;
  --kind-article-wash: #1b2528;
  --kind-note:         #6bb0e0;
  --kind-note-wash:    #19222c;
  --important: #d0bf69;
  --important-wash: #26241a;
  --critical:  #fc6a5d;
  --critical-wash:  #2b1d1c;
  --syn-keyword:   #fc5fa3;
  --syn-string:    #fc6a5d;
  --syn-comment:   #7f8c98;   /* Xcode's #6c7986, lifted to 4.5:1 on --wash */
  --syn-number:    #d0bf69;
  --syn-attribute: #bf8555;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- nav */

nav.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  max-width: 46rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 0;
}

nav.site .wordmark a {
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

nav.site .links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.9375rem;
}

nav.site .links a {
  color: var(--ink-soft);
  text-decoration: none;
}
nav.site .links a:hover { color: var(--ink); }
nav.site a[aria-current] { color: var(--ink); }

/* --------------------------------------------------------------- page */

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 6rem;
}

article, .home { max-width: 40rem; }

/* Wide content. Prose keeps the 40rem measure, about 75 characters a line.
   Tables, code blocks and figures are not read line by line, so on a wide
   window they may run past it to the right, up to 52rem, with their left
   edge still on the text. 50vw + 20rem is the room from the text's left
   edge to the right-hand gutter: the page is 46rem, centred, with 1.5rem
   of padding a side. Below 46rem they keep the column's width. */
@media (min-width: 46rem) {
  article table, article pre, article .codeblock {
    width: max-content;
    min-width: 100%;
    max-width: min(52rem, 50vw + 20rem);
  }
  /* Inside the Copy button's box, the box does the sizing. */
  article .codeblock pre { width: auto; min-width: 0; max-width: none; }
  article .fig { width: min(48rem, 50vw + 20rem); }
}

@media (max-width: 40rem) {
  body { font-size: 16px; }
  .page { padding: 2.5rem 1.25rem 4rem; }
  nav.site { padding-top: 1.5rem; }
}

/* --------------------------------------------------------- typography */

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 1.5rem;
}

h2 {
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2.75rem 0 0.875rem;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
}

h2 a, h3 a { color: inherit; text-decoration: none; }

p { margin: 0 0 1.15rem; }

.meta {
  color: var(--ink-faint);
  font-size: 0.875rem;
  margin: -1rem 0 2rem;
}

/* The author line at the foot of an article: muted, no rule above it. */
.byline {
  color: var(--ink-soft);
  font-size: 0.875rem;
  margin-top: 3rem;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--signal); }
a:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

ul, ol { margin: 0 0 1.15rem; padding-left: 1.25rem; }
li { margin-bottom: 0.4rem; }

/* Callouts. A blockquote in the Markdown becomes one; the label on its
   first line picks the level. Same radius and padding as code blocks so
   the two sit together. */

blockquote {
  margin: 1.5rem 0;
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--ink-faint);
  border-radius: 4px;
  background: var(--wash);
}
blockquote p:last-child { margin-bottom: 0; }
blockquote .label { color: var(--ink-soft); }

blockquote.important {
  border-left-color: var(--important);
  background: var(--important-wash);
}
blockquote.important .label { color: var(--important); }

blockquote.critical {
  border-left-color: var(--critical);
  background: var(--critical-wash);
}
blockquote.critical .label { color: var(--critical); }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

img { max-width: 100%; height: auto; }

/* ------------------------------------------------------------ figures */

/* Inline SVG diagrams, written as raw HTML blocks. Each element carries its
   light-theme fill as an attribute for feed readers; these rules recolour it
   from the tokens so it follows the theme. Payload is the type teal,
   framing and replies the faint ink, labels are text. On a narrow screen the
   figure scrolls sideways, like a code block, instead of shrinking its text. */
.fig { margin: 1.5rem 0; overflow-x: auto; }
.fig svg { display: block; width: 100%; min-width: 34rem; height: auto; }
.fig figcaption { color: var(--ink-soft); font-size: 0.875rem; margin-top: 0.5rem; max-width: 40rem; }
.fig .pay { fill: var(--code); }
.fig .ovh { fill: var(--ink-faint); }
.fig .idle { fill: var(--wash); stroke: var(--rule); }
.fig .ln { stroke: var(--rule); }
.fig .txt { fill: var(--ink-soft); }
.fig .ink { fill: var(--ink); }
.fig .on-pay { fill: var(--paper); }

/* ------------------------------------------------------------- tables */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}

th { font-weight: 600; }
td code { overflow-wrap: anywhere; }

/* The first column names the thing the row is about (an API, a key), so its
   code is never broken mid-identifier; the column grows to fit instead. On a
   narrow screen the table scrolls sideways, like a code block. */
td:first-child code { white-space: nowrap; overflow-wrap: normal; }

@media (max-width: 40rem) {
  table { display: block; overflow-x: auto; }
}

/* --------------------------------------------------------------- code */

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--code);
  overflow-wrap: break-word;
}

pre {
  background: var(--wash);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.875rem 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

pre code { color: var(--ink); font-size: inherit; }

/* The Copy button, added by the second script in base.html. It sits in the
   box's corner, over the end of the first line if that line is long. */
.codeblock { position: relative; margin: 1.5rem 0; }
.codeblock pre { margin: 0; }

.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.4rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}
.copy svg { display: block; width: 1rem; height: 1rem; }
.copy:hover { color: var(--ink); }
.copy:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* A fingertip needs a bigger target than a pointer: 44 points, as Apple's
   guidelines ask. */
@media (pointer: coarse) {
  .copy {
    min-height: 2.75rem;
    min-width: 2.75rem;
    padding: 0 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Swift blocks, coloured by build.py. Keywords are semibold, as in Xcode. */
pre .k { color: var(--syn-keyword); font-weight: 600; }
pre .s { color: var(--syn-string); }
pre .c { color: var(--syn-comment); }
pre .n { color: var(--syn-number); }
pre .a { color: var(--syn-attribute); }

/* ------------------------------------------------------------ listings */

ul.entries {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

ul.entries li {
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--rule);
  margin: 0;
}

ul.entries li:first-child { border-top: 1px solid var(--rule); }

ul.entries a {
  text-decoration: none;
  font-weight: 500;
}
ul.entries a:hover { text-decoration: underline; text-underline-offset: 3px; }

ul.entries .kind {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: 0.08em;
  white-space: nowrap;
}

ul.entries .kind.article {
  color: var(--kind-article);
  background: var(--kind-article-wash);
}

ul.entries .kind.note {
  color: var(--kind-note);
  background: var(--kind-note-wash);
}

ul.entries .when {
  color: var(--ink-faint);
  font-size: 0.8125rem;
  margin-left: 0.75rem;
  white-space: nowrap;
}

ul.entries .desc {
  display: block;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-top: 0.125rem;
}

/* ------------------------------------------------------------- footer */

footer.site {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 0.8125rem;
}
footer.site p { margin: 0 0 0.25rem; }
footer.site a { color: inherit; }

/* Appearance control: three radio buttons rendered as plain words. The
   selected one is set in ink; the others are faint. Hidden until the
   script in the page head reveals it, so a page without JavaScript shows
   no control it cannot honour. */

.appearance {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  align-items: baseline;
  margin: 1.25rem 0 0;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.appearance[hidden] { display: none; }

.appearance-label { margin-right: 0.25rem; }

.appearance input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.appearance label {
  cursor: pointer;
  color: var(--ink-faint);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.appearance label:hover { color: var(--ink-soft); }

.appearance input:checked + label {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.appearance input:focus-visible + label {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ------------------------------------------- consulting page fee block */

.fee {
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--signal);
  margin: 1.5rem 0 0.125rem;
}

.fee-unit {
  color: var(--ink-soft);
  font-size: 0.9375rem;
  margin: 0 0 1.15rem;
}
