/* prot — markra-grade restraint: no borders, no rules, paper-blue ground. */

@font-face {
  font-family: 'Minecraft AE';
  src: url('../assets/fonts/minecraft-ae.woff2') format('woff2'),
       url('../assets/fonts/minecraft-ae.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ground: #d4e0ec;
  --ink: #101418;
  --ink-soft: #4a5560;
  --wash: rgba(255, 255, 255, 0.45);
  --wash-strong: rgba(255, 255, 255, 0.78);
  --control-col: 240px;
  --stat-col: 186px;
}

* { box-sizing: border-box; }

img { image-rendering: pixelated; image-rendering: crisp-edges; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'Minecraft AE', 'Courier New', monospace;
  font-size: 16px;
  line-height: 1.55;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: start;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 0;
}

/* ---------- slot rows ---------- */

.controls { display: grid; gap: 40px; }

.slot-row {
  position: relative;
  display: grid;
  grid-template-columns: 56px var(--control-col) 64px;
  align-items: center;
  gap: 28px;
}

.slot-trigger {
  width: 56px;
  height: 56px;
  display: block;
  transition: background 120ms ease;
}

.slot-trigger img { width: 56px; height: 56px; display: block; }

.slot-trigger:hover { background: var(--wash); }

.durability {
  text-align: right;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- material popover ---------- */

.material-popover {
  position: absolute;
  top: 50%;
  left: 56px;
  transform: translateY(-50%);
  max-width: calc(100% - 56px);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--wash-strong);
  opacity: 0;
  visibility: hidden;
  transition: opacity 130ms ease, visibility 130ms;
  z-index: 20;
}

.material-popover.is-open {
  opacity: 1;
  visibility: visible;
}

.mat-option { width: 44px; height: 44px; display: block; transition: background 120ms ease; }
.mat-option img { width: 44px; height: 44px; display: block; }
.mat-option:hover { background: rgba(255, 255, 255, 0.9); }

/* ---------- prot control ---------- */

.prot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.prot-label { color: var(--ink-soft); }

.prot-stepper { display: flex; align-items: center; gap: 10px; }

.prot-input {
  width: 78px;
  padding: 4px 6px;
  font: inherit;
  color: inherit;
  background: var(--wash);
  border: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.prot-input:focus { outline: 1px dashed var(--ink-soft); outline-offset: 2px; }

.prot-dec, .prot-inc {
  width: 26px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  transition: background 120ms ease, color 120ms ease;
}

.prot-dec:hover, .prot-inc:hover { background: var(--wash); color: var(--ink); }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- resistance levels ---------- */

.resistance-row {
  display: grid;
  grid-template-columns: 56px var(--control-col) 64px;
  align-items: center;
  gap: 28px;
}

.res-icon {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
}

.res-levels {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  justify-items: center;
}

.res-level {
  padding: 4px 6px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  transition: background 120ms ease, color 120ms ease;
}

.res-level:first-child { justify-self: start; }
.res-level:last-child { justify-self: end; }

.res-level:hover { background: var(--wash); }

.res-level.is-active { background: var(--ink); color: var(--ground); }

/* ---------- results ---------- */

.results {
  display: grid;
  gap: 28px;
  align-content: start;
  border-left: 2px solid var(--ink);
  padding-left: 28px;
}

.breakdown {
  margin: 0;
  display: grid;
  grid-template-columns: max-content max-content;
  column-gap: 16px;
  row-gap: 4px;
}

.breakdown .line { display: contents; }

.line-label { color: var(--ink-soft); }

.line-value { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.stat { display: flex; align-items: baseline; gap: 14px; }

.stat-value {
  font-size: 40px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: var(--stat-col);
}

.stat-label { color: var(--ink-soft); cursor: default; }

.epf-capped {
  margin: 0;
  padding: 6px 10px;
  background: var(--ink);
  color: var(--ground);
  font-size: 14px;
  justify-self: start;
}

.epf-capped[hidden] { display: none; }

.damage-row { display: grid; gap: 10px; }

.damage-label { color: var(--ink-soft); }

.damage-input {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: inherit;
  background: var(--wash);
  border: 0;
  font-variant-numeric: tabular-nums;
}

.damage-input:focus { outline: 1px dashed var(--ink-soft); outline-offset: 2px; }

.damage-out { display: flex; align-items: center; gap: 18px; }

.damage-value { font-size: 26px; font-variant-numeric: tabular-nums; }

.heart-value { font-size: 26px; font-variant-numeric: tabular-nums; }

.heart-icon { width: 20px; height: 20px; display: block; }

/* ---------- mobile bar & detail modal ---------- */

.mobile-bar { display: none; }

.detail-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms;
  z-index: 60;
}

.detail-modal.is-open { opacity: 1; visibility: visible; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 20, 24, 0.28); }

.modal-card {
  position: relative;
  min-width: 240px;
  padding: 28px 32px;
  background: var(--ground);
  display: grid;
  gap: 10px;
}

.modal-lines { display: grid; gap: 6px; }

.modal-lines .line { margin: 0; color: var(--ink-soft); }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 120ms ease;
}

.modal-close:hover { color: var(--ink); }

/* ---------- mobile ---------- */

@media (max-width: 760px) {
  :root { --control-col: 100%; }

  main {
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: none;
    padding: 28px 22px 140px;
  }

  .controls { gap: 30px; }

  .slot-row { grid-template-columns: 48px minmax(0, 1fr) 44px; gap: 12px; }

  .slot-trigger, .slot-trigger img { width: 48px; height: 48px; }

  .material-popover { left: 48px; max-width: calc(100% - 48px); }

  .resistance-row { grid-template-columns: 48px minmax(0, 1fr) 44px; gap: 12px; }

  .res-icon { width: 48px; height: 48px; }

  .prot-input { width: 70px; }

  .stat-value { font-size: 30px; min-width: 0; }

  .results { gap: 20px; border-left: 0; padding-left: 0; }

  .breakdown { display: none; }

  .results > .stat { display: none; }

  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 22px;
    background: var(--ground);
    z-index: 40;
  }

  .mobile-bar .stat {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .mobile-bar .stat-value { font-size: 26px; }

  .mobile-bar .stat-label { cursor: pointer; }

  .mobile-bar .stat:first-child { align-items: flex-start; }
  .mobile-bar .stat:last-child { align-items: flex-end; }
}