/* ============================================================
   THE QUIET MACHINE — hand-built stylesheet
   phosphor-terminal meets small-press magazine
   ============================================================ */

:root {
  --bg: #0b0b0e;
  --raised: #111116;
  --ink: #ebe6da;
  --dim: #97917f;
  --accent: #ff4d00;
  --line: rgba(235, 230, 218, 0.14);
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f2eee4;
  --raised: #faf7f0;
  --ink: #1a1920;
  --dim: #6a6558;
  --accent: #cc3700;
  --line: rgba(26, 25, 32, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.75;
  overflow-x: hidden;
  transition: background-color 0.5s ease, color 0.5s ease;
}

::selection { background: var(--accent); color: var(--bg); }

section { scroll-margin-top: 90px; }

.wrap { max-width: 1140px; margin-inline: auto; padding-inline: clamp(1.1rem, 4vw, 2.5rem); }

.mono { font-family: var(--font-mono); }
.dim { color: var(--dim); }
.serif-italic { font-family: var(--font-display); font-style: italic; }

.kicker {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.kicker:not(.dim) { color: var(--accent); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.01em;
}
h1 em, h2 em, .artifact-title em { font-style: italic; color: var(--accent); }

h2 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); margin-bottom: 1.6rem; }
h3 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 0.8rem; }

p + p { margin-top: 0.9em; }

a { color: inherit; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- grain overlay ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem clamp(1.1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-decoration: none;
  white-space: nowrap;
}

.blink {
  animation: blink 1.15s steps(1) infinite;
  color: var(--accent);
}
@keyframes blink { 50% { opacity: 0; } }

.site-nav { display: flex; gap: 1.8rem; }
.site-nav a {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--dim);
  transition: color 0.25s ease;
}
.site-nav a:hover { color: var(--accent); }

.header-status { display: flex; align-items: center; gap: 1rem; font-size: 0.72rem; letter-spacing: 0.14em; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.icon-btn:hover { border-color: var(--accent); transform: rotate(20deg); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  height: 100svh;
  min-height: 600px;
  overflow: hidden;
}

#flowfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero-copy {
  position: absolute;
  left: clamp(1.1rem, 4vw, 2.5rem);
  right: clamp(1.1rem, 4vw, 2.5rem);
  bottom: clamp(2.2rem, 7vh, 5rem);
  pointer-events: none;
  max-width: 860px;
}

.hero-copy .kicker { margin-bottom: 1.2rem; }

.hero h1 {
  font-size: clamp(2.9rem, 7.2vw, 5.6rem);
  margin-bottom: 1.4rem;
}

.lede {
  max-width: 56ch;
  color: var(--dim);
}

.hint { margin-top: 1.8rem; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; }

/* ---------- section scaffolding ---------- */
#artifact, #machines, #notes { padding-block: clamp(5rem, 11vw, 9rem) 0; }
#notes { padding-bottom: clamp(5rem, 10vw, 8rem); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.1rem;
  margin-bottom: clamp(2.4rem, 5vw, 4rem);
}

/* ---------- artifact ---------- */
.artifact-grid {
  display: grid;
  grid-template-columns: minmax(280px, 470px) 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.artifact-frame {
  border: 1px solid var(--line);
  background: var(--raised);
  padding: 0.8rem;
}

#artifact-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.artifact-frame figcaption {
  padding-top: 0.7rem;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: right;
}

.artifact-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  line-height: 1.05;
  color: var(--accent);
  min-height: 1.1em;
  margin-bottom: 0.6rem;
}

.algo-tag {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 1.6rem;
}

.artifact-copy > p:not(.artifact-title):not(.algo-tag) { max-width: 52ch; color: var(--dim); }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.8rem;
}

/* ---------- buttons ---------- */
.btn {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.75em 1.5em;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.22s ease, background-color 0.22s ease, color 0.22s ease;
}
.btn:hover { border-color: var(--ink); }
.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.active { border-color: var(--accent); color: var(--accent); }

/* ---------- exhibit hall ---------- */
.exhibits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.card {
  background: var(--bg);
  padding: clamp(1.4rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: background-color 0.35s ease;
}
.card:hover { background: var(--raised); }

.card canvas { display: block; width: 100%; border: 1px solid var(--line); }

#garden-canvas { aspect-ratio: 16 / 10; cursor: crosshair; touch-action: none; }
#drone-viz { aspect-ratio: 16 / 4; }

.readout {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card .desc { color: var(--dim); font-size: 0.88rem; }

.card .btn-row { margin-top: auto; }

/* sliders */
.sliders { display: flex; flex-direction: column; gap: 0.55rem; font-size: 0.64rem; letter-spacing: 0.14em; }
.sliders label {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  align-items: center;
  gap: 0.8rem;
}
.sliders output { min-width: 5ch; text-align: right; }

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}

/* oracle */
.oracle-output {
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  padding: 1.4rem 0.4rem;
  text-align: center;
  font-size: 0.86rem;
  line-height: 2;
  min-height: 9.5em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.oracle-output p { opacity: 1; transform: none; }
.oracle-output p.arriving { animation: arrive 0.7s ease both; }
.oracle-output p:nth-child(2).arriving { animation-delay: 0.18s; }
.oracle-output p:nth-child(3).arriving { animation-delay: 0.36s; }
.oracle-output p:nth-child(4).arriving { animation-delay: 0.54s; }
@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- field notes ---------- */
.note {
  border-left: 1px solid var(--line);
  padding-left: clamp(1.2rem, 3vw, 2rem);
  margin-bottom: clamp(2.6rem, 5vw, 4rem);
  max-width: 68ch;
}
.note time {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.7rem;
}
.note p { color: var(--dim); }
.note h3 { margin-bottom: 0.9rem; }

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.6rem, 6vw, 4.5rem);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
}

footer p { font-size: 0.82rem; color: var(--dim); }
footer .kicker { margin-bottom: 1rem; }
.footer-meta p { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; line-height: 2.1; }
#foot-year, #foot-day, #visit-count { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 200%);
  z-index: 70;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  padding: 0.8em 1.6em;
  border-radius: 999px;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1.2);
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.visible { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .artifact-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .site-nav { display: none; }
  #clock { display: none; }
  .hero h1 { font-size: clamp(2.4rem, 10vw, 3.4rem); }
  .sliders label { grid-template-columns: 74px 1fr auto; font-size: 0.58rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- content pages ---------- */
.page-hero {
  padding: calc(64px + 6rem) 0 clamp(3rem, 6vw, 5rem);
  border-bottom: 1px solid var(--line);
}
.page-hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  max-width: 72ch;
}
.page-hero .lede {
  max-width: 60ch;
}

.prose { max-width: 68ch; }
.prose h2 {
  margin: 2.4rem 0 1rem;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}
.prose h3 {
  margin: 1.8rem 0 0.8rem;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
}
.prose p { color: var(--dim); }
.prose a { color: var(--accent); text-decoration: underline; }
.prose a:hover { color: var(--ink); }
.prose ul { margin: 1rem 0 1rem 1.5rem; }
.prose li { margin-bottom: 0.5rem; color: var(--dim); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--raised);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.prose pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
.prose pre code { background: none; padding: 0; }

.tool-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}
@media (max-width: 900px) {
  .tool-grid { grid-template-columns: 1fr; }
}

.faq { margin-top: 3rem; }
.faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.4rem;
  margin-bottom: 0.8rem;
  background: var(--raised);
}
.faq summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--ink);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: 1.4rem;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-top: 0.8rem; color: var(--dim); line-height: 1.7; }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}
.backlink:hover { color: var(--ink); }

.related-links {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.related-links h3 { margin-bottom: 1rem; }
.related-links ul { list-style: none; margin: 0; }
.related-links li { margin-bottom: 0.6rem; }
.related-links a { color: var(--accent); text-decoration: underline; }
.related-links a:hover { color: var(--ink); }

.archive-list { list-style: none; margin: 1.5rem 0; }
.archive-list li { margin-bottom: 0.6rem; color: var(--dim); }
.archive-list a { color: var(--accent); text-decoration: underline; }
.archive-list a:hover { color: var(--ink); }
.archive-list time { margin-right: 0.8rem; color: var(--dim); font-family: var(--font-mono); font-size: 0.85rem; }
