/* ==========================================================================
   CSS CUSTOM PROPERTIES
   ========================================================================== */

:root {
  --color-primary: #21a179;
  --color-content: #ffffff;
  --color-background: #1e1e24;
  --color-links: #8093f1;
  --color-visited: #ef476f;
  --color-inactive: #81ae9d;
  --size-step-0: clamp(1rem, calc(0.96rem + 0.22vw), 1.13rem);
  --size-step-1: clamp(1.25rem, calc(1.16rem + 0.43vw), 1.5rem);
  --size-step-2: clamp(1.56rem, calc(1.41rem + 0.76vw), 2rem);
  --size-step-3: clamp(1.95rem, calc(1.71rem + 1.24vw), 2.66rem);
  --size-step-4: clamp(2.44rem, calc(2.05rem + 1.93vw), 3.55rem);
}

/* ==========================================================================
   FONT DECLARATIONS
   ========================================================================== */

@font-face {
  font-family: "Berkeley Mono";
  src: url("https://json.blog/uploads/2024/berkeleymono-regular.woff2")
    format("woff2");
}

/* ==========================================================================
   UNIVERSAL STYLES & RESET
   ========================================================================== */

* {
  font-family: "Berkeley Mono", sans-serif;
  font-feature-settings: "tnum", "frac";
}

html:focus-within {
  scroll-behavior: smooth;
}

/* ==========================================================================
   BASE ELEMENT STYLES
   ========================================================================== */

body {
  background-color: var(--color-background);
  text-rendering: optimizeLegibility;
  margin: 40px;
  text-wrap: pretty;
}

/* Typography Hierarchy */
h1,
h1 > a {
  font-size: var(--size-step-4);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--size-step-1);
}

h1 > a,
h1 > a:visited,
h2 > a,
h2 > a:visited {
  color: var(--color-primary);
  text-decoration: none;
}

h2 {
  font-size: var(--size-step-3);
  font-weight: 400;
  color: var(--color-background);
  background-color: var(--color-primary);
  margin: auto;
}

h3 {
  font-size: var(--size-step-2);
  font-weight: 400;
  background-color: var(--color-links);
  color: var(--color-background);
  margin: auto;
}

h4 {
  font-size: var(--size-step-1);
  font-weight: 700;
  color: var(--color-primary);
  margin: auto;
}

/* Typography spacing */
h1 + h2 {
  margin-top: var(--size-step-2);
}

h2 + h3 {
  margin-top: var(--size-step-0);
}

h3 + h4 {
  margin-top: var(--size-step-0);
}

h4 + p {
  margin-top: var(--size-step-0);
}

/* Text Elements */
p,
ul,
ol {
  font-size: var(--size-step-0);
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-content);
  letter-spacing: 0.01rem;
  margin-bottom: --var(--size-step-0);
}

blockquote {
  font-style: italic;
  color: var(--color-content);
  font-size: var(--size-step-0);
  padding-left: var(--size-step-0);
  border-left: 2px solid var(--color-links);
  margin: var(--size-step-0);
  text-wrap: balance;
}

/* Links */
a {
  color: var(--color-links);
  font-weight: 400;
}

a:hover,
a:visited {
  color: var(--color-visited);
}

time > a {
  color: var(--color-inactive);
}

/* Code Elements */
pre {
  color: var(--color-content);
}

pre,
code,
code > span {
  font-family: "Berkeley Mono", monospace;
  font-size: var(--size-step-0);
  min-width: 0;
  background: #282a36;
}

pre,
code {
  white-space: pre-wrap !important;
}

/* Horizontal Rules */
hr {
  width: 100%;
  border: 0;
  height: 2px;
  color: var(--color-primary);
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ==========================================================================
   MEDIA ELEMENTS
   ========================================================================== */

img {
  max-width: 100%;
  height: auto;
}

video {
  max-width: 100%;
  height: auto;
}

figure {
  position: relative;
  background-color: rgba(0, 0, 0, 0.22);
  display: inline-block;
}

figure img {
  max-width: 100%;
  margin: auto;
  display: block;
}

figcaption {
  background-color: rgba(0, 0, 0, 0.4);
  padding: 5px 10px 5px 10px;
  position: absolute;
  bottom: 0px;
  left: 0px;
  color: white;
  text-align: left;
}

/* ==========================================================================
   TABLES
   ========================================================================== */

table {
  color: var(--color-content);
  font-variant-numeric: tabular-nums;
  border-spacing: 0;
  width: 100%;
}

th {
  border-bottom: 2px solid #ccc;
  border-collapse: collapse;
  font-weight: 700;
  text-align: left;
}



/* ==========================================================================
   LAYOUT COMPONENTS
   ========================================================================== */

main,
.content {
  max-width: 80ch;
  margin: 0 auto;
}

nav {
  max-width: 80ch;
  margin: 0 auto;
}

nav > ul {
  letter-spacing: 1px;
  list-style: none;
}

nav > ul > li {
  display: inline-block;
  margin: 0.25rem;
}

nav a {
  font-weight: 400;
}

footer {
  max-width: 80ch;
  margin: 0 auto;
}

footer > ul {
  letter-spacing: 1px;
  list-style: none;
  padding: 0;
  margin: 0;
}

footer > ul > li {
  display: inline-block;
}

footer > ul > li:before {
  content: "/";
}

footer a {
  font-weight: 400;
}

footer img {
  display: block;
  margin: auto;
}

/* ==========================================================================
   UI COMPONENTS
   ========================================================================== */

/* Date Header */
.dateheader {
  font-size: var(--size-step-1);
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  justify-content: center;
}

.dateheader::before {
  content: "░░░║";
}

.dateheader::after {
  content: "║░░░";
}

/* Date Elements */
.date {
  color: var(--color-primary);
}

.date:has(+ .post-title) {
  margin-top: var(--size-step-4);
}

.title-area .date {
  font-size: var(--size-step-0);
  font-weight: 400;
  color: var(--color-primary);
  margin-bottom: 0px;
  margin-left: -12rem;
  position: absolute;
  width: 150px;
  display: block;
  padding-left: 0.5rem;
  text-align: right;
}

.post-item .date {
  min-width: 100px;
}

/* Post Components */
.post-item {
  list-style-type: none;
  clear: both;
  padding-top: 5px;
  padding-bottom: 5px;
  display: flex;
}

.post-list .post-item:first-child {
  margin-top: var(--size-step-0);
}

.post-list + h2 {
  margin-top: var(--size-step-2);
}

.post-list + h3 {
  margin-top: var(--size-step-0);
}

.single-post-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

/* Title Bar Components */
.title-bar {
  color: var(--color-primary);
  text-decoration: none;
  margin-top: var(--size-step-4);
  text-align: center;
}

.title-bar nav {
  color: var(--color-primary);
}

.title-bar a {
  color: var(--color-primary);
  text-decoration: none;
}

.site-title {
  color: var(--color-primary);
  font-size: var(--size-step-2);
}

.site-title a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 200;
}

/* Time Components */
.day {
  margin-top: var(--size-step-1);
}

.year {
  margin-top: var(--size-step-0);
}

.month {
  margin-top: var(--size-step-0);
  margin-bottom: var(--size-step-0);
}

/* Gallery and Grid Components */
.img-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-gap: 10px;
  align-items: center;
}

.bookshelf {
  display: grid;
  grid-column-gap: 10px;
  grid-row-gap: 10px;
  grid-template-columns: 25% 25% 25% 25%;
}

.bookshelf figure {
  min-height: 100px;
  min-width: 100px;
}

.bookshelf-book-cover {
  border-radius: 5px;
  max-width: 100%;
  height: auto;
}

.bookshelf figcaption {
  height: 100%;
  width: 100%;
  opacity: 0;
  backface-visibility: hidden;
  transform-origin: 0 0;
  transform: rotateY(-90deg);
  transition: transform 0.4s, opacity 0.1s 0.3s;
  background-color: rgba(0, 0, 0, 0.75);
  text-align: center;
}

.bookshelf figure:hover figcaption {
  opacity: 1;
  transform: rotateY(0deg);
  transition: transform 0.4s, opacity 0.1s;
}

/* Lightbox (from http://codepen.io/gschier/pen/HCoqh) */
.lightbox {
  display: none;
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 100%;
  text-align: center;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.8);
}

.lightbox img {
  max-height: 95vh;
  margin-top: 2%;
}

.lightbox:target {
  outline: none;
  display: block;
}

/* Pagination */
.paginator {
  display: flex;
  justify-content: space-between;
  width: 60vw;
  max-width: 80ch;
  margin-bottom: 2em;
  margin: 2em auto;
}

.paginator > .previous {
  text-align: left;
}

.paginator > .next {
  text-align: right;
}

.photos-grid-container {
  width: 60vw;
  padding-left: 20vw;
  margin-left: 2rem;
  margin-right: 2rem;
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.h-card {
  display: none;
}

.twitter-tweet {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

.microblog_narration_button {
  color: var(--color-content);
}

/* Third-party Components */
.bigfoot-footnote__content p {
  color: black;
}

button.bigfoot-footnote__button::after {
  color: white;
}

/* Article Spacing */
article + article {
  margin-top: 2em;
}

/* ==========================================================================
   MEDIA QUERIES
   ========================================================================== */

@media only screen and (max-width: 1000px) {
  /* Layout Adjustments */
  .h-feed {
    width: 100%;
    margin: 0 auto;
  }
  
  article {
    width: 95%;
    max-width: 80ch;
    margin: initial;
  }
  
  main {
    background-color: var(--color-background);
  }
  
  footer {
    width: 95%;
  }

  /* Title Area Responsive */
  .title-area {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-direction: column;
  }

  .title-area .date {
    padding: initial;
    width: initial;
    margin: initial;
    position: initial;
    display: flex;
  }

  /* Typography Adjustments */
  p,
  ul,
  ol {
    font-size: var(--size-step-0);
    font-weight: 300;
    line-height: 1.5;
    color: var(--color-content);
    letter-spacing: initial;
  }
  
  time,
  h1 {
    margin-top: var(--size-step-0);
    margin-bottom: var(--size-step-0);
  }

  /* Component Responsive Adjustments */
  .bookshelf {
    display: grid;
    grid-template-columns: 90%;
    justify-content: center;
    grid-row-gap: 10px;
    grid-column-gap: 0px;
    padding-left: initial;
  }
  
  .photos-grid-container {
    padding-left: initial;
  }

  /* Date Header Mobile */
  .dateheader::before {
    content: "░║";
  }
  
  .dateheader::after {
    content: "║░";
  }
}
