/* ============================================
   THE CHRONICLE - Philip Rugamba
   Two-column layout. Lines. Reads real.
   ============================================ */

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

:root {
  --color-bg: #faf9f7;
  --color-text: #1d1d1d;
  --color-text-secondary: #555;
  --color-text-light: #888;
  --color-border: #e5e3df;
  --color-line: #ddd9d3;
  --color-link: #1d1d1d;
  --color-link-hover: #000;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --sidebar-width: 220px;
}

html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

a:hover {
  text-decoration-color: var(--color-text);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Two-Column Layout --- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  border-right: 1px solid var(--color-line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-inner {
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.site-name {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--color-text);
  display: block;
  margin-bottom: 0.75rem;
}

.site-name:hover {
  color: var(--color-text);
}

.sidebar-bio {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-bottom: 2rem;
}

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

.sidebar-nav a {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--color-text-light);
  text-decoration: none;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

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

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
}

.sidebar-copy {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--color-text-light);
}

/* --- Content --- */
.content {
  padding: 2.5rem 3rem 4rem;
  max-width: 720px;
}

/* --- Homepage Intro --- */
.intro {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-line);
}

.intro h1 {
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.45;
  margin-bottom: 1rem;
}

.intro p {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* --- Post List --- */
.post-list {
  list-style: none;
}

.post-list li {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

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

.post-link {
  text-decoration: none;
  display: block;
}

.post-link:hover h2 {
  color: #000;
}

.post-link:hover .post-excerpt {
  color: var(--color-text);
}

.post-meta {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--color-text-light);
  margin-bottom: 0.3rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.post-tag {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.post-link h2 {
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.4;
  margin-bottom: 0.35rem;
  transition: color 0.15s;
}

.post-excerpt {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  transition: color 0.15s;
}

/* --- Divider between sections --- */
.section-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin-top: 3rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-line);
}

.section-label:first-child {
  margin-top: 0;
}

/* --- Mondrian Grid --- */
.mondrian {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto;
  border: 1px solid var(--color-line);
  margin-bottom: 1rem;
}

.m-cell {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-right: 1px solid var(--color-line);
  border-bottom: 1px solid var(--color-line);
  transition: background 0.2s;
}

.m-cell:hover {
  background: var(--color-border);
  text-decoration: none;
}

.m-cell:nth-child(2),
.m-cell.m-wide {
  border-right: none;
}

.m-cell:nth-child(3),
.m-cell:nth-child(4) {
  border-bottom: none;
}

.m-tall {
  grid-row: span 2;
}

.m-wide {
  grid-column: span 2;
}

.m-thumb {
  flex: 1;
  min-height: 120px;
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--color-line);
}

.m-tall .m-thumb {
  min-height: 0;
}

.m-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.m-thumb span {
  font-family: var(--font-ui);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-light);
  letter-spacing: 0.05em;
}

.m-info {
  padding: 0.9rem 1rem 1rem;
}

.m-tag {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--color-text-light);
  display: block;
  margin-bottom: 0.25rem;
}

.m-info h2 {
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  color: var(--color-text);
}

.m-info p {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* --- Article Page --- */
.article-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-line);
}

.article-header .post-meta {
  margin-bottom: 1rem;
}

.article-header h1 {
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.article-header .article-intro {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.article-body p {
  margin-bottom: 1.4rem;
  font-size: 1rem;
  line-height: 1.8;
}

.article-body h2 {
  font-size: 1.25rem;
  font-weight: 400;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.35;
}

.article-body h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.article-body blockquote {
  border-left: 1px solid var(--color-line);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
}

.article-body blockquote p {
  font-style: italic;
  color: var(--color-text-secondary);
}

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

.article-body li {
  margin-bottom: 0.4rem;
  line-height: 1.7;
}

.article-body code {
  font-size: 0.88em;
  background: #eee;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--color-line);
  margin: 2.5rem 0;
}

/* --- Back link --- */
.back-link {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--color-text-light);
  text-decoration: none;
  margin-bottom: 2rem;
}

.back-link:hover {
  color: var(--color-text);
}

.back-link::before {
  content: '\2190\00a0';
}

/* --- About Page --- */
.about-content p {
  margin-bottom: 1.4rem;
  font-size: 1rem;
  line-height: 1.8;
}

.about-content h2 {
  font-size: 1.25rem;
  font-weight: 400;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

/* --- Toggle Switch --- */
.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--color-border);
  border-radius: 10px;
  position: relative;
  transition: background 0.3s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-track {
  background: #555;
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
  background: #fff;
}

/* --- Dark Mode --- */
body.dark {
  --color-bg: #111;
  --color-text: #d4d4d4;
  --color-text-secondary: #888;
  --color-text-light: #555;
  --color-border: #262626;
  --color-line: #2a2a2a;
  --color-link: #d4d4d4;
  --color-link-hover: #fff;
}

body.dark .site-name {
  color: #e5e5e5;
}

body.dark .intro h1 {
  color: #e5e5e5;
}

body.dark .post-link:hover h2 {
  color: #fff;
}

body.dark .post-link:hover .post-excerpt {
  color: #d4d4d4;
}

body.dark .article-body code {
  background: #1e1e1e;
  color: #aaa;
}

body.dark .toggle-track {
  background: #333;
}

body.dark .toggle-switch input:checked + .toggle-track {
  background: #d4d4d4;
}

body.dark .toggle-switch input:checked + .toggle-track .toggle-thumb {
  background: #111;
}

body.dark .m-thumb {
  background: #1a1a1a;
}

body.dark .m-thumb span {
  color: #333;
}

body.dark .m-cell:hover {
  background: #1a1a1a;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-line);
  }

  .sidebar-inner {
    padding: 1.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1.5rem;
  }

  .site-name {
    margin-bottom: 0;
  }

  .sidebar-bio {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    gap: 1rem;
    margin-bottom: 0;
  }

  .sidebar-footer {
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
  }

  .sidebar-copy {
    display: none;
  }

  .content {
    padding: 2rem 1.5rem 3rem;
  }

  .intro h1 {
    font-size: 1.35rem;
  }

  .article-header h1 {
    font-size: 1.6rem;
  }

  .mondrian {
    grid-template-columns: 1fr;
  }

  .m-tall { grid-row: span 1; }
  .m-wide { grid-column: span 1; }

  .m-cell {
    border-right: none;
    border-bottom: 1px solid var(--color-line);
  }

  .m-cell:last-child {
    border-bottom: none;
  }
}
