/* ==========================================================================
   Mondrian theme for John V. Kramer
   De Stijl grid — adapted from the Mondrian design system in
   github.com/jpgsantos/jpgsantos.github.io (palette, rules, primary blocks).
   Self-contained: no build step required.
   ========================================================================== */

:root {
  --ink: #0d0d0d;
  --paper: #f6f3ec;
  --paper-soft: #ece7da;
  --text: #14110f;
  --text-soft: #4a4540;
  --red: #e63946;
  --blue: #1d4ed8;
  --yellow: #facc15;
  --rule: 4px;
  --font-sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "Playfair Display", Georgia, serif;
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 0.6rem;
}

/* ---- Site header bar (used on subpages) ---------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  background: var(--paper);
  border-bottom: var(--rule) solid var(--ink);
}
.site-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.site-nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  transition: background 0.15s ease, color 0.15s ease;
}
.site-nav a:hover { background: var(--ink); color: var(--paper); }
.site-nav a[aria-current="page"] { background: var(--yellow); }

/* ==========================================================================
   Landing grid
   ========================================================================== */
.home {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2.5rem);
}

.home-grid {
  display: grid;
  gap: var(--rule);
  background: var(--ink);
  border: var(--rule) solid var(--ink);
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: minmax(72px, auto);
  grid-template-areas:
    "name     name     name     red      photo"
    "name     name     name     yellow   photo"
    "research research cv       teaching contact"
    "research research blue     teaching contact"
    "misc     misc     misc     misc     extra";
}

.tile {
  background: var(--paper);
  padding: clamp(1.1rem, 2.2vw, 1.9rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

/* Name / intro */
.tile--name { grid-area: name; gap: 0.4rem; justify-content: flex-start; }
.tile--name h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 1.6rem + 3.8vw, 4.2rem);
  line-height: 1.02;
  margin: 0.2rem 0 0.6rem;
}
.tile--name p.lede {
  margin: 0;
  font-size: clamp(1rem, 0.96rem + 0.3vw, 1.15rem);
  color: var(--text-soft);
  max-width: 46ch;
}
.tile--name .bio { margin: 0; }
.tile--name .bio p {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-soft);
  max-width: none;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.tile--name .bio p:last-child { margin-bottom: 0; }

/* Photo */
.tile--photo {
  grid-area: photo;
  background: var(--paper-soft);
  padding: 0;
  overflow: hidden;
}
.tile--photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; display: block; }
.tile--photo .photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 180px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.4rem);
  color: var(--text-soft);
  letter-spacing: 0.05em;
}

/* Decorative primary blocks */
.tile--red    { grid-area: red;    background: var(--red); }
.tile--yellow { grid-area: yellow; background: var(--yellow); }
.tile--blue   { grid-area: blue;   background: var(--blue); }

/* Navigation tiles */
.nav-tile {
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}
.nav-tile .nav-label {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
}
.nav-tile .nav-sub {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 0.35rem;
}
.nav-tile .arrow { font-weight: 700; font-size: 1.4rem; line-height: 1; }
.nav-tile:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--ink); z-index: 2; }
.nav-tile:focus-visible { outline: 4px solid var(--blue); outline-offset: -4px; }

/* Research = primary, dominant */
.tile--research {
  grid-area: research;
  background: var(--blue);
  color: #fff;
  gap: 0.5rem;
}
.tile--research .eyebrow { color: rgba(255, 255, 255, 0.8); }
.tile--research .nav-label { font-size: clamp(2.2rem, 1.4rem + 3.2vw, 3.6rem); }
.tile--research .nav-sub { color: rgba(255, 255, 255, 0.85); }
.tile--research:hover { box-shadow: 6px 6px 0 var(--ink); }

.tile--cv       { grid-area: cv; }
.tile--teaching { grid-area: teaching; }
.tile--contact  { grid-area: contact; background: var(--red); color: #fff; }
.tile--contact .nav-sub { color: rgba(255, 255, 255, 0.85); }

.tile--cv .nav-label,
.tile--teaching .nav-label,
.tile--contact .nav-label { font-size: clamp(1.4rem, 1rem + 1.4vw, 1.9rem); }

/* Miscellaneous = wide bottom strip */
.tile--misc {
  grid-area: misc;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--yellow);
}
.tile--misc .nav-label { font-size: clamp(1.4rem, 1rem + 1.4vw, 1.9rem); }
.tile--misc .nav-sub { margin-top: 0; }
.tile--extra { grid-area: extra; background: var(--blue); }

/* ==========================================================================
   Content pages (Research, Teaching, Contact)
   ========================================================================== */
.page {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 1.5rem + 3vw, 3.4rem);
  line-height: 1.05;
  margin: 0.2rem 0 2rem;
  position: relative;
  padding-bottom: 1rem;
}
.page-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 120px;
  height: var(--rule);
  background: var(--red);
}

.section { margin-bottom: 3rem; }
.section > h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 1.2rem;
  padding-left: 0.85rem;
  border-left: var(--rule) solid var(--blue);
}

/* Publication / paper cards */
.paper {
  border: 3px solid var(--ink);
  background: var(--paper);
  padding: 0.95rem 1.15rem;
  margin-bottom: 0.8rem;
  box-shadow: 5px 5px 0 var(--ink);
}
.paper h3 {
  font-family: var(--font-display);
  font-size: 1.12rem;
  margin: 0 0 0.15rem;
  line-height: 1.22;
}
.paper .authors { color: var(--text-soft); margin: 0; font-size: 0.9rem; }
.paper .venue { font-weight: 600; margin: 0.05rem 0 0; font-size: 0.9rem; }
.paper .venue em { font-style: italic; }
.paper .paper-links { margin-top: 0.55rem; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.4rem; }
.paper .paper-links a {
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  transition: background 0.15s ease, color 0.15s ease;
}
.paper .paper-links a:hover { background: var(--ink); color: var(--paper); }
.paper .tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  margin-left: 0.4rem;
  background: var(--yellow);
  vertical-align: middle;
}
.paper .authors a { color: var(--blue); text-decoration: none; border-bottom: 1px solid currentColor; }
.paper .authors a:hover { background: var(--blue); color: #fff; border-bottom-color: transparent; }

/* Expandable abstract — inline button in the links row, leftmost */
.abstract-toggle { margin: 0; }
.abstract-toggle[open] { flex-basis: 100%; }
.abstract-toggle > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  transition: background 0.15s ease, color 0.15s ease;
  width: max-content;
}
.abstract-toggle > summary::-webkit-details-marker { display: none; }
.abstract-toggle > summary::after { content: "+"; font-size: 0.9rem; line-height: 1; }
.abstract-toggle[open] > summary::after { content: "\2013"; }
.abstract-toggle > summary:hover { background: var(--ink); color: var(--paper); }
.abstract-toggle .abstract {
  margin-top: 0.55rem;
  padding: 0.8rem 1rem;
  background: var(--paper-soft);
  border-left: var(--rule) solid var(--yellow);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}
.abstract-toggle .abstract p { margin: 0; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }

/* Generic content rows (teaching, contact) */
.entry { margin-bottom: 1.4rem; }
.entry .when {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.entry .what { font-size: 1.05rem; font-weight: 600; margin: 0.1rem 0; }
.entry .detail { color: var(--text-soft); margin: 0; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--rule);
  background: var(--ink);
  border: var(--rule) solid var(--ink);
}
.contact-card {
  background: var(--paper);
  padding: 1.3rem 1.4rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.contact-card:hover { background: var(--ink); color: var(--paper); }
.contact-card--static { cursor: default; }
.contact-card--static:hover { background: var(--paper); color: inherit; }
.contact-card--static:hover .label { color: var(--text-soft); }
.contact-card .label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.contact-card:hover .label { color: var(--paper); }
.contact-card .value { font-weight: 600; margin-top: 0.25rem; word-break: break-word; }

.address-block {
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 1.2rem 1.4rem;
  margin-top: 1.5rem;
  background: var(--paper);
}
.address-block p { margin: 0.15rem 0; }

/* ---- Footer -------------------------------------------------------------- */
.site-footer {
  border-top: var(--rule) solid var(--ink);
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-soft);
  max-width: var(--maxw);
  margin: 2rem auto 0;
}
.site-footer a { font-weight: 600; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 820px) {
  .home-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      "name     name"
      "photo    photo"
      "red      yellow"
      "research research"
      "cv       teaching"
      "contact  blue"
      "misc     misc"
      "extra    extra";
  }
  .tile--photo .photo-placeholder { min-height: 220px; }
  .tile--red, .tile--yellow, .tile--blue, .tile--extra { min-height: 56px; }
}

@media (max-width: 480px) {
  .home-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name     name"
      "photo    photo"
      "red      yellow"
      "research research"
      "cv       cv"
      "teaching teaching"
      "contact  contact"
      "misc     misc"
      "blue     blue"
      "extra    extra";
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-tile, .nav-tile:hover { transform: none; transition: none; }
}
