/* Projects */
main hr {
  border: none;
  border-top: 1.5px solid var(--card-line);
  margin: 32px 0;
}
/* Top Navbar */
.top-navbar {
  width: 100%;
  background: var(--topbar-bg);
  border-bottom: 2px solid var(--topbar-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-height);
  box-shadow: none; /* flat design */
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-left {
  display: flex;
  align-items: center;
  font-size: 1.1em;
  color: var(--heading);
}
.breadcrumb {
  font-weight: 500;
  letter-spacing: 0.5px;
}
.breadcrumb-sep {
  margin: 0 8px;
  color: var(--text-muted);
}
.navbar-right {
  display: flex;
  align-items: stretch; /* let buttons fill topbar height */
  gap: 0;              /* remove inner gaps */
  margin-right: -24px; /* extend to right edge (negate topbar padding) */
  border-left: 1px solid var(--topbar-line);
}
/* Icon-only buttons in top navbar */
.top-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: var(--topbar-height);
  padding: 0 16px;
  border-radius: 0;
  background: var(--topbar-bg);
  color: var(--text);
  border: none;
  border-left: 1px solid var(--topbar-line); /* divider between buttons */
  box-shadow: none;
  cursor: pointer;
  font-size: 18px;
}
.top-icon-btn:hover {
  background: var(--topbar-btn-hover);
}
.top-icon-btn:active {
  background: var(--topbar-btn-active);
}
.navbar-right .top-icon-btn:first-child {
  border-left: none; /* avoid double line with container left border */
}

/* =========================
  Theme variables
  ========================= */
:root {
  /* layout */
  --topbar-height: 48px;
  --sidebar-width: 240px;   /* wider for better readability */
  --sidebar-width-sm: 180px; /* slightly wider on small screens */
  --content-max: 1100px;             /* standard pages */
  --content-max-sidebar: 1100px;     /* pages with sidebar */
  --content-pad: 12px 16px;          /* standard pages inner padding */
  --content-pad-sidebar: 0 50px;     /* sidebar pages inner padding */
  --radius: 12px;                    /* default rounded corner */
  --content-border-x: 2px solid var(--line);

  /* colors */
  --bg: #1e1e1e;
  /* New: page gutters and content surface */
  --gutter-bg: #171717; /* page background on sides */
  --content-bg: #232323; /* central content surface */
  --text: #e0e0e0;
  --text-muted: #aaaaaa;
  --heading: #f0f0f0;
  --link: #7aa2f7;
  --link-hover: #a7c7ff;
  --line: #333;

  --card: #1f1f1f;    /* darker than content to separate */
  --card-soft: #212121;/* between content and card for subtle panels */
  --card-alt: #181818;/* nested card surface */
  --card-line: #3a3a3a; /* more contrast for borders */
  /* Top bar (higher contrast against gutter/content) */
  --topbar-bg: #0f0f10;
  --topbar-line: #3a3a3a;
  --topbar-btn-hover: #17181a;
  --topbar-btn-active: #101114;
  /* Discussion accent (dark) */
  --discussion-bg: #1d2736;       /* subtle blue-gray tint */
  --discussion-border: #334760;    /* mid blue-gray for border */
  --discussion-accent: #4a6fbf;    /* accent for left border/title */
  --shadow: rgba(0, 0, 0, 0.4);
}

/* Light theme */
.theme-light {
  --bg: #f6f7fb;
  --gutter-bg: #eef1f6;
  --content-bg: #ffffff;
  --text: #222;
  --text-muted: #555;
  --heading: #111;
  --link: #2257d8;
  --link-hover: #1947b5;
  --line: #ddd;

  --card: #f7f8fa;    /* distinct from pure white */
  --card-soft: #f8f9fb;/* between content and card for subtle panels */
  --card-alt: #f1f2f6;/* nested card surface */
  --card-line: #d5d8df; /* slightly darker border */
  /* Top bar (higher contrast against gutter/content) */
  --topbar-bg: #ffffff;
  --topbar-line: #d5d8df;
  --topbar-btn-hover: #f2f4f8;
  --topbar-btn-active: #e9edf3;
  /* Discussion accent (light) */
  --discussion-bg: #eef3ff;       /* subtle blue tint */
  --discussion-border: #c9d7ff;   /* soft blue border */
  --discussion-accent: #6c8fff;   /* accent for left border/title */
  --shadow: rgba(0, 0, 0, 0.08);
}

/* Follow system preference */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
  --gutter-bg: #eef1f6;
  --content-bg: #ffffff;
    --text: #222;
    --text-muted: #555;
    --heading: #111;
    --link: #2257d8;
    --link-hover: #1947b5;
    --line: #ddd;

    --card: #ffffff;
    --card-line: #e9e9e9;
    --shadow: rgba(0, 0, 0, 0.08);
  }
}

/* ========== Fundamental Styles ========== */
* { box-sizing: border-box; }

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  /* Use gutter background for the page sides */
  background: var(--gutter-bg);
  color: var(--text);
  position: relative;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--heading);
  margin: 0.6em 0 0.4em;
}

p { margin: 0.6em 0; }

/* Links: default look like text; highlight on hover/focus */
a, a:link, a:visited {
  color: inherit;
  text-decoration: none;
}
a:hover, a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Focus styles */
a:focus,
button:focus {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Header / Main / Footer */
header {
  text-align: center;
  /* Match .main-center horizontal padding (0 50px) to allow full-bleed divider */
  padding: 20px 50px;
  margin-left: -50px;
  margin-right: -50px;
  border-bottom: 4px solid var(--card-line);
  position: relative;
}

main {
  max-width: var(--content-max);
  margin: 24px auto;
  padding: var(--content-pad);
  /* Central content surface and subtle separation from gutters */
  background: var(--content-bg);
  border-left: var(--content-border-x);
  border-right: var(--content-border-x);
  box-shadow: none; /* flat design */
  border-radius: var(--radius);
}
/* On pages with a sidebar, let main span full width and center inner container instead */
main.with-sidebar {
  max-width: none;
  margin: -20px;
  /* Do not apply central background to the full width wrapper */
  background: transparent;
  border: none;
  box-shadow: none;
}

footer {
  text-align: center;
  /* Match .main-center horizontal padding to allow full-bleed divider */
  padding: 16px 50px;
  margin-top: 32px;
  margin-left: -50px;
  margin-right: -50px;
  border-top: 4px solid var(--card-line);
  font-size: 14px;
  color: var(--text-muted);
}

/* ========== Navigation ========== */
nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
nav li { margin: 10px 0; }

nav a.active {
  color: var(--heading);
  font-weight: bold;
  border-bottom: 2px solid var(--link);
}

/* ========== Project card styles ========== */

/* Card container layout */
.project-cards {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 700px) {
  .project-cards { gap: 32px; }
}

/* Single project card */
.project-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  box-shadow: none;
  padding: 18px 24px;
  margin: 0;
  gap: 24px;
}

@media (max-width: 600px) {
  .project-card {
    flex-direction: column;
    padding: 14px 8px;
    gap: 12px;
  }
}

.project-img {
  flex: 0 0 160px;
  max-width: 160px;
}
.project-img img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: none;
}

.project-info {
  flex: 1;
}
.project-info h3 {
  margin: 0 0 8px 0;
  font-size: 1.2em;
}
.project-info p {
  color: var(--text-muted);
  margin: 0;
}

img.responsive {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: none;
}

/* Generic card container (used by sections) */
.card {
  background: var(--card);
  border: 2px solid var(--card-line);
  border-radius: var(--radius);
  padding: 16px 20px;
}

/* Image grid (suitable for comparison images) */
.gallery {
  display: flex;
  flex-direction: row;
  gap: 5px;
  justify-content: center;
  flex-wrap: nowrap;
}
.gallery img {
  max-width: 140px;
  width: 100%;
  height: auto;
}

/* (theme toggle styles handled by .top-icon-btn) */

/* ===== Left Sidebar ===== */
.with-sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  box-sizing: border-box;
  min-width: 0;
}
.main-center {
  max-width: var(--content-max-sidebar);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  /* Apply central surface styling for sidebar pages */
  padding: var(--content-pad-sidebar);
  background: var(--content-bg);
  border-left: var(--content-border-x);
  border-right: var(--content-border-x);
  box-shadow: none;
  border-radius: var(--radius);
}

/* Sidebar overlays content; main doesn't shift */

/* Sidebar styles */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100% - var(--topbar-height));
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 12px 8px 12px 6px; /* tighter: less left/right whitespace */
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 100;
}

/* Collapsed state */
.sidebar.collapsed {
  transform: translateX(-100%);
}

/* (Sidebar toggle button lives in the top navbar) */

/* Overlay behind sidebar to indicate modal-like focus and blur/dim background */
.overlay {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90; /* below sidebar (100), above content */
}
.sidebar:not(.collapsed) ~ .overlay {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .sidebar {
    width: var(--sidebar-width-sm);
  }
}

/* Sidebar navigation */
.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar nav li {
  margin: 8px 0; /* tighter grouping, improved rhythm */
}
.sidebar nav a {
  color: inherit;
  text-decoration: none;
  display: block;             /* full-row click target */
  padding: 6px 10px;          /* tighter horizontal padding */
  border-radius: 8px;
  font-size: 1rem;            /* improve legibility */
  line-height: 1.45;
  letter-spacing: 0.1px;
  font-weight: 500;
}
.sidebar nav a .sidebar-sub {
  display: block;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}
.sidebar nav a:hover {
  color: var(--heading);
  background: var(--card-soft); /* subtle flat highlight */
  text-decoration: none;
}