/* merlin public site theme. Hand-authored, served straight from priv/static
   -- no build step, no Tailwind. Adapted (and trimmed) from the itanimul.li
   design language: Literata prose, an OKLCH token system with color-mix
   shades, a tight justified reading column, and a JS-gated light/dark
   toggle. Deliberately its own stylesheet, unrelated to the admin panel. */

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/theme/fonts/literata-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/theme/fonts/literata-normal-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/theme/fonts/literata-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/theme/fonts/literata-italic-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --font-prose: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --primary: oklch(70% 0.1 240);
  --secondary: oklch(70% 0.1 320);
  --tertiary: oklch(70% 0.14 30);
  --special: oklch(70% 0.1 160);
  --bg: #fefefe;
  --bg-alt: color-mix(in oklch, #fefefe, black 5%);
  --bg-inver: color-mix(in oklch, #fefefe, white 45%);
  --fg: #191919;
  --fg-alt: color-mix(in oklch, #191919, white 15%);
  --fg-alter: color-mix(in oklch, #191919, white 45%);
}

:root[data-theme="dark"] {
  --font-prose: var(--font-ui);
  --bg: #090909;
  --bg-alt: color-mix(in oklch, #090909, white 10%);
  --bg-inver: color-mix(in oklch, #090909, black 60%);
  --fg: #dcdcdc;
  --fg-alt: color-mix(in oklch, #dcdcdc, black 20%);
  --fg-alter: color-mix(in oklch, #dcdcdc, black 60%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --font-prose: var(--font-ui);
    --bg: #090909;
    --bg-alt: color-mix(in oklch, #090909, white 10%);
    --bg-inver: color-mix(in oklch, #090909, black 60%);
    --fg: #dcdcdc;
    --fg-alt: color-mix(in oklch, #dcdcdc, black 20%);
    --fg-alter: color-mix(in oklch, #dcdcdc, black 60%);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
img,
picture,
video,
svg {
  display: block;
  max-width: 100%;
}
input,
button,
textarea,
select {
  font: inherit;
}

html {
  padding: 8px 32px 128px 32px;
  scrollbar-gutter: stable both-edges;
  font-size: 16px;
  font-family: var(--font-ui);
  color: var(--fg);
  background-color: var(--bg);
}

body {
  text-align: start;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
  font-size: 1rem;
  line-height: 1.58;
  max-width: 650px;
  margin-inline: auto;
}

::selection {
  color: #080808;
  background-color: oklch(70% 0.1 240);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

p {
  font-family: var(--font-prose);
  text-align: justify;
  text-wrap: pretty;
  overflow-wrap: break-word;
  font-kerning: normal;
  hyphens: auto;
  padding: 8px 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  overflow-wrap: break-word;
  padding-block: 16px 4px;
}
h1 {
  text-align: center;
  color: var(--fg-alt);
}
h5,
h6 {
  font-weight: normal;
}
h1 > strong,
h2 > strong,
h3 > strong {
  text-decoration: underline;
  color: var(--fg);
}

ul,
ol {
  font-family: var(--font-prose);
  text-align: start;
  line-height: 1.286;
  padding-inline-start: 20px;
}
ul > li > p {
  margin: 0;
  text-align: start;
}
li > ul,
li > ol {
  margin-block-end: 4px;
}

a {
  color: var(--primary);
  background-color: inherit;
}
a:hover {
  text-decoration: none;
  background-color: var(--primary);
  color: var(--bg);
}
a:active {
  background-color: var(--tertiary);
}
a.external::after {
  font-family: var(--font-mono);
  content: "\2197\FE0E";
  font-weight: bold;
}

blockquote {
  font-family: var(--font-prose);
  border-inline-start: 1px solid var(--fg-alter);
  padding-inline-start: 16px;
  color: var(--fg-alt);
  font-style: italic;
  text-wrap: balance;
}
blockquote em {
  color: var(--fg);
}

img {
  background-color: var(--bg-alt);
}
img[src*="#header"] {
  aspect-ratio: 2 / 1;
  width: 100%;
  object-fit: cover;
}

table {
  font-family: var(--font-prose);
  width: 100%;
  background-color: var(--bg-alt);
  border: 1px solid var(--fg-alt);
  border-spacing: 0;
}
table th {
  border-bottom: 1px solid var(--fg-alter);
}
table th:not(:last-child),
table td:not(:last-child) {
  border-right: 1px solid var(--fg-alter);
}
table th,
table td {
  padding: 4px;
}

code {
  background-color: var(--bg-alt);
  color: var(--fg-alt);
  padding: 4px;
}
pre code {
  display: block;
  padding: 16px;
  white-space: pre-wrap;
  font-size: 0.875rem;
  overflow-x: auto;
}

hr {
  border: none;
  height: 1px;
  background-color: var(--fg-alter);
  margin: 24px 0;
}

/* -- chrome: header nav, theme toggle, footer -------------------------- */

body > header {
  margin: 16px 0 8px 0;
}
body > header nav {
  padding: 8px 12px;
  background-color: var(--bg-inver);
  border: solid 1px var(--bg-alt);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
body > header nav a {
  text-decoration: none;
  color: var(--fg-alt);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
body > header nav a:hover {
  color: inherit;
  background-color: inherit;
}
body > header nav a span {
  border-bottom: solid 2px var(--fg-alt);
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
body > header nav a:hover span {
  color: var(--bg-alt);
  background-color: var(--fg-alt);
}
body > header nav a:first-child span {
  font-weight: bold;
  border-bottom-color: var(--primary);
}

#theme-toggle {
  display: none;
  justify-self: end;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-alt);
  font-size: 1.2em;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}
.js #theme-toggle {
  display: flex;
}
#theme-toggle:hover {
  background-color: var(--fg);
  color: var(--bg);
}
#theme-toggle:active {
  transform: rotate(180deg);
}
#theme-toggle .theme-icon::before {
  font-family: var(--font-mono);
  content: "\2600\FE0E";
}
:root[data-theme="dark"] #theme-toggle .theme-icon::before {
  content: "\263E\FE0E";
}

main header {
  margin: 4px auto;
}
main header p {
  text-align: center;
  color: var(--fg-alt);
}
main nav ul {
  list-style-type: none;
  padding: 0;
}
main nav ul li a:visited {
  color: var(--secondary);
}

body > footer {
  padding: 16px 0;
}
body > footer small {
  color: var(--fg-alt);
  user-select: none;
}

@media print {
  html {
    font-family: var(--font-prose);
    padding-block-end: 0;
  }
  body {
    max-width: 100%;
  }
  header,
  footer {
    display: none;
  }
}
