:root {
  --bg: #fbf8f1;          /* warm off-white paper */
  --bg-elev: #f3eee2;     /* slightly deeper card surface */
  --bg-soft: #f7f2e7;
  --fg: #2a2824;          /* warm near-black */
  --fg-muted: #7d7668;
  --border: #e6dfcd;
  --accent: #5e7e9a;      /* soft slate blue (overridden by site.accent) */
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 55%, transparent);
  --radius: 12px;
  --sidebar-w: 220px;
  --content-w: 720px;
  --gutter: 56px;
  --page-max: calc(var(--sidebar-w) + var(--gutter) + var(--content-w));
  --page-pad: 32px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 12px;
  border-radius: var(--radius);
}

.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 100;
}

/* ─── Header banner ─────────────────────────────────────────── */

.banner {
  width: 100%;
  height: 220px;
  background-color: var(--bg-elev);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

@media (max-width: 800px) {
  .banner {
    height: 140px;
  }
}

/* ─── Page grid: sidebar | content ───────────────────────────── */

.page-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gutter);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 64px 0;
  display: flex;
  flex-direction: column;
  gap: 36px;
  /* Intentionally no fixed height — sticky elements bottom-out against
     their parent's bottom edge. With height: 100vh the sidebar would
     get pushed up when scrolled near the page bottom (clicking Contact). */
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--fg);
  line-height: 1.2;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.85;
}

.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}

.brand-role {
  font-size: 0.78rem;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
  max-width: 200px;
}

/* ─── Vertical nav (table-of-contents style) ─────────────────── */

.sidenav {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  margin-left: 0;
}

.tab {
  appearance: none;
  display: block;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  margin-left: -1px;          /* overlap the parent's 1px line */
  padding: 8px 16px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--fg-muted);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  transition: color 140ms ease, border-color 140ms ease;
}

.tab:hover {
  color: var(--fg);
  border-left-color: var(--border);
  text-decoration: none;
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.tab[aria-current="page"] {
  color: var(--fg);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* ─── Main content ───────────────────────────────────────────── */

.main-content {
  padding: 64px 0 96px;
  max-width: var(--content-w);
  min-width: 0;
}

.section + .section {
  margin-top: 48px;
}

/* Top-level page sections (one per nav link). */
.page-section {
  scroll-margin-top: 24px;
}

/* Thin divider between top-level sections. Top + bottom spacing match
   so every section starts and ends with the same breathing room. */
.page-section + .page-section {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--border);
}

/* Make sure the last section is tall enough that every earlier section's
   top can scroll under the page top — keeps the scrollspy honest without
   needing fancy redistribution math in JS. */
.page-section:last-of-type {
  min-height: calc(100vh - 200px);
}

/* Section headings: medium-sized — smaller than the hero h1 so the
   "Sean Pentiboyina" up top stays the page's anchor, but heavier than
   body copy so each section reads as its own clear chunk. */
.section h2 {
  font-size: clamp(1.25rem, 2.4vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  margin: 0 0 20px;
}

.text-block p {
  margin: 0 0 14px;
  color: var(--fg);
}

/* ─── Hero ───────────────────────────────────────────────────── */

.hero {
  padding: 0;
}

.hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}

.hero .role {
  color: var(--fg-muted);
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.hero .tagline {
  font-size: 1.08rem;
  color: var(--fg);
  margin: 0;
  max-width: 60ch;
}

/* ─── Project cards ──────────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .cards {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 140ms ease, transform 140ms ease;
}

@media (hover: hover) {
  .card:hover {
    border-color: var(--accent-line);
  }
}

.writeup-link {
  font-weight: 500;
}

.card h3 {
  margin: 0;
  font-size: 1.0rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.card .desc {
  color: var(--fg-muted);
  margin: 0;
  font-size: 0.95rem;
}

.tech {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
}

.tag {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--fg-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.9rem;
}

/* ─── Timeline ───────────────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
}

@media (max-width: 600px) {
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.timeline-date {
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  padding-top: 3px;
}

.timeline-body h3 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 600;
}

.timeline-body .org {
  color: var(--fg-muted);
  margin: 0 0 6px;
  font-size: 0.93rem;
}

.timeline-body p {
  margin: 0;
  color: var(--fg);
}

.timeline-body .certid {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 6px 0 0;
  word-break: break-all;
}

/* ─── Link list ──────────────────────────────────────────────── */

.link-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
}

.link-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  word-break: break-word;
}

@media (max-width: 480px) {
  .link-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

.link-list li:last-child {
  border-bottom: 0;
}

.link-list li span {
  color: var(--fg-muted);
  font-size: 0.93rem;
}

/* ─── Footer ─────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding: 20px 0;
  color: var(--fg-muted);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--fg-muted);
}

.footer-links a:hover {
  color: var(--accent);
}

/* ─── Responsive: sidebar collapses to top on narrow screens ─── */

@media (max-width: 800px) {
  .page-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* `display: contents` lets brand and nav participate in the page-grid
     directly, so the nav can be `position: sticky` against the tall
     parent (the whole page-grid) and not just within a short sidebar. */
  .sidebar {
    display: contents;
  }

  .brand {
    padding: 24px 0 16px;
  }

  .brand-role {
    max-width: none;
  }

  .sidenav {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin: 0 calc(-1 * var(--page-pad));
    padding: 6px var(--page-pad);
    gap: 0;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
  }

  .sidenav::-webkit-scrollbar {
    display: none;
  }

  .tab {
    border-left: 0;
    border-bottom: 2px solid transparent;
    margin-left: 0;
    margin-bottom: -1px;
    padding: 10px 14px;
    white-space: nowrap;
  }

  .tab:hover {
    border-left-color: transparent;
    border-bottom-color: var(--border);
  }

  .tab[aria-current="page"] {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .main-content {
    padding: 32px 0 64px;
    max-width: none;
  }

  /* Sticky nav covers the top — give section anchors clearance so a
     clicked nav link doesn't land its heading hidden under the bar. */
  .page-section {
    scroll-margin-top: 64px;
  }
}

/* Smaller phones: tighten outer padding so cards/timelines have room. */
@media (max-width: 480px) {
  :root {
    --page-pad: 20px;
  }

  .hero .tagline {
    font-size: 1rem;
  }

  .card {
    padding: 16px;
  }
}

/* When the writeup modal is open, lock body scroll. */
body.modal-open {
  overflow: hidden;
}

/* ─── Project writeup modal ──────────────────────────────────── */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 5vh 24px;
  animation: modal-fade-in 160ms ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 12, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
}

.modal-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 36px clamp(20px, 4vw, 44px) 48px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18);
  animation: modal-slide-up 200ms ease-out;
}

@keyframes modal-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--bg);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background 140ms ease, color 140ms ease;
  margin-left: 12px;
}

.modal-close:hover {
  background: var(--bg-elev);
  color: var(--fg);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-loading {
  color: var(--fg-muted);
  padding: 24px 0;
}

@media (max-width: 600px) {
  .modal {
    padding: 0;
  }

  .modal-card {
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
    border: 0;
    padding: 24px 20px 64px;
  }
}

/* ─── Markdown rendering inside the writeup modal ─────────────── */

.markdown {
  color: var(--fg);
  line-height: 1.7;
  word-wrap: break-word;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown h1 {
  font-size: clamp(1.6rem, 3.4vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.markdown h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.8em 0 0.5em;
}

.markdown h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.6em 0 0.4em;
}

.markdown p {
  margin: 0 0 1em;
}

.markdown ul,
.markdown ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.markdown li {
  margin: 0.3em 0;
}

.markdown code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
}

.markdown pre {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1em;
  font-size: 0.88rem;
  line-height: 1.55;
}

.markdown pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.markdown blockquote {
  border-left: 3px solid var(--accent-line);
  padding: 2px 0 2px 14px;
  margin: 0 0 1em;
  color: var(--fg-muted);
}

.markdown img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1em 0;
  display: block;
}

.markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: 3px;
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
