/* Reset and base styles */
*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --color-bg: #fff;
  --color-text: #000;
  --color-text-secondary: #525252;
  --color-text-tertiary: #a3a3a3;
  --color-border: #e5e5e5;
  --color-code-bg: #f5f5f5;
  --color-link: #000;
  --color-link-decoration: #a3a3a3;
  --color-selection-bg: #47a3f3;
  --color-selection-text: #fefefe;

  /* Syntax highlighting */
  --sh-class: #2d5e9d;
  --sh-identifier: #354150;
  --sh-sign: #8996a3;
  --sh-string: #007f7a;
  --sh-keyword: #e02518;
  --sh-comment: #a19595;
  --sh-property: #e25a1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #000;
    --color-text: #fff;
    --color-text-secondary: #a3a3a3;
    --color-text-tertiary: #525252;
    --color-border: #262626;
    --color-code-bg: #171717;
    --color-link: #fff;
    --color-link-decoration: #525252;

    /* Dark mode syntax highlighting */
    --sh-class: #4c97f8;
    --sh-identifier: #fff;
    --sh-keyword: #f47067;
    --sh-string: #0fa295;
  }
}

::selection {
  background-color: var(--color-selection-bg);
  color: var(--color-selection-text);
}

html {
  min-width: 360px;
  color-scheme: light dark;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  font-size: 18px;
  line-height: 1.6;
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .container {
    padding: 2rem 0;
  }
}

/* Navbar */
.navbar {
  margin-bottom: 4rem;
  margin-left: -0.75rem;
}

.navbar nav {
  position: relative;
}

.nav-desktop {
  display: none;
  flex-direction: row;
  align-items: center;
}

.nav-mobile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
}

@media (min-width: 768px) {
  .nav-desktop {
    display: flex;
  }
  .nav-mobile,
  .nav-mobile-menu {
    display: none !important;
  }
}

.nav-brand {
  font-weight: bold;
  font-size: 1.125rem;
  text-decoration: none;
  color: var(--color-text);
  padding: 0.25rem 0.5rem;
  margin: 0.25rem;
  transition: color 0.2s;
}

.nav-brand:hover {
  color: var(--color-text-secondary);
}

.nav-link {
  text-decoration: none;
  color: var(--color-text);
  padding: 0.25rem 0.5rem;
  margin: 0.25rem;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link:hover {
  color: var(--color-text-secondary);
}

.nav-icon {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-icon span {
  font-size: 0.875rem;
}

.nav-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--color-text);
}

.nav-mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(4px);
  z-index: 50;
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.nav-mobile-menu[hidden] {
  display: none;
}

.nav-mobile-menu .nav-link {
  color: #fff;
  padding: 0.5rem;
}

.nav-mobile-social {
  display: flex;
  gap: 1rem;
  padding: 1rem 0.5rem 0;
  border-top: 1px solid #262626;
}

.nav-mobile-social a {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Posts list */
.posts-list {
  display: flex;
  flex-direction: column;
}

.posts-heading {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 2rem;
}

.post-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
  text-decoration: none;
  color: inherit;
}

@media (min-width: 768px) {
  .post-item {
    flex-direction: row;
    gap: 0.5rem;
  }
}

.post-date {
  color: var(--color-text-secondary);
  width: 100px;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
}

.post-title {
  color: var(--color-text);
  letter-spacing: 0;
}

.post-item:hover .post-title {
  color: var(--color-text-secondary);
}

/* Post page */
.post {
  flex: 1;
}

.post-heading {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 0.5rem 0;
  text-wrap: balance;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

.post-views {
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* Prose styles for markdown content */
.prose {
  line-height: 1.75;
}

.prose p {
  margin: 1rem 0;
  color: var(--color-text-secondary);
}

.prose h1 {
  font-size: 2.25rem;
  font-weight: 500;
  letter-spacing: 0;
  margin: 1.5rem 0 0.5rem;
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  margin: 1.5rem 0 0.5rem;
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0;
  margin: 1.5rem 0 0.5rem;
}

.prose h4 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: 0;
  margin: 1.5rem 0 0.5rem;
}

.prose strong {
  font-weight: 600;
  color: var(--color-text);
}

.prose a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-link-decoration);
  text-underline-offset: 2px;
  text-decoration-thickness: 0.1em;
  transition: text-decoration-color 0.2s;
}

.prose a:hover {
  text-decoration-color: var(--color-text);
}

.prose ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.prose ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.prose li {
  margin: 0.25rem 0;
}

.prose blockquote {
  border-left: 4px solid var(--color-border);
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--color-text-secondary);
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

.prose table {
  display: block;
  max-width: fit-content;
  overflow-x: auto;
  white-space: nowrap;
  border-collapse: collapse;
  margin: 1rem 0;
}

.prose th,
.prose td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
}

.prose th {
  background-color: var(--color-code-bg);
  font-weight: 600;
}

/* Code blocks */
.prose pre {
  background-color: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

.prose pre::-webkit-scrollbar {
  display: none;
}

.prose pre {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
}

.prose :not(pre) > code {
  background-color: var(--color-code-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  color: var(--color-text-secondary);
}

.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Rouge syntax highlighting */
.highlight .c,
.highlight .c1,
.highlight .cm { color: var(--sh-comment); }
.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt { color: var(--sh-keyword); }
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .ss { color: var(--sh-string); }
.highlight .nc,
.highlight .nn,
.highlight .nf { color: var(--sh-class); }
.highlight .na,
.highlight .nb,
.highlight .ni,
.highlight .nl,
.highlight .no,
.highlight .nv,
.highlight .nt { color: var(--sh-property); }
.highlight .o,
.highlight .p { color: var(--sh-sign); }

/* Footer */
.footer {
  margin-top: auto;
  padding-top: 2rem;
}

.footer ul {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .footer ul {
    flex-direction: row;
    gap: 1rem;
  }
}

.footer a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--color-text);
}

/* About page */
.about h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 2rem;
}

.about-image {
  float: right;
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 50%;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.about p {
  margin-bottom: 1rem;
}

/* Portfolio page */
.portfolio h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 2rem;
}

.portfolio-intro {
  margin-bottom: 2rem;
}

/* Legal pages */
.legal h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 2rem;
}

.legal-note {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.legal-english {
  margin-top: 3rem;
}

.legal-english h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 1.5rem;
}

/* Post RSS subscribe */
.post-rss-subscribe {
  margin-top: 2.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.post-rss-subscribe p {
  color: var(--color-text-secondary);
  margin: 0;
  max-width: 42rem;
}

.post-rss-subscribe a {
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-rss-subscribe a:hover {
  color: var(--color-text);
}

/* Page styles */
.page {
  flex: 1;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 2rem 0;
}

.support-page h1,
.markdown-page h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 2rem 0;
}

.support-page section {
  margin-bottom: 2rem;
}

.support-page h2,
.support-page h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
  margin: 0 0 0.5rem 0;
}

.support-page p {
  color: var(--color-text-secondary);
  margin: 0.5rem 0;
}

.support-page a,
.back-link a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-link-decoration);
  text-underline-offset: 2px;
}

.back-link {
  margin: 0 0 2rem 0;
  font-size: 0.875rem;
}

.page-content {
  color: var(--color-text-secondary);
}

.page-content a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Dark mode toggle placeholder */
@media (prefers-color-scheme: dark) {
  html {
    color-scheme: dark;
  }
}
