/* Define Custom Properties (CSS Variables) */
:root {
  --primary-text: #333;
  --secondary-text: #666;
  --background-color: aliceblue;
  --link-color: darkblue;
  --link-hover-color: rgba(80, 6, 122, 0.479);
  --card-bg: #fff;
  --button-bg-light: aliceblue;
  --button-bg-dark: #333;
  --button-text-light: #333;
  --button-text-dark: aliceblue;
  --post-card-bg-light: #fff;
  --post-card-bg-dark: #222;
  --post-card-shadow-light: rgba(0, 0, 0, 0.1);
  --post-card-shadow-dark: rgba(0, 0, 0, 0.3);
  --header-bg: #f4f4f4;
}

/* Dark Mode Overrides */
body.dark-mode {
  --primary-text: aliceblue;
  --secondary-text: #bbb;
  --background-color: #333;
  --link-color: lightblue;
  --link-hover-color: #ff0;
  --card-bg: #222;
  --button-bg-light: #333;
  --button-bg-dark: #222;
  --button-text-light: #333;
  --button-text-dark: aliceblue;
  --post-card-bg-light: #222;
  --post-card-bg-dark: #444;
  --post-card-shadow-light: rgba(0, 0, 0, 0.3);
  --post-card-shadow-dark: rgba(0, 0, 0, 0.5);
  --header-bg: #444;
}

/* === Typography Upgrade === */
/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&family=Open+Sans:wght@400;600&display=swap');

/* Apply body font */
body {
  font-family: 'Open Sans', Arial, sans-serif;
  line-height: 1.65;
  font-weight: 400;
  color: var(--primary-text);
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6,
.post-header {
  font-family: 'Merriweather', Georgia, serif;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.5px;
  color: var(--primary-text);
}

/* Post content text */
.post-content {
  font-family: 'Open Sans', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--primary-text);
}

/* Links */
a,
.site-nav a,
.projects-list a,
.post-nav a {
  font-family: 'Open Sans', Arial, sans-serif;
  font-weight: 600;
  text-decoration: none;
}

/* Meta info, small text */
.post-meta,
.post-nav {
  font-family: 'Open Sans', Arial, sans-serif;
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--secondary-text);
}

/* General Layout and Body */
html {
  height: 100%;
}

body {
  margin: 0;
  padding-bottom: 6rem;
  color: var(--primary-text);
  background-color: var(--background-color);
  min-height: 100vh;
}

a {
  color: var(--link-color);
  transition: color 0.3s ease;
}

a:hover {
  color: var(--link-hover-color);
}

/* Circle Button Styles */
.circleButton {
  background-color: var(--button-bg-light);
  color: var(--button-text-light);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  align-self: center;
  text-align: center;
  border: 1px solid;
  transition: background-color 0.3s ease;
}

.circleButton:hover {
  background-color: lightgrey;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.circleButton:focus {
  outline: 2px solid #ff0;
}

body.dark-mode .circleButton {
  background-color: var(--button-bg-dark);
  color: var(--button-text-dark);
}

/* Post Card Styling */
body.light-mode .post-card {
  background-color: var(--post-card-bg-light);
  box-shadow: var(--post-card-shadow-light);
}

body.dark-mode .post-card {
  background-color: var(--post-card-bg-dark);
  box-shadow: var(--post-card-shadow-dark);
}

.post-card {
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  transition: transform 0.2s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  background-color: #f4f4f4;
}

/* Post Layout Styling */
.post {
  max-width: 85%;
  margin: 0 auto;
  padding: 2rem;
  background-color: var(--post-card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.post-header {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary-text);
  background-color: var(--header-bg);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  padding: 0.5rem;
}

.post-header h1 {
  font-size: 2rem;
}

/* Meta Data */
.post-meta {
  font-size: 1rem;
  color: var(--secondary-text);
  padding: 1rem;
}

.post-meta span {
  margin-right: 1rem;
}

.post-content {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--primary-text);
}

/* Header */
header {
  background-color: var(--header-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 1rem;
  padding-right: 1rem;
  max-height: 3rem;
  border-radius: 1rem;
}

.kofi-logo {
  width: auto;
  height: 2.5em;
}

main {
  display: flex;
  flex-direction: column;
  min-height: calc(95vh - 6rem);
  flex-grow: 1;
  justify-self: center;
  margin: 0 auto;
  padding: 1rem 1rem 1rem 1rem;
  width: 75%;
}


.page-footer {
  position: fixed;
  /* instead of fixed */
  bottom: 0%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: 14px;
  margin-top: 2rem;
  /* add spacing */
}

.kofi-logo {
  width: auto;
  height: 2.5em;
}

.pagination {
  margin-top: 2rem;
  text-align: center;
}

.pagination a {
  margin: 0 0.5rem;
  text-decoration: none;
  font-weight: bold;
  color: var(--link-color);
}

.pagination a.active {
  color: #ff0;
  text-decoration: underline;
}

.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1rem;
}

.project-content {
  border: none;
  flex: 2;
}

@media (min-width: 600px) {
  .post-list {
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns on small screens */
  }
}

@media (min-width: 1024px) {
  .post-list {
    grid-template-columns: repeat(3, 1fr);
    /* 3 columns on large screens */
  }
}

/* Header base */
.site-header {
  background: var(--header-bg, #222);
  color: var(--primary-text, #fff);
  padding: 0.5rem 1rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
}

.site-title a {
  color: inherit;
  text-decoration: none;
  font-size: 2rem;
  font-weight: bold;
}

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 1rem;
  padding: 1rem;
  font-size: 1.5rem;
}

.site-nav a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}

.site-nav a:hover {
  text-decoration: underline;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
}



.projects-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.projects-list li {
  background: var(--card-bg, #f4f4f4);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.projects-list a {
  font-weight: bold;
  text-decoration: none;
  color: var(--link-color, #007acc);
}

.projects-list a:hover {
  text-decoration: underline;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 3rem 0 2rem;
  padding: 1rem 0;

  font-size: 0.95rem;
  font-weight: 500;
}

.post-nav a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  background-color: var(--card-bg);
  border-radius: 5%;
  padding: .5rem;
}

.post-nav a:hover {
  color: var(--link-hover-color);
  transform: translateY(-1px);
}


.post-nav .prev {
  text-align: left;
  max-width: 48%;
}

.post-nav .next {
  text-align: right;
  max-width: 48%;
}

/* Modal wrapper hidden by default */
.writing-modal.hidden {
  display: none;
}

/* Fixed fullscreen overlay */
.writing-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Semi-transparent backdrop */
.writing-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

/* Modal content box */
.writing-modal-content {
  position: relative;
  background: var(--card-bg, #fff);
  max-width: 800px;
  max-height: 90vh;
  width: 90%;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}

/* Modal header as flex row */
.writing-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--secondary-text);
  position: relative;
}

.modal-title-wrapper {
  display: flex;
  align-items: baseline;
  /* keeps title and author aligned nicely */
  gap: 0.5rem;
  /* space between title and author */
  flex-wrap: wrap;
  /* allow wrapping on small screens */
}

.writing-modal-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.writing-modal-author {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--secondary-text);
}

.writing-modal-close {
  font-size: 1.5rem;
  font-weight: bold;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary-text);
  line-height: 1;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.writing-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .writing-modal-close {
  color: var(--primary-text);
}

.writing-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  font-family: 'Open Sans', sans-serif;
  line-height: 1.6;
  color: var(--primary-text);
  white-space: pre-wrap;
}

/* Footer / Prev Next buttons */
.writing-modal-footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-top: 1px solid #ddd;
  background: var(--header-bg);
}

.writing-modal-btn {
  background: var(--button-bg-light);
  color: var(--button-text-light);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.writing-modal-btn:hover {
  background: lightgray;
}

.writing-modal-btn {
  background: #eee;
  color: #333;
}

body.dark-mode .writing-modal-btn {
  background: #777777;
  color: #eee;
}



.writing-modal-link {
  text-decoration: none;
  color: var(--link-color);
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background 0.3s ease, color 0.3s ease;
  background: var(--button-bg-light);
}

.writing-modal-link:hover {
  background: lightgray;
  color: var(--link-hover-color);
}

@media (max-width: 700px) {
  main {
    width: 95%;
    padding: 1rem;
  }

  header {
    flex-wrap: wrap;
    padding: 0.5rem;
    max-height: none;
  }
    .site-nav {
    display: none;
    position: absolute;
    top: 60px;
    right: 1rem;
    background: var(--header-bg, #222);
    padding: 0.5rem 1rem;
    border-radius: 8px;
  }

  .site-nav.open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
    gap: 0.5rem;
  }

  .menu-toggle {
    display: block;
  }
}

@media (max-width: 600px) {

  body,
  .post-content {
    font-size: 1.125rem;
    /* ~18px */
    line-height: 1.7;
  }

  .post {
    padding: 1rem;
  }
    .writing-modal-content {
    width: 95%;
    max-height: 95vh;
    font-size: 1.5rem;
  }

  .writing-modal-title {
    font-size: 1.0rem;
  }

  .writing-modal-btn {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

