/* ==========================================================================
   NATURE HUB — nature.css
   Glassmorphism · Neon stat colours · 5×5 matrix grid
   ========================================================================== */

/* ── Stat colours — bảng hiện đại (rose / sky / violet / amber / teal), dễ phân biệt trên nền tối */
:root {
  --nat-atk: #fb7185;
  --nat-def: #38bdf8;
  --nat-spa: #a78bfa;
  --nat-spd: #fbbf24;
  --nat-spe: #2dd4bf;
}

/* ── Page scroll override ───────────────────────────────────────── */
.nature-body { overflow-y: auto; height: auto; }
.nature-body main.container { overflow: visible; padding-bottom: 56px; }

/* ── Page shell ─────────────────────────────────────────────────── */
.nh-page {
  padding: 28px 0 0;
  /* main.container is a column flexbox; default min-width:auto blocks shrinking below wide matrix */
  min-width: 0;
  width: 100%;
}

/* ── Header ─────────────────────────────────────────────────────── */
.nh-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.nh-header-intro {
  min-width: 0;
  flex: 1 1 280px;
  max-width: min(720px, 100%);
}
.nh-title {
  font-size: clamp(1.5rem, 3.2vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
  background: linear-gradient(130deg, #fff 30%, rgba(255,255,255,0.5));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nh-subtitle {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.01em;
  line-height: 1.55;
  max-width: 100%;
}

/* ── Search bar ─────────────────────────────────────────────────── */
.nh-search-wrap {
  position: relative;
  flex-shrink: 0;
}
.nh-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
  stroke-width: 2;
}
.nh-search {
  width: 210px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.nh-search:focus {
  border-color: rgba(100,160,255,0.5);
  box-shadow: 0 0 0 1px rgba(100,160,255,0.15), 0 0 16px rgba(60,120,255,0.1);
}
.nh-search::placeholder { color: var(--muted); }
.nh-search::-webkit-search-cancel-button { display: none; }

/* ── Two-column layout ──────────────────────────────────────────── */
.nh-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  gap: 20px;
  align-items: start;
  min-width: 0;
}

/* Matrix section: min-width 0 so the 5×5 grid cannot “blow out” the page
   (grid items default to min-width:auto → content min = table width → clipped by body overflow-x) */
.nh-matrix-section {
  min-width: 0;
}

/* ── Matrix overflow scroll ─────────────────────────────────────── */
.nh-matrix-overflow {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  border-radius: 10px;
  padding-bottom: 2px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  /* iOS: keep momentum scroll inside this strip */
  overscroll-behavior-x: contain;
}

/* Scroll inner: matrix + glow overlays share one coordinate space */
.nh-matrix-scroll-inner {
  position: relative;
  display: inline-block;
  vertical-align: top;
  min-width: 100%;
}

/* Row/column band glow (position + size set via JS) */
.nh-matrix-glow {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  border-radius: 9px;
  opacity: 0;
  transition: opacity 0.14s ease;
  box-sizing: border-box;
}
.nh-matrix-scroll-inner.has-matrix-glow .nh-matrix-glow {
  opacity: 1;
}
.nh-matrix-glow-row {
  border: 2px solid var(--glow-row-color, transparent);
  box-shadow:
    0 0 14px var(--glow-row-color),
    0 0 28px color-mix(in srgb, var(--glow-row-color) 35%, transparent);
}
.nh-matrix-glow-col {
  border: 2px solid var(--glow-col-color, transparent);
  box-shadow:
    0 0 14px var(--glow-col-color),
    0 0 28px color-mix(in srgb, var(--glow-col-color) 35%, transparent);
}

/* ── Matrix CSS Grid (ô lớn hơn — dễ đọc tên nature) ───────────── */
.nh-matrix {
  display: grid;
  grid-template-columns: 128px repeat(5, minmax(108px, 1fr));
  gap: 5px;
  min-width: 680px;
  position: relative;
  z-index: 1;
}

/* ── Base cell ──────────────────────────────────────────────────── */
.nh-cell {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  transition: background 0.16s, border-color 0.16s, box-shadow 0.16s, transform 0.13s, opacity 0.16s;
  position: relative;
}

/* ── Corner ─────────────────────────────────────────────────────── */
.nh-corner {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  padding: 6px;
}
.nh-corner-label {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.04em;
}

/* ── Header cells (row + col labels) ───────────────────────────── */
.nh-hdr {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-color: var(--stat-color, var(--border));
  box-shadow: 0 0 8px color-mix(in srgb, var(--stat-color, #fff) 25%, transparent);
}
.nh-col-hdr {
  font-size: clamp(0.82rem, 1.35vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.2;
  color: var(--stat-color, var(--muted));
  padding: 12px 8px;
  text-align: center;
}
.nh-row-hdr {
  font-size: clamp(0.82rem, 1.35vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.2;
  color: var(--stat-color, var(--muted));
  padding: 12px 10px;
  text-align: right;
  justify-content: flex-end;
}
.nh-row-hdr span {
  white-space: nowrap;
}

/* ── Diagonal (no-nature cells) ────────────────────────────────── */
.nh-diag {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  pointer-events: none;
}

/* ── Nature data cells ──────────────────────────────────────────── */
.nh-nature-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 92px;
  padding: 10px 8px;
  cursor: pointer;
  background: rgba(8,14,30,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: rgba(255,255,255,0.07);
  transition: border-color 0.16s, box-shadow 0.16s, transform 0.13s;
}
.nh-cell-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.14s ease;
}
.nh-nature-cell.hl-dim-content .nh-cell-body {
  opacity: 0.12;
}
/* Tên nature: cỡ nền lớn hơn; hover / active = glow + scale (dễ đọc, thu hút mắt) */
.nh-nat-name {
  font-size: clamp(0.85rem, 1.35vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  color: rgba(255, 255, 255, 0.93);
  line-height: 1.25;
  transform-origin: center center;
  transition:
    transform 0.22s ease,
    color 0.22s ease,
    text-shadow 0.22s ease,
    letter-spacing 0.22s ease,
    filter 0.22s ease;
}

.nh-nature-cell:hover .nh-nat-name,
.nh-nature-cell.hl-active .nh-nat-name {
  transform: scale(1.1);
  color: #fff;
  letter-spacing: 0.07em;
  font-weight: 700;
  text-shadow:
    0 0 14px color-mix(in srgb, var(--inc-color) 65%, transparent),
    0 0 26px color-mix(in srgb, var(--dec-color) 40%, transparent),
    0 0 40px color-mix(in srgb, var(--inc-color) 22%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.45);
  filter: brightness(1.06);
}

.nh-nature-cell.search-match .nh-nat-name {
  font-weight: 700;
  color: #fff;
  text-shadow:
    0 0 10px rgba(120, 200, 255, 0.55),
    0 0 22px rgba(100, 180, 255, 0.25);
}
.nh-nat-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.nh-tag {
  font-size: 0.56rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.nh-tag-inc {
  color: var(--inc-color);
  background: color-mix(in srgb, var(--inc-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--inc-color) 35%, transparent);
}
.nh-tag-dec {
  color: var(--dec-color);
  background: color-mix(in srgb, var(--dec-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--dec-color) 35%, transparent);
}

/* ── Hover: active cell = viền/glow theo increased_stat ─────────── */
.nh-nature-cell.hl-active {
  border-color: var(--inc-color) !important;
  box-shadow:
    0 0 12px var(--inc-color),
    0 0 24px color-mix(in srgb, var(--inc-color) 40%, transparent) !important;
  transform: scale(1.02);
  z-index: 5;
}
.nh-nature-cell.hl-active .nh-cell-body {
  opacity: 1;
}

/* Diagonal cells in highlighted row/column — mờ đồng bộ Neural Search */
.nh-diag.hl-dim-diag {
  opacity: 0.12;
}

/* ── Search states ──────────────────────────────────────────────── */
.nh-nature-cell.search-dim,
.nh-neutral-badge.search-dim {
  opacity: 0.12;
  pointer-events: none;
}
.nh-nature-cell.search-match {
  border-color: rgba(100,200,255,0.7) !important;
  box-shadow: 0 0 14px rgba(100,200,255,0.4);
  opacity: 1 !important;
}
.nh-nature-cell.search-match .nh-cell-body {
  opacity: 1 !important;
}

.nh-neutral-badge.search-match {
  border-color: rgba(100,200,255,0.7) !important;
  box-shadow: 0 0 10px rgba(100,200,255,0.35);
}

/* ── Neutral strip ──────────────────────────────────────────────── */
.nh-neutral-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.nh-neutral-heading {
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  flex-shrink: 0;
}
.nh-neutral-list { display: flex; flex-wrap: wrap; gap: 6px; }
.nh-neutral-badge {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.13);
  color: var(--muted);
  letter-spacing: 0.04em;
  transition: border-color 0.18s, color 0.18s, box-shadow 0.18s;
  cursor: default;
}
.nh-neutral-badge:hover {
  border-color: rgba(255,255,255,0.32);
  color: var(--text);
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.nh-sidebar { display: flex; flex-direction: column; gap: 14px; }

.nh-panel {
  background: rgba(8,14,30,0.58);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  padding: 18px;
}
.nh-panel-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
  margin: 0 0 13px;
  text-transform: uppercase;
}
.nh-brief-text {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 14px;
}
.nh-brief-text strong { color: var(--text); }

/* Stat legend */
.nh-legend { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.nh-legend-row { display: flex; align-items: center; gap: 8px; }
.nh-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.nh-legend-name { font-size: 0.8rem; color: var(--muted); }

/* Modifier badges */
.nh-modifiers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.nh-mod-row { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--muted); }
.nh-mod-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  letter-spacing: 0.05em;
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
}
.mod-plus {
  background: color-mix(in srgb, var(--nat-spe) 14%, transparent);
  color: var(--nat-spe);
  border: 1px solid color-mix(in srgb, var(--nat-spe) 32%, transparent);
}
.mod-minus {
  background: color-mix(in srgb, var(--nat-atk) 14%, transparent);
  color: var(--nat-atk);
  border: 1px solid color-mix(in srgb, var(--nat-atk) 32%, transparent);
}
.mod-neutral { background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .nh-layout { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  /* Column stack: space-between would push the search bar down if the header stretches */
  .nh-header {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
  }
  .nh-header-intro {
    flex: 0 1 auto;
    width: 100%;
    max-width: 100%;
  }
  .nh-search { width: 100%; }
  .nh-search-wrap { width: 100%; }
}

/* Mobile portrait: compact matrix + reliable horizontal pan inside strip */
@media (max-width: 640px) {
  .nh-page {
    padding-top: 20px;
  }
  .nh-title {
    font-size: clamp(1.25rem, 6vw, 1.65rem);
    word-break: break-word;
  }
  .nh-subtitle {
    font-size: 0.76rem;
    line-height: 1.45;
    max-width: 100%;
  }
  .nh-matrix {
    grid-template-columns: 88px repeat(5, minmax(72px, 1fr));
    gap: 4px;
    min-width: 488px;
  }
  .nh-col-hdr {
    font-size: 0.72rem;
    padding: 8px 4px;
    letter-spacing: 0.035em;
  }
  .nh-row-hdr {
    font-size: 0.72rem;
    padding: 8px 6px;
    letter-spacing: 0.035em;
  }
  .nh-nature-cell {
    min-height: 76px;
    padding: 7px 5px;
  }
  .nh-nat-name {
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .nh-tag {
    font-size: 0.52rem;
    padding: 2px 4px;
  }
  .nh-cell-body {
    gap: 4px;
  }
  .nh-corner-label {
    font-size: 0.58rem;
  }
}
