@import url('https://fonts.googleapis.com/css2?family=Caveat&family=Source+Sans+Pro:wght@300;400&display=swap');

@font-face {
  font-family: 'Charter';
  font-style: normal;
  src: url('/fonts/XCharter.woff2') format('woff2');
  font-display: swap;
  font-weight: 400;
}

@font-face {
  font-family: 'Charter';
  font-style: normal;
  src: url('/fonts/XCharter-Bold.woff2') format('woff2');
  font-display: swap;
  font-weight: 600;
}

:root {
  --serif: "Charter", serif;
  --sans: "Source Sans Pro", sans-serif;

  --text-color: #333;
  --link-color: #0066cc;
  --muted-color: #666;
  --border-color: #333;
  --border-color-light: #ddd;
  --code-bg: #f4f4f4;
  --table-header-bg: #f9f9f9;
  --sidebar-bg: white;
  --bg-gradient: linear-gradient(to bottom, rgba(150, 150, 100, 0.1) 0%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 200, 0.1) 100%);
}

[data-theme="dark"] {
  color-scheme: dark;
  --text-color: #dcdcdc;
  --link-color: #6cb2ff;
  --muted-color: #9a9a9a;
  --border-color: #4a4a4a;
  --border-color-light: #333;
  --code-bg: #232326;
  --table-header-bg: #1e1e21;
  --sidebar-bg: #18181a;
  /* Opaque, smooth gradient — the light-mode recipe relies on the
     browser's white canvas showing through translucent stops, which
     turns to a muddy grey with a visible seam once inverted. */
  --bg-gradient: linear-gradient(to bottom, #1c1c1e 0%, #141416 100%);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  padding: 2rem 5%;
  color: var(--text-color);
  background: var(--bg-gradient);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.title {
  text-align: center;
  margin-bottom: 3rem;
  padding-top: 2rem;
}

.title h1 {
  font-size: 2.5em;
  font-weight: 400;
  margin: 0;
  letter-spacing: 0.05em;
  font-variant: small-caps;
}

.header {
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 2rem 0;
  margin: 2rem 0 3rem 0;
  display: flex;
  gap: 3rem;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}

.header-left {
  flex: 1;
}

.header-right {
  width: 280px;
  flex-shrink: 0;
}

.header h3 {
  font-size: 0.95em;
  font-weight: 800;
  margin: 0 0 1rem 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  font-variant: small-caps;
}

.header h4 {
  font-size: 0.9em;
  font-weight: 500;
  margin: 1.5rem 0 0.8rem 0;
  font-variant: small-caps;
}

.header p {
  font-size: 0.95em;
  line-height: 1.5;
  margin: 0.5em 0;
}

.main-content {
  max-width: 800px;
  margin: 0 auto;
}

.content-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 3rem;
}

main.left-column {
  flex: 1;
  min-width: 0;
}

aside.right-column {
  width: 280px;
  flex-shrink: 0;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto;
  padding: 4rem 1.5rem 2rem 1.5rem;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 100;
  border-left: 1px solid var(--border-color-light);
}

body.sidebar-open aside.right-column {
  transform: translateX(0);
}

article {
  line-height: 1.7;
}

article p {
  margin: 1em 0;
}

article p + p {
  text-indent: 1.5em;
}

h1 {
  font-size: 1.8em;
  font-weight: 400;
  margin: 1.5em 0 0.5em 0;
  line-height: 1.3;
  font-variant: small-caps;
}

h2 {
  font-size: 1.4em;
  font-weight: 400;
  margin: 1.5em 0 0.5em 0;
  font-variant: small-caps;
}

h3 {
  font-size: 1.1em;
  font-weight: 500;
  margin: 1.3em 0 0.5em 0;
}

h4 {
  font-size: 1em;
  font-weight: 500;
  margin: 1.2em 0 0.5em 0;
  font-variant: small-caps;
}

a {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid var(--link-color);
}

a:hover {
  opacity: 0.7;
}

/* Home button */
.home-button {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 101;
  font-size: 1.5em;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  border-bottom: 1px solid var(--link-color);
}

.home-button:hover {
  opacity: 0.7;
}

/* Sidebar toggle button */
.sidebar-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 101;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.sidebar-toggle span {
  width: 100%;
  height: 2px;
  background: var(--border-color);
  display: block;
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}

body.sidebar-open .sidebar-toggle span:nth-child(1) {
  transform: rotate(45deg) translate(0.5rem, 0.5rem);
}

body.sidebar-open .sidebar-toggle span:nth-child(2) {
  opacity: 0;
}

body.sidebar-open .sidebar-toggle span:nth-child(3) {
  transform: rotate(-45deg) translate(0.5rem, -0.5rem);
}

/* Sidebar styling */
.sidebar-section {
  margin-bottom: 2.5rem;
}

.sidebar-section h3 {
  font-size: 1em;
  font-weight: 800;
  margin: 0 0 1rem 0;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
  font-variant: small-caps;
}

.sidebar-section h4 {
  font-size: 0.95em;
  font-weight: 500;
  margin: 1.5rem 0 0.8rem 0;
  font-variant: small-caps;
}

.sidebar-section p {
  font-size: 0.95em;
  line-height: 1.5;
  margin: 0.5em 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.sidebar-nav a {
  font-size: 0.95em;
}

/* Home page navigation */
.home-nav {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color-light);
}

.home-nav a {
  font-size: 0.95em;
}

/* Post meta */
.post-meta {
  color: var(--muted-color);
  font-size: 0.9em;
  margin-bottom: 2rem;
}

/* Section list (recent writings) */
.section-list {
  margin: 2rem 0;
}

.section-item {
  margin-bottom: 1.5rem;
}

.section-link {
  border-bottom: 1px dotted var(--muted-color);
  font-size: 1em;
}

.metadata {
  color: var(--muted-color);
  font-size: 0.9em;
  margin-left: 0.5rem;
}

/* Code blocks */
code {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 5px;
  line-height: 1.4;
}

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

/* Lists */
ul, ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

li {
  margin: 0.5rem 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

th, td {
  border-bottom: 1px solid var(--border-color-light);
  padding: 0.8rem;
  text-align: left;
}

th {
  background: var(--table-header-bg);
  font-weight: 500;
}

/* Details/summary */
details {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--table-header-bg);
  border-radius: 5px;
}

summary {
  cursor: pointer;
  font-weight: 500;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color-light);
  color: var(--muted-color);
  font-size: 0.9em;
}

/* 404 page */
.not-found {
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 2rem;
  }

  .header-right {
    width: 100%;
  }

  .content-wrapper {
    flex-direction: column;
    gap: 2rem;
  }

  aside.right-column {
    width: 85%;
    max-width: 320px;
  }

  .title h1 {
    font-size: 1.8em;
  }

  body {
    padding: 1.5rem 5%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 1rem 4%;
    font-size: 15px;
  }

  .title h1 {
    font-size: 1.5em;
  }

  h1 {
    font-size: 1.3em;
  }

  h2 {
    font-size: 1.1em;
  }
}

/* Sidenotes - handwritten margin notes */
.sidenote {
  font-family: 'Caveat', sans-serif;
  position: absolute;
  width: 10rem;
  margin-left: -13rem;
  font-size: 15px;
  line-height: 1.1em;
  transform: rotateZ(-5deg);
}

.sidenote.rightnote {
  margin-left: 46rem;
}

.sidenote.straight {
  transform: rotateZ(-2deg);
}

/* Dark mode toggle */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 101;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  font-size: 1.3em;
  line-height: 1;
  color: var(--text-color);
}

.theme-toggle:hover {
  opacity: 0.7;
}

.theme-toggle .icon-dark {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-dark {
  display: inline;
}

/* On non-home pages the sidebar toggle already occupies top-right, so push
   the theme toggle to the left of it */
body:not(.is-home) .theme-toggle {
  right: 4rem;
}
