/* ============================================================
   style.css — Tessera brand theme.
   To re-skin the whole site (e.g., switch to the Cairn or
   Operant palette), change the variables in :root below.
   Everything else references them.
   ============================================================ */

:root {
  /* Tessera palette */
  --ink: #01161e;        /* deep ink — hero bg, body text */
  --ink-2: #062430;      /* slightly lifted ink — panel bg */
  --teal: #124559;       /* deep teal — headings */
  --steel: #598392;      /* steel teal — secondary text, borders */
  --sage: #aec3b0;       /* soft neutral */
  --mist: #eff6e0;       /* light background */
  --amber: #d98c3f;      /* the one accent — CTAs only */

  --card: #f9fcf0;       /* card surface on mist */
  --line: rgba(18, 69, 89, 0.14);

  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --maxw: 1060px;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--mist);
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; }
a { color: var(--teal); }
p { margin: 0 0 1em; }

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

/* ===== Nav ===== */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(20px, 4vw, 48px);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.nav.scrolled {
  background: rgba(1, 22, 30, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(239, 246, 224, 0.08);
}
.nav-brand {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--mist);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.nav-brand-dot { color: var(--amber); }
.nav-links { display: flex; align-items: center; gap: clamp(14px, 2.5vw, 28px); }
.nav-links a {
  color: rgba(239, 246, 224, 0.78);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
}
.nav-links a:hover { color: var(--mist); }
.nav-links .nav-cta {
  color: var(--ink);
  background: var(--amber);
  padding: 7px 16px;
  border-radius: 99px;
}
.nav-links .nav-cta:hover { color: var(--ink); filter: brightness(1.07); }

/* ===== Hero ===== */
.hero {
  position: relative;
  min-height: 100svh;
  background:
    radial-gradient(900px 600px at 68% 45%, rgba(18, 69, 89, 0.55), transparent 65%),
    radial-gradient(700px 500px at 15% 85%, rgba(89, 131, 146, 0.18), transparent 60%),
    var(--ink);
  overflow: hidden;
  color: var(--mist);
}
.graph-wrap, #graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#graph { display: block; touch-action: pan-y; }

.hero-copy {
  position: relative;
  z-index: 5;
  max-width: 460px;
  padding: clamp(96px, 16vh, 160px) clamp(20px, 4vw, 48px) 0;
  pointer-events: none;   /* let graph drags pass through the empty space… */
}
.hero-copy a { pointer-events: auto; }  /* …but keep buttons clickable */

.hero-kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin-bottom: 14px;
}
.hero-title {
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 700;
  color: var(--mist);
  margin-bottom: 16px;
}
.hero-sub {
  color: rgba(239, 246, 224, 0.72);
  font-size: 16px;
  margin-bottom: 26px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-hint {
  position: absolute;
  z-index: 5;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(239, 246, 224, 0.45);
  pointer-events: none;
  white-space: nowrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  padding: 11px 22px;
  border-radius: 99px;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--amber); color: var(--ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost {
  color: var(--mist);
  border: 1px solid rgba(239, 246, 224, 0.35);
}
.btn-ghost:hover { border-color: rgba(239, 246, 224, 0.7); }
.btn-lg { padding: 14px 30px; font-size: 16.5px; }
.btn-outline {
  color: var(--teal);
  border: 1.5px solid var(--teal);
  background: transparent;
}
.btn-outline:hover { background: rgba(18, 69, 89, 0.07); }

.contact-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ===== Graph nodes (SVG) ===== */
.gnode { cursor: pointer; }
.gnode circle { transition: opacity 0.25s ease; }
.gnode text {
  font-family: var(--font-mono);
  fill: rgba(239, 246, 224, 0.78);
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.gnode.hub text {
  font-family: var(--font-head);
  font-weight: 700;
  fill: var(--mist);
}
.gnode.center text {
  font-family: var(--font-head);
  font-weight: 700;
  fill: var(--ink);
}
.gnode:focus-visible { outline: none; }
.gnode:focus-visible circle { stroke: var(--amber); stroke-width: 2.5px; }
.glink { transition: stroke 0.25s ease, stroke-opacity 0.25s ease; }

.graph-dim .gnode:not(.lit) circle,
.graph-dim .gnode:not(.lit) text { opacity: 0.13; }
.graph-dim .glink { stroke-opacity: 0.05; }
.graph-dim .glink.lit { stroke-opacity: 0.9; }

/* ===== Detail panel ===== */
.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(1, 22, 30, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.panel-backdrop.open { opacity: 1; }

.panel {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(430px, 100%);
  background: var(--ink-2);
  color: var(--mist);
  padding: 56px 34px 40px;
  overflow-y: auto;
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.24, 1);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35);
}
.panel.open { transform: translateX(0); }

.panel-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(239, 246, 224, 0.08);
  color: var(--mist);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.panel-close:hover { background: rgba(239, 246, 224, 0.16); }

.panel-kind {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.panel-title { font-size: 26px; margin-bottom: 18px; color: var(--mist); }
.panel-body p { color: rgba(239, 246, 224, 0.82); font-size: 15.5px; }
.panel-body a { color: var(--amber); }

.panel-list { list-style: none; margin: 0; padding: 0; }
.panel-list li { margin-bottom: 4px; }
.panel-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--mist);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
}
.panel-list button:hover { background: rgba(239, 246, 224, 0.07); }
.panel-list .panel-list-kind {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--steel);
}

.panel-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.panel-tags span {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 99px;
  border: 1px solid rgba(239, 246, 224, 0.22);
  color: rgba(239, 246, 224, 0.7);
}

/* ===== Sections ===== */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(70px, 10vw, 110px) clamp(20px, 4vw, 48px);
}
.section-alt {
  max-width: none;
  background: linear-gradient(rgba(174, 195, 176, 0.28), rgba(174, 195, 176, 0.28));
}
.section-alt > * { max-width: var(--maxw); margin-left: auto; margin-right: auto; }

.section-kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin-bottom: 8px;
}
.section-title {
  font-size: clamp(28px, 3.6vw, 38px);
  color: var(--teal);
  margin-bottom: 14px;
}
.section-intro { color: var(--steel); max-width: 560px; margin-bottom: 34px; }

/* ===== Work list ===== */
.work-group { margin-bottom: 44px; }
.work-group-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.work-group-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  align-self: center;
}
.work-group-title { font-size: 21px; color: var(--ink); }
.work-group-tag { color: var(--steel); font-size: 14px; margin-bottom: 18px; }

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.work-card {
  text-align: left;
  font-family: var(--font-body);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--wc, var(--steel));
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.work-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(18, 69, 89, 0.12);
}
.work-card-kind {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--steel);
  display: block;
  margin-bottom: 6px;
}
.work-card-title { font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.work-card-summary { font-size: 14px; color: rgba(1, 22, 30, 0.72); margin: 0; }

/* ===== Services ===== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 30px;
}
.service {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 22px;
}
.service-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-bottom: 14px;
}
.service h3 { font-size: 18px; color: var(--teal); margin-bottom: 8px; }
.service p { font-size: 14.5px; color: rgba(1, 22, 30, 0.75); margin: 0; }

/* ===== About ===== */
.about-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  margin-top: 10px;
}
.about-text p { color: rgba(1, 22, 30, 0.82); }
.about-stats { display: grid; gap: 14px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  color: var(--teal);
}
.stat-label { font-size: 13.5px; color: var(--steel); }

/* ===== Contact ===== */
.section-contact { text-align: center; }
.section-contact .section-intro { margin: 0 auto 34px; }
.contact-line { max-width: 480px; margin: 0 auto 30px; color: rgba(1, 22, 30, 0.8); }
.contact-meta {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--steel);
}

/* ===== Footer ===== */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px clamp(20px, 4vw, 48px) 34px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--steel);
}
.footer a { color: var(--steel); }

/* ===== Stacked layout (tablets & phones) =====
   Breakpoint must match isMobile() in app.js. */
@media (max-width: 879px) {
  .hero {
    display: flex;
    flex-direction: column;
    padding-bottom: 44px;
  }
  .hero-copy {
    max-width: 560px;
    margin: 0 auto;
    padding-top: 96px;
    text-align: center;
  }
  .hero-actions { justify-content: center; }
  /* The graph gets its own box below the copy instead of
     floating behind it */
  .graph-wrap {
    position: relative;
    inset: auto;
    width: 100%;
    height: clamp(380px, 58svh, 560px);
    margin-top: 8px;
  }
  .about-grid { grid-template-columns: 1fr; }
}

/* ===== Phones ===== */
@media (max-width: 640px) {
  .about-stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 14px 10px; text-align: center; }
  .stat-value { font-size: 20px; }
  .nav-links a:not(.nav-cta) { display: none; }  /* keep nav minimal on phones */

  /* Panel becomes a bottom sheet */
  .panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(82dvh, 640px);
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
    padding: 48px 24px 36px;
  }
  .panel.open { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
