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

html, body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: #111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  padding: 24px 16px;
  display: flex;
  justify-content: flex-start;
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: 960px;
  margin-left: 56px;
}

@media (max-width: 700px) {
  .page { margin-left: 0; }
}

/* ── Header ── */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 2px solid #111;
  margin-bottom: 20px;
  /* Bleed the header slab to the left viewport edge */
  margin-left: -72px;
  padding-left: 72px;
  background: rgba(0, 0, 0, 0.03);
}

.site-header-identity {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.site-photo-link {
  display: block;
  border: 1px solid #aaa;
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  overflow: hidden;
}

.site-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.site-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.site-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0;
  letter-spacing: 0.02em;
}

.site-title a {
  text-decoration: none;
  color: inherit;
  transition: text-shadow 0.3s;
}

body.theme-dark .site-title a {
  text-shadow: 0 0 28px rgba(148, 60, 200, 0.3);
}

.site-subtitle {
  margin: 0;
  font-size: 0.88rem;
  color: #555;
  font-style: italic;
}

/* ── Nav ── */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid #aaa;
  align-self: flex-start;
}

.site-nav a {
  display: inline-block;
  padding: 5px 11px;
  font-size: 0.82rem;
  font-family: Arial, Helvetica, sans-serif;
  text-decoration: none;
  color: #111;
  border-right: 1px solid #aaa;
}

.site-nav a:last-child { border-right: none; }

.site-nav a:hover {
  background: #f0f0f0;
  color: #00c;
}

.site-nav a[aria-current="page"] {
  background: #111;
  color: #fff;
  font-weight: bold;
}

/* ── Main grid (home page) ── */
main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 700px) {
  main { grid-template-columns: 1fr; }
  .site-nav { width: 100%; }
  .site-nav a { border-bottom: 1px solid #aaa; border-right: none; }
  .site-nav a:last-child { border-bottom: none; }
}

/* ── Cards ── */
.card {
  border: 1px solid #bbb;
  padding: 14px 16px 14px 32px;
}

.card h2 {
  font-size: 1rem;
  margin: 0 0 8px -18px;
  padding-bottom: 4px;
  padding-left: 6px;
  border-bottom: 1px solid #ddd;
  border-left: 3px solid #999;
}

.card p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: #333;
}

.card a { color: #00c; }
.card a:hover { color: #c00; }

/* ── Link list (home page sidebar) ── */
.link-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.link-list li a {
  display: block;
  padding: 5px 8px;
  font-size: 0.88rem;
  background: #f7f7f7;
  border: 1px solid #ccc;
  color: #00c;
  text-decoration: none;
}

.link-list li a:hover {
  background: #eef;
  color: #c00;
}

/* ── Contact grid ── */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 4px;
}

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

.contact-grid h3 {
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.contact-grid p {
  margin: 0;
  font-size: 0.88rem;
}

/* Allow long email/URL strings to wrap inside contact cards */
.contact-grid a {
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* ── Footer ── */
.site-footer {
  margin-top: 20px;
  padding-top: 10px;
  border-top: 1px solid #bbb;
  font-size: 0.8rem;
  color: #555;
  font-family: Arial, Helvetica, sans-serif;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: space-between;
}

.footer-sep { color: #bbb; }

.site-footer a { color: #555; }
.site-footer a:hover { color: #00c; }

/* ── Theme toggle button ── */
.theme-toggle {
  align-self: flex-start;
  margin-left: auto;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: Arial, Helvetica, sans-serif;
  border: 1px solid #aaa;
  background: #f7f7f7;
  cursor: pointer;
}

.theme-toggle:hover {
  background: #eee;
}

/* ── Dark mode overrides ── */
body.theme-dark {
  background: #04040a;
  color: #f0f0f8;
}

body.theme-dark .page {
  color: inherit;
}

body.theme-dark .site-header {
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(to right, #5a1a70, #d96010, #00c898, #5a1a70) 1;
  background: rgba(255, 255, 255, 0.03);
}

body.theme-dark .site-photo-link {
  border-color: #444;
}

body.theme-dark .site-subtitle {
  color: #b5b5c7;
}

body.theme-dark .site-nav {
  border-color: #36304a;
  background: #0e0c16;
}

body.theme-dark .site-nav a {
  color: #f5f5f5;
  border-right-color: #3a3a4a;
  background: transparent;
}

body.theme-dark .site-nav a:hover {
  background: #222233;
  color: #9acbff;
}

body.theme-dark .site-nav a[aria-current="page"] {
  background: #ded5ff;
  color: #140e21;
}

body.theme-dark .card {
  border-color: #2e2840;
  background: #0e0c18;
}

body.theme-dark .card h2 {
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(to right, #8a38a8, #d46010, transparent) 1;
  border-left: 3px solid #5a5a8a;
}

body.theme-dark .card p {
  color: #e2e2f0;
}

body.theme-dark .card a {
  color: #9acbff;
}

body.theme-dark .card a:hover {
  color: #ff8330;
}

body.theme-dark .link-list li a, body.theme-dark td a {
  background: #151526;
  border-color: #303046;
  color: #9acbff;
}

body.theme-dark .link-list li a:hover {
  background: #1f1f32;
  color: #ff8330;
}

/* Publications page dark tweaks */
body.theme-dark .pub-list li {
  background: #1b1b2a;
  border-left-color: #4a4a6a;
}

body.theme-dark .pub-list li a {
  color: #9acbff;
}

body.theme-dark .pub-list li a:hover {
  color: #ff8330;
}

body.theme-dark .pub-list li em {
  color: #c0c0d5;
}

body.theme-dark .status-badge {
  background: #2a2a3d;
  border-color: #555577;
  color: #e2e2f0;
}

/* Conferences page dark tweaks */
body.theme-dark .event-list li {
  background: #1b1b2a;
  border-left-color: #4a4a6a;
}

body.theme-dark .event-date {
  color: #e2e2f0;
}

body.theme-dark .event-desc strong {
  color: #f5f5f5;
}

body.theme-dark .event-desc em {
  color: #c0c0d5;
}

body.theme-dark .event-list li a {
  color: #9acbff;
}

body.theme-dark .event-list li a:hover {
  color: #ff8330;
}

body.theme-dark .page-note a {
  color: #9acbff;
}

body.theme-dark .page-note {
  color: #c0c0d5;
}

/* Students & teaching page dark tweaks */
body.theme-dark .person-list li {
  background: #1b1b2a;
  border-left-color: #4a4a6a;
}

body.theme-dark .person-list li strong {
  color: #f5f5f5;
}

body.theme-dark .person-list li .person-note {
  color: #c0c0d5;
}

body.theme-dark .person-current strong::after {
  border-color: #666688;
  color: #d4d4ea;
}

body.theme-dark .person-list li a {
  color: #9acbff;
}

body.theme-dark .person-list li a:hover {
  color: #ff8330;
}

body.theme-dark .section-heading {
  border-bottom-color: #2e2840;
  color: #e2e2f0;
  padding-left: 10px;
  border-left: 3px solid #8a38a8;
}

body.theme-dark .teaching-table thead th {
  background: #181824;
  border-color: #3a3a4a;
}

body.theme-dark .teaching-table tbody tr:nth-child(even) td {
  background: #141420;
}

body.theme-dark .teaching-table tbody td {
  border-color: #34344a;
  color: #e2e2f0;
}

body.theme-dark .site-footer {
  border-top-color: #303046;
  color: #c0c0d5;
}

body.theme-dark .site-footer a {
  color: #c0c0d5;
}

body.theme-dark .site-footer a:hover {
  color: #9acbff;
}

body.theme-dark .theme-toggle {
  background: #151526;
  border-color: #3a3a4a;
  color: #f5f5f5;
}

body.theme-dark .theme-toggle:hover {
  background: #202036;
}

/* ── Gallery page ── */
.gallery-intro {
  font-size: 0.88rem;
  color: #444;
  margin: 0 0 20px;
  line-height: 1.6;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 12px;
}

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

.gallery-item figure {
  margin: 0;
  border: 1px solid #bbb;
  background: #fafafa;
  overflow: hidden;
}

.gallery-item figure img {
  display: block;
  width: 100%;
  height: auto;
}

.gallery-item figcaption {
  padding: 10px 12px 12px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #333;
  border-top: 1px solid #ddd;
}

.gallery-item figcaption .gallery-author {
  font-weight: bold;
  color: #111;
}

.gallery-item figcaption .gallery-paper a {
  color: #00c;
  text-decoration: none;
}

.gallery-item figcaption .gallery-paper a:hover {
  color: #c00;
}

/* ── Simulations hub ── */
.sim-hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

@media (max-width: 680px) {
  .sim-hub-grid { grid-template-columns: 1fr; }
}

.sim-hub-card {
  border: 1px solid #bbb;
  background: #fafafa;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: background 0.15s;
}

.sim-hub-card:hover {
  background: #eef;
  border-color: #99b;
}

.sim-hub-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #111;
}

.sim-hub-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #555;
  line-height: 1.5;
}

.sim-hub-card .sim-hub-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.72rem;
  font-family: Arial, Helvetica, sans-serif;
  padding: 1px 7px;
  border: 1px solid #aaa;
  color: #555;
}

/* ── Dark mode: gallery ── */
body.theme-dark .gallery-intro {
  color: #c0c0d5;
}

body.theme-dark .gallery-item figure {
  border-color: #303046;
  background: #10101b;
}

body.theme-dark .gallery-item figcaption {
  border-top-color: #2b2b3b;
  color: #c0c0d5;
}

body.theme-dark .gallery-item figcaption .gallery-author {
  color: #e2e2f0;
}

body.theme-dark .gallery-item figcaption .gallery-paper a {
  color: #9acbff;
}

body.theme-dark .gallery-item figcaption .gallery-paper a:hover {
  color: #ff8330;
}

/* ── Dark mode: simulations hub ── */
body.theme-dark .sim-hub-card {
  border-color: #303046;
  background: #10101b;
}

body.theme-dark .sim-hub-card:hover {
  background: #1a1a2e;
  border-color: #555577;
}

body.theme-dark .sim-hub-card h3 {
  color: #e2e2f0;
}

body.theme-dark .sim-hub-card p {
  color: #9090b0;
}

body.theme-dark .sim-hub-card .sim-hub-tag {
  border-color: #555577;
  color: #9090b0;
}

/* ── Decorative sidebar art (Fielding turbulence, Breaker-Design-style) ── */
/*
 * Right-side-only panel, visible in the natural gutter on wide viewports.
 * A mask gradient dissolves the inner edge so it fades into the page.
 * Light mode: present but quiet.  Dark mode: vivid.
 */
@media (min-width: 1140px) {
  body {
    /* Reserve space so the content column never runs into the decorative bar.
       Bar occupies everything right of the content (1032px) minus a 48px gap,
       capped at 420px on very wide monitors. */
    padding-right: min(420px, calc(100vw - 1080px));
  }

  body::after {
    content: '';
    position: fixed;
    right: 0;
    /* Extend 16px beyond the viewport top and bottom so the white
       margins of the source image fall outside the visible area. */
    top: -16px;
    height: calc(100vh + 32px);
    width: min(420px, calc(100vw - 1080px));
    background: url('images/fielding-turbulence.png') 20% center / cover no-repeat;
    opacity: 0.22;
    pointer-events: none;
    z-index: 0;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 35%);
            mask-image: linear-gradient(to right, transparent 0%, black 35%);
  }

  body.theme-dark::after {
    opacity: 0.72;
  }
}

/* Media page dark tweaks */
body.theme-dark .media-list li {
  background: #1b1b2a;
  border-left-color: #4a4a6a;
}

body.theme-dark .media-list li .media-outlet {
  color: #9090b0;
}

body.theme-dark .media-list li .media-title {
  color: #f5f5f5;
}

body.theme-dark .media-list li .media-title a {
  color: #9acbff;
}

body.theme-dark .media-list li .media-title a:hover {
  color: #ff8330;
}

body.theme-dark .media-list li .media-desc {
  color: #c0c0d5;
}
