/*
  AIM Micro: layout for other screen sizes
  Loaded after main.css. main.css is the fixed 960px desktop design; every rule
  in here except the first block is scoped to a viewport size, so between
  62em and 80em the desktop layout is untouched.
  Breakpoints are in em so they follow the reader's preferred text size.

  < 40em            one column: content, sidebar, extras, footer
  40em to < 62em    content + 270px sidebar, extras full width underneath
  62em to < 80em    main.css only (960px)
  >= 80em           main.css widened to 1200px (last block in this file)
----------------------------------------------- */

/* All widths: site.js wraps tables in article text so a wide one scrolls
   sideways instead of spilling out of its column. */
.table-wrapper {
	clear: both;	/* tables clear the floated article aside; keep that */
	overflow-x: auto;
	max-inline-size: 100%;
	margin: 0 0 20px 0;
}
.table-wrapper > table { margin-bottom: 0; }


@media (width < 62em) {

	*, *::before, *::after { box-sizing: border-box; }

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

	/* main.css sets 76% (about 12px) for the desktop design; use the reader's default here */
	body { font-size: 100%; }
	input, select, textarea, button { font-size: 1rem; }	/* 16px stops iOS zooming into fields */

	h1 { line-height: 1.15; }

	/* Issue section headings sit on an 18px GIF band in a bar of the same colour
	   as the text; keep them at their desktop size so the text stays on the band. */
	h2.section1, h2.section2, h2.section3, h2.section4, h2.section5 { font-size: 1.125rem; line-height: 1.1; }
	#lead h2 { font-size: clamp(1.5rem, 1rem + 2vw, 2rem); line-height: 1.1; }


	/* ---------- Shell: fluid width, no floats ---------- */

	#header, #container { width: auto; }
	#container { padding-inline: 0.75rem; }
	.threecols #container, .twocols #container { background: none; }	/* faux-column GIFs only fit 960px */

	#container > #colone,
	#container > #coltwo,
	#container > #colthree { float: none; width: auto; }
	#container > #colthree { margin-top: 0; }
	#container > #coltwo .colcontent { margin: 0; }

	.print #header, .print #container { width: auto; max-width: 550px; }


	/* ---------- Header: logo, nav, login, search ---------- */

	/* The logo and tagline are one 1024px GIF: show just the logo (first 226px)
	   and continue its white band and gradient behind it. */
	#header { background: linear-gradient(#fff 0 10px, #594b3a 10px, #4c4032 78px) #4c4032; padding-bottom: 0.75rem; }
	#header h1 { width: 226px; background: url(/images/ammark.gif) no-repeat 0 0; }

	#mainnav {
		float: none;
		display: flex;
		flex-wrap: wrap;
		flex-wrap: balance;
		gap: 4px;
		padding: 0 0.75rem;
	}
	#mainnav li { display: block; flex: 1 1 auto; }
	#mainnav a:link, #mainnav a:visited {
		float: none;
		margin: 0;
		padding: 0.6em 0.9em;
		text-align: center;
	}

	p.log { text-align: left; margin: 0.6em 0.75rem 0; font-size: 0.8125rem; }

	#search {
		position: static;
		width: auto;
		margin: 0.6em 0.75rem 0;
		border: 2px solid #c2c2aa;
		border-top-width: 3px;
	}
	#search fieldset { display: flex; gap: 0.5em; }
	#srchfld { flex: 1 1 auto; min-width: 0; }


	/* ---------- Sidebar widgets ---------- */

	/* Micro numbers: stretch the pink banner past its 244px GIF */
	#coltwo ul#micronumbers {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		background:
			url(/images/bgmicronumbers.gif) no-repeat 0 0,
			linear-gradient(#ca0743 0 24px, #fff 24px 25px, #e5e5ce 25px);
	}
	#coltwo ul#micronumbers li,
	#coltwo ul#micronumbers li.one,
	#coltwo ul#micronumbers li.two { float: none; width: auto; display: flex; }
	#coltwo ul#micronumbers li a { flex: 1 1 auto; width: auto; height: auto; min-height: 112px; padding: 0 0.5em 0.75em; }
	#coltwo ul#micronumbers li span { font-size: 250%; padding: 0.5em 0; }


	/* Tag cloud: the tags are output with no space between them, so make each
	   one a box the line can break between. */
	.tagcloud a:link, .tagcloud a:visited { display: inline-block; line-height: 1.5; margin-block: 0.25em; }


	/* ---------- Archive and issue pages ---------- */

	#colone #allissues {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
		gap: 0.5rem;
	}
	#colone #allissues li { float: none; margin: 0; display: flex; }
	#allissues a:link, #allissues a:visited { flex: 1 1 auto; width: auto; height: auto; margin: 6px; }

	.issueed { float: none; width: auto; height: auto; padding: 10px; }
	#issuecnt { float: none; margin-top: 10px; }


	/* ---------- Article page ---------- */

	#colone .article-aside { float: none; width: auto; margin: 0 0 1.5em 0; }
	#colone .article-aside .colcontent { margin: 0; }
	#colone .arttool > summary { padding-block: 0.6em; }


	/* ---------- Forms ---------- */

	#member label, #login label { float: none; width: auto; }
	#member input, #login input { width: 100%; max-width: 20rem; }
	#member textarea { width: 100%; }
	input[type="text"], input[type="email"], input[type="search"],
	input[type="password"], select, textarea { max-width: 100%; }


	/* ---------- Footer ---------- */

	#footer ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25em 0.75em; }
}


/* Tablet: content + sidebar side by side, extras underneath */
@media (40em <= width < 62em) {

	.threecols #container,
	.twocols #container { display: grid; }
	#container::after { content: none; }	/* the clearfix pseudo-element would become a grid item */

	.threecols #container {
		grid-template-columns: minmax(0, 1fr) 270px;
		grid-template-areas:
			"main  side"
			"extra extra"
			"foot  foot";
	}
	.twocols #container {
		grid-template-columns: minmax(0, 1fr) 180px;
		column-gap: 10px;
		grid-template-areas:
			"main  extra"
			"foot  foot";
	}

	#container > #colone   { grid-area: main; }
	#container > #coltwo   { grid-area: side; }
	#container > #colthree { grid-area: extra; }
	#container > #footer   { grid-area: foot; }

	#container > #coltwo .colcontent { margin: 0 0 0 20px; }
	.threecols #container > #colthree { margin-top: 1em; }
}


/* Wide screens: the desktop design 1200px across instead of 960px.
   The sidebars keep their widths (270px and 180px) and the main column gets
   all the extra room, so nothing inside the sidebars changes. 80em is 1280px
   at the default text size, leaving a margin either side.
   The printer-friendly page (body.print) stays as it is. */
@media (width >= 80em) {

	.threecols #header, .twocols #header,
	.threecols #container, .twocols #container { width: 1200px; }

	/* The logo and tagline GIF is 1024px wide: continue its white band and gradient after it */
	.threecols #header, .twocols #header {
		background:
			url(/images/ammark.gif) no-repeat 0 0,
			linear-gradient(#fff 0 10px, #594b3a 10px, #4c4032 78px) #4c4032;
	}

	/* The column lines bgthreecols.gif / bgtwocols.gif drew for 960px, measured
	   from the right so they stay beside the sidebars: 1px #b8d9ec, 429px and
	   180px in from the right edge. */
	.threecols #container {
		background:
			linear-gradient(#b8d9ec, #b8d9ec) no-repeat right 429px top 0 / 1px 100%,
			linear-gradient(#b8d9ec, #b8d9ec) no-repeat right 180px top 0 / 1px 100%;
	}
	.twocols #container {
		background: linear-gradient(#b8d9ec, #b8d9ec) no-repeat right 180px top 0 / 1px 100%;
	}

	.threecols #colone { width: calc(100% - 450px); }	/* 750px: 1200 less 270 + 180 */
	.twocols #colone { width: calc(100% - 190px); }		/* 1010px: 1200 less 180 and the 10px gap */

	/* Heading bands drawn by fixed-width GIFs, continued across the wider column. */

	/* bgdots.gif (509px, opaque): its chevron is in columns 12-28 and the rest
	   repeats every 2px, so stack copies at even offsets, each hiding the next one's chevron. */
	:is(.threecols, .twocols) #colone :is(dl.coltitle, .sitefeeds, .sitefeeds li) {
		background-image: url(/images/bgdots.gif), url(/images/bgdots.gif), url(/images/bgdots.gif);
		background-repeat: no-repeat;
		background-position: 0 0, 470px 0, 940px 0;
	}

	/* bgsec.gif (600px): a white band with the chevron cut out, over the section
	   colour. Continue the white so the bars look as they do at 960px: no
	   coloured block at the end in three columns, a 170px one in two. */
	:is(.threecols, .twocols) #colone :is(h2.section1, h2.section2, h2.section3, h2.section4, h2.section5,
		p.sectitle5, p.sectitle6, p.sectitle7, p.sectitle8, p.sectitle9, p.sectitle11) {
		background-image: url(/images/bgsec.gif), linear-gradient(#fff, #fff);
		background-repeat: no-repeat;
		background-position: 0 100%, 600px 100%;
		background-size: auto, calc(100% - 600px) 18px;
	}
	.twocols #colone :is(h2.section1, h2.section2, h2.section3, h2.section4, h2.section5,
		p.sectitle5, p.sectitle6, p.sectitle7, p.sectitle8, p.sectitle9, p.sectitle11) {
		background-size: auto, calc(100% - 770px) 18px;
	}

	/* Archive: the issue boxes are 246px plus margins, so three need 754px; fill the row instead */
	#colone #allissues { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 10px 8px; }
	#colone #allissues li { float: none; margin: 0; }
	#allissues a:link, #allissues a:visited { width: auto; }
}


/* Digest pages (blog/entry) on desktop: the same three columns, laid out as a
   grid so the middle column runs the full height of the page and its
   "In this digest" index can stay in view while the digest scrolls.
   The company list at the top of the digest is left for phones. */
@media (width >= 62em) {
	.digest-page #container {display: grid; grid-template-columns: 510px 270px 180px; align-items: stretch;}
	.digest-page #container::after {content: none;}	/* the clearfix pseudo-element would become a grid item */
	.digest-page #colone, .digest-page #coltwo, .digest-page #colthree {float: none; width: auto;}
	.digest-page #container > #footer {grid-column: 1 / -1;}
	.digest-page #coltwo > .colcontent {position: sticky; top: 0; max-height: 100dvh; overflow-y: auto;}
	.digest-page:has(.digest-index) .digest-companies {display: none;}	/* only when the index is there to replace it */
}
@media (width >= 80em) {
	.digest-page #container {grid-template-columns: minmax(0, 1fr) 270px 180px;}
}
