/* 1600px is the mininum screen width that we allow to show the manual TOC */
@media (min-width: 1600px) {
	#help_toc_container #help_toc_dynamic_menu {
		position: fixed;
		width: calc((100% - 1120px) / 2);
		left: 0px;
/*		top: 40px; */
		margin-left: 0px;
		max-height: calc(100% - 100px);
		min-height: 150px;
		height: fit-content;
		border-radius: 0px;
	}
}

/* 1210 px is the up-down position reevaluation */
@media (max-width: 1209px) {
	/* Up-down arrows */
	div#sl-container { position: fixed; top: inherit; left: inherit; right: -17px; bottom: 90px; transform: scaleX(-1); z-index: 5; }	
}

/* 1140px is the critical point for displaying header/footer */
@media (max-width: 1171px) {
	/* Main wrapper */
	div#bg-undercover { display: none; }
	div#wrapper { padding-left: 0px; padding-right: 0px; background: transparent; }
	div#wrapper::before { display: none; }
	div#wrapper { max-width: 1134px; }
	
	/* Header/footer */
	div#ht-container { margin-left: auto; margin-right: auto; }

	div#inner_section, div#main_content_section { padding-left: 0px; padding-right: 0px; }
	
	div#ft-container { background: transparent; margin-top: 5px; height: fit-content; width: 100%; }
	div#ft-container::before, div#ft-best-post-caption, div#ft-best-post-icon, div#ft-best-post-text { display: none; }
	div#ft-banners { position: static; width: 100%; }
	#moderationbuttons_strip:not(#\9) { margin-left: 0px; }

	div#wrapper { padding-bottom: 18px; min-width: 320px; }
	
	div.up_contain { width: calc(50% - 9px); }
	div.pagesection, div.cat_bar { overflow-x: clip; overflow-y: visible; }
}
@media (max-width: 1139px) and (min-width: 1024px), (max-width: 753px) {
	table.bbc_table > tbody > tr { display: flex; flex-wrap: wrap; }
	table.bbc_table > tbody > tr > td { flex-grow: 1; }

	/* Try detecting the tables with images, and squeeze them. :has degrades gracefully on older browsers to the previous case */
	table.bbc_table > tbody > tr:has(td > div.centertext > img), table.bbc_table > tbody > tr:has(td > img) { display: initial; }
}
/* Hide header once it stops fitting */
@media (max-width: 1090px) {
	div#ht-container { background: transparent; height: fit-content; width: 100%; }
	div#ht-upper-links { width: 100%; height: fit-content; }
	div#ht-slider-buttons, div#ht-slider-place, div#ht-bottom-links { display: none; }
	:is(div#upper_section, div#ht-underlinks)::before { display: none; }
}

/* 1078px is the main width of underlinks - hide all the chains here and underlinks, squeeze everything together */
@media (max-width: 1077px) {
	body { overflow-x: hidden; } /* At some widths horizontal scrollbar appears, we want to remedy that */

	div#ht-upper-links { margin-bottom: 5px; }
	div#ht-underlinks { display: none; }
	div.cat_bar, #main_content_section :is(.pagesection, .navigate_section), div.navigate_section, div.pagesection { margin-top: 0px; }
	.boardindex_table div.cat_bar::before, div.cat_bar_decorated::before, div#info_center::before, div.navigate_section::before, div.pagesection::before { display: none }
	div#info_center { margin-top: 0px; }
	.boardindex_table:not(:last-child) { margin-bottom: 0px; }
	.main_container { margin-bottom: 0px; }

	.windowbg:not(tr):not(#\9), .windowbg2, #quickreply_options, div.main_container > :not(.cat_bar), #messageindex, div.information, #info_center, .roundframe, p.information, div.post_actions_action,
			.action_recenttopics .tborder, #topic_notification_list, #memberlist table, #recent #unread, #unreadreplies, #attachments, #pmFolder .table_grid, #alerts {
		border-left-width: 0px; border-right-width: 0px; margin-top: 0px; border-radius: 0px; border-top-width: 2px; border-bottom-width: 2px; border-image-slice: 2; }
	div#upper_section::before, .boardindex_table div.cat_bar::before, div#info_center::before, div.navigate_section::before, div.pagesection::before, div.post_actions_set::before, div.windowbg::before,
			div.windowbg2_decorated::before, div.cat_bar_decorated::before, #topic_notification_list::before { display: none; }

	div.navigate_section ul li { line-height: 1em; }
/*
	div.navigate_section ul { display: flex; flex-direction: row; align-items: center; justify-content: center; flex-wrap: wrap; height: 100%; }
	div.navigate_section ul li { display: block; line-height: 1em; padding-bottom: 0px; }
	div.navigate_section ul li a { padding: 0px; margin-top: 0px; }
	div.navigate_section ul li span.dividers, div.navigate_section ul li span.dividers::after { line-height: 12px; transform: translateY(-1px); }
	div.navigate_section ul li span:not(.dividers) { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	*/
}

/* 1024px resolution - avatar squeeze */
@media (max-width: 1023px) {
	.postarea, .moderatorbar { margin: 0px 0 0 0px; }
	div.poster:not(.nominify) { width: 100%; height: fit-content; position: relative; top: 0px; background: transparent; padding: 0px; border: 0px; box-shadow: none; min-height: 82px; margin-top: 26px;
			text-shadow: none; }
	div.poster:not(.nominify)::before { top: -26px; left: -13px; transform: translateX(0px); }
	div.poster:not(.nominify) h4 { height: 0px; margin-bottom: 0px; }
	div.poster:not(.nominify) h4 > a:last-child, div.poster:not(.nominify) h4::before, div.poster:not(.nominify) h4::after { display: none; }
	div.poster:not(.nominify) h4 > a[href*="pm"], div.poster:not(.nominify) h4 > span { position: absolute; top: -28px; left: -4px; width: initial; padding: 0px; }
	div.poster:not(.nominify) .blurb { display: none; }
	div.poster:not(.nominify) li.avatar { display: list-item; height: 0px; margin-top: 0px; }
	div.poster:not(.nominify) li.avatar img.avatar { width: 64px; min-width: 64px; height: 64px; min-height: 64px; object-fit: cover; object-position: center top; position: absolute; left: -10px; top: 0px; }
	div.poster:not(.nominify) h4 > a:last-child { display: block; position: absolute; color: var(--t-red); font-size: 13px; font-weight: 400; left: 99px; top: 4px; width: fit-content; padding: 0px; }
	div.poster:not(.nominify) li.passport::before, div.poster:not(.nominify) li.custom.panel::before { display: none; }
/*	div.poster:not(.nominify) li.passport { margin-top: 0px; margin-left: 85px; text-align: left; background: transparent; padding: 0px 5px; } */
	div.poster:not(.nominify) li.passport { display: none; }
	div.poster:not(.nominify) li.custom.cust_cdesc { margin-left: 80px; padding: 0px 5px; width: calc(100% - 95px); background: transparent; text-align: left; color: var(--t-lite); opacity: 0.9;
			display: list-item; margin-top: 18px; }
	div.poster:not(.nominify) li.custom.cust_cdesc::before { display: none; }
	div.poster:not(.nominify) li.passport a { color: var(--t-red); }
	div.poster:not(.nominify) li.custom.panel { position: absolute; right: -10px; top: 0px; display: list-item; }
	.panel_likes:not(#\9), .panel_posts:not(#\9), .panel_balance:not(#\9) { border-width: 0px; background: transparent; filter: invert(1) grayscale(1); box-shadow: none; height: 20px; }
	
	div.post { width: 100%; }
	div.post .inner { min-height: initial; }
	.hide_poster div.post .inner { margin-top: 18px; }

	#forumposts .keyinfo { padding-top: 6px; margin-top: 0px; }
	#forumposts .windowbg:not(tr):not(#\9 ) { padding: 15px 15px 0px 15px; }
	#forumposts .windowbg:not(tr) .post_wrapper .signature { padding-bottom: 13px; }
}

/* Topic list proper squeeze - this width value taken from curve2 responsive.css */
@media (max-width: 855px) {
	#messageindex div:is(.board_icon, .lastpost) { display: block; }
	#messageindex .board_icon { width: 30px; }
	#messageindex .info_block { width: calc(60% - 18px); }
	#messageindex .lastpost   { width: calc(40% - 12px); max-width: 200px; }
	#topic_container .windowbg:not(\#9) { overflow: visible; } /* To always show the topic icon */

	.board_link { width: 40%; padding: 0px 15px; }
	#pmFolder .postinfo > span.smalltext > strong { display: none; }
}

/* Make categories in 1 column instead of 2 */
@media (max-width: 799px) {
	div.up_contain { width: 100%; }
}

/* Redefine the original rules at 720px */
@media (max-width: 720px) {
	/* Private messages */
	#pmFolder.flow_hidden .table_grid tr :is(td.pm_time, td.pm_from_to) { display: none; }
}

/* Super small screens */
@media (max-width: 639px) {
	div.poster:not(.nominify) li.passport { width: fit-content; }
	.panel_likes:not(#\9), .panel_posts:not(#\9), .panel_balance:not(#\9) { width: fit-content; padding: 0px 4px; }
	
	#mobile_user_menu.popup_container { position: absolute; height: fit-content; display: block !important; } /* Do not delete important, overwrites inline style on small screens */
	#mobile_user_menu.popup_container .popup_heading { display: none; }
	
	#main_menu .popup_window { width: 100%; position: static; border: 0px; overflow-x: visible; overflow-y: visible; background: transparent; }
	#main_menu .popup_window > ul.menu_nav { min-width: 320px; width: 100%; display: flex; flex-wrap: wrap; overflow-x: clip; overflow-y: visible; }
	a.mobile_user_menu { display: none; }

/*	div#main_menu, div#main_menu ul.menu_nav { margin-left: 0px; margin-right: 0px; } */
	
	#main_menu .dropmenu > li { width: fit-content; }
	#main_menu .dropmenu > li > a { padding: 0px 7px !important; line-height: 17px; } /* Important to rewrite other !important in responsive.css */
	#main_menu .dropmenu > li > ul { top: 50px; position: absolute; }

	.dropmenu li.subsections > a::after { display: none; }

	.keyinfo .postinfo .smalltext.modified { display: none; }
	.inner { padding: 5px 0px 0px 0px; }
	
	.quickbuttons { float: right; width: calc(100% - 20px); text-align: right; display: flex; flex-wrap: wrap; }

	.catbg, .catbg a { font-size: 14px; }

	.board_link { display: none; }
	.modal-sticker { width: 95%; width: min(600px, 95%); }

	#pmFolder .postinfo > span.smalltext { display: none; }
}

/* Redefine the original rules at 560px */
@media (max-width: 560px) {
	a[class^="mobile_generic_menu_"] { margin-top: 1px; margin-bottom: 1px; }
	.menu_icon { filter: invert(0.9) drop-shadow(0 0 2px var(--t-link)); }
	#ruby_popup .popup_window { max-height: initial; }
}

@media (max-width: 480px) {
	div.poster:not(.nominify) li.custom.panel { position: static; width: 100%; text-align: right; }
	#main_menu .dropmenu > li > a { padding: 0px 0px !important; line-height: 17px; } /* Important to rewrite other !important above */
	div.main_container > :not(.cat_bar) { padding-left: 0px; padding-right: 0px; }
	div.up_contain { margin: 0px; }
	.modal-sticker { width: 100%; border-radius: 0px; }

	#likes li { height: 80px; }
	#likes .like_message { -webkit-line-clamp: 3; }

	span.pages { display: none; }
}
@media (max-width: 420px) {
	div.pagesection :is(span.current_page, a.nav_page) { margin-left: -3px; padding: 0px 3px; }
	#help_main_container .manual_text_block_post_toc, #help_main_container .manual_toc { padding: 0px; border: 0px; background: transparent; }
}

/* Then, work on the ruby popup windows */
@media (max-width: 695px) { /* Remove the tiny little bit of padding */
	div#ruby_popup div.popup_window { padding-left: 0px; padding-right: 0px; overflow: visible; }
}

/* Ruby popup: passport */
@media (max-width: 699px) {
	div#passport_container div#passport_image { display: none; }
	div#passport_container div#passport_dossier { flex-grow: 0; margin: 0px auto; }
}

@media (max-width: 479px) { /* Dossier stops fitting */
	div#passport_container :is(.ruby_popup_upper, .passport_tab, #passport_dossier) { height: fit-content; }
	div.passport_tab { grid-template-rows: 150px 150px; }
	div#passport_container .passport_tab { max-height: 353px; }
	div#passport_container #passport_dossier { width: 100%; }
	div#passport_container #passport_full_name { margin-bottom: 5px; }
	div#passport_container #passport_about { display: none; }
	div#passport_container #passport_description_tabs { display: flex; justify-content: right; }
	div#passport_container #passport_description_tabs > div { width: 94.5px; }
	div#passport_container #passport_controls > * > :not(div) { display: none; }
	div#passport_container #passport_controls > * { text-align: center; }
	div#passport_container #passport_crystals_values { display: flex; flex-wrap: wrap; }
	div#passport_container #passport_crystals_values::before, div#passport_container #passport_crystals_values::after { display: none; }
	
	div#passport_container .ruby_popup_lower { padding-left: 0px; padding-right: 0px; }
	div#passport_container .passport_category { border-left-width: 0; border-right-width: 0; border-radius: 0; padding: 2px 0px; }
	div#passport_container .passport_category::after { width: 100%; bottom: 2px; left: 0px; }
	div#passport_container #passport_tab_1 { display: flex; flex-direction: column; }
	div#passport_container .passport_category_caption { height: 20px; line-height: 20px; background: transparent; }
	div#passport_container .passport_category_icons { padding: 3px 0px; }
	div#passport_container #passport_tab_1 .passport_category_icons { height: 110px; }
}

/* Ruby popup: shop */
@media (max-width: 699px) {
	div#shop_category_container .card_object_header { width: calc(100% - 80px); }
}
@media (max-width: 399px) {
	div#shop_container .object_icon_container_big .object_icon { display: none; }
	div#shop_container .object_icon_container_big { height: fit-content; width: fit-content; padding: 5px 10px; }
	div#shop_container .shop_category_objects { min-height: 10px; height: 0px; }
	div#shop_container .input_price_override > label { display: none; }

	div#shop_container div.shop_category_objects, div#shop_container #shop_category_container div.ruby_popup_lower { height: fit-content; min-height: 10px; }
}

/* Ruby popup: card */
@media (max-width: 699px) {
	div#card_container div.card_object_header { width: calc(100% - 80px); }
	span.alter_card_main { max-height: 60px; display: inline-block; overflow-y: scroll; }
	#alter_card_usertext { max-height: 60px; }
	div#card_container div.passport_category { padding-top: 0px; padding-bottom: 0px; }

	.passport_top_button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 30px; display: none; }
	.passport_top_button::before { margin-left: 4px; }
}

/* Squeeze the card if the height of our page is too little */
@media (max-height: 719px) {
	div#passport_description { display: none; }
	div#passport_image img { height: 64px; width: 64px; min-height: initial; min-width: initial; object-position: top; }
	div#passport_container > div.ruby_popup_upper, div#passport_dossier { height: fit-content; padding-bottom: 0px; }
	div#passport_dossier > #passport_description_tabs { order: 2; padding-top: 5px; }
	div#passport_about { display: none; }
	div#passport_full_name { margin-bottom: 5px; }
	div#passport_description_tabs { padding-top: 10px; }
	span#shop_description_hideable { display: none; }

}

/* Ruby popup: balance log */
@media (max-width: 540px) {
	.action_balance_log :is(.col_number) { display: none; }
}
@media (max-width: 500px) {
	.action_balance_log :is(.col_number, .col_op_who, .col_cdelta, .col_gdelta, .col_mdelta) { display: none; }
	.action_balance_log .col__delta { display: block; }

	table#balance_log_table td.col__delta { width: 100%; }
}
