/* ------------------------------------------------------------------
   Custom overrides for the Strata theme.
   Loaded after main.css.

   THE TYPE SCALE IS DEFINED PER BREAKPOINT, ON PURPOSE.

   Everything here is sized in em, relative to the body font size,
   which main.css changes at each breakpoint. So a single flat value
   like `h3 { font-size: 1.15em }` does NOT stay visually consistent:
   it renders small on a wide desktop and oversized on a phone, where
   the same proportion occupies far more of the screen.

   The fix is to set the base size AND the heading steps at each
   breakpoint, so the relationship between them is deliberate at every
   width instead of inherited by accident. All heading sizes live in
   section 2 -- change them there, not scattered through the file.
   ------------------------------------------------------------------ */

/* --- 1. Base size per breakpoint ----------------------------------- */

body, input, select, textarea {
	font-size: 17pt;			/* > 1800px */
	line-height: 1.7em;
}

@media screen and (max-width: 1800px) {
	body, input, select, textarea {
		font-size: 13.5pt;		/* laptops and desktops */
	}
}

@media screen and (max-width: 980px) {
	body, input, select, textarea {
		font-size: 12.5pt;		/* tablet, stacked layout */
	}
}

@media screen and (max-width: 736px) {
	body, input, select, textarea {
		font-size: 11.5pt;		/* phone -- the base has to come down
								   here or every em-sized heading above
								   it renders oversized */
	}
}

/* --- 2. Heading steps per breakpoint -------------------------------
   Desktop gets the largest steps because there is room for them; the
   phone gets smaller steps because the screen is narrow. This is what
   keeps the two looking like the same design.                        */

/* Desktop and laptop */
@media screen and (min-width: 981px) {
	#main h2 { font-size: 1.6em; }
	.work-item h3 { font-size: 1.12em; }
	.subhead { font-size: 1.2em; }
}

/* Tablet */
@media screen and (min-width: 737px) and (max-width: 980px) {
	#main h2 { font-size: 1.45em; }
	.work-item h3 { font-size: 1.1em; }
	.subhead { font-size: 1.15em; }
}

/* Phone */
@media screen and (max-width: 736px) {
	#main h2 { font-size: 1.35em; }
	.work-item h3 { font-size: 1.08em; }
	.subhead { font-size: 1.1em; }
}

#main h2 {
	line-height: 1.35em;
	margin: 0 0 1.1em 0;
}

.work-item h3 {
	line-height: 1.4em;
	margin: 0 0 0.7em 0;
}

/* --- 3. Colors and weights -----------------------------------------
   Headings are dark and bold (the theme ships them at weight 400, so
   they never actually looked bold); running text sits a step lighter
   so the headings carry the page.                                    */

body, input, select, textarea {
	color: #565656;
}

#main p, #main li, #main td {
	color: #565656;
}

h1, h2, h3, h4, h5, h6 {
	color: #222222;
	font-weight: 700;
}

strong, b {
	color: #333333;
	font-weight: 700;
}

a {
	color: #00539b;
}

a:hover {
	color: #0073d1 !important;
}

/* --- 4. Column geometry --------------------------------------------
   #header width and #main margin-left must always match. main.css
   also caps #main at 54em, which has to come up or the width freed by
   the narrower sidebar goes nowhere.                                 */

@media screen and (min-width: 1281px) {
	#header {
		width: 30%;
		padding: 3.5em 2em;
	}

	#main {
		margin-left: 30%;
		width: calc(100% - 30%);
		max-width: 76em;
		padding: 4.5em 4em 4em 4.5em;
	}
}

@media screen and (min-width: 981px) and (max-width: 1280px) {
	#header {
		width: 33.6%;
		padding: 3em 1.5em;
	}

	#main {
		margin-left: 33.6%;
		width: calc(100% - 33.6%);
		max-width: none;
		padding: 4em 3em;
	}
}

/* The sidebar is position: fixed with height: 100%, so its content
   has to be able to scroll on short windows or it gets clipped. */
@media screen and (min-width: 981px) {
	#header {
		overflow-y: auto;
	}

	#header > .inner {
		margin-bottom: 1em;
	}
}

/* --- 5. Sidebar ----------------------------------------------------
   A light wash over the photo takes it down a touch and seats the
   white text; a text shadow does the rest, so no heavy scrim is
   needed. See the note further down for why the photo itself is
   painted on a fixed layer on the side-by-side layout.               */

#header {
	background-size: auto, cover;
	background-position: top left, center center;
	background-repeat: repeat, no-repeat;
	color: #ffffff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 12px rgba(0, 0, 0, 0.5);
}

/* Light wash so the white text sits on the photo without dulling it. */
#header:before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(8, 14, 26, 0.2);
	pointer-events: none;
	z-index: 0;
}

/* THE BLACK BAND AT THE BOTTOM OF THE SIDEBAR.

   The sidebar needs `overflow-y: auto` (below) so its content is
   reachable on short windows. That makes it a scroll container, and a
   background painted on the element itself only covers the *client*
   box -- 820px in an 820px-high window -- not the ~900px scroll box.
   Scroll the column and the uncovered strip shows the #1f1815 base
   color, which reads as black behind the social icons. `cover` does
   not help: the problem is the scroll box, not the image size.

   So on the side-by-side layout the photo moves to a position: fixed
   layer pinned to the viewport, where it cannot scroll away. The
   width is repeated per breakpoint to match #header exactly. */
@media screen and (min-width: 981px) {
	#header {
		background-color: transparent;
		background-image: none;
	}

	#header:before {
		position: fixed;
		top: 0;
		left: 0;
		right: auto;
		bottom: 0;
		background-color: #1f1815;
		background-image:
			linear-gradient(rgba(8, 14, 26, 0.2), rgba(8, 14, 26, 0.2)),
			url("images/overlay.png"),
			url("../../images/bg.jpg");
		background-position: top left, top left, center center;
		background-repeat: repeat, repeat, no-repeat;
		background-size: auto, auto, cover;
	}
}

@media screen and (min-width: 1281px) {
	#header:before {
		width: 30%;
	}
}

@media screen and (min-width: 981px) and (max-width: 1280px) {
	#header:before {
		width: 33.6%;
	}
}

/* Keep the content above the wash. */
#header > * {
	position: relative;
	z-index: 1;
}

#header .image.avatar {
	width: 8.5em;
	margin: 0 0 1em 0;
}

#header .image.avatar img {
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

#header h1 {
	color: #ffffff;
	font-size: 1.65em;
	line-height: 1.35em;
	margin: 0 0 0.7em 0;
}

#header h1 strong {
	color: #ffffff;
	font-weight: 700;
}

/* Held just under 1em: the column is narrow enough that a larger size
   strands single words on their own line. */
#header h5 {
	color: #ffffff;
	font-size: 0.95em;
	font-weight: 400;
	line-height: 1.5em;
	margin: 0 0 1.15em 0;
}

#footer {
	color: #ffffff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

/* Social icons. The theme renders these at 40% white, which reads as
   dull gray against the photo. Instead: white glyphs on translucent
   discs, each taking its brand color on hover. */
#footer .icons {
	margin: 1.25em 0 0 0;
}

#footer .icons li {
	padding: 0 0.45em 0.5em 0;
}

#footer .icons a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.55em;
	height: 2.55em;
	border-radius: 50%;
	border-bottom: 0;
	background: rgba(255, 255, 255, 0.16);
	color: #ffffff;
	text-shadow: none;
	-moz-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, -moz-transform 0.2s ease-in-out;
	-webkit-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, -webkit-transform 0.2s ease-in-out;
	transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

#footer .icons a:before {
	font-size: 1.3em;
	line-height: 1;
}

#footer .icons a:hover {
	background: #ffffff;
	-moz-transform: translateY(-2px);
	-webkit-transform: translateY(-2px);
	transform: translateY(-2px);
}

#footer .icons a.fa-researchgate:hover { color: #00ccbb !important; }
#footer .icons a.fa-google:hover { color: #4285f4 !important; }
#footer .icons a.fa-linkedin:hover { color: #0a66c2 !important; }
#footer .icons a.fa-envelope:hover { color: #c0392b !important; }

/* Stacked layout: the sidebar becomes a full-width banner, so it can
   carry a larger photo and name. */
@media screen and (max-width: 980px) {
	#header .image.avatar {
		width: 10.5em;
	}

	#header h1 {
		font-size: 2.1em;
	}

	#header h5 {
		font-size: 1em;
	}
}

/* --- 6. Content layout --------------------------------------------- */

#main > section {
	margin: 3.5em 0 0 0;
	padding: 3.5em 0 0 0;
}

#main > section:first-of-type {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

/* Sub-headings inside the collaboration section. Indented a step so
   the theme heading above them stays the outermost level. */
.subhead {
	margin: 2em 0 1.25em 1.25em;
	padding-bottom: 0.4em;
	border-bottom: solid 2px #e9e9e9;
}

.subhead:first-of-type {
	margin-top: 0;
}

/* Long DOI URLs must not push the layout sideways. */
#main a {
	overflow-wrap: break-word;
	word-wrap: break-word;
}

/* --- 7. Publication entries ----------------------------------------
   Each entry reads title -> figure -> reference. The whole block is
   indented under its research-theme heading and capped at a single
   width, so the figure and every line of text share one left and one
   right edge.                                                        */

.work-item {
	margin: 0 0 3.25em 0;
	padding-left: 1.5em;
	border-left: solid 3px #ececec;
	-moz-transition: border-color 0.2s ease-in-out;
	-webkit-transition: border-color 0.2s ease-in-out;
	transition: border-color 0.2s ease-in-out;
}

.work-item:hover {
	border-left-color: #c8d8e8;
}

/* The indent that nests entries under their theme heading. It is on
   the row rather than the item so the item's own max-width still
   measures the text column itself. */
#main .row {
	padding-left: 2.25em;
}

/* Figures live in a fixed box rather than filling the block. The text
   now runs the full width of the column, so a figure at 100% would be
   enormous; instead each one scales down until it fits inside the box,
   limited by whichever of the two edges it reaches first.

   The source images range from nearly square (1.16:1) to very wide
   (2.42:1). A box of 34 x 16.5em lands almost all of them at roughly
   the same rendered width, which gives the list an even rhythm. */
.work-item .image.fit {
	display: inline-block;
	width: auto;
	max-width: 100%;
	margin: 0 0 1.1em 0;
	line-height: 0;
}

/* The 46vw half of this cap is load-bearing, not decoration. The
   anchor shrink-wraps the image, so a percentage max-width on the
   image would resolve against a width that depends on the image
   itself. Without a viewport-relative cap the widest figures pushed
   past the right edge of the window once the sidebar took 30% --
   42em is simply wider than the content column on a 1250-1400px
   screen. 46vw always fits, and 42em still wins on large monitors. */
.work-item .image.fit img {
	width: auto;
	height: auto;
	max-width: 42em;
	max-width: min(42em, 46vw);
	max-height: 20.5em;
	border-radius: 3px;
}

/* The box shrinks with the viewport rather than overflowing it. */
@media screen and (max-width: 980px) {
	.work-item .image.fit img {
		max-width: 100%;
	}
}

/* main.css sets `.work-item p { font-size: 0.8em }`, which outranks a
   bare `.citation` on specificity -- the reference text was rendering
   two steps smaller than intended. Qualifying with .work-item wins it
   back. */
.work-item .citation,
.work-item .conference,
.work-item .media,
.citation,
.conference,
.media,
.note {
	font-size: 1em;
	line-height: 1.65em;
	margin: 0 0 0.7em 0;
}

.work-item .conference,
.work-item .media {
	color: #6d6d6d;
}

.note {
	font-size: 0.92em;
	color: #6d6d6d;
}

.work-item p:last-child {
	margin-bottom: 0;
}

/* The author's own name, highlighted throughout the reference lists. */
.me {
	color: #1a1a1a;
	font-weight: 700;
	background: linear-gradient(transparent 62%, rgba(0, 105, 191, 0.18) 62%);
	padding: 0 0.08em;
}

.media-label {
	color: #444444;
	font-weight: 700;
}

.note {
	font-style: italic;
	border-left: solid 3px #ececec;
	padding-left: 1em;
}

.note .me {
	font-style: normal;
}

/* Stacked layout: drop the indent, which would eat the usable width. */
@media screen and (max-width: 736px) {
	#main .row {
		padding-left: 0;
	}

	.work-item {
		max-width: none;
		padding-left: 1em;
		margin-bottom: 2.75em;
	}

	.subhead {
		margin-left: 0;
	}
}

/* --- 8. Visitor map ------------------------------------------------
   A single server-rendered image, so it scales with plain CSS and the
   markers stay put. (The JavaScript widget drew its markers as a
   vector overlay that did not line up with its own raster background
   -- the dots landed in the ocean.)

   Sitting flush with the left edge of the contact column, a step
   further left than the email and address text.                      */

#visitor-map-wrapper {
	margin-top: 2.5em;
}

#visitor-map {
	display: block;
}

#visitor-map a {
	display: block;
	border-bottom: 0;
	max-width: 800px;
}

#visitor-map img {
	display: block;
	width: 100%;
	height: auto;
}

/* --- 9. Lightbox ---------------------------------------------------
   Clicking a figure opens it in the poptrox lightbox (see main.js,
   which had to be repointed at #main -- it was bound to a #two that
   no longer exists, so no lightbox was opening at all).

   The theme hides the close button until you hover the popup, and
   even then only at 50% opacity, which is easy to miss. It is now
   always visible as a solid cross, with a dark disc behind it so it
   stays legible over a light figure.                                 */

/* CONSISTENT POPUP SIZE.

   Poptrox sizes the popup to the image's natural size, capped at the
   window. The full-size figures range from 683 x 355 to 15700 x 6494,
   so one popup opened almost full-bleed while the next was a small
   card. Forcing a target width normalises them: every figure now opens
   at the same width, with height following its own aspect ratio and
   capped so tall images still fit on screen.

   1000px is chosen to sit near the middle of the sources, so the big
   ones scale down (sharp) and the small ones are only mildly enlarged.

   object-fit matters here: once max-height clamps a tall image, its
   box no longer matches the image's own ratio, and without `contain`
   the picture would be stretched to fill it. `contain` fits the
   picture inside the box instead, so nothing is ever distorted. */
.poptrox-popup .pic img {
	width: 1000px !important;
	height: auto !important;
	max-width: 88vw !important;
	max-height: 78vh !important;
	object-fit: contain !important;
}

.poptrox-popup .closer {
	opacity: 1 !important;
	color: #ffffff;
	z-index: 10;
}

.poptrox-popup .closer:before {
	background-color: rgba(20, 20, 20, 0.65);
	border: solid 3px rgba(255, 255, 255, 0.9);
	-moz-transition: background-color 0.2s ease-in-out;
	-webkit-transition: background-color 0.2s ease-in-out;
	transition: background-color 0.2s ease-in-out;
}

.poptrox-popup .closer:hover:before {
	background-color: rgba(200, 40, 40, 0.9);
}

/* Give the caption room and keep it readable. */
.poptrox-popup .caption {
	font-size: 0.95em;
	line-height: 1.5em;
}
