:root {
  --bg: #ffffff;
  --surface: #f6f7f8;
  --seg-bg: #dcdcdc;
  /* slightly darker than surface for segmented control */
  --seg-hover: rgba(0, 0, 0, 0.04);
  /* subtle hover shade for non-active items */
  --header-border: rgba(0, 0, 0, 0.12);
  --muted: #6b6f76;
  --text: #111111;
  --accent: #111111;
  --card-shadow: transparent;
}

:root.dark {
  /* VS Code-like dark palette: deeper neutrals for higher contrast */
  --bg: #1e1e1e;
  /* main page background - very dark */
  --surface: #252526;
  /* cards and surface - slightly lighter than bg */
  --seg-bg: #2a2a2a;
  /* segmented nav background */
  --seg-hover: rgba(255, 255, 255, 0.03);
  --muted: #9a9a9a;
  /* muted text */
  --text: #d4d4d4;
  /* main text */
  --accent: #d4d4d4;
  --card-shadow: transparent;
  --header-border: rgba(255, 255, 255, 0.06);
}

/* Reset & base */
* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* layout: keep footer at bottom */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 18px
}

/* Header */
.site-header {
  background: transparent;
  padding: 28px 0;
  border-bottom: 3px solid var(--header-border)
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px
}

.logo {
  font-weight: 800;
  font-size: 32px;
  letter-spacing: 1px
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 0;
  align-items: center
}

.nav-link {
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  margin: 0;
  font-weight: 700
}

.nav-link:hover {
  color: var(--text)
}

/* make active/hover pill styles consistent across all sizes */
.nav-link {
  transition: background .18s ease, color .12s ease
}

.nav-link:not(.active):hover {
  background: var(--seg-hover)
}

.nav-link.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;

}

/* Segmented filter style on larger screens */
@media (min-width:821px) {
  .site-nav {
    background: var(--seg-bg);
    padding: 6px;
    border-radius: 12px;
    gap: 6px;
    align-items: center;
  }

  .nav-link {
    padding: 10px 18px;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    transition: background .18s ease, color .12s ease;
    font-weight: 700;
  }

  /* subtle hover background for non-active items; keep text unchanged */
  .nav-link:not(.active):hover {
    background: var(--seg-hover)
  }

  .nav-link.active {
    background: var(--bg);
    color: var(--text);
    font-weight: 700;

  }
}

.header-controls {
  margin-left: 12px;
  display: flex;
  align-items: center
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer
}

/* Theme switch */
.theme-switch {
  display: inline-flex;
  align-items: center;
  position: relative
}

.theme-switch input {
  display: none
}

.switch-track {
  display: inline-block;
  width: 48px;
  height: 30px;
  /* slightly taller so knob centers visually with logo */
  background: var(--seg-bg);
  border-radius: 20px;
  position: relative;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.switch-track:after {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  background: var(--accent);
  /* use accent/text color so knob matches theme */
  border-radius: 50%;
  transition: all .18s ease;
  /* knob is flat (no shadow) */
}

/* move knob when checked */
.theme-switch input:checked+.switch-track:after {
  left: calc(100% - 4px - 22px)
}

/* dark theme-specific border tweak */

:root.dark .switch-track {
  background: var(--seg-bg);
  border: 1px solid rgba(255, 255, 255, 0.04)
}

/* Theme toggle using website theming colors */
/* Theme toggle using website theming colors */
.theme-toggle {
  display: inline-flex;
  align-items: stretch;
  padding: 4px;
  border-radius: 30px;
  background: var(--seg-bg);
  margin-left: 12px;
  position: relative;
  cursor: pointer;
  width: 180px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

/* Sliding background pill */
.theme-toggle .toggle-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--bg);
  border-radius: 24px;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Move knob to right side when dark mode */
.theme-toggle[aria-pressed="true"] .toggle-knob {
  transform: translateX(100%);
  background: #333;
  /* Slightly lighter than pure black for visibility on dark track */
}

/* Icon and text containers */
.theme-toggle .icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 50%;
  position: relative;
  z-index: 1;
  padding: 0 10px;
  transition: opacity 0.3s ease;
}

.theme-toggle .material-icons {
  font-size: 18px;
}

.theme-toggle .theme-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Default inactive state - use muted color */
.theme-toggle .material-icons,
.theme-toggle .theme-label {
  color: var(--muted);
  opacity: 0.7;
  transition: color 0.3s ease, opacity 0.3s ease;
}

/* Light mode: Light is active */
.theme-toggle:not([aria-pressed="true"]) .icon-wrap:first-child .material-icons,
.theme-toggle:not([aria-pressed="true"]) .icon-wrap:first-child .theme-label {
  color: var(--text);
  opacity: 1;
}

/* Dark mode: Dark is active */
.theme-toggle[aria-pressed="true"] .icon-wrap:last-child .material-icons,
.theme-toggle[aria-pressed="true"] .icon-wrap:last-child .theme-label {
  color: #fff;
  opacity: 1;
}

/* Hover state */
.theme-toggle:hover {
  border-color: rgba(0, 0, 0, 0.1);
}

/* Focus state */
.theme-toggle:focus {
  outline: none;
}

/* Mobile adjustments */
@media (max-width:768px) {
  .theme-toggle {
    width: 150px;
    height: 38px;
  }

  .theme-toggle .icon-wrap {
    padding: 6px 4px;
    gap: 4px;
  }

  .theme-toggle .material-icons {
    font-size: 16px;
  }

  .theme-toggle .theme-label {
    font-size: 11px;
  }
}

/* Page title */
.page-title {
  font-size: 36px;
  margin: 28px 0 8px
}

.title-rule {
  border: 0;
  height: 3px;
  background: var(--text);
  max-width: 680px;
  margin: 0 0 22px
}

/* Cards */
.cards {
  display: flex;
  flex-direction: column;
  gap: 22px
}

.card {
  background: var(--surface);
  padding: 22px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.02)
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text)
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6
}

/* Thumbnail inside project card */
.card-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-bottom: 12px
}

/* muted quote style used in About > My Beliefs */
.muted-quote {
  font-style: italic;
  color: var(--muted);
  margin-top: 8px;
  font-size: 0.95em
}

/* Utilities */
.hidden {
  display: none
}

.main-content {
  padding-bottom: 60px;
  flex: 1
}

.site-footer {
  padding: 24px 0;
  color: var(--muted);
  text-align: center
}

/* Button & helpers */
.btn {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  border: 0;
  cursor: pointer
}

.btn-muted {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text)
}

/* Responsive */
@media (max-width:820px) {

  /* stacked header on small screens: logo, segmented nav, then controls */
  .container {
    padding: 0 14px
  }

  .page-title {
    font-size: 28px
  }

  .title-rule {
    margin-bottom: 16px
  }

  .header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px
  }

  /* header-top contains logo and controls (logo left, toggle right) */
  .header-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%
  }

  /* hide hamburger — we keep it in DOM but not visible on mobile */
  .menu-toggle {
    display: none
  }

  /* show segmented nav as a full-width rounded bar under the header-top */
  .site-nav {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 8px;
    padding: 10px;
    border-radius: 12px;
    background: var(--seg-bg);
  }

  .site-nav .nav-link {
    flex: 1;
    text-align: center;
    padding: 12px 14px
  }

  /* keep theme toggle next to the logo (no full-width) */
  .header-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start
  }
}

@media (min-width:821px) {
  .site-nav {
    position: static
  }

  /* Desktop: force single-card-per-row (full-width cards) so each card occupies its own row
     across About, Projects, and Writings. This keeps spacing predictable and consistent. */
  .cards {
    flex-direction: column;
    gap: 22px;
    align-items: stretch;
  }

  .cards .card {
    /* make each card take the full content width on desktop */
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}