/* ==========================================================================
   Horville Labs — Research, experiments & software
   Design: dark, elegant, experimental — no framework, no build step.
   ========================================================================== */

:root {
  --bg: #0d0f11;
  --bg-soft: #101315;
  --surface: rgba(255, 255, 255, 0.025);
  --surface-strong: #14171a;
  --line: rgba(233, 231, 226, 0.09);
  --line-strong: rgba(233, 231, 226, 0.18);
  --text: #e9e7e2;
  --muted: #9ba3ab;
  --faint: #6f767e;
  --accent: #d9a05b;
  --accent-strong: #e8b273;
  --accent-ink: #17110a;
  --accent-soft: rgba(217, 160, 91, 0.1);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --radius: 16px;
  --container: 1120px;
  --header-h: 68px;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* ---------- Reset & base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  scrollbar-color: #2a2f34 var(--bg);
  scrollbar-width: thin;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(233, 231, 226, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 231, 226, 0.025) 1px, transparent 1px),
    radial-gradient(
      1100px 650px at 80% -10%,
      rgba(217, 160, 91, 0.07),
      transparent 65%
    );
  background-size: 44px 44px, 44px 44px, 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: rgba(217, 160, 91, 0.32);
  color: #fff;
}

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

.container {
  width: min(var(--container), 100% - 2.5rem);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.7rem 1.1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
}

.skip-link:focus {
  top: 0;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-header.is-scrolled {
  background-color: rgba(13, 15, 17, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
}

.brand-mark-accent {
  stroke: var(--accent);
}

.brand-name {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-name em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 1.9rem);
}

.nav-list a {
  position: relative;
  display: inline-block;
  padding: 0.35rem 0;
  font-size: 0.92rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s ease;
}

.nav-list a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.nav-list a:hover,
.nav-list a:focus-visible,
.nav-list a[aria-current="true"] {
  color: var(--text);
}

.nav-list a:hover::after,
.nav-list a:focus-visible::after,
.nav-list a[aria-current="true"]::after {
  width: 100%;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  transition: transform 0.3s var(--ease), opacity 0.2s ease;
}

.nav-toggle-bar {
  position: relative;
}

.nav-toggle-bar::before,
.nav-toggle-bar::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-bar::before {
  top: -6px;
}

.nav-toggle-bar::after {
  top: 6px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: min(86vh, 920px);
  padding: clamp(4rem, 10vh, 7rem) 0;
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-graphic {
  position: absolute;
  top: 50%;
  right: max(-70px, -5vw);
  width: clamp(360px, 42vw, 540px);
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.4rem;
}

.hero-title {
  font-size: clamp(3rem, 9.5vw, 5.75rem);
  line-height: 1;
  letter-spacing: -0.025em;
}

.hero-subtitle {
  margin-top: 1.1rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  color: var(--muted);
}

.hero-lead {
  max-width: 54ch;
  margin-top: 1.6rem;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2.2rem;
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 2.4rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--faint);
}

/* Hero graphic elements */

.hg-ring {
  fill: none;
  stroke: rgba(233, 231, 226, 0.1);
  stroke-width: 1;
}

.hg-tick {
  fill: none;
  stroke: rgba(233, 231, 226, 0.28);
  stroke-width: 2;
}

.hg-orbit {
  transform-box: view-box;
  transform-origin: 50% 50%;
}

.hg-orbit--a {
  animation: hg-spin 44s linear infinite;
}

.hg-orbit--b {
  animation: hg-spin 76s linear infinite reverse;
}

.hg-node {
  fill: var(--accent);
}

.hg-node--soft {
  fill: rgba(233, 231, 226, 0.55);
}

.hg-spoke {
  stroke: rgba(217, 160, 91, 0.35);
  stroke-width: 1;
}

.hg-spoke--soft {
  stroke: rgba(233, 231, 226, 0.12);
}

.hg-core {
  fill: var(--accent);
}

.hg-halo {
  fill: none;
  stroke: rgba(217, 160, 91, 0.4);
  stroke-width: 1;
  animation: hg-breathe 4.5s ease-in-out infinite;
}

@keyframes hg-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hg-breathe {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s ease, border-color 0.25s ease,
    color 0.25s ease, transform 0.25s var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn-ghost {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* ---------- Sections ---------- */

.section {
  position: relative;
  padding: clamp(4.5rem, 11vh, 7.5rem) 0;
  scroll-margin-top: calc(var(--header-h) + 8px);
}

.section--soft {
  background-color: rgba(255, 255, 255, 0.018);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-head {
  max-width: 62ch;
  margin-bottom: clamp(2.5rem, 5vh, 3.5rem);
}

.section-index {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.24em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.section-head h2 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  margin-bottom: 0.9rem;
}

.section-lead {
  color: var(--muted);
  line-height: 1.75;
  font-size: 1.02rem;
}

.section-note {
  margin-top: 2.2rem;
  color: var(--faint);
  font-size: 0.95rem;
  font-style: italic;
}

.section-note::before {
  content: "— ";
  color: var(--accent);
  font-style: normal;
}

/* ---------- Cards (projects, notes) ---------- */

.project-grid,
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.25rem;
}

.project-grid > li,
.notes-grid > li {
  display: flex;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  padding: clamp(1.4rem, 3vw, 1.9rem);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.035),
    rgba(255, 255, 255, 0.012)
  );
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s ease, transform 0.3s var(--ease),
    background-color 0.3s ease;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 65%);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
}

.card:hover::before {
  opacity: 0.85;
}

.card-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 2.8s ease-out infinite;
}

@keyframes dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 160, 91, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(217, 160, 91, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 160, 91, 0);
  }
}

.card-title {
  font-size: 1.45rem;
  margin-bottom: 0.7rem;
}

.card-text {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.card-meta {
  margin-top: auto;
  padding-top: 1.2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.card-meta::before {
  content: "";
  display: block;
  margin-bottom: 1rem;
  border-top: 1px dashed var(--line);
}

.badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.32rem 0.75rem;
  margin-bottom: 1.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(217, 160, 91, 0.28);
  border-radius: 999px;
}

.note-card {
  background: rgba(255, 255, 255, 0.012);
  border-style: dashed;
}

/* ---------- Research axes ---------- */

.axes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  column-gap: clamp(1.5rem, 4vw, 3rem);
  row-gap: 0;
}

.axis {
  position: relative;
  padding: 1.5rem 0 1.75rem;
  border-top: 1px solid var(--line);
}

.axis::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 42px;
  height: 1px;
  background: var(--accent);
}

.axis h3 {
  font-size: 1.2rem;
  margin-bottom: 0.55rem;
}

.axis p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
}

/* ---------- Split: lab & OnPremSoftware ---------- */

.split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

.split-text h3 {
  font-size: 1.55rem;
  margin-bottom: 1.1rem;
}

.split-text p {
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 1.1rem;
  max-width: 58ch;
}

.split-text strong {
  color: var(--text);
}

.split-note {
  padding-left: 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--text) !important;
}

.link-card {
  position: relative;
  padding: clamp(1.5rem, 3vw, 2rem);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.link-card::after {
  content: "";
  position: absolute;
  top: -55px;
  right: -55px;
  width: 170px;
  height: 170px;
  background: radial-gradient(
    circle,
    rgba(217, 160, 91, 0.2),
    transparent 70%
  );
  pointer-events: none;
}

.link-card-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.link-card-name {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.link-card-text {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  transition: gap 0.25s var(--ease), color 0.25s ease;
}

.link-arrow:hover {
  gap: 0.85rem;
  color: var(--accent-strong);
}

/* ---------- About ---------- */

.about {
  max-width: 68ch;
}

.about p {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.85;
  margin-bottom: 1.3rem;
}

.about strong {
  color: var(--text);
}

.about p a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.25s ease;
}

.about p a:hover {
  color: var(--accent);
}

.about .btn {
  margin-top: 0.6rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background-color: rgba(11, 13, 15, 0.9);
  padding: 3rem 0 2.5rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem 3rem;
  align-items: flex-start;
  justify-content: space-between;
}

.footer-name {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
}

.footer-tag {
  margin-top: 0.3rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--faint);
}

.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
}

.footer-nav a,
.footer-links a {
  font-size: 0.92rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.25s ease;
}

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

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: right;
}

.footer-copy {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.footer-sep {
  color: var(--accent);
}

/* ---------- Scroll reveal (JS only) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.project-grid > .reveal:nth-child(2),
.notes-grid > .reveal:nth-child(2),
.axes-grid > .reveal:nth-child(2) {
  transition-delay: 0.08s;
}

.notes-grid > .reveal:nth-child(3),
.axes-grid > .reveal:nth-child(3) {
  transition-delay: 0.16s;
}

.axes-grid > .reveal:nth-child(4) {
  transition-delay: 0.24s;
}

.axes-grid > .reveal:nth-child(5) {
  transition-delay: 0.32s;
}

.axes-grid > .reveal:nth-child(6) {
  transition-delay: 0.4s;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .hero-graphic {
    right: -16vw;
    width: 72vw;
    opacity: 0.22;
  }

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

  .footer-links {
    text-align: left;
  }
}

@media (max-width: 860px) {
  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.4rem 1.25rem 1.2rem;
    background-color: rgba(13, 15, 17, 0.97);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }

  .site-nav.is-open {
    display: block;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav-list a {
    display: block;
    padding: 0.9rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--line);
  }

  .nav-list li:last-child a {
    border-bottom: 0;
  }

  .nav-list a::after {
    display: none;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(var(--container), 100% - 1.75rem);
  }

  .hero {
    min-height: auto;
    padding-top: clamp(3rem, 8vh, 5rem);
  }

  .hero-graphic {
    display: none;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
  }

  .footer-inner {
    flex-direction: column;
    gap: 1.5rem;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
