/* Recettes — DA Factomancer (fenêtres machines in-game) */

:root {
  --ft-ink: #e6e2f2;
  --ft-bg: #070b18;
  --ft-panel: #151c38;
  --ft-raised: #1f294c;
  --ft-card: #1a2040;
  --ft-card-root: #2a1f4a;
  --ft-card-base: #142838;
  --ft-line: rgba(201, 168, 76, 0.55);
  --ft-gold: #e8c56a;
  --ft-gold-deep: #b8862e;
  --ft-accent: #9b6dd4;
  --ft-accent-soft: rgba(124, 77, 187, 0.28);
  --ft-text: #f3f0fa;
  --ft-muted: #9aa3c7;
  --ft-rate: #5cdb7a;
  --ft-fact: #f0b429;
  --ft-price: #f5d76e;
  --ft-border: rgba(201, 168, 76, 0.35);
}

.page-recettes .page-head {
  margin: 0 0 0.85rem;
  padding: 0;
}

.page-recettes .page-head h1 {
  font-family: var(--font-display, Cinzel, serif);
  font-size: clamp(1.45rem, 2.6vw, 1.9rem);
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
  color: var(--ft-gold);
}

.page-recettes .page-head p {
  margin: 0;
  font-size: 1rem;
  color: var(--ft-muted);
  font-weight: 500;
  line-height: 1.5;
}

.page-recettes .page-head code {
  color: var(--ft-rate);
  font-size: 0.9em;
}

.cat-block {
  margin-bottom: 0.95rem;
  border: 1.5px solid var(--ft-border);
  border-radius: 14px;
  background: var(--ft-panel);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  overflow: visible;
  color: var(--ft-ink);
}

.cat-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  align-items: baseline;
  padding: 0.65rem 0.95rem;
  border-bottom: 1px solid var(--ft-border);
  background: linear-gradient(180deg, rgba(34, 44, 82, 0.98) 0%, rgba(18, 24, 48, 0.98) 100%);
  border-radius: 12px 12px 0 0;
}

.cat-head h2 {
  margin: 0;
  font-family: var(--font-display, Cinzel, serif);
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ft-gold);
}

.cat-head p {
  margin: 0;
  font-weight: 600;
  color: var(--ft-muted);
  font-size: 0.9rem;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 0.55rem;
  padding: 0.8rem;
  align-items: start;
}

.item-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.4rem 0.5rem;
  border: 1.5px solid var(--ft-border);
  border-radius: 12px;
  background: linear-gradient(165deg, var(--ft-raised) 0%, #161d3a 100%);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.item-cell.is-hidden { display: none !important; }

.item-cell:hover,
.item-cell:focus-visible {
  border-color: var(--ft-gold);
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(232, 197, 106, 0.25);
}

.item-cell.is-open {
  border-color: var(--ft-gold);
  box-shadow: 0 0 0 1px var(--ft-gold), 0 0 24px rgba(155, 109, 212, 0.35);
}

.item-cell .thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(201, 168, 76, 0.2);
}

.item-cell .name {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.2;
  color: var(--ft-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2em;
}

.item-cell .price {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ft-price);
}

.ft-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  white-space: nowrap;
  color: var(--ft-price);
  font-weight: inherit;
}

.ft-coin {
  width: 1em;
  height: 1em;
  display: inline-block;
  flex: 0 0 auto;
  object-fit: contain;
  vertical-align: -0.12em;
  image-rendering: auto;
}

.item-cell .price .ft-coin {
  width: 0.95em;
  height: 0.95em;
}

.ft-stats .p .ft-coin {
  width: 0.9em;
  height: 0.9em;
}

.mach-table .ft-coin {
  width: 0.95em;
  height: 0.95em;
}

.mach-total .sum .ft-coin {
  width: 1.15em;
  height: 1.15em;
}

.item-cell .rate {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ft-rate);
}

.item-cell .meta {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ft-muted);
}

.craft-slot {
  display: none;
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0.2rem 0 0.3rem;
  padding: 0;
  border: 1.5px solid var(--ft-gold);
  border-radius: 14px;
  background: linear-gradient(180deg, #1a2448 0%, #121833 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 32px rgba(124, 77, 187, 0.2);
  color: var(--ft-ink);
  text-align: left;
  cursor: default;
  min-width: 0;
  overflow: hidden;
}

.craft-slot.is-active { display: block; }

.craft-fs-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(4, 8, 20, 0.82);
  cursor: pointer;
}

.craft-slot.is-expanded {
  position: fixed;
  inset: 0.7rem;
  z-index: 250;
  margin: 0;
  width: auto;
  max-width: none;
  height: calc(100dvh - 1.4rem);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.65),
    0 0 48px rgba(124, 77, 187, 0.28);
}

.craft-slot.is-expanded .panel-head {
  flex: 0 0 auto;
  border-radius: 14px 14px 0 0;
}

.craft-slot.is-expanded .panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding-bottom: 1.5rem;
}

.craft-slot.is-expanded .tree-map {
  margin-left: 1rem;
  margin-right: 1rem;
}

.craft-slot.is-expanded .tree-map-viewport {
  height: min(78dvh, 860px);
}

.craft-slot.is-expanded .tree-map-toolbar {
  justify-content: space-between;
  gap: 0.75rem;
}

.craft-fs-jumps {
  display: none;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.craft-slot.is-expanded .craft-fs-jumps {
  display: inline-flex;
}

.craft-fs-jumps a {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 999px;
  background: rgba(10, 14, 32, 0.55);
  color: var(--ft-gold);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.craft-fs-jumps a:hover {
  border-color: var(--ft-gold);
  background: rgba(232, 197, 106, 0.12);
}

body.craft-fs-open {
  overflow: hidden;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, var(--ft-gold) 0%, var(--ft-gold-deep) 100%);
  border-radius: 12px 12px 0 0;
}

.panel-head .left {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
}

.panel-head .hero-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(10, 14, 32, 0.45);
  border: 1.5px solid rgba(26, 20, 8, 0.35);
}

.panel-head h3 {
  margin: 0;
  font-family: var(--font-display, Cinzel, serif);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1a1408;
}

.panel-head .sub {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(26, 20, 8, 0.72);
}

.factory-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.factory-ctrl button {
  min-width: 2.4rem;
  height: 2.2rem;
  padding: 0 0.75rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #9b6dd4 0%, #5a2d8a 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(90, 45, 138, 0.45);
}

.factory-ctrl button:hover {
  filter: brightness(1.08);
}

.factory-ctrl button[data-expand] {
  font-size: 1.05rem;
  letter-spacing: 0;
}

.panel-body { padding: 0.85rem 0.95rem 1.1rem; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ft-muted);
}

.legend i { font-style: normal; margin-right: 0.2rem; }
.legend .r { color: var(--ft-rate); }
.legend .f { color: var(--ft-fact); }
.legend .p { color: var(--ft-price); }

.tree-map {
  position: relative;
  margin: 0 100px 0.85rem;
  border: 1.5px solid var(--ft-border);
  border-radius: 12px;
  background: #0c1228;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.tree-map-toolbar {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--ft-border);
  background: rgba(31, 41, 76, 0.9);
}

.tree-map-hint {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ft-muted);
}

.tree-map-viewport {
  position: relative;
  height: min(58vh, 520px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle at 1px 1px, rgba(201, 168, 76, 0.22) 1px, transparent 0) 0 0 / 20px 20px,
    linear-gradient(180deg, #0a1020 0%, #121833 100%);
}

.tree-map-viewport.is-panning { cursor: grabbing; }

.tree-map-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

.ftree {
  --line: 2px solid rgba(201, 168, 76, 0.55);
  display: flex;
  justify-content: center;
  padding: 1rem 1.25rem;
  width: max-content;
}

.ftree ul {
  display: flex;
  justify-content: center;
  padding-top: 1.1rem;
  position: relative;
  margin: 0;
  list-style: none;
}

.ftree ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 1.1rem;
  border-left: var(--line);
  transform: translateX(-1px);
}

.ftree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 1.1rem 0.4rem 0;
}

.ftree li::before,
.ftree li::after {
  content: "";
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: 1.1rem;
  border-top: var(--line);
}

.ftree li::after { right: auto; left: 50%; border-left: var(--line); }
.ftree li:only-child::before,
.ftree li:only-child::after { display: none; }

.ftree li:only-child::after {
  display: block;
  left: 50%;
  border: 0;
  border-left: var(--line);
  height: 1.1rem;
  width: 0;
}

.ftree li:first-child::before,
.ftree li:last-child::after { border: 0 none; }
.ftree li:last-child::before { border-right: var(--line); border-radius: 0 6px 0 0; }
.ftree li:first-child::after { border-radius: 6px 0 0 0; }
.ftree > .ft-unit { padding-top: 0; }
.ftree > .ft-unit::before,
.ftree > .ft-unit::after { display: none !important; }

.ft-unit { display: flex; align-items: flex-start; gap: 0.35rem; }

.ft-box {
  width: 118px;
  min-height: 112px;
  padding: 0.45rem;
  border: 1.5px solid rgba(154, 163, 199, 0.45);
  border-radius: 10px;
  background: var(--ft-card);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.ft-box:hover {
  transform: translateY(-2px);
  border-color: var(--ft-accent);
  box-shadow: 0 0 18px rgba(155, 109, 212, 0.35);
}

.ft-box.is-root {
  border-color: var(--ft-gold);
  background: var(--ft-card-root);
  box-shadow: 0 0 20px rgba(232, 197, 106, 0.25);
}

.ft-box.is-base {
  border-color: var(--ft-rate);
  background: var(--ft-card-base);
}

.ft-box img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  display: block;
  margin: 0 auto 0.2rem;
  pointer-events: none;
}

.ft-box .nm {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--ft-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ft-box .mach {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #c4b5fd;
  line-height: 1.2;
}

.ft-stats {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 5.8rem;
  padding-top: 0.15rem;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
}

.ft-stats .r { color: var(--ft-rate); }
.ft-stats .f { color: var(--ft-fact); }
.ft-stats .p { color: var(--ft-price); }
.ft-stats .m {
  color: #c4b5fd;
  font-size: 0.78rem;
  font-weight: 600;
}

.side-blocks {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 800px) {
  .side-blocks { grid-template-columns: 1fr 1fr; }
}

.side-blocks h4 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display, Cinzel, serif);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--ft-gold);
}

.raw-chip,
.into-chip,
.craft-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0.35rem 0.35rem 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--ft-border);
  border-radius: 999px;
  background: rgba(31, 41, 76, 0.9);
  color: var(--ft-ink);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.raw-chip:hover,
.into-chip:hover,
.craft-chip:hover {
  border-color: var(--ft-gold);
  box-shadow: 0 0 12px rgba(232, 197, 106, 0.2);
}

.raw-chip img,
.into-chip img,
.craft-chip img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.raw-chip .n,
.craft-chip .n { color: var(--ft-fact); }
.craft-chip .m { color: var(--ft-accent); font-size: 0.75rem; }

.empty { color: var(--ft-muted); font-weight: 600; font-size: 0.9rem; }

.mach-block {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1.5px solid var(--ft-border);
  border-radius: 12px;
  background: rgba(12, 18, 40, 0.7);
}

.mach-block h4 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display, Cinzel, serif);
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--ft-gold);
}

.craft-list { display: flex; flex-wrap: wrap; }

.mach-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  border: 1.5px solid rgba(201, 168, 76, 0.55);
}

.mach-table th,
.mach-table td {
  padding: 0.55rem 0.6rem;
  border: 1px solid rgba(201, 168, 76, 0.4);
  text-align: left;
  color: var(--ft-ink);
}

.mach-table th {
  color: var(--ft-gold);
  font-weight: 700;
  background: rgba(124, 77, 187, 0.18);
}

.mach-table tbody tr:nth-child(even) td {
  background: rgba(31, 41, 76, 0.45);
}

.mach-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.mach-table .need { color: var(--ft-fact); font-weight: 800; }
.mach-table .buy { font-weight: 800; }
.mach-table .unit,
.mach-table .line { color: var(--ft-price); font-weight: 700; }

.mach-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
}

.mach-cell img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.mach-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1.5px solid var(--ft-border);
  font-weight: 800;
  font-size: 1rem;
  color: var(--ft-ink);
}

.mach-total .sum {
  font-size: 1.25rem;
  color: var(--ft-price);
}

.mach-note {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--ft-muted);
  font-weight: 500;
}

.close-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--ft-muted);
  font-weight: 500;
}

@media (max-width: 900px) {
  .tree-map {
    margin-left: 12px;
    margin-right: 12px;
  }

  .craft-slot.is-expanded {
    inset: 0.35rem;
    height: calc(100dvh - 0.7rem);
  }

  .craft-slot.is-expanded .tree-map-viewport {
    height: min(62dvh, 640px);
  }

  .craft-fs-jumps a {
    font-size: 0.72rem;
    padding: 0.18rem 0.45rem;
  }
}
