/*
 * goprb site: responsive layer.
 *
 * The pages are built on one outer table (marked with class "goprb-main"):
 *   row 1 - header: logo | title | picture
 *   row 2 - content: left column | problem + player | right column
 *   row 3 - footer
 *
 * On narrow screens the table is turned into a single column and reordered so
 * that the problem and its player come first, the navigation right below it,
 * and the side-column content after that.
 *
 * Loaded by every page together with Add/enc.css.
 */

/* ---------- all screen sizes ---------- */

img {
	max-width: 100%;
	height: auto;
}

/* the feedback form declares fixed pixel widths (480px inputs) in enc.css */
input,
textarea,
select {
	max-width: 100%;
	box-sizing: border-box;
}

.go-problem {
	max-width: 520px;
	margin: 0 auto;
}

/* Feedback form honeypot: people never see it, scripted submitters fill it in
   and get rejected by Add/msender.php. Kept off-screen rather than
   display:none, which simple bots know to skip. */
.goprb-trap {
	position: absolute;
	left: -9999px;
	top: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.goprb-form img#goprb-captcha {
	border: 1px solid #cfc9bb;
	border-radius: 3px;
	margin: 6px 0;
	max-width: 100%;
	height: auto;
}

.goprb-form .button {
	font: inherit;
	padding: 8px 14px;
	margin: 4px 0 8px;
	cursor: pointer;
}

/* ---------- narrow screens ----------\n   Breakpoint 1000px: below it the three-column table squeezes the board\n   under ~250px (a 768px tablet gave 213px), which is too small to solve on. */

@media (max-width: 1000px) {

	body {
		margin: 0;
		-webkit-text-size-adjust: 100%;
	}

	table.goprb-main {
		width: 100% !important;
		height: auto !important;
		border-spacing: 0 !important;
		table-layout: auto !important;
	}

	table.goprb-main > tbody > tr {
		display: flex;
		flex-direction: column;
	}

	table.goprb-main > tbody > tr > td {
		display: block;
		width: auto !important;
		max-width: 100% !important;
		height: auto !important;
		padding: 12px !important;
		box-sizing: border-box;
	}

	/* content row: problem + player first, side columns after it */
	table.goprb-main > tbody > tr:nth-child(2) > td:nth-child(2) {
		order: -1;
		padding-bottom: 0 !important;
	}

	/* header: keep the title on top, shrink the logo, drop the decorative image */
	table.goprb-main > tbody > tr:first-child > td:nth-child(2) {
		order: -1;
		padding-bottom: 0 !important;
	}

	table.goprb-main > tbody > tr:first-child > td:first-child img {
		width: 180px !important;
	}

	table.goprb-main > tbody > tr:first-child > td:nth-child(3) {
		display: none !important;
	}

	table.goprb-main h1 {
		font-size: 20px;
		line-height: 1.25;
		margin: 0;
	}

	/* separate the stacked blocks visually */
	table.goprb-main > tbody > tr:nth-child(2) > td + td {
		border-top: 1px solid #e0e0e0;
	}

	/* the navigation block of the left column sits directly under the player */
	table.goprb-main > tbody > tr:nth-child(2) > td:first-child center {
		font-size: 16px;
		line-height: 1.7;
	}

	/* nested tables (news, ad blocks injected by the PHP includes) must not
	   force the page wider than the screen */
	table.goprb-main td table {
		width: 100% !important;
		max-width: 100% !important;
	}

	table.goprb-main td table td {
		width: auto !important;
		white-space: normal !important;
	}

	/* long unbreakable strings (URLs, nobr links) */
	table.goprb-main td {
		overflow-wrap: break-word;
		word-wrap: break-word;
	}

	/* form fields size themselves from cols/size attributes, which would hold
	   the layout open; make them follow the container instead */
	input[type="text"],
	input[type="email"],
	textarea,
	select {
		width: 100% !important;
	}

	/* the paragraph indent of enc.css would push a full-width field off-screen */
	form,
	form p {
		text-indent: 0 !important;
	}

	/* comfortable touch targets on the feedback form */
	.goprb-form input[type="submit"],
	.goprb-form button {
		min-height: 44px;
		padding: 12px 18px;
	}

	.goprb-form input[type="text"],
	.goprb-form input[type="email"],
	.goprb-form textarea {
		font-size: 16px;   /* below 16px iOS zooms the page on focus */
	}

	table.goprb-main nobr {
		white-space: normal;
	}

	/* the player itself */
	.go-problem {
		max-width: 100%;
	}

	/* tsumego.css is linked after this file, so match its specificity */
	.wgo-tsumego .wgo-tsumego-comment {
		font-size: 16px;
	}

	.wgo-tsumego .wgo-tsumego-btn {
		font-size: 16px;
		padding: 12px 8px;
		min-height: 44px;   /* comfortable touch target */
	}

	.wgo-tsumego .wgo-tsumego-control {
		margin-top: 14px;
	}

	/* readable body text on a phone */
	table.goprb-main .maintext,
	table.goprb-main .maintexth1,
	table.goprb-main p,
	table.goprb-main li {
		font-size: 16px;
		line-height: 1.5;
	}
}

/* very small phones */
@media (max-width: 380px) {

	table.goprb-main > tbody > tr > td {
		padding: 8px !important;
	}

	table.goprb-main h1 {
		font-size: 18px;
	}
}
