/* ============================================
   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: 180px;
  --list-width: 420px;
}

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;
}

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

.layout-full {
  grid-template-columns: var(--sidebar-width) 1fr;
}

/* --- 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 {
  text-decoration: none;
  display: block;
  margin-bottom: 0.75rem;
}

.site-name img {
  width: 48px;
  height: auto;
}

.site-name:hover {
  opacity: 0.8;
}

body.dark .site-name img {
  filter: invert(1);
}

.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-social {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-light);
  text-decoration: none;
  transition: color 0.15s;
}

.sidebar-social:hover {
  color: var(--color-text);
}

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

/* --- Post List Column --- */
.post-list-column {
  border-right: 1px solid var(--color-line);
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 1.5rem 0;
}

.post-list-column .section-label {
  margin: 0 1.25rem 1rem;
  padding-bottom: 0.6rem;
}

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

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

.post-list-column .post-link {
  display: block;
  padding: 0.7rem 1.25rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.15s;
}

.post-list-column .post-link:hover {
  background: var(--color-border);
}

.post-list-column .post-link.active {
  background: var(--color-border);
  border-left-color: var(--color-text);
}

.post-list-column .post-link h2 {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 0.2rem;
  transition: color 0.15s;
}

.post-list-column .post-link .post-excerpt {
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--color-text-light);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.post-list-column .post-meta {
  font-size: 0.68rem;
  margin-bottom: 0;
  gap: 0.5rem;
}

/* --- Reading Pane --- */
.reading-pane {
  overflow-y: auto;
  height: 100vh;
  padding: 2.5rem 3rem 4rem;
}

.reading-pane-inner {
  max-width: 680px;
}

@media (min-width: 769px) {
  .reading-pane-inner {
    max-width: none;
    width: 80%;
  }
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--color-text-light);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

/* --- Content (standalone post pages) --- */
.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;
}

.project-tag {
  font-size: 0.68rem;
  color: #7a6e5f;
  letter-spacing: 0.02em;
}

.project-tag::before {
  content: '#';
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.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;
}

/* --- Image Placeholders (used in posts) --- */
.m-thumb {
  min-height: 120px;
  background: var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.m-thumb span {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--color-text-light);
}

/* --- 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;
}

.article-body figure {
  margin: 2rem 0;
}

.article-body figcaption {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--color-text-light);
  margin-top: 0.5rem;
}

/* --- 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;
}

.about-content h4 {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* --- 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 .project-tag {
  color: #8a7e6f;
}

body.dark .post-list-column .post-link:hover {
  background: #1a1a1a;
}

body.dark .post-list-column .post-link.active {
  background: #1a1a1a;
  border-left-color: #d4d4d4;
}

/* --- Portfolio Pages --- */
.portfolio-page {
  max-width: none;
  padding: 2.5rem 3rem 4rem;
}

.portfolio-page h1 {
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}

.portfolio-page .page-intro {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-line);
}

.page-intro {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-line);
}

/* --- Showcase Item --- */
.showcase-item {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-line);
}

.showcase-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.showcase-embed {
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-border);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.showcase-embed iframe,
.showcase-embed object {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.showcase-embed.tall {
  aspect-ratio: 4 / 3;
}

.showcase-embed.short {
  aspect-ratio: 16 / 7;
}

.showcase-info {
  display: flex;
  gap: 2rem;
  align-items: baseline;
}

.showcase-info h3 {
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.35;
  min-width: 200px;
  flex-shrink: 0;
}

.showcase-info p {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--color-text-secondary);
  max-width: 500px;
}

.showcase-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.showcase-tags span {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 500;
  color: #7a6e5f;
  letter-spacing: 0.02em;
  background: var(--color-border);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
}

/* --- Portfolio Grid (for items without embeds) --- */
.showcase-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-line);
}

.showcase-grid:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.grid-item h3 {
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
}

.grid-item p {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.grid-item .showcase-tags {
  margin-top: 0.5rem;
}

/* --- Nav Section Label --- */
.nav-label {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin-top: 1.25rem;
  margin-bottom: 0.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-line);
}

.nav-label:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* --- Dark mode portfolio --- */
body.dark .showcase-embed {
  background: #1a1a1a;
  border-color: #262626;
}

body.dark .showcase-tags span {
  color: #8a7e6f;
  background: #1e1e1e;
}

/* --- 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;
  }

  .reading-pane {
    display: none;
  }

  .post-list-column {
    height: auto;
    position: relative;
    border-right: none;
    padding: 2rem 1.5rem 3rem;
  }

  .post-list-column .post-link {
    padding: 0;
    border-left: none;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
  }

  .post-list-column .post-link:hover {
    background: none;
  }

  .post-list-column .post-link.active {
    background: none;
    border-left: none;
  }

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

  .post-list-column .post-link h2 {
    font-size: 1.15rem;
    font-weight: 400;
    margin-bottom: 0.35rem;
  }

  .post-list-column .post-link .post-excerpt {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    display: block;
    -webkit-line-clamp: unset;
  }

  .post-list-column .post-meta {
    font-size: 0.72rem;
    margin-bottom: 0.3rem;
  }

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

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

  .portfolio-page {
    padding: 2rem 1.5rem 3rem;
  }

  .showcase-info {
    flex-direction: column;
    gap: 0.5rem;
  }

  .showcase-info h3 {
    min-width: unset;
  }

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

  .nav-label {
    display: none;
  }

}
