:root {
  --bg: #0f172a;
  --fg: #e0e7ff;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #38bdf8;
  --sidebar-width: 250px;
  --transition-speed: 0.3s;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

/* Sidebar */
#sidebar {
  background: #172a4d;
  width: var(--sidebar-width);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed);
  overflow: hidden;
}

#sidebar header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--fg);
  white-space: nowrap;
}

#sidebar nav {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  transition: opacity var(--transition-speed), height var(--transition-speed);
  overflow: hidden;
}

#sidebar nav.hidden {
  opacity: 0;
  height: 0;
  padding: 0;
  pointer-events: none;
}

#sidebar nav a {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  color: var(--muted);
  white-space: nowrap;
  border-left: 4px solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
}

#sidebar nav a:hover,
#sidebar nav a:focus {
  background-color: #1e3a8a;
  color: var(--accent);
  border-left-color: var(--accent);
  outline: none;
}

/* Toggle button */
#toggle-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.75rem;
  user-select: none;
  transition: transform 0.3s;
  display: none;
}
#toggle-btn.collapsed {
  transform: rotate(180deg);
}

/* Main content */
main {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 2.5rem;
  background: var(--bg);
  color: var(--fg);
  min-width: 0;
  max-width: 100%;
}

.post {
  max-width: 42rem;
}

.post h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.post p,
.post ul {
  margin-bottom: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post ul {
  padding-left: 1.5rem;
}

.post li {
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

h1, h2, h3 {
  color: var(--fg);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 2rem;
}

.actions a {
  display: inline-block;
  margin-right: 1.25rem;
  font-weight: 500;
  color: var(--accent);
}
.actions a:hover {
  text-decoration: underline;
}

.section {
  padding: 3rem 0;
  border-top: 1px solid var(--line);
  max-width: 100%;
  overflow-x: hidden;
}

.section h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.section p {
  color: var(--muted);
  max-width: 40rem;
  margin: 0 0 1.25rem;
}

.list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

#home-posts {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Featured posts layout for homepage */
.featured-posts {
  display: grid;
  grid-template-columns: 60% 40%;
  gap: 1.25rem;
  margin-top: 1.5rem;
  width: 100%;
  overflow-x: hidden;
}

.featured-posts .card {
  width: 100%;
  min-width: 0;
}

.featured-posts-secondary {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
  width: 100%;
}

.featured-posts-secondary .card {
  flex: 1;
  min-width: 0;
}

.featured-primary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.featured-primary h3,
.featured-primary p {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.featured-primary h3 {
  font-size: 1.35rem;
}

.featured-primary p {
  font-size: 1rem;
}

.card {
  padding: 1.25rem 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1e293b;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.card p.meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  body {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: #172a4d;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
  }

  #sidebar.active {
    transform: translateX(0);
  }

  main {
    margin-top: 0;
    padding: 4rem 1rem 1.5rem;
    overflow: visible;
  }

  /* Adjust toggle button position */
  #toggle-btn {
    display: block;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    font-size: 2rem;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
  }

  /* Mobile-only scroll lock while sidebar is open */
  body.sidebar-open {
    overflow: hidden;
    height: 100vh;
  }

  body.sidebar-open main {
    overflow: hidden;
  }

  /* Make nav links bigger for easier touch */
  #sidebar nav a {
    padding: 1rem 1.5rem;
    font-size: 1.25rem;
  }

  /* Stack featured posts vertically on mobile */
  .featured-posts {
    grid-template-columns: 1fr;
  }
}
