/* ==========================================================================
   Wildsforge skill calculators (cooking XP, fishing XP, ...): layout, form
   controls, result tiles, comparison table and the phone summary bar.
   Needs /assets/site.css loaded first for tokens, header, footer and buttons.
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.calc-intro { max-width: 760px; margin: 10px 0 18px; }
.calc-intro h1 { font-size: clamp(26px, 4.2vw, 36px); }
.calc-intro p { margin: 10px 0 0; color: var(--muted); }

.calc { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.calc__results { display: grid; gap: 14px; }
.calc__setup { position: sticky; top: 12px; }
.calc h2 { margin-bottom: 8px; font-size: 17px; }
.calc__subhead { margin: 16px 0 6px; font-size: 15px; }

.card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* Form controls */
.field { margin: 0 0 12px; padding: 0; border: 0; }
.field label, .field legend, .sub-label { display: block; margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.sub-label { margin-top: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 400; }
.field label .hint, .check .hint { margin: 0; }

input[type="number"], select {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.check { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 34px; color: var(--text) !important; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Headline numbers */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 0; }
.stat { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.stat dt { color: var(--muted); font-size: 13px; }
.stat dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat--main { background: var(--logo-bg); }
.stat--main dd { color: var(--accent); }

.calc__warning { margin: 12px 0 0; padding: 10px 12px; border-left: 4px solid var(--spark); border-radius: 8px; background: var(--surface-2); }

.needs { margin: 0; padding-left: 20px; }
.needs li { margin-bottom: 4px; }

/* Comparison table */
.table-scroll { margin-top: 8px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
thead th { background: var(--surface-2); font-size: 13px; }
tbody tr:last-child > * { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.is-selected { background: var(--logo-bg); }
.locked { color: var(--warn); font-size: 13px; }

.milestones { margin: 0; padding-left: 0; list-style: none; }
.milestones li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.milestones li:last-child { border-bottom: 0; }
.milestones b { color: var(--accent); }
.milestones span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.calc__notes { margin-top: 14px; color: var(--muted); }
.calc__notes ul { margin: 0; padding-left: 20px; }

/* Phone-only result bar, so the answer stays visible while changing inputs */
.summary-bar { display: none; }

.is-flashing { animation: flash 0.7s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 28%, transparent); } }

/* Phones: setup first but compact, results right after; table rows become cards */
@media (max-width: 820px) {
  :root { --donate-offset: 88px; --consent-offset: 84px; }
  .page-footer__inner { padding-bottom: 150px; }

  .summary-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -6px 20px rgb(0 0 0 / 0.12);
    animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .summary-bar__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  .summary-bar__main { overflow: hidden; color: var(--accent); font-size: 17px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
  .summary-bar__sub { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
  .summary-bar .button { flex: none; min-height: 44px; padding: 8px 14px; }
  .calc { grid-template-columns: 1fr; }
  .calc__setup { position: static; }
  .stat dd { font-size: 20px; }
  input[type="number"], select { font-size: 16px; min-height: 44px; } /* 16px stops iOS zooming */

  #compare .table-scroll, #compare { border: 0; overflow: visible; }
  #compare thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #compare table, #compare tbody, #compare tr, #compare td, #compare tbody th { display: block; }
  #compare tr { margin-bottom: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
  #compare td, #compare tbody th { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; text-align: right; }
  #compare td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  #compare tbody th { display: block; padding: 6px 0 8px; font-size: 15px; text-align: left; }
}
