/* theme variables */
:root {
  --background-color: #ffffff;
  --text-color: #333333;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background-color: #333333;
    --text-color: #ffffff;
  }
}

:root[data-theme="dark"] {
  --background-color: #333333;
  --text-color: #ffffff;
}

/* body */
body {
  background-color: var(--background-color);
  color: var(--text-color);
  transition: all 0.3s ease;
}

/* links */
a {
  text-decoration: underline;
  color: inherit;
}
a:visited { color: inherit !important; }

/* nav spans (for theme toggle) */
nav span {
  cursor: pointer;
  display: inline-block;
  width: 1.2em;
  text-align: center;
  font-size: 1rem;
  user-select: none;
  padding: 0.3em;
  margin: -0.3em;
}

/* active nav item */
nav .active { background-size: 100% 1px; }

/* nav links - no underline */
#header nav a,
#header nav a:visited,
#header nav a:active {
  color: inherit;
  text-decoration: none;
}
#header nav a.active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

#header.faded {
  opacity: 0.25;
  transition: opacity 0.2s ease;
  animation: fadeOut 0.5s ease;
}

#header.faded.no-anim {
  animation: none;
}

#header.faded:hover {
  opacity: 1;
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0.25; }
}

/* layout */
#main {
  display: flex;
  flex-direction: column;
  max-width: 675px;
  width: 100%;
  margin-top: 3rem;
  padding-bottom: 3rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  box-sizing: border-box;
  align-self: center;
}

#header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

#header h2 {
  font-family: Palatino;
  margin: 0;
  font-weight: normal;
  font-size: 1.5rem;
  line-height: 1;
}

#header h2 a {
  text-decoration: none;
  color: inherit;
}

#header nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  font-family: Palatino;
  letter-spacing: 0.05em;
}

/* content paragraphs */
.content {
  margin-top: 2rem;
}

.content p {
  font-family: Palatino;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

.content + .content {
  margin-top: 1rem;
}

/* lit-generated content */
#main > p {
  font-family: Palatino;
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
}

#main > #header + p {
  margin-top: 2rem;
}

#main > p + p {
  margin-top: 1rem;
}

#main > h3 {
  font-family: Palatino;
  font-weight: bold;
  margin: 0;
  font-size: 1.1rem;
}

#main > #header + h3 {
  margin-top: 2rem;
}

#main > p + h3 {
  margin-top: 1rem;
}

#main > h3 + p {
  margin-top: 0.5rem;
}

/* blog post list */
.post-item {
  margin-top: 1.5rem;
}

#header + .post-item {
  margin-top: 2rem;
}

.post-item h2 {
  font-family: Palatino;
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}

.post-item h2 a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0% 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.3s ease;
}

.post-item h2 a:hover {
  background-size: 100% 1px;
}

.post-date {
  font-family: Palatino;
  font-size: 0.9rem;
  color: gray;
  margin-top: 0.25rem;
}

/* notes list */
.note-item {
  margin-top: 1.5rem;
}

.note-title {
  font-family: Palatino;
  font-size: 1.1rem;
  margin: 0;
}

.note-title a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0% 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.3s ease;
}

.note-title a:hover {
  background-size: 100% 1px;
}

.note-date {
  font-family: Palatino;
  font-size: 0.9rem;
  color: gray;
  margin-top: 0.25rem;
}

/* toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-color);
  color: var(--background-color);
  padding: 0.5rem 1rem;
  font-family: sans-serif;
  font-size: 0.9rem;
  border-radius: 0.25rem;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show {
  opacity: 1;
}

/* post header */
.post-header {
  margin-bottom: 2rem;
}

.post-header h2 {
  font-family: Palatino;
  margin: 0;
  font-weight: normal;
  font-size: 1.5rem;
  line-height: 1;
}

.post-header h2 a,
.post-header h2 a:hover {
  text-decoration: none;
  color: inherit;
}

.post-header .post-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.post-header .back-link {
  font-family: Palatino;
  text-decoration: none;
  color: gray;
  font-size: 0.9rem;
}

.post-header .theme-toggle {
  cursor: pointer;
  font-size: 1rem;
  user-select: none;
}


/* post typography */
article.post {
  margin-top: 0;
}

article.post h2 {
  font-size: 1.3em;
  margin: 0;
}

article.post h3 {
  font-size: 1.15em;
}

article.post .post-date {
  color: gray;
}

article.post p {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.125rem;
  line-height: 1.5em;
  margin: 1.5rem 0;
  text-align: justify;
}

article.post p:first-of-type {
  margin-top: 0;
}

article.post ol,
article.post ul {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.125rem;
  line-height: 1.5em;
  text-align: justify;
}

article.post h2 {
  font-family: Palatino;
  font-size: 1.5rem;
  font-weight: normal;
  margin: 2.5rem 0 1rem 0;
}

article.post h3 {
  font-family: Palatino;
  font-size: 1.25rem;
  font-weight: normal;
  margin: 2rem 0 0.75rem 0;
}

article.post blockquote {
  margin: 1.5rem 0;
  padding-left: 1.5rem;
  border-left: 3px solid #ccc;
  font-style: italic;
}

article.post code {
  font-family: "SF Mono", Menlo, Monaco, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

article.post pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

article.post pre code {
  background: none;
  padding: 0;
}

/* dark mode adjustments for posts */
:root[data-theme="dark"] article.post .post-meta,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) article.post .post-meta {
    color: #aaa;
  }
}

:root[data-theme="dark"] article.post code,
:root[data-theme="dark"] article.post pre {
  background: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) article.post code,
  :root:not([data-theme="light"]) article.post pre {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* mobile */
@media (max-width: 750px) {
  #main {
    margin-top: 2rem;
  }

  #header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}
