/* Blog-specific page components. Everything shared across every sonibla
   property (colors, type, buttons, the site-header/footer, the title
   underline) lives in /brand instead — see brand/README.md for that
   boundary. This file is only what's specific to the blog's own pages:
   the homepage hero, breadcrumbs, and the taxonomy accordion. */

.book-cover {
  max-width: 33%;
}

/* Breadcrumb: navigation path back to home, shown on every page except
   the homepage. Plain text, no chrome — matches the "minimal chrome"
   branding rule rather than introducing a boxed/pill nav pattern. */
.breadcrumb {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  color: #555;
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
}

.breadcrumb [aria-current="page"] {
  color: var(--color-text);
}

.breadcrumb__sep {
  margin: 0 0.5em;
}

.breadcrumb__home {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: #555;
  -webkit-mask-image: url('/img/house.svg');
  mask-image: url('/img/house.svg');
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: background-color 140ms ease;
}

.breadcrumb__home:hover,
.breadcrumb__home:focus-visible {
  background-color: var(--color-accent);
}

/* Home page only: center the hero within the available space. */
body.page-home main,
/* 404 page: same centered treatment as the homepage hero — it's an
   empty-content landing page too, not a normal article. */
body.page-404 main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.not-found h1 {
  margin: 0 auto var(--space-3);
}

.hero__title {
  /* horizontally center the box itself, now that h1 shrink-wraps to its
     text instead of stretching to fill .hero — text-align: center alone
     only centers content inside a box, not the box's own position. Also
     opts out of the brand stylesheet's default h1 margin-bottom, since
     this h1 centers as a single block with the subtitle/actions below it
     rather than leading into unrelated body content. */
  margin: 0 auto;
}

.hero__title-byline {
  font-variant-caps: normal;
  letter-spacing: normal;
}

.hero__subtitle {
  margin: var(--space-3) 0 var(--space-3);
  color: var(--color-text);
}

/* Category accordion (categories / book-categories index pages): each
   category is a native <details> disclosure instead of a link to a
   separate per-category page — see CLAUDE.md content & taxonomy notes.
   The bullet becomes an arrow (::before on summary) that rotates on open;
   everything else about the list keeps its default plain-list look. */
.category-accordion {
  list-style: none;
  padding-left: 0;
}

.category-accordion>li+li {
  margin-top: var(--space-1);
}

.category-accordion summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
}

.category-accordion summary::-webkit-details-marker {
  display: none;
}

/* A drawn triangle in a fixed square box, not a text glyph — a glyph's
   box is sized by line-height (tall and narrow, not square), so rotating
   it visually pivots around a point away from the mark itself instead of
   spinning in place. */
.category-accordion summary::before {
  content: "";
  flex: none;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.6em;
  background-color: var(--color-text);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transition: transform 250ms ease-out;
}

.category-accordion details[open]>summary::before {
  transform: rotate(90deg);
}

/* accordion.js adds this the instant a collapse starts (see shrink()) so
   the arrow rotates back in step with the height animation, rather than
   waiting for [open] to be removed once that animation finishes. */
.category-accordion details.is-collapsing>summary::before {
  transform: none;
}

/* Height is animated from JS (accordion.js) via the Web Animations API —
   native <details> has no open/close transition of its own. overflow is
   toggled by the script only while an animation is running. */
.category-accordion details>ul {
  margin: var(--space-1) 0 0;
}

/* Post table of contents (single.html, when the page has >=1 heading).
   Hidden by default — the branding spec rules out a sidebar, so this only
   appears once the viewport is wide enough that it fits in the empty
   margin beside the centered content column without narrowing it, closer
   to a margin note than a docs-site two-column layout. position: fixed
   (rather than sticky) is required here: <body> itself is the max-width,
   centered box (see brand/web/typography.css), so a normal in-flow
   descendant has no way to sit outside it — fixed is what places the TOC
   in that outer margin at all.

   Visibility, `left` and `top` are set by toc.js, not CSS: the gap
   beside the article depends on the article's actual rendered width,
   which this typeface's `ch`-based --content-max-width doesn't translate
   to px reliably (varies with font metrics, zoom, scrollbar width) — a
   calc() guess here overlapped article text on at least one real
   browser. JS measures the article's true right edge (and the
   breadcrumb's bottom edge, so the TOC starts below it) instead, and
   only shows the TOC when it actually fits. Only `width` (used by the
   JS fit check) and the rest of the visual styling live here. */
.toc {
  display: none;
  position: fixed;
  width: 176px;
  overflow-y: auto;
  font-size: 0.875rem;
}

.toc__label {
  font-variant-caps: small-caps;
  letter-spacing: 0.02em;
  color: #555;
  margin: 0 0 var(--space-1);
}

.toc #TableOfContents ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
  border-left: 1px solid #eee;
}

.toc #TableOfContents ul ul {
  padding-left: var(--space-2);
  border-left: none;
}

.toc #TableOfContents li {
  margin: 0;
}

.toc #TableOfContents a {
  display: block;
  padding: 0.3em 0 0.3em var(--space-1);
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: #555;
  text-decoration: none;
  line-height: 1.3;
  transition: color 140ms ease, border-color 140ms ease;
}

.toc #TableOfContents a:hover,
.toc #TableOfContents a:focus-visible {
  color: var(--color-text);
}

.toc #TableOfContents a[aria-current="true"] {
  color: var(--color-text);
  border-left-color: var(--color-accent);
}
/* Code blocks — see layouts/_default/_markup/render-codeblock.html.
   Plain bordered box, header line with label + buttons. Monochrome syntax
   highlighting (weight/style only) to respect the no-extra-colors rule. */
.code-block {
  margin: var(--space-3) 0;
  border: 1px solid var(--color-text);
  border-radius: 0.5rem;
  overflow: hidden;
}
.code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.4em 1em;
  border-bottom: 1px solid var(--color-text);
  font-variant-caps: small-caps;
  letter-spacing: 0.02em;
}
.code-block__actions { display: flex; gap: var(--space-2); }
.code-block__btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 140ms ease;
}
.code-block__btn:hover,
.code-block__btn:focus-visible { color: var(--color-accent); }
.code-block__body .chroma,
.code-block__body pre {
  margin: 0;
  padding: 1em;
  overflow-x: auto;
  background: transparent;
  font-size: 0.9rem;
  line-height: 1.5;
}
.code-block__body code { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
.code-block__body .chroma .line { display: flex; }
.code-block__body .chroma .cl { flex: 1; }
.code-block__body .chroma .ln { margin-right: 1em; user-select: none; opacity: 0.5; }
.code-block.is-collapsed .code-block__body { max-height: 8rem; overflow: hidden; }
.chroma .c, .chroma .c1, .chroma .cm, .chroma .cs, .chroma .ch, .chroma .cp, .chroma .cpf { font-style: italic; opacity: 0.6; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt, .chroma .nt { font-weight: bold; }
.chroma .hl { display: block; width: 100%; background: rgba(0, 0, 0, 0.06); }
.code-block__body { position: relative; }
.code-block__more {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  padding: 0.3em 0.9em;
  border: 1px solid var(--color-text);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}
.code-block__more:hover,
.code-block__more:focus-visible { border-color: var(--color-accent); color: var(--color-accent); }
.code-block.is-collapsed .code-block__body::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--color-bg));
  pointer-events: none;
}
.code-block__more { z-index: 1; }

/* Portfolio: a grid of cards. Only the image, "Visit" and the optional
   write-up link are clickable — the card itself and its title are not. The
   image link is hidden from assistive tech/tab order since "Visit" goes to
   the same place. */
.projects {
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--space-3);
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-text);
  background: var(--color-bg);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.project:hover,
.project:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 6px 18px rgba(18, 52, 188, 0.12);
  transform: translateY(-2px);
}

.project__image-link {
  display: block;
}

.project__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-bottom: 1px solid var(--color-text);
  transition: border-color 140ms ease;
}

.project:hover .project__image,
.project:focus-within .project__image {
  border-bottom-color: var(--color-accent);
}

.project__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: var(--space-2);
}

/* Cards don't use the page-title underline — the card border is the chrome. */
.project__title {
  margin: 0 0 var(--space-1);
  padding: 0;
  border: 0;
  font-size: 1.35rem;
}

.project__description {
  margin: 0 0 var(--space-2);
  line-height: 1.5;
}

.project__footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-1);
  margin: auto 0 0;
  font-variant-caps: small-caps;
  letter-spacing: 0.02em;
}


/* Mermaid diagrams (rendered client-side by js/mermaid-loader.js) */
pre.mermaid {
  background: none;
  border: 0;
  padding: 0;
  margin: var(--space-3) 0;
  overflow-x: auto;
  text-align: center;
}
pre.mermaid svg {
  max-width: 100%;
  height: auto;
}
/* Mermaid wraps cluster titles at 200px but only reserves one line for
   them, so a wrapped title overlaps the diagram. Keep titles on one line. */
pre.mermaid .cluster-label foreignObject { overflow: visible; }
pre.mermaid .cluster-label foreignObject > div {
  white-space: nowrap !important;
  max-width: none !important;
  color: var(--color-accent) !important;
  font-weight: bold;
  /* Pull the title above and to the left of its cluster box, instead of
     sitting inside it. */
  transform: translate(-0.5em, -1.6em);
}

.math-block {
  margin: 1.5em 0;
  /* overflow-x: auto alone makes overflow-y compute to auto too, and MathML
     often overflows by a few px vertically — that turned the block into a
     vertical scroller that swallowed the mouse wheel. Only scroll sideways. */
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25em 0;
}

/* Adjacent button groups (about page) sit side by side. The gap is explicit
   so it doesn't depend on whitespace between them in the HTML, which dev
   (`hugo server`) keeps and a minified prod build strips. */
.button-group + .button-group {
  margin-left: 0.25em;
  vertical-align: top;
}
