/* FATED UI kit */

/* ---------- Buttons ---------- */
.btn {
  --h: 34px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 14px; border-radius: 9px; font-weight: 500; font-size: 13px; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-fast), opacity var(--t-fast);
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ivory); color: #0A0A0B; box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 1px 2px rgba(0,0,0,.4); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-secondary { background: var(--slate); color: var(--text); box-shadow: 0 0 0 1px var(--line-2) inset, 0 1px 0 rgba(255,255,255,.04) inset; }
.btn-secondary:hover:not(:disabled) { background: var(--iron); box-shadow: 0 0 0 1px var(--line-3) inset; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(236,230,216,.06); color: var(--text); }
.btn-danger { background: rgba(242,85,90,.12); color: #FF8A8D; box-shadow: 0 0 0 1px rgba(242,85,90,.25) inset; }
.btn-danger:hover:not(:disabled) { background: rgba(242,85,90,.2); }
.btn-signal { background: var(--signal); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.25) inset; }
.btn-signal:hover:not(:disabled) { background: #FF6243; }
.btn-sm { --h: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-lg { --h: 44px; padding: 0 20px; font-size: 14px; border-radius: 11px; }
.btn-icon { width: var(--h); padding: 0; }
.btn-block { width: 100%; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 1.6px solid currentColor; border-color: rgba(10,10,11,.25); border-top-color: #0A0A0B; animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after { border-color: rgba(236,230,216,.2); border-top-color: var(--ivory); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Fields ---------- */
.field { display: grid; gap: 7px; }
.field > label, .label { font-size: 12.5px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: #FF8A8D; display: none; align-items: center; gap: 6px; }
.field.has-error .err { display: flex; animation: errIn var(--t) var(--ease-out); }
.field.has-error .input, .field.has-error .textarea { border-color: rgba(242,85,90,.55); }
@keyframes errIn { from { opacity: 0; transform: translateY(-3px); } }
.counter { font: 400 11px var(--mono); color: var(--faint); }
.counter.over { color: var(--danger); }

.input, .textarea {
  width: 100%; height: 36px; padding: 0 12px; border-radius: 9px; background: var(--obsidian); color: var(--text);
  border: 1px solid var(--line-2); transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}
.textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .textarea:focus { border-color: rgba(236,230,216,.4); box-shadow: 0 0 0 3px rgba(236,230,216,.07); background: #0C0C0E; }
.input-lg { height: 44px; font-size: 14px; border-radius: 11px; padding: 0 14px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line-2); background: var(--obsidian); border-radius: 9px; transition: border-color var(--t-fast), box-shadow var(--t-fast); overflow: hidden; }
.input-group:focus-within { border-color: rgba(236,230,216,.4); box-shadow: 0 0 0 3px rgba(236,230,216,.07); }
.input-group .prefix { display: flex; align-items: center; padding: 0 2px 0 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-group .input { border: 0; background: transparent; box-shadow: none; padding-left: 0; }
.input-group .suffix { display: flex; align-items: center; padding-right: 10px; }
.field.has-error .input-group { border-color: rgba(242,85,90,.55); }
.otp-input { letter-spacing: .5em; text-align: center; font: 500 20px var(--mono); height: 52px; }

/* Switch */
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 20px; background: var(--iron); box-shadow: 0 0 0 1px var(--line-2) inset; transition: background var(--t) var(--ease); }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform var(--t) var(--spring), background var(--t); }
.switch input:checked ~ .track { background: var(--ivory); }
.switch input:checked ~ .thumb { transform: translateX(14px); background: #0A0A0B; }
.switch input:focus-visible ~ .track { box-shadow: var(--focus); }

/* Range */
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { font: 400 12px var(--mono); color: var(--text-2); min-width: 38px; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--ivory) var(--p), var(--iron) var(--p)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--ivory) var(--p), var(--iron) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ivory); margin-top: -5px; box-shadow: 0 0 0 4px rgba(10,10,11,.9), 0 1px 3px rgba(0,0,0,.6); transition: transform var(--t-fast) var(--ease); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ivory); border: 0; box-shadow: 0 0 0 4px rgba(10,10,11,.9); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type=range]:focus-visible { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--obsidian); border: 1px solid var(--line-2); border-radius: 10px; position: relative; flex-wrap: wrap; }
.seg button { position: relative; z-index: 1; height: 28px; padding: 0 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; transition: color var(--t-fast), background var(--t-fast); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed=true] { color: var(--text); background: var(--iron); box-shadow: 0 0 0 1px var(--line-2) inset, 0 1px 2px rgba(0,0,0,.4); }
.seg.full { display: flex; } .seg.full button { flex: 1; justify-content: center; }

/* Option tiles (visual choices) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile { position: relative; display: grid; gap: 8px; padding: 8px; border-radius: 11px; background: var(--obsidian); border: 1px solid var(--line-2); text-align: left; transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease); }
.tile:hover { border-color: var(--line-3); }
.tile[aria-pressed=true] { border-color: var(--ivory); background: var(--graphite); }
.tile[aria-pressed=true]::after { content: ''; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); }
.tile .tile-art { height: 54px; border-radius: 7px; background: var(--slate); overflow: hidden; display: grid; place-items: center; color: var(--text-2); }
.tile .tile-name { font-size: 12px; font-weight: 500; color: var(--text-2); padding: 0 2px; }
.tile[aria-pressed=true] .tile-name { color: var(--text); }

/* Colour input */
.color { display: flex; align-items: center; gap: 0; border: 1px solid var(--line-2); background: var(--obsidian); border-radius: 9px; height: 36px; padding: 4px; transition: border-color var(--t-fast); }
.color:focus-within { border-color: rgba(236,230,216,.4); }
.color .swatch { position: relative; width: 26px; height: 26px; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset; flex: none; }
.color .swatch input { position: absolute; inset: -8px; width: 42px; height: 42px; border: 0; padding: 0; cursor: pointer; opacity: 0; }
.color .hex { border: 0; background: transparent; width: 100%; min-width: 0; height: 26px; padding: 0 8px; font: 400 12.5px var(--mono); text-transform: uppercase; outline: none; color: var(--text); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 22px; height: 22px; border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.1) inset; transition: transform var(--t-fast) var(--spring); }
.swatches button:hover { transform: scale(1.12); }

/* ---------- Panels & rows ---------- */
.panel { background: var(--obsidian); border: 1px solid var(--line); border-radius: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 14px; font-family: var(--font); font-weight: 600; letter-spacing: -0.01em; }
.panel-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 18px; display: grid; gap: 18px; }
.rows > .row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px; }
.rows > .row + .row { border-top: 1px solid var(--line); }
.row .row-text { min-width: 0; }
.row .row-title { font-weight: 500; font-size: 13.5px; }
.row .row-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Pills / tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 500; background: rgba(236,230,216,.06); color: var(--text-2); box-shadow: 0 0 0 1px var(--line) inset; white-space: nowrap; }
.tag.success { background: rgba(61,214,140,.1); color: #6EE7B0; box-shadow: 0 0 0 1px rgba(61,214,140,.2) inset; }
.tag.warn { background: rgba(245,184,61,.1); color: #F8CB6E; box-shadow: 0 0 0 1px rgba(245,184,61,.2) inset; }
.tag.danger { background: rgba(242,85,90,.1); color: #FF8A8D; box-shadow: 0 0 0 1px rgba(242,85,90,.2) inset; }
.tag.signal { background: var(--signal-soft); color: #FF8467; box-shadow: 0 0 0 1px rgba(255,77,46,.25) inset; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font: 500 11px var(--mono); color: var(--muted); background: var(--graphite); box-shadow: 0 0 0 1px var(--line-2) inset, 0 -1px 0 rgba(0,0,0,.5) inset; }

/* Rarity colours */
.r-common { --rc: #B4B1AA; } .r-rare { --rc: #4C8DFF; } .r-epic { --rc: #4FD1E8; } .r-legendary { --rc: #F5B83D; } .r-mythic { --rc: #FF4D2E; }
.rarity { color: var(--rc); font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- Popovers: menu / select / tooltip / context ---------- */
.popover {
  position: fixed; z-index: 1150; min-width: 180px; padding: 5px; background: rgba(20,20,23,.96); border-radius: 12px;
  box-shadow: var(--shadow-pop); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  transform-origin: var(--origin, top left); animation: popIn var(--t) var(--ease-out);
  max-height: min(360px, 70vh); overflow: auto;
}
.popover.closing { animation: popOut 110ms var(--ease) forwards; }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
@keyframes popOut { to { opacity: 0; transform: scale(.97); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border-radius: 7px; font-size: 13px; color: var(--text-2); text-align: left; transition: background 80ms, color 80ms; }
.menu-item:hover, .menu-item.active { background: rgba(236,230,216,.07); color: var(--text); }
.menu-item[aria-selected=true] { color: var(--text); }
.menu-item .check { margin-left: auto; opacity: 0; color: var(--ivory); }
.menu-item[aria-selected=true] .check { opacity: 1; }
.menu-item.danger { color: #FF8A8D; } .menu-item.danger:hover { background: rgba(242,85,90,.1); }
.menu-item .kbd { margin-left: auto; }
.menu-sep { height: 1px; margin: 5px -5px; background: var(--line); }
.menu-label { padding: 6px 10px 4px; font: 500 10.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }

.select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 36px; padding: 0 10px 0 12px; border-radius: 9px; background: var(--obsidian); border: 1px solid var(--line-2); color: var(--text); text-align: left; transition: border-color var(--t-fast); }
.select-trigger:hover { border-color: var(--line-3); }
.select-trigger[aria-expanded=true] { border-color: rgba(236,230,216,.4); }
.select-trigger .val { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger .ic:last-child { color: var(--muted); transition: transform var(--t) var(--ease); }
.select-trigger[aria-expanded=true] .ic:last-child { transform: rotate(180deg); }

.tooltip {
  position: fixed; z-index: 1300; pointer-events: none; max-width: 240px; padding: 6px 9px; border-radius: 8px;
  background: #ECE6D8; color: #0A0A0B; font-size: 12px; font-weight: 500; line-height: 1.35;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,.6); animation: tipIn 140ms var(--ease-out);
}
.tooltip .tip-sub { display: block; font-weight: 400; color: #4A4844; font-size: 11.5px; margin-top: 2px; }
@keyframes tipIn { from { opacity: 0; transform: translateY(3px) scale(.98); } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; position: relative; overflow: hidden; display: flex; gap: 11px; align-items: flex-start; width: 340px; max-width: calc(100vw - 40px);
  padding: 12px 14px; border-radius: 12px; background: rgba(22,22,25,.97); box-shadow: var(--shadow-pop);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: toastIn var(--t-slow) var(--ease-out);
}
.toast.out { animation: toastOut 220ms var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
.toast .t-ic { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; flex: none; margin-top: 1px; }
.toast.success .t-ic { background: rgba(61,214,140,.15); color: var(--success); }
.toast.error .t-ic { background: rgba(242,85,90,.15); color: var(--danger); }
.toast.info .t-ic { background: rgba(236,230,216,.1); color: var(--ivory); }
.toast .t-title { font-weight: 600; font-size: 13px; }
.toast .t-msg { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.toast .t-x { margin-left: auto; color: var(--faint); padding: 2px; border-radius: 5px; }
.toast .t-x:hover { color: var(--text); }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: currentColor; opacity: .5; transform-origin: left; animation: bar linear forwards; }
.toast.success .t-bar { color: var(--success); } .toast.error .t-bar { color: var(--danger); } .toast.info .t-bar { color: var(--ivory); }
@keyframes bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 640px) { .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; } .toast { width: auto; } }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,5,6,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn var(--t) var(--ease); }
.modal {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 40px); overflow: auto; background: var(--graphite); border-radius: 16px;
  box-shadow: 0 0 0 1px var(--line-2), 0 32px 80px -16px rgba(0,0,0,.85); animation: modalIn var(--t-slow) var(--ease-out);
}
.modal.wide { max-width: 560px; }
.modal-root.closing .modal { animation: modalOut 160ms var(--ease) forwards; }
.modal-root.closing .modal-backdrop { animation: fadeOut 160ms var(--ease) forwards; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes modalOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal-head { padding: 20px 22px 0; display: flex; gap: 14px; align-items: flex-start; }
.modal-head .m-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--slate); box-shadow: 0 0 0 1px var(--line-2) inset; flex: none; color: var(--ivory); }
.modal-head .m-ic.danger { background: rgba(242,85,90,.12); color: var(--danger); box-shadow: 0 0 0 1px rgba(242,85,90,.25) inset; }
.modal-head h2 { font-size: 17px; }
.modal-head p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.modal-body { padding: 18px 22px; display: grid; gap: 14px; }
.modal-foot { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: rgba(0,0,0,.15); }
.modal-x { position: absolute; top: 14px; right: 14px; }

/* ---------- Skeleton / empty / misc ---------- */
.skel { position: relative; overflow: hidden; background: var(--graphite); border-radius: 8px; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(236,230,216,.05), transparent); animation: shimmer 1.4s var(--ease) infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 20px; }
.empty .e-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: var(--text-2); background: var(--graphite); box-shadow: 0 0 0 1px var(--line-2) inset, 0 0 0 6px rgba(236,230,216,.02); margin-bottom: 4px; }
.empty h4 { font-size: 14px; font-weight: 600; }
.empty p { font-size: 13px; color: var(--muted); max-width: 300px; }
.error-state .e-ic { color: var(--danger); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 1.6px solid rgba(236,230,216,.18); border-top-color: var(--ivory); animation: spin .7s linear infinite; }
.divider { height: 1px; background: var(--line); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: rgba(236,230,216,.04); box-shadow: 0 0 0 1px var(--line) inset; font-size: 12.5px; color: var(--text-2); }
.callout.warn { background: rgba(245,184,61,.06); box-shadow: 0 0 0 1px rgba(245,184,61,.18) inset; }
.callout.warn .ic { color: var(--warn); }
.callout .ic { margin-top: 1px; color: var(--muted); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 14px; background: var(--obsidian); border-radius: 10px; box-shadow: 0 0 0 1px var(--line) inset; font: 500 14px var(--mono); text-align: center; }

/* Official link logos: drawn as a mask so they take the link's colour */
.ic-logo { display: inline-block; flex: none; vertical-align: middle; background: currentColor; -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
img.ic-fav { display: inline-block; flex: none; vertical-align: middle; object-fit: contain; border-radius: 4px; }
