/* 
  Modern Blog Theme
  A clean, minimal design focused on readability and content
*/

/* ========== CSS Variables ========== */
:root {
  --color-primary: #2563eb;
  --color-text: #1a1a1a;
  --color-text-muted: #6b7280;
  --color-text-code: #381f00;
  --color-background: #ffffff;
  --color-background-alt: rgba(249, 250, 251, 0.5);
  --color-border: #e5e7eb;
  --color-border-subtle: rgba(229, 231, 235, 0.5);

  /* Syntax highlighting colors */
  --color-syntax-red: #dc2626;
  --color-syntax-green: #059669;
  --color-syntax-blue: #2563eb;
  --color-syntax-orange: #d97706;
  --color-syntax-comment: #6b7280;

  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: Menlo, Consolas, "Liberation Mono", monospace;
  --max-width: 800px;
  --spacing-unit: 1rem;
}

/* ========== Reset & Base Styles ========== */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-background);
  min-height: 100vh;
}

/* ========== Typography ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 2rem 0 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

h1 {
  font-size: 2.25rem;
  margin-top: 0;
}

h2 {
  font-size: 1.875rem;
}

h3 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 1.5rem;
}

/* ========== Links ========== */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

a:hover {
  opacity: 0.9;
  text-decoration: none;
}

a:visited {
  color: var(--color-primary);
}

/* Animated underline using syntax colors - desktop only */
@media (hover: hover) and (pointer: fine) {
  .entry a:hover::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
      to right,
      var(--color-syntax-blue),
      var(--color-syntax-green)
    );
    animation: linkUnderline 0.3s ease-out;
  }

  @keyframes linkUnderline {
    from {
      transform: scaleX(0);
    }

    to {
      transform: scaleX(1);
    }
  }
}

/* ========== Header ========== */
#header {
  background-color: var(--color-background);
  border-bottom: 2px solid transparent;
  padding: 1.5rem 0;
  margin-bottom: 3rem;
  position: relative;
}

#header::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--color-syntax-blue) 0%,
    var(--color-syntax-green) 33%,
    var(--color-syntax-orange) 66%,
    var(--color-syntax-blue) 100%
  );
  background-size: 200% 100%;
  opacity: 0.8;
  animation: gradientShift 10s ease infinite;
}

#header > div {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin: 0;
}

#header h1 a {
  color: var(--color-text);
}

#header h1 a:hover {
  text-decoration: none;
  opacity: 0.8;
}

#header .links {
  font-size: 1rem;
  display: flex;
  gap: 1.5rem;
}

#header .links a {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ========== Main Layout ========== */
#page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

#content {
  width: 100%;
}

/* ========== Posts ========== */
.post {
  margin-bottom: 4rem;
}

.paginated-posts .post {
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.paginated-posts .post:last-child {
  border-bottom: none;
  margin-bottom: 2rem;
}

.post > h2 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 700;
}

.entry h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
}

.post h2 a {
  color: var(--color-text);
}

/* Fancy underline animation - desktop only */
@media (hover: hover) and (pointer: fine) {
  .post h2 a {
    background-image: linear-gradient(
      120deg,
      var(--color-syntax-blue) 0%,
      var(--color-syntax-green) 100%
    );
    background-repeat: no-repeat;
    background-size: 0% 3px;
    background-position: 0 95%;
    transition: background-size 0.3s ease-in-out;
  }

  .post h2 a:hover {
    color: var(--color-text);
    text-decoration: none;
    background-size: 100% 3px;
  }

  .post h2 a:hover::after {
    display: none;
  }
}

/* Simple underline on touch devices */
@media (hover: none) or (pointer: coarse) {
  .post h2 a:hover {
    text-decoration: underline;
  }
}

.entry {
  font-size: 1.125rem;
  line-height: 1.75;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.entry a {
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.entry h3 {
  margin-top: 2rem;
}

.read-more {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
}

.read-more:hover {
  text-decoration: underline;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: var(--color-bg-secondary);
  color: var(--color-primary);
  text-decoration: none;
  border-radius: 4px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.pagination a:hover {
  background-color: var(--color-primary);
  color: white;
}

.pagination .previous::before {
  content: "← ";
  margin-right: 0.25rem;
}

.pagination .next::after {
  content: " →";
  margin-left: 0.25rem;
}

.pagination span.next {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ========== Post Metadata ========== */
.postmetadata {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 1rem 0;
  font-family: var(--font-mono);
}

.postmetadata a {
  color: var(--color-text-muted);
}

.postmetadata a:hover {
  color: var(--color-primary);
}

#tags {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* ========== Images ========== */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
}

/* Constrain content images to a reasonable max width */
.entry img:not(.avatar) {
  max-width: min(100%, 1000px);
}

img.bordered {
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* ========== Lists ========== */
ul,
ol {
  margin: 0 0 1.5rem;
  padding-left: 2rem;
}

li {
  margin-bottom: 0.5rem;
}

/* ========== Blockquotes ========== */
blockquote {
  margin: 2rem 0;
  padding-left: 1.5rem;
  border-left: 4px solid var(--color-primary);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ========== Code ========== */
code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-code);
  background-color: var(--color-background-alt);
  padding: 0.0425rem 0.25rem;
  border-radius: 3px;
  border: 1px solid var(--color-border-subtle);
  word-break: break-word;
  overflow-wrap: break-word;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  background-color: var(--color-background-alt);
  border: 1px solid var(--color-border-subtle);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Prism.js syntax highlighting - simplified */
pre[class*="language-"] {
  background-color: var(--color-background-alt);
  border-left: 4px solid transparent;
  border-image: linear-gradient(
      to bottom,
      var(--color-syntax-blue),
      var(--color-syntax-green),
      var(--color-syntax-orange)
    )
    1;
  border-image-slice: 1;
  border-radius: 0;
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  position: relative;
}

/* ========== Tables ========== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.875rem;
}

th,
td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  background-color: var(--color-background-alt);
}

/* ========== Navigation ========== */
.navigation {
  margin: 3rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.875rem;
}

.navigation a {
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ========== Comments ========== */
.commentlist {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

.commentlist li {
  padding: 1rem;
  margin-bottom: 1rem;
  background-color: var(--color-background-alt);
  border-radius: 6px;
}

.commentmetadata {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* ========== Forms ========== */
input,
textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  width: 100%;
  max-width: 500px;
}

/* ========== Utility Classes ========== */
.update {
  background-color: #fef3c7;
  border: 1px solid #f59e0b;
  padding: 1rem;
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* Post date spacing */
.post > em:first-of-type {
  display: block;
  margin-bottom: 1.5rem;
}

.hidden {
  display: none;
}

.center {
  text-align: center;
}

/* ========== Responsive Design ========== */
@media (min-width: 1200px) {
  :root {
    --max-width: 900px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  #header > div {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  #header .links {
    font-size: 0.875rem;
  }

  .entry {
    font-size: 1rem;
    max-width: 100%;
    overflow-x: hidden;
  }

  pre {
    font-size: 0.8125rem;
    padding: 0.75rem;
  }
}

/* ========== Prism.js Token Colors ========== */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6b7280;
}

.token.punctuation {
  color: #374151;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #dc2626;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #059669;
}

.token.operator,
.token.entity,
.token.url,
.token.variable {
  color: #d97706;
}

.token.atrule,
.token.attr-value,
.token.keyword,
.token.class-name {
  color: #2563eb;
}

.token.regex,
.token.important {
  color: #dc2626;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

/* ========== Reading Progress Bar ========== */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--color-syntax-blue) 0%,
    var(--color-syntax-green) 33%,
    var(--color-syntax-orange) 66%,
    var(--color-syntax-blue) 100%
  );
  background-size: 200% 100%;
  transform: scaleX(0);
  transform-origin: left;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 100% 0%;
  }

  100% {
    background-position: 0% 0%;
  }
}

/* ========== Print Styles ========== */
@media print {
  body {
    color: black;
    background: white;
  }

  #header,
  .navigation,
  .postmetadata,
  .reading-progress {
    display: none;
  }
}
