/* ============================================================
   DSA — Deep Sensing Algorithm
   Hermes-adjacent. Plain CSS. No build step.
   ============================================================ */

:root {
  --bg: #0a0f17;
  --bg-elevated: #0d121b;
  --fg: #e6dfd1;
  --fg-strong: #f5efe2;
  --fg-muted: rgba(230, 223, 209, 0.5);
  --fg-faint: rgba(230, 223, 209, 0.3);
  --fg-line: rgba(230, 223, 209, 0.16);
  --fg-line-strong: rgba(230, 223, 209, 0.28);
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.12);
  --warning: #ffba5b;

  --max-width: 1440px;
  --pad: clamp(1rem, 2.5vw, 2rem);
  --gap: 1rem;

  --font-mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --tracking-wide: 0.18em;
  --tracking-wider: 0.24em;
}

:root[data-theme="light"] {
  --bg: #ece7d8;
  --bg-elevated: #e3dccc;
  --fg: #131722;
  --fg-strong: #05080f;
  --fg-muted: rgba(19, 23, 34, 0.55);
  --fg-faint: rgba(19, 23, 34, 0.3);
  --fg-line: rgba(19, 23, 34, 0.18);
  --fg-line-strong: rgba(19, 23, 34, 0.32);
  --accent: #2c4fb8;
  --accent-soft: rgba(44, 79, 184, 0.12);
}

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
}

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

/* ============================================================
   ATMOSPHERIC LAYERS
   ============================================================ */

.texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 0% 0%, var(--accent-soft) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, var(--accent-soft) 0%, transparent 55%);
  mix-blend-mode: screen;
  opacity: 0.5;
}

:root[data-theme="light"] .texture { mix-blend-mode: multiply; opacity: 0.08; }
:root[data-theme="light"] .vignette { mix-blend-mode: multiply; opacity: 0.3; }

/* ============================================================
   LAYOUT
   ============================================================ */

main {
  position: relative;
  z-index: 2;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--pad);
}

.g {
  display: grid;
  border-right: 1px solid var(--fg-line);
  border-bottom: 1px solid var(--fg-line);
  margin-bottom: var(--gap);
}

.gc {
  border-top: 1px solid var(--fg-line);
  border-left: 1px solid var(--fg-line);
  padding: 1.25rem 1.5rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* hover wash on linked cells, Hermes-style */
a.gc::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
  mix-blend-mode: difference;
}
a.gc:hover::after { opacity: 0.04; transition: opacity 0ms; }
a.gc:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* ============================================================
   TYPE
   ============================================================ */

.label {
  font-size: 0.8125rem;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  font-weight: 400;
}

.muted { opacity: 0.55; }

.prose {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9375rem;
  line-height: 1.65;
  opacity: 0.78;
  font-weight: 400;
}

.headline {
  letter-spacing: 0.015em;
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--fg-strong);
  max-width: 22ch;
}

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

.header {
  grid-template-columns: 2fr 1fr 1fr 1.4fr;
}

.wordmark {
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}
.wordmark-text {
  font-size: clamp(2rem, 3.6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--fg-strong);
}

.nav-link {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-chevron {
  opacity: 0.5;
  transition: opacity 200ms ease, color 200ms ease, transform 200ms ease;
  flex-shrink: 0;
}
a.nav-link:hover .nav-chevron {
  opacity: 1;
  color: var(--accent);
  transform: translateY(1px);
}

.socials-cell {
  justify-content: space-between;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}
.socials-link {
  display: inline-flex;
  align-items: center;
  color: var(--fg);
  opacity: 0.7;
  transition: opacity 200ms ease, color 200ms ease;
}
.socials-link:hover {
  color: var(--accent);
  opacity: 1;
}
.socials-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}
.socials-link svg { display: block; }

/* ============================================================
   HERO
   ============================================================ */

.hero { grid-template-columns: 3fr 4fr; }

.hero-text {
  align-items: flex-start;
  text-align: left;
  padding: clamp(2.5rem, 5vw, 4rem) clamp(1.5rem, 3vw, 2.5rem);
  gap: 1.5rem;
  justify-content: center;
}
.hero-text .prose { max-width: 52ch; }
.hero-text .headline { max-width: none; }

.hero-terminal {
  padding: 1.25rem clamp(1rem, 2.5vw, 1.75rem);
  justify-content: center;
}

/* terminal */
.terminal {
  width: 100%;
  max-width: 680px;
  margin-left: auto;
  border: 3px double var(--fg-line-strong);
  background: rgba(8, 12, 20, 0.6);
  font-family: var(--font-mono);
  position: relative;
}
.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--fg-line);
}
.terminal-dots {
  display: inline-flex;
  gap: 0.4rem;
}
.terminal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg);
}
.terminal-dot-2 { opacity: 0.55; }
.terminal-dot-3 { opacity: 0.28; }
.terminal-title {
  margin-left: auto;
  font-size: 0.6875rem;
  opacity: 0.55;
  letter-spacing: var(--tracking-wider);
}
.terminal-body {
  height: clamp(300px, 38vh, 380px);
  overflow-y: auto;
  padding: 0.95rem 1.1rem;
  font-size: 0.72rem;
  line-height: 1.75;
  text-transform: none;
  letter-spacing: 0;
}
.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--fg-line); }
.terminal-content { white-space: pre-wrap; }

.terminal-line { color: var(--fg); opacity: 0.85; }
.terminal-prompt { color: var(--fg-strong); opacity: 1; }
.terminal-prompt::before { content: "❯ "; color: var(--accent); opacity: 0.9; }

.terminal-cmd-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--fg);
  opacity: 0.78;
}
.terminal-cmd::before { content: "  "; }
.terminal-time { color: var(--fg-strong); opacity: 0.45; flex-shrink: 0; }

.terminal-result { color: var(--fg-strong); opacity: 0.92; }
.terminal-bullet { color: var(--fg); opacity: 0.78; padding-left: 0.5rem; }
.terminal-bullet::before { content: "  ▸ "; color: var(--accent); opacity: 0.8; }
.terminal-skill { color: var(--accent); opacity: 0.85; }
.terminal-meta { color: var(--fg); opacity: 0.40; padding-top: 0.4em; }

.terminal-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--fg);
  margin-left: 0.18em;
  vertical-align: text-bottom;
  animation: blink 1.1s steps(2, end) infinite;
}

.blink {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--fg);
  margin-left: 0.3em;
  vertical-align: text-bottom;
  animation: blink 1.1s steps(2, end) infinite;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* ============================================================
   GRAPH SECTION
   ============================================================ */

.graph-section { margin-bottom: var(--gap); }

.graph-frame {
  grid-template-columns: 1fr;
}

.graph-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.5rem;
}
.graph-header .label:first-child { color: var(--fg-strong); }

.graph-reseed {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--fg-line-strong);
  padding: 0.4rem 0.7rem;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.graph-reseed:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.graph-reseed:hover .label { color: var(--fg-strong); }

.graph-canvas-cell {
  padding: 0;
  height: clamp(560px, 78vh, 860px);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse at center, rgba(91, 141, 239, 0.05) 0%, transparent 70%),
    var(--bg-elevated);
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.graph-hint {
  position: absolute;
  bottom: 0.85rem;
  right: 1.25rem;
  pointer-events: none;
  opacity: 0.4;
}

.graph-caption {
  padding: 1.25rem 1.5rem;
}
.graph-caption .prose {
  max-width: 72ch;
  font-size: 0.875rem;
  opacity: 0.65;
}

@media (max-width: 720px) {
  .graph-canvas-cell { height: clamp(420px, 80vh, 620px); }
  .graph-header { padding: 0.85rem 1rem; }
}

/* ============================================================
   INQUIRY
   ============================================================ */

.full-row { grid-column: 1 / -1; }

.inquiry { grid-template-columns: repeat(2, 1fr); }
.question {
  min-height: 180px;
  gap: 1rem;
  justify-content: flex-start;
}
.question .label { color: var(--fg-strong); }
.question-text {
  letter-spacing: 0.012em;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.45;
  color: var(--fg-strong);
  font-weight: 400;
  max-width: 32ch;
}

/* ============================================================
   COUNTERPARTIES / LOG
   ============================================================ */

.counterparties, .engagements { grid-template-columns: 1fr; }

.log {
  padding: 0;
  gap: 0;
}
.log-row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 1.5rem;
  padding: 0.95rem 1.5rem;
  border-top: 1px solid var(--fg-line);
  align-items: baseline;
}
.log-row:first-child { border-top: 0; }

.log-date {
  font-size: 0.8125rem;
  letter-spacing: var(--tracking-wide);
  opacity: 0.5;
}
.log-entry {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9375rem;
  opacity: 0.85;
  line-height: 1.5;
}
.log-tag {
  font-size: 0.6875rem;
  letter-spacing: var(--tracking-wider);
  opacity: 0.5;
  text-align: right;
}

.discretion {
  padding: 1.1rem 1.5rem;
}
.discretion .prose {
  max-width: 64ch;
  opacity: 0.6;
  font-size: 0.875rem;
}

/* ============================================================
   CONTACT
   ============================================================ */

.contact { grid-template-columns: 1fr; }

.contact-cell {
  align-items: center;
  text-align: center;
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
  gap: 1rem;
}
.contact-address {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  letter-spacing: 0.04em;
  font-weight: 400;
  color: var(--fg-strong);
  position: relative;
  transition: color 200ms ease;
}
.contact-address:hover { color: var(--accent); }
.contact-note {
  max-width: 52ch;
  opacity: 0.55;
}

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

.footer {
  grid-template-columns: 2fr 2fr 1fr;
  margin-bottom: 0;
}
.footer .gc { padding: 0.9rem 1.5rem; }
.footer .label:first-child { color: var(--fg-strong); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .header { grid-template-columns: 2fr 1fr 1fr 1fr; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-text { align-items: center; text-align: center; }
  .hero-text .prose { max-width: 56ch; }
  .hero-terminal { padding-top: 0; }
  .terminal { margin-left: 0; margin-right: auto; }
}

@media (max-width: 720px) {
  .header { grid-template-columns: 1fr 1fr; }
  .header .wordmark { grid-column: 1 / -1; }
  .header .socials-cell { display: none; }
  .inquiry { grid-template-columns: 1fr; }
  .footer { grid-template-columns: 1fr; }
  .log-row {
    grid-template-columns: 6rem 1fr;
    gap: 1rem;
  }
  .log-tag { display: none; }
  .headline { font-size: 2rem; }
}

@media (max-width: 600px) {
  .hero-terminal { display: none; }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

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