/** Main style for jmthornton.net
 *
 * Copyright (c) 2012-2025 Jade Michael Thornton
 */

/* Fonts */

@font-face {
  font-family: VictorMono;
  src:
    local("VictorMono-Regular"),
    url(https://jmthornton.net/assets/fonts/VictorMono-Regular.woff2) format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: VictorMono;
  src:
    local("VictorMono-Bold"),
    url(https://jmthornton.net/assets/fonts/VictorMono-Bold.woff2) format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: MetroNova;
  src:
    local("MetroNova-Regular"),
    url(https://jmthornton.net/assets/fonts/MetroNova-Regular.woff2) format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: MetroNova;
  src:
    local("MetroNova-Italic"),
    url(https://jmthornton.net/assets/fonts/MetroNova-Italic.woff2) format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: MetroNova;
  src:
    local("MetroNova-Bold"),
    url(https://jmthornton.net/assets/fonts/MetroNova-Bold.woff2) format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: MetroNova;
  src:
    local("MetroNova-BoldItalic"),
    url(https://jmthornton.net/assets/fonts/MetroNova-BoldItalic.woff2) format("woff2");
  font-style: italic;
  font-weight: 700;
  font-display: swap;
}

/* Numeric definitions */
:root {
  --main-width: 770px; /* approx. 88ch, but without the loading flash */
  --phi-em: 1.618033em;
  --font-main: MetroNova;
  --font-secondary: sans-serif;
  --font-mono: VictorMono, monospace;
  --font-size: 16px;
  --line-height: 1.618033em;
  --standard-margin: 1.618033em 0;
  --border-radius: 5px;

  /* Semantic colors */
  --error: var(--red);
  --heading: var(--mint);
  --heading-marker: var(--brown);
  --anchor: var(--fg);
  --anchor-hover: var(--blue);
  --footer-line: var(--heading);
  --button-primary-bg: var(--brown);
  --button-primary-fg: white;
  --button-primary-bg-hover: var(--mint);
  --button-primary-fg-hover: white;
  --button-secondary-bg: var(--mint);
  --button-secondary-fg: white;
  --button-secondary-bg-hover: var(--mint);
  --button-secondary-fg-hover: white;
  --button-low-key-bg: var(--grey2);
  --button-low-key-fg: white;
  --button-low-key-bg-hover: #f2f2f2; /* darkened white */
  --button-low-key-fg-hover: white;
  --spinner-fg: var(--mint);
  --pre-border: var(--green);
  --blockquote-bg: var(--gold);
  --aside-bg: var(--lighter-blue);
  --toggle-bg: var(--brown);
  --toggle-bg-disabled: #9f8473; /* lightened #83684c */
}

/* Base colors */
@media (prefers-color-scheme: light) {
  :root {
    --mint: #2aa198;
    --blue: #4b788d;
    --brown: #83684c;
    --gold: #fabd2f;
    --green: #8ec07c;
    --lighter-blue: #82aec5;
    --grey1: #e4e2e2;
    --grey2: #6b6b6b;
    --red: #dd8844;
    --bg: #fbfbfb;
    --bg-alt: #f6f3e7;
    --bg-alt-darker: #d6d0b9; /* manually darkened */
    --fg: #525c5a;
    --hr: var(--grey1);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --mint: #1a9188;
    --mint-alt: #4e7370;
    --blue: #5b889d;
    --brown: #83583c;
    --gold: #eaad1f;
    --green: #7eb06c;
    --lighter-blue: #729eb5;
    --grey1: #9295a0;
    --grey2: #6b6b6b;
    --red: #dd8844;
    --bg: #26282b;
    --bg-alt: #434546;
    --bg-alt-darker: #1f2225; /* manually darkened */
    --fg: #d5dae3;
    --hr: var(--grey2);
  }
}

/* Major structural elements */

:root {
  font-family: var(--font-main);
  font-size: var(--font-size);
  color: var(--fg);
  line-height: var(--line-height);
  scrollbar-color: var(--brown transparent);
}

body {
  display: flex;
  position: relative;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  margin: 40px auto;
  padding: 0 10px;
}

main {
  width: 100%;
  max-width: var(--main-width);
  margin: 0 2rem;
}

header {
  height: 2em;
  width: 100%;
  max-width: var(--main-width);
}

footer {
  position: relative;
  margin-top: 5rem;

  &::before {
    content: "- - - - - - -";
    color: var(--footer-line);
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

section {
  margin: 4rem 0;
}

figure {
  text-align: center;
}

figcaption {
  padding-top: 1em;
  font-style: italic;
}

/* Other elements */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: 1rem;
  font-weight: normal;
  line-height: var(--line-height);
  color: var(--heading);
  margin: var(--standard-margin);

  small {
    display: block;
    font-size: 0.6em;
    line-height: 1.2em;
  }
}

h1,
h2 {
  margin: 2.7rem 0 2rem;
}

h1 {
  font-size: 2.618030789em;

  @at-root main &:first-child {
    margin-top: 1.5rem;
  }
}

h2 {
  font-size: 1.618033em;
}

h3 {
  font-size: 1.35rem;
}

h4 {
  font-size: 1.15rem;
}

p,
ul {
  margin: var(--standard-margin);
}

li > p:first-child {
  margin-top: 0;
}

ul,
ol {
  list-style: none;
  padding: 0;

  > li {
    padding: 0.25em 0 0.25em 2ch;
    position: relative;
    margin: 0.15rem 0;
  }

  li::before {
    content: "•";
    position: absolute;
    top: 0.5ex;
    left: 0;
  }

  &.dl > li p:first-child {
    font-weight: bold;
  }
}

a {
  color: var(--anchor);
  text-decoration-color: var(--mint);

  @media (prefers-color-scheme: dark) {
    text-decoration-color: var(--mint-alt);
  }

  &:hover {
    text-decoration-color: var(--anchor-hover);
  }
}

div.no-md-a a {
  font-style: normal;
  &::before {
    content: none;
  }
  &::after {
    content: none;
  }
}

time {
  font-style: italic;

  &:not(:first-of-type)::before {
    content: "| ";
    font-style: normal;
    color: var(--heading-marker);
  }
}

blockquote {
  margin: 1rem;
  display: block;
  position: relative;
  font-style: italic;
  padding: 0.5rem;
  padding-left: 1rem;
  border-left: 0.375rem solid var(--blockquote-bg);
  border-radius: var(--border-radius);
  background: var(--bg-alt);

  &[cite]::after {
    font-style: normal;
    font-size: 0.75em;
    font-weight: 700;
    content: "\a—  " attr(cite);
    white-space: pre;
  }
}

aside {
  margin: 1rem;
  display: block;
  position: relative;
  padding: 1rem 1.5rem 1rem 2.5rem;
  border-left: 0.375rem solid var(--aside-bg);
  border-radius: var(--border-radius);
  background: var(--bg-alt);
}

img {
  border-radius: var(--border-radius);
  max-width: 100%;
  height: auto;
}

hr {
  border: 1px solid var(--hr);
}

.sep-top {
  border-top: 1px solid var(--hr);
}

/* Buttons and inputs */

button {
  display: inline-block;
  padding: 10px 12px;
  min-width: 6rem;
  min-height: max-content;
  border-color: var(--button-primary-bg);
  background-color: var(--button-primary-bg);
  color: var(--button-primary-fg);
  border-radius: var(--border-radius);
  text-decoration: none;
  cursor: pointer;
  line-height: 20px;
  text-align: center;
  outline: 0;

  &:hover {
    background-color: var(--button-primary-bg-hover);
    color: var(--button-primary-fg-hover);
  }

  &.secondary {
    background-color: none;
    border: 1px solid var(--button-secondary-bg);
    color: var(--button-secondary-fg);

    &:hover {
      background-color: var(--button-secondary-bg-hover);
      color: var(--button-secondary-fg-hover);
    }
  }

  &.low-key {
    background-color: var(--button-low-key-bg);
    color: var(--button-low-key-fg);
    &:hover {
      background-color: var(--button-low-key-bg-hover);
      color: var(--button-low-key-fg-hover);
    }
  }
}

div.action-buttons {
  display: flex;
  justify-content: end;
  width: 100%;

  > button {
    margin: 0 4px;

    &:last-child {
      margin-right: 0;
    }
  }
}

label.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;

  > span {
    padding-right: 1em;
    font-size: 0.85em;
  }

  input.toggle {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    user-select: none;
    background-color: var(--toggle-bg);
    border: 1px solid var(--toggle-bg);
    border-radius: var(--border-radius);
    height: 1.5em;
    width: 3em;
    box-shadow:
      -1.5em 0 0 2px var(--bg) inset,
      0 0 0 2px var(--bg) inset,
      0 0 0;

    &:not(.no-transition) {
      transition:
        background,
        box-shadow 0.2s ease-in-out;
    }

    &:checked {
      box-shadow:
        1.5em 0 0 2px var(--bg) inset,
        0 0 0 2px var(--bg) inset,
        0 0 0;
      background: var(--mint);
    }

    &:disabled {
      cursor: not-allowed;
      background-color: var(--toggle-bg-disabled);
      border-color: var(--toggle-bg-disabled);
    }
  }
}

/* Using some important tags to override prism */
pre {
  overflow: auto;
  position: relative;
  background: var(--bg-alt !important);
  padding: 0.75rem !important;
  margin: 2rem 0.5rem !important;
  border: none;
  border-left: 0.25rem solid var(--pre-border);
  border-radius: var(--border-radius);

  &.line-numbers {
    padding-left: 3.8em !important;
  }
}

code,
sub {
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  line-height: 0;
  position: relative;
  vertical-align: super;
  font-size: 0.7em;
}

code {
  background: var(--bg-alt);
  border: 1px solid var(--bg-alt-darker);
  border-radius: var(--border-radius);
  padding: 0 4px;
  font-size: 0.85em;

  pre & {
    background: transparent;
    border: none;
    padding: 0;
    font-size: inherit;
  }

  /* other prism improvements */
  .token.variable,
  .token.important,
  .token.regex,
  .token.property {
    color: #83684c;
  }
  .token.keyword,
  .token.selector {
    color: #968955;
    font-weight: bold;
  }
  .token.string {
    color: #8b887d;
  }
  .token.tag,
  .token.attr-name {
    color: #8b887d;
  }
  .token.function {
    color: #ab7146;
  }
  .token.builtin {
    color: #4b788d;
  }
  .token.attr-value {
    color: inherit;
  }
  .token.number {
    color: var(--fg);
  }
  .token.boolean,
  .token.class-name,
  .token.constant {
    color: #718388;
    font-weight: bold;
  }
  .token.doctype,
  .token.doctype * {
    color: silver;
  }
}

html code[class*="language-"],
html pre[class*="language-"] {
  color: var(--fg);
  font-family: var(--font-mono);
  text-shadow: none;
  -moz-tab-size: 2;
  -o-tab-size: 2;
  tab-size: 2;
}

code[class*="language-"] {
  font-size: 0.85em;

  pre & {
    font-size: 1em;
  }
}

div.code-toolbar > .toolbar {
  right: 1em;
}

.language-css .token.string,
.style .token.string,
.token.entity,
.token.operator,
.token.url {
  background: none;
}

/* page specifics */

div.stats {
  margin: 2.7rem 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;

  img {
    max-width: 90vw;
  }
}

div.shield-links {
  margin: 2.7rem 0;

  img {
    border-radius: 0;

    &:hover {
      transform: scale(2);
    }
  }

  a {
    text-decoration: none;
    background: none; /* clears hover animation */

    &::before {
      content: none;
    }
    &::after {
      content: none;
    }
  }
}

div.sponsor {
  display: flex;
  justify-content: center;
}

div.split {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;

  div.right {
    display: flex;
    align-items: center;
  }

  /* Same as main width */
  @media (min-width: 770px) {
    div.left {
      max-width: 54%;
    }

    div.right {
      max-width: 40%;
    }
  }
}

textarea {
  background-color: var(--bg-alt);
  color: var(--fg);
  border-color: transparent;
}

div.dev-only {
  padding: 1rem;
  background: red;
  color: white;
}

/* Effects */

/* Spinners */
.spinner {
  margin: var(--standard-margin);
  border: 0.25rem solid var(--bg);
  border-left: 0.25rem solid var(--spinner-fg);
  border-radius: 50%;
  width: 1.25rem;
  height: 1.25rem;
  animation: spinner-donut-anim 1.2s linear infinite;
}

@keyframes spinner-donut-anim {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spinner-donut {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 3em;
}

@keyframes hexdots-loader {
  0% {
    box-shadow:
      #666666 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  8.33% {
    box-shadow:
      #666666 26px -15px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  16.67% {
    box-shadow:
      #666666 26px 15px 0 7px,
      #999 26px 15px 0 7px,
      #999 26px 15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  25% {
    box-shadow:
      #666666 0 30px 0 7px,
      #999 0 30px 0 7px,
      #999 0 30px 0 7px,
      #999 0 30px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  33.33% {
    box-shadow:
      #666666 -26px 15px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  41.67% {
    box-shadow:
      #666666 -26px -15px 0 7px,
      #999 -26px -15px 0 7px,
      #999 -26px -15px 0 7px,
      #999 -26px -15px 0 7px,
      #999 -26px -15px 0 7px,
      #999 -26px -15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  50% {
    box-shadow:
      #666666 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 0 -30px 0 7px;
  }
  58.33% {
    box-shadow:
      #666666 26px -15px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px -15px 0 7px;
  }
  66.67% {
    box-shadow:
      #666666 26px 15px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 26px 15px 0 7px,
      #999 26px 15px 0 7px,
      #999 26px 15px 0 7px;
  }
  75% {
    box-shadow:
      #666666 0 30px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 0 30px 0 7px,
      #999 0 30px 0 7px;
  }
  83.33% {
    box-shadow:
      #666666 -26px 15px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px 15px 0 7px;
  }
  91.67% {
    box-shadow:
      #666666 -26px -15px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
  100% {
    box-shadow:
      #666666 0 -30px 0 7px,
      #999 0 -30px 0 7px,
      #999 26px -15px 0 7px,
      #999 26px 15px 0 7px,
      #999 0 30px 0 7px,
      #999 -26px 15px 0 7px,
      #999 -26px -15px 0 7px;
  }
}

.hexdots-loader {
  overflow: hidden;
  position: relative;
  text-indent: -9999px;
  display: inline-block;
  width: 7px;
  height: 7px;
  background: transparent;
  border-radius: 100%;
  box-shadow:
    #666666 0 -30px 0 7px,
    #999 26px -15px 0 7px,
    #999 26px 15px 0 7px,
    #999 0 30px 0 7px,
    #999 0 30px 0 7px,
    #999 0 30px 0 7px;
  animation: hexdots-loader 5s infinite ease-in-out;
  transform-origin: 50% 50%;
}

.hexdots-loader-wrapper {
  margin-left: 50%;
  padding-top: 100px;
}

/* RGB Animation */
:root {
  --rgb-orange: #f79533;
  --rgb-lime: #aee406;
  --rgb-sea-green: #07b39b;
  --rgb-green: #1098ad;
  --rgb-blue: #5073b8;
  --rgb-purple: #a166ab;
  --rgb-pink: #f37055;
  --rgb-red: #ef4e7b;
}

.rgb-color {
  color: var(--fg);
  animation: rgb-color-anim 7s linear infinite;
}

@keyframes rgb-color-anim {
  0% {
    color: var(--mint);
  }
  12.5% {
    color: var(--rgb-sea-green);
  }
  25% {
    color: var(--rgb-green);
  }
  37.5% {
    color: var(--rgb-blue);
  }
  50% {
    color: var(--rgb-purple);
  }
  62.5% {
    color: var(--rgb-pink);
  }
  75% {
    color: var(--rgb-red);
  }
  87.5% {
    color: var(--rgb-orange);
  }
  100% {
    color: var(--mint);
  }
}

/* RGB on Link Hovers */
@keyframes rgb-text-decoration-anim {
  0% {
    text-decoration: underline var(--mint);
  }
  12.5% {
    text-decoration: underline var(--rgb-sea-green);
  }
  25% {
    text-decoration: underline var(--rgb-green);
  }
  37.5% {
    text-decoration: underline var(--rgb-blue);
  }
  50% {
    text-decoration: underline var(--rgb-purple);
  }
  62.5% {
    text-decoration: underline var(--rgb-pink);
  }
  75% {
    text-decoration: underline var(--rgb-red);
  }
  87.5% {
    text-decoration: underline var(--rgb-orange);
  }
  100% {
    text-decoration: underline var(--mint);
  }
}

a:not(.no-rgb) {
  text-decoration: underline var(--mint);

  &:hover {
    animation: rgb-text-decoration-anim 4s linear infinite;
  }

  &.no-a {
    text-decoration: none;
    animation: none;
  }
}
