/* The KTC Item Shop (system/box/gift.php, js/function_ktc.js): beside the items, the shop's ad and
   a rarity filter of coloured checkboxes; the items as cards with their rarity border
   (css/ktc/ktc-items.css), name and price. The shop fills its window edge to edge: the ad sits in
   the top left corner, flush. Spacing sticks to 4/8/12/16/24. On phones the ad is a 3:1 banner,
   with the filter as one row of chips below it, and the screen doesn't scroll: the items that
   don't fit are further slides, sideways (KtcSlides in js/ktc/ktc_mobile.js). */

/* the window: no padding round the shop, the ad and items run to its rounded edges */
.over_modal_in:has(.ktc_shop) { padding: 0; overflow: hidden; }
.over_modal_in:has(.ktc_shop) .modal_close { z-index: 3; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(10, 10, 14, .6); backdrop-filter: blur(6px); }
.over_modal_in:has(.ktc_shop) #gift_second { padding: 36px 20px 20px; }

.ktc_shop { font-family: var(--ktc-font); }
.shop_layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.shop_layout.shop_no_ad { grid-template-columns: 196px minmax(0, 1fr); }
.shop_side { display: flex; flex-direction: column; min-width: 0; }

/* the ad: square, as the ads are drawn (art/ads), in the window's corner */
.shop_ad { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: #101010; }
.shop_ad_img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shop_ad_empty { display: flex; margin: 12px 12px 0; border: 2px dashed rgba(255, 255, 255, .18); border-radius: 14px; background: rgba(255, 255, 255, .03); box-sizing: border-box; }
.shop_ad_add { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; color: #888; cursor: pointer; transition: color .15s, background .15s; }
.shop_ad_add:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.shop_ad_add i { font-size: 28px; color: #12c2e9; }
.shop_ad_add span { font-size: 15px; font-weight: 600; color: #fff; }
.shop_ad_add small { font-size: 12px; line-height: 1.4; }
/* staff tools: top left, clear of the window's close button */
.shop_ad_tools { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; gap: 8px; }
.shop_ad_tool { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 1px solid rgba(255, 255, 255, .2); border-radius: 50%; background: rgba(10, 10, 14, .65); color: #fff; font-size: 14px; cursor: pointer; backdrop-filter: blur(6px); transition: background .15s, transform .15s; }
.shop_ad_tool:hover { background: #03add8; }
.shop_ad_tool:active { transform: scale(.94); }
.shop_ad_remove.is_armed { background: #cc0000; border-color: #cc0000; }
.shop_ad_confirm { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 2; margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(10, 10, 14, .85); font-size: 13px; font-weight: 600; line-height: 1.4; color: #fff; backdrop-filter: blur(6px); }
.shop_ad_busy::before { content: ''; position: absolute; inset: 0; z-index: 1; background: rgba(0, 0, 0, .55); }
.shop_ad_busy::after { content: ''; position: absolute; top: 50%; left: 50%; z-index: 2; width: 32px; height: 32px; margin: -16px 0 0 -16px; box-sizing: border-box; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: shopSpin .8s linear infinite; }
@keyframes shopSpin { to { transform: rotate(360deg); } }

/* the rarity filter: coloured checkboxes */
.shop_filter { margin: 0; padding: 12px; border: 0; min-width: 0; }
.shop_label { margin: 0 0 8px; padding: 0; font-size: 13px; font-weight: 600; color: #888; }
.shop_filter_list { display: flex; flex-direction: column; gap: 6px; }
.shop_rarity { --r: #9aa0a6; position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; box-sizing: border-box; border: 1px solid rgba(255, 255, 255, .08); border-radius: 10px; background: rgba(255, 255, 255, .03); cursor: pointer; transition: border-color .15s, background .15s; }
.shop_rarity:hover { border-color: var(--r); }
.shop_r_normal { --r: #9aa0a6; }
.shop_r_rare { --r: #8fe06e; }
.shop_r_ultra { --r: #ef4444; }
.shop_r_unique { --r: #a855f7; }
.shop_rarity_box { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.shop_tick { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 18px; height: 18px; box-sizing: border-box; border: 2px solid var(--r); border-radius: 5px; color: #111; font-size: 10px; transition: background .15s; }
.shop_tick i { opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.shop_rarity.is_on { border-color: var(--r); background: color-mix(in srgb, var(--r) 14%, transparent); }
.shop_rarity.is_on .shop_tick { background: var(--r); }
.shop_rarity.is_on .shop_tick i { opacity: 1; transform: none; }
.shop_rarity_box:focus-visible + .shop_tick { outline: 2px solid #12c2e9; outline-offset: 2px; }
.shop_rarity_name { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; }
.shop_rarity_count { min-width: 22px; padding: 2px 6px; box-sizing: border-box; border-radius: 999px; background: rgba(255, 255, 255, .06); font-size: 12px; font-weight: 600; color: #aaa; text-align: center; font-variant-numeric: tabular-nums; }
.shop_rarity_none { opacity: .45; cursor: not-allowed; }
.shop_rarity_none:hover { border-color: rgba(255, 255, 255, .08); }

/* the items */
.shop_main { min-width: 0; padding: 12px; box-sizing: border-box; }
.shop_bar { display: flex; align-items: center; gap: 12px; min-height: 36px; margin: 0 48px 8px 0; }    /* clear of the close button */
.shop_bar .shop_label { margin: 0; }
.shop_clear { margin: 0; padding: 8px 0; border: 0; background: none; color: #12c2e9; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.shop_clear:hover { text-decoration: underline; }
.shop_grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.shop_card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; min-width: 0; margin: 0; padding: 16px 8px 8px; box-sizing: border-box; border-radius: 12px; --gift-radius: 12px; background: rgba(255, 255, 255, .04); color: inherit; font: inherit; text-align: center; cursor: pointer; transition: transform .15s, background .15s, box-shadow .15s; }
.shop_card.gift_rarity_normal, .shop_card.gift_rarity_rare, .shop_card.gift_rarity_ultra, .shop_card.gift_rarity_unique { border-width: 3px; --gift-border: 3px; }
.shop_card:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .07); box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.shop_card:active { transform: translateY(0) scale(.98); }
.shop_card:focus-visible { outline: 2px solid #12c2e9; outline-offset: 2px; }
.shop_card.hidden { display: none; }
/* item images keep transparent room round the item (its shadow, room to move), so they're scaled up
   past their box: the item fills it, the empty margin spills over */
.shop_card_art { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; }
.shop_card_img { max-width: 64px; max-height: 64px; object-fit: contain; transform: scale(1.25); }
.shop_card_name { width: 100%; overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.shop_card_price { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .3); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.shop_card_price img { width: 14px; height: 14px; }
.shop_card .gcard_limit { top: 4px; }
.shop_none { padding: 48px 16px; text-align: center; }
.shop_none i { display: block; margin-bottom: 12px; font-size: 32px; color: #555; }
.shop_none p { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }

/* after a purchase (shopBought, js/function_ktc.js): the item pops in over a glow in its rarity's
   colour, then what it is and what next */
.over_modal_in:has(.ktc_shop) #gift_third { padding: 40px 20px 24px; }
.shop_bought { display: flex; flex-direction: column; align-items: center; text-align: center; }
.shop_bought.hidden { display: none; }
.shop_bought.tier_0 { --bought-glow: rgba(154, 160, 166, .45); }
.shop_bought.tier_1 { --bought-glow: rgba(143, 224, 110, .5); }
.shop_bought.tier_2 { --bought-glow: rgba(239, 68, 68, .55); }
.shop_bought.tier_3 { --bought-glow: rgba(168, 85, 247, .65); }
.shop_bought_art { position: relative; display: flex; align-items: center; justify-content: center; width: 200px; height: 200px; margin-bottom: 12px; }
.shop_bought_glow { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, var(--bought-glow) 0, transparent 68%); }
.shop_bought.tier_2 .shop_bought_glow, .shop_bought.tier_3 .shop_bought_glow { inset: -24px; }
.shop_bought.tier_3 .shop_bought_glow::before { content: ''; position: absolute; inset: 8%; border-radius: 50%; background: repeating-conic-gradient(var(--bought-glow) 0 6deg, transparent 6deg 18deg); -webkit-mask-image: radial-gradient(circle, #000 0 35%, transparent 70%); mask-image: radial-gradient(circle, #000 0 35%, transparent 70%); animation: shopRays 14s linear infinite; }
@keyframes shopRays { to { transform: rotate(360deg); } }
.shop_bought_frame { position: relative; padding: 8px; --gift-radius: 22px; background: rgba(20, 16, 32, .85); box-shadow: 0 0 32px var(--bought-glow), 0 16px 40px rgba(0, 0, 0, .45); }
.shop_bought_frame img { display: block; width: 128px; height: 128px; object-fit: contain; transform: scale(1.2); }
.shop_bought_title { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.2; }
.shop_bought_name { margin: 6px 0 0; font-size: 17px; font-weight: 700; }
.shop_bought_meta { margin: 4px 0 0; font-size: 14px; font-weight: 700; }
.shop_bought_serial { color: #aaa; }
.shop_bought_balance { display: inline-flex; align-items: center; gap: 6px; margin: 14px 0 20px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .06); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.shop_bought_balance img { width: 16px; height: 16px; }
.shop_bought_actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.shop_bought_actions .reg_button { min-height: 44px; padding: 0 18px; }
.shop_bought_open { order: -1; flex-basis: 100%; max-width: 320px; font-size: 16px; }
.shop_bought.is_in .shop_bought_frame { animation: shopPop .55s cubic-bezier(.2, .9, .3, 1.5) both; }
.shop_bought.is_in .shop_bought_glow { animation: shopGlow .7s ease-out both; }
.shop_bought.is_in .shop_bought_frame img { animation: shopFloat 3s ease-in-out .7s infinite; }
.shop_bought.is_in .shop_bought_title, .shop_bought.is_in .shop_bought_name, .shop_bought.is_in .shop_bought_meta, .shop_bought.is_in .shop_bought_balance, .shop_bought.is_in .shop_bought_actions { animation: shopRise .4s ease-out both; }
.shop_bought.is_in .shop_bought_title { animation-delay: .18s; }
.shop_bought.is_in .shop_bought_name, .shop_bought.is_in .shop_bought_meta { animation-delay: .26s; }
.shop_bought.is_in .shop_bought_balance { animation-delay: .34s; }
.shop_bought.is_in .shop_bought_actions { animation-delay: .42s; }
@keyframes shopPop { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 70% { transform: scale(1.08) rotate(2deg); opacity: 1; } 100% { transform: none; } }
@keyframes shopGlow { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }
@keyframes shopFloat { 50% { translate: 0 -5px; } }
@keyframes shopRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
	/* one column: the ad full width on top, the filter as a row of chips, then the items */
	.shop_layout, .shop_layout.shop_no_ad { grid-template-columns: minmax(0, 1fr); }
	.shop_ad { flex: none; aspect-ratio: 3 / 1; }
	.shop_ad_for_square { display: none !important; }
	.shop_ad_empty { display: block; margin: 0; border: 0; border-radius: 0; background: #101010; }
	/* no banner: nothing for members, somewhere to add one for staff */
	.shop_ad_no_banner { display: flex; aspect-ratio: auto; min-height: 72px; margin: 8px 12px 0; border: 2px dashed rgba(255, 255, 255, .18); border-radius: 14px; background: rgba(255, 255, 255, .03); }
	.shop_ad_no_banner:not(:has(.shop_ad_add)) { display: none; }
	.shop_ad_no_banner picture, .shop_ad_no_banner .shop_ad_tools { display: none; }
	.shop_filter { padding: 12px 0 0; }
	.shop_filter_list { flex-direction: row; gap: 8px; padding: 0 12px 4px; overflow-x: auto; scrollbar-width: none; }
	.shop_filter_list::-webkit-scrollbar { display: none; }
	.shop_rarity { flex: none; min-height: 40px; padding: 0 12px; }
	.shop_no_ad .shop_filter { padding-top: 56px; }       /* below the close button when there is no ad */
	.shop_main { padding-top: 8px; }
	.shop_bar { margin-right: 0; }
	.shop_grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

	/* the screen stays still: everything fits in the window and the items page sideways */
	html .over_modal_in.modal_in:has(.ktc_shop:not([style*="none"])), html .over_modal_in.modal_in:has(#view_gift_box) { display: flex; flex-direction: column; height: calc(100dvh - 24px - var(--safe-top)); overflow: hidden; }
	.over_modal_in:has(.ktc_shop:not([style*="none"])) > #over_modal_content, .over_modal_in:has(#view_gift_box) > #over_modal_content { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
	.ktc_shop:not([style*="none"]) { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
	.ktc_shop .shop_layout { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
	/* nothing here may grow wider than the screen: the chips and the items scroll inside it instead */
	.over_modal_in:has(.ktc_shop:not([style*="none"])) > #over_modal_content, .over_modal_in:has(#view_gift_box) > #over_modal_content, .ktc_shop:not([style*="none"]), .ktc_shop .shop_layout, .ktc_shop .shop_side, .ktc_shop .shop_main { width: 100%; min-width: 0; }
	.ktc_shop .shop_side { flex: none; }
	.ktc_shop .shop_main { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; padding-bottom: 0; }
	.ktc_shop .shop_bar { flex: none; margin-bottom: 0; }
	.ktc_item_search { flex: none; }
	html.ktc_keyboard .ktc_shop .shop_side { display: none; }
	/* My items, in the Market's screen (a profile's Items tab has the same markup and scrolls with the profile) */
	html #over_modal #view_gift_box, html #over_modal #view_gift_box :has(.ktc_slide_grid) { display: flex; flex: 1 1 0; flex-direction: column; width: 100%; min-width: 0; min-height: 0; }
	html .ktc_slide_grid.ktc_slide_grid.ktc_slide_grid {
		display: grid; flex: 1 1 0; grid-template-columns: repeat(var(--slide-columns, 3), calc((100% - 16px) / 3)); grid-template-rows: repeat(var(--slide-rows, 2), max-content); align-content: start;
		gap: 8px; min-height: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; touch-action: pan-x;
	}
	.ktc_slide_grid::-webkit-scrollbar { display: none; }
	/* the chat's tabs show a zone with an inline display:block, and hide it with an inline display:none */
	html .ktc_slide_grid { display: grid !important; }
	html .ktc_slide_grid.hidden, html .ktc_slide_grid[style*="display: none"] { display: none !important; }
	/* Trades and Auctions: the same, in the panel they open in, one column of rows at a time */
	html #chat_left:has(.trade_panel, .au_panel), html #chat_left_data:has(> .trade_panel, > .au_panel) { overflow: hidden; }
	#chat_left_data:has(> .trade_panel, > .au_panel) { display: flex; flex-direction: column; }
	.trade_panel, .au_panel, .trade_lists, .au_lists, #au_tab_browse:not(.hide_zone, [style*="none"]) { display: flex; flex: 1 1 0; flex-direction: column; width: 100%; min-width: 0; min-height: 0; }
	.trade_hub_bar, .au_bar, .au_find, .trade_notice, .au_notice { flex: none; }
	html .ktc_slide_grid.ktc_slide_list.ktc_slide_list.ktc_slide_list { grid-template-columns: repeat(var(--slide-columns, 1), 100%); }
	html .ktc_slide_list > .au_row + .au_row { margin-top: 0; }
	.ktc_slide_list > .au_more_btn { display: none; }
	.ktc_slide_grid > * { scroll-snap-align: start; }
	.ktc_slide_grid > :focus-visible { outline-offset: -2px; }
	#view_gift_box .ktc_slide_grid { scroll-padding-left: 8px; }
	.ktc_slides_none { margin: 0; padding: 32px 16px; text-align: center; }
	.ktc_slides { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; height: 52px; padding: 4px 8px; box-sizing: border-box; }
	.ktc_slides[hidden] { display: none; }
	.ktc_slides_arrow { display: flex; align-items: center; justify-content: center; width: 72px; height: 44px; padding: 0; border: 2px solid var(--kt-edge); border-radius: 12px; background: var(--kt-violet, #7a5cff); box-shadow: 0 3px 0 var(--kt-edge); color: #fff; font-size: 18px; cursor: pointer; }
	.ktc_slides_arrow:active { transform: translateY(3px); box-shadow: none; }
	.ktc_slides_arrow:disabled { border-color: rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .06); box-shadow: none; color: rgba(255, 255, 255, .25); transform: none; cursor: default; }
	.ktc_slides_arrow:focus-visible { outline: 2px solid #12c2e9; outline-offset: 2px; }
	.ktc_slides_count { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
}
/* a small phone on its side has room for the items and the arrows, and that's all: without this the banner alone fills the screen */
@media (max-width: 640px) and (max-height: 500px) {
	.au_find, .ktc_shop .shop_side, .ktc_shop .ktc_item_search, .ktc_shop .shop_bar, .over_modal_in:has(#view_gift_box) > #over_modal_content > :not(#view_gift_box) { display: none; }
	.ktc_slide_grid .shop_card { gap: 4px; padding: 8px 4px 4px; }
	.ktc_slide_grid .shop_card_art, .ktc_slide_grid .shop_card_img { width: 40px; height: 40px; max-width: 40px; max-height: 40px; }
	html .ktc_slide_grid .pgcard_img { height: 40px; max-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
	.shop_bought.is_in *, .shop_bought_glow::before { animation: none !important; }
	.shop_card, .shop_tick i, .shop_rarity, .shop_ad_tool { transition: none; }
	.shop_card:hover { transform: none; }
}
