/* Minimal concept: home page.
 * One quiet column on one dark background, a numbered list of work, and a
 * preview that develops from a 1-bit dither into the full image. */

:root {
  --ink: #ededeb;
  --paper: #0c0c0c;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: #0c0c0c; }

::selection { background: var(--hue, var(--ink)); color: var(--paper); }

.page {
  --muted: color-mix(in srgb, var(--ink) 50%, var(--paper));
  --faint: color-mix(in srgb, var(--ink) 35%, var(--paper));
  --rule: color-mix(in srgb, var(--ink) 10%, var(--paper));
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, p, ol { margin: 0; font: inherit; }
a { color: inherit; }

.col {
  max-width: 36rem;
  margin: 0 auto;
  padding: clamp(3rem, 14vh, 9rem) 1.5rem 4rem;
}
@media (min-width: 1000px) {
  .col { margin-left: max(1.5rem, 12vw); }
}

.muted { color: var(--muted); }

/* ---------- Header: the mark and the reading mode ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2.5rem;
}
.mark {
  display: block;
  width: 56px;
  height: 56px;
  margin-left: -2px;
  image-rendering: pixelated;
}
.mark canvas { display: block; width: 100%; height: 100%; }
.mark:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }

.mode {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--faint);
}
.mode button {
  all: unset;
  cursor: pointer;
  color: var(--faint);
  transition: color 0.25s ease;
}
.mode button:hover { color: var(--ink); }
.mode button[aria-pressed="true"] { color: var(--ink); }
.mode button:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* ---------- Intro ---------- */

.intro { margin-bottom: 4.5rem; }

/* Currently / Previously: two labelled columns, stacked on narrow screens. */
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2rem;
  row-gap: 1.25rem;
  margin: 1.75rem 0 0;
}
.facts dt { margin-bottom: 0.3rem; }
.facts dd { margin: 0; }
@media (max-width: 480px) {
  .facts { grid-template-columns: 1fr; }
}

/* ---------- Work list ---------- */

.label { margin-bottom: 1rem; }

.work { list-style: none; padding: 0; --name-x: calc(2.25rem + 1rem); }
.work li { position: relative; border-top: 1px solid var(--rule); }
.work li:last-child { border-bottom: 1px solid var(--rule); }

.row {
  display: grid;
  grid-template-columns: 2.25rem 1fr auto 3rem;
  column-gap: 1rem;
  align-items: baseline;
  width: 100%;
  padding: 0.6rem 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.35s ease;
}
.row:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.row .n, .row .y {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.row .n { color: var(--faint); transition: color 0.4s ease; }
.row .y { text-align: right; }
.row .t { min-width: 0; }
.row .ext {
  margin-left: 0.35em;
  font-size: 12px;
  color: var(--faint);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.work.has-active .row { opacity: 0.3; }
.work.has-active .is-active .row { opacity: 1; }
.is-active .row .n { color: var(--muted); }
.is-active .row .ext { opacity: 1; }

/* A one-line description above the name, shown while the row is active. */
.tip {
  position: absolute;
  left: var(--name-x);
  bottom: calc(100% - 0.3rem);
  z-index: 2;
  max-width: calc(100% - var(--name-x));
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.25s var(--ease);
}
.is-active .tip { opacity: 1; transform: none; }

/* Touch: tapping a row opens its preview underneath. */
.inline-preview {
  padding: 0.25rem 0 1rem;
  animation: open 0.35s var(--ease) both;
}
.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.75rem;
}
@keyframes open {
  from { opacity: 0; transform: translateY(-4px); }
}

/* ---------- Agent mode ---------- */

.agent-view[hidden], .human-view[hidden] { display: none; }
.agent-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}
.agent-actions { display: flex; gap: 1.25rem; }
.agent-text {
  margin: 0;
  padding: 1rem 0;
  max-height: 70vh;
  overflow: auto;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: color-mix(in srgb, var(--ink) 80%, var(--paper));
}

/* ---------- Footer: the menu ---------- */

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 4.5rem;
}

.link, footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink) 25%, var(--paper));
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.25s ease;
  cursor: pointer;
}
button.link { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--ink) 25%, var(--paper)); text-underline-offset: 0.2em; }
.link:hover, footer a:hover { text-decoration-color: var(--ink); }
/* The page you're on: plain grey, no underline. */
/* "page" on the page itself; "true" for its section (Writing, seen from a post). */
footer a[aria-current] { color: var(--muted); text-decoration: none; }
/* A link that downloads a file (the CV): a down arrow under a bar, in the text colour.
   To put the bar under the arrow instead, swap the two paths' y values in the SVG. */
footer a[download]::after {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.25em;
  vertical-align: -0.05em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 2h10'/%3E%3Cpath d='M8 5v9M4.5 10.5 8 14l3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 2h10'/%3E%3Cpath d='M8 5v9M4.5 10.5 8 14l3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Read by screen readers, not shown. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.link:focus-visible, footer a:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* ---------- The floating preview ---------- */

.preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  will-change: transform;
}
.preview.is-on { opacity: 1; }

.develop {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
}
.develop > canvas, .develop > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---------- Entrance ---------- */

.rise {
  animation: rise 0.8s var(--ease) both;
  animation-delay: calc(var(--d) * 90ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
}

@media (max-width: 480px) {
  .row { grid-template-columns: 2rem 1fr 2.75rem; }
  .work { --name-x: calc(2rem + 1rem); }
  .row .o { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rise, .inline-preview { animation: none; }
  .tip { transform: none; transition: opacity 0.2s ease; }
}
