/**
 * shared/ui/osrs-melee-ranged-calc.css
 * ----------------------------------------------------------------------
 * Responsibility: shared design tokens and components. v3: rebuilt to
 * replicate the UI/UX specimen the user provided for the Quest
 * Calculator — same underlying colors as v1/v2 (the hex values are
 * identical), extended with semantic tokens the specimen introduced
 * (--good, --bad, --muted, --line, --line-soft, --surface-hover) and its
 * component language (bordered pseudo-tabs, .panel/.panel-heading/
 * eyebrow, .status-note, .source tags, chips, progress bars, a reusable
 * modal, toast). --font-pixel keeps 'Press Start 2P' as the primary face
 * (the one hub-wide identity element established across this project)
 * with the specimen's Courier New as its own fallback before monospace.
 */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  color-scheme: dark;
  --app-bg: #1A1309;
  --panel-bg: #2A1F10;
  --surface-bg: #3D2D16;
  --surface-hover: #49371D;
  --text: #F2E6CC;
  --text-soft: #EADFC4;
  --muted: #B8A98B;
  --gold: #D4A24E;
  --gold-deep: #C9922F;
  --good: #7FBF7F;
  --bad: #D4716A;
  --line: rgba(212, 162, 78, .72);
  --line-soft: rgba(212, 162, 78, .22);
  --border: 2px solid var(--gold-deep);
  --radius: 8px;
  --space: 8px;
  --font-body: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-pixel: 'Press Start 2P', 'Courier New', Courier, monospace;
  --shadow: 0 16px 42px rgba(0, 0, 0, .42);
  --shadow-glow: 0 0 0 3px rgba(212, 162, 78, 0.25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--app-bg); scroll-behavior: smooth; }
body {
  margin: 0; background: radial-gradient(ellipse at top, #241A0C 0%, var(--app-bg) 60%);
  color: var(--text); font: 15px/1.55 var(--font-body);
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, .chip:focus-visible, .choice:focus-within {
  outline: 2px solid var(--text); outline-offset: 2px;
}

h1, h2, h3, .pixel { font-family: var(--font-pixel); font-weight: 700; letter-spacing: .02em; }
h1 { margin: 0; font-size: clamp(14px, 2vw, 18px); line-height: 1.6; }
h2 { margin: 0; font-size: 12px; line-height: 1.8; color: var(--text); }
h3 { margin: 18px 0 8px; font-size: 10px; line-height: 1.7; color: var(--gold); }
h3:first-child { margin-top: 0; }
p { margin: 8px 0; }

#app { width: min(100% - 28px, 1024px); margin: 0 auto; padding: 12px 0 64px; animation: app-in 0.45s ease-out; }
@keyframes app-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Header ===== */
header.topbar { display: grid; gap: 14px; padding: 20px 8px 12px; text-align: center; }
.brand-mark { color: var(--gold); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
header.topbar p { color: var(--muted); font-size: 12px; margin: 0; }
header.topbar a { color: var(--muted); font-size: 12px; text-decoration: none; }
header.topbar a:hover { color: var(--gold); }

/* ===== Tabs — bordered pseudo-folder tabs ===== */
.tabs-nav { display: flex; gap: 8px; border-bottom: 2px solid var(--gold-deep); position: sticky; top: 0; background: var(--app-bg); z-index: 5; overflow-x: auto; }
.tabs-nav .tab {
  flex: 1; min-width: fit-content; padding: 11px 12px 12px; border: 2px solid var(--gold-deep); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; background: var(--panel-bg); color: var(--text-soft);
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: background .16s ease, color .16s ease;
}
.tabs-nav .tab:hover { background: var(--surface-bg); }
.tabs-nav .tab.active { background: var(--gold-deep); color: var(--app-bg); }

.tab-panel[hidden] { display: none; }
.tab-panel.panel-enter { animation: panel-in 0.18s ease-out; }
@keyframes panel-in { from { opacity: .55; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Panels (grouped sections) ===== */
.panel, .section-card { margin: 0 0 16px; padding: 16px; background: var(--panel-bg); border: var(--border); border-radius: var(--radius); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.eyebrow { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

/* ===== Fields ===== */
.field-label { display: block; margin: 10px 0 5px; color: var(--text-soft); font-size: 12px; font-weight: 650; }
.field-label:first-child { margin-top: 0; }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row > .field, .field-row > .searchable-select { flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: calc(var(--space) * 1.5); }
.field label { font-size: 0.8rem; color: var(--text-soft); }
.field input[type="number"],
.field input[type="text"],
.field select,
.searchable-select input {
  width: 100%; min-width: 0; padding: 9px 10px; color: var(--text); background: var(--surface-bg);
  border: var(--border); border-radius: var(--radius); transition: box-shadow 0.15s, border-color 0.15s, background .15s;
}
.field input::placeholder, .searchable-select input::placeholder { color: #B7A687; opacity: .8; }
.field input[type="number"]:hover,
.field input[type="text"]:hover,
.field select:hover,
.searchable-select input:hover { border-color: var(--gold); background: var(--surface-hover); }
.field input[type="number"]:focus,
.field input[type="text"]:focus,
.field select:focus,
.searchable-select input:focus { outline: none; border-color: var(--gold); box-shadow: var(--shadow-glow); }
.field select { cursor: pointer; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px;
  padding: 8px 14px; border: 0; border-radius: var(--radius); background: var(--gold); color: var(--app-bg);
  font-family: var(--font-body); font-size: 13px; font-weight: 800; cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}
.btn:hover, .btn-primary:hover { background: var(--gold-deep); }
.btn:active { transform: translateY(1px); }
.btn.secondary, .btn:not(.btn-primary):not(.btn.secondary) { background: var(--surface-bg); color: var(--text); border: var(--border); }
.btn.secondary:hover { background: var(--surface-hover); }
.btn-primary { background: var(--gold); color: var(--app-bg); }
.btn.small { min-height: 29px; padding: 4px 9px; font-size: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===== Status / meta / source tags ===== */
.status-note, .status-message { min-height: 18px; color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-note.success, .status-message.success { color: var(--good); }
.status-note.error, .status-message.error { color: var(--bad); }
.meta-line { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 0; color: var(--text-soft); font-size: 12px; }
.source { margin-left: 5px; font-size: 10px; white-space: nowrap; }
.source.auto { color: var(--good); }
.source.manual { color: var(--gold); }

/* ===== Searchable select / multiselect ===== */
.searchable-select { position: relative; width: 100%; }
.searchable-select .options {
  position: absolute; z-index: 10; top: calc(100% + 3px); left: 0; right: 0; max-height: 220px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px; background: var(--surface-bg); border: var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.searchable-select .option {
  display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 4px;
  cursor: pointer; font-size: 0.85rem; color: var(--text); transition: background 0.1s; border-bottom: 1px solid var(--line-soft);
}
.searchable-select .option:last-child { border-bottom: 0; }
.searchable-select .option:hover { background: var(--panel-bg); color: var(--gold); }
.searchable-select .option.selected { color: var(--gold); font-weight: 600; }
.searchable-select .option .tag { color: var(--gold); font-size: 10px; white-space: nowrap; flex: 0 0 auto; }

.searchable-multiselect .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  display: inline-flex; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-bg); color: var(--text-soft); font-size: 11px; font-weight: 700; cursor: pointer;
  user-select: none; transition: background .14s ease;
}
.chip:hover { background: var(--surface-hover); }
.chip.selected { background: var(--gold-deep); color: var(--app-bg); border-color: var(--gold); }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-remove { background: none; border: none; color: inherit; font-size: 0.9rem; line-height: 1; cursor: pointer; margin-left: 6px; padding: 0; opacity: .75; }
.chip-remove:hover { opacity: 1; }

/* ===== Results / cards ===== */
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space); }
.result-card { background: var(--surface-bg); border: var(--border); border-radius: var(--radius); padding: calc(var(--space) * 1.5); transition: border-color .2s; }
.result-card:hover { border-color: var(--gold); }
.result-card h3 { margin: 0 0 4px; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.result-card .value { margin: 0; font-size: 1.1rem; color: var(--gold); }

.combo-card .result-card { animation: glow-pulse 2.4s ease-in-out infinite; }
@keyframes glow-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(212, 162, 78, 0); } 50% { box-shadow: 0 0 16px rgba(212, 162, 78, 0.35); } }

.combo-notice { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--gold-deep); border-radius: var(--radius); background: rgba(212, 162, 78, .1); font-size: 12px; }
.combo-notice.good { border-color: var(--good); background: rgba(127, 191, 127, .1); }

/* ===== Progress bar ===== */
.progress-wrap { height: 14px; margin: 8px 0 4px; overflow: hidden; border: 2px solid var(--gold-deep); border-radius: 99px; background: var(--surface-bg); }
.progress-bar { height: 100%; width: 0; background: var(--gold); transition: width .25s ease; }
.progress-caption { color: var(--muted); font-size: 10px; }

/* ===== Choice rows (radio/checkbox) ===== */
.choice { display: block; margin-bottom: 4px; font-size: 0.85rem; cursor: pointer; }
.choice input { margin-right: 6px; accent-color: var(--gold); cursor: pointer; }

/* ===== Requirement tables ===== */
.requirements-table-wrap { overflow-x: auto; }
.requirements-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.requirements-table th, .requirements-table td { text-align: left; padding: calc(var(--space)) calc(var(--space) * 1.25); border-bottom: 1px solid var(--line-soft); }
.requirements-table th { color: var(--gold); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.requirements-table tbody tr { cursor: pointer; transition: background 0.1s, opacity .15s; }
.requirements-table tbody tr:hover { background: rgba(212, 162, 78, 0.08); }
.requirements-table tbody tr.locked-row { opacity: .62; }
.requirements-table tbody tr.recommended-row { box-shadow: inset 3px 0 0 var(--good); }
.requirements-table td .choice { cursor: pointer; }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.02em; }
.badge-unlocked { background: var(--good); color: var(--app-bg); }
.badge-locked { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

/* ===== Modal ===== */
.overlay { position: fixed; z-index: 30; inset: 0; display: none; align-items: center; justify-content: center; padding: 14px; background: rgba(0, 0, 0, .68); }
.overlay.open { display: flex; }
.modal { width: min(560px, 100%); max-height: 86dvh; overflow: auto; padding: 17px; border: var(--border); border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-meta { margin: 5px 0 12px; color: var(--muted); font-size: 11px; }
.modal-section { margin-top: 13px; }
.modal-section h3 { margin-top: 0; }
.modal-list { margin: 0; padding-left: 18px; color: var(--text-soft); font-size: 12px; }
.modal-list li { margin-bottom: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 20px; transform: translate(-50%, 20px); max-width: calc(100vw - 30px);
  padding: 9px 13px; border: 1px solid var(--gold-deep); border-radius: var(--radius); background: var(--surface-bg);
  color: var(--text); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { text-align: center; color: var(--muted); font-size: 10px; margin: 24px 2px 0; }

@media (max-width: 680px) {
  #app { width: min(100% - 20px, 1024px); }
  .tabs-nav .tab { padding: 10px 5px; font-size: 11px; }
  .panel, .section-card { padding: 12px; }
}
@media (max-width: 390px) {
  .field-row { align-items: stretch; flex-direction: column; }
  .field-row .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
