/* CandyBoudoir: tokens and components for candyboudoir.com and
   stash.candyboudoir.com, built on the brand board: ivory, cherry red,
   cardigan pink and near-black, the script wordmark and the character. */

@font-face {
  font-family: 'Young Serif';
  src: url('fonts/young-serif-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'Libre Franklin';
  src: url('fonts/libre-franklin-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Libre Franklin';
  src: url('fonts/libre-franklin-latin-400-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Libre Franklin';
  src: url('fonts/libre-franklin-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Libre Franklin';
  src: url('fonts/libre-franklin-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'Libre Franklin';
  src: url('fonts/libre-franklin-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --c-ivory: #fff0e5;
  --c-ink: #1a1310;
  --c-cherry: #a80217;
  --c-pink: #f87289;
  --c-night: #1d1512;
  --serif: 'Young Serif', georgia, serif;
  --sans: 'Libre Franklin', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', menlo, monospace;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  --gap: clamp(1rem, 2.5vw, 2rem);

  /* Light: ivory ground, near-black text, cherry links, an ink tip block. */
  color-scheme: light;

  --bg: var(--c-ivory);
  --text: var(--c-ink);
  --text-soft: #6b4a40;
  --link: var(--c-cherry);
  --rule: rgb(26 19 16 / 18%);
  --rule-strong: var(--c-ink);
  --block-bg: var(--c-ink);
  --block-text: var(--c-ivory);
  --block-soft: rgb(255 240 229 / 72%);
  --button-bg: var(--c-ink);
  --button-text: var(--c-ivory);
  --button-hover: var(--c-cherry);
}

/* Dark: night ground, ivory text, pink links, an ivory tip block. The pink
   band keeps its ink text in both themes. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --bg: var(--c-night);
    --text: var(--c-ivory);
    --text-soft: #c8a89c;
    --link: var(--c-pink);
    --rule: rgb(255 240 229 / 18%);
    --rule-strong: var(--c-ivory);
    --block-bg: var(--c-ivory);
    --block-text: var(--c-ink);
    --block-soft: rgb(26 19 16 / 72%);
    --button-bg: var(--c-ivory);
    --button-text: var(--c-ink);
    --button-hover: var(--c-pink);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: var(--c-night);
  --text: var(--c-ivory);
  --text-soft: #c8a89c;
  --link: var(--c-pink);
  --rule: rgb(255 240 229 / 18%);
  --rule-strong: var(--c-ivory);
  --block-bg: var(--c-ivory);
  --block-text: var(--c-ink);
  --block-soft: rgb(26 19 16 / 72%);
  --button-bg: var(--c-ivory);
  --button-text: var(--c-ink);
  --button-hover: var(--c-pink);
}

/* Art drawn in near-black has an ivory twin for the dark theme. */
.on-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .on-light {
    display: none;
  }

  :root:not([data-theme='light']) .on-dark {
    display: block;
  }
}

:root[data-theme='dark'] .on-light {
  display: none;
}

:root[data-theme='dark'] .on-dark {
  display: block;
}

:root[data-theme='light'] .on-dark {
  display: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--c-pink);
  color: var(--c-ink);
}

a {
  color: var(--link);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 3px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid currentcolor;
  outline-offset: 3px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  text-wrap: balance;
}

h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 1;
}

h3 {
  font-size: 1.75rem;
  line-height: 1.1;
}

p {
  text-wrap: pretty;
}

code {
  font: 500 0.9em var(--mono);
  overflow-wrap: break-word;
}

.wrap {
  padding-inline: var(--gutter);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Top line of links. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem 1.5rem;
  padding-block: 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.topbar a,
.theme-toggle {
  color: var(--text);
  text-decoration-color: transparent;
}

.topbar a:hover,
.topbar a[aria-current] {
  text-decoration-color: var(--link);
}

.topbar .tip-link {
  color: var(--link);
}

/* The theme button: an icon for auto (half a circle), light (a sun) or
   dark (a moon), whichever is current. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: -0.375rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.theme-toggle svg {
  display: none;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle[data-state='auto'] .i-auto,
.theme-toggle[data-state='light'] .i-light,
.theme-toggle[data-state='dark'] .i-dark {
  display: block;
}

.theme-toggle:hover {
  color: var(--link);
}

/* Marks a link that leaves the site. */
.ext {
  width: 0.75em;
  height: 0.75em;
  margin-left: 0.25em;
  vertical-align: -0.02em;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The stage: the character on the left and the wordmark beside her, as on
   the brand kit's hero, sitting on a pink band that carries the
   introduction. */
.stage {
  align-items: end;
  margin-top: clamp(0rem, 2vw, 1.5rem);
}

.stage > h1 {
  grid-row: 1;
  grid-column: 7 / -1;
  place-self: center center;
  padding-bottom: clamp(2rem, 6vw, 5rem);
}

.stage > h1 img {
  vertical-align: bottom;
  width: 100%;
  max-width: 36rem;
  height: auto;
}

.stage .character {
  grid-row: 1;
  grid-column: 1 / 7;
  display: block;
  width: 100%;
  max-width: 34rem;
  height: auto;
  justify-self: start;
}

/* The band keeps its colours in both themes, so it sets the roles the
   components inside it read. */
.band {
  --bg: var(--c-pink);
  --text: var(--c-ink);
  --text-soft: #3a2420;
  --link: var(--c-ink);
  --rule: rgb(26 19 16 / 25%);
  --rule-strong: var(--c-ink);

  background: var(--bg);
  color: var(--text);
}

/* The band holds two columns: the introduction or the install steps on the
   left, and notes beside them on the right, each opening on a rule. */
.band .intro-block,
.band .install {
  grid-column: 1 / 7;
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.band .intro-block {
  grid-column: 1 / 8;
}

.band-notes {
  grid-column: 8 / -1;
  padding-block: clamp(2rem, 5vw, 3.5rem);
}

.band .install + .band-notes {
  grid-column: 7 / -1;
}

.band-notes section {
  padding-block: 1.25rem 1.5rem;
  border-top: 2px solid var(--rule-strong);
}

.band-notes section + section {
  border-top-width: 1px;
  border-top-color: var(--rule);
}

.band-notes h2 {
  font-size: 1.5rem;
  line-height: 1.15;
}

.band-notes p {
  max-width: 34em;
  margin: 0.5rem 0 0;
}

.band-notes > section > a {
  display: inline-block;
  margin-top: 0.75rem;
  font-weight: 600;
}

/* The plugin site's header: the wordmark small in the top line, a written
   title in place of the large wordmark, and a smaller character. */
.topbar .home {
  margin-right: auto;
}

.topbar .home img {
  vertical-align: bottom;
  width: auto;
  height: 2.75rem;
}

.stage .title {
  grid-row: 1;
  grid-column: 7 / -1;
  align-self: center;
  padding-bottom: clamp(2rem, 5vw, 4rem);
}

.stage .title h1 {
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 1;
}

.stage .title p {
  max-width: 30em;
  margin: 1.25rem 0 0;
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
}

/* The plugin site uses a crop cut through her elbow and the chair arm at
   the left, so she bleeds off the page there. */
.stage--compact .character {
  max-width: 24rem;
  margin-left: calc(var(--gutter) * -1);
}

.band .intro {
  max-width: 34em;
  margin: 0;
  font-size: clamp(1.25rem, 2.2vw, 1.75rem);
  font-weight: 500;
  line-height: 1.3;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1.75rem;
  font-weight: 600;
}

.band a:not(.button) {
  color: var(--c-ink);
  text-decoration-color: var(--c-cherry);
}

.band ::selection {
  background: var(--c-ink);
  color: var(--c-pink);
}

/* A section: its title in the left columns, its content on the right. */
.section {
  margin-top: clamp(4.5rem, 9vw, 8rem);
}

.section > h2 {
  grid-column: 1 / 5;
  align-self: start;
}

.section > .body {
  grid-column: 5 / -1;
}

/* Themes: each a screenshot with its caption under it. */
.works {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem var(--gap);
}

.works figure {
  margin: 0;
}

.works img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}

.works figcaption {
  margin-top: 1rem;
}

.works p {
  max-width: 32em;
  margin: 0.5rem 0 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.version {
  margin-left: 0.5rem;
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  vertical-align: 0.35em;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

/* Plugins: one row each between rules. */
.index {
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--rule-strong);
  list-style: none;
}

.index li {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.5rem var(--gap);
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.index p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.index .links {
  margin: 0;
  justify-content: flex-end;
}

.aside {
  max-width: 36em;
  margin: 1.5rem 0 0;
  color: var(--text-soft);
  font-size: 1rem;
}

/* The tip block: the portrait on ink (ivory in the dark theme), the one
   solid block on the page. */
.tip {
  margin-top: clamp(5rem, 10vw, 9rem);
  padding-block: clamp(3rem, 7vw, 5.5rem);
  background: var(--block-bg);
  color: var(--block-text);
  align-items: center;
}

.tip img {
  grid-column: 1 / 4;
  display: block;
  width: 100%;
  max-width: 16rem;
  height: auto;
}

.tip .copy-block {
  grid-column: 5 / 12;
}

.tip h2 {
  color: var(--block-text);
}

.tip p {
  max-width: 32em;
  margin: 1.25rem 0 1.75rem;
  font-size: 1.125rem;
}

.tip .fine {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
}

.button {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  border-radius: 4px;
  background: var(--button-bg);
  color: var(--button-text);
  font-weight: 600;
  text-decoration: none;
}

.button:hover {
  background: var(--button-hover);
  color: var(--button-text);
}

/* On the pink band the button is ink in both themes; in the tip block it
   is pink in both themes. */
.band .button {
  background: var(--c-ink);
  color: var(--c-ivory);
}

.band .button:hover {
  background: var(--c-cherry);
  color: var(--c-ivory);
}

.tip .button {
  background: var(--c-pink);
  color: var(--c-ink);
}

.tip .button:hover {
  background: var(--c-ivory);
  color: var(--c-ink);
}

.fine {
  margin: 1rem 0 0;
  color: var(--block-soft);
  font-size: 0.9375rem;
}

.body > .lead {
  max-width: 36em;
  margin: 0 0 1.5rem;
}

/* News: dated entries. */
.notes {
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--rule-strong);
  list-style: none;
}

.notes li {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 0.25rem var(--gap);
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.notes time {
  color: var(--text-soft);
  font-size: 0.9375rem;
  font-weight: 500;
}

.notes p {
  max-width: 36em;
  margin: 0;
}

/* Steps: a real sequence, so real numbers. */
.steps {
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--rule-strong);
  list-style: none;
  counter-reset: step;
}

.steps > li {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
  counter-increment: step;
}

.steps > li::before {
  content: counter(step);
  color: var(--link);
  font-family: var(--serif);
  font-size: 1.75rem;
  line-height: 1;
}

.steps p {
  max-width: 36em;
  margin: 0;
}

/* Copy fields for the source's name, URL and local path. */
.fields {
  margin: 1rem 0 0;
}

.field {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem 1rem;
  padding-block: 0.6rem;
  border-top: 1px solid var(--rule);
}

.field:last-child {
  border-bottom: 1px solid var(--rule);
}

.field > span {
  color: var(--text-soft);
  font-size: 0.875rem;
  font-weight: 500;
}

.field code {
  font: 500 0.9375rem var(--mono);
  overflow-wrap: break-word;
}

.copy {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--text);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: 600 0.875rem/1.2 var(--sans);
  cursor: pointer;
}

.copy:hover,
.copy.done {
  background: var(--text);
  color: var(--bg);
}

/* The 404 page: the full figure in her armchair beside the message. */
.notfound {
  align-items: center;
  padding-block: clamp(2rem, 6vw, 5rem);
}

.notfound > div {
  grid-row: 1;
  grid-column: 7 / -1;
}

.notfound h1 {
  font-size: clamp(3rem, 7vw, 5.5rem);
  line-height: 1;
}

.notfound p {
  max-width: 26em;
  margin: 1.25rem 0 0;
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
}

.notfound img {
  grid-row: 1;
  grid-column: 1 / 6;
  justify-self: center;
  width: 100%;
  max-width: 24rem;
  height: auto;
}

/* Footer. */
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2rem;
  margin-top: clamp(4.5rem, 9vw, 7rem);
  padding-block: 1.5rem 3rem;
  border-top: 2px solid var(--rule-strong);
  font-size: 0.9375rem;
}

.footer img {
  width: 4rem;
  height: auto;
}

.footer p {
  flex: 1;
  margin: 0;
}

.footer nav {
  display: flex;
  gap: 1.25rem;
}

@media (width < 56rem) {
  .stage > h1,
  .stage .title,
  .stage .character,
  .band .intro-block,
  .band .install,
  .band-notes,
  .band .install + .band-notes,
  .section > h2,
  .section > .body,
  .tip img,
  .tip .copy-block {
    grid-column: 1 / -1;
  }

  .stage > h1,
  .stage .title,
  .stage .character,
  .notfound > div,
  .notfound img {
    grid-row: auto;
    grid-column: 1 / -1;
  }

  .notfound img {
    max-width: 16rem;
    margin-top: 2.5rem;
  }

  .band-notes {
    padding-top: 0;
  }

  .stage > h1 {
    justify-self: start;
    padding-bottom: 1.5rem;
  }

  .stage .character {
    max-width: 26rem;
  }

  /* On the plugin site the install steps come first, so she sits small. */
  .stage--compact .character {
    max-width: 13rem;
  }

  .section > h2 {
    margin-bottom: 1.5rem;
  }

  .tip img {
    max-width: 10rem;
    margin-bottom: 1.5rem;
  }
}

@media (width < 40rem) {
  .works {
    grid-template-columns: 1fr;
  }

  .index li,
  .notes li {
    grid-template-columns: 1fr;
  }

  .index .links {
    justify-content: flex-start;
  }

  .topbar {
    justify-content: flex-start;
    gap: 0.25rem 1.1rem;
  }

  .field {
    grid-template: 'label copy' 'code code' / 1fr auto;
  }

  .field > span {
    grid-area: label;
  }

  .field .copy {
    grid-area: copy;
  }

  .field code {
    grid-area: code;
    font-size: 0.8125rem;
  }
}
