/*
  CSS: Cool, Super, and Swishy
*/

/* Originally based on Poole https://github.com/poole/poole */

/*
  Colours come from the Pantone colour of the year 2018: Ultra Violet
  https://www.pantone.com/articles/color-of-the-year/color-of-the-year-2018
*/
:root {
  /* Brand palette */
  --ultra-violet: #71589b;
  --sparkling-grape: #8d4384;
  --mulberry: #b36e9f;

  /* Semantic colours (light theme, dark theme done later) */
  --background: #fff;
  --surface: #f7f6f9;
  --border: #e3e0e8;
  --text: #2f2b35;
  --text-strong: #17141c;
  --text-muted: #6b6672;
  --heading: var(--sparkling-grape);
  --accent: var(--ultra-violet);
  --link: #0a6ebd;
  --code-text: #b0384a;

  /* Measure and rhythm */
  --measure: 774px;  /* 44em at the old fixed 18px root */
  --gutter: clamp(0.75rem, 2.5vw, 1.15rem);
  --flow: 1.25rem;
  --radius: 6px;

  color-scheme: light dark;
  accent-color: var(--accent);
}

/* Fonts from https://gwfh.mranftl.com/fonts/pt-sans?subsets=latin */
@font-face {
  font-display: swap;
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/pt-sans-v17-latin-regular.woff2') format('woff2');
}
@font-face {
  font-display: swap;
  font-family: 'PT Sans';
  font-style: italic;
  font-weight: 400;
  src: url('../fonts/pt-sans-v17-latin-italic.woff2') format('woff2');
}
@font-face {
  font-display: swap;
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/pt-sans-v17-latin-700.woff2') format('woff2');
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: "PT Sans", Helvetica, Arial, sans-serif;
  /* 17px on a phone growing to 19px on a wide screen */
  font-size: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  line-height: 1.65;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--background);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  max-inline-size: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-block: 0.5rem 2rem;
  padding-inline: var(--gutter);
}

/* Links */

/* No `:visited` state is required by default (browsers will use `a`) */
a {
  color: var(--link);
  text-decoration-thickness: 0.07em;
  text-underline-offset: 0.16em;
}
a strong {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection {
  background-color: color-mix(in oklab, var(--mulberry) 32%, transparent);
}

/* Site header */
nav#top {
  /* Gradient: https://www.joshwcomeau.com/gradient-generator/ */
  background: var(--ultra-violet) linear-gradient(
    45deg,
    hsl(262deg 28% 48%) 0%,
    hsl(267deg 28% 47%) 38%,
    hsl(272deg 29% 46%) 54%,
    hsl(277deg 29% 45%) 67%,
    hsl(282deg 30% 44%) 77%,
    hsl(287deg 30% 43%) 85%,
    hsl(292deg 31% 42%) 92%,
    hsl(298deg 32% 41%) 97%,
    hsl(303deg 33% 41%) 100%,
    hsl(307deg 36% 41%) 100%
  );
  color: #fff;
  padding-block: 0.7rem 0.85rem;
  padding-inline: 1.15rem;
  margin-block-end: 2rem;

  & p {
    margin-block: 0;
  }
  & a {
    color: #fff;
    text-decoration-color: color-mix(in srgb, #fff 45%, transparent);

    &:hover {
      text-decoration-color: #fff;
    }
  }
}
#site-name {
  font-size: 1.7rem;
  font-weight: bold;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-block: 0 0.15rem;
  text-rendering: optimizeLegibility;
}

/* Headings */
:is(h1, h2, h3, h4, h5, h6) {
  color: var(--heading);
  font-weight: bold;
  line-height: 1.2;
  text-rendering: optimizeLegibility;
  overflow-wrap: anywhere;
  text-wrap: balance;
  scroll-margin-block-start: 1.5rem;
}
:is(h1, h2, h3, h4, h5, h6):first-child {
  margin-block-start: 0;
}
h1 {
  font-size: 2.1rem;
  letter-spacing: -0.02em;
  margin-block: 0 0.5rem;
}
h2 {
  font-size: 1.55rem;
  letter-spacing: -0.015em;
  margin-block: 2.5rem 0.65rem;
}
h3 {
  font-size: 1.25rem;
  margin-block: 1.9rem 0.5rem;
}
h4, h5, h6 {
  font-size: 1.05rem;
  margin-block: 1.6rem 0.4rem;
}
/* Inline code in a heading keeps the heading's colour, just in monospace */
:is(h1, h2, h3, h4, h5, h6) code {
  background-color: transparent;
  color: inherit;
  padding: 0;
}

/* Permalinks revealed on hover of their heading, or on keyboard focus */
a.headerlink {
  color: var(--mulberry);
  padding-inline-start: 0.3em;
  text-decoration: none;
  opacity: 0;
}
a.headerlink::before {
  content: '¶';
}
:is(h1, h2, h3, h4, h5, h6):hover > a.headerlink,
a.headerlink:focus-visible {
  opacity: 1;
}

/* Body text */
p {
  margin-block: 0 var(--flow);
  text-wrap: pretty;
}

strong {
  color: var(--text-strong);
}

small {
  font-size: 0.875em;
}

/* Lists */
ul, ol, dl {
  margin-block: 0 var(--flow);
}
ul, ol {
  padding-inline-start: 1.5rem;

  & li {
    text-wrap: pretty;
  }
  & li + li {
    margin-block-start: 0.7rem;
  }
  /* Tighten "loose" lists, where docutils wraps each item's text in a `p` */
  & li > p:last-child {
    margin-block-end: 0;
  }
  & ::marker {
    color: var(--mulberry);
  }
}
ol.loweralpha {
  list-style-type: lower-alpha;
}

dt {
  font-weight: bold;
  color: var(--text-strong);
}
dd {
  margin-block-end: 0.5rem;
  margin-inline-start: 1.5rem;
}

/* Misc */
hr {
  border: 0;
  block-size: 1px;
  margin-block: 2.5rem;
  background-color: var(--border);
}

abbr {
  font-size: 0.875em;
  font-weight: bold;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
abbr[title] {
  cursor: help;
  border-block-end: 1px dotted var(--border);
}
summary {
  cursor: pointer;

  &::marker {
    color: var(--mulberry);
  }
}

/* Code */
code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875em;
}
code {
  background-color: var(--surface);
  border-radius: 4px;
  color: var(--code-text);
  padding: 0.12em 0.3em;
}
pre {
  background-color: var(--surface);
  border-radius: var(--radius);
  display: block;
  line-height: 1.5;
  margin-block: 0 var(--flow);
  overflow-wrap: break-word;
  padding: 1rem 1.15rem;
  tab-size: 4;
  white-space: pre-wrap;
}
pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
}
@media (width <= 790px) {
  /* scroll code instead of wrapping it on small screens */
  pre {
    overflow-x: auto;
    white-space: pre;
  }
}

/* Quotes */
blockquote {
  border-inline-start: 3px solid var(--mulberry);
  color: var(--text-muted);
  margin-block: var(--flow);
  margin-inline: 0;
  padding-inline: 1.15rem;

  & p:last-child {
    margin-block-end: 0;
  }
}

img {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
  margin-block: 0 var(--flow);
  margin-inline: auto;
}

/* Tables */
table {
  border: 1px solid var(--border);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  inline-size: 100%;
  margin-block-end: var(--flow);
}
table.borderless {
  border: 0;
  & th, & td {
    border: 0;
  }
}
td,
th {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: start;
}
thead th {
  background-color: var(--surface);
  color: var(--text-strong);
}
table.striped tbody tr:nth-child(odd) :is(td, th) {
  background-color: var(--surface);
}
@media (width <= 790px) {
  /*
    Scroll a table that cannot fit, rather than letting it push the whole page
    sideways -- the same treatment `pre` gets at this width.
  */
  table {
    display: block;
    inline-size: max-content;
    max-inline-size: 100%;
    overflow-x: auto;
  }
}

/* Forms */
form {
  display: flow-root; /* contain floated labels and inputs */
  margin-block: 2rem;
}
label, input {
  font-family: inherit;
  font-size: 1rem;
  margin-block: 0;
  margin-inline: 0 0.5em;
}
input {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.4em 0.6em;
}
input[type="submit"] {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  cursor: pointer;
  padding-inline: 1em;

  &:hover {
    background: color-mix(in oklab, var(--accent) 85%, #000);
  }
}


/*
 * Messages
 *
 * Show alert messages to users. You may add it to single elements like a `<p>`,
 * or to a parent if there are multiple elements to show.
 */

.message {
  background-color: var(--surface);
  border-inline-start: 4px solid var(--mulberry);
  border-radius: var(--radius);
  color: var(--text);
  margin-block-end: var(--flow);
  padding: 1rem 1.15rem;
}


/*
 * Posts and pages
 *
 * Each post is wrapped in `.post` and is used on default and post layouts. Each
 * page is wrapped in `.page` and is only used on the page layout.
 */

.page,
.post {
  margin-block-end: 1em;
}

/* Blog post or page title */
.post-title,
.post-title a {
  color: var(--heading);
}
/* Titles in the post lists sit below the page's own heading */
.posts .post-title {
  font-size: 1.7rem;
}
.post-title a {
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

.post time,  /* Meta data line below post title */
.game-date  /* Date line below each game heading on the games page */
{
  color: var(--text-muted);
  display: block;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  margin-block: 0 1.25rem;
}

/*
 * Pagination
 *
 * Super lightweight (HTML-wise) blog pagination. `span`s are provide for when
 * there are no more previous or next posts to show.
 */

.pagination {
  display: flex;
  flex-direction: column;
  margin-block: 1.5rem;
  text-align: center;
}

/* Pagination items can be `span`s or `a`s */
.pagination-item {
  border: 1px solid var(--border);
  padding: 0.9rem 1rem;
}
/* Pull each item onto its neighbour so they share one border, not two */
.pagination-item + .pagination-item {
  margin-block-start: -1px;
}
span.pagination-item {
  color: var(--text-muted);
}
a.pagination-item {
  text-decoration: none;

  &:hover {
    background-color: var(--surface);
  }
}

@media (width >= 30em) {
  /* Side by side, joined into a single pill rounded only at its two ends */
  .pagination {
    flex-direction: row;
    margin-block: 3rem;
  }
  .pagination-item {
    flex: 1;
  }
  .pagination-item + .pagination-item {
    margin-block-start: 0;
    margin-inline-start: -1px;
  }
  .pagination-item:first-child {
    border-start-start-radius: var(--radius);
    border-end-start-radius: var(--radius);
  }
  .pagination-item:last-child {
    border-start-end-radius: var(--radius);
    border-end-end-radius: var(--radius);
  }
}

/* Syntax highlighting using Pygments */
.highlight {
  margin: 0 0 var(--flow) 0;
}
.highlight pre {
  margin-bottom: 0;
}
.highlight .hll { background-color: #ffc; }
.highlight .c { color: #999; }/* Comment */
.highlight .err { color: #a00; background-color: #faa }/* Error */
.highlight .k { color: #069; }/* Keyword */
.highlight .o { color: #777 }/* Operator */
.highlight .cm { color: #09f }/* Comment.Multiline */
.highlight .cp { color: #099 }/* Comment.Preproc */
.highlight .c1 { color: #999; }/* Comment.Single */
.highlight .cs { color: #999; }/* Comment.Special */
.highlight .gd { background-color: #fcc; border: 1px solid #c00 }/* Generic.Deleted */
.highlight .ge { font-style: italic }/* Generic.Emph */
.highlight .gr { color: #f00 }/* Generic.Error */
.highlight .gh { color: #030; }/* Generic.Heading */
.highlight .gi { background-color: #cfc; border: 1px solid #0c0 }/* Generic.Inserted */
.highlight .gp { color: #009; }/* Generic.Prompt */
.highlight .gs { }/* Generic.Strong */
.highlight .gu { color: #030; }/* Generic.Subheading */
.highlight .gt { color: #9c6 }/* Generic.Traceback */
.highlight .kc { color: #069; }/* Keyword.Constant */
.highlight .kd { color: #069; }/* Keyword.Declaration */
.highlight .kn { color: #069; }/* Keyword.Namespace */
.highlight .kp { color: #069 }/* Keyword.Pseudo */
.highlight .kr { color: #069; }/* Keyword.Reserved */
.highlight .kt { color: #078; }/* Keyword.Type */
.highlight .m { color: #f60 }/* Literal.Number */
.highlight .s { color: #d44950 }/* Literal.String */
.highlight .na { color: #4f9fcf }/* Name.Attribute */
.highlight .nb { color: #366 }/* Name.Builtin */
.highlight .nc { color: #0a8; }/* Name.Class */
.highlight .no { color: #360 }/* Name.Constant */
.highlight .nd { color: #99f }/* Name.Decorator */
.highlight .ni { color: #999; }/* Name.Entity */
.highlight .ne { color: #c00; }/* Name.Exception */
.highlight .nf { color: #c0f }/* Name.Function */
.highlight .nl { color: #99f }/* Name.Label */
.highlight .nn { color: #0cf; }/* Name.Namespace */
.highlight .nt { color: #2f6f9f; }/* Name.Tag */
.highlight .nv { color: #033 }/* Name.Variable */
.highlight .ow { color: #069 }/* Operator.Word */
.highlight .w { color: #bbb }/* Text.Whitespace */
.highlight .mf { color: #f60 }/* Literal.Number.Float */
.highlight .mh { color: #f60 }/* Literal.Number.Hex */
.highlight .mi { color: #f60 }/* Literal.Number.Integer */
.highlight .mo { color: #f60 }/* Literal.Number.Oct */
.highlight .sb { color: #c30 }/* Literal.String.Backtick */
.highlight .sc { color: #c30 }/* Literal.String.Char */
.highlight .sd { color: #c30 }/* Literal.String.Doc */
.highlight .s2 { color: #c30 }/* Literal.String.Double */
.highlight .se { color: #c30 }/* Literal.String.Escape */
.highlight .sh { color: #c30 }/* Literal.String.Heredoc */
.highlight .si { color: #a00 }/* Literal.String.Interpol */
.highlight .sx { color: #c30 }/* Literal.String.Other */
.highlight .sr { color: #3aa }/* Literal.String.Regex */
.highlight .s1 { color: #c30 }/* Literal.String.Single */
.highlight .ss { color: #fc3 }/* Literal.String.Symbol */
.highlight .bp { color: #366 }/* Name.Builtin.Pseudo */
.highlight .vc { color: #033 }/* Name.Variable.Class */
.highlight .vg { color: #033 }/* Name.Variable.Global */
.highlight .vi { color: #033 }/* Name.Variable.Instance */
.highlight .il { color: #f60 }/* Literal.Number.Integer.Long */

.highlight .ipy .gh { color: #900; }

.highlight .-Color-BGGreen { color: #0a0; background-color: #afa }
.highlight .-Color-BGRed { color: #a00; background-color: #faa }
.highlight .-Color-Faint { color: #999 }

.css .o,
.css .o + .nt,
.css .nt + .nt { color: #999; }

@media (prefers-color-scheme: dark) {
  :root {
    /*
      The background stays pure black so that `.post-image` illustrations,
      which are inverted below, blend into the page.
    */
    --background: #000;
    --surface: #17171a;
    --border: #2e2c33;
    --text: #eee8d5;
    --text-strong: #fff;
    --text-muted: #a09ba8;
    --heading: #c890c4;
    --accent: #9b7ec8;
    --link: #63b4ef;
    --code-text: #f0909e;
  }

  .highlight .hll { background-color: #3d3a14; }
  .highlight .highlight { color: #026802; }
  .highlight .gh { color: #0a0; }
  .highlight .gi { background-color: #030; }
  .highlight .gd { background-color: #300; }
  .highlight .gp { color: #0cf; }
  .highlight .gu { color: #090; }
  .highlight .nv { color: #099; }

  .post-image {
    filter: invert(1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  @view-transition {
    navigation: auto;
  }
}

/* Tailwind inspired utilities */
.float-left {float: left;}
.float-right {float: right;}
.m-0 { margin: 0; }
.m-4 { margin: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.inline { display: inline; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }

/* Mailchimp extracted inline CSS */
.mailchimp-obscured-input {
  position: absolute;
  left: -5000px;
}
