/*----- base formatting -----*/

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h3,
h2,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  background: transparent;
  box-sizing: border-box;
}

/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
  display: block;
}

body {
  line-height: 1;
}

ol,
ul {
  list-style: none;
}

blockquote,
q {
  quotes: none;
}

blockquote:before,
blockquote:after,
q:before,
q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/*----- variables -----*/

:root {

  /*----- body -----*/
  --text: #444444;
  --link: #968aff;
  --link-hover: rgba(120, 197, 161, 1);
  --link-hover-background: rgba(161, 213, 189, 0.182);
  --bold: #78c5a1;
  --italic: rgba(150, 138, 255, 0.1);
  --marker: rgba(150, 138, 255, 0.2);
  --marker1: rgba(150, 138, 255, 0.2);
  --marker2: white;
  --highlight-text: #000000;
  --highlight-background: #b5ffdc46;
  --h1-text: #444444;
  --h1-shadow: #78c5a167;
  --h3-underline: rgba(150, 138, 255, 0.3);
  --h2-color: rgb(37, 37, 37);
  --h2-background: rgba(181, 255, 220, 0.6);
  --color-code: rgba(187, 187, 187, 0.2);
  --fieldset-border: solid 1px rgba(150, 138, 255, 0.4);

  /*----- scrollbar -----*/
  --scrollbar: #b5b5ff;
  --scrollbar-width: 0px;

  /*-- dark mode --*/

  --background-dark: #1f1f1f;
  --link-dark: rgb(179, 166, 255);
  --link-hover-background-dark: rgba(34, 126, 83, 0.3);
  --text-dark: #ddd;
}

/*----- fonts -----*/

@font-face {
  font-family: 'Press Start';
  src: url('/fonts/PressStartReg.woff2') format('woff2'),
    url('/fonts/PressStartReg.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'maru';
  src: url('/fonts/x12y16pxMaruMonica.woff2') format('woff2'),
    url('/fonts/x12y16pxMaruMonica.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'nineteen93';
  src: url('/fonts/Nineteen-Ninety-Three.woff2') format('woff2'),
    url('/fonts/Nineteen-Ninety-Three.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'NDS true bios';
  src: url('/fonts/NDStruebios.woff2') format('woff2'), url('/fonts/NDStruebios.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ibm-plex-sans-thai-300 - latin_latin-ext_thai */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 300;
  src: url('/fonts/ibm-plex-sans-thai-v10-latin_latin-ext_thai-300.woff2') format('woff2');
}

/* ibm-plex-sans-thai-regular - latin_latin-ext_thai */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 400;
  src: url('/fonts/ibm-plex-sans-thai-v10-latin_latin-ext_thai-regular.woff2') format('woff2');
}

/* ibm-plex-sans-thai-500 - latin_latin-ext_thai */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 500;
  src: url('/fonts/ibm-plex-sans-thai-v10-latin_latin-ext_thai-500.woff2') format('woff2');
}

/* ibm-plex-sans-thai-600 - latin_latin-ext_thai */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 600;
  src: url('/fonts/ibm-plex-sans-thai-v10-latin_latin-ext_thai-600.woff2') format('woff2');
}

/* ibm-plex-sans-thai-700 - latin_latin-ext_thai */
@font-face {
  font-display: swap;
  font-family: 'IBM Plex Sans Thai';
  font-style: normal;
  font-weight: 700;
  src: url('/fonts/ibm-plex-sans-thai-v10-latin_latin-ext_thai-700.woff2') format('woff2');
}

/*----- text highlight -----*/

::selection {
  color: var(--highlight-text);
  background: var(--highlight-background);
}

::-moz-selection {
  color: var(--highlight-text);
  background: var(--highlight-background);
}

/*----- webkit scrollbar -----*/

::-webkit-scrollbar {
  width: var(--scrollbar-width);
  height: 0;
  background-color: var(--main-box-background);
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar);
  border-radius: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
  background-color: var(--main-box-background);
  border-radius: var(--scrollbar-width);
}

::-webkit-scrollbar-corner {
  background: var(--main-box-background);
}

/*----- body -----*/

* {
  box-sizing: border-box;
}

a:focus,
iframe:focus,
#leftcolumn-inner a:focus,
summary:focus,
textarea:focus {
  outline: 4px solid var(--link);
  z-index: 99;
  position: relative;
}

html,
body {
  scroll-behavior: smooth;
}

body {
  display: grid;
  grid-template-columns: auto 0px;
  padding: 10px;
  color: var(--text);
  font-family: "IBM Plex Sans Thai", sans-serif;
  font-optical-sizing: auto;
  font-style: normal;
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: left;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

article {
  width: calc(100vw - 20px);
  max-width: 800px;
  margin: 0 auto;
}

/*----- text decoration -----*/

h1 {
  font-family: 'Press Start';
  font-size: 24px;
  font-weight: normal;
  text-transform: uppercase;
  line-height: 2em;
  color: var(--h1-text);
  text-shadow: 2px 2px 0px var(--h1-shadow);
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

h3,
.h3 {
  font-family: maru;
  /* font-weight: 700; */
  font-size: 16px;
  text-decoration: underline solid var(--h3-underline) 3px;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  padding-bottom: 0.3em;
}

h3 {
  font-size: 32px;
}

p {
  margin: 0.5em 0;

  &:not(:has(span)) {
    text-indent: 1em;
  }

  &:is(.img) {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

p>code {
  border-radius: 0.2em;
  border-width: 0.15em;
  border-style: solid;
  border-color: var(--color-code);
  background-color: var(--color-code);
}

pre:has(code) {
  border-radius: 0.2em;
  border-width: 0.15em;
  border-style: solid;
  padding: 0.5em;
  margin: 0.5em 0;
  border-color: var(--color-code);
  background-color: var(--color-code);
}

a {
  position: relative;
  text-decoration: none;
  color: var(--link);
  background-image: linear-gradient(var(--link-hover-background), var(--link-hover-background));
  background-position: 50% 100%;
  background-repeat: no-repeat;
  background-size: 100% 40%;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  -o-transition: all 0.3s ease-in-out;
  -ms-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
}

a:hover,
a:focus {
  color: var(--link-hover);
  background-size: 100% 100%;
}

a:has(img),
a.h3 {
  background-image: unset;
}

img {
  display: inline;
  max-width: 100%;
  height: auto;
}

li {
  list-style-image: url(/main/images/heartgreen.gif);
  line-height: 1.5;
  padding: 1px 0px 1px 5px;
  margin: 0;
}

li:nth-child(even) {
  list-style-image: url(/main/images/heartpurple.gif);
}

ul {
  padding: 0 0 0 9px;
  margin: 0 0 0 0px;
}

fieldset {
  clear: both;
  border: var(--fieldset-border);
  margin-bottom: 1em;
  padding: 10px;
}

blockquote {
  border-left: 10px solid var(--link-hover-background);
  margin: 0em 10px;
  padding: 0.5em 10px;
  quotes: "\201C" "\201D" "\2018" "\2019";
}

h2 {
  font-family: nineteen93, maru;
  font-weight: normal;
  font-size: 18px;
  line-height: 2em;
  color: var(--h2-color);
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

article > h2 {
  padding: 2px 10px;
  margin: 4px 0;
  text-align: right;
  background-color: var(--h2-background);
}

summary {
  cursor: pointer;
  display: flex;
  align-items: center;

  &::before {
    content: '';
    width: 9px;
    height: 10px;
    background: url('/resources/images/plus.png') no-repeat;
    filter: invert(1);
    margin-right: 5px;
  }

  &:has(h2) {
    display: flex;
    justify-content: space-between;
    background-color: var(--h2-background);
    padding: 2px 10px;
    margin: 4px 0;
  }
}

details[open]>summary::before {
  background: url('/resources/images/min.png') no-repeat;
}

summary::-webkit-details-marker {
  display: none;
}

summary:has(.h2) {
  justify-content: flex-end;
}

summary:has(.h2)::before {
  margin-right: 6px;
}

summary:has(.h3)::before {
  margin-right: 4px;
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--background-dark);
  }

  body,
  h3,
  .h3,
  h1 {
    color: var(--text-dark);
  }

  a {
    position: relative;
    text-decoration: none;
    color: var(--link-dark);
    background-image: linear-gradient(var(--link-hover-background-dark), var(--link-hover-background-dark));
  }

  blockquote {
    border-left: 10px solid var(--link-hover-background-dark);
  }

  summary:is(.h3)::before {
    filter: invert(0);
  }

  summary:is(.h2)::before {
    filter: invert(1);
  }
}