/* ** Reset from https://www.joshwcomeau.com/css/custom-css-reset/ */
/* 1. Use a more-intuitive box-sizing model */
*, *::before, *::after { box-sizing: border-box; }
/* 2. Remove default margin */
*:not(dialog) { margin: 0; }
/* 3. Enable keyword animations */
@media (prefers-reduced-motion: no-preference) { html { interpolate-size: allow-keywords; } }
/* 4. Add accessible line-height */
body { line-height: 1.5; }
/* 5. Improve text rendering (only for high dpi...?) */
/*body { -webkit-font-smoothing: antialiased; }*/
/* 6. Improve media defaults */
img, picture, video, canvas, svg { display: block; max-width: 100%; }
/* 7. Inherit fonts for form controls */
input, button, textarea, select { font: inherit; }
/* 8. Avoid text overflows */
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
/* 9. Improve line wrapping */
p { text-wrap: pretty; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; }
/* 10. Create a root stacking context */
#root, #__next { isolation: isolate; }

/* my own stuff */
html { overscroll-behavior-y: none; scrollbar-gutter: stable; background: #FBFBFB; }
p, ul { margin-bottom: 1.5rem; &:last-child { margin-bottom: 0; } }
iframe { border: none; display: block; }

/* https://chrisnager.github.io/ungrid is convenient */
@media (min-width: 30em) {
  .row { width: 100%; display: table; table-layout: fixed; border-spacing: 10px 0; }
  .col { display: table-cell; }
}

@font-face {
  font-family: Libron;
  src: url(/fonts/Libron-Regular.woff2);
}

@font-face {
  font-family: Libron;
  src: url(/fonts/Libron-Italic.woff2);
  font-style: italic;
}

@font-face {
  font-family: Libron;
  src: url(/fonts/Libron-Bold.woff2);
  font-weight: bold;
}

@font-face {
  font-family: Libron;
  src: url(/fonts/Libron-BoldItalic.woff2);
  font-style: italic;
  font-weight: bold;
}

@font-face {
  font-family: IosevkaTerm;
  src: url(/fonts/iosevka-regular.woff2);
}

:root {
  --yellow: #FFEB3B;

  --font-body: Libron, sans-serif;
  --font-mono: IosevkaTerm, monospace;
}

/*@view-transition { navigation: auto; }*/

body {
  max-width: 720px;
  padding: 0 1rem;
  margin: 0 auto;
  font-family: var(--font-body);
  font-size: 1.2rem;
  line-height: 1.5;
  background: #FBFBFB;

  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a {
  color: #444;
  &:hover { color: #666; }
  &.link-missing {
    color: #944;
    &:hover { color: #966; }
  }
}

@keyframes color-shift {
  from { color: #FFEB3B; }
  25% { color: #FFEC3B; }
  70% { color: #E3FF85; }
  to { color: #FFEB3B; }
}

header {
  display: flex;
  /*flex-direction: column;*/
  align-items: baseline;
  margin-top: 10px;
  isolation: isolate; /* keeps z-index:-1 drop shadows above body's background */

  @media (max-width: 980px) {
    flex-direction: column;
    align-items: center;
    nav { margin-left: 0; }
  }

  a {
    text-decoration: none;
  }

  h1 {
    margin-bottom: 0;
    margin-top: 0;
    text-transform: lowercase;
    font-size: 3rem;
    font-family: Arial Rounded MT Bold, Arial, sans-serif;
    font-weight: 800;
    letter-spacing: -2px;
    -webkit-text-stroke: 3px black;
    paint-order: stroke fill;
    position: relative;

    color: #FFEB3B;
    animation-duration: 30s;
    animation-iteration-count: 1;
    animation-name: color-shift;

    &::after {
      content: 'magicalhack';
      text-transform: lowercase;
      position: absolute;
      left: 4px;
      top: 4px;
      z-index: -1;
      background-color: black;
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-text-fill-color: black;
      -webkit-text-stroke: 1px black;
      paint-order: stroke fill;
    }
  }
  p { margin: 0; }
  nav {
    margin-left: 26px;
    color: #AAA;

    a {
      color: black;
      background: white;
      padding: 4px 8px;
      border-radius: 3px;
      border: 1px solid black;
      font-size: 0.8rem;
      position: relative;

      &:hover {
        background: #FFEB3B;
        color: #333;
      }

      &::after {
        position: absolute;
        box-sizing: content-box;
        content: ' ';
        left: 1px;
        top: 1px;
        z-index: -1;
        background-color: black;
        border-radius: 3px;
        border: 1px solid black;
        width: 100%;
        height: 100%;
      }
    }
    p {
      margin-bottom: 0;
    }
  }
}

main {
  padding: 2rem 2px;
  margin-bottom: 5rem;
  isolation: isolate; /* keeps z-index:-1 drop shadows above body's background */

  > .title {
    margin: 0;
    margin-bottom: 1.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .post-date {
      font-family: var(--font-mono);
      flex-shrink: 0;
      font-size: 0.9rem;
    }
  }

  p {
    margin-top: 0;
  }

  h1 { margin-bottom: 1rem; }
  .post-title {
    @media (max-width: 980px) {
      flex-direction: column;
      align-items: start;
    }

    h1 { margin-bottom: 0; }
    div.reading-time {
      flex-shrink: 0;
      font-family: var(--font-mono);
      background: white;
      padding: 10px 20px;
      border-radius: 3px;
      border: 1px solid black;
      font-size: 0.8rem;
      position: relative;

      &::after {
        position: absolute;
        box-sizing: content-box;
        content: ' ';
        left: 1px;
        top: 1px;
        z-index: -1;
        background-color: black;
        border-radius: 3px;
        border: 1px solid black;
        width: 100%;
        height: 100%;
      }
    }
  }
  .page-title {
    h1 { margin-bottom: 0; }
  }
  h2 { margin-top: 4rem; margin-bottom: 0.8rem; }
  h3 { margin-top: 3rem; margin-bottom: 0.75rem; }

  article {
    ul, ol {
      margin-bottom: 2rem;
      li {
        margin-bottom: 0.5rem;
      }
    }
    img { margin: 2rem 0; }
    .center {
      display: flex; justify-content: center;
      img { margin-top: 0; }
    }

    .card {
      margin-bottom: 2rem;
      img:first-child { margin-top: 0; margin-bottom: 1rem; }
      p:last-child { margin-bottom: 0; }
    }
  }

  .post-footer {
    display: flex;
    justify-content: center;
    margin-top: 5rem;
    font-size: .9rem;
    color: black;
    text-align: center;
    span.label { color: #999; }

    .post-footer-inner {
      background: white;
      padding: 16px 20px;
      border-radius: 3px;
      border: 1px solid black;
      font-size: 0.8rem;
      position: relative;

      .draft {
        font-size: 1.25rem;
        font-weight: bold;
      }

      &::after {
        position: absolute;
        box-sizing: content-box;
        content: ' ';
        left: 1px;
        top: 1px;
        z-index: -1;
        background-color: black;
        border-radius: 3px;
        border: 1px solid black;
        width: 100%;
        height: 100%;
      }
    }
  }

  pre {
    padding: 14px 18px;
    font-size: 0.95rem;

    background: white;
    border: 1px solid black;
    border-radius: 3px;
    position: relative;
    margin-right: 2px;
    margin-bottom: 1.5rem;

    &::after {
      position: absolute;
      box-sizing: content-box;
      content: ' ';
      left: 1px;
      top: 1px;
      z-index: -1;
      background-color: black;
      border-radius: 3px;
      border: 1px solid black;
      width: 100%;
      height: 100%;
    }

    code {
      font-family: var(--font-mono);
    }
  }

  .shadow-header {
    font-family: Arial Rounded MT Bold, Arial, sans-serif;
    font-weight: 800;
    letter-spacing: -1px;
    color: #FFEB3B;
    text-transform: lowercase;
    -webkit-text-stroke: 2px black;
    paint-order: stroke fill;
    position: relative;
    text-decoration: none;
    isolation: isolate;

    &::after {
      content: attr(data-shadow);
      text-transform: lowercase;
      position: absolute;
      left: 2px;
      top: 2px;
      z-index: -1;
      background-color: black;
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-text-fill-color: black;
      -webkit-text-stroke: 1px black;
      paint-order: stroke fill;
    }
  }

  mark {
    background-color: #FFEB3B;
  }

  blockquote {
    border-left: 4px solid #E4D233;
    padding: 1.25rem 1.5rem;
    background: #F2F2F2;
  }

  table {
    width: 100%;

    tr {
      border-bottom: 1px solid #EEE;
      th, td {
        padding: 0.5rem 0.25rem;
      }
      th {
        font-family: var(--font-mono);
        text-align: left;
        vertical-align: top;
        padding-right: 1rem;
        padding-left: 0;
        color: #444;
      }
      td {
      }
    }
  }
}

/* auto-collapse to 1-up on narrow viewports */
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 4rem;
  &:has(+ p) { margin-bottom: 2rem; }
  .card { margin-bottom: 0; }
}
.grid[style*="--cols"] {
  grid-template-columns: repeat(auto-fit,
    minmax(max(180px, (100% - (var(--cols) - 1) * 1rem) / var(--cols)), 1fr));
}
.grid > * { margin-top: 0; }


.card {
  background: white;
  border: 1px solid black;
  border-radius: 3px;
  position: relative;
  padding: 1.7rem 2rem;
  flex: 1;
  font-size: 1rem;
  margin-right: 2px;

  &::after {
    position: absolute;
    box-sizing: content-box;
    content: ' ';
    left: 1px;
    top: 1px;
    z-index: -1;
    background-color: black;
    border-radius: 3px;
    border: 1px solid black;
    width: 100%;
    height: 100%;
  }
}

a.card {
  color: inherit;
  text-decoration: none;
  &:hover {
    color: inherit;
    background: #FDFDFD;
    &::after {
      background-color: #FFEB3B;
    }
  }
}

.muted { color: #999 !important; }

ul#post-list {
  padding: unset;
  margin: unset;
  margin-bottom: 1.5rem;
  margin-top: 1rem;

  > li {
    list-style: none;
    column-gap: .375em;
    margin: 0;
    margin-bottom: 0.5rem;
    border: 1px solid black;
    border-radius: 3px;
    background: white;
    position: relative;

    &::after {
      position: absolute;
      content: ' ';
      box-sizing: content-box;
      left: 1px;
      top: 1px;
      z-index: -1;
      background-color: black;
      border-radius: 3px;
      border: 1px solid black;
      width: 100%;
      height: 100%;
    }

    a {
      color: black;
      text-decoration: none;
      font-size: 1.4rem;
      padding: 1rem 1.2rem;
      display: flex;
      justify-content: space-between;
      align-items: baseline;
    }
    .post-date {
      white-space: nowrap;
      font-family: var(--font-mono);
      margin-left: 16px;
      color: #666;
      font-size: 0.9rem;
    }
  }
}

#note-type {
  background: white;
  border: 1px solid black;
  border-radius: 3px;
  position: relative;

  &::after {
    position: absolute;
    box-sizing: content-box;
    content: ' ';
    left: 1px;
    top: 1px;
    z-index: -1;
    background-color: black;
    border-radius: 3px;
    border: 1px solid black;
    width: 100%;
    height: 100%;
  }

  #note-inner {
    padding: 2rem 2rem;

    @media (max-width: 980px) {
      /*padding: 1.2rem 1.4rem;*/
      padding: 1.25rem 1.4rem;
    }
  }
}


footer {
  color: #AAA;
  text-align: center;
  margin-top: auto;
  padding: 6px 0;
  font-size: 0.8rem;

  a {
    color: #999;
    &:hover { color: #BBB; }
  }
}

/* view transitions: hard cut, no motion */
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: 1ms;
  animation-timing-function: steps(1, end);
  mix-blend-mode: normal;
}
::view-transition-old(*) { opacity: 0; }
::view-transition-new(*) { opacity: 1; }
