/* ==========================================================================
   JoyStats UI kit layer.
   Loaded LAST (after tokens, joystats-base, theme and the hero stat css).
   One consistent bevel language for every skin, in light and dark:

   - square corners (no stepped clip-paths)
   - raised = pressable (buttons, chips), sunken = typeable (fields, wells)
   - containers are borderless: a soft surface fill on a tinted page
   - slow, muted hover; one solid focus ring
   - spotlight (.is-spot) for growth nudges: a soft outline that fades fully
     out, then pulses in, using the skin's own second accent (--mg)
   - pop-ups and the theme picker: floating inline header, no title bar

   Everything keys off the skin tokens in tokens.css, so a new skin only needs
   its token block.
   ========================================================================== */

/* ---------- component tokens (derived from skin tokens) ---------- */
:root,
[data-skin] {
	--c1: none;
	--c2: none;
	--ctab: none;
	--btn-clip: none;
	--tab-clip: none;
	--r: 0;
	--rb: 0;
	--px: 4px;
	--k-edge: var(--ink-7);                  /* strong edge: interactive things */
	--k-edge-soft: var(--ink-5);             /* soft edge: fields, resting chips */
	--k-edge-box: color-mix(in srgb, var(--ink-5) 42%, var(--ink-2)); /* soft edge for wells inside containers */
	--k-surface: var(--ink-2);               /* container fill */
	--k-well: var(--ink-1);                  /* sunken fill: fields, nested wells */
	--k-quiet: var(--ink-3);                 /* quiet button / resting chip fill */
	--k-hi: rgba(255, 255, 255, .34);
	--k-lo: rgba(0, 0, 0, .26);
	--k-focus: var(--ink-7);
	--on-mg: var(--on-accent);
	--spot: var(--mg);                       /* spotlight = the skin's own second accent */
	--on-spot: var(--on-mg);
	--spot-ink: var(--mg-t);
	--tl-r: #d9645a;
	--up: inset 4px 4px 0 var(--k-hi), inset -4px -4px 0 var(--k-lo);
	--down: inset 4px 4px 0 var(--k-lo), inset -4px -4px 0 var(--k-hi);
	--page-bg: var(--ink-1);
}

/* dark: lighter quiet fill + heavier shade edge so raised things separate from containers */
[data-mode="dark"] {
	--k-quiet: color-mix(in srgb, var(--ink-3), var(--ink-7) 26%);
	--k-hi: rgba(255, 255, 255, .32);
	--k-lo: rgba(0, 0, 0, .4);
	--page-bg: var(--ink-1);
}

/* Round 58 item 2: meadow dark only, the quiet fill stays at ink-3
   with no lightening, so ghost-button text (ink-7) reads clearly.
   The same fill is used by resting chips, icon buttons and quiet
   fills, all with ink-7 or ink-5 text, so the darker fill improves
   their contrast too (ink-5 on quiet goes from about 2.5:1 to about
   5.4:1). Raised controls keep their bevel for separation. */
[data-skin="meadow"][data-mode="dark"] {
	--k-quiet: var(--ink-3);
}

/* light: stronger shade edge, and a page tint (the skin's own pastel) behind containers */
[data-mode="light"] {
	--k-lo: rgba(0, 0, 0, .32);
	--page-bg: color-mix(in srgb, var(--ink-1), var(--ink-3) 75%);
}

/* text on the second accent where the default on-accent does not hold up */
[data-skin="stealth"][data-mode="dark"] { --on-mg: #f7f7f8; }
[data-skin="cosmos"][data-mode="light"] { --on-mg: #2a1d00; }   /* dark text on gold */
[data-skin="butter"][data-mode="light"] { --on-mg: #ffffff; }   /* white text on red */

/* forest has no dot background */
[data-skin="forest"][data-mode="light"],
[data-skin="forest"][data-mode="dark"] { --page-img: none; }

/* ---------- focus: one solid ring everywhere ---------- */
:focus-visible {
	outline: 3px solid var(--k-focus);
	outline-offset: 3px;
}
.btn:focus-visible, .tab:focus-visible, .seg button:focus-visible, .chip-btn:focus-visible, .sw:focus-visible, .theme:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .sel:focus-visible{
	outline: 3px solid var(--k-focus);
	outline-offset: 4px;
	box-shadow: var(--up);
}

/* ---------- page + containers ---------- */
body { background: var(--page-bg); }
.js-page {
	background-color: var(--page-bg);
	--bc: transparent;                 /* every .px outline in the page goes transparent: containers are borderless */
}
.js-page .px { box-shadow: none; }

.sitebar, .box, .custom, .empty-list, .nudge{
	background-color: var(--k-surface);
	clip-path: none;
	border-radius: 0;
	box-shadow: none;
}
.sitebar { padding: 12px 20px; margin: 0; }

/* section headers: plain large title on the surface, .box__head h2, .box__head .h2, .box .h2{
	background: none;
	color: var(--ink-7);
	padding: 0;
	font-size: var(--fs-heading);
	line-height: 1.1;
}
.box__head small,
.h2 small { color: var(--ink-5); font-size: var(--fs-secondary); }

/* nested cards and wells: sunken or quiet, .sheet__hint{
	background: var(--k-quiet);
	clip-path: none;
	border-radius: 0;
	outline: 0;
	box-shadow: var(--up);
}
.sheet__hint { background: var(--k-quiet); color: var(--ink-7); box-shadow: none; }

/* ---------- buttons ---------- */
.btn,
.fab {
	--bg: var(--cy);
	--fg: var(--on-accent);
	background: var(--bg);
	color: var(--fg);
	border: 0;
	border-radius: 0;
	clip-path: none;
	box-shadow: var(--up);
	transition: background-color .35s ease, box-shadow .25s ease, transform .25s ease;
}
.btn--ghost,
.btn.btn--ghost {
	--bg: var(--k-quiet);
	--fg: var(--ink-7);
}
.btn:hover:not([disabled]),
.fab:hover:not([disabled]) {
	background: color-mix(in srgb, var(--bg), var(--ink-7) 10%);
}
.btn:active:not([disabled]),
.fab:active:not([disabled]) {
	transform: none;
	box-shadow: var(--down);
}
.btn[disabled] {
	opacity: 1;
	color: var(--ink-5);
	background: repeating-linear-gradient(135deg, var(--k-quiet) 0 8px, color-mix(in srgb, var(--k-quiet), var(--ink-7) 8%) 8px 16px);
	box-shadow: none;
}
.fab { box-shadow: var(--up), 0 6px 0 var(--k-lo); }

/* icon buttons + link-ish buttons share the quiet raised look */
.iconbtn,
.icon-btn,
.pinb--icon,
.pinb--head,
.favbtn,
.sharebtn {
	/* theme.css forces these transparent with !important; the kit gives every button the same raised look */
	background: var(--k-quiet) !important;
	color: var(--ink-7);
	border: 0;
	border-radius: 0;
	clip-path: none;
	outline: 0;
	box-shadow: var(--up) !important;
	transition: background-color .35s ease, box-shadow .25s ease;
}
.iconbtn:hover,
.icon-btn:hover,
.pinb--icon:hover,
.pinb--head:hover,
.favbtn:hover,
.sharebtn:hover {
	background: color-mix(in srgb, var(--k-quiet), var(--ink-7) 10%) !important;
}
.pinb--head[aria-pressed="true"],
.favbtn.is-fav,
.favbtn[aria-pressed="true"] { box-shadow: var(--down) !important; }
.sitebar__r .themedrop__btn,
.sitebar__r .icon-btn { background: var(--k-quiet) !important; }

/* ---------- selection chips + segmented controls ---------- */
.chip-btn,
.seg button,
.sel,
.tabs .chip-btn,
.sheet .chip-btn,
.sheet .seg button {
	background: var(--k-quiet);
	color: var(--ink-7);
	border: 0;
	border-radius: 0;
	clip-path: none;
	outline: 0;
	box-shadow: var(--up);
	transition: background-color .35s ease, box-shadow .25s ease;
}
.chip-btn:hover,
.seg button:hover { background: color-mix(in srgb, var(--k-quiet), var(--ink-7) 10%); }
.seg button + button { margin-left: 0; }
.seg { gap: 6px; }
.chip-btn[aria-pressed="true"],
.seg button[aria-pressed="true"],
.tabs .chip-btn[aria-pressed="true"],
.sheet .chip-btn[aria-pressed="true"],
.sheet .seg button[aria-pressed="true"],
.menu__modes .chip-btn[aria-pressed="true"] {
	background: var(--cy) !important;
	color: var(--on-accent) !important;
	border: 0 !important;
	box-shadow: var(--down);
}
.chip-btn[disabled],
.seg button[disabled] { opacity: .6; box-shadow: none; }

/* static tags (genre, platform, version): flat, quiet */
.chip,
.badge,
.spoiler {
	background: var(--k-quiet);
	color: var(--ink-7);
	clip-path: none;
	border-radius: 0;
	box-shadow: none;
}

/* ---------- text fields: sunken, 4px edge ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
textarea,
select,
.ta,
.sheet .sel,
.sheet input[type="number"],
.sheet .ta {
	background: var(--k-well);
	color: var(--ink-7);
	border: 4px solid var(--k-edge-soft);
	border-radius: 0 !important;
	clip-path: none;
	outline: 0;
	box-shadow: var(--down);
	transition: border-color .3s ease;
}
select.sel,
.sheet select.sel,
.sel {
	/* .sel is also used on <select>; give it the field look, not the chip look */
	background: var(--k-well);
	border: 4px solid var(--k-edge-soft);
	box-shadow: var(--down);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover,
textarea:hover,
select:hover { border-color: var(--k-edge); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
textarea:focus,
select:focus,
.sheet .sel:focus,
.sheet input:focus {
	border: 4px solid var(--k-edge);
	box-shadow: var(--down);
}
input::placeholder,
textarea::placeholder { color: var(--ink-5); opacity: 1; }
input:disabled,
textarea:disabled,
select:disabled {
	color: var(--ink-5);
	background: repeating-linear-gradient(135deg, var(--k-well) 0 8px, color-mix(in srgb, var(--k-well), var(--ink-7) 8%) 8px 16px);
	box-shadow: none;
}
.hint { color: var(--ink-5); }
.check input { accent-color: var(--cy); }

/* ---------- nav ---------- */
.nav__b { color: var(--ink-5); }
.nav__b[aria-current="page"] { color: var(--ink-7); }
.tab[aria-selected="true"] { color: var(--ink-7); border-bottom-color: var(--cy); }

/* ---------- spotlight: soft outline, fades fully out, then pulses in ---------- */
@keyframes jsSpotFade {
	0%, 12%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--spot-ink) 0%, transparent), 0 0 0 0 transparent, var(--up); }
	32%, 62%      { box-shadow: 0 0 0 4px color-mix(in srgb, var(--spot-ink) 80%, transparent), 0 0 22px 2px color-mix(in srgb, var(--spot-ink) 28%, transparent), var(--up); }
	92%           { box-shadow: 0 0 0 4px color-mix(in srgb, var(--spot-ink) 0%, transparent), 0 0 0 0 transparent, var(--up); }
}
.btn--pulse{ animation: jsSpotFade 4.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
	.btn--pulse{ animation: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--spot-ink) 45%, transparent); }
}
/* growth nudge banner */
.nudge { background: var(--k-surface); }
.nudge p b { color: var(--ink-7); }

/* ---------- pop-ups: sheets, modals, menus, theme picker ---------- */
.sheet-bg,
.avatar-modal,
.achmodal { background: rgba(10, 12, 16, .62); }
.sheet, .avatar-modal__box, .themedrop__menu{
	background: var(--k-surface);
	border: 0;
	outline: 0;
	border-radius: 0;
	clip-path: none;
	box-shadow: 6px 6px 0 color-mix(in srgb, var(--ink-7) 12%, transparent);
}
.sheet__head h2{ font: 400 var(--fs-heading)/1.1 var(--f-display); color: var(--ink-7); }
.sheet__act { background: var(--k-surface); }

/* theme picker ("pick theme") */
.themedrop__menu {
	width: 460px;
	max-width: calc(100vw - 32px);
	padding: 0;
	box-shadow: none;
}
.themedrop__body { display: grid; gap: 16px; padding: 20px 24px 24px; }
.theme-grid { margin: 0; gap: 10px; }
.theme-grid .theme {
	background: var(--k-quiet);
	color: var(--ink-7);
	border: 0;
	outline: 0;
	border-radius: 0 !important;
	clip-path: none;
	box-shadow: var(--up);
	padding: 10px 12px;
	gap: 8px;
	transition: background-color .35s ease;
}
.theme-grid .theme:hover { background: color-mix(in srgb, var(--k-quiet), var(--ink-7) 10%); }
.theme-grid .theme__name { font-size: var(--fs-body); color: inherit; }
.theme-grid .theme[aria-pressed="true"],
.theme-grid .theme[aria-checked="true"] {
	background: var(--cy) !important;
	color: var(--on-accent);
	box-shadow: var(--down);
}
.theme-grid .theme[aria-pressed="true"] .theme__name,
.theme-grid .theme[aria-checked="true"] .theme__name { color: var(--on-accent) !important; }
.theme-grid .theme .pal { height: 16px; outline: 2px solid color-mix(in srgb, var(--ink-7) 45%, transparent); }
.menu__modes { border-top: 0; padding: 0; gap: 10px; }

/* ---------- hero stat component, restyled with the skin tokens ---------- */
.p-right {
	--joystats-slot: transparent;
	--joystats-card: var(--ink-3);
	/* Rectangle behind the stat block: one step darker than the --ink-2 header
	   container, staying within the theme. */
	--joystats-panel: var(--ink-1);
	--joystats-edge: transparent;
	--joystats-fg: var(--ink-7);
	--joystats-title: var(--ink-7);
	--joystats-muted: var(--ink-5);
	--joystats-accent: var(--cy-t);
	--joystats-accent2: var(--ink-7);
	--joystats-gold: var(--ink-6);
	--joystats-ink: var(--on-accent);
	--joystats-font: var(--f-display);
	--joystats-font-num: var(--f-num, 'Press Start 2P');
}
.p-right .js-stat { border-radius: 0; text-transform: lowercase; font-size: var(--fs-lead); }
.p-right .js-lab { background: var(--cy); box-shadow: var(--up); }
.p-right .js-lab .js-pick { color: var(--cy-t); }
.p-right .js-n { height: auto !important; line-height: 1 !important; }
.p-right .js-m-cart .js-n,
.p-right .js-m-floppy .js-n,
.p-right .js-m-switch .js-n,
.p-right .js-m-case .js-n,
.p-right .js-m-ps .js-n { font-size: var(--fs-secondary) !important; }
.p-right .js-cell { font-size: var(--fs-secondary); box-shadow: inset 0 0 0 2px var(--ink-4); }
.p-right .js-pct { font-size: var(--fs-secondary); }
.p-right .js-stat :where(button):focus-visible { outline: 3px solid var(--k-focus); outline-offset: 3px; }
.p-right .js-m-switch .js-jc.js-l { background: var(--ink-7); }
.p-right .js-m-switch .js-jc.js-r { background: var(--ink-5); }
.p-right .js-m-switch .js-jc .js-s,
.p-right .js-m-switch .js-jc .js-b { background: var(--ink-1); }

/* ---------- theme-picker swatches (dark palette per skin: ink-1, cy, mg, ink-4, ink-7) ---------- */
.pal[data-skin="mining"] i:nth-child(1){background:#1a1020}
.pal[data-skin="mining"] i:nth-child(2){background:#ff8a3d}
.pal[data-skin="mining"] i:nth-child(3){background:#ff4f7b}
.pal[data-skin="mining"] i:nth-child(4){background:#6a3d5c}
.pal[data-skin="mining"] i:nth-child(5){background:#fff6ee}
.pal[data-skin="arcana"] i:nth-child(1){background:#0a0a24}
.pal[data-skin="arcana"] i:nth-child(2){background:#8b7bff}
.pal[data-skin="arcana"] i:nth-child(3){background:#c27bff}
.pal[data-skin="arcana"] i:nth-child(4){background:#3d3d9c}
.pal[data-skin="arcana"] i:nth-child(5){background:#f8f8ff}
.pal[data-skin="cosmos"] i:nth-child(1){background:#070e26}
.pal[data-skin="cosmos"] i:nth-child(2){background:#5ea8ff}
.pal[data-skin="cosmos"] i:nth-child(3){background:#ffd24a}
.pal[data-skin="cosmos"] i:nth-child(4){background:#2f4686}
.pal[data-skin="cosmos"] i:nth-child(5){background:#f5f8ff}
.pal[data-skin="butter"] i:nth-child(1){background:#1d1606}
.pal[data-skin="butter"] i:nth-child(2){background:#ffd84d}
.pal[data-skin="butter"] i:nth-child(3){background:#ff5a4a}
.pal[data-skin="butter"] i:nth-child(4){background:#6e581a}
.pal[data-skin="butter"] i:nth-child(5){background:#fff8dc}

/* ---------- no dashed lines: structural dashes become flat quiet wells, .sug, .ghostbox, .chip--est{
	border: 0;
	outline: 0;
	background: var(--k-well);
	box-shadow: var(--down);
	color: var(--ink-6);
}
.chip--line { background: var(--k-quiet); outline: 0; color: var(--ink-7); padding: 4px 12px; }
.is-editing [data-show-key],
.is-editing [data-show-key][hidden] {
	outline: 3px solid color-mix(in srgb, var(--cy) 60%, transparent);
	outline-offset: 4px;
}

/* Round 10: game cover renders smooth, never pixelated. */
.ghead__art { image-rendering: auto !important; }
