/* Page rules for the Gem Planner. Tokens come from ../shared/theme.css; the class vocabulary mirrors
   site/hunter/optimizer.css and site/missions/missions.css. The board is one column per gem. */

.app-shell {
  max-width: 1880px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.nav-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar p,
.panel-copy,
.card-note {
  margin: 6px 0 0;
  color: var(--muted);
}

.panel-copy strong,
.card-note strong {
  color: var(--text);
  font-weight: 600;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px var(--shadow);
  padding: 16px 20px;
  min-width: 0;
}

.planner {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.planner-form {
  display: contents;
}

/* ---- toolbar: code box, orbs on hand, actions in one row ---- */

.toolbar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  gap: 18px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-label small {
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}

input[type="number"],
input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 9px 12px;
}

textarea {
  resize: vertical;
  min-height: 44px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
}

input[type="number"]:focus,
input[type="text"]:focus,
textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

input.invalid {
  border-color: var(--danger);
}

input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  margin-top: 6px;
}

.tool-code .card-note {
  font-size: 0.84rem;
}

.tool-code .card-note:empty {
  display: none;
}

.tool-actions {
  padding-top: 22px;
}

.run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* the Hide locked switch: a checkbox drawn as a flat toggle */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  cursor: pointer;
  user-select: none;
  font-size: 0.86rem;
  color: var(--muted);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
}

.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-track::after {
  left: 18px;
  background: var(--accent-contrast);
}

.switch input:checked ~ .switch-text {
  color: var(--text);
}

.switch input:focus-visible + .switch-track {
  outline: 1px solid var(--accent-light);
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  color: var(--text);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.button:hover:not(:disabled) {
  border-color: var(--accent);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  min-width: 120px;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button.secondary {
  background: var(--panel-soft);
}

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

.results-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px 20px;
  align-items: start;
}

.results-panel .notes {
  grid-column: 1 / -1;
}

.notice {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 4px;
}

.notice p:first-child {
  font-weight: 700;
  font-size: 1.05rem;
}

.notice-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.notice-ok {
  border-color: var(--success-border);
  color: var(--success);
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.totals li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.86rem;
  background: var(--panel-alt);
}

.totals li b {
  font-variant-numeric: tabular-nums;
}

.totals li.total {
  border-color: var(--accent);
  color: var(--accent-light);
}

#notes {
  grid-column: 1 / -1;
}

#notes:empty {
  display: none;
}

.result-card ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.result-card li {
  margin: 2px 0;
}

/* ---- what to buy ---- */

.results-detail h2 {
  margin-bottom: 12px;
}

.items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.items h3 {
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

.plan-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.plan-table th,
.plan-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 0.9rem;
}

.plan-table thead th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plan-table tbody tr:last-child td {
  border-bottom: none;
}

.plan-table tbody td {
  background: var(--panel-alt);
}

.plan-table td.note {
  white-space: normal;
  color: var(--muted);
  font-size: 0.82rem;
}

.plan-table tr.blocked td {
  color: var(--warn-text);
}

.plan-table tr.subtotal td {
  font-weight: 700;
  color: var(--accent-light);
}

.plan-table td.orbs {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- the board: one column per gem ---- */

.board-help {
  margin: 0;
  font-size: 0.86rem;
}

.fine-print {
  margin-top: 12px;
  font-size: 0.8rem;
}

.gem-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.gem-card {
  --gem: var(--muted);
  container-type: inline-size;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gem);
  border-radius: 12px;
  padding: 10px;
  min-width: 0;
}

/* gem colours as cifi-tools shows them (its gem page matches the game); --gem-ink is the text
   colour that reads on each. Evolution's game colour (#0a3814) is too dark for this theme, so it
   gets the same green hue, lighter. */
.gem-card { --gem-ink: #fff; }
.gem-card.exodus, .gem-swatch.exodus { --gem: #8b5cf6; }
.gem-card.temporal, .gem-swatch.temporal { --gem: #dc2626; }
.gem-card.innovation, .gem-swatch.innovation { --gem: #ffa600; --gem-ink: #14142a; }
.gem-card.power, .gem-swatch.power { --gem: #8b5cf6; }
.gem-card.attraction, .gem-swatch.attraction { --gem: #3b82f6; }
.gem-card.creation, .gem-swatch.creation { --gem: #f97316; --gem-ink: #14142a; }
.gem-card.evolution, .gem-swatch.evolution { --gem: #16a34a; }

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gem-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--gem, var(--muted));
  flex: 0 0 auto;
}

.badge {
  font-size: 0.68rem;
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.quality-badge {
  background: var(--gem);
  border-color: var(--gem);
  color: var(--gem-ink);
  font-weight: 700;
  font-size: 0.74rem;
  padding: 2px 9px;
}

/* affordability underline: the fill is orbs on hand / cost of the next level, green once covered.
   The padding gives the 3px line a hover target for its tooltip. */
.afford {
  display: block;
  height: 3px;
  padding: 4px 0 3px;
  box-sizing: content-box;
  background: var(--border);
  background-clip: content-box;
  border-radius: 2px;
}

.afford .fill {
  display: block;
  height: 3px;
  width: 0;
  border-radius: 2px;
  background: var(--danger);
}

.afford.ok .fill {
  background: var(--success);
}

.afford.off {
  background-color: transparent;
}

.card-total {
  margin: 6px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-light);
}

.card-total:empty {
  display: none;
}

/* steppers: label, minus, value, plus */

.stepper {
  display: grid;
  grid-template-columns: 32px 24px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 2px;
}

.lbl {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.step {
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.step:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper input[type="number"] {
  height: 26px;
  padding: 0 4px;
  text-align: center;
  border-radius: 6px;
  font-size: 0.86rem;
  -moz-appearance: textfield;
  appearance: textfield;
}

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

.quality {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}

/* nodes: two rows of six toggles, filled in the gem's colour when on */

.nodes {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.node-row {
  display: grid;
  grid-template-columns: 32px repeat(6, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}

.node {
  position: relative;
  display: block;
}

.node input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.pill {
  position: relative; /* the now pill's affordability fill sits along its bottom edge */
  overflow: hidden;
  display: block;
  height: 24px;
  line-height: 22px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.74rem;
  cursor: pointer;
  user-select: none;
}

.pill:hover {
  border-color: var(--gem);
}

.node input:checked + .pill {
  background: var(--gem);
  border-color: var(--gem);
  color: var(--gem-ink);
  font-weight: 700;
}

.node input:focus-visible + .pill {
  outline: 1px solid var(--accent);
}

.node .fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: var(--danger);
}

.node.ok .fill {
  background: var(--success);
}

.node.blocked .pill {
  border-style: dashed;
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.node.blocked input:checked + .pill {
  background: var(--warn-bg);
}

/* upgrade tiles */

.tiles {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.tile {
  border: 1px solid var(--border);
  border-left: 3px solid var(--gem);
  border-radius: 8px;
  padding: 6px 8px 7px;
  background: var(--panel);
  min-width: 0;
}

.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.tile-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile .steppers {
  display: grid;
  gap: 3px;
  margin-top: 5px;
}

.tile.blocked {
  border-left-color: var(--warn-border);
}

.tile.unavailable {
  opacity: 0.55;
}

.nodes .note,
.tile .note {
  margin: 3px 0 0;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--muted);
}

.nodes .note:empty,
.tile .note:empty {
  display: none;
}

.nodes .note:not(:empty),
.tile.blocked .note {
  color: var(--warn-text);
}

.warn {
  color: var(--warn-text);
}

/* a wide column fits the two steppers side by side */
@container (min-width: 236px) {
  .tile .steppers {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}

/* ---- narrow screens ---- */

@media (max-width: 1000px) {
  .toolbar-grid {
    grid-template-columns: minmax(0, 1fr) 220px;
  }

  .tool-actions {
    grid-column: 1 / -1;
    padding-top: 0;
  }

  .results-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .panel {
    padding: 14px;
  }

  .toolbar-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .run-actions .button {
    flex: 1 1 auto;
  }

  .gem-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .items {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-table th,
  .plan-table td {
    padding: 7px 8px;
  }
}
