/* Fold-out sections (scripts/fold.js): the fold of Physik Radar and the project apps, in one colour.
   A section is a card with a header band (number, title, counts, round toggle); while open the band pins to the top
   of the window. A part inside a section folds the same way one level down and pins under its section's band. */

:root {
  --fold-accent: var(--accent, #7a1f2b);
  --fold-card: var(--card, #fffaf3);
  --fold-line: var(--line-strong, #cdc1ae);
  --fold-tint: color-mix(in srgb, var(--fold-accent) 5%, var(--fold-card));
  --fold-tint-2: color-mix(in srgb, var(--fold-accent) 3%, var(--fold-card));
  --fold-soft-line: color-mix(in srgb, var(--fold-accent) 28%, var(--fold-card));
  --fold-top: 0px;
}

/* ---------- level 1: the section card ---------- */
.fsec {
  background: var(--fold-card);
  border: 1px solid var(--fold-line);
  border-left: 4px solid var(--fold-accent);
  border-radius: 10px;
  scroll-margin-top: calc(var(--fold-top) + 12px);
  transition: border-color var(--fold-open) var(--fold-ease), box-shadow var(--fold-open) var(--fold-ease);
}
.fsec[data-collapsed="1"]:hover { border-color: var(--fold-soft-line); border-left-color: var(--fold-accent); }
.fsec[data-collapsed="0"] { border-color: var(--fold-soft-line); border-left-color: var(--fold-accent); box-shadow: 0 12px 32px -20px rgba(60, 40, 20, .35); }

.fs-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 16px 20px; border-radius: 6px 10px 10px 6px; background: var(--fold-tint);
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; transition: box-shadow .15s ease;
}
.fs-head:hover { box-shadow: inset 0 0 0 999px rgba(28, 21, 24, .03); }
.fsec[data-collapsed="0"] > .fs-head { position: sticky; top: var(--fold-top); z-index: 6; border-radius: 6px 10px 0 0; box-shadow: 0 1px 0 var(--fold-soft-line); }
.fsec[data-collapsed="0"] > .fs-head:hover { box-shadow: 0 1px 0 var(--fold-soft-line), inset 0 0 0 999px rgba(28, 21, 24, .03); }
.fs-main { min-width: 0; }
.fs-side { display: flex; align-items: center; flex: none; }
.fs-main > h2, .fs-main > h3, .fs-main > h4 { margin: 0; }
.fs-counts { margin: 4px 0 0; font: 12px/1.5 var(--mono); color: var(--muted, #8b8079); letter-spacing: 0; text-transform: none; }
.fs-num {
  display: inline-block; min-width: 26px; padding: 2px 6px; margin-right: 12px; border-radius: 4px;
  background: var(--fold-accent); color: #fff; font: 500 11px/1.4 var(--mono); letter-spacing: .04em; text-align: center; vertical-align: .45em;
}

.fs-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--fold-soft-line); border-radius: 50%; background: var(--fold-card); color: var(--fold-accent); cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color var(--fold-open) var(--fold-ease), transform .1s ease;
}
.fs-head:hover .fs-toggle, .fs-toggle:hover { border-color: var(--fold-accent); }
.fs-toggle:active { transform: scale(.94); }
.fs-toggle:focus-visible, .fold-tool:focus-visible, .fs-more:focus-visible { outline: 2px solid var(--fold-accent); outline-offset: 2px; }
[data-collapsed="0"] > .fs-head .fs-toggle { background: var(--fold-accent); border-color: var(--fold-accent); color: #fff; }
.chev { display: block; transition: transform var(--fold-open) var(--fold-ease); }
[data-collapsed="0"] > .fs-head .chev, [data-card][data-collapsed="0"] .fs-more .chev { transform: rotate(180deg); }

/* the body unfolds by its own height */
.fold { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; overflow-anchor: none; transition: grid-template-rows var(--fold-open) var(--fold-ease); }
.fold > .fold-i { overflow: clip; min-height: 0; min-width: 0; }  /* clip, not hidden: lets the headers inside pin to the window */
.fold > .fold-i > * { transition: opacity var(--fold-open) var(--fold-ease), transform var(--fold-open) var(--fold-ease); }
.fold[data-open="0"] { grid-template-rows: 0fr; transition-duration: var(--fold-close); }
.fold[data-open="0"] > .fold-i > * { opacity: 0; transform: translateY(-8px); transition-duration: var(--fold-close); }
.fs-body { padding: 20px 22px 22px; }
.fold-no-anim .fold, .fold-no-anim .fold > .fold-i > *, .fold-no-anim .chev, .fold-no-anim .fs-toggle, .fold-no-anim .fsec { transition: none !important; }

/* ---------- level 2: a part inside a section ---------- */
.fsub { margin: 16px 0 0; border: 1px solid var(--fold-line); border-radius: 8px; background: var(--fold-card); scroll-margin-top: calc(var(--fold-top) + var(--head-h, 64px) + 8px); }
.fsub > .fs-head { padding: 8px 10px 8px 16px; border-radius: 8px; background: var(--fold-tint-2); }
.fsub[data-collapsed="0"] > .fs-head { position: sticky; top: calc(var(--fold-top) + var(--head-h, 64px)); z-index: 5; border-radius: 8px 8px 0 0; box-shadow: 0 1px 0 var(--fold-soft-line); }
.fsub[data-collapsed="0"] > .fs-head:hover { box-shadow: 0 1px 0 var(--fold-soft-line), inset 0 0 0 999px rgba(28, 21, 24, .03); }
.fsub .fs-toggle { width: 30px; height: 30px; }
.fsub > .fold > .fold-i > .fs-body { padding: 14px 18px 16px; }

/* ---------- Expand all / Collapse all ---------- */
.fold-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin: 0 0 12px; }
.fold-tool {
  padding: 6px 13px; border: 1px solid var(--fold-line); border-radius: 999px; background: var(--fold-card);
  font: 12px var(--mono); color: var(--ink-2, #3a322e); cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.fold-tool:hover { border-color: var(--fold-accent); color: var(--fold-accent); }

/* ---------- cards: details behind More / Less ---------- */
.fs-more {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--fold-line); border-radius: 4px;
  background: transparent; font: 12px var(--mono); color: var(--muted, #8b8079); cursor: pointer;
}
.fs-more:hover, [data-card][data-collapsed="0"] .fs-more { border-color: var(--fold-accent); color: var(--fold-accent); }

@media (max-width: 720px) {
  .fs-head { padding: 14px; }
  .fs-toggle { width: 34px; height: 34px; }
  .fs-body { padding: 16px 14px 18px; }
  .fsub > .fs-head { padding: 7px 8px 7px 12px; }
  .fsub > .fold > .fold-i > .fs-body { padding: 12px 12px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .fold, .fold > .fold-i > *, .chev, .fs-toggle, .fsec, .fs-head { transition-duration: .01ms !important; }
}
@media print {
  .fs-toggle, .fold-tools, .fs-more { display: none !important; }
  .fold { grid-template-rows: 1fr !important; }
  .fold > .fold-i > * { opacity: 1 !important; transform: none !important; }
  .fs-head { position: static !important; }
}

/* ---------- the site's structures ---------- */

/* lecture notes */
.paper .psec.fsec { margin-top: 14px; padding-top: 0; border-top: 1px solid var(--fold-line); scroll-margin-top: calc(var(--fold-top) + 12px); }
.paper .psec.fsec:first-child { margin-top: 0; }
.paper .psec > .fs-head h3 { margin: 0; font: 400 clamp(26px, 2.6vw, 34px)/1.1 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.paper .ppart h4 { margin: 0; font-size: 21px; }
.paper .ppart.fsub { margin-top: 18px; }
.paper .fs-body > p:first-child { margin-top: 0; }
.paper .fs-body > :last-child { margin-bottom: 0; }

/* From symbols to code */
.walk.fsec { margin-top: 64px; }
.walk.fsec > .fs-head h2 { margin: 0; padding: 0; font-weight: 400; font-size: clamp(26px, 2.6vw, 34px); line-height: 1.1; letter-spacing: -.02em; }
.walk.fsec > .fs-head h2::before { display: none; }
.walk.fsec .walk__head { margin-bottom: 14px; }

/* the home page */
.section.fsec { padding-top: 0; margin-top: 28px; }
.content > .fold-tools { margin-top: 104px; margin-bottom: 0; }
.section.fsec > .fs-head h2 { margin: 0; padding: 0; font-size: clamp(26px, 2.6vw, 34px); line-height: 1.1; }
.section.fsec > .fs-head h2::before { display: none; }
.section.fsec > .fold > .fold-i > .fs-body { padding: 24px 24px 28px; }

/* the Portfolios page */
.proj.fsec { overflow: clip; }
.proj.fsec > .fs-head h2.fs-title { margin: 0; font: 400 clamp(28px, 3vw, 38px)/1.08 var(--serif); letter-spacing: -.012em; }
.proj.fsec > .fs-head .fs-counts { text-transform: none; }
.proj.fsec > .fold > .fold-i > .fs-body { padding: 0; }
.proj__part.fsub { margin-top: 18px; padding-top: 0; border-top: 1px solid var(--fold-line); }
.proj__part.fsub > .fs-head h3 { margin: 0; font-size: 24px; }
.proj__part .fs-body > p { margin: 0 0 14px; max-width: 820px; font: 18px/1.68 var(--tex); color: var(--ink); }
.proj__part .fs-body > .proj__note { margin: 18px 0 0; font: 12px/1.5 var(--mono); color: var(--muted); }

@media (max-width: 980px) {
  .content > .fold-tools { margin-top: 48px; }
}

/* the simulations list: each card's details behind More / Less */
.entry__foot .fs-more { margin-left: auto; }
.entry__more { padding-top: 2px; }

.fold-tools:has(+ #catalog) { margin: 22px 0 -14px; }
.paper .psec > .fs-head h3 { display: block; }
.paper .psec > .fs-head .psec__n { display: inline-block; position: relative; margin-right: 12px; vertical-align: .2em; top: 0; }
.paper .psec > .fs-head .star { margin-left: 8px; }

/* the simulations list: one card per simulation, titled and numbered by its figure */
.cat__list.cat__list--sorted { display: flex; flex-direction: column; gap: 12px; }
.cat__list.cat__list--sorted:empty { display: none; margin-top: 0; }
.simfold.fsec { scroll-margin-top: calc(var(--fold-top) + 12px); }
.simfold > .fs-head h2.fs-title { margin: 0; font: 400 clamp(26px, 2.6vw, 32px)/1.1 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.simfold .entry { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); grid-template-rows: auto 1fr; column-gap: 26px;
  border: 0; border-radius: 0; background: transparent; overflow: visible; }
.simfold .entry__fig { grid-column: 1; grid-row: 1; padding: 0; }
.simfold .entry__cap { grid-column: 1; grid-row: 2; padding: 8px 0 0; align-self: start; }
.simfold .entry__body { grid-column: 2; grid-row: 1 / span 2; padding: 0; }
.simfold .entry h3 { display: none; }   /* the title is already the card's header */
@media (max-width: 860px) {
  .simfold .entry { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .simfold .entry__fig, .simfold .entry__cap, .simfold .entry__body { grid-column: 1; grid-row: auto; }
  .simfold .entry__body { padding-top: 14px; }
}
.simfold .entry::before, .simfold .entry::after { content: none; display: none; }
