:root {
  --fn: "Avenir Next", "Avenir", "Nunito Sans", system-ui, sans-serif;
  --fa: "Avenir", "Avenir Next", "Nunito Sans", system-ui, sans-serif;
  --blue: #001a9b;
  --ink: #3c3c3c;
  --bg: #f0f0f0;
  --panel: #ffffff;
  --gutter: 16px;
  --sidebar-w: 254px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fn);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

/* ---------- 100vh shell: fixed sidebar, scrolling main ---------- */
body { overflow: hidden; }

.layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  margin: var(--gutter) 0 var(--gutter) var(--gutter);
  padding: 24px 26px;
  background: var(--panel);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  overflow-y: auto;
}

.main {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c9c9c9 transparent;
}

.page-project .main { padding: 28px 20px; }

.page-home .main {
  margin: var(--gutter) var(--gutter) var(--gutter) 30px;
  padding: 24px 0;
}
.page-home .content { display: flex; flex-direction: column; min-height: 100%; }
.page-home .content > div { flex: 1 0 auto; gap: 40px; }

/* ---------- Sidebar ---------- */
.title {
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 24px;
  line-height: 24px;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  transition: color .15s ease;
}
.title:hover,
.title.is-current { color: var(--blue); }

.projects-label {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 20px;
  letter-spacing: 0.01em;
  color: var(--blue);
}

.projects ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.projects li { display: flex; }

.nav-item {
  position: relative;
  display: inline-block;
  font-size: 18px;
  line-height: 20px;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s ease;
}
.nav-item:hover,
.nav-item.is-current { color: var(--blue); }
.nav-item.is-current::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--blue);
  transform: translateY(-50%) rotate(45deg);
}

/* Hamburger: only shown on mobile */
.menu-toggle { display: none; }

.title:focus-visible,
.nav-item:focus-visible,
.menu-toggle:focus-visible,
.t a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---------- Content (generated from the Figma frames) ---------- */
.content { width: 100%; }
.content > div { width: 100%; }
.content div { max-width: 100%; }

/* Pages with a dedicated phone layout render both; CSS shows one */
.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-desktop { display: none; }
  .only-mobile { display: block; }
  .only-mobile > div { width: 100%; }
}

.t { margin: 0; overflow-wrap: break-word; }
.t ul, .t ol { margin: 0; padding-left: 1.4em; }
/* Lists that mirror Figma's list spacing: .t-list sets --ps (paragraph spacing) */
.t-list ul { padding-left: 17px; list-style-type: disc; }
.t-list ul ul { padding-left: 26px; }
.t-list li + li,
.t-list li > ul { margin-top: var(--ps, 0); }
.t a { color: inherit; text-decoration: none; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color .15s ease; }
.t a:hover { color: var(--blue); }
.ps { display: block; }

.m {
  display: block;
  height: auto;
}

.ln { flex: 0 0 auto; }

/* GIFs: show a still frame, swap to the animated GIF while in view (app.js) */
.gif {
  object-fit: cover;
  border-radius: 8px;
}
.gif-stack { position: relative; }
.gif-stack .gif { display: block; width: 100%; }
.gif-overlay {
  position: absolute;
  height: auto;
  pointer-events: none;
}

.smile {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 68px;
  height: 68px;
}
.page-home .main { position: relative; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .r { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .layout { display: block; height: auto; }

  /* Sticky top bar: one-line title + hamburger; projects collapse below */
  .sidebar {
    position: sticky;
    top: 12px;
    z-index: 10;
    margin: 12px 12px 16px;
    padding: 8px 8px 8px 20px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    overflow: visible;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .06);
  }

  .title {
    flex-direction: row;
    gap: .3em;
    min-width: 0;
    font-size: 18px;
    line-height: 24px;
    white-space: nowrap;
  }
  .title span + span { opacity: .6; }

  .menu-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle:hover,
  .sidebar.is-open .menu-toggle { color: var(--blue); }

  .menu-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 14px;
  }
  .menu-icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
    transition: transform .25s ease, opacity .2s ease, top .25s ease;
  }
  .menu-icon span:nth-child(1) { top: 0; }
  .menu-icon span:nth-child(2) { top: 6.25px; }
  .menu-icon span:nth-child(3) { top: 12.5px; }
  .sidebar.is-open .menu-icon span:nth-child(1) { top: 6.25px; transform: rotate(45deg); }
  .sidebar.is-open .menu-icon span:nth-child(2) { opacity: 0; }
  .sidebar.is-open .menu-icon span:nth-child(3) { top: 6.25px; transform: rotate(-45deg); }

  /* Collapsible project list: drops down over the page as part of the same card
     (animates its height via grid rows) */
  .sidebar { transition: border-radius .3s ease; }
  .sidebar.is-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .projects {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: grid;
    grid-template-rows: 0fr;
    background: var(--panel);
    border-radius: 0 0 16px 16px;
    box-shadow: 0 12px 16px -8px rgba(0, 0, 0, .08);
    transition: grid-template-rows .3s ease;
  }
  .projects-inner {
    min-height: 0;
    padding: 0 20px;
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0s linear .3s;
  }
  .sidebar.is-open .projects { grid-template-rows: 1fr; }
  .sidebar.is-open .projects-inner {
    visibility: visible;
    transition-delay: 0s;
  }
  .projects-label { margin: 8px 0 16px; }
  .projects ul { padding-bottom: 20px; }
  .nav-item { white-space: normal; }

  .page-project .main,
  .page-home .main {
    margin: 0;
    padding: 8px var(--gutter) 32px;
    overflow: visible;
  }
  .page-home .content { min-height: 0; }

  .g { grid-template-columns: minmax(0, 1fr) !important; }
  .stack { flex-direction: column !important; align-items: stretch !important; justify-content: flex-start !important; }
  .stack > * { flex: 0 0 auto !important; width: auto !important; max-width: 100% !important; }
  .content [style*="width:"] { max-width: 100%; }
  .content h1.t { font-size: 40px !important; line-height: 1.15 !important; }
  .smile { position: static; margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Wrapping rows in phone layouts keep Figma's column count; items scale to fill */
.wgrid > * { width: 100% !important; min-width: 0; }
.wgrid > .c > img.m { width: 100% !important; }
