/* ==========================================================================
   Knowledge Science & Technology — site stylesheet
   Hand-written replacement for the RapidWeaver/Stacks/Foundation output.
   No build step, no JS framework — just HTML + this file.
   ========================================================================== */

:root {
  --navy: #1d2d7a;
  --green-dark: #3f5a2a;
  --green-mid: #4a6b32;
  --red-link: #c0392b;
  --tan-bg: #e9e2d3;
  --tan-bg-pattern: #ded4bd;
  --text: #222;
  --max-width: 900px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--tan-bg);
  background-image: radial-gradient(var(--tan-bg-pattern) 1px, transparent 1px);
  background-size: 8px 8px;
  line-height: 1.5;
}

a { color: var(--red-link); }
a:hover { text-decoration: none; }

/* ---- Header ---- */

.site-header {
  background: var(--navy);
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 1rem;
  font-size: 2.1rem;
  font-weight: 800;
}

.site-header p {
  margin: 0;
  color: #d6e7c3;
  font-size: 1.1rem;
  font-weight: 600;
}

.fast-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.fast-link {
  text-align: center;
  padding: 0.5rem 1rem;
}

.fast-link a {
  color: var(--red-link);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---- Banner (dark green strip under header) ---- */

.site-banner {
  background: var(--green-dark);
  color: #fff;
  text-align: center;
  padding: 0.6rem 1rem;
  font-weight: 600;
}

/* ---- Main content ---- */

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

main h2 {
  color: var(--green-dark);
  font-size: 1.3rem;
  margin: 1.6rem 0 0.5rem;
}

main h3 {
  color: var(--green-dark);
  font-size: 1.1rem;
  margin: 1.3rem 0 0.4rem;
}

.lead-figure {
  float: right;
  width: 400px;
  margin: 0 0 1rem 1.5rem;
  text-align: center;
}

.lead-figure img {
  width: 100%;
  height: auto;
  border: 1px solid #b9ae92;
}

.lead-figure figcaption {
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.3rem;
}

.photo-cycle {
  cursor: pointer;
  user-select: none;
}

.photo-cycle:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 3px;
}

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

.home-view {
  text-align: center;
  margin: 2rem 0;
}

.home-view img {
  max-width: 320px;
  width: 100%;
  height: auto;
  border: 1px solid #b9ae92;
}

.home-view figcaption {
  font-size: 0.9rem;
  color: #555;
  margin-top: 0.4rem;
}

/* ---- Collapsible sections (native <details>, no JS) ---- */

details.section {
  background: var(--green-mid);
  border-radius: 3px;
  margin: 0.5rem 0;
  color: #fff;
}

main > details.section:first-child { margin-top: 0; }

details.section + details.section { margin-top: 0.6rem; }

details.section summary {
  list-style: none;
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.section summary::-webkit-details-marker { display: none; }

details.section summary::after {
  content: "▾";
  transition: transform 0.15s ease;
}

details.section[open] summary::after {
  transform: rotate(180deg);
}

details.section .section-body {
  background: #fff;
  color: var(--text);
  padding: 0.4rem 1.25rem;
  border: 1px solid var(--green-mid);
  border-top: none;
}

details.section .section-body h3:first-child { margin-top: 0; }
details.section .section-body > *:first-child { margin-top: 0; }
details.section .section-body > *:last-child { margin-bottom: 0; }

.other-sites {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.other-sites a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  background: var(--tan-bg);
  border: 1px solid #b9ae92;
  border-radius: 4px;
  padding: 1rem;
  text-align: center;
  font-weight: 600;
  text-decoration: none;
}

.other-sites a img {
  width: 100%;
  max-width: 400px;
  height: auto;
  border: 1px solid #b9ae92;
}

.other-sites a:hover { background: #fff; }

/* ---- Footer ---- */

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  color: #666;
}

/* ---- Popup (Hubel & Wiesel quote) ---- */

.popup-link { color: var(--red-link); text-decoration: underline; }

dialog.popup {
  max-width: 560px;
  width: 90%;
  border: none;
  border-radius: 6px;
  padding: 1.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  background: #fff;
  color: var(--text);
}

dialog.popup::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

dialog.popup blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--green-mid);
  color: #444;
  font-style: italic;
}

.popup-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #777;
}

.popup-close:hover { color: var(--text); }

@media (max-width: 600px) {
  .lead-figure { float: none; width: 60%; margin: 0 auto 1rem; }
  .site-header h1 { font-size: 1.6rem; }
}

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

.site-header .subtitle {
  margin: 0;
  color: #d6e7c3;
  font-size: 1.1rem;
  font-weight: 600;
}

main.pubs { max-width: 1100px; }

.pubs-table-wrap { overflow-x: auto; }

table.pubs-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

table.pubs-table td {
  border: 1px solid #c9bfa3;
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

table.pubs-table td:first-child {
  text-align: center;
  white-space: nowrap;
  width: 3.5rem;
}

table.pubs-table:not(.two-col) td:nth-child(2) {
  text-align: center;
  white-space: nowrap;
  width: 3.5rem;
}

table.pubs-table tr:nth-child(even) { background: var(--tan-bg); }

table.pubs-table tr[hidden] { display: none; }

.mac-click-note {
  text-align: center;
  font-size: 0.85rem;
  color: #666;
  margin-top: 1rem;
}

/* Floating draggable table-search box */

#searchWin {
  position: fixed;
  width: 260px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  font: 14px system-ui, sans-serif;
  color: #222;
}

#searchBar {
  padding: 6px 10px;
  background: var(--green-mid);
  color: #fff;
  border-radius: 8px 8px 0 0;
  cursor: move;
  user-select: none;
  touch-action: none;
  font-weight: 600;
}

#searchBody { padding: 10px; }

#tableSearch {
  width: 240px;
  box-sizing: border-box;
  padding: 6px;
  margin: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
}

#searchCount { margin-top: 6px; color: #666; font-size: 12px; }
