/* sched.css: shared styles for the Week 6 scheduling walkthroughs.
   Part 1 is the shared engine theme (byte-identical to the KERNEL block in ../../worksheet5/pipe/pipe.css and ../../worksheet4/cpu/cpu.css).
   Part 2 is specific to these pages: job cards, the policy listing, the CPU, the timeline, the ready queue or tree, the metrics table. */
  /* === KERNEL-START === */
  /* ---------- theme ---------- */
  :root {
    --bg: #f6f5f1;
    --panel: #ffffff;
    --ink: #1c1c1c;
    --muted: #6b6b6b;
    --line: #d9d6cf;
    --hot: #ffcf33;
    --hot-ink: #6b4d00;
    --new: #1e9e5a;
    --gone: #c0392b;
    --lookup: #7b3fe4;
    --cat: #e0662a;
    --py: #2266d3;
    --kernel: #555;
    font-size: 17px;
  }
  @media (min-width: 1500px) { :root { font-size: 19px; } }
  @media (max-width: 1200px) { :root { font-size: 14px; } }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body {
    background: var(--bg); color: var(--ink);
    font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
    display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  }
  code, .mono { font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; }
  b { font-weight: 700; }

  /* ---------- header ---------- */
  header {
    display: flex; align-items: center; gap: 1.2rem;
    padding: .55rem 1.2rem; background: #fff; border-bottom: 2px solid var(--line);
  }
  header .title { font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
  header .title span { color: var(--muted); font-weight: 500; margin-left: .6rem; font-size: .95rem; }
  header .stepno { margin-left: auto; color: var(--muted); font-size: .95rem; white-space: nowrap; }
  header .stepno b { color: var(--ink); }
  header .part { color: var(--ink); font-weight: 600; }
  nav { display: flex; gap: .4rem; }
  nav button {
    font: inherit; font-weight: 700; padding: .4rem .9rem; border-radius: .5rem;
    border: 2px solid var(--ink); background: #fff; cursor: pointer;
  }
  nav button:hover { background: #f0efe9; }
  nav button:disabled { opacity: .35; cursor: default; }
  .progress { height: 4px; background: #e8e6df; }
  .progress i { display: block; height: 100%; background: var(--ink); transition: width .25s; }

  /* ---------- main grid ---------- */
  main {
    flex: 1; display: grid; gap: 1rem; padding: 1rem 1.2rem; min-height: 0;
  }
  .col { min-width: 0; display: flex; flex-direction: column; gap: .7rem; overflow-y: auto; overflow-x: hidden; padding: .3rem .35rem; }
  .col > h2 {
    margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: .06em;
    display: flex; flex-direction: column; gap: .1rem;
  }
  .col > h2 small {
    text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted);
    font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .8rem;
  }
  .empty { color: var(--muted); font-style: italic; padding: .4rem .2rem; }

  /* ---------- generic boxes ---------- */
  .box { background: var(--panel); border: 2px solid var(--line); border-radius: .7rem; padding: .45rem .7rem; position: relative; }
  .proc { background: var(--panel); border: 2px solid var(--c); border-radius: .7rem; overflow: hidden; position: relative; }
  .proc .phead {
    background: var(--c); color: #fff; padding: .35rem .7rem; font-weight: 700;
    display: flex; justify-content: space-between; align-items: baseline; gap: .6rem;
  }
  .proc .phead small { font-weight: 500; opacity: .9; }
  .chip {
    display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .45rem; border-radius: 1rem;
    border: 1px solid var(--line); background: #fafaf7; color: #333; white-space: nowrap;
  }
  .badge { font-size: .75rem; font-weight: 700; padding: .05rem .45rem; border-radius: 1rem; background: var(--gone); color: #fff; }

  /* ---------- states ---------- */
  .hot { box-shadow: 0 0 0 4px var(--hot); animation: pulse 1.1s ease-in-out 2; position: relative; z-index: 1; }
  @keyframes pulse { 0%,100% { box-shadow: 0 0 0 4px var(--hot); } 50% { box-shadow: 0 0 0 8px #ffe28a; } }
  .new { border-color: var(--new) !important; position: relative; }
  .new::after {
    content: "NEW"; position: absolute; top: -.6rem; right: .6rem; background: var(--new); color: #fff;
    font-size: .65rem; font-weight: 800; padding: .05rem .4rem; border-radius: .3rem; letter-spacing: .05em; z-index: 1;
  }
  .gone { opacity: .5; border-style: dashed !important; border-color: var(--gone) !important; position: relative; }
  .gone::after {
    content: "FREED"; position: absolute; top: -.6rem; right: .6rem; background: var(--gone); color: #fff;
    font-size: .65rem; font-weight: 800; padding: .05rem .4rem; border-radius: .3rem; letter-spacing: .05em; z-index: 1;
  }
  .gone.lost::after { content: "LOST"; }

  /* ---------- footer ---------- */
  footer {
    background: #fff; border-top: 2px solid var(--line); padding: .7rem 1.2rem .9rem;
    display: grid; grid-template-columns: 1fr; gap: .5rem; min-height: 9.5rem;
  }
  .call {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; min-height: 2rem;
    font-family: Menlo, monospace; font-size: 1.05rem;
  }
  .call .who {
    background: var(--c, var(--kernel)); color: #fff; padding: .15rem .6rem; border-radius: .4rem;
    font-family: -apple-system, "Segoe UI", sans-serif; font-weight: 700; font-size: .9rem;
  }
  .call .sys { font-weight: 700; }
  .call .ret { color: var(--new); font-weight: 800; }
  .call .bytes { background: var(--hot); color: var(--hot-ink); padding: 0 .4rem; border-radius: .3rem; font-weight: 700; }
  .call .note { color: var(--muted); font-family: -apple-system, "Segoe UI", sans-serif; font-size: .9rem; }
  .crumbs { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .95rem; }
  .crumb { border: 2px solid var(--line); border-radius: .4rem; padding: .05rem .5rem; color: var(--muted); }
  .crumb.done { border-color: var(--lookup); color: var(--lookup); font-weight: 700; }
  .crumb.cur { background: var(--lookup); border-color: var(--lookup); color: #fff; font-weight: 800; }
  .crumb small { font-weight: 500; opacity: .8; }
  .narr h3 { margin: 0 0 .25rem; font-size: 1.1rem; }
  .narr p { margin: 0; font-size: 1.05rem; line-height: 1.45; max-width: 95ch; }
  .narr ul { margin: .2rem 0 0; padding-left: 1.3rem; font-size: 1rem; line-height: 1.4; columns: 2; column-gap: 2.5rem; }
  .narr li { break-inside: avoid; margin-bottom: .25rem; }
  .narr code { background: #f0efe9; padding: 0 .3rem; border-radius: .25rem; font-size: .95em; }
  .narr table { border-collapse: collapse; font-size: .95rem; margin-top: .3rem; }
  .narr th, .narr td { border: 1px solid var(--line); padding: .15rem .6rem; text-align: left; }
  .narr .k { color: var(--lookup); font-weight: 700; }
  .narr .cat { color: var(--cat); font-weight: 700; }
  .narr .py { color: var(--py); font-weight: 700; }
  nav button#explain { border-color: var(--line); font-weight: 600; color: var(--muted); }
  nav button#explain[aria-pressed="true"] { background: var(--hot); border-color: var(--hot-ink); color: var(--hot-ink); }
  footer.collapsed { min-height: 0; }
  footer.collapsed .narr > :not(h3) { display: none; }
  footer.collapsed .narr h3 { cursor: pointer; }
  footer.collapsed .narr h3::after { content: ": explanation hidden · press E or “Explain”"; color: var(--muted); font-weight: 500; font-size: .85rem; }

  /* ---------- arrow overlay ---------- */
  #arrows { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2; }
  #arrows path { fill: none; stroke-width: 2.5; stroke: var(--kernel); }
  #arrows polygon { fill: var(--kernel); }
  #arrows path.lookup { stroke: var(--lookup); stroke-dasharray: 7 5; stroke-width: 3; }
  #arrows polygon.lookup { fill: var(--lookup); }
  #arrows path.new { stroke: var(--new); stroke-width: 3; }
  #arrows polygon.new { fill: var(--new); }
  #arrows path.gone { stroke: var(--gone); stroke-dasharray: 4 4; stroke-width: 3; }
  #arrows polygon.gone { fill: var(--gone); }
  #arrows path.hotarrow { stroke: var(--hot-ink); stroke-width: 3.5; }
  #arrows polygon.hotarrow { fill: var(--hot-ink); }
  #arrows .dim { opacity: .3; }
  /* === KERNEL-END === */

  /* ---------- page: scheduling walkthroughs ---------- */
  main { grid-template-columns: .9fr 1.9fr .95fr; padding: .6rem 1.2rem .5rem; }
  header .title { white-space: nowrap; }
  @media (max-width: 1400px) { header .title span { display: none; } }
  .col > h2 { font-size: .9rem; }
  .col > h2 small { font-size: .72rem; }
  .call:empty { display: none; }
  .narr p { max-width: 125ch; }
  .narr th, .narr td { padding: .08rem .5rem; }
  .narr .r { color: var(--gone); font-weight: 700; }
  .narr .g { color: var(--new); font-weight: 700; }
  .narr mark { background: #fff1b8; padding: 0 .2rem; border-radius: .2rem; }
  .emp { color: var(--muted); font-style: italic; font-size: .75rem; padding: .1rem .2rem; }
  .mono { font-family: "SF Mono", Menlo, Consolas, monospace; }

  /* job cards */
  #jobs { display: flex; flex-direction: column; gap: .4rem; }
  .job { border: 2px solid var(--c); border-radius: .55rem; background: #fff; padding: .25rem .55rem .35rem; font-size: .8rem; position: relative; }
  .job .jh { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
  .job .jh b { font-family: "SF Mono", Menlo, Consolas, monospace; color: var(--c); font-size: .9rem; }
  .job .jn { color: var(--muted); font-size: .72rem; line-height: 1.25; }
  .job .jk { display: flex; flex-wrap: wrap; gap: .1rem .6rem; color: var(--muted); font-size: .72rem; margin-top: .1rem; }
  .job .jk b { color: var(--ink); font-family: "SF Mono", Menlo, Consolas, monospace; }
  .job .kv.bump b { background: var(--hot); border-radius: .2rem; padding: 0 .2rem; }
  .job .jbar { position: relative; height: .95rem; background: #efede6; border-radius: .25rem; overflow: hidden; margin-top: .25rem; }
  .job .jbar i { position: absolute; inset: 0 auto 0 0; background: var(--t); border-right: 2px solid var(--c); }
  .job .jbar span { position: absolute; left: .35rem; top: 0; font-size: .64rem; line-height: .95rem; font-weight: 700; color: #444; }
  .job.future { opacity: .45; border-style: dashed; }
  .job.done { opacity: .6; }
  .job.running { background: var(--t); }
  .st { display: inline-block; font-size: .6rem; font-weight: 800; padding: .02rem .45rem; border-radius: 1rem; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--kernel); white-space: nowrap; }
  .st.running { background: var(--new); }
  .st.ready { background: #b8860b; }
  .st.sleeping { background: #8d8a83; }
  .st.future { background: #c9c6be; }
  .st.done { background: #1c1c1c; }

  /* the policy, as pseudocode */
  .prog { background: #fff; border: 2px solid var(--line); border-radius: .7rem; position: relative; }
  .prog .ph { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .74rem; font-weight: 700; padding: .22rem .6rem; background: #fbfaf6; border-bottom: 1px solid var(--line); border-radius: .5rem .5rem 0 0; display: flex; justify-content: space-between; gap: .6rem; white-space: nowrap; }
  .prog .ph small { font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
  .prog ol { list-style: none; margin: 0; padding: .18rem .3rem .25rem; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .68rem; line-height: 1.35; }
  .prog li { display: grid; grid-template-columns: 1.2rem 1fr; gap: .3rem; align-items: start; white-space: pre-wrap; padding: 0 .25rem; border-radius: .3rem; color: #6d6a63; }
  .prog li .tx { padding-left: var(--ind, 0); text-indent: calc(-1 * var(--ind, 0)); }
  .prog li .ln { color: #c2bfb7; text-align: right; }
  .prog li .tx .c { color: #9a978f; }
  .prog li.cur { background: var(--hot); color: var(--ink); font-weight: 700; }
  .prog li.cur .ln { color: var(--hot-ink); }

  /* the CPU */
  .cpu { display: grid; grid-template-columns: 1fr; gap: .45rem; }
  .cpuslot { border: 2.5px solid var(--c, var(--line)); background: var(--t, #fff); border-radius: .6rem; padding: .3rem .6rem; text-align: center; }
  .cpuslot b { display: block; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; color: var(--c, var(--muted)); }
  .cpuslot small { color: var(--muted); font-size: .7rem; }
  .cpuslot.idle { border-style: dashed; }
  .cpuk { display: grid; grid-template-columns: auto 1fr; gap: .1rem .7rem; align-items: baseline; font-size: .8rem; }
  .cpuk .k { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
  .cpuk .v { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 700; }

  /* the timeline */
  .gantt { padding: .4rem .5rem .35rem; }
  .gantt svg { display: block; width: 100%; height: auto; }
  .gantt svg text { font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
  .gantt svg text.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
  .legend { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .68rem; color: var(--muted); margin-top: .15rem; }
  .legend span { display: inline-flex; align-items: center; gap: .3rem; }
  .lg { display: inline-block; width: 1.1rem; height: .6rem; border-radius: .15rem; }
  .lg.run { background: var(--ink); }
  .lg.wait { background: #ffcf33; opacity: .75; height: .4rem; }
  .lg.zz { background: #fff; border: 1.5px dashed #8d8a83; }
  /* faces of the comic characters next to job names */
  .fc { display: inline-flex; align-items: center; justify-content: center; width: 1.45em; height: 1.2em; margin-right: .3em; vertical-align: -.2em; border-radius: .3em; background: var(--t); border: 1px solid rgba(74, 59, 42, .55); }
  .fc img { height: .95em; width: auto; display: block; }
  .jc { display: inline-block; white-space: nowrap; font-weight: 600; font-size: .95em; line-height: 1.3; padding: 0 .35em 0 .25em; border-radius: .35em; border: 1px solid rgba(74, 59, 42, .35); }
  .jc::before { content: ""; display: inline-block; width: 1.25em; height: 1em; margin-right: .2em; vertical-align: -.15em; background: center / contain no-repeat; }
  .jc.dog { background: #fce48b; } .jc.dog::before { background-image: url(../images/face-dog.webp); }
  .jc.blue { background: #a9e7fb; } .jc.blue::before { background-image: url(../images/face-blue.webp); }
  .jc.pink { background: #f9bfda; } .jc.pink::before { background-image: url(../images/face-pink.webp); }
  /* the 7-Eleven logo next to its name in the narration */
  .nw { white-space: nowrap; }
  .brand { height: 1.15em; width: auto; vertical-align: -.22em; }
  /* <body class="doze">: waiting jobs doze in grey */
  .doze .lg.wait { background: #e4e1da; opacity: 1; height: .75rem; font-size: .55rem; font-weight: 800; font-style: italic; color: #8d8a83; line-height: .75rem; text-align: center; }
  .doze .st.ready { background: #8d8a83; }
  .doze .job.ready { background: #f3f2ee; border-color: #c9c6be; }
  .doze .qc { background: #efede6; border-color: #b9b5ac; }
  .doze .qc::after { content: "z z Z"; position: absolute; top: -.95rem; right: -.5rem; font-style: italic; font-weight: 800; font-size: .7rem; letter-spacing: -.05em; color: #8d8a83; pointer-events: none; animation: zzz-float 2.4s ease-in-out infinite; }
  .doze .qc + .qc::after { animation-delay: .8s; }
  .doze #gantt-svg g.hot, .doze #gantt-svg rect.hot, .doze #gantt-svg line.hot { filter: none; }
  @keyframes zzz-float { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-4px); opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .doze .qc::after { animation: none; } }
  .lg.arr { width: 0; height: 0; border-left: .35rem solid transparent; border-right: .35rem solid transparent; border-top: .55rem solid var(--gone); border-radius: 0; }
  .lg.sw { background: var(--gone); width: .35rem; }
  #gantt-svg g.hot, #gantt-svg rect.hot, #gantt-svg line.hot { box-shadow: none; animation: none; filter: drop-shadow(0 0 4px #ffcf33) drop-shadow(0 0 2px #ffcf33); }

  /* ready queue */
  .qs { display: flex; flex-direction: column; gap: .35rem; }
  .qrow { display: grid; grid-template-columns: 4.6rem 1fr; gap: .5rem; align-items: center; }
  .qk { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
  .qv { display: flex; flex-wrap: wrap; gap: .3rem; min-height: 2rem; align-items: center; }
  .qc { font-style: normal; display: inline-flex; flex-direction: column; align-items: center; border: 2px solid var(--c); background: var(--t); border-radius: .45rem; padding: .05rem .5rem; line-height: 1.2; position: relative; }
  .qc b { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .8rem; color: var(--c); }
  .qc small { font-size: .62rem; color: #555; white-space: nowrap; }
  .qc.zz { border-style: dashed; background: #fff; }
  /* CFS: the run queue as a list sorted by vruntime; the first one runs next */
  .qv.sorted { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .qv.sorted .qc { flex-direction: row; justify-content: space-between; gap: .6rem; padding: .1rem .6rem; }
  .qv.sorted .qc small { white-space: pre; }
  .doze .qv.sorted .qc::after { content: none; }
  .qc.next { outline: 2px solid var(--ink); outline-offset: 1px; }   /* CFS: the task with the smallest vruntime runs next */
  .tree { padding: .3rem .4rem .35rem; }
  .treesvg { display: block; width: 100%; max-height: 13rem; }
  .treesvg text { font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
  .treesvg text.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
  .treesvg g.hot { box-shadow: none; animation: none; filter: drop-shadow(0 0 5px #ffcf33); }
  .treecap { font-size: .7rem; color: var(--hot-ink); font-weight: 700; text-align: center; }

  /* metrics */
  .metrics { padding: .3rem .35rem; overflow-x: auto; }
  .metrics table { border-collapse: collapse; width: 100%; font-size: .74rem; }
  .metrics th { font-size: .62rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: right; padding: .15rem .3rem; border-bottom: 2px solid var(--line); vertical-align: bottom; line-height: 1.15; }
  .metrics th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .58rem; color: #9a978f; }
  .metrics td { font-family: "SF Mono", Menlo, Consolas, monospace; text-align: right; padding: .14rem .3rem; border-bottom: 1px solid #efede6; }
  .metrics td.nm { text-align: left; font-weight: 800; color: var(--c); }
  .metrics tr.avg td { border-top: 2px solid var(--ink); font-weight: 800; background: #fbfaf6; }
  .metrics tr.avg td.nm { color: var(--ink); font-family: -apple-system, "Segoe UI", sans-serif; }
  .metrics td.fresh { background: #e6f4ea; }
  .cpuk .v.hot { box-shadow: none; background: #fff1b8; border-radius: .2rem; animation: none; }   /* no ring over the neighboring lines */
  .metrics td.hot, .metrics tr.hot { box-shadow: inset 0 0 0 2px var(--hot-ink); background: #fff1b8; animation: none; }
  #notes { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
  /* the scoreboard as a table (a page that defines NOTES_HEAD) */
  #notes.scoretable { display: block; background: #fff; border: 2px solid var(--line); border-radius: .55rem; padding: .25rem .4rem; }
  #notes.scoretable table { width: 100%; border-collapse: collapse; font-size: .74rem; }
  #notes.scoretable th, #notes.scoretable td { padding: .2rem .25rem; border-bottom: 1px solid #efede6; text-align: right; white-space: nowrap; }
  #notes.scoretable tr:first-child th { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; vertical-align: bottom; white-space: normal; }
  #notes.scoretable tr:last-child > * { border-bottom: 0; }
  #notes.scoretable tr > th:first-child { text-align: left; font-weight: 700; }
  #notes.scoretable td { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 700; }
  #notes.scoretable td.good { color: var(--new); } #notes.scoretable td.bad { color: var(--gone); }
  #notes.scoretable td.emp { text-align: left; color: var(--muted); font-family: inherit; font-weight: 400; font-style: italic; }
  #notes.scoretable tr.hot { box-shadow: none; background: #fff1b8; animation: none; }
  #notes .note { background: #fff; border: 2px solid var(--line); border-radius: .55rem; padding: .25rem .55rem; }
  #notes .note small { display: block; font-size: .64rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  #notes .note b { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; }
  #notes .note.bad b { color: var(--gone); } #notes .note.good b { color: var(--new); }
  .job.done .jk, .job.done .jbar, .job.done .jn { display: none; }
  .job.done { padding-bottom: .2rem; }
  #notes .note small { text-transform: none; letter-spacing: 0; }
  .col > * { flex-shrink: 0; }
  #jobs.many .job .jn { display: none; }
