/* * {
  outline: 1px red solid;
} */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  /* padding: 0; */
}

*+* {
  margin-block-start: 2em;
}

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scrollbar-gutter: stable;
}

:root {
  color-scheme: light dark;
  /* reds */
  --hero: oklch(45.54% 0.137 358.99);
  --ruby: oklch(from var(--hero) 30% c h);
  /* approx #5d002c */
  --deep-ruby: oklch(from var(--hero) 17% c h);
  /* approx #34000e */

  /* pinks */
  --thulian: oklch(from var(--hero) 75% c h);
  /* a strong purplish-pink mineral colour */
  --carnation-pink: oklch(from var(--hero) 85% c h);
  /* a bright pink, approx #ffa6cc */
  --ballet-pink: oklch(0.8529 0.0567 6.35);
  /* #f1c0c9 */

  /* sandy */
  --soapstone: oklch(98.62% 0.014 84.58);
  /* #fffaf0 */
  --linen: oklch(from var(--soapstone) 95% c h);
  /* #f3eee4 */

  /* greys */
  --charcoal: oklch(0.2988 0 0);
  /* #2d2d2d */
  --mid-grey: oklch(50% 0 0);

  --headings-color: light-dark(var(--hero), var(--thulian));
  --background-color: light-dark(var(--soapstone), var(--deep-ruby));
  --text-color: light-dark(black, var(--linen));
  --link-color: light-dark(var(--hero), var(--carnation-pink));
  --link-hover-color: light-dark(var(--deep-ruby), var(--ballet-pink));
}

body {
  min-block-size: 100svh;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family:
    'Instrument Sans',
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    'Open Sans',
    'Helvetica Neue',
    sans-serif;
  max-width: min(90vw, 80ch);
  margin: 1rem auto;
}

@media (min-width: 1000px) {

  .left,
  .right {
    max-width: 60%;
    margin: 2rem;
  }

  .right {
    float: right;
    margin-inline-end: -5ch;
  }

  .left {
    float: left;
    margin-inline-start: -5ch;
  }
}

blockquote {
  border-inline-start: 0.5em solid oklch(from var(--mid-grey) l c h / 0.4);
  background-color: light-dark(oklch(from var(--mid-grey) l c h / 0.15),
      oklch(from var(--mid-grey) l c h / 0.35));
  font-size: 1.1em;
  padding-block: 0.8em;
  padding-inline: 1em 2em;
  margin-block-start: 1em;
}

blockquote.article-self-quote {
  border-inline-start: 0.7em solid oklch(from var(--mid-grey) l c h / 0.5);
  background-color: light-dark(oklch(from var(--mid-grey) l c h / 0.15),
      oklch(from var(--mid-grey) l c h / 0.35));
  font-size: 1.2em;
  padding-block: 1em;
  padding-inline: 1em 2em;
  position: relative;
  margin-block-start: 1em;

  @media (min-width: 1000px) {
    font-size: 1.5em;
  }

  text-wrap: balance;
  font-style: italic;
  line-height: 1.5;
}

pre {
  /* overflow-x: scroll; */
  white-space: pre-wrap;
  background-color: light-dark(oklch(from var(--mid-grey) l c h / 0.15),
      oklch(from var(--mid-grey) l c h / 0.35));
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  line-height: 1.5;
  padding: 1em;
}

code .comment,
code .delimiter {
  color: light-dark(var(--ruby), var(--ballet-pink));
}

code .comment {
  font-style: italic;
}

ul,
ol {
  margin-block: 1em 3em;
}

p,
li {
  max-width: 80ch;
  text-wrap: pretty;
  line-height: 1.5;
  letter-spacing: 0.12ch;
  word-spacing: 0.16ch;
}

h1+p,
h2+p,
h3+p {
  margin-block-start: 1em;
}

li {
  margin-block-start: 1em;
  max-width: 60ch;

  @media (max-width: 60ch) {
    text-wrap: balance;
  }
}

h1,
h2,
h3 {
  color: var(--headings-color);
  font-family:
    'Rethink Sans',
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    'Open Sans',
    'Helvetica Neue',
    sans-serif;
  text-wrap: balance;
}

h1 {
  line-height: 0.95;
  padding-top: 1rem;
}

h3 {
  font-size: 1.3rem;
}

h2 {
  font-size: 1.6rem;
}

h1 {
  font-size: 2.56rem;
}

a {
  color: var(--link-color);
  text-underline-offset: 0.2em;
  font-weight: 500;
}

a:hover,
a:focus-visible {
  color: var(--link-hover-color);
}

/* Intro data grid styling */
div.intro-data {
  color: light-dark(var(--charcoal), var(--ballet-pink));
  font-size: 0.8rem;
  line-height: 1;
  display: grid;
  margin-block-start: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15ch, 1fr));
  row-gap: 0.5rem;
  /* multi-rows on small screens */

  * {
    margin: 0;
    padding: 0;
  }
}

/* Sequence and component diagrams grid styling */
div.image-container {
  background: var(--background-color);
  max-width: 35rem;
  /* default max-width for sequence diagrams */
  margin: 1em auto 0 auto;
  /* resets owl and applies horizontal center with auto */
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 1rem;
  align-items: center;
  justify-items: center;

  /* target component diagram containers specifically */
  &:has(.component-diagram) {
    max-width: 30rem;
  }

  /* needed? */
  @media (max-width: 60ch) {
    grid-template-columns: 1fr;
  }

  * {
    margin: 0;
  }

  picture {
    display: contents;
  }

  picture img {
    width: 100%;
    /* fills the inner content width of the figure */
    height: auto;
    /* maintains original aspect ratio */
  }

  p.image-caption {
    font-size: 0.9rem;
    font-style: italic;
    text-align: left;
    max-width: 100%;
    grid-column: 1/-1;
    place-self: start;
  }
}

/* Robocop equation grid styling */
figure#robocop-equation {
  max-width: 100%;
  margin: 1em auto 0 auto;
  /* resets owl and applies horizontal center with auto */
  width: max-content;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 1rem;
  align-items: center;

  @media (max-width: 60ch) {
    grid-template-columns: 1fr;
  }

  * {
    margin: 0;
  }

  justify-items: center;
}

figure#robocop-equation {
  /* grid */
  width: inherit;
  /* move to block above? */
  /* margin-top: 2em; */

  img {
    justify-self: center;
    /* redundant with justify-items: center in block above? */
  }

  .label {
    align-self: start;
  }

  /* desktop grid */
  @media (width > 60ch) {
    grid-template-columns: 1fr 5ch 1fr 5ch 1fr;
    column-gap: 1rem;
    row-gap: 0;
  }

  /* mobile grid */
  @media (max-width: 60ch) {
    grid-template-columns: 1fr;
    row-gap: 2rem;
  }

  /* desktop element placement */
  @media (width > 60ch) {
    .drawing {
      grid-row: 1;
    }

    .label {
      grid-row: 2;
    }

    figcaption {
      grid-column: 1 / -1;
      grid-row: 3;
      margin-top: 0.5em;
    }

    #agent,
    #agent_text {
      grid-column: 1;
    }

    #equals {
      grid-column: 2;
    }

    #brain,
    #brain_text {
      grid-column: 3;
    }

    #plus {
      grid-column: 4;
    }

    #armour,
    #armour_text {
      grid-column: 5;
    }
  }

  /* mobile element placement */
  @media (max-width: 60ch) {
    .label {
      margin-top: -1.5rem;
    }

    #agent {
      grid-row: 1;
    }

    #agent_text {
      grid-row: 2;
    }

    #equals {
      grid-row: 3;
    }

    #brain {
      grid-row: 4;
    }

    #brain_text {
      grid-row: 5;
    }

    #plus {
      grid-row: 6;
    }

    #armour {
      grid-row: 7;
    }

    #armour_text {
      grid-row: 8;
    }

    figcaption {
      grid-row: 9;
      margin-top: -1em;
    }
  }
}

figure#robocop-equation {
  display: grid;

  /* probs redundant. need to test. */
  img {
    width: 100%;
    /* actually in use? overriden by individual image styles? */
    height: auto;
    /* actually in use? */
    /* max-width: 100rem; */
  }

  figcaption {
    font-size: 0.9rem;
    font-style: italic;
    text-align: left;
    max-width: 75ch;
    grid-column: 1/-1;
    place-self: start;
  }
}

/*
Robocop equation
- constrains drawing and label sizes
- em values calculated from originals at 16px font size
- desktop imgs are resized to 50% of the originals
- mobile imgs are resized to 75% of the desktop sizes
- on mobile, agent is resized to match armour
*/
img#agent {
  max-width: 14.616rem;

  @media (max-width: 60ch) {
    max-width: 8.103rem;
  }
}

img#agent_text {
  max-width: 5.67rem;

  @media (max-width: 60ch) {
    max-width: 4.253rem;
  }
}

img#equals {
  max-width: 1.827rem;

  @media (max-width: 60ch) {
    max-width: 1.37rem;
  }
}

img#brain {
  max-width: 8.852rem;

  @media (max-width: 60ch) {
    max-width: 6.639rem;
  }
}

img#brain_text {
  max-width: 7.812rem;

  @media (max-width: 60ch) {
    max-width: 5.859rem;
  }
}

img#plus {
  max-width: 1.386rem;

  @media (max-width: 60ch) {
    max-width: 1.04rem;
  }
}

img#armour {
  max-width: 10.805rem;

  @media (max-width: 60ch) {
    max-width: 8.103rem;
  }
}

img#armour_text {
  max-width: 7.25rem;

  @media (max-width: 60ch) {
    max-width: 5.438rem;
  }
}

/* Fall down image styling */
figure#fall-down-figure {
  /* grid */
  max-width: 100%;
  margin: 1em auto 0 auto;
  /* do you want the 1em top margin? */
  width: inherit;
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 1rem;
  align-items: center;

  * {
    margin: 0;
  }

  justify-items: center;

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

  figcaption {
    font-size: 0.9rem;
    font-style: italic;
    text-align: left;
    max-width: 75ch;
    grid-column: 1/-1;
    place-self: start;
  }
}
