/* ===================================================================
   influx-portfolio — main.css

   Colors derived via CSS oklch() (perceptually uniform OKLab space).
   Theme source: #4E82B4 ≈ oklch(0.60 0.09 249).
   Dark mode: prefers-color-scheme: dark with inverted L values.
   =================================================================== */

/* --- Reset --- */

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

/* --- Custom properties (light mode) --- */

:root {
  /* Colors */
  --accent:        oklch(0.60 0.10 235);   /* warmer blue */
  --accent-dim:    oklch(0.52 0.10 235);   /* hover state */
  --text:          oklch(0.14 0.01 70);    /* near-black, warm */
  --text-muted:    oklch(0.48 0.01 70);    /* secondary text */
  --bg:            oklch(0.965 0.008 80);  /* warm cream paper — card surface */
  --bg-outer:      oklch(0.88 0.012 80);   /* page background behind the card */
  --rule:          oklch(0.84 0.008 80);   /* hairline divider */
  --grid-minor:    oklch(0.92 0.006 80);   /* barely-visible texture */
  --grid-major:    oklch(0.82 0.012 80);   /* graph paper major lines */

  /* Typography — system font stack (zero CDN fetches) */
  --font-sans:  system-ui, -apple-system, BlinkMacSystemFont,
                "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Georgia,
                "Times New Roman", serif;
  --font-mono:  ui-monospace, "SF Mono", "Cascadia Code", "Source Code Pro",
                Menlo, Consolas, monospace;
  --type-base:   1.0625rem;   /* 17px */
  --line-height: 1.65;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;

  /* Layout */
  --column:      700px;
  --column-wide: 960px;
  --gutter:      1rem;
}

/* --- Dark mode token overrides --- */

:root[data-theme="dark"] {
  --accent:       oklch(0.72 0.10 235);   /* warmer blue, dark-adapted */
  --accent-dim:   oklch(0.80 0.10 235);
  --text:         oklch(0.91 0.01 70);
  --text-muted:   oklch(0.60 0.01 70);
  --bg:           oklch(0.19 0.005 255);  /* card surface */
  --bg-outer:     oklch(0.10 0.008 255);  /* page background behind card */
  --rule:         oklch(0.28 0.010 255);
  --grid-minor:   oklch(0.14 0.004 255);  /* barely-visible texture */
  --grid-major:   oklch(0.24 0.010 255);
}

/* --- Base --- */

html {
  font-size: var(--type-base);
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-outer);
  background-image:
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size:
    24px 24px,
    24px 24px;
  background-position: center center;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: var(--line-height);
  font-variant-ligatures: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Code --- */

/* Inline code — in headings, prose, anywhere */

:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--grid-minor);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  color: var(--text);
}

/* Fenced code blocks */

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--grid-minor);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
  margin-bottom: 1.4em;
}

pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  color: var(--text);
}

/* --- Shared: section label ---
   Small metadata line. Dates, status labels, section headers. */

.section-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: normal;
  color: var(--text-muted);
}

/* --- Shared: back-nav links ---
   Used by essay, project, log-index, log-entry pages. */

.back-nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.back-nav a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Shared: page shell ---
   Single-column content pages. */

.essay,
.index,
.project,
.log-index,
.log-entry {
  max-width: var(--column-wide);
  margin-inline: auto;
  padding: var(--space-lg) var(--gutter);
  background: var(--bg);
  border: 1px solid var(--rule);
  min-height: 100vh;
}

/* Center the content column within the wide shell. */
.essay > *,
.index > *,
.project > *,
.log-index > *,
.log-entry > * {
  max-width: var(--column);
  margin-inline: auto;
}

.back-nav {
  margin-bottom: var(--space-md);
}

/* --- Shared: page title --- */

.essay-header h1,
.project-header h1,
.log-entry-header h1,
.index h1,
.log-index h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* --- Shared: prose body ---
   Essay body, project body, log entry body. */

.essay-body,
.project-body,
.log-entry-body {
  font-family: var(--font-serif);
  line-height: 1.75;
}

.essay-body p,
.project-body p,
.log-entry-body p {
  margin-bottom: 1.4em;
}

.essay-body h2,
.project-body h2,
.log-entry-body h2 {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  margin: var(--space-lg) 0 var(--space-sm);
}

.essay-body h3,
.project-body h3,
.log-entry-body h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  margin: var(--space-md) 0 var(--space-xs);
}

.essay-body hr,
.project-body hr,
.log-entry-body hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: var(--space-lg) 0;
}

.essay-body a,
.project-body a,
.log-entry-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.essay-body a:hover,
.project-body a:hover,
.log-entry-body a:hover {
  color: var(--accent-dim);
}

/* --- Shared: index entry list ---
   Writing index and projects index. */

.entry-list {
  list-style: none;
  margin-top: var(--space-md);
}

.entry {
  padding: var(--space-md) 0;
  border-top: 1px solid var(--rule);
}

.entry .section-label {
  margin-bottom: var(--space-xs);
}

.entry-title {
  font-size: 1.0625rem;
  font-weight: 400;
  margin-bottom: var(--space-xs);
}

.entry-title a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.entry-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.entry-description {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: var(--line-height);
}

/* ===================================================================
   HOME PAGE
   Two-column layout. Header constrained to --column; columns fill
   --column-wide. On narrow viewports columns stack, lead domain first.
   =================================================================== */

.home {
  max-width: var(--column-wide);
  margin-inline: auto;
  padding: var(--space-xl) var(--gutter);
  background: var(--bg);
  border: 1px solid var(--rule);
  min-height: 100vh;
}

.home-header {
  max-width: var(--column);
  margin-inline: auto;
  margin-bottom: var(--space-sm);
  text-align: center;
}

.site-logo {
  height: 80px;
  width: auto;
  margin-bottom: var(--space-sm);
  /* Light mode: black silhouette, faint depth shadow */
  filter: drop-shadow(0 1px 4px oklch(0 0 0 / 0.12));
}

[data-theme="dark"] .site-logo {
  /* Dark mode: invert to white, add halo for legibility */
  filter: invert(1) drop-shadow(0 0 5px oklch(1 0 0 / 0.22));
}

.site-title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.0;
  margin-bottom: var(--space-md);
}

.orientation {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: var(--line-height);
  max-width: 52ch;
  margin-inline: auto;
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

/* Two-column grid */

.home-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

@media (max-width: 640px) {
  .home-columns {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

.home-section {
  display: flex;
  flex-direction: column;
}

/* Section header — h2-scale heading that doubles as an index link */

.home-section > h2 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--text);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.home-section > h2 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.home-section > h2 a::after {
  content: " \2192";
  font-size: 0.8em;
  opacity: 0.35;
  transition: opacity 0.15s ease;
}

.home-section > h2 a:hover {
  color: var(--accent);
}

.home-section > h2 a:hover::after {
  opacity: 1;
}

/* Home entry items */

.home-entry-list {
  list-style: none;
}

.home-entry {
  padding-bottom: var(--space-md);
}

.home-entry + .home-entry {
  padding-top: var(--space-md);
  border-top: 1px solid var(--rule);
}

.home-entry .section-label {
  margin-bottom: 0.3rem;
}

.home-entry-title {
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.home-entry-title a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.home-entry-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.home-entry-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

/* View all link at the foot of each teaser section */

.home-section-more {
  display: inline-block;
  margin-top: auto;
  padding-top: var(--space-md);
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid oklch(from var(--accent) l c h / 0.4);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.home-section-more:hover {
  color: var(--accent-dim);
  border-bottom-color: var(--accent-dim);
}

/* Footer */

.home > .site-footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
  text-align: center;
}

/* ===================================================================
   ESSAY PAGE
   =================================================================== */

.essay-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.essay-header h1 {
  margin-bottom: var(--space-sm);
}

.essay-description {
  margin-top: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.essay-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.essay-pagination {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}

.pagination-prev,
.pagination-next {
  min-width: 0;
}

.pagination-next {
  text-align: right;
  margin-left: auto;
}

.essay-pagination a {
  font-size: 0.9375rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-block;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.essay-pagination a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===================================================================
   PROJECT PAGE
   =================================================================== */

.project-header {
  margin-bottom: var(--space-md);
}

.project-header h1 {
  margin-bottom: var(--space-sm);
}

.project-description {
  margin-top: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
  text-wrap: pretty;
}

/* Log teaser block at the bottom of project page */

.project-log-teaser {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--rule);
}

.project-log-teaser > h2 {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.project-log-teaser .entry-list {
  margin-top: 0;
}

.project-log-teaser > h2 a {
  color: inherit;
  text-decoration: none;
}

.project-log-teaser > h2 a:hover {
  color: var(--accent);
}

.project-log-teaser > a {
  display: inline-block;
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.project-log-teaser > a:hover {
  color: var(--accent-dim);
  border-bottom-color: var(--accent-dim);
}

/* ===================================================================
   LOG INDEX PAGE
   =================================================================== */

.log-index h1 {
  margin-bottom: var(--space-lg);
}

/* ===================================================================
   LOG ENTRY PAGE
   =================================================================== */

.log-entry-header {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.log-entry-header .section-label {
  margin-bottom: var(--space-xs);
}

.log-entry-header h1 {
  margin-bottom: 0;
}

/* ===================================================================
   SITE MARK
   Appears at the top of all inner pages. Crow + site name, links home.
   =================================================================== */

.site-mark {
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.site-mark a {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  text-decoration: none;
  border-bottom: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  transition: color 0.15s ease;
}

.site-mark a:hover {
  color: var(--accent);
}

.site-mark img {
  height: 14px;
  width: auto;
}

[data-theme="dark"] .site-mark img {
  filter: invert(1) opacity(0.7);
}

/* ===================================================================
   PAGE FOOTER NAV
   Bottom of all inner pages. Cross-section jump links + site footer
   in a single ruled bar.
   =================================================================== */

.section-footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.section-footer-links {
  display: flex;
  gap: var(--space-md);
}

.section-footer-links a {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: none;
  transition: color 0.15s ease;
}

.section-footer-links a:hover {
  color: var(--accent);
}

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

.site-footer {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-footer a:hover {
  color: var(--accent);
}

/* ===================================================================
   THEME TOGGLE
   Fixed button, top-right corner, visible on every page.
   =================================================================== */

.theme-toggle {
  position: fixed;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  line-height: 1;
  z-index: 100;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===================================================================
   NOT FOUND
   =================================================================== */

.not-found {
  color: var(--text-muted);
}

/* ===================================================================
   CONTACT EMAIL — scrape-resistant
   The @ symbol is only assembled in the CSS content property, never
   as a text node in HTML. data-user and data-domain are unremarkable
   in isolation; email harvesters looking for user@domain in source
   find nothing. Readable and copy-pasteable by humans in all modern
   browsers (CSS ::before content participates in selection).
   =================================================================== */

.source-contact {
  font-family: var(--font-mono);
  color: var(--accent);
}
/* No ::before — text is a real DOM node so it's selectable and copy-pasteable.
   The @ is entity-encoded (&#64;) in the HTML source; browsers decode it
   normally for display, click, and copy. Scrapers scanning for user@domain
   patterns in raw markup find nothing. */

/* ===================================================================
   DIAGRAM DSL
   Schematic SVG diagrams embedded in log entry pages.
   Visual style: geometric, schematic, no gradients.
   Theming: CSS variables only — dark/light is automatic.
   =================================================================== */

/* --- Diagram color tokens --- */

:root {
  --diag-error:      oklch(0.62 0.17 43);   /* warm amber — compile error state */
  --diag-error-fill: oklch(0.62 0.17 43 / 0.10);
  --diag-valid-fill: oklch(0.60 0.09 249 / 0.10);
  --diag-lead-fill:  oklch(0.60 0.09 249 / 0.16);
}

:root[data-theme="dark"] {
  --diag-error:      oklch(0.76 0.14 43);
  --diag-error-fill: oklch(0.76 0.14 43 / 0.12);
  --diag-valid-fill: oklch(0.72 0.10 235 / 0.12);
  --diag-lead-fill:  oklch(0.72 0.10 235 / 0.20);
}

/* --- Diagram container --- */

.diagram {
  margin: var(--space-md) auto;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--rule);
}

.diagram-caption {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: var(--space-sm);
  margin-inline: auto;
}

.diagram-svg {
  display: block;
  max-width: 480px;
  height: auto;
  overflow: visible;
  margin: 0 auto;
}

/* --- Structural base styles for SVG elements --- */

.diag-rect {
  stroke-width: 1.5;
}

.diag-circle {
  stroke-width: 0;
}

.diag-marker {
  stroke-width: 0;
}

.diag-line {
  fill: none;
  stroke-width: 2;
}

.diag-arrowhead {
  stroke: none;
}

.diag-text {
  font-family: var(--font-mono);
  font-size: 11px;
  stroke: none;
}

.diag-sublabel {
  font-size: 10px;
  opacity: 0.78;
}

.diag-track-label {
  font-size: 11px;
}

/* --- Semantic state: valid --- */

.diag-rect.diag-valid   { stroke: var(--accent); fill: var(--diag-valid-fill); }
.diag-text.diag-valid   { fill: var(--accent); }
.diag-circle.diag-valid { fill: var(--accent); stroke: none; }
.diag-marker.diag-valid { fill: var(--accent); }
.diag-line.diag-valid   { stroke: var(--accent); }
.diag-arrowhead.diag-valid { fill: var(--accent); }

/* --- Semantic state: lead --- */

.diag-rect.diag-lead   { stroke: var(--accent); fill: var(--diag-lead-fill); }
.diag-text.diag-lead   { fill: var(--accent); }
.diag-circle.diag-lead { fill: var(--accent); stroke: none; }
.diag-marker.diag-lead { fill: var(--accent); }
.diag-line.diag-lead   { stroke: var(--accent); }
.diag-arrowhead.diag-lead { fill: var(--accent); }

/* --- Semantic state: draft (dashed border, muted) --- */

.diag-rect.diag-draft   { stroke: var(--text-muted); fill: transparent; stroke-dasharray: 5 3; }
.diag-text.diag-draft   { fill: var(--text-muted); }
.diag-circle.diag-draft { fill: var(--text-muted); stroke: none; }
.diag-marker.diag-draft { fill: var(--text-muted); }
.diag-line.diag-draft   { stroke: var(--text-muted); stroke-dasharray: 5 3; }
.diag-arrowhead.diag-draft { fill: var(--text-muted); }

/* --- Semantic state: error (warm amber) --- */

.diag-rect.diag-error   { stroke: var(--diag-error); fill: var(--diag-error-fill); }
.diag-text.diag-error   { fill: var(--diag-error); }
.diag-circle.diag-error { fill: var(--diag-error); stroke: none; }
.diag-marker.diag-error { fill: var(--diag-error); }
.diag-line.diag-error   { stroke: var(--diag-error); }
.diag-arrowhead.diag-error { fill: var(--diag-error); }

/* --- Semantic state: muted (faint) --- */

.diag-rect.diag-muted   { stroke: var(--rule); fill: var(--grid-minor); }
.diag-text.diag-muted   { fill: var(--text-muted); }
.diag-circle.diag-muted { fill: var(--text-muted); stroke: none; }
.diag-marker.diag-muted { fill: var(--text-muted); }
.diag-line.diag-muted   { stroke: var(--text-muted); }
.diag-arrowhead.diag-muted { fill: var(--text-muted); }

