/*
   Stylesheet for the Y. D. Chong research group website.
   Modern refresh: flexbox/grid layout, system font stack, rem units,
   responsive without JavaScript.  Visual identity (sidebar buttons,
   blue palette, header image) preserved from the original design.
*/

/* ---------- Base ---------- */

html {
    font-size: 100%; /* respect the user's browser font size (16px default) */
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto,
	"Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    background: #fcfcff;
    color: #2e3436;
    margin: 0;
}

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

/* ---------- Links and focus ---------- */

a {
    color: #204a87;
}

a:visited {
    color: #5c3566;
}

a:hover {
    color: #3465a4;
}

:focus-visible {
    outline: 3px solid #3465a4;
    outline-offset: 2px;
}

/* Skip-to-content link: hidden until focused */
.skip-link {
    position: absolute;
    top: -4rem;
    left: 0.5rem;
    z-index: 10;
    background: #204a87;
    color: #ffffff;
    padding: 0.5rem 1rem;
    text-decoration: none;
}

.skip-link:focus-visible {
    top: 0;
}

/* ---------- Headings ---------- */

h2 {
    color: #3465a4;
    font-size: 1.6rem;
    line-height: 1.25;
    margin: 0 0 0.5rem;
}

h3 {
    color: #3465a4;
    font-size: 1.2rem;
    margin: 1.5rem 0 0.4rem;
}

.subheading {
    color: #5f615c;
    font-size: 0.9rem;
}

.blue-text {
    color: #204a87;
    font-size: 1.2rem;
}

cite {
    font-style: italic;
}

/* ---------- Overall layout ---------- */

#canvas {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    max-width: 75rem;
    margin: 0 auto;
    padding: 0.75rem;
    box-sizing: border-box;
}

#main {
    flex: 1 1 auto;
    min-width: 0; /* allow the fluid column to shrink without overflow */
    padding: 0.25rem 0.5rem 1rem;
}

/* Limit the reading measure; photo grids use the full main width. */
#main :where(p, ul, ol, dl, h2, h3, .subheading) {
    max-width: 72ch;
}

#main :where(.members-grid, .alumni) {
    max-width: none;
}

#main li {
    margin-bottom: 0.5em;
}

#main a {
    overflow-wrap: break-word;
}

#main pre {
    overflow-x: auto;
    font-size: 0.75rem;
}

#footer {
    padding: 0.5rem;
}

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

#sb {
    flex: 0 0 13.75rem; /* ~220px column */
}

#sb ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sb-ref,
.sb-img,
.sb-title,
.sb-here {
    display: block;
    padding: 0.6rem 0.75rem;
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1.4;
    text-decoration: none;
    border-radius: 0.2rem;
}

.sb-ref,
.sb-img {
    background: #204a87;
    color: #d3d7cf;
}

.sb-ref:visited,
.sb-img:visited {
    color: #d3d7cf;
}

.sb-ref:hover,
.sb-img:hover {
    background: #729fcf;
    color: #16283f; /* dark enough for AA contrast on the light blue */
}

.sb-title {
    background: #eeeeec;
    color: #204a87;
    border: 2px solid #204a87;
}

.sb-title:visited {
    color: #204a87;
}

.sb-title:hover {
    background: #c6dcf2;
}

/* "You are here" marker for the current page (aria-current="page"). */
.sb-here {
    background: #275ba6;
    color: #ffffff;
    box-shadow: inset 0.25rem 0 0 #729fcf;
}

/* NTU logo button */
.sb-img {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sb-button-img img {
    display: block;
    height: 3.75rem; /* matches the height="60" attribute */
    width: auto;
}

/* Subtle hover transitions, disabled when reduced motion is requested. */
.sb-ref,
.sb-img,
.sb-title {
    transition: background-color 0.15s ease, color 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
    .sb-ref,
    .sb-img,
    .sb-title {
	transition: none;
    }
}

/* ---------- Header image with overlay title (index) ---------- */

#header-image {
    position: relative;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

#header-image img {
    display: block;
    width: 100%;
    height: clamp(7rem, 22vw, 13rem);
    object-fit: cover;
}

#main-title-text {
    position: absolute;
    top: clamp(0.75rem, 3vw, 1.5rem);
    left: clamp(0.75rem, 3vw, 1.5rem);
    max-width: 80%;
    color: #ffffff;
    font-size: clamp(1.3rem, 4vw, 2.2rem);
    line-height: 1.2;
    background: rgba(0, 0, 0, 0.55);
    padding: 0.5em 0.75em;
}

/* ---------- Figures ---------- */

.imgfloat {
    float: right;
    margin: 0.25rem 0 0.75rem 1rem;
    padding: 0.25rem;
    border: 1px solid #3465a4;
    width: 15.625rem; /* 250px */
    max-width: 45%;
    box-sizing: border-box;
}

.floated-image {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.img-float-left {
    display: block;
    margin-left: 0;
    margin-right: auto;
    max-width: 37.5rem;
    padding: 0.2rem;
    background: #dddde6;
}

.img-caption {
    font-size: 0.8rem;
    color: #3465a4;
}

/* ---------- Members page ---------- */

.members-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    list-style: none;
    padding: 0;
    font-size: 0.95rem;
}

.members-grid > li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.member-photo {
    flex: 0 0 auto;
    margin-top: 0.25rem;
}

.member-photo img {
    display: block;
}

.member-data {
    min-width: 0;
}

.alumni {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 0;
    margin-top: 1rem;
}

.alumni-box {
    font-size: 0.88rem;
}

.alumni-box img {
    display: block;
}

.alumni-box p {
    margin: 0.3rem 0 0;
}

/* ---------- Contact page ---------- */

.contact-info {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.15rem 0.75rem;
}

.contact-info dt {
    font-weight: bold;
}

.contact-info dd {
    margin: 0;
}

/* ---------- Publications page ---------- */

.top-level-list {
    padding-left: 1.5em;
}

/* ---------- Responsive ---------- */

/* Below 800px: sidebar becomes a wrapped horizontal row of buttons. */
@media (max-width: 800px) {
    #canvas {
	flex-direction: column;
	gap: 0.5rem;
    }

    #sb {
	flex: none;
	width: 100%;
    }

    #sb ul {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 0.3rem;
    }

    #sb li {
	display: contents; /* let the buttons themselves wrap */
    }

    .sb-ref,
    .sb-img,
    .sb-title,
    .sb-here {
	padding: 0.35rem 0.6rem;
	font-size: 0.85rem;
    }

    .sb-button-img img {
	height: 1.4rem;
    }

    #main {
	padding: 0.25rem;
    }
}

@media (max-width: 600px) {
    .members-grid {
	grid-template-columns: 1fr;
    }

    .imgfloat {
	float: none;
	max-width: 100%;
	margin: 0.75rem auto;
    }
}
