/* ========== Reset & Base ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Roboto", sans-serif;
  line-height: 1.6;
  background-color: #f5f5f5;
  font-size: 16px;
  color: #2a2a2a;
}

/* ========== Navbar (mobile-first: top bar) ========== */
#navbar {
  position: static;
  /* stack on top for mobile */
  width: 100%;
  background-color: #333;
  color: #fff;
  padding: 14px 16px;
}

#navbar header {
  font-size: clamp(1.1rem, 3.8vw, 1.5rem);
  margin-bottom: 10px;
  color: #fff;
}

#navbar a {
  display: block;
  color: #fff;
  text-decoration: none;
  margin-bottom: 8px;
  font-weight: 700;
  padding: 6px 0;
}

#navbar a:hover {
  background-color: #555;
  padding-left: 5px;
}

/* ========== Main Content (mobile: full-bleed cards) ========== */
#main-doc {
  /* remove side padding on mobile so sections can touch edges */
  padding: 0;
  max-width: none;
  width: 100%;
}

/* Section cards */
.main-section {
  /* full-bleed on mobile */
  width: 100%;
  background-color: #fefefe;
  padding: 18px clamp(16px, 4.5vw, 22px);
  margin: 0 0 18px 0;
  /* no side gutters on mobile */
  border-radius: 0;
  /* edge-to-edge look */
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid #ddd;
}

/* Headings vs paragraphs */
.main-section header {
  font-size: clamp(1.3rem, 4.8vw, 1.8rem);
  color: #2f2f2f;
  margin-bottom: 10px;
  border-bottom: 2px solid #333;
  padding-bottom: 5px;
}

.main-section p {
  color: #515151;
  margin: 10px 0;
}

/* Inline code: wrap on small screens */
.main-section code {
  display: inline-block;
  background-color: #f0f0f0;
  color: #d63384;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  border-radius: 4px;
  margin-top: 5px;
  font-size: 0.95em;
  white-space: pre-wrap;
  word-break: break-word;
}

.main-section ul {
  margin-left: 20px;
}

.main-section li {
  margin-bottom: 5px;
  color: #2a2a2a;
}

/* ========== Small phones ========== */
@media (max-width: 360px) {
  body {
    font-size: 15px;
  }

  /* keep legible text */
  #navbar {
    text-align: left;
    padding: 12px 14px;
  }

  #navbar a {
    display: block;
    margin: 6px 0;
    padding: 4px 0;
  }

  .main-section {
    padding: 16px 14px;
  }
}

/* ========== Tablets / small laptops (bring back side padding) ========== */
@media (min-width: 601px) and (max-width: 768px) {
  #main-doc {
    padding: 16px;
  }

  /* light gutter on tablets */
  .main-section {
    border-radius: 8px;
    /* cards feel nicer with rounded corners when not full-bleed */
    margin: 0 0 20px 0;
  }
}

/* ========== Desktop: fixed left sidebar layout ========== */
@media (min-width: 769px) {
  #navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
  }

  #main-doc {
    margin-left: 270px;
    /* space for navbar */
    padding: 40px 60px;
    /* comfortable reading width */
    max-width: 1200px;
    width: calc(100% - 270px);
  }

  .main-section {
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}

/* ========== Extra niceties ========== */
/* Improve tap targets on touch */
@media (hover: none) and (pointer: coarse) {
  #navbar a {
    padding: 10px 0;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}