/* erkams.com — two ways of seeing: artist (paper & ink) and machine (screen & detections) */

:root {
  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1280px;
  --ease: cubic-bezier(.7, 0, .2, 1);

  /* artist: warm paper, iron-gall ink, vermilion, ultramarine */
  --bg-rgb: 241, 236, 226;
  --ink-rgb: 26, 23, 20;
  --muted-rgb: 108, 100, 90;
  --accent-rgb: 222, 70, 26;
  --accent2-rgb: 44, 72, 214;
  --card-rgb: 231, 224, 211;
}

html[data-mode="machine"] {
  /* machine: phosphor dark, detection lime, alert orange */
  --bg-rgb: 11, 14, 12;
  --ink-rgb: 216, 227, 219;
  --muted-rgb: 124, 138, 129;
  --accent-rgb: 196, 245, 66;
  --accent2-rgb: 255, 96, 56;
  --card-rgb: 19, 24, 21;
}

:root {
  --bg: rgb(var(--bg-rgb));
  --ink: rgb(var(--ink-rgb));
  --muted: rgb(var(--muted-rgb));
  --accent: rgb(var(--accent-rgb));
  --line: rgba(var(--ink-rgb), .16);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
  transition: background-color .5s ease, color .5s ease;
}

/* texture overlay: paper grain for the artist, a pixel grid for the machine */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: .22;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
html[data-mode="machine"] body::before {
  opacity: 1;
  background-image:
    linear-gradient(rgba(var(--ink-rgb), .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--ink-rgb), .03) 1px, transparent 1px);
  background-size: 32px 32px;
}

::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.when-machine { display: none; }
html[data-mode="machine"] .when-machine { display: revert; }
html[data-mode="machine"] .when-artist { display: none; }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--gutter);
  background: rgba(var(--bg-rgb), .78);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background-color .5s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.mark {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1;
  text-decoration: none;
  letter-spacing: -.01em;
}
.mark i { font-style: normal; color: var(--accent); }
html[data-mode="machine"] .mark { font-family: var(--mono); font-size: 18px; letter-spacing: -.04em; }

.nav-links {
  display: flex;
  gap: 26px;
  font-family: var(--mono);
  font-size: 12px;
  margin-left: auto;
  margin-right: 12px;
}
.nav-links a { text-decoration: none; color: var(--muted); transition: color .2s; }
.nav-links a:hover { color: var(--accent); }

.mode-switch {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(var(--ink-rgb), .25);
  border-radius: 999px;
  background: rgba(var(--bg-rgb), .7);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.mode-switch::before {
  content: "";
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--ink);
  transition: transform .45s var(--ease), background-color .5s;
}
html[data-mode="machine"] .mode-switch::before { transform: translateX(100%); }
.mode-switch span {
  position: relative;
  z-index: 1;
  min-width: 74px;
  padding: 6px 10px;
  text-align: center;
  transition: color .3s;
}
html[data-mode="artist"] .mode-switch .opt-artist,
html[data-mode="machine"] .mode-switch .opt-machine { color: var(--bg); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: end;
  padding: 120px var(--gutter) clamp(32px, 7vh, 72px);
  overflow: hidden;
  touch-action: pan-y;
}
#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.hero-copy {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  pointer-events: none;
}
.hero-copy button { pointer-events: auto; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 18px;
}
html[data-mode="machine"] .eyebrow { margin-bottom: 44px; }

.name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(4.2rem, 15vw, 13.5rem);
  line-height: .86;
  letter-spacing: -.025em;
  margin: 0;
  width: fit-content;
}
.name em { font-style: italic; color: var(--accent); }
html[data-mode="machine"] .name {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(2.6rem, 9.5vw, 8.5rem);
  line-height: .95;
  letter-spacing: -.065em;
  text-transform: lowercase;
}
html[data-mode="machine"] .name em { font-style: normal; }

.lede {
  max-width: 32ch;
  margin: 26px 0 0;
  font-size: clamp(1.1rem, 1.7vw, 1.45rem);
  line-height: 1.38;
  text-wrap: pretty;
}
.lede-machine {
  max-width: none;
  font-family: var(--mono);
  font-size: clamp(.82rem, 1.15vw, 1rem);
  line-height: 1.7;
  white-space: pre-line;
  color: var(--accent);
}

.hero-cta {
  margin-top: 28px;
  padding: 0 0 3px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: color .2s;
}
.hero-cta:hover { color: var(--accent); }

.hud {
  position: absolute;
  z-index: 2;
  top: 86px;
  right: var(--gutter);
  margin: 0;
  max-width: 300px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  text-align: right;
  white-space: pre-line;
}

/* ---------- sections ---------- */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(72px, 11vw, 150px) var(--gutter) 0;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  display: flex;
  align-items: baseline;
  gap: .45em;
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.3rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: -.015em;
}
.num { font-family: var(--mono); font-size: 12px; letter-spacing: 0; color: var(--accent); }
html[data-mode="machine"] .section-head h2 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.5rem, 3.4vw, 2.4rem);
  letter-spacing: -.05em;
  text-transform: lowercase;
}
.section-note {
  margin: 0 0 40px;
  max-width: 60ch;
  color: var(--muted);
  font-size: .95rem;
}

.filters { display: flex; gap: 6px; font-family: var(--mono); font-size: 12px; }
.filters button {
  padding: 5px 12px;
  border: 1px solid rgba(var(--ink-rgb), .22);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}
.filters button:hover { border-color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- work grid (masonry via columns) ---------- */
.grid { columns: 3 280px; column-gap: clamp(18px, 2.6vw, 36px); }
.card {
  break-inside: avoid;
  margin: 0 0 clamp(36px, 5vw, 60px);
  padding-top: 18px; /* room for machine-mode labels */
}
.card[hidden] { display: none; }

.thumb {
  position: relative;
  aspect-ratio: var(--ar, 4/5);
  background: rgb(var(--card-rgb));
  overflow: hidden;
}
.thumb canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 1s cubic-bezier(.2, .7, .2, 1);
}
.card:hover .thumb canvas { transform: scale(1.035); }

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.card h3 {
  margin: 6px 0 6px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.95rem;
  line-height: 1.05;
  letter-spacing: -.01em;
}
html[data-mode="machine"] .card h3 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -.03em;
  text-transform: lowercase;
}
.card p { margin: 0; max-width: 42ch; color: var(--muted); font-size: .97rem; }

/* ---------- machine-mode detections on DOM elements ---------- */
[data-det] { position: relative; }
html[data-mode="machine"] [data-det] {
  outline: 1px solid rgba(var(--accent-rgb), .9);
  outline-offset: 6px;
}
html[data-mode="machine"] [data-det]::after {
  content: attr(data-det);
  position: absolute;
  left: -7px;
  top: -7px;
  transform: translateY(-100%);
  padding: 4px 6px;
  background: var(--accent);
  color: var(--bg);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}
html[data-mode="machine"] .thumb[data-det] { outline-offset: 4px; overflow: visible; }
html[data-mode="machine"] .thumb[data-det] canvas { clip-path: inset(0); }
html[data-mode="machine"] .thumb[data-det]::after { left: -5px; top: -5px; }

/* ---------- contact ---------- */
.big {
  margin: 36px 0 52px;
  max-width: 15ch;
  font-family: var(--serif);
  font-size: clamp(2.6rem, 7vw, 6.4rem);
  line-height: .98;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.big em { color: var(--accent); }
html[data-mode="machine"] .big {
  max-width: 22ch;
  font-family: var(--mono);
  font-size: clamp(1.6rem, 4vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -.05em;
}
html[data-mode="machine"] .big em { font-style: normal; }
.links { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.links li { border-bottom: 1px solid var(--line); }
.links a, .links .soon {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 20px 0;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  line-height: 1.1;
  text-decoration: none;
  transition: padding .35s var(--ease), color .2s;
}
.links .soon { color: var(--muted); }
.links a:hover { padding-left: 16px; color: var(--accent); }
.links small { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; }
html[data-mode="machine"] .links a, html[data-mode="machine"] .links .soon { font-family: var(--mono); font-size: 1.05rem; }

/* ---------- footer ---------- */
.footer {
  max-width: var(--max);
  margin: clamp(80px, 12vw, 160px) auto 0;
  padding: 22px var(--gutter) 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
kbd {
  font: inherit;
  padding: 1px 5px;
  border: 1px solid rgba(var(--ink-rgb), .3);
  border-radius: 4px;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .nav-links { display: none; }
  .mode-switch span { min-width: 64px; padding: 6px 8px; }
  .hud { top: 72px; left: var(--gutter); right: auto; text-align: left; }
  .kbd-hint { display: none; }
  .hero { padding-top: 140px; }
}
@media (hover: none) {
  .kbd-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card:hover .thumb canvas { transform: none; }
  body, .mode-switch::before { transition: none; }
}
