/* ============================================================
   smirby.com
   Three-column layout with Tufte-style sidenotes
   SFU palette: #A6192E (dark red) · #CC0633 (bright red)
   ============================================================ */

/* --- Variables & reset ------------------------------------ */
:root {
  --red:        #A6192E;
  --red2:       #CC0633;
  --text:       #333;
  --muted:      #555;
  --light:      #888;
  --bg:         #fafafa;
  --white:      #fff;
  --border:     #e4e4e4;
  --nav-w:      190px;
  --text-w:     58%;
  --note-w:     34%;
  --page-max:   1100px;
}

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

html { font-size: 17px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* --- Page structure --------------------------------------- */
.page-outer {
  max-width: var(--page-max);
  margin: 0 auto;
}

.page-body {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  padding: 0 1.5rem;
  gap: 0 2rem;
  min-height: calc(100vh - 120px);
}

/* --- Site header ------------------------------------------ */
.site-header {
  background: var(--red);
  color: white;
  padding: 1.6rem 2rem 1.2rem;
}

.site-header a {
  color: white;
  text-decoration: none;
}

.site-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.site-header .subtitle {
  font-size: 0.88rem;
  opacity: 0.88;
}

/* --- Navigation sidebar ----------------------------------- */
.site-nav {
  padding: 2.5rem 1.2rem 2rem 0;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: fit-content;
  align-self: start;
}

.site-nav ul { list-style: none; }

.site-nav li { margin-bottom: 0.5rem; }

.site-nav a {
  display: block;
  padding: 0.25rem 0.6rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--red);
  background: rgba(166, 25, 46, 0.07);
}

/* --- Main area -------------------------------------------- */
main {
  padding: 2.5rem 0 4rem;
  min-width: 0;
}

/* --- Post list -------------------------------------------- */
.post-summary {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

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

.post-summary h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.post-summary h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-summary h2 a:hover { color: var(--red); }

.post-meta {
  font-size: 0.8rem;
  color: var(--light);
  margin-bottom: 0.5rem;
}

.post-summary p {
  font-size: 0.94rem;
  color: var(--muted);
  max-width: 60ch;
}

/* --- Single article --------------------------------------- */
.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.article-header h1 {
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  max-width: var(--text-w);
}

/* Article body: constrain block elements to left portion,
   leaving right margin free for sidenotes */
.article-body { position: relative; }

.article-body > p,
.article-body > h2,
.article-body > h3,
.article-body > h4,
.article-body > ul,
.article-body > ol,
.article-body > blockquote,
.article-body > pre,
.article-body > hr {
  max-width: var(--text-w);
}

.article-body p { margin-bottom: 1.2rem; }

.article-body h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--red);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.article-body h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
}

.article-body a {
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid #d4a0a8;
}

.article-body a:hover {
  color: var(--red2);
  border-bottom-color: var(--red);
}

.article-body ul,
.article-body ol {
  padding-left: 1.6rem;
  margin-bottom: 1.2rem;
}

.article-body li { margin-bottom: 0.35rem; }

.article-body blockquote {
  border-left: 4px solid var(--red);
  padding: 0.6rem 1rem;
  margin: 1.5rem 0;
  color: var(--muted);
  background: rgba(166, 25, 46, 0.03);
  font-style: italic;
}

.article-body blockquote p { max-width: 100%; }

.article-body pre {
  background: #f4f4f4;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  border-radius: 4px;
  margin-bottom: 1.2rem;
}

.article-body code {
  background: #f0f0f0;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.88em;
}

.article-body pre code {
  background: none;
  padding: 0;
}

/* --- Sidenotes -------------------------------------------- */
/* Counter lives on the article body so numbers reset per article */
.article-body { counter-reset: sidenote-counter; }

.sidenote,
.marginnote {
  float: right;
  clear: right;
  margin-right: calc(-1 * (var(--note-w) + 3%));
  width: var(--note-w);
  margin-top: 0.15em;
  margin-bottom: 0.5em;
  font-size: 0.79rem;
  line-height: 1.55;
  color: var(--muted);
  vertical-align: baseline;
  position: relative;
}

.sidenote p,
.marginnote p {
  max-width: 100%;
  margin-bottom: 0.3rem;
}

.sidenote a,
.marginnote a { color: var(--red); }

/* Sidenote number in main text */
.sidenote-number { counter-increment: sidenote-counter; }

.sidenote-number::after {
  content: counter(sidenote-counter);
  font-size: 0.65rem;
  vertical-align: super;
  color: var(--red);
  font-weight: 600;
  margin-left: 0.05em;
}

/* Sidenote number at start of note */
.sidenote::before {
  content: counter(sidenote-counter) " ";
  font-size: 0.7rem;
  vertical-align: super;
  color: var(--red);
  font-weight: 600;
}

/* Margin note toggle icon (⊕) */
label.margin-toggle:not(.sidenote-number) {
  display: none;
  color: var(--red);
  cursor: pointer;
}

input.margin-toggle { display: none; }

/* --- Tags ------------------------------------------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.5rem;
  max-width: var(--text-w);
}

a.tag {
  background: var(--red);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.75rem;
  text-decoration: none;
  border-bottom: none;
}

a.tag:hover {
  background: var(--red2);
  color: white;
  border-bottom: none;
}

/* --- Page content (about, static) ------------------------- */
.page-content h1 {
  font-size: 1.7rem;
  margin-bottom: 1.5rem;
}

.page-content h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--red);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.page-content p { margin-bottom: 1.1rem; max-width: 60ch; }

.page-content a { color: var(--red); }

.page-content ul,
.page-content ol {
  padding-left: 1.6rem;
  margin-bottom: 1.1rem;
  max-width: 60ch;
}

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

/* --- Footer ----------------------------------------------- */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 1.2rem 2rem;
  font-size: 0.82rem;
  color: var(--light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-footer a {
  color: var(--red);
  text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

.footer-links {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 820px) {
  /* Stack nav above content */
  .page-body {
    grid-template-columns: 1fr;
    padding: 0 1rem;
  }

  .site-nav {
    display: flex;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 0 0.8rem;
    position: static;
    margin-bottom: 0.5rem;
  }

  .site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
  }

  .site-nav li { margin-bottom: 0; }

  /* Constrained widths go full-width */
  .article-header h1,
  .article-body > p,
  .article-body > h2,
  .article-body > h3,
  .article-body > h4,
  .article-body > ul,
  .article-body > ol,
  .article-body > blockquote,
  .article-body > pre,
  .tag-list {
    max-width: 100%;
  }

  /* Sidenotes collapse to inline toggles */
  label.margin-toggle:not(.sidenote-number) { display: inline; }

  .sidenote,
  .marginnote {
    display: none;
    float: left;
    clear: both;
    width: 95%;
    margin: 0.8rem 2.5%;
    position: relative;
  }

  .margin-toggle:checked + .sidenote,
  .margin-toggle:checked + .marginnote {
    display: block;
  }
}
