@charset "UTF-8";

/* ===========================================================================
   Shared blog chrome — the two-column shell (sidebar + content column) and
   the theme toggle, used by every page under /blog/.

     index.html : et-book.css  +  blog-chrome.css  +  index-page-base.css
     posts      : tufte.css    +  blog-chrome.css

   This file owns LAYOUT + SIDEBAR + TOGGLE only. Page typography comes from
   et-book/tufte plus the page-specific stylesheet, so loading it after either
   base leaves Tufte's sidenote/margin-note geometry untouched (those
   percentages resolve against the paragraph, not the body).
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Layout container
   ------------------------------------------------------------------------- */
body {
  margin: 0;
  width: auto;
  max-width: none;
  padding-left: 0;
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* Content column — index uses <main>, posts use <article id="main-content"> */
main,
body > article#main-content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 1200px;
  padding: 3rem 3rem 4rem 5rem;
  animation: page-enter 0.45s ease both;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  main,
  body > article#main-content { animation: none; }
}

/* ---------------------------------------------------------------------------
   Sidebar: logo mark + nav + social
   ------------------------------------------------------------------------- */
#asidebar {
  flex: 0 0 auto;
  padding: 8rem 0 0 4rem;
}

/* Neutralize tufte.css's global ul/li typography (font-size, line-height,
   list margins) which otherwise leaks into the sidebar on article pages and
   makes the nav spacing differ from the index. */
#asidebar ul,
#asidebar li {
  font-size: 1rem;
  line-height: 1.4;
  margin-top: 0;
}

#asidebar #logo {
  text-align: center;
  margin-bottom: 2rem;
}

#asidebar #logo a {
  display: inline-block;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

#asidebar #logo img {
  display: block;
  width: 110px;
  height: 110px;
}

/* For a black-on-transparent engraving emblem, add class="emblem-invert" to the
   logo <img> so the line-art flips to light on the dark theme. */
[data-theme="dark"] #asidebar #logo img.emblem-invert {
  filter: invert(1) brightness(1.1);
}

#asidebar .main-menu ul {
  list-style: none;
  text-align: center;
  margin: 0;
  padding: 0;
}

#asidebar .main-menu ul li {
  margin: 0 0 20px 0;
  padding: 0;
  font-size: 1.3rem;
}

#asidebar .main-menu ul li a {
  color: #111;
  text-decoration: none;
  position: relative;
  padding: 10px;
}

#asidebar .main-menu ul li a:after {
  content: "";
  position: absolute;
  height: 2px;
  bottom: 7px;
  left: 10px;
  right: 10px;
  background-color: rgba(17, 17, 17, 0.7);
  visibility: hidden;
  transform: scaleX(0);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#asidebar .main-menu ul li a:hover:after {
  visibility: visible;
  transform: scaleX(1);
}

#asidebar #social {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-evenly;
  align-items: center;
  gap: 0.75rem;
}

#asidebar #social li { margin: 0; }

#asidebar #social a {
  display: inline-flex;
  color: rgba(17, 17, 17, 0.75);
  transition: color 0.2s ease, transform 0.15s ease;
}

#asidebar #social a:hover { color: #111; transform: translateY(-2px); }

#asidebar #social svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------------------------------------------------------------------------
   Theme toggle (crossfades via View Transitions)
   ------------------------------------------------------------------------- */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 248, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.15s ease;
}

.theme-toggle:hover { transform: scale(1.08); border-color: rgba(17, 17, 17, 0.2); }
.theme-toggle:active { transform: scale(0.95); }

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: rgba(17, 17, 17, 0.55);
}

.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

/* ---------------------------------------------------------------------------
   Accessibility
   ------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.6rem 1rem;
  background: #111;
  color: #fff;
  transform: translateY(-120%);
  transition: transform 0.2s ease;
  z-index: 1100;
}

.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 2px solid #7eb8da;
  outline-offset: 3px;
  border-radius: 2px;
}

.theme-toggle:focus-visible { border-radius: 50%; }

/* ===========================================================================
   Dark mode — chrome only (page bodies handle their own content colors)
   ========================================================================= */
[data-theme="dark"] #asidebar .main-menu ul li a { color: #e0e0e0; }
[data-theme="dark"] #asidebar .main-menu ul li a:after { background-color: rgba(224, 224, 224, 0.6); }
[data-theme="dark"] #asidebar #social a { color: rgba(224, 224, 224, 0.7); }
[data-theme="dark"] #asidebar #social a:hover { color: #f0f0f0; }

[data-theme="dark"] .theme-toggle {
  background: rgba(26, 26, 26, 0.8);
  border-color: rgba(224, 224, 224, 0.12);
}
[data-theme="dark"] .theme-toggle:hover { border-color: rgba(224, 224, 224, 0.25); }
[data-theme="dark"] .theme-toggle svg { color: rgba(224, 224, 224, 0.7); }
[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

[data-theme="dark"] :focus-visible { outline-color: #7eb8da; }

/* View-transition crossfade for the theme swap */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: ease;
  mix-blend-mode: normal;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0s; }
}

/* ===========================================================================
   Responsive — collapse the sidebar into a top bar
   ========================================================================= */
@media screen and (max-width: 1200px) {
  main,
  body > article#main-content { padding-right: 2rem; }
}

@media screen and (max-width: 900px) {
  body {
    display: block;
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  #asidebar {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 2rem 0.5rem;
  }

  #asidebar #logo { margin-bottom: 0; }
  #asidebar #logo img { width: 56px; height: 56px; }

  #asidebar .main-menu ul {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 0 1.25rem;
    text-align: left;
  }

  #asidebar .main-menu ul li { margin: 0; }

  #asidebar .main-menu ul li a {
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(17, 17, 17, 0.35);
  }

  #asidebar .main-menu ul li a:after { display: none; }

  [data-theme="dark"] #asidebar .main-menu ul li a { text-decoration-color: rgba(224, 224, 224, 0.4); }

  #asidebar #social { margin: 0 0 0 auto; }

  main,
  body > article#main-content {
    max-width: none;
    padding: 1.5rem 2rem 3rem;
  }
}

@media screen and (max-width: 560px) {
  #asidebar { flex-wrap: wrap; }
  #asidebar #social { margin: 0; }

  main,
  body > article#main-content { padding: 1rem 1.5rem 3rem; }

  .theme-toggle { top: 1rem; right: 1rem; width: 36px; height: 36px; }
  .theme-toggle svg { width: 16px; height: 16px; }
}

@media print {
  .theme-toggle,
  #asidebar { display: none; }

  main,
  body > article#main-content { max-width: none; padding: 0; }
}
