/* =========================================================
   TriNex Crafting Page
   Builds on sitepro/magicitems.css shared variables and header.
   ========================================================= */

.crafting-page {
  --forge: #f59e0b;
  --forge-2: #ef4444;
  --steel: #38bdf8;
  --smoke: #64748b;
}

body.crafting-page::before {
  background:
    radial-gradient(900px 560px at 13% 8%, rgba(245, 158, 11, .18), transparent 62%),
    radial-gradient(780px 520px at 82% 10%, rgba(56, 189, 248, .12), transparent 58%),
    radial-gradient(680px 560px at 54% 100%, rgba(var(--magic-rgb), .12), transparent 68%),
    linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 44%);
}

body.crafting-page::after {
  opacity: .12;
  background-image:
    linear-gradient(rgba(245, 158, 11, .12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, .08) 1px, transparent 1px);
}

.crafting-shell {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px var(--pad) 64px;
}

.crafting-header .page-title-row::before {
  background:
    radial-gradient(circle at 32% 26%, rgba(245, 158, 11, .38), transparent 42%),
    url("/gallery/tnx-logo-ts1760711022.png") center / cover no-repeat,
    url("/gallery/tnx-logo.WebP") center / cover no-repeat;
}

.crafting-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(300px, .97fr);
  align-items: stretch;
  gap: 18px;
  min-height: 420px;
  border: 1px solid rgba(245, 158, 11, .20);
  border-radius: 24px;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--panel) 96%, #000), color-mix(in srgb, var(--panel-2) 90%, #000)),
    var(--panel);
  box-shadow: 0 24px 76px rgba(0, 0, 0, .22);
}

.crafting-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(245, 158, 11, .13), transparent 32%, rgba(56, 189, 248, .08)),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 255, 255, .035) 22px 23px);
  opacity: .58;
}

.crafting-hero-copy,
.crafting-art {
  position: relative;
  z-index: 1;
}

.crafting-hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(22px, 4vw, 38px);
}

.crafting-kicker {
  margin: 0 0 8px;
  color: var(--steel);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.crafting-hero h2,
.recipe-detail-panel h2,
.recipe-list-panel h2 {
  margin: 0;
  line-height: 1.12;
}

.crafting-hero h2 {
  max-width: 690px;
  font-size: 50px;
}

.crafting-hero p {
  max-width: 690px;
  margin: 12px 0 0;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  font-size: 15px;
}

.guide-form {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.guide-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.guide-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  max-width: 720px;
}

.guide-input-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(245, 158, 11, .26);
  border-radius: 16px;
  outline: none;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, .08), transparent 46%),
    color-mix(in srgb, var(--panel) 94%, #000);
  color: var(--text);
  padding: 10px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.guide-input-row input:focus {
  border-color: color-mix(in srgb, var(--forge) 78%, var(--link));
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}

.guide-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  min-height: 38px;
}

.guide-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}

.guide-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(100%, 440px);
  min-height: 34px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 999px;
  background: rgba(245, 158, 11, .075);
  color: var(--text);
  padding: 5px 6px 5px 11px;
  font-size: 12px;
}

.guide-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guide-chip button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.guide-chip button:hover,
.guide-chip button:focus-visible {
  color: var(--text);
  border-color: rgba(245, 158, 11, .38);
  outline: none;
}

.btn.subtle {
  color: var(--muted);
  background: rgba(255, 255, 255, .018);
}

.crafting-art {
  min-height: 320px;
  border-left: 1px solid rgba(245, 158, 11, .14);
  margin: 0;
}

.crafting-art::before,
.crafting-art::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.crafting-art::before {
  z-index: 1;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--panel) 82%, transparent), transparent 33%),
    linear-gradient(0deg, rgba(0, 0, 0, .36), transparent 40%);
}

.crafting-art::after {
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, .045);
  border-radius: 0 24px 24px 0;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .28);
}

.crafting-art img {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: block;
  object-fit: cover;
  object-position: center;
}

.crafting-status {
  display: none;
  margin: 14px 0;
  border: 1px solid rgba(165, 180, 252, .16);
  border-radius: 16px;
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
  padding: 11px 13px;
  font-size: 13px;
}

.crafting-status:not(:empty) {
  display: block;
}

.crafting-status.is-error {
  border-color: rgba(239, 68, 68, .34);
  background: rgba(239, 68, 68, .08);
  color: color-mix(in srgb, var(--danger) 78%, var(--text));
}

.crafting-status.is-good {
  border-color: rgba(34, 197, 94, .30);
  background: rgba(34, 197, 94, .07);
  color: color-mix(in srgb, var(--ok) 76%, var(--text));
}

.crafting-status.is-warning {
  border-color: rgba(245, 158, 11, .34);
  background: rgba(245, 158, 11, .08);
  color: color-mix(in srgb, var(--forge) 78%, var(--text));
}

.crafting-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.recipe-list-panel,
.recipe-detail-panel {
  border: 1px solid rgba(165, 180, 252, .16);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 26%),
    color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 18px 56px rgba(0, 0, 0, .15);
}

.recipe-list-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.recipe-detail-panel {
  min-height: 520px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(165, 180, 252, .12);
}

.panel-heading h2 {
  font-size: 24px;
}

.recipe-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.recipe-card {
  position: relative;
  width: 100%;
  min-height: 108px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, .09), transparent 52%),
    rgba(255, 255, 255, .025);
  color: var(--text);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.recipe-card:hover,
.recipe-card:focus-visible {
  border-color: rgba(245, 158, 11, .44);
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, .13), transparent 56%),
    rgba(255, 255, 255, .038);
  outline: none;
  transform: translateY(-1px);
}

.recipe-card.is-active {
  border-color: rgba(56, 189, 248, .58);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, .16) inset;
}

.recipe-card-title {
  display: block;
  margin: 0 0 7px;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.25;
}

.recipe-card-meta,
.detail-meta,
.detail-chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-chip-row {
  margin-top: 10px;
}

.knowledge-badge,
.detail-chip,
.unknown-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .035);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.2;
}

.knowledge-badge.is-full {
  color: var(--gold);
  border-color: rgba(247, 201, 72, .34);
  background: rgba(247, 201, 72, .07);
}

.knowledge-badge.is-partial {
  color: var(--steel);
  border-color: rgba(56, 189, 248, .32);
  background: rgba(56, 189, 248, .07);
}

.unknown-chip {
  color: color-mix(in srgb, var(--forge) 82%, var(--text));
  border-color: rgba(245, 158, 11, .28);
  background: rgba(245, 158, 11, .07);
}

.empty-list,
.empty-workbench {
  min-height: 220px;
  display: grid;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.empty-list {
  min-height: 160px;
  border: 1px dashed var(--border);
  border-radius: 16px;
}

.empty-workbench h2 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
}

.empty-workbench p {
  margin: 0;
}

.recipe-detail-head {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(165, 180, 252, .12);
}

.recipe-detail-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.recipe-detail-title-row h2 {
  font-size: 36px;
}

.result-link {
  justify-self: end;
  white-space: nowrap;
}

.recipe-detail-text {
  max-width: 860px;
  margin: 0;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
}

.detail-section {
  display: grid;
  gap: 10px;
  padding: 15px 0;
  border-top: 1px solid rgba(165, 180, 252, .10);
}

.detail-section:first-of-type {
  border-top: 0;
}

.detail-section h3 {
  margin: 0;
  color: var(--link);
  font-size: 18px;
  line-height: 1.25;
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 9px;
}

.component-item,
.requirement-item,
.stage-item,
.risk-item {
  border: 1px solid rgba(165, 180, 252, .13);
  border-radius: 14px;
  background: rgba(255, 255, 255, .022);
  padding: 11px;
}

.component-item strong,
.stage-item strong {
  display: block;
  color: var(--text);
  line-height: 1.25;
}

.component-item small,
.stage-item small,
.requirement-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.requirement-list,
.stage-list,
.risk-list {
  display: grid;
  gap: 9px;
}

.requirement-item {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr);
  gap: 10px;
}

.requirement-item b {
  color: var(--muted);
  font-size: 12px;
}

.requirement-item span,
.risk-item {
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.stage-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
}

.stage-pe {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(245, 158, 11, .30);
  border-radius: 14px;
  background: rgba(245, 158, 11, .08);
  color: var(--gold);
  font-weight: 900;
}

.stage-copy {
  min-width: 0;
}

.stage-copy p {
  margin: 5px 0 0;
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
}

.unknown-section {
  border: 1px dashed rgba(245, 158, 11, .28);
  border-radius: 16px;
  background: rgba(245, 158, 11, .045);
  padding: 13px;
  color: color-mix(in srgb, var(--forge) 78%, var(--text));
}

.unknown-section p {
  margin: 4px 0 0;
  color: var(--muted);
}

.detail-note {
  color: var(--muted);
  font-size: 13px;
}

[data-theme="light"] body.crafting-page::before {
  background:
    radial-gradient(900px 560px at 13% 8%, rgba(245, 158, 11, .12), transparent 62%),
    radial-gradient(780px 520px at 82% 10%, rgba(14, 165, 233, .10), transparent 58%),
    radial-gradient(680px 560px at 54% 100%, rgba(var(--magic-rgb), .08), transparent 68%),
    linear-gradient(180deg, rgba(15, 23, 42, .012), transparent 44%);
}

[data-theme="light"] .crafting-hero,
[data-theme="light"] .recipe-list-panel,
[data-theme="light"] .recipe-detail-panel {
  box-shadow: 0 18px 44px rgba(15, 23, 42, .08);
}

[data-theme="light"] .guide-input-row input {
  background: #ffffff;
}

[data-theme="light"] .crafting-art::before {
  background:
    linear-gradient(90deg, rgba(15, 23, 42, .24), transparent 36%),
    linear-gradient(0deg, rgba(15, 23, 42, .24), transparent 44%);
}

@media (max-width: 980px) {
  .crafting-hero {
    grid-template-columns: 1fr;
  }

  .crafting-art {
    min-height: 280px;
    border-left: 0;
    border-top: 1px solid rgba(245, 158, 11, .14);
  }

  .crafting-art::before {
    background: linear-gradient(0deg, color-mix(in srgb, var(--panel) 84%, transparent), transparent 44%);
  }

  .crafting-art::after {
    border-radius: 0 0 24px 24px;
  }

  .crafting-art img {
    min-height: 320px;
  }

  .crafting-workspace {
    grid-template-columns: 1fr;
  }

  .recipe-list-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .crafting-shell {
    padding-top: 14px;
  }

  .crafting-hero {
    min-height: 0;
    border-radius: 20px;
  }

  .crafting-art {
    order: -1;
    min-height: 178px;
    border-top: 0;
    border-bottom: 1px solid rgba(245, 158, 11, .14);
  }

  .crafting-art img {
    min-height: 178px;
    max-height: 220px;
  }

  .crafting-art::before {
    background:
      linear-gradient(180deg, transparent 42%, color-mix(in srgb, var(--panel) 84%, transparent)),
      linear-gradient(0deg, rgba(0, 0, 0, .34), transparent 44%);
  }

  .crafting-art::after {
    border-radius: 20px 20px 0 0;
  }

  .crafting-hero-copy {
    padding: 20px 15px;
  }

  .crafting-hero h2 {
    font-size: 32px;
  }

  .guide-input-row {
    grid-template-columns: 1fr;
  }

  .guide-input-row .btn,
  .guide-toolbar .btn {
    width: 100%;
  }

  .guide-chips,
  .guide-chip {
    width: 100%;
  }

  .guide-chip {
    max-width: none;
    justify-content: space-between;
  }

  .recipe-list-panel,
  .recipe-detail-panel {
    border-radius: 20px;
  }

  .recipe-detail-panel {
    padding: 14px;
    min-height: 420px;
  }

  .recipe-detail-title-row {
    grid-template-columns: 1fr;
  }

  .recipe-detail-title-row h2 {
    font-size: 28px;
  }

  .result-link {
    justify-self: stretch;
  }

  .result-link.btn {
    width: 100%;
  }

  .requirement-item,
  .stage-item {
    grid-template-columns: 1fr;
  }

  .stage-pe {
    width: auto;
    min-height: 38px;
  }
}

@media (max-width: 980px) {
  [data-theme="light"] .crafting-art::before {
    background:
      linear-gradient(0deg, rgba(15, 23, 42, .28), transparent 44%);
  }
}

@media (max-width: 680px) {
  [data-theme="light"] .crafting-art::before {
    background:
      linear-gradient(180deg, transparent 42%, rgba(15, 23, 42, .30)),
      linear-gradient(0deg, rgba(15, 23, 42, .24), transparent 44%);
  }
}

@media print {
  .crafting-header,
  .crafting-hero,
  .crafting-status,
  .recipe-list-panel {
    display: none !important;
  }

  .crafting-shell,
  .crafting-workspace,
  .recipe-detail-panel {
    display: block;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 0;
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  .detail-section,
  .component-item,
  .requirement-item,
  .stage-item,
  .risk-item,
  .unknown-section {
    border-color: #777 !important;
    background: #fff !important;
    break-inside: avoid;
  }
}
