/* ============================================================
   OLD GUARD / PLaiGROUND — shared stylesheet
   Monospace, structured, flat. Black/white + #ED6E5D.
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --muted: #8a8a8a;
  --dim: #1a1a1a;
  --line: #2a2a2a;
  --accent: #ED6E5D;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --pad-x: clamp(16px, 4vw, 40px);
  --rule: 1px solid var(--line);
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --muted: #6a6a6a;
  --dim: #f0f0f0;
  --line: #d8d8d8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #0a0a0a; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }

/* ============================================================
   HEADER
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: var(--rule);
  padding: 14px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  background-color: currentColor;
  color: var(--fg);
  -webkit-mask: url("logo.png") center / contain no-repeat;
          mask: url("logo.png") center / contain no-repeat;
  flex-shrink: 0;
  transition: color 140ms;
}
.brand:hover .brand-logo { color: var(--accent); }

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--rule);
  font-size: 12px;
  transition: border-color 120ms, color 120ms;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.theme-toggle {
  border: none;
  color: var(--muted);
  width: 28px;
  height: 28px;
}
.theme-toggle:hover { color: var(--accent); border: none; }
.theme-toggle svg { display: block; transition: transform 200ms; }
:root[data-theme="light"] .theme-toggle svg { transform: rotate(180deg); }

@media (max-width: 720px) {
  .site-header { gap: 12px; padding: 12px var(--pad-x); }
  .brand-logo { width: 44px; height: 44px; }
}

/* ============================================================
   PAGE INTRO (hero)
   ============================================================ */

.intro {
  padding: clamp(40px, 8vw, 96px) var(--pad-x) clamp(28px, 4vw, 56px);
  border-bottom: var(--rule);
}

.intro h1 {
  margin: 0;
  font-size: clamp(28px, 5.5vw, 84px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-weight: 600;
  text-wrap: balance;
}
.intro h1 .accent { color: var(--accent); }
.intro h1 .lower {
  display: block;
  font-weight: 300;
  /* clamp at 16px min so the line stays legible at small viewport sizes */
  font-size: max(16px, 0.25em);
  margin-top: 0.6em;
  letter-spacing: 0;
  color: var(--muted);
}

@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   TOOLBAR (filter + view toggle)
   ============================================================ */

.toolbar {
  padding: 12px var(--pad-x);
  border-bottom: var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toolbar-count { font-weight: 500; color: var(--fg); }
.toolbar-meta { color: var(--muted); }

.view-toggle {
  display: flex;
  border: var(--rule);
}
.view-toggle button {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  border-right: var(--rule);
}
.view-toggle button:last-child { border-right: none; }
.view-toggle button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

/* ============================================================
   EXPERIMENT INDEX — GRID VIEW
   ============================================================ */

.experiments[data-view="grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0;
  border-bottom: var(--rule);
}

.experiments[data-view="grid"] .card {
  display: block;
  padding: 18px;
  border-right: var(--rule);
  border-bottom: var(--rule);
  position: relative;
  transition: background 140ms;
}
.experiments[data-view="grid"] .card:hover {
  background: var(--dim);
}
.experiments[data-view="grid"] .card:hover .thumb-arrow {
  transform: translate(4px, -4px);
  color: var(--accent);
}
.experiments[data-view="grid"] .card:hover .meta-title {
  color: var(--accent);
}

.experiments[data-view="grid"] .thumb {
  aspect-ratio: 4 / 3;
  background: var(--dim);
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  border: var(--rule);
}

.thumb-arrow {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
  color: var(--muted);
  transition: transform 180ms, color 180ms;
}

.thumb-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Card meta — single row of metadata, title is the prominent item */
.experiments[data-view="grid"] .card-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.experiments[data-view="grid"] .meta-num { color: var(--fg); font-weight: 500; }
.experiments[data-view="grid"] .meta-title {
  font-size: 16px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--fg);
  transition: color 140ms;
}
.experiments[data-view="grid"] .meta-cat { justify-self: end; }
.experiments[data-view="grid"] .meta-year,
.experiments[data-view="grid"] .meta-arrow { display: none; }

/* ============================================================
   EXPERIMENT INDEX — LIST VIEW
   ============================================================ */

.experiments[data-view="list"] {
  border-bottom: var(--rule);
}

.experiments[data-view="list"] .card {
  display: block;
  border-bottom: var(--rule);
  transition: background 140ms, padding 140ms;
}
.experiments[data-view="list"] .card:hover {
  background: var(--dim);
}
.experiments[data-view="list"] .card:hover .meta-title {
  color: var(--accent);
}
.experiments[data-view="list"] .card:hover .meta-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

.experiments[data-view="list"] .thumb { display: none; }

.experiments[data-view="list"] .card-meta {
  display: grid;
  grid-template-columns: 80px 1fr 32px;
  align-items: center;
  gap: 24px;
  padding: 18px var(--pad-x);
}
.experiments[data-view="list"] .meta-num {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.experiments[data-view="list"] .meta-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
  transition: color 140ms;
}
.experiments[data-view="list"] .meta-arrow {
  font-size: 14px;
  color: var(--muted);
  text-align: right;
  transition: transform 180ms, color 180ms;
}

.experiments[data-view="list"] .meta-cat { display: none; }

/* Avoid doubled rule above the footer: the main wrapper already draws its
   bottom border, so drop the last card's. */
.experiments[data-view="list"] .card:last-child { border-bottom: none; }

@media (max-width: 720px) {
  .experiments[data-view="list"] .card-meta {
    grid-template-columns: 60px 1fr 32px;
  }
}

.card.is-hidden { display: none !important; }

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  padding: 28px var(--pad-x);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.site-footer .label { display: inline; color: var(--fg); font-weight: 500; }
.site-footer .dot {
  display: inline-block;
  margin: 0 8px;
  color: var(--muted);
}
.site-footer .footer-link {
  color: var(--muted);
  transition: color 140ms;
}
.site-footer .footer-link:hover { color: var(--accent); }
.site-footer .right { text-align: right; }

@media (max-width: 720px) {
  .site-footer { grid-template-columns: 1fr; }
  .site-footer .right { text-align: left; }
}

/* ============================================================
   EXPERIMENT DETAIL PAGE
   ============================================================ */

.crumbs {
  padding: 12px var(--pad-x);
  border-bottom: var(--rule);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  gap: 8px;
}
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .here { color: var(--fg); }

.exp-head {
  padding: clamp(32px, 6vw, 64px) var(--pad-x);
  border-bottom: var(--rule);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 32px;
}

.exp-num {
  font-size: clamp(48px, 10vw, 120px);
  font-weight: 600;
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: var(--accent);
}

.exp-title {
  margin: 0;
  font-size: clamp(32px, 6vw, 72px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.exp-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 180px;
}
.exp-meta strong { color: var(--fg); font-weight: 500; }

@media (max-width: 720px) {
  .exp-head { grid-template-columns: 1fr; gap: 16px; }
  .exp-meta { text-align: left; min-width: 0; }
}

.exp-stage {
  padding: var(--pad-x);
  border-bottom: var(--rule);
  min-height: clamp(420px, 60vh, 720px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 40px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 40px 100%,
    var(--bg);
  background-blend-mode: normal;
}
.exp-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0.96;
  pointer-events: none;
}
.exp-stage > * { position: relative; z-index: 1; }

.exp-stage-label {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  z-index: 2;
}
.exp-stage-label .ind { color: var(--accent); }

.exp-notes {
  padding: clamp(32px, 5vw, 64px) var(--pad-x);
  border-bottom: var(--rule);
}
.exp-notes-inner {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 40px;
  max-width: 1200px;
}
.exp-notes-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: var(--rule);
}
.exp-notes-head .num {
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}
.exp-notes-head .title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.exp-notes h3 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
}
.exp-notes p {
  margin: 0 0 14px 0;
  font-size: 15px;
  line-height: 1.6;
  max-width: 60ch;
}
.exp-notes p:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .exp-notes-inner { grid-template-columns: 1fr; gap: 12px; }
}

.exp-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: var(--rule);
}
.exp-nav a {
  padding: 24px var(--pad-x);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: background 140ms;
}
.exp-nav a:hover { background: var(--dim); }
.exp-nav a:hover .nav-title { color: var(--accent); }
.exp-nav .nav-dir {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.exp-nav .nav-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: color 140ms;
}
.exp-nav .next {
  text-align: right;
  border-left: var(--rule);
}
.exp-nav .disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ============================================================
   UTIL — striped placeholder for thumbnails
   ============================================================ */

.stripes {
  background-image: repeating-linear-gradient(
    -45deg,
    var(--line) 0 1px,
    transparent 1px 8px
  );
}

.thumb-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
