/* style.css -- starter theme for the Cox Group site
   Edit freely; nothing here is generated, it's all yours. */

:root {
  --accent: #7E317B;
  --accent-rgb: 126, 49, 123;
  --text: #222;
  --muted: #666;
  --bg: #fff;
  --max-width: 800px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

#site-header {
  background: var(--accent);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

#site-header nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 1.2rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

#site-header nav a:hover { opacity: 1; text-decoration: underline; }

#content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

#content h1 { font-size: 1.8rem; margin-top: 0; }
#content h2 { font-size: 1.3rem; color: var(--accent); margin-top: 2rem; }

#content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.2rem 0;
  border-radius: 4px;
}

/* Durham logo: keep it a modest badge, not a full-width banner */
#content .org-svg {
  max-width: 220px;
  margin-left: auto;
  margin-right: auto;
}

figure {
  margin: 0;
}

a { color: var(--accent); }

#site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid #eee;
}

#site-footer .generated { color: #767676; }

/* Simple responsive nav wrap on narrow screens */
@media (max-width: 600px) {
  #site-header { flex-direction: column; align-items: flex-start; }
  #site-header nav a { margin-left: 0; margin-right: 1rem; }
}

.people-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1.5rem 0 2.5rem;
}

.person {
  flex: 1 1 220px;
  max-width: 260px;
  text-align: center;
}

#content .person-photo {
  border-radius: 50%;
  width: 160px;
  height: 160px;
  object-fit: cover;
  margin: 0 auto 0.8rem;
}

.person p {
  font-size: 0.92rem;
  margin: 0.4rem 0;
}

/* Publications list */
.pub {
  margin: 1.4rem 0;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid #eee;
}

.pub p { margin: 0.3rem 0; }

/* News */
.news {
  margin: 1.6rem 0 2.4rem;
  padding-bottom: 1.6rem;
  border-bottom: 3px solid #eee;
}

.news .figure {
  text-align: center;
}

.news .figure img {
  max-width: 80%;
  margin: 0.8rem auto;
}

/* Join us page: make the contact links read as calls-to-action */
#content a[href^="mailto:"] {
  font-weight: 600;
  border-bottom: 1px solid var(--accent);
}

/* Research page: paper thumbnail + link, side by side */
.paper-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.paper-link .figure {
  flex: 0 0 auto;
  margin: 0;
}

.paper-link img {
  width: 200px;
  height: auto;
  border-radius: 4px;
  margin: 0;
}

.paper-link p:last-child {
  margin: 0;
}

@media (max-width: 500px) {
  .paper-link { flex-direction: column; align-items: flex-start; }
  .paper-link img { width: 100%; max-width: 220px; }
}

/* Homepage tiles: clickable image with overlaid caption */
.tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  margin: 1.8rem 0;
  text-decoration: none;
  line-height: 0; /* avoid whitespace gap under inline img */
}

/* Both homepage tiles share the same responsive aspect ratio, so
   height scales with the tile's (viewport-driven) width instead of
   being pinned to a fixed pixel value. */
.tile img {
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  display: block;
  margin: 0;
  border-radius: 0;
}

/* The "Meet the team" tile is a single static photo (not the carousel) -
   bias the crop toward the top so heads aren't cut off by the wide box. */
.tile > img {
  object-position: top;
}

.tile-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 0.9rem 1rem;
  font-weight: 600;
  font-size: 1.05rem;
  text-align: center;
  line-height: 1.3;
  transition: background 0.2s ease;
}

.tile:hover .tile-caption,
.tile:focus-visible .tile-caption {
  background: rgba(var(--accent-rgb), 0.85);
}

/* Rotating carousel of thumbnails behind the "Research" tile caption.
   Pure CSS - no JS. Each image gets an equal slice of one shared loop,
   offset by animation-delay so only one is visible at a time. */
.tile-carousel {
  position: relative;
  width: 100%;
  aspect-ratio: 21 / 9;
}

.tile-carousel img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: tile-carousel-fade 24s infinite;
}

/* 6 images -> 4s each; stagger the start of each by one slot */
.tile-carousel img:nth-child(1) { animation-delay: 0s; }
.tile-carousel img:nth-child(2) { animation-delay: 4s; }
.tile-carousel img:nth-child(3) { animation-delay: 8s; }
.tile-carousel img:nth-child(4) { animation-delay: 12s; }
.tile-carousel img:nth-child(5) { animation-delay: 16s; }
.tile-carousel img:nth-child(6) { animation-delay: 20s; }

/* Fallback so something shows even if animations are disabled */
.tile-carousel img:first-child { opacity: 1; }

@keyframes tile-carousel-fade {
  0%    { opacity: 0; }
  2%    { opacity: 1; }
  14%   { opacity: 1; }
  16.7% { opacity: 0; }
  100%  { opacity: 0; }
}

/* Respect reduced-motion: freeze on the first slide instead of fading */
@media (prefers-reduced-motion: reduce) {
  .tile-carousel img {
    animation: none;
  }
}
