/* ─── Deadlock Texture Forge v2 ──────────────────────────────────────────────
   Hero-centric two-level navigation.
   Same noir-industrial palette as Sound Forge.
─────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:        #1c1916;
  --bg-1:      #252119;
  --bg-2:      #2e2a22;
  --bg-3:      #3a352c;
  --ink:       #f2ead8;
  --ink-dim:   #c0ae96;
  --ink-faint: #8a7a68;
  --line:      #4a4238;
  --line-hot:  #6e5c48;

  --brass:     #d4a86a;
  --brass-hot: #f3c789;
  --brass-dim: #8a6d45;

  --blood:     #c14a2d;
  --blood-hot: #e25c3a;

  --teal:      #4fa391;

  --font-display: "Syncopate", "Arial Narrow", sans-serif;
  --font-mono:    "IBM Plex Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brass); text-decoration: none; }
a:hover { color: var(--brass-hot); }

/* ─── overlays ───────────────────────────────────────── */

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  opacity: 0.022; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 99;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.28) 100%);
}
.scanline {
  position: fixed; left: 0; right: 0; top: 54px; height: 1px;
  background: linear-gradient(to right, transparent, var(--brass-dim) 20%, var(--brass) 50%, var(--brass-dim) 80%, transparent);
  opacity: 0.35; pointer-events: none; z-index: 10;
}

/* ─── header ─────────────────────────────────────────── */

.chrome {
  position: relative; display: flex; align-items: center;
  justify-content: space-between; height: 54px; padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--bg-1), var(--bg));
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  color: var(--brass); font-family: var(--font-display);
  letter-spacing: 0.3em; font-size: 11px;
  padding: 2px 6px; border: 1px solid var(--brass-dim); line-height: 1;
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-line-1 {
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.42em; font-size: 15px; color: var(--ink);
}
.brand-line-2 {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--brass); letter-spacing: 0.28em; text-transform: uppercase;
}
.chrome-center { flex: 1; display: flex; justify-content: center; gap: 10px; }
.nav-link {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); border: 1px solid var(--line); padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover { color: var(--brass); border-color: var(--brass-dim); }

.status {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.2em;
}
.status .dot {
  width: 7px; height: 7px; background: var(--blood);
  border-radius: 50%; box-shadow: 0 0 6px var(--blood);
}
.status.ok .dot { background: var(--teal); box-shadow: 0 0 6px var(--teal); }

/* ─── layout ─────────────────────────────────────────── */

.layout {
  position: absolute; inset: 55px 0 0 0;
  display: grid;
  grid-template-columns: 180px minmax(0,1fr) 300px;
  height: calc(100% - 55px);
  min-width: 0;
  overflow: hidden;
}
.layout > aside, .layout > section {
  overflow: auto;
  scrollbar-color: var(--line-hot) var(--bg);
  scrollbar-width: thin;
}

/* ─── sidebar (left) ─────────────────────────────────── */

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  display: flex; flex-direction: column;
  padding: 14px 0;
  gap: 0;
}

.sidebar-search { padding: 0 14px 14px; border-bottom: 1px solid var(--line); }
.searchbar {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--bg-2); padding: 5px 8px;
}
.searchbar .glyph { color: var(--brass-dim); font-size: 14px; line-height: 1; flex-shrink: 0; }
.searchbar input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--ink); font-family: var(--font-mono); font-size: 12px; padding: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.searchbar input::placeholder { color: var(--ink-faint); }



.side-footer {
  margin-top: auto; padding: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-faint);
  letter-spacing: 0.06em;
  display: flex; flex-direction: column; gap: 4px;
}
.side-footer span { color: var(--ink-dim); }

/* ─── center panel ───────────────────────────────────── */

.center {
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.view {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}

.view-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1); flex-shrink: 0;
}
.view-title {
  font-family: var(--font-display); font-size: 10px;
  letter-spacing: 0.4em; color: var(--ink-faint); text-transform: uppercase;
}
.view-subtitle {
  font-size: 11px; color: var(--ink-faint); margin-left: auto;
}

/* ─── hero grid ──────────────────────────────────────── */

#hero-grid {
  flex: 1; overflow-y: auto; padding: 14px;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  grid-auto-rows: max-content;
  gap: 10px;
  align-content: start;
  scrollbar-color: var(--line-hot) var(--bg); scrollbar-width: thin;
}

.hero-card {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-2);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  overflow: hidden;
  position: relative;
}
.hero-card:hover {
  border-color: var(--line-hot);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}
.hero-card.has-selection {
  border-color: var(--brass);
  box-shadow: 0 0 0 1px var(--brass);
}

.hero-card-img {
  width: 100%;
  aspect-ratio: 120 / 200;
  overflow: hidden;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
}
.hero-card-img img {
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: auto;
  transition: transform 0.2s;
}
.hero-card:hover .hero-card-img img { transform: scale(1.04); }
.hero-card-img .hero-no-img {
  font-size: 24px; color: var(--ink-faint);
}

.hero-card-meta {
  padding: 7px 8px 8px;
  border-top: 1px solid var(--line);
}
.hero-card-name {
  font-family: var(--font-display); font-size: 8px;
  letter-spacing: 0.22em; color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-card-sub {
  font-size: 9px; color: var(--ink-faint);
  letter-spacing: 0.05em; margin-top: 2px;
}
.hero-card.has-selection .hero-card-name { color: var(--brass); }

/* selected badge */
.hero-sel-badge {
  position: absolute; top: 5px; right: 5px;
  background: var(--brass); color: var(--bg);
  font-size: 8px; font-family: var(--font-mono);
  padding: 1px 4px; letter-spacing: 0.1em;
  display: none;
}
.hero-card.has-selection .hero-sel-badge { display: block; }



/* ─── detail view ────────────────────────────────────── */

.detail-header {
  gap: 14px;
}
.back-btn {
  background: none; border: 1px solid var(--line); color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 11px;
  padding: 4px 10px; cursor: pointer; letter-spacing: 0.08em;
  transition: all 0.1s; flex-shrink: 0;
}
.back-btn:hover { color: var(--brass); border-color: var(--brass-dim); }

.detail-hero-name {
  font-family: var(--font-display); font-size: 12px;
  letter-spacing: 0.35em; color: var(--ink); text-transform: uppercase;
}

#view-detail {
  overflow-y: auto;
  scrollbar-color: var(--line-hot) var(--bg); scrollbar-width: thin;
}

.detail-section {
  padding: 0 14px 16px;
}
.detail-section-label {
  font-family: var(--font-display); font-size: 9px;
  letter-spacing: 0.4em; color: var(--ink-faint);
  text-transform: uppercase;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

/* ─── texture tiles ──────────────────────────────────── */

.texture-grid {
  display: grid; gap: 8px;
}
.portrait-grid {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
.ability-grid {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}

.tex-tile {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-2);
  position: relative; overflow: hidden;
  transition: border-color 0.1s, transform 0.1s;
  user-select: none;
}
.tex-tile:hover {
  border-color: var(--line-hot);
  transform: translateY(-1px);
}
.tex-tile.selected {
  border-color: var(--brass);
  box-shadow: 0 0 0 1px var(--brass);
}
.tex-tile.selected::after {
  content: "◆";
  position: absolute; top: 3px; right: 4px;
  font-size: 8px; color: var(--brass);
  text-shadow: 0 0 4px rgba(0,0,0,0.9);
  line-height: 1;
}

.tex-img-wrap {
  width: 100%; overflow: hidden;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
}
/* portrait ratio 120:200 = 0.6 — taller tiles */
.portrait-grid .tex-img-wrap { aspect-ratio: 3/4; }
/* ability ratio ~1:1 */
.ability-grid .tex-img-wrap { aspect-ratio: 1; }

.tex-img-wrap img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; width: 100%; height: 100%;
}
.tex-img-wrap .tex-no-img { font-size: 16px; color: var(--ink-faint); }

/* ─── HUD circular-card context preview ────────────────────────────── */

/* Outer container – dark panel like the in-game top-bar segment */
.hud-card-preview {
  width: 100%;
  aspect-ratio: 1;           /* square tile so circle fills it nicely */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14%;
  position: relative;
  background: var(--bg-3);
}

/* Amber variant – normal top-bar card */
.hud-card--normal {
  background: radial-gradient(ellipse at 50% 110%, #6b4414 0%, #2a1e0c 80%);
  box-shadow: inset 0 -3px 10px rgba(212, 168, 106, 0.15);
}
/* Red variant – low-HP critical card */
.hud-card--critical {
  background: radial-gradient(ellipse at 50% 110%, #5c1212 0%, #1e0a0a 80%);
  box-shadow: inset 0 -3px 10px rgba(193, 74, 45, 0.25);
}
/* Gold variant – kill-streak gloat card */
.hud-card--gloat {
  background: radial-gradient(ellipse at 50% 110%, #5c4a08 0%, #1e180a 80%);
  box-shadow: inset 0 -3px 10px rgba(230, 190, 40, 0.2);
}

/* The circle that clips the portrait */
.hud-card-circle {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

/* Accent ring on the circle */
.hud-card--normal   .hud-card-circle { box-shadow: 0 0 0 2px #c8883a, 0 0 8px rgba(200,136,58,0.5); }
.hud-card--critical .hud-card-circle { box-shadow: 0 0 0 2px #c14a2d, 0 0 10px rgba(193,74,45,0.6); }
.hud-card--gloat    .hud-card-circle { box-shadow: 0 0 0 2px #e0b830, 0 0 10px rgba(224,184,48,0.55); }

/* The portrait image inside the circle */
.hud-card-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;   /* show the hero face, not the torso */
  display: block;
}

.tex-meta {
  padding: 4px 5px 5px;
  border-top: 1px solid var(--line);
}
.tex-label {
  font-size: 9px; color: var(--ink-dim); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── empty state ────────────────────────────────────── */

.empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--ink-faint); padding: 40px;
}
.empty-mark { font-size: 32px; color: var(--blood); }
.empty p { font-size: 12px; letter-spacing: 0.08em; text-align: center; }

/* ─── forge panel (right) ────────────────────────────── */

.forge {
  background: var(--bg-1);
  display: flex; flex-direction: column;
}
.forge-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--ink-faint); padding: 32px; text-align: center;
}
.forge-empty p { font-size: 12px; letter-spacing: 0.06em; line-height: 1.6; }

.forge-active {
  flex: 1; display: flex; flex-direction: column;
  overflow-y: auto;
  scrollbar-color: var(--line-hot) var(--bg); scrollbar-width: thin;
}

.forge-section { padding: 14px 16px; }
.forge-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.forge-section-title {
  font-family: var(--font-display); font-size: 9px;
  letter-spacing: 0.4em; color: var(--ink-faint); text-transform: uppercase;
}
.forge-divider { height: 1px; background: var(--line); flex-shrink: 0; }

.selection-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 150px; overflow-y: auto;
  scrollbar-color: var(--line-hot) var(--bg); scrollbar-width: thin;
}
.sel-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim);
}
.sel-item img {
  width: 24px; height: 24px; object-fit: contain;
  background: var(--bg-3); flex-shrink: 0;
}
.sel-item .sel-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item .sel-item-remove { flex-shrink: 0; cursor: pointer; color: var(--ink-faint); }
.sel-item .sel-item-remove:hover { color: var(--blood-hot); }

.sel-item--batch { flex-wrap: nowrap; gap: 6px; }
.sel-item--batch .sel-item-label { font-size: 10px; }
.sel-item-status { flex-shrink: 0; font-size: 12px; color: var(--ink-faint); width: 12px; text-align: center; }
.sel-item-status.ok { color: var(--teal); }
.sel-item-upload { flex-shrink: 0; font-size: 9px; padding: 2px 6px; }

.selection-list { max-height: none; }

.dim-info { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.06em; margin-bottom: 8px; }

.drop {
  border: 1px dashed var(--line-hot); background: var(--bg-2);
  cursor: pointer; min-height: 80px;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.drag-over { border-color: var(--brass-dim); background: var(--bg-3); }
.drop-inner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; padding: 16px; text-align: center; pointer-events: none;
}
.drop-glyph { font-size: 20px; color: var(--blood); line-height: 1; transition: color 0.15s; }
.drop-glyph.ok { color: var(--teal); }
.drop p { font-size: 12px; color: var(--ink-dim); margin: 0; line-height: 1.45; }
.drop p .dim { font-size: 11px; color: var(--ink-faint); }
.drop-ready {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; gap: 8px;
}
.drop-file-info { display: flex; align-items: center; gap: 10px; }
.drop-file-info .drop-glyph { font-size: 16px; }
.drop-file-info code { font-size: 11px; color: var(--ink); display: block; }
.drop-file-info .dim { font-size: 10px; color: var(--ink-faint); margin: 2px 0 0; }

.preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.preview-slot { display: flex; flex-direction: column; gap: 4px; }
.preview-label {
  font-size: 9px; color: var(--ink-faint);
  letter-spacing: 0.18em; text-transform: uppercase; text-align: center;
}
.preview-img {
  width: 100%; object-fit: contain; background: var(--bg-3);
  border: 1px solid var(--line); min-height: 60px; max-height: 160px;
}

/* buttons */
.mini {
  background: var(--bg-3); color: var(--ink-dim);
  border: 1px solid var(--line); padding: 3px 9px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; cursor: pointer; text-transform: uppercase;
  transition: all 0.1s;
}
.mini:hover { color: var(--brass); border-color: var(--brass-dim); }

#dl-template-zip { display: block; margin-bottom: 10px; width: 100%; text-align: left; font-size: 11px; }

.forge-btn {
  display: block; width: calc(100% - 32px);
  margin: 0 16px 16px;
  background: linear-gradient(135deg, var(--blood) 0%, #8a2510 100%);
  color: var(--ink); border: 1px solid var(--blood);
  padding: 12px 0;
  font-family: var(--font-display); font-weight: 700;
  font-size: 11px; letter-spacing: 0.5em; text-transform: uppercase;
  cursor: pointer; transition: all 0.15s;
}
.forge-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blood-hot) 0%, var(--blood) 100%);
  box-shadow: 0 0 16px rgba(193,74,45,0.35);
}
.forge-btn:disabled { opacity: 0.4; cursor: default; }
.forge-btn.loading { animation: pulse 1s ease-in-out infinite alternate; }
.forge-btn-zip {
  background: linear-gradient(135deg, #2e3f4f 0%, #1e2d3a 100%);
  color: #8fc4d8; border-color: #3a5060;
}
.forge-btn-zip:hover:not(:disabled) {
  background: linear-gradient(135deg, #3a5060 0%, #2e3f4f 100%);
  box-shadow: 0 0 16px rgba(79,163,145,0.25);
  color: #b8dce8;
}
.forge-btn-zip.loading {
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.6; } to { opacity: 1.0; } }

.log {
  margin: 0 16px 16px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim);
  white-space: pre-wrap; line-height: 1.5; letter-spacing: 0.02em;
}
.log.ok { border-color: var(--teal); color: var(--teal); }
.log.err { border-color: var(--blood); color: var(--blood-hot); }

.dim { color: var(--ink-faint); }

/* ─── responsive ──────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 160px minmax(0,1fr) 260px;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 140px minmax(0,1fr) 220px;
  }
  .brand-line-1 { font-size: 12px; }
  .brand-line-2 { font-size: 9px; }
}
