/* ============================================================================
 * The alchemy book — #brewWin.
 *
 * Three columns, narrowest first: the eight families, the nine grades of one
 * family, and the recipe you are reading. That order is the order the question
 * is actually asked in — which draught, then how big, then can I afford it —
 * and each column only ever repaints the ones to its right.
 *
 * `--fam` is the family's own colour, set inline from POTION_FAMILIES so the
 * stylesheet never holds a second copy of the eight hexes. It rules the tab,
 * the selected row and the header, which is what makes switching family feel
 * like turning to a different part of the book rather than reloading a list.
 *
 * Depends on theme.css for the tokens and the .nw / .btn primitives, and
 * mirrors shop.css's window chrome deliberately rather than sharing it — see
 * the note at the top of that file for why.
 * ========================================================================= */

#brewWin{position:fixed;inset:0;z-index:130;pointer-events:none}
#brewWin.hidden{display:none}
#brewWin .box{
  pointer-events:auto;position:absolute;left:50%;top:56px;transform:translateX(-50%);
  width:min(880px,calc(var(--vw) * 95));height:min(600px,calc(var(--vh) * 84));
  display:flex;flex-direction:column;overflow:hidden;
  background:linear-gradient(#17122af7,#100b20f9);
  box-shadow:0 26px 70px -18px #000,0 0 0 1px #ffffff10}

#brewWin .winbar{display:flex;align-items:center;gap:9px;padding:9px 14px;flex:none;
  border-bottom:1px solid var(--edge);cursor:grab;user-select:none;
  background:linear-gradient(#21183a,#150f26);border-radius:11px 11px 0 0}
#brewWin .winbar:active{cursor:grabbing}
#brewWin .winbar .wt{font-size:12px;letter-spacing:.14em;text-transform:uppercase;
  font-weight:800;color:var(--gold2)}
#brewWin .winbar .wsub{margin-left:auto;font-size:11px;color:var(--dim);letter-spacing:.04em}
#brewWin .winbar .wx{margin-left:10px;width:24px;height:24px;border-radius:7px;display:grid;
  place-items:center;background:#0f0a1d;border:1px solid var(--edge);color:var(--faint);
  cursor:pointer;font-size:12px}
#brewWin .winbar .wx:hover{color:#fff;border-color:var(--gold3)}

#brewWin .brewbody{flex:1;min-height:0;display:grid;grid-template-columns:150px 230px 1fr}

/* ------------------------------------------------------------- the families */
#brewWin .brewfams{display:flex;flex-direction:column;gap:2px;padding:10px 8px;
  overflow-y:auto;border-right:1px solid var(--edge);
  background:linear-gradient(180deg,#150f26,#0f0a1c)}
#brewWin .brewfam{display:flex;align-items:center;gap:8px;padding:7px 9px;
  border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;
  color:var(--dim);font-size:12px;text-align:left;width:100%}
#brewWin .brewfam:hover{background:#ffffff08;color:var(--ink)}
/* The selected family is lit in its own colour, on both the dot and the edge:
   one hue doing two jobs is what keeps eight tabs from becoming a paint chart. */
#brewWin .brewfam.on{background:#ffffff0d;border-color:var(--fam);color:var(--ink)}
#brewWin .brewfam .famdot{flex:none;width:10px;height:10px;border-radius:50%;
  background:var(--fam);box-shadow:0 0 8px -1px var(--fam)}
#brewWin .brewfam .famname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
#brewWin .brewfam .famcount{flex:none;font-size:10px;color:var(--faint);font-variant-numeric:tabular-nums}
/* A family with no page open at all is dimmed, not hidden: knowing that
   Warding exists and that you cannot brew any of it is the information. */
#brewWin .brewfam.shut .famdot{opacity:.35}
#brewWin .brewfam.shut .famname{opacity:.6}

/* --------------------------------------------------------------- the grades */
#brewWin .brewgrades{display:flex;flex-direction:column;gap:2px;padding:10px 8px;
  overflow-y:auto;border-right:1px solid var(--edge)}
#brewWin .brewgrade{display:flex;align-items:center;gap:8px;padding:5px 8px;width:100%;
  border:1px solid transparent;border-radius:8px;background:none;cursor:pointer;text-align:left}
#brewWin .brewgrade:hover{background:#ffffff08}
#brewWin .brewgrade.on{background:#ffffff0d;border-color:var(--fam)}
#brewWin .brewgrade .gicon{flex:none;width:30px;height:30px;display:grid;place-items:center}
#brewWin .brewgrade .gimg{max-width:30px;max-height:30px;image-rendering:pixelated}
#brewWin .brewgrade .gtext{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.2}
#brewWin .brewgrade .gtext b{font-size:12px;color:var(--ink)}
#brewWin .brewgrade .gtext i{font-size:10px;color:var(--faint);font-style:normal;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#brewWin .brewgrade .glock{flex:none;font-size:10px;color:var(--dim);
  font-variant-numeric:tabular-nums}
/* A shut page keeps its bottle and loses its colour — you can see the shape of
   what is coming without being able to mistake it for something you have. */
#brewWin .brewgrade.shut .gimg{filter:grayscale(1);opacity:.4}
#brewWin .brewgrade.shut .gtext b{color:var(--dim)}
#brewWin .brewgrade.shut .glock{color:var(--gold3)}

/* ---------------------------------------------------------------- the sheet */
#brewWin .brewsheet{display:flex;flex-direction:column;min-height:0;padding:14px 16px;
  overflow-y:auto;background:linear-gradient(180deg,#130e24,#0d0918)}
#brewWin .brewhdr{display:flex;align-items:center;gap:12px;padding-bottom:10px;
  border-bottom:1px solid var(--edge)}
#brewWin .bicon{flex:none;width:56px;height:56px;display:grid;place-items:center;
  background:radial-gradient(circle at 50% 35%,#2b2039,#140e22);
  border:1px solid var(--fam);border-radius:10px;
  box-shadow:inset 0 0 18px #0009,0 0 22px -14px var(--fam)}
#brewWin .bimg{max-width:44px;max-height:44px;image-rendering:pixelated}
#brewWin .bid b{display:block;font-size:15px;color:var(--ink)}
#brewWin .bid span{font-size:11px;color:var(--faint)}
#brewWin .brewfx{margin:10px 0 6px;font-size:12px;color:var(--gold2);line-height:1.45}

#brewWin .brewreq h4{margin:12px 0 6px;font-size:11px;letter-spacing:.12em;
  text-transform:uppercase;color:var(--dim);font-weight:700}
#brewWin .brewreq h4 span{letter-spacing:0;text-transform:none;color:var(--faint);
  font-weight:400}
#brewWin .brewlines{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:3px}
#brewWin .brewlines li{display:flex;align-items:baseline;gap:10px;padding:5px 9px;
  border-radius:7px;background:#ffffff06;font-size:12px}
#brewWin .brewlines .rname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;color:var(--ink)}
#brewWin .brewlines .rqty{flex:none;font-variant-numeric:tabular-nums;font-weight:700}
#brewWin .brewlines .rqty i{font-style:normal;font-weight:400;color:var(--faint)}
/* Green when the bag covers the line, red when it does not. The whole point of
   the list is answering "what am I short of" without arithmetic. */
#brewWin .brewlines li.ok .rqty{color:#7fd48a}
#brewWin .brewlines li.short .rqty{color:#e0705f}
#brewWin .brewlines li.short{background:#e0705f14}

#brewWin .brewfoot{margin-top:auto;padding-top:14px;display:flex;align-items:center;gap:12px}
#brewWin .brewqty{display:flex;align-items:center;gap:2px}
#brewWin .brewqty button{width:28px;height:28px;border-radius:7px;cursor:pointer;
  background:#0f0a1d;border:1px solid var(--edge);color:var(--ink);font-size:13px}
#brewWin .brewqty button:hover{border-color:var(--gold3)}
#brewWin .brewqty .qmax{width:auto;padding:0 9px;font-size:11px}
#brewWin .brewqty span{min-width:62px;text-align:center;font-size:12px;color:var(--dim);
  font-variant-numeric:tabular-nums}
#brewWin .brewgo{margin-left:auto;min-width:130px;height:34px;font-size:12px;
  letter-spacing:.08em;text-transform:uppercase;font-weight:800}
#brewWin .brewgo[disabled]{opacity:.4;cursor:not-allowed}
#brewWin .brewnote{margin:8px 0 0;font-size:11px;color:var(--faint);line-height:1.4}
