/* The home page has no H1 in its Markdown (the banner image stands in for it) */
.md-content__inner > h2:first-child { margin-top: .5rem; }

/* ---------- Cards ---------- */

.md-typeset .grid.cards > ul > li,
.md-typeset .grid > .card {
  border-radius: .6rem;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.md-typeset .grid.cards > ul > li:hover {
  transform: translateY(-2px);
}

.md-typeset .lg {
  font-size: 2.2em;
  vertical-align: middle;
}

.md-typeset .book-icon { color: var(--md-primary-fg-color); }
.md-typeset .book-icon.soon { color: var(--md-default-fg-color--lighter); }
.md-typeset .feature-icon { color: var(--md-accent-fg-color); }

.md-typeset .badge-soon {
  display: inline-block;
  padding: .1rem .6rem;
  border-radius: 1rem;
  font-size: .65rem;
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}

/* Chapter cards on a book's index page */
.md-typeset .card-label {
  display: inline-block;
  font-size: .65rem;
  font-weight: 600;
  padding: .05rem .55rem;
  border-radius: 1rem;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
}

.md-typeset .grid.cards > ul > li > p:first-child { margin-bottom: .3em; }

/* ---------- Exercise levels (custom admonitions) ---------- */

:root {
  --ex-icon-1: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="3" y="15" width="5" height="6" rx="1"/><rect x="9.5" y="9" width="5" height="12" rx="1" opacity=".3"/><rect x="16" y="3" width="5" height="18" rx="1" opacity=".3"/></svg>');
  --ex-icon-2: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="3" y="15" width="5" height="6" rx="1"/><rect x="9.5" y="9" width="5" height="12" rx="1"/><rect x="16" y="3" width="5" height="18" rx="1" opacity=".3"/></svg>');
  --ex-icon-3: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="3" y="15" width="5" height="6" rx="1"/><rect x="9.5" y="9" width="5" height="12" rx="1"/><rect x="16" y="3" width="5" height="18" rx="1"/></svg>');
  --ex-icon-4: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><polygon points="12,2 15.1,8.6 22,9.3 16.8,14 18.2,21 12,17.3 5.8,21 7.2,14 2,9.3 8.9,8.6"/></svg>');
}

.md-typeset .admonition.ex-basic,     .md-typeset details.ex-basic     { border-color: #43a047; }
.md-typeset .admonition.ex-medium,    .md-typeset details.ex-medium    { border-color: #f9a825; }
.md-typeset .admonition.ex-hard,      .md-typeset details.ex-hard      { border-color: #ef6c00; }
.md-typeset .admonition.ex-challenge, .md-typeset details.ex-challenge { border-color: #8e24aa; }

.md-typeset .ex-basic > .admonition-title,     .md-typeset .ex-basic > summary     { background-color: rgba(67, 160, 71, .1); }
.md-typeset .ex-medium > .admonition-title,    .md-typeset .ex-medium > summary    { background-color: rgba(249, 168, 37, .12); }
.md-typeset .ex-hard > .admonition-title,      .md-typeset .ex-hard > summary      { background-color: rgba(239, 108, 0, .1); }
.md-typeset .ex-challenge > .admonition-title, .md-typeset .ex-challenge > summary { background-color: rgba(142, 36, 170, .1); }

.md-typeset .ex-basic > .admonition-title::before,     .md-typeset .ex-basic > summary::before     { background-color: #43a047; -webkit-mask-image: var(--ex-icon-1); mask-image: var(--ex-icon-1); }
.md-typeset .ex-medium > .admonition-title::before,    .md-typeset .ex-medium > summary::before    { background-color: #f9a825; -webkit-mask-image: var(--ex-icon-2); mask-image: var(--ex-icon-2); }
.md-typeset .ex-hard > .admonition-title::before,      .md-typeset .ex-hard > summary::before      { background-color: #ef6c00; -webkit-mask-image: var(--ex-icon-3); mask-image: var(--ex-icon-3); }
.md-typeset .ex-challenge > .admonition-title::before, .md-typeset .ex-challenge > summary::before { background-color: #8e24aa; -webkit-mask-image: var(--ex-icon-4); mask-image: var(--ex-icon-4); }

/* ---------- Chapter page details ---------- */

/* Mermaid diagrams lay out left-to-right internally; Hebrew labels still render correctly */
.md-typeset .mermaid {
  direction: ltr;
  text-align: center;
}

/* Figure captions */
.md-typeset .caption {
  text-align: center;
  font-size: .7rem;
  color: var(--md-default-fg-color--light);
  margin-top: -.6em;
}

/* Key-points list at the end of a chapter */
.md-typeset .key-points li::marker { color: var(--md-accent-fg-color); }

/* Self-check answers */
.md-typeset .quiz ol { list-style-type: hebrew; }

/* Markdown tables: code cells LTR */
.md-typeset table:not([class]) td code { white-space: nowrap; }

/* Additional exercises (no level) */
.md-typeset .admonition.ex-extra, .md-typeset details.ex-extra { border-color: #78909c; }
.md-typeset .ex-extra > .admonition-title, .md-typeset .ex-extra > summary { background-color: rgba(120, 144, 156, .1); }
.md-typeset .ex-extra > .admonition-title::before, .md-typeset .ex-extra > summary::before { background-color: #78909c; -webkit-mask-image: var(--ex-icon-1); mask-image: var(--ex-icon-1); }

/* ---------- Memory diagram: an array drawn as cells ----------
   <div class="mem">
     <span class="mem__name">arr</span>
     <span class="mem__cell"><b>12</b><i>[0]</i><small>1000</small></span> ...
   </div>
*/
.md-typeset .mem {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  direction: ltr;
  margin: 1.2em 0 .4em;
  font-family: var(--md-code-font-family);
}

.md-typeset .mem__name {
  align-self: center;
  margin-right: .6rem;
  font-weight: 700;
  color: var(--md-accent-fg-color);
}

.md-typeset .mem__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.md-typeset .mem__cell b {
  min-width: 2.6rem;
  padding: .45rem .5rem;
  text-align: center;
  font-weight: 600;
  border: 2px solid var(--md-primary-fg-color);
  background: rgba(63, 81, 181, .08);
}

.md-typeset .mem__cell + .mem__cell b { border-left-width: 0; }
.md-typeset .mem__cell--hl b { background: rgba(255, 200, 87, .45); }
.md-typeset .mem__cell--end b { background: rgba(239, 108, 0, .15); }

.md-typeset .mem__cell i {
  font-style: normal;
  font-size: .65rem;
  color: var(--md-primary-fg-color);
  margin-top: .15rem;
}

.md-typeset .mem__cell small {
  font-size: .55rem;
  color: var(--md-default-fg-color--light);
}

/* ---------- Matrix diagram ---------- */
.md-typeset .matrix-wrap {
  display: flex;
  justify-content: center;
  direction: ltr;
}

.md-typeset table.matrix {
  display: table;
  border-collapse: collapse;
  font-family: var(--md-code-font-family);
  font-size: .75rem;
}

.md-typeset table.matrix td,
.md-typeset table.matrix th {
  width: 2.3rem;
  height: 2rem;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--md-default-fg-color--lighter);
}

.md-typeset table.matrix th {
  border: none;
  font-size: .6rem;
  font-weight: 400;
  color: var(--md-primary-fg-color);
  background: none;
}

.md-typeset table.matrix td.d1 { background: rgba(255, 200, 87, .55); }
.md-typeset table.matrix td.d2 { background: rgba(0, 137, 123, .25); }
.md-typeset table.matrix td.r0 { background: rgba(63, 81, 181, .15); }
.md-typeset table.matrix td.r1 { background: rgba(0, 137, 123, .18); }
.md-typeset table.matrix td.r2 { background: rgba(239, 108, 0, .18); }
.md-typeset .mem__cell.r0 b { background: rgba(63, 81, 181, .15); }
.md-typeset .mem__cell.r1 b { background: rgba(0, 137, 123, .18); }
.md-typeset .mem__cell.r2 b { background: rgba(239, 108, 0, .18); }

/* ---------- Lab task (lab books) ---------- */
:root {
  --lab-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 2h6v2h-1v5.2l5.6 9.3A2 2 0 0 1 17.9 22H6.1a2 2 0 0 1-1.7-3.5L10 9.2V4H9z"/></svg>');
}
.md-typeset .admonition.lab, .md-typeset details.lab { border-color: #00897b; }
.md-typeset .lab > .admonition-title, .md-typeset .lab > summary { background-color: rgba(0, 137, 123, .1); }
.md-typeset .lab > .admonition-title::before, .md-typeset .lab > summary::before {
  background-color: #00897b;
  -webkit-mask-image: var(--lab-icon);
  mask-image: var(--lab-icon);
}

/* Links that open in a new tab get a small "external" mark */
.md-typeset a[target="_blank"]::after {
  content: "";
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-inline-start: .2em;
  vertical-align: -.05em;
  background-color: currentColor;
  -webkit-mask: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7h-2z"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7h-2z"/></svg>') center / contain no-repeat;
}

/* ...but not on buttons */
.md-typeset .md-button[target="_blank"]::after { display: none; }

/* ---------- abin icon in the Material header: light chip so the navy mark reads on the indigo bar ---------- */
.md-header__button.md-logo img {
  background: #fff;
  border-radius: .3rem;
  padding: .1rem;
  height: 1.6rem;
  width: auto;
}
