/* Small additions on top of tufte.css for the ForShor project page. */
/* Always light: tufte.css switches to a dark body under prefers-color-scheme: dark,
   but the layer graph and figures are designed for a light page. */
:root { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  body { background-color: #fffff8; color: #111; }
}
.site-links { font-size: 1rem; margin-top: 1.5rem; }
/* The site-wide navigation (every page): the three tracks, then the outside links. */
.site-nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1.6rem; margin-top: 1.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid #111; font-size: 1.05rem; width: 55%; }
.site-nav a { background: none; text-shadow: none; text-decoration: none; color: #111; padding-bottom: 1px; border-bottom: 1px solid transparent; }
.site-nav a:hover { border-bottom-color: #111; }
.site-nav a[aria-current="page"] { font-weight: bold; border-bottom-color: #111; }
.site-nav .nav-out { margin-left: auto; font-size: 0.95rem; }
.site-nav .nav-out a { color: #444; }
@media (max-width: 760px) { .site-nav { width: auto; } .site-nav .nav-out { margin-left: 0; } }
.byline { font-size: 1.1rem; font-style: italic; margin-top: 0; }
figure.fullwidth img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #ccc;
}
figure.fullwidth a { background: none; text-shadow: none; }
pre.code {
  font-size: 0.85rem; line-height: 1.45; overflow-x: auto;
  padding: 0.8rem 1rem; width: 55%; max-width: none;
  background: #fff; border: 1px solid #ddd; border-radius: 3px;
}
pre.code > code { display: block; width: auto; margin-left: 0; overflow-x: visible; font-size: inherit; line-height: inherit; }
@media (max-width: 760px) { pre.code { width: auto; } }
.colophon { font-size: 1rem; margin-top: 3rem; }

/* ---- The layer graph (index.html, data/layers.js, layers.js) ---------- */
figure.layers-figure { margin-top: 1.4rem; margin-bottom: 2rem; }
.layers {
  --lane-pad: 185px;                     /* room for the side routes and their labels */
  position: relative;
  padding: 0.5rem var(--lane-pad);
  font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
}
.lrow {
  display: flex;
  justify-content: center;
  gap: 8.5rem;
  margin: 0 0 3.2rem 0;
}
.lrow:last-child { margin-bottom: 0; }
.layer {
  position: relative; z-index: 1; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  min-width: 12rem;
  padding: 0.7rem 1rem 0.65rem 1rem;
  border: 1px solid #111; border-radius: 3px;
  background: #fff;
  font: inherit; font-size: 1.15rem; color: #111;
  text-align: left; cursor: pointer;
  transition: box-shadow .25s ease, transform .25s ease;
}
.layer:hover { box-shadow: 0 2px 0 #111; transform: translateY(-1px); }
.layer:focus-visible { outline: 2px solid #111; outline-offset: 2px; }
.layer.open { box-shadow: 0 3px 0 #111; }
.layer .lname { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.95rem; font-weight: bold; }
.layer .lrole { font-style: italic; font-size: 1rem; color: #333; }
/* a soft tint per role, matching the map's legend roughly */
.layer-Framework { background: #eef3fa; }
.layer-PhaseProduct, .layer-QFT, .layer-ModularExponentiation, .layer-Compiler { background: #eff6ea; }
.layer-Shor { background: #fbf0e3; }
.layer-QubitCount { background: #f8eaf0; }
.layer-Reference { background: #efeaf7; }

.larrows { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 0; }
.ledge { fill: none; }
.ledge-primary { stroke: #111; stroke-width: 1.6; }
.ledge-secondary { stroke: #9a9a9a; stroke-width: 1; }
.ledge-dim { stroke: #b5b5b5; stroke-width: 1; stroke-dasharray: 4 4; }
#la-primary path { fill: #111; }
#la-secondary path { fill: #9a9a9a; }
#la-dim path { fill: #b5b5b5; }
.llabel {
  font-size: 0.82rem; font-style: italic; fill: #333;
  paint-order: stroke; stroke: #fffff8; stroke-width: 5px; stroke-linejoin: round;
}
.llabel-mono { font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-style: normal; font-size: 0.74rem; }

/* the panel that unfolds under a row */
.ldetail {
  position: relative; z-index: 1;
  display: grid; grid-template-rows: 0fr;
  opacity: 0;
  margin: -2.2rem calc(-1 * var(--lane-pad)) 3.2rem calc(-1 * var(--lane-pad));   /* span the whole figure */
  transition: grid-template-rows .6s cubic-bezier(.2,.7,.2,1), opacity .45s ease, margin .6s cubic-bezier(.2,.7,.2,1);
}
.ldetail.open { grid-template-rows: 1fr; opacity: 1; }
.ldetail.instant { transition: none; }
.ldetail-inner { overflow: hidden; min-height: 0; min-width: 0; }
.ldetail-text, .ldetail-code { min-width: 0; }
.ldetail-grid {
  position: relative;
  margin-top: 1.1rem;
  padding: 1.4rem 1.6rem 1.4rem 1.6rem;
  border-top: 1px solid #111; border-bottom: 1px solid #111;
  background: #fffff8;
  display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 10fr); gap: 0 2.2rem;
}
.ldetail-grid::before {                /* caret under the open block */
  content: ""; position: absolute; top: -8px; left: var(--caret-x, 50%);
  width: 14px; height: 14px; margin-left: -7px;
  background: #fffff8; border-left: 1px solid #111; border-top: 1px solid #111;
  transform: rotate(45deg);
}
.ldetail h3 { margin-top: 0; font-size: 1.5rem; }
.ldetail h3 .lrole { font-style: italic; font-weight: normal; font-size: 1.15rem; color: #333; margin-left: 0.4rem; }
.ldetail p { font-size: 1.15rem; line-height: 1.6; margin-top: 0.9rem; width: 100%; max-width: none; }
.ldetail .lmeta { font-size: 1rem; color: #333; margin-top: 0.2rem; }
.ldetail code { font-size: 0.9rem; }
.ldeps { margin-top: 1.3rem; font-size: 1rem; }
.ldeps > div { margin-top: 0.5rem; display: flex; flex-wrap: wrap; align-items: flex-start; }
.ldeps-k { display: inline-block; min-width: 5.2rem; font-style: italic; color: #333; }
.lchip {
  display: inline-block; vertical-align: baseline;
  margin: 0.15rem 0.35rem 0.15rem 0; padding: 0.1rem 0.55rem;
  border: 1px solid #777; border-radius: 999px; background: #fff;
  font: inherit; font-size: 0.95rem; color: #111; cursor: pointer;
  max-width: 100%; text-align: left;
}
.lchip:hover { border-color: #111; }
.lchip-n { color: #666; margin-left: 0.4rem; font-size: 0.85rem; }
.lchip-via { display: block; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 0.72rem; color: #333; word-break: break-all; }
.lsnip-head { font-size: 1rem; margin: 0.9rem 0 0.3rem 0; }
.lsnip-head:first-child { margin-top: 0; }
.ldetail-code .lsnip-head { margin-top: 1.2rem; }
.ldetail-code .lsnip-head:first-child { margin-top: 0; }
pre.lsnip {
  font-size: 0.78rem; line-height: 1.4; overflow-x: auto;
  margin: 0; padding: 0.7rem 0.9rem; width: auto; max-width: none;
  background: #fff; border: 1px solid #ddd; border-radius: 3px;
}
pre.lsnip > code { display: block; width: auto; margin-left: 0; overflow-x: visible; font-size: inherit; line-height: inherit; }
.lsnip-note { font-size: 1rem !important; color: #333; margin-top: 0.4rem !important; }

/* The Shor's algorithm overview reuses the layer-graph machinery (layers.js). */
.layers.algo { --lane-pad: 150px; }
.layers.algo .lrow { gap: 2.6rem; margin-bottom: 3.6rem; }
.layers.algo .layer { min-width: 9rem; }
.layers.algo .lname { font-family: inherit; font-size: 1.1rem; }
.step-classical { background: #f6f6f3; }
.step-quantum { background: #eef3fa; }
.lgroup { fill: none; stroke: #6a7f9e; stroke-width: 1; stroke-dasharray: 5 4; }
.llabel-group { font-style: italic; fill: #3a4d6b; }

/* The interactive PhaseProduct recursion figure (ppfig.js, data/pp.js) */
.ppfig { --lane-pad: 0px; font-family: et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; }
.ppsvg { width: 100%; height: auto; display: block; }
.ppsvg .pt { font-size: 15px; fill: #111; }
.ppsvg .ph { font-size: 17px; font-weight: bold; }
.ppsvg .pt-b { font-weight: bold; }
.ppsvg .pt-i { font-style: italic; fill: #444; }
.ppsvg .pt-s { font-size: 13px; fill: #444; font-style: italic; }
.ppsvg .pt-m { font-size: 14.5px; }
.ppsvg .pt-w { font-size: 14px; fill: #333; }
.ppsvg .pt-n { font-size: 12px; font-weight: bold; }
.ppsvg .pw { stroke: #888; stroke-width: 1.2; }
.ppsvg .pa { stroke: #444; stroke-width: 1.3; }
.ppsvg .pa-thin { stroke-width: 1; }
.ppsvg marker path { fill: #444; }
.ppsvg .pcard rect { fill: #e7f0fb; stroke: #4a8fd4; stroke-width: 1.5; }
.ppsvg .pn { cursor: pointer; }
.ppsvg .pn rect { fill: #f3f3f1; stroke: #777; stroke-width: 1.2; transition: fill .2s, stroke .2s; }
.ppsvg .prow rect { fill: transparent; stroke: none; }
.ppsvg .pu rect, .ppsvg .pband rect { fill: #dfe9f6; stroke: #4a8fd4; }
.ppsvg .pstrip rect { fill: #fff; stroke: #4a8fd4; stroke-dasharray: 5 4; }
.ppsvg .pout rect { fill: #fde8dc; stroke: #e0703a; }
.ppsvg .pnum circle { fill: #fff; stroke: #111; stroke-width: 1.4; }
.ppsvg .pn:hover rect { stroke: #111; }
.ppsvg .prow:hover rect { fill: rgba(74, 143, 212, .14); }
.ppsvg .pn.on rect { stroke: #111; stroke-width: 2.2; }
.ppsvg .prow.on rect { fill: rgba(74, 143, 212, .22); stroke: none; }
.ppsvg .pn:focus { outline: none; }
.ppsvg .pn:focus-visible rect { stroke: #111; stroke-width: 2.2; }
.ppsvg .ptitle rect { fill: transparent; stroke: none; }
.ppsvg .ptitle:hover rect { fill: rgba(74, 143, 212, .14); stroke: none; }
.ppsvg .ptitle.on rect { fill: rgba(74, 143, 212, .22); stroke: none; }
.ppsvg .psw { stroke: #4a8fd4; stroke-width: 1; }
.ppsvg .psw1, .ppsvg .pbr1 rect { fill: #b9d9ea; }
.ppsvg .psw2, .ppsvg .pbr2 rect { fill: #8fc1d9; }
.ppsvg .pbandreg rect { stroke: none; }
.ppsvg .pbr0 rect { fill: #f1f1ef; }
.ppsvg .pbandreg:hover rect, .ppsvg .pbandreg.on rect { stroke: #111; stroke-width: 1.6; }
.ppsvg .pwrow rect { fill: #fff; stroke: #4a8fd4; }
.ppsvg .pthr { stroke: #222; stroke-width: 1.4; stroke-dasharray: 7 4; }
.ppsvg .pthrlab rect { fill: #fff; stroke: #222; }
.ppsvg .pt-thr { font-style: normal; font-weight: bold; fill: #111; }
.ppsvg .pt-pi { font-size: 12px; }
.ppsvg .prow rect.psw1 { fill: #b9d9ea; stroke: #4a8fd4; }
.ppsvg .prow rect.psw2 { fill: #8fc1d9; stroke: #4a8fd4; }
.ppdetail { margin: 0.6rem 0 1.4rem 0; }
.ppdetail .ldetail-grid::before { display: none; }
table.pstate { border-collapse: collapse; font-size: 1rem; margin-top: 0.8rem; }
table.pstate th, table.pstate td { padding: 0.15rem 0.9rem 0.15rem 0; text-align: left; font-family: Consolas, "Liberation Mono", Menlo, monospace; font-size: 0.85rem; }
table.pstate th { font-family: inherit; font-style: italic; font-weight: normal; color: #444; }

@media (max-width: 1100px) {
  .layers.algo { --lane-pad: 140px; }
  .layers.algo .lrow { gap: 1.4rem; }
  .layers { --lane-pad: 160px; }
  .lrow { gap: 5rem; }
  .llabel { font-size: 0.75rem; }
}
@media (max-width: 760px) {
  .layers { --lane-pad: 0px; }
  .larrows { display: none; }
  .lrow { flex-direction: column; align-items: stretch; gap: 0.6rem; margin-bottom: 1.2rem; }
  .layer { min-width: 0; }
  .ldetail { margin: -0.6rem 0 1.2rem 0; }
  .ldetail-grid { grid-template-columns: minmax(0, 1fr); padding: 1rem 0.6rem; }
  .ldetail-grid::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ldetail, .layer { transition: none; }
}

/* Syntax highlighting: Lean snippets (layers.js leanHL) and the static shell/BibTeX blocks in index.html. */
pre.lean .lk, pre.hl .lk { color: #d6336c; }
pre.lean .ld, pre.hl .ld { color: #7048e8; font-weight: 600; }
pre.lean .lt, pre.hl .lt { color: #0c8599; }
pre.lean .lo, pre.hl .lo { color: #e8590c; }
pre.lean .ln, pre.hl .ln { color: #1c7ed6; }
pre.lean .ls, pre.hl .ls { color: #2f9e44; }
pre.lean .lc, pre.hl .lc { color: #868e96; font-style: italic; }
