/* Import CSS reset and base styles */
@import "resets.css";

:root {
  --brand-color: 352;
  --font-text: effra, -apple-system, BlinkMacSystemFont, “Roboto”, “Droid Sans”, Helvetica, Arial, sans-serif;
  --font-alt: ff-typestar-ocr-web-pro, sans-serif;
  --font-display: "ITC Clearface Bold", Georgia, serif;
  --base: 1.25rem; /* 20px */
  --line-height: calc( 4 / 3 );
  --lh: calc(var(--base) * var(--line-height));
  --teeny: .6em;
  --smallest: .7em;
  --smaller: .85em;
  --larger: 1.4em;
  --largest: 2.4em;
  --lightness: 0%;
  --bg-color: hsl(0 0% calc(100% - var(--lightness)));
  --bg-accent: hsl(42 100% 96%);
  --text-color: hsl(0 0% var(--lightness) / 0.85);
  --lighter: hsl(0 0% var(--lightness) / 0.75);
  --lightest: hsl(0 0% var(--lightness) / 0.55);
  --darker: hsl(0 0% var(--lightness) / 1.0);
  --faint: hsl(0 0% var(--lightness) / 0.10);
  --faintest: hsl(0 0% var(--lightness) / 0.02);
  --ql: calc(var(--lh) / 4);
  --hl: calc(var(--lh) / 2);
  --dl: calc(var(--lh) * 2);
  --link-color: hsl(var(--brand-color), 72%, 54%);
  --link-accent: hsl(306 26% 85%);
  --grid-unit: 80px;
  --grid-gap: 24px;
}

html {
  font-size: var(--base);
  line-height: var(--line-height);
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: var(--font-text);
  color: var(--text-color);
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

header {
  background: var(--faintest);
}

header li, footer li {
  list-style: none;
}

header, footer, .content, .outer {
  padding: var(--lh) var(--grid-gap);
}

main footer {
  padding-top: 0;
}

header p a {
  text-decoration: underline;
}

#site-main {
  padding-top: 0;
}
.content a { color: var(--link-color); }

h1, h2, h3, strong {
  color: var(--darker);
  font-weight: 500;
}

h1, h2 {
  font-size: var(--larger);
  margin: var(--hl) 0;
  font-weight: normal;
  line-height: calc( 4 / 3 );
}

header h1 {
  font-size: var(--largest);
  line-height: 1.125;
  margin: var(--hl) 0 var(--ql);
  font-family: var(--font-display);
  font-weight: bold;
  letter-spacing: -0.02em;
}

h5 {
  font-weight: normal;
}

h5, time, .tag, .tags a, .button, button {
  font-size: var(--smallest);
  font-family: var(--font-alt);
  text-transform: uppercase;
  word-spacing: -0.15em;
}

h4 {
  margin-bottom: var(--ql);
}

h5, time {
  color: var(--lightest);
}

h5 time {
  font-size: 1em;
}

h5 time::before {
  content: " | ";
  color: var(--faint);
}

.article-excerpt {
  font-size: var(--smaller);
  color: var(--lightest);
  margin-top: var(--lh);
  line-height: 1.5;
}

main > header, article > header {
  text-align: center;
}

.article-header h4 {
  margin: var(--ql) 0 calc(var(--ql) * -1);
}

.article-header .article-image {
  margin: var(--lh) calc(var(--grid-gap) * -1);
  position: relative;
  border-radius: 2px;
}

.article-header .article-image img {
  display: block;
  width: 100%;
}

figcaption {
  font-size: var(--teeny);
  color: var(--lightest);
  text-align: right;
  padding: var(--ql);
  font-family: var(--font-alt);
  width: 100%;
  /* background: var(--faintest); */
}

figcaption a {
  text-decoration: underline;
}

.article-content h2 {
  margin-top: var(--dl);
}

.article-content h3 {
  margin: var(--lh) 0 0;
}

.article-content, .post-list {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.article-content > *, .post-list > * {
  width: 100%;
  max-width: 29rem;
}

.article-content p, .article-content ul, .article-content ol, .article-content blockquote, .article-content > iframe{
  margin-bottom: var(--lh);
}

.article-content p {
  hyphens: auto;
}

.article-content p a{
  color: var(--link-color);
  hyphens: none; /* don't hyphenate links */
}

.article-content li {
  padding-left: 0.5em;
  margin: var(--ql) 1.1em;
}

.article-content div + p {
  margin-top: var(--lh);
}

.article-content > *:last-child {
  margin-bottom: 0;
}

hr {
  border: none;
  height: 2px;
  background: var(--faint);
  margin: var(--hl) auto;
  width: 10vw;
}

hr + h2 {
  margin-top: var(--hl);
}

.article-content blockquote {
  padding-left: calc(var(--hl) + 5px);
  border-left: 2px solid var(--link-color);
  color: var(--lighter);
}

.article-content figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: var(--hl) 0;
  border-radius: 2px;
}

.article-content figure img {
  margin-bottom: 0;
  display: block;
}

.article-content iframe {
  max-width: 100%;
  margin-bottom: var(--lh);
}

.article-content .cards {
  margin-left: calc(var(--grid-gap) * -1);
  margin-right: calc(var(--grid-gap) * -1);
}

a:hover, button:hover { opacity: 0.8; }

.tags {
  margin: var(--lh) 0;
  line-height: 1.75;
}

.tags, footer nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em;
}

.tags a, .button, button {
  border: 2px solid var(--link-color);
  border-radius: 2px;
  white-space: nowrap; /* prevent word break */
  cursor: pointer;
  display: inline-block;
  padding: 0 0.4em;
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  color: var(--link-color);
}

.tags a:hover, .tags a.active-tag {
  opacity: 1.0;
}

a.light {
  border-color: var(--faint);
  background: transparent !important; 
  color: var(--lightest) !important;
}

/* Article Navigation */

.article-nav {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding-top: var(--lh);
  font-size: var(--smaller);
}

.article-nav a {
  color: var(--link-color);
  display: block;
  max-width: 45vw;
}

.next-post {
  text-align: right;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-gap: var(--grid-gap);
  position: relative;
}

.cards .card a {
  background: var(--faintest);
  display: block;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
  min-height: calc(var(--lh) * 6);
}

/* .card a {
  background: var(--faintest);
  display: block;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
  min-height: calc(var(--lh) * 6);
} */

.card img, .card .cta-content{
  object-fit: cover;
  aspect-ratio: 3 / 2;
  width: 100%;
  display: block;
  margin-bottom: 0;
}

.card .cta-content {
  position: absolute;
}

.card-content {
  font-size: var(--smaller);
  padding: calc(var(--grid-gap) * .75);
  line-height: 1.333;
  margin: auto;
  width: 100%;
}

.card-content h3, .card-content p {
  font-weight: normal;
  letter-spacing: 0.01em;
}

.card-content p {
  color: var(--lightest);
  margin-bottom: 0;
}

.card-content time {
  font-size: var(--smallest);
}

#sunday-content .cards {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Memberships */

#plans {
}

#plans .card {
  background: rbg(254,251,232);
  border: 1px solid var(--faint);
  padding: var(--grid-gap);
  margin-bottom: var(--hl);
}

#plans .card-content {
}

#plans article a {
  display: block;
}

#plans article h2 {
  margin: 0;
}

#plans + p {
  color: var(--lighter);
  font-size: var(--smaller);
  text-align: center;
}

#membership-updates {
  padding-bottom: var(--dl);
  /* border-top: 3px solid var(--link-color); */
}

#membership-updates article {
  position: relative;
  margin: var(--lh) 0 calc(var(--lh) * 1.5);
}

#membership-updates.article-content {
  display: block;
}

#membership-updates .article-image {
  margin-bottom: var(--lh);
}

.membership-card {
  background: var(--bg-accent);
  padding: var(--hl);
  margin-top: var(--lh);
}

.membership-card h2 {
  margin-top: 0;
  line-height: 1.2;
  font-size: var(--base);
}

.membership-card + p {
  font-size: var(--smaller);
  text-align: center;
  margin-top: var(--ql);
}

.membership-card + p a {
  color: var(--link-color);
}

.membership-card li a {
  border-bottom: 1px solid var(--lighter);
}

p.membership-description {
  margin: 0 -12px var(--ql);
}

.membership-locked {
  text-align: center;
  background: var(--faintest);
  padding: var(--lh) var(--lh) var(--dl);
  margin-bottom: var(--hl);
  /* border: 1px dotted var(--faint); */
}

.membership-locked a {
  margin-top: var(--ql);
}

.blurred{
  filter: blur(6px);
}

/* Sunday Letter Signup */

.cta-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: var(--lh) var(--grid-gap) calc(var(--lh) * 1.25);
  background: var(--bg-accent);
  border-radius: 2px;
  margin-right: calc(var(--grid-gap) * -1);
  margin-left: calc(var(--grid-gap) * -1);
  color: var(--lighter);
}

.cta-content > p {
  font-size: var(--smaller);
  width: 100%;
  max-width: calc(var(--grid-unit) * 8);
}

.cta-content a {
  /* border-bottom: 2px solid var(--link-accent);  */
  text-decoration: underline;
}

main header .tags {
  margin-top: var(--ql);
}

main header p {
  margin-bottom: var(--hl);
}

#cta-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ql);
}

#cta-form {
  width: 100%;
  max-width: calc(var(--grid-unit) * 6);
  margin-top: var(--hl);
}

#cta-form p {
  font-size: var(--smaller);
  margin: var(--hl) 0;
  position: absolute;
  color: var(--lighter);
}

#cta-form.loading button {
  display: none;
}

#cta-form.error::after {
  content: "Something went wrong. 😬";
}

#cta-form.success::after {
  content: "One more step: you should have just received an email to confirm your address. If you don’t see it in your Inbox, check your Spam or Promotions folders.";
  font-size: var(--smaller);
  margin: var(--hl) 0;
  display: block;
  color: var(--lighter);
}

#cta-form.loading #cta-fields::after {
  content: "Loading...";
  border-radius: 2px;
  background: var(--faint);
  text-align: center;
  display: inline-block;
  color: var(--bg-color);
  padding: var(--ql);
  text-transform: uppercase;
  font-size: var(--smallest);
  font-family: var(--font-alt);
  word-spacing: -0.15em;
}

#cta-form input {
  color: var(--text-color);
  background: var(--bg-color);
  border: 1px solid var(--faint);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.05);
  padding: 6px 10px;
  flex: 4 0 auto;
  border-radius: 2px;
  line-height: 2rem;
}

#cta-form button, #cta-form.loading #cta-fields::after {
  flex: 1 0 auto;
  line-height: 2rem;
}

.button, button, .active-tag {
  background: var(--link-color);
  color: var(--bg-color) !important;
}

.button, button {
  padding: 5px 10px;
  cursor: pointer;
  text-align: center;
}

/* override for Ghost audio player button color */
.kg-audio-player button {
  color: var(--link-color) !important;
}

.active-tag {
  position: relative;
  padding-left: 20px !important;
}

.active-tag:before, .active-tag:after {
  position: absolute;
  left: 9px;
  top: 8px;
  content: ' ';
  height: 10px;
  width: 2px;
  background-color: var(--bg-color);
}

.active-tag:before {
  transform: rotate(45deg);
}

.active-tag:after {
  transform: rotate(-45deg);
}

/* Index Pages */

.archive-content h3 {
  font-weight: normal;
}

.archive-content h3 time {
  margin-left: 0.5em;
  font-size: var(--smallest);
}

.archive-content li {
  list-style: none;
  padding: calc(var(--lh) * .75) 0;
  border-bottom: 1px solid var(--faint);
}

.archive-content li:last-child {
  border-bottom: 0;
}

.archive-content p {
  color: var(--lighter);
}

/* Book Index */

.books-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-gap: var(--grid-gap);
}

.book-content {
  display: flex;
  flex-direction: column;
  text-align: center;
  margin: var(--ql) 0;
}

.book-title {
  order: 1;
}

.book-pubdate {
  order: 2;
  margin: calc(var(--ql) / 2) 0;
}

.book-description {
  font-size: var(--smaller);
  order: 3;
}

/* Footer */

#site-footer {
  background: hsl(0 0% 0% / 1.0);
  font-size: var(--smaller);
  color: hsl(0 0% 55%);
  text-align: center;
}

#site-footer a {
  color: hsl(0 0% 100%);
}

#site-footer ul {
  column-gap: 1.2em;
  justify-content: center;
}

#site-footer nav {
  margin-bottom: var(--hl);
}

#site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--smaller);
}

#site-nav a {
  color: var(--link-color);
  display: block;
}

#site-nav ul {
  display: flex;
  flex-direction: column;
  text-align: right;
  justify-content: flex-end;
  flex-wrap: wrap;
  column-gap: 1em;
  /* margin-top: var(--hl);
  margin-right: 200px; */
}

#site-logo {
  /* position: absolute;
  right: calc(var(--hl) * -.75);
  top: calc(var(--hl) * -1); */
  margin-left: -8px;
}

#site-logo svg {
  width: 100px;
  height: 100px;
  animation: spin 60s infinite steps(60);
  fill: var(--link-color);
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.emoji {
  margin-right: 0.2em;
}

/* Homepage */

body.home-template section > p {
  margin-bottom: var(--hl);
}

body.home-template p a {
  text-decoration: underline;
}

#home-about {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

#home-about h1, #home-about p {
  width: 100%;
  max-width: 680px;
  text-align: left;
}

#home-about h1 {
  color: var(--link-color);
  margin: var(--lh) 0 var(--hl);
}

#home-about h1 br {
  display: none;
}

#home-sunday {
  padding-bottom: calc(var(--lh) * 1.25);
}

#home-sunday p:first-child {
  text-align: center;
  color: var(--lighter);
  font-size: var(--smaller);
}

#home-sunday p:first-child::after {
  content: " ↓"
}

/* Book Pages */

#book-content {
  display: flex;
  flex-direction: column;
}

#book-cover {
  margin-top: 0;
  margin-bottom: 0;
}

#book-cover figcaption {
  text-align: center;
}

#book-cover figcaption a {
  color: var(--lighter);
  text-decoration: none;
}

#book-recognition {
  font-size: var(--smaller);
  color: var(--lightest);
  line-height: 1.5;
  margin: var(--lh) 0;
  text-align: center;
}

#book-recognition li{
  list-style: none;
  margin: 0;
  padding: 0;
}

#book-actions {
  border: var(--hl) solid var(--faintest);
  padding: var(--hl);
  margin-top: var(--ql);
  margin-bottom: var(--lh);
  text-align: center;
}

#book-actions li, #book-actions ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#cta-form + p {
  margin-top: var(--lh);
  color: var(--lightest);
}

/* Hide timestamp on page template */

.page-template .article-content > time {
  display: none;
}

/* Other Helpers */

.shorten {
  display: none;
}

#membership-about {
  margin: calc(var(--lh) * -1) calc(var(--lh) * -1) 0; /* hack for small screen outer padding */
}

/* Tablets and Up */

@media (min-width: 701px) {
  :root {
    --base: 1.25rem; /* 20px */
    --line-height: 1.5;
  }

  footer nav {
    margin-bottom: 0;
  }

  #site-main .has-image #article-content {
    padding-top: 18.5rem;
  }
  
  .article-header .article-image {
    position: relative;
    margin: var(--lh) calc(var(--grid-gap) * -1) -18rem;
    overflow: hidden;
  }

  .article-content .cards {
    margin-left: calc(var(--grid-gap) * -1);
    margin-right: calc(var(--grid-gap) * -1);
  }

  /* restore homepage h1 line break */

  #home-about h1 br {
    display: block;
  }
  
  #site-nav ul {
    flex-direction: row;
    text-align: left;  
    gap: 1.5em;
  }

  #site-nav a {
    font-size: 1.2em;
  }

  #site-footer {
    display: flex;
    justify-content: space-between;
    flex-direction: row-reverse;
    margin-top: var(--lh);
  }

  #site-footer nav {
    margin-bottom: 0;
  }

  .shorten {
    display: inline;
  }

  /* make tall book cover not so tall  */

  #book-header {
    text-align: left;
    display: flex;
    gap: var(--lh);
    align-items: center;
  }

  #book-title {
    font-size: 4.2em;
    line-height: 1em;
  }
    
  #book-intro {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-grow: 2;
    width: 420px;
  }

  #book-content {
    display: block;
  }

  #book-cover, #book-actions {
    width: 260px;
    /* margin: 0 0 0 var(--lh); */
  }

  #book-actions {
    float: right;
    margin-left: var(--lh);
    margin-top: var(--hl);
  }

  #book-recognition {
    text-align: left;
    flex-grow: 2;
  }

  #sunday-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  #sunday-header > * {
    width: calc(var(--grid-unit) * 6);
  }

  #cta-form + p {
    flex-grow: 2;
  }

  hr {
    margin: calc(var(--lh) * 1.5 - 2px) auto;
  }
  
  hr + h2 {
    margin-top: calc(var(--lh) * 1.5);
  }

  #membership-about {
    margin: 0; /* hack for small screen outer padding */
  }
}

@media (min-width: 801px ) {
  .cards {
    grid-gap: var(--hl);
  }

  /* .article-header {
    text-align: left;
  } */

  .article-header .article-image {
    margin-left: calc(var(--grid-unit) * -1);
    margin-right: calc(var(--grid-unit) * -1);
  }

  .article-content .kg-gallery-container {
    width: 800px;
  }

  header, footer, .content, .outer {
    padding: var(--lh) calc((100vw - 740px) / 2);
  }

  #plans, #plans + p {
    max-width: none;
    width: 800px;  
  }

  /* Book Index */

  .books-list .book {
    border: 0;
  }

}

@media (min-width: 960px ) {
  #site-header, #site-footer, #home-sunday {
    padding: var(--lh) calc((100vw - 900px) / 2);
  }
  #site-header {
    padding-bottom: 0;
  }
  #sunday-content {
    /* display: flex; */
    padding-left: var(--lh);
    padding-right: var(--lh);
  }
  #site-membership {
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 530px 20px 300px 1fr;
    grid-gap: var(--grid-gap);
    grid-template-areas:
      "header header header header header"
      ". main . sidebar .";
  }
  #membership-about{
    grid-area: header;
  }
  #membership-account{
    grid-area: sidebar;
  }
  #membership-updates{
    grid-area: main;
  }

  p.excerpt {
    margin-bottom: 0;
  }
  
  p.excerpt a {
    color: var(--link-color);
  }
  
  .article-content .kg-gallery-container {
    width: 960px;
  }

  /* #sunday-content .tags {
    flex-direction: column;
    align-items: flex-start;
    width: 280px; 
  }
  #sunday-content .cards {
    flex-grow: 2;
  } */
}

/* Dark Mode */

@media (prefers-color-scheme: dark) {
  :root {
    --brand-color: 172;
    --lightness: 100%;
    --faint: hsl(0 0% var(--lightness) / 0.25);
    --faintest: hsl(0 0% var(--lightness) / 0.07);  
    --bg-accent: hsl(172 100% 4%);
  }
}