/* Blog Common Styles */

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

.page {
  opacity: 0;
  animation: pageIn 0.35s ease 0.05s forwards;
}

@keyframes pageIn {
  to {
    opacity: 1;
  }
}

html, body {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: rgba(237, 232, 220, 0.92);
  font-family: 'Inter', sans-serif;
  color: rgba(25, 18, 70, 0.85);
  -webkit-font-smoothing: antialiased;
}

/* Page wrapper */
.page {
  width: 100%;
  max-width: 920px;
  padding: 4vh 3rem 2vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 2vh;
  border-bottom: 1px solid rgba(30, 20, 80, 0.08);
  margin-bottom: 4vh;
}

.header__name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: rgba(25, 18, 70, 0.88);
  text-decoration: none;
}

.header__name:hover {
  color: rgba(25, 18, 70, 1);
}

.header__nav {
  display: flex;
  gap: 1.5rem;
}

.header__nav a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: rgba(30, 22, 80, 0.5);
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.3s;
}

.header__nav a:hover {
  color: rgba(25, 18, 70, 0.8);
}

.header__nav a.active {
  color: rgba(25, 18, 70, 0.88);
}

/* Article layout: main + margin */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2rem;
  flex: 1;
  min-width: 0;
}

.article-layout > * {
  min-width: 0;
}

/* Article meta */
.article-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: rgba(50, 40, 130, 0.6);
  margin-bottom: 0.8vh;
}

.article-tag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: 3px;
  color: #3a2d8c;
  background: rgba(50, 40, 130, 0.1);
  letter-spacing: 0.06em;
  margin-bottom: 1vh;
}

.article-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 600;
  color: rgba(25, 18, 70, 0.92);
  line-height: 1.3;
  margin-bottom: 2.5vh;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Abstract / system-prompt style */
.article-abstract {
  border-left: 2px solid rgba(50, 40, 130, 0.35);
  padding-left: 1rem;
  margin-bottom: 3.5vh;
  font-size: 0.9rem;
  color: rgba(25, 18, 70, 0.6);
  line-height: 1.75;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Body prose */
.article-body {
  line-height: 1.78;
  font-size: 0.95rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.article-body p {
  margin-bottom: 1.6em;
}

.article-body h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: rgba(25, 18, 70, 0.88);
  margin-top: 2.5em;
  margin-bottom: 0.8em;
  line-height: 1.3;
}

.article-body h3 {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: rgba(25, 18, 70, 0.8);
  margin-top: 2em;
  margin-bottom: 0.6em;
}

/* Inline note marker */
.note-ref {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem;
  color: rgba(50, 40, 130, 0.6);
  vertical-align: super;
  cursor: pointer;
  transition: color 0.2s;
  margin: 0 1px;
}

.note-ref:hover {
  color: #615eed;
}

.note-ref.active {
  color: #615eed;
}

/* Margin notes */
.margin-notes {
  padding-top: 0;
}

.margin-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: rgba(30, 22, 80, 1);
  line-height: 1.6;
  margin-bottom: 2rem;
  padding-left: 0.8rem;
  border-left: 1px solid rgba(30, 22, 80, 0.15);
  transition: color 0.3s, border-color 0.3s;
}

.margin-note.highlight {
  color: rgba(30, 22, 80, 0.7);
  border-left-color: rgba(80, 60, 200, 0.4);
}

.margin-note__label {
  display: block;
  font-weight: 500;
  color: rgba(50, 40, 130, 1);
  margin-bottom: 0.3em;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Math blocks */
.math-block {
  margin: 1.5em 0;
  padding: 1.2rem 0;
  text-align: center;
  overflow-x: auto;
  max-width: 100%;
}

/* Inline math */
.math-inline .katex {
  font-size: 0.95em;
}

/* Blockquote */
.article-body blockquote {
  border-left: 2px solid rgba(50, 40, 130, 0.2);
  padding-left: 1rem;
  margin: 1.5em 0;
  color: rgba(25, 18, 70, 0.6);
  font-style: italic;
}

/* Links */
.article-body a {
  color: rgba(80, 60, 200, 0.8);
  text-decoration: none;
  border-bottom: 1px solid rgba(80, 60, 200, 0.2);
  transition: all 0.2s;
}

.article-body a:hover {
  color: rgba(80, 60, 200, 1);
  border-bottom-color: rgba(80, 60, 200, 0.5);
}

/* Back link & footer */
.article-footer {
  margin-top: 4vh;
  padding-top: 2vh;
  border-top: 1px solid rgba(30, 20, 80, 0.06);
}

.back-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: rgba(50, 40, 130, 0.5);
  text-decoration: none;
  transition: color 0.3s;
}

.back-link:hover {
  color: rgba(50, 40, 130, 0.8);
}

.footer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding-top: 1.2vh;
  border-top: 1px solid rgba(30, 22, 80, 0.08);
  margin-top: 3vh;
  padding-bottom: 0;
}

.footer a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: rgba(30, 22, 80, 0.4);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.3s;
}

.footer a:hover {
  color: rgba(25, 18, 70, 0.75);
}

/* Page transition overlay */
#page-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(237, 232, 220, 0.92);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

#page-transition.active {
  opacity: 1;
  pointer-events: all;
}

/* Dissolve — "paper soaking into water" when returning home */
.page.dissolve {
  filter: blur(8px);
  opacity: 0;
  transform: scale(0.985);
  transition: filter 0.55s ease-out, opacity 0.55s ease-out, transform 0.55s ease-out;
}

#page-transition.ocean {
  background: linear-gradient(180deg, rgba(130, 140, 210, 0.35) 0%, rgba(100, 115, 210, 0.18) 100%);
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.55s ease-out;
}

/* Inline note */
.note-inline {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: rgba(30, 22, 80, 0.5);
  background: rgba(30, 22, 80, 0.03);
  padding: 0.6rem 0.8rem;
  border-radius: 3px;
  margin: 0.8em 0;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 780px) {
  .page {
    padding: 3vh 1.5rem;
  }

  .article-layout {
    grid-template-columns: 1fr;
  }

  .margin-notes {
    display: none;
  }

  .code-block pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .math-block {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .note-inline {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: rgba(30, 22, 80, 0.5);
    background: rgba(30, 22, 80, 0.03);
    padding: 0.6rem 0.8rem;
    border-radius: 3px;
    margin: 0.8em 0;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  .header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .footer {
    flex-wrap: wrap;
  }
}

@media (min-width: 781px) {
  .note-inline {
    display: none;
  }
}
