/* site.css -- self-contained styling for the org-mode export.
   Styles org's native markup (#table-of-contents, .outline-2, .outline-4);
   js/site.js moves the title, TOC, and social links into a .sidebar nav.
   Without JS the page degrades to a readable single column. */

:root {
  --ink: #16191d;
  --body: #3c4149;
  --muted: #6a7280;
  --line: #e6e8ec;
  --paper: #ffffff;
  --panel: #f6f7f9;
  --accent: #0a66c2;
  --accent-ink: #084d92;
  --sidebar-w: 14.5rem;
  --content-w: 44rem;
  --content-pad: 2.5rem;
  /* the sidebar+content pair centers as one unit on wide screens;
     the offset clamps to 0 when the viewport is narrower than the pair */
  --page-w: calc(var(--sidebar-w) + var(--content-w) + 2 * var(--content-pad));
  --page-offset: max(0px, calc((100vw - var(--page-w)) / 2));
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.97rem;
  line-height: 1.65;
  color: var(--body);
  background: var(--paper);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ */
/* Sidebar (assembled by site.js from title + TOC + social links)     */
/* ------------------------------------------------------------------ */

.sidebar {
  position: fixed;
  top: 0;
  left: var(--page-offset);
  width: var(--sidebar-w);
  border-left: 1px solid var(--line);
  height: 100vh;
  padding: 28px 22px 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar h1.title {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--ink);
}

.sidebar #table-of-contents h2 { display: none; }

.sidebar #text-table-of-contents ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar #text-table-of-contents > ul > li {
  margin-bottom: 2px;
}

.sidebar #text-table-of-contents a {
  display: block;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--body);
}

.sidebar #text-table-of-contents a:hover {
  color: var(--accent);
  background: rgba(10, 102, 194, 0.06);
  text-decoration: none;
}

.sidebar #text-table-of-contents a.active {
  color: var(--accent);
  font-weight: 600;
}

/* nested levels: smaller, indented, muted */
.sidebar #text-table-of-contents ul ul a {
  padding-left: 18px;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.sidebar .social-icons {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.social-icons a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 6px;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--body);
}

.social-icons a:hover {
  color: var(--accent);
  background: rgba(10, 102, 194, 0.06);
  text-decoration: none;
}

.social-icons svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hamburger button (site.js adds it; visible only on small screens) */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Content                                                             */
/* ------------------------------------------------------------------ */

#content {
  margin-left: calc(var(--page-offset) + var(--sidebar-w));
  padding: 44px var(--content-pad) 60px;
  max-width: calc(var(--content-w) + 2 * var(--content-pad));
}

/* no-JS fallback: title/TOC/social stay in flow and just look plain */
body:not(.has-sidebar) #content { margin-left: auto; margin-right: auto; }

h2 {
  margin: 2.2em 0 0.6em;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.outline-2:first-of-type h2 { margin-top: 0; }

h4 {
  margin: 1.8em 0 0.4em;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

p { margin: 0.75em 0; }

b { color: var(--ink); font-weight: 600; }

/* Portrait */
#my-image {
  float: right;
  width: 132px;
  height: auto;
  margin: 4px 0 12px 20px;
  border-radius: 10px;
}

/* Publication lists: each entry a quiet card */
ul.org-ul {
  list-style: none;
  margin: 0.8em 0;
  padding: 0;
}

ul.org-ul > li {
  background: var(--panel);
  border-radius: 10px;
  padding: 13px 16px;
  margin-bottom: 10px;
  border-left: 2px solid transparent;
  font-size: 0.92rem;
  transition: border-color 120ms ease;
}

ul.org-ul > li:hover { border-left-color: var(--accent); }

ul.org-ul > li i { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------------ */
/* Small screens: sidebar becomes a top bar with a toggle panel        */
/* ------------------------------------------------------------------ */

@media (max-width: 800px) {
  .sidebar {
    position: sticky;
    left: auto;
    border-left: none;
    width: 100%;
    height: auto;
    padding: 12px 18px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    z-index: 10;
  }

  .sidebar h1.title { margin: 0; font-size: 1rem; }

  .nav-toggle { display: block; }

  .sidebar #table-of-contents,
  .sidebar .social-icons {
    display: none;
    width: 100%;
  }

  .sidebar.open #table-of-contents,
  .sidebar.open .social-icons {
    display: block;
    margin-top: 12px;
  }

  .sidebar.open .social-icons {
    display: flex;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }

  #content {
    margin-left: 0;
    padding-left: 20px;
    padding-right: 20px;
  }

  #content { padding-top: 24px; }

  #my-image { width: 104px; margin-left: 14px; }
}

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