/* proc.css: shared styles for the Week 3 process walkthroughs.
   Part 1 is the shared engine theme (byte-identical to the Week 2 KERNEL block in ../../worksheet2/_tools/kernel-template.html).
   Part 2 is specific to the process pages: source listings, process boxes, the kernel's process table, the terminal. */
  /* === 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: process walkthroughs ---------- */
  main { grid-template-columns: 1.55fr 1fr .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; }
  #col-procs { padding-right: 1rem; }

  /* source listings: one box per program that has a live process */
  .prog { background: #fff; border: 2px solid var(--line); border-radius: .7rem; overflow: hidden; }
  .prog .ph { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .78rem; font-weight: 700; padding: .22rem .6rem; background: #fbfaf6; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .6rem; }
  .prog .ph small { font-weight: 500; color: var(--muted); display: flex; gap: .25rem; align-items: center; }
  .prog .ph small i { font-style: normal; background: var(--c); color: #fff; font-size: .58rem; font-weight: 800; padding: 0 .32rem; border-radius: .6rem; line-height: 1.5; }
  .prog ol { list-style: none; margin: 0; padding: .18rem .3rem .25rem; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .7rem; line-height: 1.32; }
  .prog li { display: grid; grid-template-columns: minmax(2.4rem, auto) 1.4rem 1fr; gap: .3rem; align-items: center; white-space: pre; padding: 0 .25rem; border-radius: .3rem; color: #6d6a63; }
  .prog li .tx { overflow: hidden; text-overflow: ellipsis; }
  .prog li .mk { display: flex; gap: .15rem; justify-content: flex-end; min-height: 1rem; }
  .prog li .mk i { font-style: normal; background: var(--c); color: #fff; font-size: .58rem; font-weight: 800; padding: 0 .32rem; border-radius: .6rem; line-height: 1.5; letter-spacing: .02em; }
  .prog li .mk i.many { background: var(--kernel); }
  .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); }
  .prog li.cur .tx .c { color: #7d6a2a; }
  .prog.binary ol { color: var(--muted); font-style: italic; padding: .4rem .6rem; }
  .prog.binary li { display: block; white-space: normal; }
  .prog.gone { opacity: .45; }

  /* process boxes: indented under their parent like a file tree */
  .tnode { margin-left: calc(var(--d) * 1.6rem); position: relative; }
  .tnode[style*='--d:1'], .tnode[style*='--d:2'], .tnode[style*='--d:3'] { }
  .tnode::before { content: ''; position: absolute; left: -1rem; top: -.55rem; width: .7rem; height: 1.5rem; border-left: 2px solid var(--c); border-bottom: 2px solid var(--c); border-radius: 0 0 0 .4rem; opacity: .7; }
  .tnode[style*='--d:0']::before { display: none; }
  #procs { display: grid; grid-template-columns: 1fr; gap: .55rem; }
  #procs.dense { grid-template-columns: 1fr 1fr; gap: .45rem; }
  .pbox { border: 2px solid var(--c); border-radius: .6rem; background: #fff; position: relative; font-size: .8rem; }
  .pbox .phead { background: var(--c); color: #fff; padding: .18rem .55rem; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .85rem; border-radius: .35rem .35rem 0 0; }
  .pbox .phead small { font-weight: 500; opacity: .92; white-space: nowrap; }
  .pbox .rows { padding: .25rem .55rem .35rem; display: grid; grid-template-columns: auto 1fr; gap: .08rem .55rem; align-items: baseline; }
  .pbox .k { color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; }
  .pbox .v { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pbox .v.wrap { white-space: normal; }
  .pbox .v b { font-weight: 800; }
  .pbox.zombie { border-style: dashed; background: #fff5f3; }
  .pbox.zombie .phead { background: var(--gone); }
  .pbox.gone .phead { opacity: .7; }
  #procs.dense .pbox .rows { padding: .18rem .45rem .28rem; gap: .03rem .4rem; }
  #procs.dense .pbox .v, #procs.dense .pbox .k { font-size: .66rem; }
  #procs.dense .pbox .phead { font-size: .76rem; padding: .12rem .45rem; }
  .st { display: inline-block; font-size: .64rem; font-weight: 800; padding: .02rem .45rem; border-radius: 1rem; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--kernel); }
  .st.running { background: var(--new); }
  .st.ready { background: #6c8; }
  .st.sleeping { background: #8d8a83; }
  .st.zombie { background: var(--gone); }
  .st.gone { background: #bbb; }
  .fdchips { display: inline-flex; gap: .15rem; }
  .fdchips i { font-style: normal; border: 1px solid var(--line); border-radius: .3rem; padding: 0 .3rem; font-size: .66rem; background: #fafaf7; }

  /* the kernel's process table */
  .ptab { background: #fff; border: 2px solid var(--line); border-radius: .7rem; overflow: hidden; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .7rem; }
  .ptab .r { display: grid; grid-template-columns: 2.9rem 2.9rem 1fr 4.9rem 2.1rem; gap: .3rem; padding: .14rem .5rem; border-top: 1px solid var(--line); align-items: center; white-space: nowrap; }
  .ptab .r:first-child { border-top: 0; }
  .ptab .r.h { font-weight: 700; background: #fbfaf6; text-transform: uppercase; font-size: .6rem; letter-spacing: .05em; color: var(--muted); }
  .ptab .r .dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--c); margin-right: .3rem; vertical-align: middle; }
  .ptab .r.z { background: #fff5f3; }
  .ptab .r.gone { opacity: .45; text-decoration: line-through; }
  .ptab .r .st { font-size: .56rem; padding: 0 .35rem; }
  .ptab .r.hot { z-index: 1; }

  /* the terminal */
  .term { background: #1d1f21; color: #e6e6e6; border-radius: .7rem; padding: .45rem .7rem .5rem; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .74rem; line-height: 1.5; min-height: 5.5rem; flex: 1; }
  .term .l { display: flex; gap: .45rem; align-items: baseline; white-space: pre-wrap; border-radius: .25rem; padding: 0 .2rem; margin: 0 -.2rem; }
  .term .l .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--c); flex: none; position: relative; top: -.05rem; }
  .term .l.prompt { color: #8fd3a5; }
  .term .l.fresh { background: rgba(255, 207, 51, .22); }
  .term .l.dim { color: #8a8d92; }
  .term .cursor { display: inline-block; width: .5rem; height: .95rem; background: #e6e6e6; vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
  .term.hot { box-shadow: 0 0 0 4px var(--hot); }
  .legend { color: var(--muted); font-size: .72rem; margin-top: .2rem; }
