/* ── Крафт (вариант C — «верстак в центре») ─────────────────
   Three columns over the whole content height: search and recipes at the left (21rem), the live grid with its
   buttons and the 9 × 4 inventory in the middle, hints at the right (19rem). The page itself does not scroll; each
   column scrolls on its own. Slots reuse the inventory component (character.css .slot, .stack, .inv); here only
   their sizes and the crafting states are set. No live blur, no endless animation: only transform and opacity move. */
.content[data-screen="crafting"] { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 1.5rem; }
.page-head.craft-head { margin-bottom: 0.9rem; align-items: center; }
.craft-head .page-actions { padding-bottom: 0; }
.craft-head .badge { height: 1.6rem; padding: 0 0.7rem; font-size: 0.72rem; }
.craft-head .btn-ghost { height: 1.75rem; padding: 0 0.7rem; font-size: 0.75rem; }

.craft {
  --slot-gap: 0.15rem;
  --hot-gap: 0.6rem;
  --icon: 32px;
  --px: 2px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 21rem minmax(0, 1fr) 19rem;
  gap: 1.25rem;
}

/* an item picture in a slot-like cell (lists and panels); the game's icon replaces the glyph once hydrated */
.craft-ico { --s: 2.6rem; width: var(--s); height: var(--s); flex: none; border-radius: 0.3rem; background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); color: var(--text-2); }
.craft-ico .ic { width: 52%; height: 52%; stroke-width: 1.6; }
.craft-ico img.ico { image-rendering: pixelated; }
.craft-ico.xs { --s: 2.1rem; }
.craft-ico.sm { --s: 2.6rem; }
.craft-ico.craft-src { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--text-3); }

/* ── left: search, chips, recipes ─────────────────────────── */
.craft-list { min-height: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.craft-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 2.8rem;
  padding: 0 0.6rem 0 1.1rem;
  flex: none;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid var(--line-2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  color: var(--text-2);
  transition: border-color var(--t-fast);
}
.craft-search:focus-within { border-color: rgba(255, 255, 255, 0.3); }
.craft-search .ic { width: 1.25rem; height: 1.25rem; }
.craft-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 0.95rem; font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.craft-search input::placeholder { color: var(--text-3); font-weight: 400; font-size: 0.875rem; }
.craft-search kbd { font: 600 0.6875rem/1 var(--font); padding: 0.25rem 0.42rem; border-radius: 0.3rem; border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.035); color: var(--text-2); }
.craft-fix { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.1rem 0.35rem; margin-top: -0.35rem; font-size: 0.8125rem; color: var(--text-3); }
.craft-fix b { color: var(--text); font-weight: 600; }
.craft-fix button { padding: 0; border: 0; background: none; color: var(--text-2); font-size: 0.75rem; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.25); text-underline-offset: 0.18em; }
.craft-fix button:hover { color: var(--text); }

.craft-chips { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; flex: none; }
.craft-chip { display: inline-flex; align-items: center; gap: 0.45rem; height: 2.05rem; padding: 0 0.8rem; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text-2); font-size: 0.8125rem; font-weight: 500; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast); }
.craft-chip:hover { background: var(--surface); color: var(--text); }
.craft-chip b { font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.craft-chip[aria-pressed="true"] { background: #eceff4; color: var(--on-light); border-color: transparent; }
.craft-chip[aria-pressed="true"] b { color: rgba(12, 15, 20, 0.55); }
.craft-chip .dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--mint); }
.craft-chip .dot.amber { background: var(--amber); }

.craft-rows { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 0.15rem; margin-right: -0.6rem; padding-right: 0.6rem; }
.craft-group { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; padding: 0.7rem 0.5rem 0.3rem 0.35rem; font-size: 0.6875rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.craft-group:first-child { padding-top: 0.1rem; }
.craft-group span { letter-spacing: 0; text-transform: none; font-weight: 500; }
.craft-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  width: 100%;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  flex: none;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.craft-row:hover { background: var(--surface); }
.craft-row[aria-selected="true"] { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.craft-row:focus-visible { outline-offset: -2px; }
.craft-row.is-current .craft-row-name { color: var(--text); }
.craft-row.is-current .craft-ico { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.75); }
.craft-row.is-done .craft-ico { box-shadow: inset 0 0 0 1.5px rgba(75, 214, 156, 0.6); }
.craft-row-body { display: flex; flex-direction: column; min-width: 0; }
.craft-row-name { display: block; font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.craft-row .craft-state { margin-top: 0.1rem; }
.craft-more { flex: none; margin: 0.5rem 0.35rem 0.25rem; height: 2rem; }
.craft-list-empty { padding: 1rem 0.5rem; font-size: 0.8125rem; color: var(--text-3); line-height: 1.5; }
.craft-skel { display: grid; gap: 0.35rem; }
.craft-skel i { display: block; height: 3.1rem; border-radius: var(--r-sm); background: var(--surface); }

/* a recipe's state: coloured text with a dot, as in the mockup */
.craft-state { display: flex; align-items: center; gap: 0.35rem; min-width: 0; font-size: 0.75rem; font-weight: 500; white-space: nowrap; color: var(--text-3); }
.craft-state > span { overflow: hidden; text-overflow: ellipsis; }
.craft-state::before { content: ""; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; flex: none; }
.craft-state.ready, .craft-state.done { color: var(--mint); }
.craft-state.steps { color: var(--sky); }
.craft-state.station, .craft-state.smelt { color: var(--amber); }
.craft-state.almost::before, .craft-state.missing::before, .craft-state.raw::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.craft-state.missing, .craft-state.raw { color: var(--text-4); }

/* ── middle: the station, buttons, inventory ─────────────── */
.craft-bench { position: relative; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 1.1rem; -webkit-user-select: none; user-select: none; }
.craft-bench > * { flex: none; }
.craft-bench .note, .craft-bench [data-connecting] { width: 100%; max-width: 30rem; }
.craft-station { display: flex; align-items: center; gap: 1.6rem; padding: 1.1rem 1.6rem; border-radius: var(--r-lg); background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); }
/* the live grid and the recipe preview in one cell of a fixed 3×3 footprint, whichever of them shows */
.craft-grids { --slot: 4.4rem; display: grid; place-items: center; min-width: calc(var(--slot) * 3 + 0.4rem); min-height: calc(var(--slot) * 3 + 0.4rem); }
.craft-grids > .craft-grid { grid-area: 1 / 1; }
.craft-grid { --slot: 4.4rem; display: grid; grid-template-columns: repeat(var(--w, 3), var(--slot)); gap: 0.2rem; }
.craft-arrow { display: grid; place-items: center; color: var(--text-3); }
.craft-arrow .ic { width: 1.6rem; height: 1.6rem; stroke-width: 1.4; }
.craft-out { --slot: 5.2rem; position: relative; }
.craft-out-label { position: absolute; left: 50%; top: calc(100% + 0.35rem); transform: translateX(-50%); font-size: 0.6875rem; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.craft-cell { position: relative; width: var(--slot); height: var(--slot); display: grid; place-items: center; border-radius: 0.3rem; background: rgba(255, 255, 255, 0.04); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.craft-cell > * { grid-area: 1 / 1; }
.craft-cap { max-width: 100%; margin: -0.4rem 0 -0.3rem; font-size: 0.75rem; color: var(--text-3); text-align: center; text-wrap: balance; }
.craft-cap b { color: var(--text-2); font-weight: 500; }

/* the ghost of the selected recipe over an empty grid: icons at 45 %, missing cells with a red dashed frame */
.slot-ghost { display: none; place-items: center; pointer-events: none; }
.craft-station.has-ghost .slot-ghost:not(:empty) { display: grid; }
/* a real or predicted stack (a click, a drag preview) always covers the ghost in its cell */
.craft-station .slot.is-filled > .slot-ghost, .craft-station .slot.is-drag > .slot-ghost { display: none; }
/* the box is the icon over hydrateIcons' 0.84 fill, so the game icon comes at the same pixel scale as the stacks */
.slot-ghost .gh { width: calc(var(--icon) / 0.84 + 0.5px); height: calc(var(--icon) / 0.84 + 0.5px); display: grid; place-items: center; color: var(--text-2); opacity: 0.45; }
.slot-ghost .gh .ic { width: 62%; height: 62%; stroke-width: 1.6; }
.slot-ghost .gh img.ico { image-rendering: pixelated; }
.slot-ghost .gh.item-ico { overflow: visible; }
.craft-out .slot-ghost .gh { opacity: 1; }
.craft-station.has-ghost .is-missing { background: rgba(226, 71, 77, 0.07); box-shadow: inset 0 0 0 1px rgba(226, 71, 77, 0.55); }
.craft-station.has-ghost .is-missing::after { content: ""; position: absolute; inset: 0.2rem; border: 1px dashed rgba(255, 154, 158, 0.45); border-radius: 0.2rem; pointer-events: none; }
.craft-station.has-ghost .is-missing .gh { filter: grayscale(0.6); }
/* hidden, not removed: the grid keeps its size, so nothing around it moves (and hidden cells take no clicks) */
.craft-station.is-preview .craft-grid[data-real], .craft-station:not(.is-preview) .craft-grid[data-preview] { visibility: hidden; pointer-events: none; }
.craft-station .slot.is-ready { background: rgba(255, 255, 255, 0.09); }

.craft-do { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.45rem; width: 100%; max-width: 30rem; }
.craft-do .btn { height: 2.75rem; }
.craft-do .btn-primary { font-size: 0.9rem; min-width: 0; }
.craft-do .btn-primary > span { overflow: hidden; text-overflow: ellipsis; }
.craft-do .btn-primary small { font-weight: 500; opacity: 0.6; margin-left: 0.35rem; font-size: 0.75rem; }
.craft-do .btn-primary.is-running { cursor: default; }
.craft-do .btn-primary.is-running:disabled { opacity: 1; }
.craft-stepper { display: inline-flex; align-items: center; height: 2.75rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.craft-stepper button { width: 2.1rem; height: 100%; border: 0; background: none; color: var(--text-2); font-size: 1rem; line-height: 1; }
.craft-stepper button:hover:not(:disabled) { color: var(--text); }
.craft-stepper button:disabled { opacity: 0.35; cursor: default; }
.craft-stepper output { min-width: 1.8rem; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
/* the reason sits in the gap under the buttons: one line takes no extra room, so the idle layout is the mockup's */
.craft-why { width: 100%; max-width: 30rem; min-height: 1.1rem; margin: -1rem 0; display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 0.2rem 0.75rem; font-size: 0.75rem; line-height: 1.35; color: var(--text-2); text-align: center; }
/* a long reason wraps beside its button instead of above it: two short lines, not three */
.craft-why > span { min-width: 0; text-wrap: balance; }
.craft-why .btn { flex: none; }
.craft-why .amber { color: var(--amber); }
.craft-why .mint { color: var(--mint); }
.craft-why .btn { height: 1.6rem; padding: 0 0.65rem; font-size: 0.72rem; }

/* 9 × 3.2rem + 8 gaps = 30rem: the inventory is exactly as wide as the buttons above it. The hint line hangs below
   it; the margin keeps its room inside the centred group, so the column never scrolls just for the hint. */
.craft-inv { position: relative; width: 30rem; max-width: 100%; margin-bottom: 1.15rem; }
.craft-inv .inv { --slot: 3.2rem; }
/* one quiet line (the key hints fit the 30rem width); notes replace it in place */
.craft-inv .inv-hint { position: absolute; left: 0; right: 0; top: calc(100% + 0.1rem); flex-wrap: nowrap; justify-content: center; font-size: 0.65rem; gap: 0 0.7rem; color: var(--text-4); text-align: center; }
.craft-inv .inv-note { white-space: normal; }
.craft-inv .inv-hint kbd { font-size: 0.625rem; padding: 0.15rem 0.3rem; }
.craft-bench.is-view-only .slot:hover { background: rgba(255, 255, 255, 0.1); }

/* ── right: what is needed, where to get it, how, uses ──── */
.craft-side { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 1rem; margin-right: -0.6rem; padding-right: 0.6rem; }
.craft-panel { position: relative; flex: none; padding: 1.15rem 1.25rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.9rem; }
/* a panel the search pointed at («где взять …», «зачем …») lights its edge once; opacity only */
.craft-panel.is-flash::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5); pointer-events: none; animation: craft-flash 0.7s var(--ease) both; }
@keyframes craft-flash { from { opacity: 1; } to { opacity: 0; } }
.craft-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.craft-panel-head h2 { min-width: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.craft-panel-head span { flex: none; font-size: 0.75rem; color: var(--text-3); }
.craft-empty { font-size: 0.8125rem; color: var(--text-3); line-height: 1.5; }
.craft-need { display: flex; flex-direction: column; }
.craft-need-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.craft-need-row:first-child { border-top: 0; padding-top: 0; }
.craft-need-row:last-child { padding-bottom: 0; }
.craft-need-name { font-size: 0.875rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.craft-need-sub { font-size: 0.75rem; color: var(--text-3); margin-top: 0.1rem; line-height: 1.4; }
.craft-need-sub.ok { color: var(--mint); }
.craft-need-sub.no { color: #ff9a9e; }
.craft-count { font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.craft-need-row .btn { height: 1.875rem; padding: 0 0.75rem; font-size: 0.75rem; }
.craft-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.craft-steps li { counter-increment: step; display: grid; grid-template-columns: 1.3rem auto minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.craft-steps li:first-child { border-top: 0; padding-top: 0; }
.craft-steps li::before { content: counter(step); width: 1.3rem; height: 1.3rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.68rem; font-weight: 700; background: #262c36; color: var(--text-2); border: 1px solid var(--line-2); }
.craft-steps li.is-done::before { background: var(--mint); color: var(--on-light); border-color: transparent; }
.craft-uses { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.3rem; }
.craft-use { aspect-ratio: 1; width: 100%; padding: 0; border: 0; border-radius: 0.3rem; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); color: var(--text-2); }
.craft-use:hover { background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }
.craft-use-art { width: 100%; height: 100%; }
.craft-use .ic { width: 50%; height: 50%; stroke-width: 1.6; }
.craft-use img.ico { image-rendering: pixelated; }

/* ── stage 2: the row over the grid, ★, goals, the sunset hint, the economy ── */
/* one slim line over the station, as wide as the buttons and the inventory, 0.3rem above it: with the station's
   padding a little tighter it takes the room the mockup left over the grid, and the worst case (a two-line reason
   under the buttons at 2×2) still fits a 16:9 screen without scrolling */
.craft-headrow { display: flex; align-items: center; gap: 0.45rem; width: 100%; max-width: 30rem; height: 1.6rem; margin-bottom: -0.8rem; }
.craft-head-name { flex: 1; min-width: 0; font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.craft-headrow .btn { flex: none; height: 1.6rem; padding: 0 0.65rem; gap: 0.4rem; font-size: 0.72rem; }
.craft-headrow .btn .ic, .craft-panel-pin .ic { width: 0.9rem; height: 0.9rem; }
/* off at three goals: the reason stays readable (not the faded default of a disabled button) */
.craft-headrow .btn:disabled, .craft-panel-pin:disabled { opacity: 1; background: transparent; border-color: var(--line); color: var(--text-3); }
.btn.is-on { background: var(--mint-soft); border-color: rgba(75, 214, 156, 0.35); color: var(--mint); }
.btn.is-on:hover { background: rgba(75, 214, 156, 0.2); border-color: rgba(75, 214, 156, 0.5); }
.craft-panel-head .craft-panel-pin { align-self: center; flex: none; height: 1.6rem; padding: 0 0.6rem; gap: 0.35rem; font-size: 0.7rem; }
.craft-panel-head .craft-panel-pin span { font-size: inherit; color: inherit; }
.craft-pin-why { margin-top: -0.5rem; font-size: 0.75rem; color: var(--text-3); }

/* ★: quiet until hovered; gold and filled once the item is a favourite */
.craft-row-fav, .craft-head-fav { display: grid; place-items: center; flex: none; width: 1.75rem; height: 1.75rem; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-4); transition: color var(--t-fast), background var(--t-fast), opacity var(--t-fast); }
.craft-row-fav .ic, .craft-head-fav .ic { width: 1rem; height: 1rem; }
.craft-row-fav:hover, .craft-head-fav:hover { color: var(--text); background: var(--surface-2); }
.craft-row-fav[aria-pressed="true"], .craft-head-fav[aria-pressed="true"] { color: var(--gold); }
.craft-row-fav[aria-pressed="true"] .ic, .craft-head-fav[aria-pressed="true"] .ic { fill: currentColor; }
.craft-row:has(> .craft-row-fav) { grid-template-columns: auto minmax(0, 1fr) auto; }
.craft-row-fav { opacity: 0; margin-left: -0.4rem; }
.craft-row:hover .craft-row-fav, .craft-row[aria-selected="true"] .craft-row-fav, .craft-row-fav[aria-pressed="true"], .craft-row-fav:focus-visible { opacity: 1; }
/* a mark on its way to the server: the ★ and the pin wait, dimmed, until the reply (no animation) */
.craft-row .craft-row-fav[aria-busy="true"], .craft-head-fav[aria-busy="true"] { opacity: 0.45; cursor: progress; }
.craft-headrow .btn[aria-busy="true"], .craft-panel-pin[aria-busy="true"] { cursor: progress; }

/* a goal's progress under its line: a thin track, the fill scaled (no layout, no animation) */
.craft-row-bar { display: block; height: 0.2rem; margin-top: 0.35rem; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.craft-row-bar > i { display: block; height: 100%; background: var(--sky); transform-origin: left center; transform: scaleX(var(--p, 0)); }
.craft-row.is-done .craft-row-bar > i { background: var(--mint); }

/* «До заката ~1 мин. Хватит на 8 факелов» over the home list (outside the listbox: it holds a button): a quiet line
   (doc), only the sun in amber; it stays in view while the list scrolls */
.craft-night { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.6rem; flex: none; padding: 0.55rem 0.6rem 0.55rem 0.7rem; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); font-size: 0.78rem; line-height: 1.35; color: var(--text-2); }
.craft-night > .ic { width: 1.05rem; height: 1.05rem; color: var(--amber); }
.craft-night .btn { height: 1.75rem; padding: 0 0.65rem; font-size: 0.72rem; }

/* lots, orders and contracts in «Где взять»: the line, and under it the button to where it is */
.craft-need-row.craft-econ { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
.craft-econ .craft-ico.craft-src { color: var(--gold); }
.craft-econ .btn { margin-top: 0.4rem; height: 1.6rem; padding: 0 0.65rem; font-size: 0.72rem; }

@media (max-width: 1100px) {
  .content[data-screen="crafting"] { overflow-y: auto; display: block; }
  .craft { grid-template-columns: minmax(0, 1fr); }
  .craft-rows { max-height: 24rem; }
}
