/* ===== CSS Variables ===== */
:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #444444;
  --color-muted: #777777;
  --color-border: #d0d0d0;
  --color-tag-bg: #1a1a1a;
  --color-tag-text: #ffffff;
  --color-footer-bg: #f7f7f7;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", "Consolas", monospace;

  --max-width: 900px;
  --nav-height: 56px;
  --border: 1px solid var(--color-border);
  --transition: 0.15s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

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

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

/* ===== Navigation ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: var(--border);
  height: var(--nav-height);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar__logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.navbar__logo:hover {
  color: var(--color-muted);
}

.navbar__links {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.navbar__links a {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 400;
  text-decoration: none;
  padding: 0.25rem 0;
}

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

.navbar__links a.active {
  color: var(--color-text);
  font-weight: 600;
}

/* Remove old underline animation */
.navbar__links a::after {
  display: none;
}

/* Hamburger */
.navbar__toggle {
  display: none;
  background: none;
  border: var(--border);
  cursor: pointer;
  padding: 0.4rem;
}

.navbar__toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  margin: 4px 0;
  transition: var(--transition);
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
}

main {
  flex: 1;
}

/* ===== Intro Section (index) ===== */
.intro {
  padding: 3.5rem 0 2rem;
  border-bottom: var(--border);
}

.intro__greeting {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.intro__text {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ===== CV Embed ===== */
.cv-embed {
  border: var(--border);
  overflow: hidden;
}

.cv-embed embed {
  display: block;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: var(--border);
  transition: all var(--transition);
}

.btn--primary {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.btn--primary:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn--outline {
  background: transparent;
  color: var(--color-text);
}

.btn--outline:hover {
  background: var(--color-text);
  color: var(--color-bg);
}

/* ===== Section ===== */
.section {
  padding: 3.5rem 0;
}

.section__title {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.section__subtitle {
  color: var(--color-text-secondary);
  margin-bottom: 2.5rem;
  font-size: 0.95rem;
}

/* ===== Cards List ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.card {
  background: var(--color-surface);
  border: var(--border);
  border-bottom: none;
  padding: 1.5rem 1.75rem;
}

.card:last-child {
  border-bottom: var(--border);
}

a.card--link {
  text-decoration: none;
  display: block;
  color: inherit;
}

a.card--link:hover {
  background: inherit;
  color: inherit;
}

a.card--link:hover .card__title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card__date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.card__title {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.card__description {
  color: var(--color-text-secondary);
  font-size: 0.93rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
}

.card__link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.card__link::after {
  content: " ->";
}

/* ===== Blog List ===== */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.blog-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.25rem 1.75rem;
  background: var(--color-surface);
  border: var(--border);
  border-bottom: none;
  text-decoration: none;
}

.blog-item:last-child {
  border-bottom: var(--border);
}

.blog-item:hover .blog-item__title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.blog-item__title {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.blog-item__date {
  font-family: var(--font-mono);
  color: var(--color-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-left: 1.5rem;
}

/* ===== Blog Post (article page) ===== */
.post {
  padding: 3rem 0 4rem;
}

.post__header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: var(--border);
}

.post__title {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post__meta {
  font-family: var(--font-mono);
  color: var(--color-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post__download {
  display: inline-block;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  border: var(--border);
  padding: 0.45rem 1rem;
  transition: all var(--transition);
}

.post__download::before {
  content: "\2193  ";
}

.post__link-external::before {
  content: "\2192  ";
}

.post__download:hover {
  background: var(--color-text);
  color: var(--color-bg);
}

.post__content {
  font-size: 1.02rem;
  line-height: 1.8;
}

.post__content h2 {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
}

.post__content h3 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
}

.post__content p {
  margin-bottom: 1.25rem;
}

.post__content code {
  font-family: var(--font-mono);
  background: #f3f3f3;
  padding: 0.15rem 0.4rem;
  font-size: 0.88em;
  border: 1px solid var(--color-border);
}

.post__content pre {
  background: #1a1a1a;
  color: #e0e0e0;
  padding: 1.25rem;
  border: var(--border);
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  line-height: 1.6;
}

.post__content pre code {
  background: none;
  padding: 0;
  color: inherit;
  border: none;
}

.post__content ul,
.post__content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post__content li {
  margin-bottom: 0.4rem;
}

.post__content blockquote {
  border-left: 3px solid var(--color-text);
  padding: 0.75rem 1.25rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
  font-style: italic;
}

/* Figures */
.post__content figure {
  margin: 1.75rem 0;
}

.post__content figure img {
  max-width: 100%;
  height: auto;
  border: var(--border);
}

.post__content figcaption {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* Tables */
.post__content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.post__content th,
.post__content td {
  border: var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.post__content th {
  font-family: var(--font-mono);
  font-weight: 600;
  background: #f5f5f5;
}

/* Headings h4 */
.post__content h4 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
}

/* Table of contents */
.toc {
  padding-left: 1.25rem;
  margin-bottom: 2rem;
}

.toc ol {
  padding-left: 1.25rem;
  margin-bottom: 0;
}

.toc li {
  margin-bottom: 0.3rem;
}

.toc a {
  font-size: 0.95rem;
}

.post__back {
  display: inline-block;
  margin-top: 2.5rem;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
}

.post__back::before {
  content: "<- ";
}

/* ===== Footer ===== */
.footer {
  background: var(--color-footer-bg);
  border-top: var(--border);
  padding: 2rem 0;
  margin-top: auto;
}

.footer__text {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.footer__links {
  margin-top: 0.5rem;
  display: flex;
  gap: 1.25rem;
}

.footer__links a {
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-decoration: none;
}

.footer__links a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .intro__greeting {
    font-size: 1.2rem;
  }

  .intro__text {
    font-size: 0.95rem;
  }

  .cv-embed embed {
    height: 500px;
  }

  .section__title {
    font-size: 1.3rem;
  }

  .navbar__links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-bg);
    flex-direction: column;
    padding: 0.75rem 2rem;
    gap: 0.5rem;
    border-bottom: var(--border);
  }

  .navbar__links.open {
    display: flex;
  }

  .navbar__toggle {
    display: block;
  }

  .blog-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .blog-item__date {
    margin-left: 0;
  }

  .post__title {
    font-size: 1.4rem;
  }
}
