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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: #111;
  background: #fff;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  border: 16px solid var(--page-border-color, #2d3748);
}

/* Shared column: aligns "Husain Ghadiali" with page content */
.layout {
  max-width: calc(720px + 3rem);
  margin: 0 auto;
  padding: 0 2rem 0 2rem;
  padding-right: 1rem;
}

/* Header: name top-left, nav right */
.site-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid #e5e5e5;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 400;
  color: #111;
  text-decoration: none;
}

.site-name:hover {
  text-decoration: underline;
}

.nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.nav a {
  color: #111;
  text-decoration: none;
  font-size: 1rem;
}

.nav a:hover {
  text-decoration: underline;
}

.nav .nav-current {
  text-decoration: underline;
}

.theme-toggle {
  padding: 0;
  margin: 0;
  margin-left: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  line-height: 0;
  vertical-align: middle;
  flex-shrink: 0;
}

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

/* State 1 (light mode): dark gray pill, knob left, white knob, black sun */
.theme-toggle-track {
  display: block;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #4a5568;
  position: relative;
  flex-shrink: 0;
}

/* State 2 (dark mode): white pill, knob right, black knob, white moon */
html[data-theme="dark"] .theme-toggle-track {
  background: #2d3748;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.theme-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  z-index: 1;
}

.theme-toggle-knob {
  transform: translateX(0);
}

.theme-toggle-knob svg {
  width: 10px;
  height: 10px;
}

.knob-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.knob-sun {
  display: flex;
  color: #111;
}

.knob-moon {
  display: none;
}

/* Dark mode: knob right, black knob, white moon */
html[data-theme="dark"] .theme-toggle-knob {
  background: #111;
  transform: translateX(18px);
}

html[data-theme="dark"] .knob-moon {
  display: flex;
  color: #fff;
}

html[data-theme="dark"] .knob-sun {
  display: none;
}

/* Dark mode */
html[data-theme="dark"] body {
  color: #e5e5e5;
  background: #111;
  border-color: var(--page-border-color, #2d3748);
}

html[data-theme="dark"] .site-header {
  border-bottom-color: #333;
}

html[data-theme="dark"] .site-name,
html[data-theme="dark"] .nav a,
html[data-theme="dark"] .essay-list a {
  color: #e5e5e5;
}

html[data-theme="dark"] .site-name:hover,
html[data-theme="dark"] .nav a:hover,
html[data-theme="dark"] .essay-list a:hover {
  color: #fff;
}

/* Main content: uses same .layout column as header */
.content {
  flex: 1;
  padding: 2rem 0 4rem 0;
}

.essay-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.essay-list li {
  margin: 0;
  padding: 0.35em 0;
  border-bottom: 1px solid transparent;
}

.essay-list a {
  color: #111;
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1.4;
  display: inline-block;
}

.essay-list a:hover {
  text-decoration: underline;
}

/* Inner pages (about, connect) */
.content--page {
  padding-top: 2.5rem;
}

.content--page h1 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0 0 1rem;
}

.page-title-list {
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.4;
  margin: 0 0 1rem;
}

.article-page .page-title-list {
  font-size: 0.85rem;
}

.content--page p {
  margin: 0 0 1rem;
  max-width: 55ch;
}

.article-body {
  max-width: 55ch;
}

.article-body p {
  margin: 0 0 1rem;
}

.article-body p:last-child {
  margin-bottom: 0;
}

.essay-list--musings {
  margin-top: 1.5rem;
}

.connect-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.connect-list li {
  margin: 0;
  padding: 0.2em 0;
}

.connect-list a {
  color: #0969da;
  text-decoration: none;
}

.connect-list a:hover {
  color: #0550ae;
}

html[data-theme="dark"] .connect-list a {
  color: #58a6ff;
}

html[data-theme="dark"] .connect-list a:hover {
  color: #79c0ff;
}

.connect-label {
  display: inline-block;
  min-width: 5.5em;
  margin-right: 0.25em;
}

/* Footer */
.site-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid #e5e5e5;
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
}

.site-footer .nav {
  justify-content: flex-start;
}

/* Responsive */
@media (max-width: 640px) {
  .layout {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .site-footer {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .essay-list a {
    font-size: 1.1rem;
  }
}
