/* Shared by every page except the apps. One design throughout; each section
   swaps the accent: body.s-math is blue, body.s-torah is burgundy and RTL.
   The theme follows the system unless the menu's toggle set
   <html data-theme="light|dark"> (remembered in localStorage). */

:root {
  --bg: #f8f5ef;
  --bg-torah: #f6f0e4;
  --surface: #fffdf9;
  --ink: #1f1e1c;
  --muted: #5e5b55;
  --line: #e3ddd1;
  --math: #2c4fa3;
  --math-soft: #e7ecf7;
  --torah: #8a2f3b;
  --torah-soft: #f3e4e0;
  --accent: var(--math);
  --accent-soft: var(--math-soft);
  --f-display: "Newsreader", Georgia, serif;
  --f-body: "Inter", "Segoe UI", system-ui, sans-serif;
  /* Narkisim is a Windows font (not ours to serve), so it shows where it is
     installed; elsewhere Frank Ruhl Libre stands in. */
  --f-hebrew: "Narkisim", "Frank Ruhl Libre", "David", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b;
    --bg-torah: #17151a;
    --surface: #1b1e25;
    --ink: #e7e8ec;
    --muted: #a0a5b2;
    --line: #2d313b;
    --math: #8fa9ff;
    --math-soft: #212a43;
    --torah: #f0a3a8;
    --torah-soft: #3a2328;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b;
  --bg-torah: #17151a;
  --surface: #1b1e25;
  --ink: #e7e8ec;
  --muted: #a0a5b2;
  --line: #2d313b;
  --math: #8fa9ff;
  --math-soft: #212a43;
  --torah: #f0a3a8;
  --torah-soft: #3a2328;
  color-scheme: dark;
}
body.s-torah { --accent: var(--torah); --accent-soft: var(--torah-soft); --bg: var(--bg-torah); }

/* The two section motifs, as masks so they take the accent color in either
   theme: the triangular lattice of an Ã₂ apartment for mathematics, ruled
   lines for Torah. */
:root {
  --lattice: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='55.426'%3E%3Cpath d='M0 0H32M0 27.713H32M0 55.426H32M0 0L32 55.426M32 0L0 55.426' stroke='%23000' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  --lattice-size: 32px 55.426px;
  --ruled: repeating-linear-gradient(to bottom, #000 0 1px, transparent 1px 22px);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--f-body);
}
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 16px 48px;
}
a { color: var(--accent); }

h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.15; }
h1 { font-size: clamp(2.4rem, 7vw, 3.4rem); margin: 0; }
h2 { font-size: 1.6rem; margin: 56px 0 4px; }
h3 { font-size: 1.25rem; margin: 12px 0 4px; }

/* Kept for screen readers and search engines, not shown. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.home .intro > .lede:first-of-type { margin-top: 8px; }

.role { margin: 6px 0 0; color: var(--muted); font-weight: 500; }
.lede { font-size: 1.12rem; max-width: 60ch; margin: 24px 0 0; }
.note { color: var(--muted); margin: 0 0 20px; }

.contact { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 20px 0 0; padding: 0; list-style: none; font-size: .95rem; }
.contact a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; }
.contact a:hover { color: var(--accent); }
.contact svg { width: 16px; height: 16px; flex: none; }

/* The site menu (nav.js) is a bar across the top. Its shadow styles read
   these --n-* variables, so it matches the page and the theme toggle; in the
   apps they are unset and it falls back to its own colors. */
site-nav {
  position: sticky;
  top: 0;
  margin: 0;
  max-width: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  --n-max: 760px;
  --n-surface: var(--surface);
  --n-ink: var(--ink);
  --n-muted: var(--muted);
  --n-line: var(--line);
  --n-hover: var(--accent-soft);
  --n-math: var(--math);
  --n-torah: var(--torah);
  --n-bar-border: 0;
  --n-bar-bg: transparent;
  --n-bar-radius: 0;
  --n-theme: grid;
}
.s-home site-nav { --n-max: 1040px; }

/* A header with class .motif gets a band of the section's motif across the
   top of the window, fading out downward. It is drawn on body, which spans
   the window exactly, so it never makes the page scroll sideways. */
body:has(.motif)::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 420px;
  z-index: -1;
  background: var(--accent);
  opacity: .16;
  -webkit-mask: var(--lattice) 0 0 / var(--lattice-size), linear-gradient(#000 20%, transparent);
  -webkit-mask-composite: source-in;
  mask: var(--lattice) 0 0 / var(--lattice-size), linear-gradient(#000 20%, transparent);
  mask-composite: intersect;
  pointer-events: none;
}
body:has(.motif.ruled)::before {
  opacity: .14;
  -webkit-mask: var(--ruled), linear-gradient(#000 20%, transparent);
  -webkit-mask-composite: source-in;
  mask: var(--ruled), linear-gradient(#000 20%, transparent);
  mask-composite: intersect;
}

/* ---- Cards ---------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card p { margin: 0 0 16px; color: var(--muted); font-size: .95rem; }
.thumb { width: 100%; height: 90px; color: var(--line); background: var(--accent-soft); border-radius: 8px; padding: 10px; }
.thumb .fill { fill: var(--accent); opacity: .55; }
.go { margin-top: auto; color: var(--accent); font-weight: 600; font-size: .95rem; }

/* ---- Homepage: the name, then one half per section ------------------------ */
.home { max-width: 1040px; }
.home .intro { text-align: center; }
.home .lede { margin-inline: auto; }
.home .lede.he { font-family: var(--f-hebrew); font-size: 1.25rem; }
.home .lede.he + .lede { margin-top: 10px; }
.home .contact { justify-content: center; }

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 48px;
}
.half {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 340px;
  padding: 32px 28px 28px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--ink);
  text-decoration: none;
  transition: transform .2s;
}
.half.math { --accent: var(--math); --accent-soft: var(--math-soft); }
.half.torah { --accent: var(--torah); --accent-soft: var(--torah-soft); }
.half::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--accent);
  opacity: .2;
  transition: opacity .2s;
  -webkit-mask: var(--lattice) 0 0 / var(--lattice-size), linear-gradient(to top, #000, transparent 75%);
  -webkit-mask-composite: source-in;
  mask: var(--lattice) 0 0 / var(--lattice-size), linear-gradient(to top, #000, transparent 75%);
  mask-composite: intersect;
}
.half.torah::before {
  -webkit-mask: var(--ruled), linear-gradient(to top, #000, transparent 75%);
  -webkit-mask-composite: source-in;
  mask: var(--ruled), linear-gradient(to top, #000, transparent 75%);
  mask-composite: intersect;
}
.half:hover { transform: translateY(-3px); }
.half:hover::before { opacity: .32; }
.half:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.half .kicker { color: var(--accent); font-size: .85rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.half h2 { margin: 6px 0 12px; font-size: clamp(2.4rem, 6vw, 3.2rem); color: var(--accent); }
.half p { margin: 0 0 24px; max-width: 34ch; font-size: 1.02rem; }
.half .go { font-size: 1rem; }
.half.torah .kicker { letter-spacing: 0; text-transform: none; }
.half.torah h2, .half.torah p { font-family: var(--f-hebrew); }
.half.torah h2 { font-size: clamp(2.7rem, 7vw, 3.6rem); font-weight: 700; }
.half.torah p { font-size: 1.2rem; }

/* ---- Math section: lists of papers, teaching, etc. ------------------------ */
/* The profile (photo, name, advisors, email, CV) stands in a sticky column
   beside the content; below 880px it sits above it, and from 1100px the page
   fits in one window (after the placeholders). The content opens with the hero:
   a random walk on an Ã₂ apartment drawn live by math.js, behind the title
   and the research summary, which a toggle switches between two versions. */
.math-page { max-width: 1080px; padding-top: 40px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0 48px; align-items: start; }
.math-page > footer { grid-column: 2; }
.profile { position: sticky; top: 76px; display: grid; gap: 18px; }
.profile .who { display: grid; gap: 14px; }
.photo {
  position: relative; display: grid; place-items: end center;
  width: 132px; max-width: 100%; aspect-ratio: 5 / 6; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--accent-soft); color: var(--accent); overflow: hidden;
}
.photo svg { width: 80%; }
.photo span { position: absolute; top: 8px; inset-inline: 0; text-align: center; font-size: .72rem; color: var(--muted); }
html:not(.draft) .todo-photo { display: none; }
.pname { font-size: 1.9rem; }
.ppos { margin: 6px 0 0; color: var(--muted); font-size: .95rem; line-height: 1.45; }
.padv { margin: 8px 0 0; font-size: .95rem; line-height: 1.45; }
.padv a { text-underline-offset: 2px; white-space: nowrap; }
.pmail { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .92rem; }
.pmail a { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.pmail a:hover { color: var(--accent); }
.pmail svg { width: 16px; height: 16px; flex: none; }
.pcv { font-size: .92rem; font-weight: 500; }
.pcv .todo { margin: 0; }

.hero {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: flex-end; min-height: 300px; padding: 36px 32px 28px;
  border-radius: 16px; background: var(--accent-soft);
}
.hero .lattice { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.hero-text { display: grid; gap: 10px; max-width: 58ch; }
.hero-title { margin: 0; font-size: clamp(2.6rem, 6vw, 3.4rem); color: var(--accent); }
.register { display: grid; gap: 10px; }
.seg { display: inline-flex; justify-self: start; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.seg button { padding: 4px 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
.stmt { margin: 0; max-width: 60ch; font-size: 1.08rem; }
:is(.seg button, .bubble a, .bubble button):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.math-page .part > h2 { margin-top: 56px; }
.abstract { margin: 6px 0 4px; }
.abstract summary { width: fit-content; color: var(--accent); font-size: .9rem; font-weight: 500; cursor: pointer; }
/* The abstract is a bubble under the toggle; math.js closes it on a click
   outside it or on Escape. */
.abstract { position: relative; }
.abstract p {
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; margin: 0; padding: 14px 16px;
  width: min(68ch, calc(100vw - 32px)); font-size: .95rem; line-height: 1.6; cursor: default; text-align: left;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px -8px rgb(0 0 0 / .3); animation: pop .12s ease-out;
}
.stmt .katex, .abstract .katex { font-size: 1.05em; }
.nowrap { white-space: nowrap; }
/* A paper: the whole entry is the target, and a click opens a small bubble
   of links where it landed. */
/* The highlight reaches past the text by a spread shadow, so the rules
   between entries stay aligned with the column. */
.entries li.paper { position: relative; border-radius: 2px; cursor: pointer; transition: background-color .15s, box-shadow .15s; }
.entries li.paper:hover, .entries li.paper[aria-expanded="true"] { background: var(--accent-soft); box-shadow: 0 0 0 10px var(--accent-soft); border-radius: 6px; }
.entries li.paper:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bubble {
  position: absolute; z-index: 30; display: flex; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px -8px rgb(0 0 0 / .3); cursor: default;
  animation: pop .12s ease-out;
}
.bubble[hidden] { display: none; }
/* The tip points at the click; math.js sets --tip. */
.bubble::before {
  content: ""; position: absolute; top: -6px; left: var(--tip, 24px);
  width: 10px; height: 10px; transform: rotate(45deg);
  background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
}
.bubble a, .bubble button {
  position: relative; display: block; padding: 6px 12px; border: 0; border-radius: 6px;
  background: none; color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.bubble a:hover, .bubble button:hover { background: var(--accent-soft); color: var(--accent); }
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.bib {
  margin: 10px 0 0; padding: 12px 14px; overflow-x: auto; border-radius: 8px; background: var(--accent-soft);
  font: .8rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink); cursor: text;
}
.apps .card h3 { margin: 14px 0 0; }
.share + .share { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

@media (max-width: 880px) {
  .math-page { grid-template-columns: 1fr; gap: 28px; }
  .math-page > footer { grid-column: auto; margin-top: 44px; }
  .profile { position: static; }
  .profile .who { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .photo { width: 84px; }
  .pname { font-size: 1.6rem; }
  .hero { min-height: 280px; padding: 28px 20px 22px; }
}
/* On a phone the lattice is a band above the title (math.js), not behind the text. */
@media (max-width: 600px) { .hero { padding-top: 120px; } }

.part { scroll-margin-top: 16px; }
.part > h2 { font-size: 2rem; margin: 64px 0 0; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.part > section > h3 { font-size: 1.4rem; margin: 36px 0 4px; }
.entries { list-style: none; padding: 0; margin: 16px 0 0; }
.entries li { padding: 14px 0; border-top: 1px solid var(--line); }
.entries li:last-child { border-bottom: 1px solid var(--line); }
.entries .t { font-weight: 600; }
.entries .m { color: var(--muted); font-size: .92rem; }
.entries .links a { font-size: .9rem; font-weight: 500; margin-inline-end: 12px; }

/* Placeholders still to be filled in. They show only on localhost (the
   page's head script adds .draft); on the live site the section is hidden. */
.todo {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  color: var(--muted);
  font-size: .92rem;
}
html:not(.draft) :is(section, .pcv):has(> .todo) { display: none; }

/* On a computer screen the whole math page fits in one window: a shorter
   hero with the toggle beside the title, the subsections of each part as
   cards side by side, three to a row, and the footer at the foot of the profile column. */
@media (min-width: 1100px) {
  .math-page { max-width: 1400px; padding-top: 16px; padding-bottom: 12px; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 40px; }
  .profile { position: static; }
  .math-page > footer { grid-column: 1; grid-row: 2; align-self: end; margin: 0; }
  .main-col { grid-column: 2; grid-row: 1 / span 2; }

  .hero { min-height: 0; padding: 20px 28px 22px; }
  .hero-text { grid-template-columns: auto 1fr; align-items: center; column-gap: 20px; max-width: 64ch; }
  .hero-title { font-size: 2.4rem; }
  .register { display: contents; }
  .stmt { grid-column: 1 / -1; font-size: 1.02rem; line-height: 1.55; }

  .math-page .part > h2 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 1.35rem; padding-bottom: 4px; }
  /* The subsections of a part stand side by side, each a card: its title
     on a shaded strip, its content below. */
  .part { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto; grid-auto-rows: 1fr; gap: 12px; }
  .part > section { display: flex; flex-direction: column; margin: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .part > section > h3 { margin: 0; padding: 7px 16px; border-bottom: 1px solid var(--line); border-radius: 11px 11px 0 0; background: var(--accent-soft); color: var(--accent); font-size: 1.1rem; }
  .part > section > :not(h3) { margin: 0 16px; }
  .part > section > h3 + * { margin-top: 10px; }
  .part > section > :last-child { margin-bottom: 12px; }
  .entries li, .entries li:last-child { padding: 0; border: 0; }
  .entries li + li { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
  .entries li.paper:hover, .entries li.paper[aria-expanded="true"] { box-shadow: 0 0 0 8px var(--accent-soft); }
  .entries .t { line-height: 1.45; }
  .entries .m { margin-top: 3px; line-height: 1.45; }
  .entries .t a { text-decoration: none; }
  .todo { margin: 0; }
  .abstract { margin: 8px 0 0; }
  .abstract summary {
    display: inline-block; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; list-style: none;
    background: var(--surface); color: var(--ink); font-size: .85rem; font-weight: 500; line-height: 1.75;
  }
  .abstract summary::-webkit-details-marker { display: none; }
  .abstract summary:hover, .abstract[open] summary { border-color: var(--accent); color: var(--accent); }
  /* The apps and the tools: in each part the note, then the programs as
     small cards, one under the other. */
  .part > section .note { margin: 0; font-size: .92rem; line-height: 1.45; }
  /* Research has four columns, and the apps and tools take two of them:
     one wide box, its two parts side by side with a rule between. */
  .part:has(.share) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .part > section:has(> .share) { grid-column: span 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto 1fr; }
  .part > section > h3:has(+ .share) { grid-column: 1 / -1; }
  .part > section > .share { margin: 0; padding: 10px 16px 12px; }
  .part > section > .share + .share { margin-top: 0; padding-top: 10px; border-top: 0; border-left: 1px solid var(--line); }
  .apps.cards { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
  .apps .card { flex-direction: row; align-items: center; gap: 8px; padding: 1px 10px 1px 3px; border-radius: 10px; }
  .apps .thumb { flex: none; width: 42px; height: 28px; padding: 2px; border-radius: 7px; }
  .apps .card h3 { margin: 0; font: 600 .9rem/1.4 var(--f-body); }
  /* A card whose content is one link (a seminar, the planner) is a target
     as a whole: its title's link covers the card. */
  .part > section:has(> .entries a):not(:has(.paper)) { position: relative; transition: background-color .15s, border-color .15s; }
  .part > section:has(> .entries a):not(:has(.paper)) .t a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
  .part > section:has(> .entries a):not(:has(.paper)):hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
  .part > section:has(> .entries a):not(:has(.paper)):has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
  .part > section:has(> .entries a):not(:has(.paper)) .t a:focus-visible { outline: 0; }
  /* Likewise a part of the apps and tools box with one program (Buildings
     Simulator, Glossa): the program's card link covers the whole half. The
     card does not lift on hover, since a transform would shrink the link's
     cover to the card itself. */
  .share:has(> .apps > .card:only-child) { position: relative; border-radius: 0 0 0 11px; transition: background-color .15s; }
  .share + .share:has(> .apps > .card:only-child) { border-radius: 0 0 11px 0; }
  .share:has(> .apps > .card:only-child) .card::after { content: ""; position: absolute; inset: 0; }
  .share:has(> .apps > .card:only-child):hover { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
  .share:has(> .apps > .card:only-child) .card:hover { transform: none; }
  .share:has(> .apps > .card:only-child):has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
  .share:has(> .apps > .card:only-child) .card:focus-visible { outline: 0; }

}

/* ---- Torah section (Hebrew, RTL) ------------------------------------------ */
.s-torah .wrap { font-family: var(--f-hebrew); font-size: 1.15rem; line-height: 1.75; }
.s-torah h1, .s-torah h2, .s-torah h3 { font-family: var(--f-hebrew); font-weight: 700; }
.s-torah .lede { font-size: 1.2rem; }

.topics-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 0; padding: 0; list-style: none; }
.topics-nav a, .chip {
  display: block;
  padding: 2px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}
.topics-nav a:hover, .chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }

/* Search and book filter (torah.js). */
.finder { margin: 28px 0 0; }
.finder input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.finder input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.finder .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.empty { color: var(--muted); margin: 24px 0 0; }
.results .where { color: var(--muted); font-size: .95rem; margin-inline-start: 8px; }

/* This week's parasha (torah.js fills it in from hebcal.com). */
.this-week {
  margin: 32px 0 0;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--accent-soft);
  border-inline-start: 4px solid var(--accent);
}
.this-week h2 { margin: 0; font-size: 1.35rem; }
.this-week .label { color: var(--accent); font-size: .95rem; font-weight: 700; }
.this-week ul { list-style: none; margin: 8px 0 0; padding: 0; }
.this-week li { padding: 2px 0; }
.this-week a { color: var(--ink); }
.this-week a:hover { color: var(--accent); }
.this-week .where { color: var(--muted); font-size: .95rem; }

.topic { scroll-margin-top: 72px; }
.topic h2 { border-bottom: 2px solid var(--accent); padding-bottom: 6px; display: inline-block; }
.pieces { list-style: none; padding: 0; margin: 8px 0 0; }
.pieces li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.pieces a { color: var(--ink); text-decoration: none; font-weight: 700; }
.pieces a:hover { color: var(--accent); }
.pieces p { margin: 2px 0 0; color: var(--muted); font-size: 1rem; }
.kind {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 700;
  vertical-align: 2px;
}
/* Where a piece was published, as a small rounded badge by its title. */
.published, .pieces a.published {
  display: inline-block;
  margin-inline-start: 10px;
  padding: 1px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--f-hebrew);
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.6;
  text-decoration: none;
  vertical-align: 2px;
  white-space: nowrap;
}
a.published:hover, .pieces a.published:hover { background: var(--accent); color: var(--bg); }
h1 .published { font-size: 1rem; vertical-align: .5em; }

/* A single piece: the heading over the page, then the text on a sheet of
   paper, centered, at a comfortable line length. */
.piece { max-width: 800px; margin-inline: auto; }
.wrap:has(> .piece) { max-width: 832px; }
.reader > .body {
  padding: 44px 56px 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 10px 30px -12px rgb(0 0 0 / .14);
  text-align: justify;
  hyphens: auto;
}
.reader > .body p { margin: 0 0 .9em; }
.piece .body :is(h2, h3, h4, .sec) { scroll-margin-top: 72px; }
@media (max-width: 640px) {
  .reader > .body { margin-inline: -8px; padding: 28px 20px 24px; }
}

/* The table of contents (torah.mjs, when a piece has headings). On a narrow
   screen it is a folded box above the text; on a wide one it stands beside
   the page, on the side where the lines start, stays in view, and marks the part being read (torah.js). */
.toc { margin: 24px 0 0; font-size: 1rem; line-height: 1.4; }
.toc summary {
  cursor: pointer;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
}
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 5px 12px;
  border-inline-start: 2px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}
.toc .sub a { padding-inline-start: 26px; font-size: .9rem; }
.toc .num { font-family: var(--f-body); font-size: .85em; font-variant-numeric: tabular-nums; }
.piece .body .num { color: var(--accent); font-family: var(--f-body); font-size: .8em; margin-inline-end: 4px; }
.toc a:hover { color: var(--accent); }
.toc a[aria-current="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
@media (min-width: 1180px) {
  .wrap:has(> .piece.has-toc) { max-width: 1112px; }
  .piece.has-toc { max-width: 1080px; }
  .piece.has-toc > :not(.reader) { max-width: 800px; margin-inline-start: 280px; }
  .has-toc .reader { display: grid; grid-template-columns: 240px minmax(0, 800px); gap: 40px; align-items: start; }
  .has-toc .reader > .body { grid-column: 2; grid-row: 1; }
  .has-toc .toc {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 72px;
    margin: 32px 0 0;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }
  .has-toc .toc summary {
    pointer-events: none;
    padding: 0 12px 6px;
    border: 0;
    background: none;
    list-style: none;
  }
  .has-toc .toc summary::-webkit-details-marker { display: none; }
}
/* How far along the piece the reader is, as a thin line under the menu.
   Scroll-driven, so where the browser lacks it the line just isn't there. */
@supports (animation-timeline: scroll()) {
  .piece::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: 3px;
    z-index: 1001;
    background: var(--accent);
    transform-origin: right;
    animation: read-progress linear both;
    animation-timeline: scroll(root);
  }
  [dir="ltr"] .piece::before { transform-origin: left; }
}
@keyframes read-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.piece h1 { font-size: clamp(2rem, 6vw, 2.8rem); }
.piece .meta { color: var(--muted); margin: 8px 0 0; font-size: 1rem; }
.piece .byline { margin: 2px 0 0; font-size: 1rem; font-weight: 700; color: var(--accent); }
.piece .downloads { margin: 10px 0 0; font: .85rem/1.4 var(--f-body); color: var(--muted); }
.piece .downloads a {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.piece .downloads a:hover { border-color: var(--accent); color: var(--accent); }
.piece .body { margin-top: 32px; }
.piece .body h2 { font-size: 1.5rem; margin: 40px 0 8px; }
.piece .body h3 { font-size: 1.25rem; margin: 28px 0 4px; }
.piece .body h4 { font-size: 1.1rem; margin: 24px 0 4px; }
.piece .body h5 { font-size: 1.02rem; margin: 20px 0 2px; }
.piece .body h6 { font-size: 1rem; margin: 16px 0 2px; color: var(--muted); }
/* In pieces from Word, a heading is bold, italic or underlined as in the file
   (torah.mjs puts the Word style's formatting on the text). */
.piece .body.word :is(h2, h3, h4, h5, h6) { font-weight: 400; }
.piece .body.word :is(h2, h3, h4, h5, h6) strong { font-weight: 700; }
.piece .body > p.lead::first-letter {
  color: var(--accent);
  font-weight: 700;
}
@supports (initial-letter: 2) or (-webkit-initial-letter: 2) {
  .piece .body > p.lead::first-letter {
    -webkit-initial-letter: 2;
    initial-letter: 2;
    margin-inline-end: 6px;
  }
}
.piece .body blockquote {
  margin: 20px 0;
  padding: 4px 18px;
  border-inline-start: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  /* As the quotation style in the Word files: Arial 9 beside body text in 11. */
  font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: calc(9em / 11);
}
.piece .body .ref { font-size: calc(10em / 11); }
.piece .body blockquote .source { margin: 8px 0 4px; font-family: var(--f-hebrew); }
.piece .body img { max-width: 100%; }
/* The source line above a quotation ("בבלי מכות ד, ב"). */
.piece .body .source { margin: 22px 0 -12px; font-size: 1rem; font-weight: 700; color: var(--muted); }
.piece .body .sec {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 40px 0 16px;
  color: var(--accent);
  font-weight: 700;
}
.piece .body .sec::before, .piece .body .sec::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}
.piece .body hr { border: 0; margin: 32px 0; text-align: center; color: var(--accent); }
.piece .body hr::after { content: "❖ ❖ ❖"; letter-spacing: .6em; font-size: .8rem; }
.piece .footnotes { margin-top: 48px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .95rem; color: var(--muted); }
.piece .footnotes h2 { font-size: 1.1rem; }
.piece .pdf { margin-top: 32px; }

/* Previous and next piece in the topic. */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 56px 0 0;
}
.pager a {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager .dir { display: block; color: var(--accent); font-size: .9rem; font-weight: 700; }
.pager .next { grid-column: 2; text-align: end; }

footer { margin-top: 72px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.s-torah footer { font-family: var(--f-body); }

/* Page headers and the homepage halves rise in on load. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.wrap > header, .wrap > article > h1, .split > * { animation: rise .5s ease-out both; }
.split > :nth-child(1) { animation-delay: .08s; }
.split > :nth-child(2) { animation-delay: .16s; }

@media (prefers-reduced-motion: reduce) {
  .card, .half, .half::before, .entries li.paper { transition: none; }
  .bubble { animation: none; }
  .card:hover, .half:hover { transform: none; }
  .wrap > header, .wrap > article > h1, .split > * { animation: none; }
}
