/* Structural + component styles for oaken.tools.
   Colors/typography come from the theme file (theme-*.css) via CSS variables.
   Design language follows Oaken Tower's UI: beveled wooden frames, dark item
   slots, near-square panels, pill buttons, serif type. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(176, 140, 80, 0.10), transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(120, 80, 40, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--header-border, var(--border));
  box-shadow: 0 1px 3px rgba(20, 12, 4, 0.35);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--header-text, var(--text));
  flex-shrink: 0;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 0;
  flex-shrink: 0;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.01em;
}
.brand-text .accent { color: var(--header-accent, var(--accent)); }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin-left: auto;
}

#search {
  width: 100%;
  padding: 9px 74px 9px 12px;
  border-radius: 0;
  border: 1px solid var(--frame-outer);
  box-shadow: inset 0 0 0 1px var(--frame-inner), inset 0 1px 2px rgba(60, 40, 18, 0.08);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-ui);
  outline: none;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--text-faint); }

.shortcut {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1px 6px;
  pointer-events: none;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px 10px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--header-text-dim, var(--text-dim));
  padding: 6px 16px;
  border-radius: 0;
  font-size: 15px;
  font-family: var(--font-ui);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.tab:hover { color: var(--header-text, var(--text)); }
.tab.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.tab .hotkey {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tabs .tab:focus { outline: none; }
.tabs .tab:focus-visible,
.tabs .tab.nav-arrow-focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-label {
  flex-shrink: 0;
  width: 56px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--border);
  background: var(--chip-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  color: var(--text-dim);
  padding: 3px 13px;
  border-radius: 0;
  font-size: 14px;
  font-family: var(--font-ui);
  cursor: pointer;
  text-transform: capitalize;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--text-faint); }
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.count { color: var(--text-dim); font-size: 14px; }

.rarity-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
}

.rarity-filter select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  padding: 5px 8px;
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}
.grid.is-table { display: block; }

/* Table view */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--frame-inner);
}
.view-toggle button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 14px;
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
}
.view-toggle button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--frame-inner), var(--frame-shadow);
  background: var(--bg-card);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

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

.table-wrap th {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-soft);
  position: sticky;
  top: 0;
}

.table-wrap th.sortable {
  cursor: pointer;
  user-select: none;
}
.table-wrap th.sortable:hover { color: var(--text-dim); }
.table-wrap th.sorted { color: var(--accent); }
.table-wrap th.sorted::after { content: " \25B2"; font-size: 0.7em; }
.table-wrap th.sorted.desc::after { content: " \25BC"; }

.table-wrap .cell-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
}
.table-wrap .cell-item img {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  object-fit: contain;
}
.table-wrap .cell-item > span {
  line-height: 1;
}
.table-wrap .cell-ability {
  white-space: normal;
  min-width: 240px;
  color: var(--text-dim);
}
.table-wrap td .rarity-label { font-size: 14px; }
.table-wrap .stat-icon { width: 18px; height: 18px; }
.table-wrap .status-effects { gap: 12px; }
.table-wrap tr:hover td { background: var(--bg-hover); }

/* Card = parchment panel with a beveled wooden frame (dark outline + light inner edge). */
.card {
  background: var(--bg-card);
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--frame-inner), var(--frame-shadow);
  padding: 12px;
  display: flex;
  gap: 13px;
}

/* Item icon slot = dark beveled square, echoing the game's spr_box slot. */
.card-icon {
  width: 62px;
  height: 62px;
  flex-shrink: 0;
  border-radius: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-outer);
  box-shadow: inset 0 0 0 1px var(--slot-inner), inset 0 0 6px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-icon img { width: 100%; height: 100%; object-fit: contain; }
.card-icon .noimg { color: #b7a17f; font-size: 11px; font-style: italic; }

.card-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.card-stats {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  justify-items: start;
  align-items: center;
  gap: 4px 6px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  min-width: 72px;
}
/* Each .stat dissolves into the grid so every icon forms a left column and
   every value a left-aligned second column. */
.card-stats .stat { display: contents; }
.card-stats .stat-value { white-space: nowrap; }

.stat-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  vertical-align: -2px;
  margin-right: 3px;
}

/* All stat glyphs are stacked under the item's main icon. */
.card-stats .stat-icon {
  width: 21px;
  height: 21px;
  margin: 0;
}

.status-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.status {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}
.status .stat-icon { width: 15px; height: 15px; margin-right: 2px; }
.status-crit { color: #b8730a; }
.status-burn { color: #c0530a; }
.status-poison { color: #2f7d5a; }
.status-bleed { color: #b03030; }
.status-shock { color: #b8860b; }
.status-block { color: #2f6fb0; }
.status-healing { color: #2f8f4a; }
.status-multicast { color: #8a3fc0; }
.status-lifesteal { color: #b03030; }
.status-charges { color: #6b7280; }
.status-slow { color: #4a6b8a; }
.status-haste { color: #2f7d7d; }

.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  margin: 0;
  line-height: 1.2;
}

/* Rarity as a colored word to the right of the item name. */
.rarity-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
  flex-shrink: 0;
  font-family: var(--font-ui);
}
.rarity-label.common { color: var(--rarity-common); }
.rarity-label.rare { color: var(--rarity-rare); }
.rarity-label.epic { color: var(--rarity-epic); }
.rarity-label.legendary { color: var(--rarity-legendary); }
.rarity-label.cursed { color: var(--rarity-cursed); }
.rarity-label.forged { color: var(--rarity-forged); }
.rarity-label.special { color: var(--rarity-special); }

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 12px;
  text-transform: capitalize;
  padding: 0 8px;
  border-radius: 0;
  color: var(--text-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.tag.family { color: var(--tag-family); font-weight: 600; }
.tag.kind { color: var(--tag-kind); }

.tiers { display: flex; flex-direction: column; gap: 7px; }

/* Star-tier picker: the in-game badges; click one to switch tier. */
.tier-picker { display: flex; gap: 3px; flex-wrap: wrap; }

.tier-star {
  width: 46px;
  height: 25px;
  border: 1px solid transparent;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  padding: 0;
  border-radius: 0;
  cursor: pointer;
  opacity: 0.5;
}
.tier-star[data-star="0"] { background-image: url("assets/spr_0star.webp"); }
.tier-star[data-star="1"] { background-image: url("assets/spr_1star.webp"); }
.tier-star[data-star="2"] { background-image: url("assets/spr_2star.webp"); }
.tier-star[data-star="3"] { background-image: url("assets/spr_3star.webp"); }
.tier-star:hover { opacity: 0.8; }
.tier-star.is-active {
  opacity: 1;
  border-color: var(--tier-frame, #46321c);
  background-color: var(--bg-soft);
}

/* Selected tier's effect, framed in brown like the game's wooden frames. */
.tier-effect {
  border: 1px solid var(--tier-frame, #46321c);
  box-shadow: inset 0 0 0 1px var(--frame-inner);
  background: var(--bg-soft);
  padding: 6px 9px;
  font-size: 15px;
  color: var(--text-dim);
}
.tier-effect.is-empty .tier-text { color: var(--text-faint); font-style: italic; }

.tier { font-size: 15px; color: var(--text-dim); }

/* Tier-diff highlight: words that changed vs the previous star. */
.tiers mark.delta {
  background: var(--delta-bg);
  color: var(--delta-text);
  font-weight: 600;
  border-radius: 0;
  padding: 0 2px;
}

.toolbar-left { display: flex; align-items: center; gap: 12px; }
.legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-faint);
  font-size: 13px;
}
.legend mark.delta { font-size: 12px; }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
}

.site-footer {
  border-top: 1px solid var(--frame-outer);
  padding: 20px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.site-footer > p { margin: 5px 0; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.footer-links a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.footer-links-sep { color: var(--text-faint); }

.footer-version {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Content pages (credits) */
.back-link {
  margin-left: auto;
  color: var(--header-text-dim, var(--text-dim));
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover { color: var(--header-accent, var(--accent)); }

.prose {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px;
  line-height: 1.65;
}
.prose h1 {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0 0 12px;
}
.prose h2 {
  font-family: var(--font-display);
  font-size: 21px;
  margin: 26px 0 8px;
  color: var(--accent);
}
.prose p { margin: 10px 0; }
.prose ul { margin: 10px 0; padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose a { color: var(--accent); }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0 4px;
}
.footer-version-line { color: var(--text-faint); }

.site-footer kbd {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg-soft);
  font-size: 0.85em;
}

/* ------------------------------------------------------------------ */
/* Encounters and perks                                                */
/* ------------------------------------------------------------------ */

.encounter-card {
  background: var(--bg-card);
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--frame-inner), var(--frame-shadow);
  padding: 12px;
  display: flex;
  gap: 13px;
}

.portrait {
  width: 62px;
  height: 92px;
  flex-shrink: 0;
  border-radius: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-outer);
  box-shadow: inset 0 0 0 1px var(--slot-inner), inset 0 0 6px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .noimg { color: #b7a17f; font-size: 11px; font-style: italic; }

.encounter-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }

.encounter-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.day-badge,
.seasonal-badge {
  font-size: 12px;
  padding: 0 8px;
  border-radius: 0;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--bg-soft);
  flex-shrink: 0;
  font-weight: 600;
}
.seasonal-badge { color: var(--rarity-special); border-color: var(--badge-special-border); background: var(--badge-special-bg); }

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

.option { display: flex; flex-direction: column; gap: 1px; }
.option-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
.option-text { font-size: 14px; color: var(--text-dim); }
.option-tip { font-size: 12px; color: var(--text-faint); font-style: italic; }

.perk-card {
  background: var(--bg-card);
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--frame-inner), var(--frame-shadow);
  padding: 12px;
  display: flex;
  gap: 13px;
}

.perk-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-outer);
  box-shadow: inset 0 0 0 1px var(--slot-inner);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.perk-icon img { width: 100%; height: 100%; object-fit: contain; }
.perk-icon .noimg { color: #b7a17f; font-size: 11px; }

.perk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.perk-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.perk-text { font-size: 14px; color: var(--text-dim); }
.perk-unlock { font-size: 13px; color: var(--text-faint); font-style: italic; }
.perk-unlock::before { content: "Unlock: "; font-style: normal; }

/* ------------------------------------------------------------------ */
/* Command palette (Ctrl+K)                                            */
/* ------------------------------------------------------------------ */

.cmd-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: var(--overlay-dim);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.cmd-overlay[hidden] { display: none; }
@media (max-width: 700px) {
  .cmd-overlay { padding-top: 40px; }
  .cmd-results { max-height: calc(100dvh - 100px); }
}

.cmd-dialog {
  background: var(--bg-card);
  border: 1px solid var(--frame-outer);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--frame-inner), 0 10px 40px rgba(60, 40, 18, 0.35);
  width: min(90vw, 560px);
  overflow: hidden;
}

.cmd-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.1rem;
  color: var(--text);
  font-size: 17px;
  font-family: var(--font-ui);
  outline: none;
}
.cmd-input::placeholder { color: var(--text-faint); }

.cmd-results {
  max-height: 440px;
  overflow-y: auto;
  scrollbar-color: var(--text-faint) transparent;
}

.cmd-section-header {
  padding: 0.4rem 1.1rem 0.15rem;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--border);
}
.cmd-section-header:first-child { border-top: 0; }
.cmd-section-count { opacity: 0.7; margin-left: 0.15em; }

.cmd-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 1.1rem;
  cursor: pointer;
}
.cmd-row:hover { background: var(--bg-hover); }
.cmd-row.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.cmd-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: var(--slot-bg);
  border: 1px solid var(--slot-outer);
  box-shadow: inset 0 0 0 1px var(--slot-inner);
  color: #b7a17f;
}
.cmd-icon img { width: 100%; height: 100%; object-fit: contain; }

.cmd-title { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); font-weight: 600; }

.cmd-meta {
  color: var(--text-dim);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

.cmd-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
}

.cmd-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.4rem 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.cmd-footer kbd {
  display: inline-block;
  padding: 0.02rem 0.3rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 12px;
  line-height: 1.35;
  margin-right: 0.12rem;
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .grid { grid-template-columns: 1fr; }
  .filter-row { flex-direction: column; gap: 6px; }
  .filter-label { width: auto; }
  .cmd-meta { display: none; }
}
