/* ========================================
   calumbest.net — Main Stylesheet
   ======================================== */

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

/* Base */
:root {
  --font-body: 'Nunito', sans-serif;
  --font-size-body: 18px;
  --font-size-small: 14px;
  --font-size-h1: 28px;
  --font-size-h2: 22px;
  --font-size-h3: 19px;
  --line-height: 1.7;
  --color-text: #333;
  --color-text-light: #666;
  --color-link: #1a6;
  --color-link-hover: #148;
  --color-bg: #fff;
  --color-border: #e0e0e0;
  --color-sidenote-bg: #fafafa;
  --content-width: 650px;
  --sidenote-width: 250px;
  --sidenote-gap: 30px;
}

html {
  font-size: var(--font-size-body);
}

body {
  font-family: var(--font-body);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.site-header {
  max-width: var(--content-width);
  margin: 2rem auto 0;
  padding: 0 1rem;
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.site-footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  color: var(--color-text-light);
  font-size: var(--font-size-small);
}

/* Navigation */
nav {
  font-size: var(--font-size-small);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

nav a {
  color: var(--color-text-light);
  text-decoration: none;
}

nav a:hover,
nav a.current {
  color: var(--color-text);
}

.nav-sep {
  color: var(--color-border);
  margin: 0 0.4em;
}

/* Home / Post List */
.home h1 {
  font-size: var(--font-size-h1);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.site-desc {
  color: var(--color-text-light);
  margin-bottom: 2rem;
}

.post-list {
  list-style: none;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

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

.post-list time {
  color: var(--color-text-light);
  font-size: var(--font-size-small);
  white-space: nowrap;
  margin-left: 1rem;
}

/* Post */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: var(--font-size-h1);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.post-meta {
  color: var(--color-text-light);
  font-size: var(--font-size-small);
}

.last-edited {
  color: var(--color-text-light);
}

/* Post Content */
.post-content h2 {
  font-size: var(--font-size-h2);
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post-content h3 {
  font-size: var(--font-size-h3);
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.3rem;
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 1rem;
  color: var(--color-text-light);
  margin-bottom: 1.2rem;
}

.post-content code {
  font-size: 0.9em;
  background: var(--color-sidenote-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-sidenote-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.2rem;
}

.post-content pre code {
  background: none;
  padding: 0;
}

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

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

.post-content img {
  max-width: 100%;
  height: auto;
}

/* Links in general */
a {
  color: var(--color-link);
}

/* Page content (about, etc.) */
.page-content p {
  margin-bottom: 1.2rem;
}

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

/* Footnotes (base — before JS converts to sidenotes) */
.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-small);
  color: var(--color-text-light);
}

.footnotes ol {
  padding-left: 1.5rem;
}

/* Make footnote ref numbers smaller and tighter */
.post-content sup {
  font-size: 0.65em;
  line-height: 0;
  vertical-align: super;
}

.post-content sup a.footnote-ref {
  text-decoration: none;
  color: var(--color-link);
}

.footnotes li {
  margin-bottom: 0.5rem;
}

/* Sidenotes (injected by JS on wide screens) */
.sidenote {
  position: absolute;
  right: calc(-1 * var(--sidenote-width) - var(--sidenote-gap));
  width: var(--sidenote-width);
  font-size: var(--font-size-small);
  line-height: 1.5;
  color: var(--color-text-light);
}

.sidenote-number {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--color-link);
  margin-right: 0.2em;
  vertical-align: super;
}

/* When sidenotes are active, make the post content positioned for absolute children */
.post-content.has-sidenotes {
  position: relative;
}

/* Hide original footnote section when sidenotes are active */
.post-content.has-sidenotes .footnotes {
  display: none;
}

/* Post Actions */
.post-actions {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.copy-markdown-btn {
  font-family: var(--font-body);
  font-size: var(--font-size-small);
  color: var(--color-text-light);
  background: none;
  border: 1px solid var(--color-border);
  padding: 0.4em 0.8em;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-markdown-btn:hover {
  color: var(--color-text);
  border-color: var(--color-text-light);
}

.copy-markdown-btn.copied {
  color: var(--color-link);
  border-color: var(--color-link);
}

/* Post Navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-small);
}

.post-nav a {
  color: var(--color-text-light);
  text-decoration: none;
  max-width: 45%;
}

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

.post-nav-next {
  margin-left: auto;
  text-align: right;
}

/* Page (About, etc.) */
.page h1 {
  font-size: var(--font-size-h1);
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Responsive: sidenotes need wide viewport */
@media (min-width: 1040px) {
  .site-header,
  main,
  .site-footer {
    /* Shift content left to make room for sidenote margin */
    margin-left: calc(50% - var(--content-width) / 2 - var(--sidenote-width) / 2);
  }
}

/* Small screens */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .post-list li {
    flex-direction: column;
    gap: 0;
  }

  .post-list time {
    margin-left: 0;
  }
}
