/* ============================================================
   maria-sara.com v2 shell: left sidebar navigation
   Shared by every page in /v2. Page-specific styles stay inline
   in each page, exactly as in v1. Color tokens (--bg, --text,
   --muted, --faint, --line, --hover, --accent, --ease) come from
   each page's own :root block so light/dark keep working.
   ============================================================ */
:root {
  --sb-w: 64px; /* collapsed */
  --sb-w-open: 240px; /* expanded */
  --sb-ctl: 40px; /* every square control: mark, nav item, icon button */
  --sb-pad: 12px; /* horizontal padding, so (64 - 2*12) = one control */
  --sb-radius: 10px;
  --sb-dur: 0.26s; /* width / slide */
  --sb-fade: 0.16s; /* label fade */
  --sb-fade-delay: 0.06s; /* labels fade in once the width has started moving */
  --sb-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- layout: sticky sidebar + scrolling column ---------- */
.shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}
.shell-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  outline: none;
}
.shell-main > main {
  flex: 1 0 auto;
}

/* skip link: first tab stop, visible only while focused */
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  padding: 10px 14px;
  border-radius: var(--sb-radius);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  transform: translateY(-200%);
  opacity: 0;
  transition:
    transform 0.2s var(--sb-ease),
    opacity 0.2s ease;
}
.skip-link:focus-visible {
  transform: none;
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--sb-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* above the v1 page chrome (header 60, drawer 55) and the fixed scroll
     progress bar (200), so the bar reads as starting at the content column */
  z-index: 250;
  transition:
    background-color 0.4s var(--ease),
    border-color 0.4s var(--ease);
}
/* width only animates after first paint, so a remembered "open" state
   never slides in on page load */
#sidebar.sb-ready {
  transition:
    width var(--sb-dur) var(--sb-ease),
    background-color 0.4s var(--ease),
    border-color 0.4s var(--ease);
}
html.sb-open #sidebar {
  width: var(--sb-w-open);
}

/* the v1 pages style a bare <nav> as the old 70px top bar; neutralise it here */
#sidebar nav {
  display: block;
  height: auto;
  align-items: normal;
  justify-content: normal;
}
#sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------- identity row: the mark is the toggle ---------- */
.sb-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 70px;
  padding: 0 var(--sb-pad);
  flex-shrink: 0;
}
.sb-mark {
  width: var(--sb-ctl);
  height: var(--sb-ctl);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--sb-radius);
  background: none;
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.sb-mark:hover {
  background: var(--hover);
  color: var(--accent);
}
.sb-mark svg {
  width: 30px;
  height: 21px;
  display: block;
  overflow: visible;
}
/* three primitives, same geometry as favicon.svg.
   NOTE: transform lengths on SVG paths are viewBox units, not screen px.
   The viewBox is 210 wide drawn at 30px, so 1px here = 0.14px on screen;
   translateX(21px) is a 3px move. */
.sb-mark .m {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 12.76;
  stroke-linejoin: miter;
  animation: sb-rise 0.5s var(--ease) both;
}
.sb-mark .m2 {
  animation-delay: 90ms;
}
.sb-mark .m3 {
  animation-delay: 180ms;
}
@keyframes sb-rise {
  from {
    opacity: 0;
    transform: translateY(50px); /* ~7px on screen */
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* once the entrance has played, hovering the mark leans it the way the
   sidebar is about to move (right = expand, left = collapse); ~2.5/5/7.5px */
.sb-mark.mark-ready .m {
  animation: none;
  transition: transform 0.24s var(--sb-ease);
}
html:not(.sb-open) .sb-mark.mark-ready:hover .m1 {
  transform: translateX(18px);
}
html:not(.sb-open) .sb-mark.mark-ready:hover .m2 {
  transform: translateX(36px);
}
html:not(.sb-open) .sb-mark.mark-ready:hover .m3 {
  transform: translateX(54px);
}
html.sb-open .sb-mark.mark-ready:hover .m1 {
  transform: translateX(-54px);
}
html.sb-open .sb-mark.mark-ready:hover .m2 {
  transform: translateX(-36px);
}
html.sb-open .sb-mark.mark-ready:hover .m3 {
  transform: translateX(-18px);
}

.sb-identity-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  visibility: hidden;
  border-radius: 6px;
  transition:
    max-width var(--sb-dur) var(--sb-ease),
    opacity var(--sb-fade) ease,
    visibility 0s linear var(--sb-dur);
}
html.sb-open .sb-identity-text {
  max-width: 170px;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s, var(--sb-fade-delay), 0s;
}
.sb-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}
.sb-role {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
  margin-top: 3px;
}

/* ---------- primary nav ---------- */
.sb-nav {
  padding: 6px var(--sb-pad);
  flex-shrink: 0;
}
.sb-nav ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-item {
  display: flex;
  align-items: center;
  height: var(--sb-ctl);
  padding: 0 11px;
  border-radius: var(--sb-radius);
  color: var(--muted); /* --faint fails contrast on the icon-only state */
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.sb-item:hover {
  color: var(--text);
  background: var(--hover);
}
.sb-item[aria-current] {
  color: var(--text);
  background: var(--hover);
}
.sb-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sb-text {
  max-width: 0;
  opacity: 0;
  margin-left: 0;
  overflow: hidden;
  transition:
    max-width var(--sb-dur) var(--sb-ease),
    margin-left var(--sb-dur) var(--sb-ease),
    opacity var(--sb-fade) ease;
}
html.sb-open .sb-text {
  max-width: 160px;
  opacity: 1;
  margin-left: 10px;
  transition-delay: 0s, 0s, var(--sb-fade-delay);
}

/* ---------- foot: elsewhere links, clock, theme ---------- */
.sb-foot {
  margin-top: auto;
  padding: 10px var(--sb-pad) 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.sb-elsewhere {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
html.sb-open .sb-elsewhere {
  flex-direction: row;
}
.sb-icon {
  width: var(--sb-ctl);
  height: var(--sb-ctl);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--sb-radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}
.sb-icon:hover {
  color: var(--text);
  background: var(--hover);
}
.sb-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sb-icon .sun {
  display: none;
}
:root[data-theme="dark"] .sb-icon .sun {
  display: block;
}
:root[data-theme="dark"] .sb-icon .moon {
  display: none;
}
.sb-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.sb-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 0;
  transition:
    max-width var(--sb-dur) var(--sb-ease),
    opacity var(--sb-fade) ease,
    padding var(--sb-dur) var(--sb-ease);
}
html.sb-open .sb-time {
  max-width: 140px;
  opacity: 1;
  padding-left: 11px;
  transition-delay: 0s, var(--sb-fade-delay), 0s;
}

/* ---------- tooltip (collapsed state) ---------- */
#sb-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 260;
  pointer-events: none;
  transform: translate(-4px, -50%);
  background: var(--text);
  color: var(--bg);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 9px;
  border-radius: 7px;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
#sb-tip.on {
  opacity: 1;
  transform: translate(0, -50%);
  transition-delay: 0.08s;
}

/* ---------- focus ---------- */
.sb-mark:focus-visible,
.sb-item:focus-visible,
.sb-icon:focus-visible,
.sb-identity-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- responsive: sidebar on desktop, v1 top bar on phones ---------- */
@media (min-width: 721px) {
  .shell header#hdr,
  .shell .mobile {
    display: none;
  }
  /* case studies: the v1 offsets assumed a 70px sticky header above */
  .shell .case-toc {
    top: 32px;
  }
  .shell .cs-section {
    scroll-margin-top: 32px;
  }
}
@media (max-width: 720px) {
  #sidebar {
    display: none;
  }
  .shell {
    display: block;
    min-height: 0;
  }
  .shell-main {
    display: block;
  }
}
@media print {
  #sidebar,
  header#hdr,
  .mobile,
  .skip-link,
  #sb-tip {
    display: none !important;
  }
  /* scroll-reveal elements never intersect on paper */
  .rv {
    opacity: 1 !important;
    transform: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #sidebar *,
  #sb-tip,
  .skip-link {
    transition: none !important;
    animation: none !important;
  }
}
