@use '_root.scss';
@use '_vars.scss' as *;

@use '_node.scss';

// Variables //

:root {
  --base: 198deg;
  --light: var(--arc-background-simple-color, hsl(var(--base), 88%, 33%));
  --lighter: hsl(var(--base), 22%, 84%);
  --warn: #b45c5c;
  --border: lightgrey;
  --fg2: #3b4044;
  color-scheme: light dark;

  @media (prefers-color-scheme: dark) {
    --light: var(--arc-background-simple-color, hsl(var(--base), 81%, 40%));
    --border: #363636;
    --fg2: #f0f0f0;
    --bg2: darkslategray;
  }
}

.lighter {
  color: var(--light) !important;
}

// setting this and the same in body is similar to 100vh
// but it works on mobile browsers as well
// could also do 100dvh but low support
html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: $fontFamily, serif;
  font-size: 1.2rem;
  min-height: 100%;
  margin: 0;
  padding: 75px 20px;
  background: #fff8f5;
  color: #101010;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-wrap: break-word;
  box-sizing: border-box;
  flex-direction: column;
  position: relative;

  & > * {
    width: min(600px, 100%);
  }
}

p {
  margin-block: $mb1;
}

// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/Heading_Elements#specifying_a_uniform_font_size_for_h1
h1 {
  font-size: 1.5em;
  margin-block: 0.83em;
}

// used for rss icons
h1,
h2 {
  > a > img {
    padding-left: 5px;
    margin-bottom: -2px;
    width: initial;
  }
}

// Links //

a {
  color: inherit;
  text-decoration-color: var(--light);
  text-decoration-thickness: 2px;
  transition: color 0.3s;

  &[href*="//"]:not([href*="boehs.org"]) {
    --light: var(--warn);
  }

  &:hover {
    color: var(--light);
  }

  &:active {
    color: #ff9e9e;
  }
}

.e-content a[href*="//"]:not([href*="boehs.org"]) {
  &:after {
    content: "";
    display: inline-block;
    vertical-align: middle;
    width: .9em;
    height: .9em;
    margin: 0 0.2em;
    margin-bottom: 3px;
    border-radius: $radius;
    background-size: contain;
    background-image: var(--url);
  }

  &:not(:hover):after {
    filter: grayscale(60%);
  }
}

// Cards //

.card {
  color: inherit;
  text-decoration: inherit;
  border-left: 2px solid var(--light);
  padding-left: $p2;
  display: block;

  > p {
    margin-block: .25em;
  }

  &:not(.contain .card) {
    margin-block: $mb1;
  }
}

.contain {
  display: grid;
  grid-template-rows: masonry;
  gap: $p2;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  list-style-type: none;
  padding-inline: 0;

  .card {
    :first-child {
      margin-top: 0;
    }

    :last-child {
      margin-bottom: 0;
    }
  }
}

// in post lists, the list shouldn't have numbers
.h-feed > ol {
  list-style-type: none;
  padding-inline: 0;
}

// Structure //

// (lists)
ul {
  list-style: georgian;
}

li,
figcaption {
  > p {
    margin-block: 0;
  }
}

hr {
  border: none;
  text-align: center;

  &::after {
    content: "✴✴✴";
  }
}

// kv == key-value
nav > dl,
.kv {
  font-feature-settings: "onum";
  display: grid;
  grid-template-columns: auto max-content;
  gap: 5px;

  & > dd {
    margin-left: auto;
  }

  * {
    margin-block: 0;
  }

  ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0px 15px;
    padding-inline: 0;
  }
}

.h-card > :not(.p-name) {
  display: none;
}

header {
  view-transition-name: head;

  > * {
    display: block;
    text-align: center;
    font-size: 1.25rem;
  }

  > span a {
    text-decoration: inherit;
  }
}

#is {
  cursor: pointer;
}

footer {
  flex-wrap: wrap;
  display: flex;
  justify-content: center;

  pre {
    font-weight: bold;
    margin: 0;
    font-size: 1.1rem;
  }

  view-transition-name: footer;
}

article,
nav,
header {
  line-height: 1.6;
}

main {
  view-transition-name: main;
}

// Labeling and such //

legend,
dt,
label {
  font-weight: bold;
}

.pagination {
  border-radius: $radius;
  border: 2px solid var(--border);
  padding: $p1 $p2;
  view-transition-name: pagination;

  @media screen and (max-width: $mobile) {
    ul {
      justify-content: space-between;
    }
  }
}

// (Media Queries)

@media screen and (max-width: $mobile) {
  footer {
    pre {
      display: none;
    }
  }

  footer > nav > dl,
  .kv {
    display: block;
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media (prefers-color-scheme: dark) {

  // will switch to light-dark when it reaches 90%
  body {
    background: #282828;
    color: whitesmoke;
  }

  :not(pre) > code,
  blockquote {
    background: var(--bg2);
  }
}

@media (prefers-color-scheme: light) {

  // Optimizes codeblocks for light mode
  :not(footer) > pre {
    filter: brightness(1.1) contrast(1.2);
    background: #313131 !important;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes slide-from {
  from {
    transform: translateX(var(--from));
  }
}

@keyframes slide-to {
  to {
    transform: translateX(var(--to));
  }
}

/* 'Forward' transitions */
::view-transition-old(main) {
  --to: -30px;
  animation:
    90ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
    300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to;
}

::view-transition-new(main) {
  --from: 30px;
  animation:
    210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
    300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from;
}

/* Overrides for 'back' transitions */
.back-transition::view-transition-old(main) {
  --to: 30px;
  animation-name: fade-out, slide-to;
}

.back-transition::view-transition-new(main) {
  --from: -30px;
  animation-name: fade-in, slide-from;
}

.tree {
  position: absolute;
  pointer-events: none;
  top: 0;
  opacity: 0.7;
}
