/* ======================
   CSS Reset & Base Styles
   ====================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.5;
}

body {
  font-family: Montserrat, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  background-color: #ffffff;
  color: #374151;
}

body.dark {
  background-color: #222222;
  color: #e5e7eb;
}

/* ======================
   Typography
   ====================== */

h1 {
  font-family: "Press Start 2P", monospace;
  line-height: 1.2;
  font-weight: 400;
}

h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 400;
}

a {
  text-decoration: none;
  color: inherit;
}

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

/* ======================
   Utility Classes
   ====================== */

.container {
  max-width: clamp(320px, 100%, 2400px);
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 8rem);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.space-x-4 > * + * {
  margin-left: 1rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.gap-4 {
  gap: 1rem;
}

.flex-grow {
  flex-grow: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

.hidden {
  display: none;
}

.block {
  display: block;
}

.inline-flex {
  display: inline-flex;
}

/* ======================
   Custom Fonts
   ====================== */

.bit_font {
  font-family: 'Courier New', Courier, monospace;
}

/* ======================
   Header & Navigation
   ====================== */

.site-header nav {
  background-color: #ffffff;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 50;
  box-shadow: none;
}

body.dark .site-header nav {
  background-color: #222222;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: clamp(4rem, 5vw, 6rem);
}

.nav-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.nav-brand {
  font-family: "Press Start 2P", monospace;
  color: #111827;
  font-size: clamp(0.75rem, 1.2vw, 1.5rem);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.2rem);
  flex-shrink: 1;
  min-width: 0;
}

.nav-text {
  display: inline;
  line-height: 1;
}

.nav-brand-img {
  height: clamp(1.75rem, 3vw, 3.5rem);
  width: auto;
  flex-shrink: 0;
}

body.dark .nav-brand {
  color: white;
}

.mobile-menu-button {
  background: none;
  border: none;
  color: #111827;
  cursor: pointer;
  padding: 0.5rem;
  flex-shrink: 0;
}

body.dark .mobile-menu-button {
  color: white;
}

.mobile-menu-button svg {
  width: 1.5rem;
  height: 1.5rem;
}

.desktop-menu {
  display: none;
  align-items: center;
  gap: clamp(1.5rem, 2vw, 3rem);
}

.desktop-menu a {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.75rem, 1vw, 1.25rem);
  color: #111827;
  text-decoration: underline;
  transition: color 0.2s;
}

.desktop-menu a:hover {
  color: #527c9f;
}

.desktop-menu a.active {
  text-decoration: none;
}

body.dark .desktop-menu a {
  color: white;
}

body.dark .desktop-menu a:hover {
  color: #e5e7eb;
}


.theme-toggle {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.75rem, 1vw, 1.25rem);
  background: none;
  border: none;
  color: #111827;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s;
}

.theme-toggle img {
  transition: opacity 0.2s;
}

.theme-toggle:hover img {
  opacity: 0.7;
}

.theme-toggle:hover {
  color: #527c9f;
}

body.dark .theme-toggle {
  color: white;
}

body.dark .theme-toggle:hover {
  color: #e5e7eb;
}



.mobile-menu {
  padding-bottom: 1rem;
}

.mobile-menu:not(.hidden) {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.mobile-menu a {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.875rem, 2vw, 1.25rem);
  display: block;
  padding: 0.75rem 0;
  color: #111827;
  text-decoration: underline;
  text-align: right;
}

.mobile-menu a:hover {
  color: #527c9f;
}

.mobile-menu a.active {
  text-decoration: none;
}

.mobile-menu .theme-toggle {
  display: block;
  text-align: right;
  padding: 0.75rem 0;
}

body.dark .mobile-menu a {
  color: white;
}

body.dark .mobile-menu a:hover {
  color: #e5e7eb;
}

/* ======================
   Main Content Area
   ====================== */

main {
  margin-top: 5rem;
  display: grid;
  place-items: center;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.main-content {
  grid-column: span 1;
}

/* ======================
   Hero Section
   ====================== */

.hero-section {
  width: 100%;
}

.hero-mobile {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: center;
  text-align: center;
  padding: 1rem;
}

.hero-mobile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hero-mobile img {
  margin: 0;
  height: clamp(4rem, 8vw, 6rem);
}

.hero-bio-mobile {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.5rem, 1.5vw, 0.875rem);
  line-height: 2;
  max-width: 90%;
  padding: 2rem 3rem;
}

.homepage-title-wrapper {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: clamp(0.5rem, 1vw, 2rem);

}

.homepage-title {
  font-size: clamp(2.5rem, 3vw + 1rem, 6rem);
  font-weight: 700;
  line-height: 1.1;
  color: #111827;
  grid-column: 1 / -1;
  grid-row: 1;
}

body.dark .homepage-title {
  color: white;
}

.small-homepage-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: #111827;
  padding-left: 0;
  align-self: center;
  display: inline-block;
  position: relative;
}

body.dark .small-homepage-title {
  color: white;
}

.homepage-title-footnote {
  font-size: clamp(1.25rem, 1vw + 0.5rem, 3rem);
  opacity: 0.5;
  transform: rotate(-20deg) translate(50%, 100%);
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  align-self: start;
}

.nav-footnote {
  font-size: 0.4em;
  opacity: 0.5;
  vertical-align: 0.05em;
  margin-left: -1.8em;
}

.footer-footnote {
  font-size: 0.4em;
  opacity: 0.5;
}

.hero-footnote {
  font-size: 0.4em;
  opacity: 0.5;
  position: absolute;
  bottom: 0;
  right: -20%;
  transform: rotate(-20deg) translate(-10%, 150%);
  margin-left: 0;
}

.hero-desktop {
  display: none;
}

.hero-desktop img {
  margin: 0;
}

.hero-bio {
  text-align: left;
  margin: 0;
  font-size: 0.875rem;
  color: #111827;
}

.hero-bio a {
  color: #2563eb;
  text-decoration: underline;
}

body.dark .hero-bio {
  color: white;
}

body.dark .hero-bio a {
  color: #60a5fa;
}

/* ======================
   Blog Posts
   ====================== */

.posts-section {
  margin-top: 2rem;
}

.section-title {
  font-size: clamp(1.875rem, 3vw, 3.5rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: #111827;
}

body.dark .section-title {
  color: white;
}

.content-section {
  background-color: white;
  border-radius: 0.5rem;
  margin-bottom: 3rem;
  padding: 1.5rem;
  padding-bottom: 2rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
  border-bottom: 1px solid #e5e7eb;
}

.content-section:last-child {
  border-bottom: none;
}

body.dark .content-section {
  background-color: #222222;
  border-bottom-color: #374151;
}

body.dark .content-section:last-child {
  border-bottom: none;
}

.article-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.article-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.article-body {
  flex-grow: 1;
  margin-top: 2rem;
}

.article-metadata {
  margin-bottom: 0.5rem;
}

.article-metadata a {
  margin-right: 0.5rem;
  color: #2563eb;
}

body.dark .article-metadata a {
  color: #60a5fa;
}

.article-metadata small {
  color: #6b7280;
}

body.dark .article-metadata small {
  color: #9ca3af;
}

.article-title {
  font-size: clamp(1.5rem, 2.5vw, 2.5rem);
  margin-bottom: 0.5rem;
  color: #111827;
  transition: color 0.2s;
}

body.dark .article-title {
  color: white;
}

.article-title:hover {
  color: #2563eb;
}

body.dark .article-title:hover {
  color: #60a5fa;
}

.article-content {
  color: #374151;
  line-height: 1.7;
  max-width: 100%;
  overflow-x: auto;
}

body.dark .article-content {
  color: #d1d5db;
}

/* ======================
   Post Detail Page
   ====================== */

.post-title {
  font-size: clamp(2.25rem, 3.5vw, 4rem);
  margin-bottom: 1rem;
  color: #111827;
}

body.dark .post-title {
  color: white;
}

.post-actions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

body.dark .post-actions {
  border-top-color: #374151;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  margin-right: 0.5rem;
}

.btn-secondary {
  border-color: #d1d5db;
  color: #374151;
  background: transparent;
}

.btn-secondary:hover {
  background-color: #f9fafb;
}

body.dark .btn-secondary {
  border-color: #4b5563;
  color: #d1d5db;
}

body.dark .btn-secondary:hover {
  background-color: #333333;
}

.btn-danger {
  border-color: #ef4444;
  color: #ef4444;
  background: transparent;
}

.btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

body.dark .btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
}

/* ======================
   Markdown Content Styles
   ====================== */

.article-content h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  color: #111827;
}

body.dark .article-content h1 {
  color: white;
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  color: #111827;
}

body.dark .article-content h2 {
  color: white;
}

.article-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: #111827;
}

body.dark .article-content h3 {
  color: white;
}

.article-content p {
  margin-bottom: 1rem;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1rem;
  margin-left: 1.5rem;
}

.article-content ul {
  list-style-type: disc;
}

.article-content ol {
  list-style-type: decimal;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content a {
  color: #2563eb;
  text-decoration: underline;
}

body.dark .article-content a {
  color: #60a5fa;
}

.article-content code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  font-family: 'Courier New', Courier, monospace;
}

body.dark .article-content code {
  background-color: #333333;
}

.article-content pre {
  background-color: #f3f4f6;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  max-width: 100%;
}

body.dark .article-content pre {
  background-color: #333333;
}

.article-content pre code {
  background-color: transparent;
  padding: 0;
}

.article-content blockquote {
  border-left: 4px solid #d1d5db;
  padding-left: 1rem;
  font-style: italic;
  margin: 1rem 0;
}

body.dark .article-content blockquote {
  border-left-color: #4b5563;
}

.article-content img {
  border-radius: 0.5rem;
  margin: 1rem auto;
  max-width: 100%;
  height: auto;
  display: block;
}

.article-content figcaption {
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.5rem;
}

body.dark .article-content figcaption {
  color: #9ca3af;
}

.article-content hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid #d1d5db;
}

body.dark .article-content hr {
  border-top-color: #4b5563;
}

.article-content table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.article-content th {
  background-color: #f3f4f6;
  font-weight: 700;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
}

body.dark .article-content th {
  background-color: #333333;
  border-color: #4b5563;
}

.article-content td {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
}

body.dark .article-content td {
  border-color: #4b5563;
}

/* ======================
   Modal
   ====================== */

.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-content {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
  max-width: 28rem;
  width: 100%;
  margin: 1rem;
}

body.dark .modal-content {
  background-color: #222222;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

body.dark .modal-header {
  border-bottom-color: #374151;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

body.dark .modal-title {
  color: white;
}

.modal-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
}

.modal-close:hover {
  color: #4b5563;
}

body.dark .modal-close:hover {
  color: #d1d5db;
}

.modal-close svg {
  width: 1.5rem;
  height: 1.5rem;
}

.modal-body {
  padding: 1rem 1.5rem;
  color: #374151;
}

body.dark .modal-body {
  color: #d1d5db;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background-color: #f9fafb;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

body.dark .modal-footer {
  background-color: #222222;
}

/* ======================
   Footer
   ====================== */

footer {
  padding: clamp(1.5rem, 3vw, 3rem) 0;
  background-color: white;
  border-top: 1px solid #e5e7eb;
}

body.dark footer {
  background-color: #222222;
  border-top-color: #374151;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}

.social-icons {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.5vw, 2rem);
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.social-icon:hover {
  opacity: 0.8;
}

.social-icon img {
  width: clamp(2rem, 2.5vw, 3rem);
  height: clamp(2rem, 2.5vw, 3rem);
}

body.dark .social-icon img {
  filter: invert(1);
}

.copyright {
  color: #111827;
  font-size: clamp(1rem, 1.5vw, 1.5rem);
  font-weight: 500;
}

body.dark .copyright {
  color: white;
}

/* ======================
   Error Page
   ====================== */

.error-section {
  padding: 1.5rem;
}

.error-title {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #111827;
}

body.dark .error-title {
  color: white;
}

.error-message {
  font-size: 1.125rem;
}

/* ======================
   Responsive Design
   ====================== */

/* Small tablets and large phones (640px+) */
@media (min-width: 640px) {
  .article-card {
    gap: 1.5rem;
  }

  .article-img {
    width: clamp(64px, 8vw, 100px);
    height: clamp(64px, 8vw, 100px);
  }
}

/* Tablets and small desktops (768px+) */
@media (min-width: 768px) {
  .mobile-menu-button {
    display: none;
  }

  .desktop-menu {
    display: flex;
  }

  .main-grid {
    grid-template-columns: repeat(12, 1fr);
  }

  .main-content {
    grid-column: span 12;
  }

  .hero-mobile {
    display: none;
  }

  .hero-desktop {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(2rem, 4vw, 8rem);
    place-content: center;
    margin: 0 auto;
    max-width: clamp(900px, 80vw, 2800px);
  }

  .hero-bio {
    font-family: "Press Start 2P", monospace;
    text-align: right;
    font-size: clamp(0.875rem, 1.2vw, 1.75rem);
    align-self: center;
    justify-self: end;
  }

  .hero-image {
    justify-self: center;
    align-self: center;
  }

  .hero-image img {
    width: clamp(200px, 20vw, 550px);
    height: auto;
  }

  .hero-titles {
    justify-self: start;
    align-self: center;
  }

  .homepage-title {
    margin-bottom: 0;
  }

  .homepage-title-footnote {
    transform: rotate(-20deg) translate(15%, 150%);
  }
}

/* Large desktops (1280px+) - structural changes only */
@media (min-width: 1280px) {
  .homepage-title-footnote {
    transform: rotate(-20deg) translate(30%, 150%);
  }
}

/* Extra large desktops (1536px+) - structural changes only */
@media (min-width: 1536px) {
}

/* Ultra-wide desktops (2200px+) - structural changes only */
@media (min-width: 2200px) {
}

/* Extreme ultra-wide desktops (2800px+) - structural changes only */
@media (min-width: 2800px) {
}
